Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: Cycerin on December 12, 2012, 02:50:13 AM

Title: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 12, 2012, 02:50:13 AM
I often have small questions that I don't feel deserve a thread of their own, and I don't think I'm alone. A thread like this could be useful and make sure the forum doesn't get clogged up.

To start us off:
Would it be possible to make a Guardian PD-style beam weapon where each offset beam fires in turn, like alternating barrels on a projectile weapon?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on December 12, 2012, 08:03:13 AM
On the *.weapon file:

Code
"barrelMode":"ALTERNATING", # or LINKED. whether barrels fire at the same time or alternate.

On the CSV file:
adding a tiny "burst delay" to make it fire once every X.X seconds
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 12, 2012, 09:35:54 AM
I tried that, but it doesn't look like barrelMode does anything in this case. Maybe it only works on projectile-type weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 09:55:42 AM
Yeah, beams ignore the "barrelMode" setting. To answer the original question: not possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 10:06:12 AM
Yeah, beams ignore the "barrelMode" setting. To answer the original question: not possible.
Is there any possibility to make a way to allow the creation of minigun lasers? Pretty much an assault chain gun but with lasers?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Reshy on December 12, 2012, 10:12:19 AM
Yeah, beams ignore the "barrelMode" setting. To answer the original question: not possible.
Is there any possibility to make a way to allow the creation of minigun lasers? Pretty much an assault chain gun but with lasers?


Like a burst PD chain gun?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on December 12, 2012, 11:30:49 AM
Well i made a "blaster" cannon out of it on Star Treker, theres quite a few on alot a mods out there, you just create a really cool white (and long) projectile then add some color glow effects and "fake" a laser blast
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 12:39:00 PM
Yeah, beams ignore the "barrelMode" setting. To answer the original question: not possible.
Is there any possibility to make a way to allow the creation of minigun lasers? Pretty much an assault chain gun but with lasers?


Like a burst PD chain gun?

yes! :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 02:43:31 PM
Yeah, beams ignore the "barrelMode" setting. To answer the original question: not possible.
Is there any possibility to make a way to allow the creation of minigun lasers? Pretty much an assault chain gun but with lasers?


Like a burst PD chain gun?

yes! :D

Can't right now - only projectile weapons can be animated. But, oh, why not - actually a pretty simple change, just added it. A beam gatling gun is just too cool a concept to pass up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: arcibalde on December 12, 2012, 02:46:12 PM
LOOOOOL  ;D ;D ;D     Alex you ARE kid (inside  :P)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on December 12, 2012, 02:47:44 PM
Wait, we can have a beam gatling gun?  Like shooting beams from different spots each time it fires?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 02:49:14 PM
No. But it can now have an animated barrel, a la the Assault Chaingun or the Thumper.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on December 12, 2012, 02:50:35 PM
Damn.

Still has it's usefulness, though, I suppose.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 02:53:20 PM
Alex.
Spoiler
I love you
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 02:54:29 PM
Can it also rapid fire too? Like a burst delay of 0.05 and a small spread?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 03:09:49 PM
Can it also rapid fire too? Like a burst delay of 0.05 and a small spread?

Rapid fire, sure. No spread for beam weapons, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 03:22:22 PM
Can it also rapid fire too? Like a burst delay of 0.05 and a small spread?

Rapid fire, sure. No spread for beam weapons, though.
Aww darn, had plans for a hull stripper, rapid fire, wide spread ballistic energy weapon that works like a lightning arc gun that wipes out armor
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 03:32:33 PM
Ah. Probably better off with a pulse laser type, then. If you make the projectiles really long, it almost looks like beams. Has an interesting look to it, anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 03:40:38 PM
Ah. Probably better off with a pulse laser type, then. If you make the projectiles really long, it almost looks like beams. Has an interesting look to it, anyway.
Shall have to try, and the possibility of beams applying force to objects it hits? Like a massive bomb knocking back ships?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 03:44:15 PM
No - not something the engine supports.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 03:45:11 PM
No - not something the engine supports.
Ah bugger, and my old beam shape suggestion a while back that you liked?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 03:48:01 PM
Link?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 03:49:08 PM
Link?
Shall take a look and edit this post

Edit:
http://fractalsoftworks.com/forum/index.php?topic=3396.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 03:57:48 PM
Oh. I'm fairly certain whatever I told you boiled down to "interesting, but no" :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 04:00:06 PM
Oh. I'm fairly certain whatever I told you boiled down to "interesting, but no" :)
Ah, okie dokie
And sorry for the bump, it was to make sure I didn lose the page as I'm on my phone and the battery is almost dead
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 04:01:02 PM
Oh, ok, fair enough.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 12, 2012, 04:02:09 PM
Oh, ok, fair enough.
Regardless, my apologies, and is there to be a new upcoming features list? Or what do you plan on doing for the next release? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2012, 04:03:45 PM
As usual, no - the first you'll see of it will be in the new patch notes. I will say that there's an 0.54.1a in the works, though.

Let's try to keep this on topic - it's a good idea for a thread.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on December 12, 2012, 06:13:14 PM
I've already deduced that there's no decent way to make a single beam weapon fire multiple beams from multiple barrels alternating, but what about a single barreled beam weapon firing a beams that could start before the first one finished? A stacking sort of effect,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 12, 2012, 09:35:29 PM
Maybe through power-up vs. cooldown rates?  Or just do a burst?

I agree that multi-barrel behaviors that can do ALTERNATE would be very cool, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on December 13, 2012, 02:22:49 AM
Is it possible to use skillpoints to influence campaign things like factions relationship? Is it possible to not spend skill points or get them refunded?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on December 13, 2012, 07:17:47 AM
Might be possible by creating a new skill called Diplomatic and an algoritm that when you affect a factions rep, it goes tro that algoritm, for example, you reputation with [faction] was increased by return (100 * 1.1) -> (bonus 10%).

Again it might be possible by creating a script on the systems script, same way we got those faction rep resets, you should be able to reset the skill points when you "buy" a certain item on a station for example.

Note: I havent messed around with the skill system enough to be 100% sure, but im fairly optimistic...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on December 13, 2012, 08:05:30 AM
Anyone interested trying to figure that out with me you can have my Skype (PM me).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on December 15, 2012, 09:42:29 AM
Spoiler
Not sure if this would warrent it's own thread, but I don't feel like it would..

So, I'm trying to create my own shipsystem, a new drone one..

I got the drones working and all that, but they are not using the weapons I set in the variant file..

they get a machinegun whenever I go into game.. and i cannot figure out why.

I have triple checked that the variant file is in the right place, /data/variants/drones

I have double checked all the names and they are identical, no caps no spaces, its just one word.

the WS numbers are identical in both .ship and variant file..

in data/hulls I've added:
Ship_data with only my drone in it.
.ship file for my drones

in data/variants/drones I've added:
.variant file

in data/shipsystems I've added
ship_systems file with my drone system
.system file for my drones

As mentioned, the drones appear and work in game, it's just their weapons that are not what I set them to.

does the game not recognize them as drones and I need to place the variant file in the data/variant folder?
[close]

EDIT: ok, so found where the variant used was defined, which did it :)

Title: NEW QUESTION
Post by: maximilianyuen on December 16, 2012, 12:09:07 AM
Got a quick question:

Think of a kamikaze cargo ship which use the destruction blast as a weapon, obviously.

What factor determine the radius as well as the destruction power of such ship?

simply making it a capital class does not do the job ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on December 16, 2012, 03:37:08 AM
I got another very intresting question..

what would cause this?

(WARNING, MASSIVE WALL OF TEXT)
Spoiler
at java.util.Arrays.mergeSort(Arrays.java:1270)
   at java.util.Arrays.mergeSort(Arrays.java:1281)
   at java.util.Arrays.mergeSort(Arrays.java:1282)
   at java.util.Arrays.mergeSort(Arrays.java:1281)
   at java.util.Arrays.sort(Arrays.java:1210)
   at java.util.Collections.sort(Collections.java:159)
   at com.fs.starfarer.campaign.fleet.FleetData.for.return$Object(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
[close]
Just to give you an idea, in the log file that continues for 1017 lines!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2012, 05:30:58 PM
What factor determine the radius as well as the destruction power of such ship?

simply making it a capital class does not do the job ???

Flux capacity for the explosion's damage and collisionRadius for its radius.


@Plasmatic: Eugh. That's what you call "infinite recursion", not sure what's actually causing it in this case, though. Looking at the code, doesn't seem possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MCWarhammer on December 16, 2012, 06:05:18 PM
Basic Java question, but what would be the opposite of ".equals()" in this instance?

Code
if (station.getName().toString().equals("Corporate HQ")){
                                    restockShips(aMothFleet,tShips);
                                    restockFighters(aMothFleet,tWings);

What I'm trying to do is replace it with the Neutral Serenity station so that the Restock mod doesn't feed into it, because it's only purpose is to reset allegiances.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on December 17, 2012, 02:32:09 AM
What factor determine the radius as well as the destruction power of such ship?

simply making it a capital class does not do the job ???

Flux capacity for the explosion's damage and collisionRadius for its radius.


@Plasmatic: Eugh. That's what you call "infinite recursion", not sure what's actually causing it in this case, though. Looking at the code, doesn't seem possible.

If it helps I have a couple mods installed and I cannot seem to replicated the error. (was in battle and all enemies were destroyed but battle did not end, hit esc and said to autocomplete, and boom, crash)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on December 17, 2012, 06:13:21 AM
What factor determine the radius as well as the destruction power of such ship?

simply making it a capital class does not do the job ???

Flux capacity for the explosion's damage and collisionRadius for its radius.


@Plasmatic: Eugh. That's what you call "infinite recursion", not sure what's actually causing it in this case, though. Looking at the code, doesn't seem possible.

When you have ruled out all other possibilities, what's left, no matter how inconceivable, must be the answer
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on December 17, 2012, 06:43:07 AM
I got another very intresting question..

what would cause this?

(WARNING, MASSIVE WALL OF TEXT)
Spoiler
at java.util.Arrays.mergeSort(Arrays.java:1270)
   at java.util.Arrays.mergeSort(Arrays.java:1281)
   at java.util.Arrays.mergeSort(Arrays.java:1282)
   at java.util.Arrays.mergeSort(Arrays.java:1281)
   at java.util.Arrays.sort(Arrays.java:1210)
   at java.util.Collections.sort(Collections.java:159)
   at com.fs.starfarer.campaign.fleet.FleetData.for.return$Object(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.Ò0Ö000(Unknown Source)
[close]
Just to give you an idea, in the log file that continues for 1017 lines!

We wont know until you post the actual error that caused it all. should be named [Thread 6] Error or something, you will find it above the "at" lines near the bottom.
Title: Concerning asteroidbelts
Post by: Thule on December 17, 2012, 08:16:48 AM
I am sure someone already figured out the variables for asteroidbelts

1. anchorpoint
2. ???
3. orbital radius of the belt
4. the width of the belt
5. ???
6. ???

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on December 17, 2012, 08:40:26 AM
1. Anchor point.
2. How many asteroids the belt contains.
3. Orbital distance between the belt and the object it orbits.
4. Belt width.
5. Minimal asteroid orbit speed.
6. Maximum asteroid orbit speed.

 ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on December 17, 2012, 08:46:42 AM
thank you very much
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MCWarhammer on December 17, 2012, 04:25:00 PM
I'm having problems with my U'sC version of the restock mod. Every time I try to start up Starfarer it crashes because of a compile error, and pops this in the logs:

12/17/12 4:19:54.076 PM [0x0-0xc8cc8c].com.Fractal Softworks LLC.Starfarer.Starfarer: Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/world/corvus/RestockSpawnPoint.java, Line 388, Column 13: Unexpected token "private" in primary

The code is here: https://github.com/JSCleveland/Restock-Mod-for-Uomoz-Corvus/blob/d5b807ac47113546d07812d33d2dd9e8dcfe2eb3/data/scripts/world/corvus/RestockSpawnPoint.java (https://github.com/JSCleveland/Restock-Mod-for-Uomoz-Corvus/blob/d5b807ac47113546d07812d33d2dd9e8dcfe2eb3/data/scripts/world/corvus/RestockSpawnPoint.java)

EDIT:

Problem solved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on December 19, 2012, 08:54:46 AM
What factor determine the radius as well as the destruction power of such ship?

simply making it a capital class does not do the job ???

Flux capacity for the explosion's damage and collisionRadius for its radius.


@Plasmatic: Eugh. That's what you call "infinite recursion", not sure what's actually causing it in this case, though. Looking at the code, doesn't seem possible.

Thanks Admiral :!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 26, 2012, 10:52:11 AM
Okay, I have this multi-offset beam weapon that can't hit missiles. Specifically, it seems to aim just to the side of them by a few pixels. Either way, it does roughly 400 fragmentation damage in one burst, which as far as I know, is enough to one-shot any missile, and even so, it often wastes several shots on one missile without doing anything to it. Doesn't matter what kind of missile. Sometimes it seems to be able to destroy them, usually when there is little transversal velocity involved. It hits fighters just fine.

Code
	"id":"brburst",  # this id must match what's in the spreadsheet
"specClass":"beam",
"type":"ENERGY",
"size":"MEDIUM",
"displayArcRadius":600,
"turretSprite":"graphics/weapons/arguspd_turret_base.png",
"turretGlowSprite":"graphics/weapons/arguspd_turretglow.png",
"hardpointSprite":"graphics/weapons/burstpd_hardpoint_base.png",
"hardpointGlowSprite":"graphics/weapons/burstpd_hardpoint_glow.png",
"glowColor":[190,205,52,255],
"hardpointOffsets":[12, -9, 12, 9, 12, 0],
"turretOffsets":[8, -9, 8, 9, 8, 0],
"hardpointAngleOffsets":[0, 0, 0],
"turretAngleOffsets":[0, 0, 0],
"convergeOnPoint":true,
"fringeColor":[231,251,91,175],
"coreColor":[86,96,46,255],
"darkCore":false,
"width":6.0,
"textureType":SMOOTH,
#"textureType":["graphics/fx/emp_arcs.png","graphics/fx/emp_arcs.png"],
"textureScrollSpeed":292.0,
"pixelsPerTexel":5.0,
"fireSoundOne":"beam_light_burst_1",
"fireSoundTwo":"beam_light_loop",

I'm not sure if it's a rounding error or something, but it's pretty much identical to the Guardian PD except it only has three beam offsets in total.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 26, 2012, 10:55:38 AM
I'd look into beam speed and possibly turret turn rate - the comment on low transverse velocity makes it sound like it's firing at where the missile was and thus missing.  (Obviously, if it has the same values here as the Guardian, then there's something else off.  But "pretty much identical" implies some possibility of variance, so I figured this was worth mentioning.)

Edit: You'll find these values in the weapons spreadsheet, rather than the file you edited it above.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 26, 2012, 11:06:52 AM
I know. The beam speed is 100000 (i've tried several different speeds with no real change) and the chargeup has been shifted around too to try to troubleshoot. From 0 to 0.1 and so on. I'm pretty sure it's just the fact that it has three offsets that screws everything up. I thought I fixed it when I changed the offsets from odd to even numbers, but it was just a fluke.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 26, 2012, 11:13:07 AM
Huh.  Well, next thing to try: save a copy, and then edit the guardian to have those specific offsets, see how it behaves.  If it starts missing, then it's definitely the offsets.  If not, then there's something else going on.  I'd try it myself, but I'm not at a machine where I can run the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2012, 11:18:20 AM
There's a bug with the Guardian where it won't re-target quickly enough, wasting shots on an already-dead missile (i.e., firing at the spot where it used to be.)

But, this thing is medum (the Guardian bug was related to it being large)... so it really ought to behave the same way the Heavy Burst laser does. Having extra offsets shouldn't matter, as long as one of them is centered. A quick way to verify would be to convert it to single-beam and try it that way to see if that makes a difference.

The turn rate of the weapon is something else I'd look at.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 26, 2012, 11:57:23 AM
It doesn't matter what turn speed I use, that was one of the first things I tried to change. I verified that the problem is specifically due to the fact that it has off-centered offsets. If I set all the offsets to 0, the beam aims at the center of incoming missiles and destroys them. With three offsets, two to each side and one in the center, it does the weird "i am not aiming right at the missile" thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 26, 2012, 12:05:05 PM
Oh hey.  Here's a random thought: does it matter what order the offsets are in?  If you put the one with zero first, for example, does that change the behavior any?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2012, 12:06:26 PM
Good call. Was just about to post this - the Guardian-style ("convergeOnPoint") beams use the first offset as the centerline to aim along.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 26, 2012, 12:07:59 PM
Yeah, good call! That was the problem. Thanks alot, you two. ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CopperCoyote on December 26, 2012, 12:59:30 PM
Is there a mod that decreases the frequency of the various supply convoys? Right now Corvus is so busy that the ships and weapons pile up faster than my green crews and I can lose them. I'd like it to feel more like a scavenger world(solarsystem?) than it currently does.

Alternatively is that something i can just edit by hand in the save file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on December 27, 2012, 12:52:50 AM
Is there a mod that decreases the frequency of the various supply convoys? Right now Corvus is so busy that the ships and weapons pile up faster than my green crews and I can lose them. I'd like it to feel more like a scavenger world(solarsystem?) than it currently does.

Alternatively is that something i can just edit by hand in the save file?

Open up that save's campaign.xml and search for HegemonyConvoySpawnPoint. Change <daysInterval> to whatever you like for that and the following two spawn points (PiratePlunderFleetSpawnPoint and TriTachyonSupplyFleetSpawnPoint).

If you want this to be permanent, you would need to make a simple mod that replaces data/scripts/world/corvus/Corvus.java (just make a mod folder with a mod_info.json* and a copy of Corvus.java in the correct folder). At the end of the generate() method in Corvus.java, there are three lines that create the convoy spawn points. The third argument (after sector and system) is the interval in days between spawns, so that's what you would need to change.

If you use the second method, you'd need to start a new game to see the changes (or just use the first method to get the changes in your current game).

* Example mod_info.json:
Spoiler
Quote
{
  "id":"lessconvoys",
  "name":"Less Frequent Convoy Spawns",
  "author":"CopperCoyote",
  "version":"1.0",
  "description":"Lowers the amount of convoys spawned in the sector.",
  "gameVersion":"0.54",
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 27, 2012, 09:57:38 AM
Good call. Was just about to post this - the Guardian-style ("convergeOnPoint") beams use the first offset as the centerline to aim along.

Out of curiosity, is there any advantage to doing this?  Would it make more sense to have converge on point treat the offset as always zero?  As it is, you're limiting converging beams to odd numbers of beams; you couldn't make one (that looked right / had pinpoint accuracy for PD work) that fired just two beams.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CopperCoyote on December 28, 2012, 11:38:43 AM
Thanks LazyWizard. I think i'll start with editing a new game's save first, and work from there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on December 29, 2012, 10:13:39 AM
what is the "render missile hint" in the wpn file?
of course it's responsible to show the tip of the missile visually to know that the missile is loaded, but what decided how much/which part/what graphic is used for such visual hint?

and i have something else wanted to do with it...just made a little capital artillery with missile hatch which happen to have light indicator in my imagination.

is it possible to make the render missile hint to be a green light graphic, to replace the default red light in the ship sprite?

sprite
Spoiler
(https://lh3.googleusercontent.com/-Y3neXUwF-wk/UN8FTfUEI9I/AAAAAAAAVc0/SNWX0M_j2X0/s440/13acFinalReal.png)
[close]

if it's not clear, here's the big one. i hope it's obvious enough which 14 red boxes are the missile hatch..
full render
Spoiler
(https://lh5.googleusercontent.com/-3qO8QpWkRDs/UN8Dy5pAZ0I/AAAAAAAAVcQ/AFsZ3Q_UO5M/s0/13acFinalFull.png)
[close]


just in case:

it's not ok to use green light as missile :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on December 29, 2012, 09:09:39 PM
another question:

"explosionSpec":{"duration":2f,

what's the unit of f?  frame?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on December 30, 2012, 06:10:31 AM
another question:

"explosionSpec":{"duration":2f,

what's the unit of f?  frame?

Duration is measured in seconds.

f just means the number's data type is a float (in short, a decimal; in long, it's complicated ;)) as opposed to an integer (which can only accept whole numbers).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on December 30, 2012, 06:42:05 AM
another question:

"explosionSpec":{"duration":2f,

what's the unit of f?  frame?

Duration is measured in seconds.

f just means the number's data type is a float (in short, a decimal; in long, it's complicated ;)) as opposed to an integer (which can only accept whole numbers).

For example Pi is 3.14....... you only want the first 2 decimals so you make it a type float becoming 3.14f
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on December 30, 2012, 06:42:43 AM
another question:

"explosionSpec":{"duration":2f,

what's the unit of f?  frame?

Duration is measured in seconds.

f just means the number's data type is a float (in short, a decimal; in long, it's complicated ;)) as opposed to an integer (which can only accept whole numbers).

thanks:)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on December 30, 2012, 06:44:49 AM
another question:

"explosionSpec":{"duration":2f,

what's the unit of f?  frame?

Duration is measured in seconds.

f just means the number's data type is a float (in short, a decimal; in long, it's complicated ;)) as opposed to an integer (which can only accept whole numbers).

For example Pi is 3.14....... you only want the first 2 decimals so you make it a type float becoming 3.14f

i guess all i can handle for now is the number is measured in second lol
the practical system is a bit hard to measure directly with visual hence the question :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on January 03, 2013, 06:17:16 AM
New problem:

auto pilot/ AI won't fire my new missile weapon.

It has unlimited ammo (over time), added a DO_NOT_AIM, USE_VS_FRIGATE tag in the csv, and a range of 1500

what makes the AI think this weapon is useless?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 03, 2013, 09:36:32 AM
New problem:

auto pilot/ AI won't fire my new missile weapon.

It has unlimited ammo (over time), added a DO_NOT_AIM, USE_VS_FRIGATE tag in the csv, and a range of 1500

what makes the AI think this weapon is useless?

I believe missiles need at least 30 ammo to autofire.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 03, 2013, 09:44:25 AM
Also: if missile ammo is <= 5, it'll wait to fire it until it's a good time to - i.e, the missile is high explosive and shields are down. It doesn't take regeneration into account for this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 03, 2013, 12:53:14 PM
1. It seems i have forgotten the location where i specifiy what background images will be used ingame.
   
2. I specified in the faction file
Code
"shipNameSources":{
"THULE":1,
},
but the game will randomly pick a name, not just from the specified one.
    What could be the problem?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on January 03, 2013, 01:11:02 PM
Something I want...

(http://oi45.tinypic.com/2s7i2v4.jpg)


What I get...

(http://oi48.tinypic.com/2j4wvwx.jpg)


... but why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheHappyFace on January 04, 2013, 02:51:19 AM
did you use correct extension? not something like a photoshop file? something it cant read?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on January 04, 2013, 07:30:28 AM
did you use correct extension? not something like a photoshop file? something it cant read?


First thing I checked and its a .png  :-\  must be something I accidently did in PS,
however I dunno what can cause this.


Edit - got it, had wrong bit levels. All is good now, thank you for your time :)

Spoiler
(http://oi45.tinypic.com/2jcac0n.jpg)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on January 05, 2013, 06:56:02 AM

I believe missiles need at least 30 ammo to autofire.

Also: if missile ammo is <= 5, it'll wait to fire it until it's a good time to - i.e, the missile is high explosive and shields are down. It doesn't take regeneration into account for this.

ah....thanks for the info ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on January 05, 2013, 06:56:39 AM
did you use correct extension? not something like a photoshop file? something it cant read?


First thing I checked and its a .png  :-\  must be something I accidently did in PS,
however I dunno what can cause this.


Edit - got it, had wrong bit levels. All is good now, thank you for your time :)

Spoiler
(http://oi45.tinypic.com/2jcac0n.jpg)
[close]

yes, the game only eat 8 bit graphic, 16bit is a no go
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 05, 2013, 07:02:48 AM
Not only that, its now StarSector so you'll need to remake it anyway  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on January 05, 2013, 03:27:17 PM
Not only that, its now StarSector so you'll need to remake it anyway  :D

You cant imagine the look on my face, when I saw the email, that "new Starsector is out"  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lordzias on January 06, 2013, 01:51:09 AM
How do i add my own portraits to the game? Placing them in the portraits folder doesn't work and I dont want some random pirate to have the same pretty mug as me...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 06, 2013, 01:11:08 PM
Would it be possible to do something similar to the Aegis Deflector from Battleships Forever?

(http://img102.imageshack.us/img102/6707/athenauk1.png)

The glowing blue generators at the back could be shot down and take the invulnerable white sections to the front offline.

The main interesting idea is to tie some effect to a weapon that, if taken offline, disables the effect. For instance, imagine a ship with a series of generators along the side that confer a passive energy weapon damage bonus as long as they are online.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 06, 2013, 02:06:17 PM
Right now, no, since parts dont actually change the stats of a ship being the engines an exception
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 06, 2013, 05:01:05 PM
   
2. I specified in the faction file
Code
"shipNameSources":{
"THULE":1,
},
but the game will randomly pick a name, not just from the specified one.
    What could be the problem?

has someone a hint for me?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 06, 2013, 08:25:39 PM
   
2. I specified in the faction file
Code
"shipNameSources":{
"THULE":1,
},
but the game will randomly pick a name, not just from the specified one.
    What could be the problem?

has someone a hint for me?

Can you send me a link to the mod? I should be able to take a look tomorrow.

One thing to check - if you're modifing a stock faction (which I suspect you're not), this would simply add the "THULE" name set to it - you'd have to specify for the .faction file to be replaced in mod_info.json.

Also: make sure your ship_names.json is under data/strings.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 07, 2013, 07:56:29 AM
Actually, about that - all mothballed ships seem to pull from every ship name list in the data structure, not just the ones belonging to the faction that owns the station. Is that intended?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 07, 2013, 08:23:41 AM
Here is the updated mod.

ship_names.json in data/strings   :     check
no stockfaction = no replacing in mod_info.json? (or is it the opposite?)  :     check

Here (http://www.mediafire.com/?prwcgzmrzj68v96) is the updated version of the mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 08, 2013, 05:04:55 PM
Ok, finally had a chance to look. In your ship_names.json, you 1) probably don't need to have all the other name categories and 2) don't actually have a "THULE" category (it's "OLD HIGH GERMAN").

Actually, about that - all mothballed ships seem to pull from every ship name list in the data structure, not just the ones belonging to the faction that owns the station. Is that intended?

You need to call void initMothballedShips(String factionId); on the cargo of the station. Otherwise, it'll init with the "independent" faction the first time it's used.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 08, 2013, 10:53:15 PM
Thank you Alex for taking the time to have a look, unfortunatly i mixed up the json files and uploaded the outdated version, my real updated version looks like this. The naming issue is still present.

ship_names.json
Code
{
"THULE":
[
"Adalberga",
"Adalbrand",
"Adalburg",
"Adalger",
"Adalward",
"Adelar",
"Adelbrand",
"Adelfrieda",
"Adelfriede",
"Adelger",
"Adelgunde",
"Adelgundis",
"Adelrune",
"Agibert",
"Agilhard",
"Agilulf",
"Alarich",
"Albina",
"Albine",
"Albrada",
"Albruna",
"Albrune",
"Alfger",
"Alfhilde",
"Alfonsa",
"Alftrud",
"Alkmar",
"Aloisia",
"Alram",
"Alwine",
"Amalberga",
"Amalberta",
"Amalburga",
"Amalfried",
"Amalfrieda",
"Amalfriede",
"Amalgard",
"Amalgunda",
"Amalgundis",
"Amalie",
"Amalinde",
"Amalindis",
"Arngrim",
"Arnhard",
"Arnhelm",
"Arnulf",
"Arwin",
"Aschwin",
"Askold",
"Aswin",
"Baldebert",
"Baldegunde",
"Baldemar",
"Balderich",
"Baldfried",
"Baltfried",
"Balthard",
"Baltram",
"Baltrun",
"Baltwin",
"Bardulf",
"Bathilde",
"Bathildis",
"Bergunde",
"Berlinde",
"Berlindis",
"Bernalde",
"Bernfried",
"Bernfriede",
"Berngard",
"Bernger",
"Bernharde",
"Bernhelm",
"Bernhilde",
"Bernulf",
"Bernwald",
"Bernward",
"Berold",
"Bertfried",
"Bertfriede",
"Bertgunde",
"Bertholda",
"Bertholde",
"Bertlinde",
"Bertlindis",
"Bertolf",
"Bertrade",
"Bertradis",
"Bertrand",
"Bertraude",
"Bertrun",
"Bertulf",
"Bertwald",
"Bertwin",
"Billfried",
"Billhard",
"Billhilde",
"Billibald",
"Biterolf",
"Bleikard",
"Botmar",
"Botwin",
"Brandolf",
"Brandulf",
"Brunhard",
"Brünhilde",
"Burglinde",
"Burgwald",
"Burgward",
"Christhard",
"Christmar",
"Christwart",
"Dankrad",
"Dankrade",
"Deert",
"Deinhard",
"Diederike",
"Dietbald",
"Dietberga",
"Dietberta",
"Dietbold",
"Dietbrand",
"Dietburga",
"Dietegen",
"Dietgard",
"Dietgunde",
"Diethelm",
"Diether",
"Diethilde",
"Dietmund",
"Dietmut",
"Dietolf",
"Dietrade",
"Dietram",
"Dietrun",
"Dietwald",
"Dietward",
"Dietwart",
"Dietwin",
"Dietwolf",
"Eberfried",
"Ebergard",
"Eberharda",
"Eberhilde",
"Eckeward",
"Eckewart",
"Eckhard",
"Eckwin",
"Egberta",
"Egberte",
"Egilward",
"Eginolf",
"Egmond",
"Ehrengrad",
"Ehrentraud",
"Eilbert",
"Eilfried",
"Eilmar",
"Eiltraud",
"Einharde",
"Elfgard",
"Elftraud",
"Emeram",
"Emmeram",
"Engelberga",
"Engelberta",
"Engelburga",
"Engelgard",
"Engeltraud",
"Erkenbald",
"Erkenbert",
"Erkenbrecht",
"Erkenfried",
"Erkengard",
"Erkenrad",
"Erkentraud",
"Erlfried",
"Erlfriede",
"Erlgard",
"Erltraud",
"Erlwin",
"Erlwine",
"Ermenbert",
"Ermenbrecht",
"Erminolde",
"Ernesta",
"Erpo",
"Ertrud",
"Erwine",
"Etzel",
"Ewara",
"Eward",
"Ewerdina",
"Ewerdine",
"Falkmar",
"Faramund",
"Farfried",
"Farhilde",
"Farold",
"Fastmar",
"Fastmund",
"Fastrad",
"Fastrade",
"Fatrada",
"Filiberta",
"Framhild",
"Friedebald",
"Friedeberga",
"Friedebert",
"Friedeburg",
"Friedeburga",
"Friedelind",
"Friederun",
"Friedewald",
"Friedhard",
"Friedhelm",
"Friedolf",
"Friedrich",
"Frodebert",
"Frodegard",
"Frodemute",
"Frodewine",
"Frommhold",
"Garlieb",
"Gastold",
"Gebharde",
"Gerbald",
"Gerbod",
"Gerborg",
"Gerbrand",
"Gerburg",
"Gerfried",
"Gerharda",
"Gerharde",
"Gerhilde",
"Germar",
"Gertraud",
"Gerwine",
"Gilberte",
"Gildbrecht",
"Gildebert",
"Giselberga",
"Giselberta",
"Giselburga",
"Giselheid",
"Giseltraud",
"Gismara",
"Gismunda",
"Gismunde",
"Godeberta",
"Godela",
"Godwin",
"Gosbert",
"Gotlinde",
"Gotlindis",
"Gottbert",
"Gotthelm",
"Gotthilde",
"Gottmar",
"Gottwin",
"Gotwin",
"Gunborg",
"Gundobald",
"Gunntberta",
"Guntberga",
"Guntbert",
"Guntbrecht",
"Guntfried",
"Gunthard",
"Gunthelm",
"Gunthilde",
"Guntrad",
"Guntrada",
"Guntrade",
"Guntram",
"Guntrun",
"Guntwin",
"Gühnter",
"Hadamar",
"Hadburga",
"Hadelind",
"Hademund",
"Haduwig",
"Hadwine",
"Hariolf",
"Hariulf",
"Harmina",
"Harold",
"Hartbert",
"Hartfried",
"Hartlieb",
"Hartmute",
"Hartwig",
"Hatto",
"Heiderich",
"Heilburg",
"Heilmar",
"Heiltraud",
"Heilwig",
"Heimberga",
"Heimbert",
"Heimbrecht",
"Heimburga",
"Heimeram",
"Heimeran",
"Heimtraud",
"Heinhard",
"Heinrike",
"Helferich",
"Helmbald",
"Helmbold",
"Helmbrecht",
"Helmburg",
"Helmfried",
"Helmgerd",
"Helmold",
"Helmtraud",
"Herbald",
"Herberta",
"Herborg",
"Herbrand",
"Herburg",
"Hergilde",
"Herlinde",
"Herlindis",
"Herlof",
"Herluf",
"Hermandine",
"Hermanna",
"Hermanne",
"Hermengilde",
"Herrada",
"Herrade",
"Herta",
"Hertwiga",
"Herwald",
"Herward",
"Herwig",
"Herwiga",
"Hildburg",
"Hildebald",
"Hildebert",
"Hildebrand",
"Hildebrecht",
"Hildefons",
"Hildemar",
"Hildemut",
"Hildewin",
"Hildolf",
"Hiltraud",
"Horstmar",
"Huberta",
"Hugbald",
"Humbrecht",
"Humfried",
"Hunold",
"Ingegerd",
"Ingmar",
"Irmenbert",
"Irmenburg",
"Irmenfried",
"Irmengard",
"Irmenhard",
"Irmenrad",
"Isberga",
"Isenbert",
"Isenbrand",
"Isenger",
"Isenhard",
"Isentraud",
"Isgard",
"Ismar",
"Ismunde",
"Ithamar",
"Iwo",
"Janfried",
"Klothilde",
"Kolbert",
"Kriemhild",
"Kunibald",
"Kunibert",
"Kunimund",
"Lambrecht",
"Lampert",
"Lamprecht",
"Landerich",
"Landewin",
"Landfried",
"Leonharda",
"Leopola",
"Leopolde",
"Liberta",
"Liebetraud",
"Liebfried",
"Liebhard",
"Liebhilde",
"Liebrecht",
"Liebwald",
"Liebward",
"Liebwin",
"Lindgrad",
"Luitbald",
"Luitbrand",
"Luitfried",
"Luitgard",
"Luitgunde",
"Luither",
"Luithilde",
"Luithold",
"Luitolf",
"Luitwin",
"Lütmar",
"Malfriede",
"Malvine",
"Malwin",
"Manhard",
"Manhart",
"Marbert",
"Marbod",
"Marhold",
"Marigard",
"Markolf",
"Markward",
"Maxbert",
"Meinbod",
"Meinfried",
"Meinhilde",
"Meinholde",
"Meinrade",
"Meinwald",
"Meithard",
"Mildburg",
"Milltraud",
"Neidhard",
"Nidger",
"Nonfried",
"Nordrun",
"Nordwin",
"Norfried",
"Norgard",
"Norhilde",
"Notburga",
"Notger",
"Notker",
"Oldwig",
"Ortfried",
"Ortger",
"Orthilde",
"Ortlinde",
"Ortnit",
"Ortraud",
"Osberta",
"Osmunde",
"Osterlind",
"Oswalda",
"Oswalde",
"Oswina",
"Otberga",
"Otger",
"Otgunde",
"Othilde",
"Otker",
"Otlinde",
"Otmund",
"Ottar",
"Ottogebe",
"Otwald",
"Otward",
"Otwin",
"Pippin",
"Radegunde",
"Rambald",
"Rambert",
"Rambod",
"Randolf",
"Randwig",
"Ratbald",
"Ratbert",
"Ratberta",
"Ratbod",
"Ratburga",
"Ratfried",
"Ratgard",
"Ratger",
"Rathard",
"Rathilde",
"Rathold",
"Ratmar",
"Ratwald",
"Ratward",
"Regelinde",
"Reginald",
"Reginalda",
"Regiswinda",
"Reimara",
"Reimbert",
"Reimbod",
"Reimund",
"Reimute",
"Reinald",
"Reinalde",
"Reinberta",
"Reinburga",
"Reiner",
"Reinfried",
"Reinfrieda",
"Reingard",
"Reinhardine",
"Reinholde",
"Reintraud",
"Reinwald",
"Richbald",
"Richbert",
"Richhilde",
"Richlinde",
"Richmar",
"Richmut",
"Richwald",
"Rigmor",
"Ringolf",
"Rodegang",
"Rodegard",
"Rodehilde",
"Rodewald",
"Rolanda",
"Romilda",
"Rosalinde",
"Rosemarie",
"Roswin",
"Rothard",
"Rother",
"Rudibert",
"Rudmar",
"Rudolfa",
"Rumold",
"Runfried",
"Runhilde",
"Ruperta",
"Rutgard",
"Rutlieb",
"Schwabhild",
"Schöntrud",
"Sebalde",
"Siegberta",
"Siegbod",
"Siegbrand",
"Siegburga",
"Sieghelm",
"Siegher",
"Sieghilde",
"Siegolf",
"Siegram",
"Siegrich",
"Siegrun",
"Siegtraude",
"Siegwald",
"Siegward",
"Siegwin",
"Sigismunde",
"Sintbald",
"Sintbert",
"Sirk",
"Solbert",
"Sonnfried",
"Sonngard",
"Sonnhilde",
"Sonntraud",
"Stillfried",
"Svava",
"Swanburga",
"Swanhilde",
"Swidgard",
"Swindbert",
"Teutobald",
"Teutobert",
"Teutobod",
"Teutomar",
"Teutwart",
"Thorgard",
"Thorgund",
"Traudhilde",
"Traudlinde",
"Treumunde",
"Trudberta",
"Trudgard",
"Uhland",
"Ulbert",
"Ulberta",
"Ulfert",
"Usmar",
"Vilmar",
"Volbert",
"Volkbert",
"Volkberta",
"Volkbrand",
"Volkbrecht",
"Volkerdine",
"Volkhard",
"Volkhilde",
"Volkmann",
"Volko",
"Volkrad",
"Volkram",
"Volkwald",
"Volkward",
"Volkwin",
"Walbert",
"Waldeberta",
"Waldegunde",
"Waldfried",
"Walfriede",
"Walthard",
"Waltheide",
"Walthilde",
"Waltrada",
"Waltram",
"Waltraud",
"Waltrun",
"Welfhard",
"Wendelbert",
"Wendelgard",
"Wendelmar",
"Weriand",
"Wernburg",
"Werngrad",
"Wernhard",
"Wernhilde",
"Wibrande",
"Wichard",
"Wiclef",
"Wiebke",
"Wigand",
"Wigbald",
"Wigbert",
"Wigberta",
"Wigburga",
"Wigmar",
"Wigmund",
"Wignand",
"Wilbert",
"Wilbrand",
"Wilburg",
"Wilderich",
"Wildfried",
"Wilfrieda",
"Wilgard",
"Wilgunde",
"Wilhard",
"Wilhelma",
"Willehad",
"Willibert",
"Willibrand",
"Willimar",
"Williram",
"Wilma",
"Wilmont",
"Wilmut",
"Wilrun",
"Winald",
"Winand",
"Winfrieda",
"Winibald",
"Winibert",
"Winimar",
"Winrich",
"Wintrud",
"Wisgard",
"Wisgunde",
"Witold",
"Wolfbert",
"Wolfgang",
"Wolfger",
"Wolfgunde",
"Wolfhelm",
"Wolfhilde",
"Wolfrad",
"Wolfried",
"Wolfrun",
"Wolftraud",
"Wulfrin",
"Wunibald",
"Wybren",

],
"Erk":
[
"Adeodatus",
"Adorata",
"Afra",
"Agnus",
"Albin",
"Aloisius",
"Aloysius",
"Alva",
"Alwinus",
"Amadea",
"Amand",
"Amatus",
"Amöna",
"Amöne",
"Antonius",
"Arcadius",
"Arkadius",
"Ascanius",
"Askan",
"Augustus",
"Aurelius",
"Balbina",
"Balbine",
"Baldus",
"Beat",
"Beata",
"Beate",
"Beatus",
"Benedikte",
"Benediktus",
"Benigna",
"Bibiana",
"Bibiane",
"Bona",
"Bonaventura",
"Bonifatia",
"Bonifaz",
"Bonifazius",
"Brigida",
"Brigide",
"Cajetan",
"Candid",
"Candidus",
"Caritas",
"Carola",
"Carolus",
"Celestin",
"Celestina",
"Centa",
"Christian",
"Clamor",
"Clodia",
"Columba",
"Columban",
"Columbina",
"Concordia",
"Consilia",
"Constantin",
"Corin",
"Cornel",
"Corvinius",
"Crescentia",
"Crispin",
"Crispinus",
"Cyprian",
"Cäcilia",
"Cäcilius",
"Cäsarina",
"Cäsarine",
"Cölestin",
"Cölestina",
"Deodat",
"Deodata",
"Deodatus",
"Desiderius",
"Diane",
"Dominik",
"Donat",
"Elestin",
"Emerita",
"Emilia",
"Ernesto",
"Ernestus",
"Fabius",
"Fausta",
"Faustinus",
"Faustus",
"Felicia",
"Felizia",
"Fideelius",
"Fidelia",
"Fidelis",
"Fides",
"Firmina",
"Flavia",
"Flavius",
"Florens",
"Florentia",
"Florentius",
"Floriane",
"Florida",
"Florina",
"Florine",
"Florus",
"Fortuna",
"Fortunat",
"Fortunata",
"Fortunatus",
"Franciscus",
"Frobenius",
"Galla",
"Gallus",
"Gaudentius",
"Gemma",
"Gerke",
"Gerko",
"Gertrudis",
"Glorius",
"Gordian",
"Gratian",
"Gratianus",
"Grazian",
"Hilaria",
"Honorius",
"Hubertus",
"Ignatia",
"Ignaz",
"Immakulata",
"Ingenuin",
"Innozens",
"Innozent",
"Innozentia",
"Jucunda",
"Julia",
"Klemens",
"Kolomba",
"Laura",
"Laurenz",
"Lavinia",
"Leo",
"Leon",
"Leona",
"Leonie",
"Longin",
"Longina",
"Longinus",
"Lucretius",
"Ludgerus",
"Ludovicus",
"Lätizia",
"Marzellus",
"Maura",
"Maurus",
"Maximilian",
"Maximus",
"Medardus",
"Modeste",
"Natalia",
"Nero",
"Octaria",
"Oktavian",
"Optatus",
"Orania",
"Ostian",
"Parsimonius",
"Patrizia",
"Patrizius",
"Paul",
"Perdita",
"Peregrin",
"Peregrinus",
"Petrus",
"Piata",
"Pontian",
"Pretiosa",
"Primus",
"Priscus",
"Priska",
"Prosperus",
"Prudentia",
"Pulcheria",
"Romulus",
"Rosina",
"Rufina",
"Rufus",
"Salvator",
"Salvina",
"Salwa",
"Santo",
"Saturnus",
"Scholastika",
"Scipio",
"Serena",
"Serenus",
"Sergia",
"Severa",
"Severina",
"Sidonia",
"Sidonius",
"Silva",
"Silvan",
"Silvester",
"Silvius",
"Sulpiz",
"Tarcisius",
"Terzia",
"Tiziana",
"Urbana",
"Urbanus",
"Urs",
"Ursina",
"Ursula",
"Valerie",
"Valten",
"Velten",
"Veltin",
"Venetia",
"Ventur",
"Veritas",
"Victoria",
"Viktor",
"Vincentia",
"Vita",
"Vital",
"Vivian",
"Viviana",
"Zelestin",
]
}

thulelegacy.faction
Code
{
id:"thulelegacy",
"color":[153,95,158,255],
"displayName":"Thule Legacy",
"shipNamePrefix":"TLS",
"shipNameSources":{
"THULE":1,
},
"description":"No description yet.",
"names":{
"modern":1,
},
"portraits":{
"standard_male":[
"graphics/portraits/portrait_thule04.png",
"graphics/portraits/portrait_thule03.png",
],
"standard_female":[
"graphics/portraits/portrait_thule02.png",
"graphics/portraits/portrait_thule01.png",
],
},
"fleetCompositions":{
"blitz":{
"displayName":"Blitz Trooper",
"maxFleetPoints":11,
"daysWorthOfSupplies":[30, 50],
"lyWorthOfFuel":[40, 60],
"extraCrewPercent":[80, 80],
"marinesPercent":[20, 20],
"ships":{
"thule_vikingmki_Assault":[1, 1],
"thule_vikingmkii_Assault":[1, 1],
"thule_einherjer_wing":[1, 1],
},
},
"stormer":{
"displayName":"Stormer Battalion",
"maxFleetPoints":25,
"daysWorthOfSupplies":[30, 50],
"lyWorthOfFuel":[40, 60],
"extraCrewPercent":[80, 80],
"marinesPercent":[20, 20],
"ships":{
"thule_vikingmki_Assault":[2, 3],
"thule_vikingmkii_Assault":[0, 1],
"thule_berserker_Standard":[0, 1],
"thule_einherjer_wing":[2, 3],
},
},
"pacifier":{
"displayName":"Pacifier Flotilla",
"maxFleetPoints":50,
"daysWorthOfSupplies":[30, 50],
"lyWorthOfFuel":[40, 60],
"extraCrewPercent":[80, 80],
"marinesPercent":[20, 20],
"ships":{
"thule_berserker_Standard":[2, 2],
"thule_vikingmki_Assault":[2, 3],
"thule_vikingmkii_Assault":[2, 3],
"thule_einherjer_wing":[0, 4],
"thule_wartool_wing":[0, 2],
},
},
"peacekeeper":{
"displayName":"Peacekeeper Fleet",
"maxFleetPoints":100,
"daysWorthOfSupplies":[30, 50],
"lyWorthOfFuel":[40, 60],
"extraCrewPercent":[80, 80],
"marinesPercent":[20, 20],
"ships":{
"thule_herzog_Standard":[2, 2],
"thule_berserker_Standard":[2, 4],
"thule_berserker_Support":[1, 2],
"thule_vikingmki_Assault":[2, 3],
"thule_tungsten_experimental":[2, 2],
"thule_vikingmki_Support":[2, 3],
"thule_einherjer_wing":[2, 6],
"thule_wartool_wing":[2, 6],
},
},
"supplyfleet":{
            "displayName":"Supply Fleet",
            "maxFleetPoints":70,
            "daysWorthOfSupplies":[30, 50],
            "lyWorthOfFuel":[40, 60],
"extraCrewPercent":[80, 80],
"marinesPercent":[20, 20],
            "ships":{
                "buffalo_Standard":[4, 7],
                "aurora_Balanced":[1, 3],
                "medusa_Attack":[0, 2],
                "medusa_CS":[0, 2],
                "tempest_Attack":[0, 3],
                "wolf_CS":[0, 3],
                "xyphos_wing":[2,3],
                "wasp_wing":[3, 4],
            },
        },
},
"traits":{
"admiral":{

},
"captain":{
"cowardly":1,
"cautious":1,
"steady":1,
"aggressive":1,
"suicidal":1,
"fearless":1,
},
},
"dialogue":{
"greetingFriendly":"This Thule Legacy ship is on a classified mission. Identity and peaceful status confirmed.",
"greetingNeutral":"Thule Legacy have scanned your ship and analyzed your capabilities to cause a disturbance. Maintain your distance.",
"greetingHostileAggressive":"I can picture in my mind a system without war, a system without hate. And I can picture us attacking that system, because they'd never expect it. Prepare to be pacified.",
"greetingHostileTimid":"Attention. Your vessel has been scanned and identified as a disturbence to the Thule Legacy. Prepare to be pacified. Peace through superior firepower.",
}
},
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 09, 2013, 05:57:09 AM
Another modding question - I have a modified Maneuvering Jets system in my mod that uses the effectLevel to create a slowly fading stat boost. This means most of the effect is executed in the chargedown phase, and thus if I use "clamp max speed after=true" in the system file, the entire effect gets messed up. However I'd still very much like for the max speed to clamp after the chargedown ends, to make the system less useful for fast travel and more useful for combat maneuvering. How could I accomplish this?

Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;

public class BurstJetsStats implements ShipSystemStatsScript {

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
if (state == ShipSystemStatsScript.State.OUT) {
stats.getMaxSpeed().modifyPercent(id, 100f * effectLevel); // to slow down ship to its regular top speed while powering drive down
stats.getMaxTurnRate().modifyPercent(id, 100f * effectLevel);
stats.getDeceleration().modifyPercent(id, 100f * effectLevel);
} else {
stats.getMaxSpeed().modifyFlat(id, 130f * effectLevel);
stats.getAcceleration().modifyFlat(id, 190f * effectLevel);
stats.getDeceleration().modifyFlat(id, 120f * effectLevel);
stats.getTurnAcceleration().modifyFlat(id, 90f * effectLevel);
stats.getTurnAcceleration().modifyPercent(id, 200f * effectLevel);
stats.getMaxTurnRate().modifyFlat(id, 40f * effectLevel);
stats.getMaxTurnRate().modifyPercent(id, 100f * effectLevel);
}
}
public void unapply(MutableShipStatsAPI stats, String id) {
stats.getMaxSpeed().unmodify(id);
stats.getMaxTurnRate().unmodify(id);
stats.getTurnAcceleration().unmodify(id);
stats.getAcceleration().unmodify(id);
stats.getDeceleration().unmodify(id);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("improved maneuverability", false);
} else if (index == 1) {
return new StatusData("increased top speed", false);
}
return null;
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 09, 2013, 12:20:09 PM
Thank you Alex for taking the time to have a look, unfortunatly i mixed up the json files and uploaded the outdated version, my real updated version looks like this. The naming issue is still present.

Pasted those in and it works fine. Let's take a step back - what's the actual issue? Outside the campaign, or in missions (i.e. if you go to Edit Variants -> Run Simulation off the main screen, or play a mission), the ships aren't associated with a faction. Inside the campaign, this seems to be working correctly - the Thule resupply fleet has names drawn from that group.

Another modding question - I have a modified Maneuvering Jets system in my mod that uses the effectLevel to create a slowly fading stat boost. This means most of the effect is executed in the chargedown phase, and thus if I use "clamp max speed after=true" in the system file, the entire effect gets messed up. However I'd still very much like for the max speed to clamp after the chargedown ends, to make the system less useful for fast travel and more useful for combat maneuvering. How could I accomplish this?

What you could do is turn clamping off, and then do it manually inside the "apply" method, based on the effectLevel when state == ShipSystemStatsScript.State.OUT.

The apply() method gets called every frame. One minor complication is you don't get a time amount passed in, so instead of that, you'll have to base the magnitude of the clamping effect on the value of effectLevel - which is tied to time, so it's just a slightly roundabout way of getting at it.

I.E., once you know it's fading, and the effect level goes to 0.25 - or whatever other value you like - you start clamping, based on how much effectLevel changed between subsequent calls to apply(). I'd also apply some final clamping in unapply() for good measure - that gets called once after a system finishes being turned off.

To actually get at the ship, so you can clamp the velocity/turn rate you can call stats.getEntity() - that returns a CombatEntityAPI. Make sure to check that the return value isn't null before doing anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 09, 2013, 12:23:16 PM
Really minor question:

How do I use plugins? Since I am getting a compiler error I assume I first have to compile them? If so how?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 09, 2013, 04:51:33 PM
The game compiles them, you can set a program like netbeans to read the libraries from the game, helps coding by alot, heres a how to by LazyWizard:

http://fractalsoftworks.com/forum/index.php?topic=3173

as for using plugins, you should add those *.java files on the ...\mods\[Your mod folder]\data\scripts\plugins\
they also should have the initial package set to where they are located, in case of the plugins would be:

package data.scripts.plugins;

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 10, 2013, 05:36:24 AM
Still getting a compile error oO.

I made sure everything is where its supposed to be:

the plugin "RotatingDish.java" is located at "modname/data/scripts/plugins/" - it hold the package "data.scripts.plugins".

The sensordish.wpn calls the "everyFrameEffect" wich points at "modname/data/scripts/plugins/RotatingDish.java".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 10, 2013, 08:27:30 AM
wizardry

Thanks a lot for the help, I'm going to take a look at the system again soon. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 10, 2013, 12:36:53 PM
Hmm I replaced my engine sounds with new ones, I also set the path to them. So why does Starsector still play the default engine sounds?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: arcibalde on January 10, 2013, 12:39:06 PM
Hmm I replaced my engine sounds with new ones, I also set the path to them. So why does Starsector still play the default engine sounds?
data/config/sounds.json   did you change there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 10, 2013, 01:00:24 PM
Yupp see below.

Code
	# Engines
# played when engines are being used - depending on ship style and size
# For example - a "new" frigate would play the third sound listed, at volume 0.6
"engine_loop":{
"sounds":[
{"file":"sounds/fx/engines/engine.ogg","pitch":1,"volume":1},
{"file":"sounds/fx/engines/engine.ogg","pitch":1,"volume":1},
{"file":"sounds/fx/engines/engine.ogg","pitch":1,"volume":1},
],
"LOW_TECH":{"sounds":[0], "pitch":1, "volume":1},
"MIDLINE":{"sounds":[1], "pitch":1, "volume":1},
"HIGH_TECH":{"sounds":[2], "pitch":1, "volume":1},
"FIGHTER":{"sounds":[0,1,2], "pitch":1, "volume":0.4},
"FRIGATE":{"sounds":[0,1,2], "pitch":1, "volume":0.6},
"DESTROYER":{"sounds":[0,1,2], "pitch":1, "volume":0.7},
"CRUISER":{"sounds":[0,1,2], "pitch":1, "volume":0.8},
"CAPITAL_SHIP":{"sounds":[0,1,2], "pitch":1, "volume":1},
},
"engine_accelerate":{ # played when ship receives an "engine boost" from having zero flux
"sounds":[
{"file":"sounds/fx/engines/engine_startup.ogg","pitch":0.95,"volume":1},
],
"LOW_TECH":{"sounds":[0], "pitch":0.8, "volume":1},
"MIDLINE":{"sounds":[0], "pitch":0.9, "volume":1},
"HIGH_TECH":{"sounds":[0], "pitch":1, "volume":1},
"FIGHTER":{"sounds":[0], "pitch":1, "volume":0.4},
"FRIGATE":{"sounds":[0], "pitch":1, "volume":0.6},
"DESTROYER":{"sounds":[0], "pitch":1, "volume":0.7},
"CRUISER":{"sounds":[0], "pitch":1, "volume":0.8},
"CAPITAL_SHIP":{"sounds":[0], "pitch":1, "volume":1},
},

The soundfile does work btw, tested it with a weapon, however for some reason it does not override the engine sound... annoying -.-"

Fixed it:

Unlike weapon sounds, the engine sounds need to be named EXACTLY like the original files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 12, 2013, 02:24:02 PM
Thank you Alex for taking the time to have a look, unfortunatly i mixed up the json files and uploaded the outdated version, my real updated version looks like this. The naming issue is still present.

Pasted those in and it works fine. Let's take a step back - what's the actual issue? Outside the campaign, or in missions (i.e. if you go to Edit Variants -> Run Simulation off the main screen, or play a mission), the ships aren't associated with a faction. Inside the campaign, this seems to be working correctly - the Thule resupply fleet has names drawn from that group.

Okay, thank you very much Alex, my bad.
I thought in missions ships where still associated with factions.
And yes in campaign mode it works properly.

Thank you again and sorry for wasting your time ;)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 12, 2013, 02:27:59 PM
I'm trying to make a hull repair ship system, which looks like it should be easy enough (the java for it is quite easy, just using stats.getHullRepairRatePercentPerSecond())


However, when it comes to the .SYSTEM file I'm not sure how to proceed.

I figure I can use:
   "type":"STAT_MOD",

But I have no idea what to set the aiType to. Or, should I be using the example of FastMissileRacksAI.java and doing my own custom one?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 12, 2013, 02:30:37 PM
Yeah but that one example is kinda limited to understand how exactly can we make our own, pretty much the reason we havent started to mess up with them

heres an old system to repair your hull:
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.ShipAPI;

public class RegenerateHitpoints  implements ShipSystemStatsScript {

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
        ShipAPI ship = (ShipAPI) stats.getEntity();

        if (ship == null)
            return;

            if(ship.getHitpoints() < ship.getMaxHitpoints())
            {
                stats.getMaxHullRepairFraction().modifyFlat(id, 1000f); // the % in speed it heals back

                float CurrentPercHP = (ship.getHitpoints() * 100) / ship.getMaxHitpoints(); //Grab current perc

                if(CurrentPercHP < 20.000f) //checking if its less then 20% to repair
                    stats.getHullRepairRatePercentPerSecond().modifyFlat(id, CurrentPercHP); // if its less then 20% heal
                else
                    stats.getHullRepairRatePercentPerSecond().modifyFlat(id, 20.000f); // else heal exacly 20%

            }
}
public void unapply(MutableShipStatsAPI stats, String id)
        {
            stats.getMaxHullRepairFraction().unmodify(id);
            stats.getHullRepairRatePercentPerSecond().unmodify(id);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("Regenerating Hitpoints...", false);
}
return null;
}
}

and on the *.system file
Code
{
"id":"podship_regeneration",
"type":"SHIELD_MOD",
"aiType":"FORTRESS_SHIELD",

"statsScript":"data.shipsystems.scripts.RegenerateHitpoints",

"soundFilterType":"LOWPASS",
"soundFilterGain":1,
"soundFilterGainHF":0.0,

"useSound":"podship_regenerate",
#"loopSound":"beam_heavy_loop",
#"deactivateSound":"terminator_shield",
#"outOfUsesSound":"gun_out_of_ammo",

#"useSound":"terminator_shield",
#"deactivateSound":"terminator_shield",
# Stian disabled these two because the timing of activate/deactivate did not work together with the loop sound.
# Enable them to test the issue. The deactivateSound plays late, after the loopsound has already stopped,
# creating a stuttering effect.
"loopSound":"podship_regenerate",
"outOfUsesSound":"gun_out_of_ammo",
}

i didnt change the type of aitype, so the ai doesnt know how to use it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 12, 2013, 02:37:59 PM
Huh.

Guess I'm gonna try to write my own AI script then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 12, 2013, 03:39:29 PM
Getting close.

The system itself works nicely (it's not an instant repair, it's a 4-second repair that shuts down pretty much all of your ship systems and does 5% per second, or less if your HP is above 80%):

Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.ShipAPI;

/**
 *
 * @author Ender
 */
public class Hull_Repair implements ShipSystemStatsScript {
    
    public static final float REPAIR_RATE_MOD = 5f;
    
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
        stats.getMaxHullRepairFraction().modifyFlat(id, 1000f); // the % in speed it heals back
        ShipAPI ship = (ShipAPI) stats.getEntity();
        if (ship == null)
            return;
        
        float CurrentPercHP = (ship.getHitpoints() * 100) / ship.getMaxHitpoints();
        if (CurrentPercHP <= 20.000f) {
            float repairRatePercent = REPAIR_RATE_MOD * effectLevel;
            stats.getHullRepairRatePercentPerSecond().modifyFlat(id, repairRatePercent);
        } else {
            float repairRatePercent = REPAIR_RATE_MOD * effectLevel * (100.0f - CurrentPercHP);
            stats.getHullRepairRatePercentPerSecond().modifyFlat(id, repairRatePercent);
        }
        
    }
    public void unapply(MutableShipStatsAPI stats, String id) {
        stats.getHullRepairRatePercentPerSecond().unmodifyFlat(id);
    }
    
    public StatusData getStatusData(int index, State state, float effectLevel) {
        float repairRatePercent = REPAIR_RATE_MOD * effectLevel;
        if (index == 0) {
            return new StatusData("hull repair rate +" + (int) repairRatePercent + "%", false);
        } else if (index == 1) {
            return null;
        }
        
        return null;
    }
}


But the AI script causes an error.

Here's the AI java code (it's a bit hacky but it's a work in progress):
Code
package data.shipsystems.scripts.ai;

import java.util.List;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.util.IntervalUtil;
/**
 *
 * @author Ender
 */
public class Hull_RepairAI {
    
     private ShipAPI ship;
private CombatEngineAPI engine;
private ShipwideAIFlags flags;
private ShipSystemAPI system;

private IntervalUtil tracker = new IntervalUtil(0.5f, 1f);
        
        public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
this.ship = ship;
this.flags = flags;
this.engine = engine;
this.system = system;
}
        
        private float bestFractionEver = 0f;
private float sinceLast = 0f;
        
        
        @SuppressWarnings("unchecked")
        
        public void advance(float amount, ShipAPI target) {
            tracker.advance(amount);
            sinceLast += amount;
            
            if (tracker.intervalElapsed()) {
                if (system.getCooldownRemaining() > 0) return;
if (system.isOutOfAmmo()) return;
if (system.isActive()) return;
                
                float maxCooldown = 0f;
float totalCooldownSaved = 0f;
                
                float currentHullHP = (100.0f * ship.getHitpoints() / ship.getMaxHitpoints());
                
                if (maxCooldown <= 0 || totalCooldownSaved <= 0 || currentHullHP >= 80.0f) return;
                
                float fluxLevel = ship.getFluxTracker().getFluxLevel();

boolean targetIsVulnerable = target != null && target.getFluxTracker().isOverloadedOrVenting() &&
                        (target.getFluxTracker().getOverloadTimeRemaining() > 5f ||
                        target.getFluxTracker().getTimeToVent() > 5f);
                
                float remainingFluxLevel = 1f - fluxLevel;
                float fluxFractionPerUse = system.getFluxPerUse() / ship.getFluxTracker().getMaxFlux();
if (fluxFractionPerUse > remainingFluxLevel) return;
                
                float fluxLevelAfterUse = fluxLevel + fluxFractionPerUse;
if (fluxLevelAfterUse > 0.9f && fluxFractionPerUse > 0.025f) return;
                
                if (!targetIsVulnerable && sinceLast < 10f && currentHullHP >= 20.0f) return; //in an emergency, we shouldn't care if the enemy ship is currently voulnerable because we're already losing
                
                float fraction = totalCooldownSaved / maxCooldown;
                
                if (fraction > bestFractionEver) {
                        bestFractionEver = fraction;
                }
                
                if (fraction >= 0.5) {
                        ship.useSystem();
                        sinceLast = 0f;
                        return;
                }
            }
        }
        
}


And here's the error block I get:

Quote
42620 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: data.shipsystems.scripts.ai.Hull_RepairAI cannot be cast to com.fs.starfarer.api.combat.ShipSystemAIScript
java.lang.ClassCastException: data.shipsystems.scripts.ai.Hull_RepairAI cannot be cast to com.fs.starfarer.api.combat.ShipSystemAIScript
   at com.fs.starfarer.loading.specs.Oooo.öO0000(Unknown Source)
   at com.fs.starfarer.loading.specs.Oooo.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.<init>(Unknown Source)
   at com.fs.starfarer.combat.CombatFleetManager.super(Unknown Source)
   at com.fs.starfarer.combat.CombatFleetManager.super(Unknown Source)
   at com.fs.starfarer.combat.CombatFleetManager.deploy(Unknown Source)
   at com.fs.starfarer.ui.impl.G.super(Unknown Source)
   at com.fs.starfarer.ui.impl.G.super(Unknown Source)
   at com.fs.starfarer.ui.o00oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.ui.OOoO.super(Unknown Source)
   at com.fs.starfarer.ui.Objectsuper.o00000(Unknown Source)
   at com.fs.starfarer.combat.F.ÖÖÒ000(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 12, 2013, 05:37:45 PM
Spoiler
Getting close.

The system itself works nicely (it's not an instant repair, it's a 4-second repair that shuts down pretty much all of your ship systems and does 5% per second, or less if your HP is above 80%):

Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.ShipAPI;

/**
 *
 * @author Ender
 */
public class Hull_Repair implements ShipSystemStatsScript {
    
    public static final float REPAIR_RATE_MOD = 5f;
    
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
        stats.getMaxHullRepairFraction().modifyFlat(id, 1000f); // the % in speed it heals back
        ShipAPI ship = (ShipAPI) stats.getEntity();
        if (ship == null)
            return;
        
        float CurrentPercHP = (ship.getHitpoints() * 100) / ship.getMaxHitpoints();
        if (CurrentPercHP <= 20.000f) {
            float repairRatePercent = REPAIR_RATE_MOD * effectLevel;
            stats.getHullRepairRatePercentPerSecond().modifyFlat(id, repairRatePercent);
        } else {
            float repairRatePercent = REPAIR_RATE_MOD * effectLevel * (100.0f - CurrentPercHP);
            stats.getHullRepairRatePercentPerSecond().modifyFlat(id, repairRatePercent);
        }
        
    }
    public void unapply(MutableShipStatsAPI stats, String id) {
        stats.getHullRepairRatePercentPerSecond().unmodifyFlat(id);
    }
    
    public StatusData getStatusData(int index, State state, float effectLevel) {
        float repairRatePercent = REPAIR_RATE_MOD * effectLevel;
        if (index == 0) {
            return new StatusData("hull repair rate +" + (int) repairRatePercent + "%", false);
        } else if (index == 1) {
            return null;
        }
        
        return null;
    }
}


But the AI script causes an error.

Here's the AI java code (it's a bit hacky but it's a work in progress):
Code
package data.shipsystems.scripts.ai;

import java.util.List;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.util.IntervalUtil;
/**
 *
 * @author Ender
 */
public class Hull_RepairAI {
    
     private ShipAPI ship;
private CombatEngineAPI engine;
private ShipwideAIFlags flags;
private ShipSystemAPI system;

private IntervalUtil tracker = new IntervalUtil(0.5f, 1f);
        
        public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
this.ship = ship;
this.flags = flags;
this.engine = engine;
this.system = system;
}
        
        private float bestFractionEver = 0f;
private float sinceLast = 0f;
        
        
        @SuppressWarnings("unchecked")
        
        public void advance(float amount, ShipAPI target) {
            tracker.advance(amount);
            sinceLast += amount;
            
            if (tracker.intervalElapsed()) {
                if (system.getCooldownRemaining() > 0) return;
if (system.isOutOfAmmo()) return;
if (system.isActive()) return;
                
                float maxCooldown = 0f;
float totalCooldownSaved = 0f;
                
                float currentHullHP = (100.0f * ship.getHitpoints() / ship.getMaxHitpoints());
                
                if (maxCooldown <= 0 || totalCooldownSaved <= 0 || currentHullHP >= 80.0f) return;
                
                float fluxLevel = ship.getFluxTracker().getFluxLevel();

boolean targetIsVulnerable = target != null && target.getFluxTracker().isOverloadedOrVenting() &&
                        (target.getFluxTracker().getOverloadTimeRemaining() > 5f ||
                        target.getFluxTracker().getTimeToVent() > 5f);
                
                float remainingFluxLevel = 1f - fluxLevel;
                float fluxFractionPerUse = system.getFluxPerUse() / ship.getFluxTracker().getMaxFlux();
if (fluxFractionPerUse > remainingFluxLevel) return;
                
                float fluxLevelAfterUse = fluxLevel + fluxFractionPerUse;
if (fluxLevelAfterUse > 0.9f && fluxFractionPerUse > 0.025f) return;
                
                if (!targetIsVulnerable && sinceLast < 10f && currentHullHP >= 20.0f) return; //in an emergency, we shouldn't care if the enemy ship is currently voulnerable because we're already losing
                
                float fraction = totalCooldownSaved / maxCooldown;
                
                if (fraction > bestFractionEver) {
                        bestFractionEver = fraction;
                }
                
                if (fraction >= 0.5) {
                        ship.useSystem();
                        sinceLast = 0f;
                        return;
                }
            }
        }
        
}


And here's the error block I get:

Quote
42620 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: data.shipsystems.scripts.ai.Hull_RepairAI cannot be cast to com.fs.starfarer.api.combat.ShipSystemAIScript
java.lang.ClassCastException: data.shipsystems.scripts.ai.Hull_RepairAI cannot be cast to com.fs.starfarer.api.combat.ShipSystemAIScript
   at com.fs.starfarer.loading.specs.Oooo.öO0000(Unknown Source)
   at com.fs.starfarer.loading.specs.Oooo.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.<init>(Unknown Source)
   at com.fs.starfarer.combat.CombatFleetManager.super(Unknown Source)
   at com.fs.starfarer.combat.CombatFleetManager.super(Unknown Source)
   at com.fs.starfarer.combat.CombatFleetManager.deploy(Unknown Source)
   at com.fs.starfarer.ui.impl.G.super(Unknown Source)
   at com.fs.starfarer.ui.impl.G.super(Unknown Source)
   at com.fs.starfarer.ui.o00oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.ui.OOoO.super(Unknown Source)
   at com.fs.starfarer.ui.Objectsuper.o00000(Unknown Source)
   at com.fs.starfarer.combat.F.ÖÖÒ000(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
[close]

You forgot to have Hull_RepairAI implement ShipSystemAIScript. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 12, 2013, 05:47:50 PM
You forgot to have Hull_RepairAI implement ShipSystemAIScript. :)
/facepalm


I knew it would be something simple.

Now I just have to get the AI to actually use the damn thing since apparently the actual criteria isn't being met.

EDIT: It's using it, now I just need to make it actually be smart about using it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on January 12, 2013, 07:07:54 PM
If anyone would be nice enough to take a look at this mod, see what I've done wrong.
http://fractalsoftworks.com/forum/index.php?topic=4502.msg83744#msg83744
The .log is posted by Uthilian.  I've checked the code for the spawn point and the convoy to see what I've missed, but I can't figure it out.  All I know is that the game crashes when the convoy spawns.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 12, 2013, 07:30:42 PM
If anyone would be nice enough to take a look at this mod, see what I've done wrong.
http://fractalsoftworks.com/forum/index.php?topic=4502.msg83744#msg83744
The .log is posted by Uthilian.  I've checked the code for the spawn point and the convoy to see what I've missed, but I can't figure it out.  All I know is that the game crashes when the convoy spawns.

I answered in your mod's thread. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on January 12, 2013, 08:30:13 PM
Thanks!  Aside from that stupid feeling I have, I appreciate it. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on January 12, 2013, 09:35:45 PM
IS there anyway to make it so when a mirv splits it doesn't leave a crapload of particles behind?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 12, 2013, 11:49:42 PM
One more crazy one for tonight. I'm trying to create a ship system that benefits other ships in the fleet in a similar manner to battlefield objectives, such as raising weapon ranges, etc.

But I can't find a way to do it! It's easy to make it apply to the ship using the system, but the only idea I've had so far to use it with the fleet is by trying to invoke BattleObjectivesEffectsPlugin.

However, any attempt to actually use this in the system code results in a crash even just trying to enter the refit screen for the ship.

Am I missing something or is this currently not possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 12, 2013, 11:56:43 PM
It's possible, but you will need the current CombatEngineAPI to do it. Once you have the engine, you can use CombatEngineAPI's getShips(), then filter those with ShipAPI's getOwner().

The easiest/most reusable way to get at the current engine is to add something similar to the following script under data/scripts/plugins:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import java.util.List;

public class CombatUtils implements EveryFrameCombatPlugin
{
    private static CombatEngineAPI engine;
    private static float combatTime = 0f;

    public static CombatEngineAPI getCombatEngine()
    {
        return engine;
    }

    public static float getElapsedCombatTime()
    {
        return combatTime;
    }

    @Override
    public void advance(float amount, List events)
    {
        combatTime += amount;
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        CombatUtils.engine = engine;
        CombatUtils.combatTime = 0f;
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on January 13, 2013, 12:24:34 AM
Hey guys,

this one will be really weird, but Ill go with it anyways...

Would it be possible to have a weapon, that would actually emit shield´, in fixed direction, of course.
( :P)



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 13, 2013, 12:36:30 AM
Eh like an Omni shield?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on January 13, 2013, 12:40:38 AM
Eh like an Omni shield?


I better explain, what I need.

I wanted to create somesort of a shiled generator, that would be in fix pos. and cover
some part of the ship. (ship not having any vanila omni or front shields)

First I tried it with drones, that would act as seperateparts of the ship, however, they
are always "floating" a bit and ..just doesnt seem right.

Now, if a weapon would emit a ..i would suspect a front sheild, it would be much eaiser
and precise to put them on the ship - using weapon slots.. either make them hidden, built-in etc.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 13, 2013, 03:30:39 AM
With new decorative weapon type and ability to assign scripts i suppose you can do something like that. Look at shipAPI, shieldsAPI and weaponAPI files. There might be some clues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on January 13, 2013, 04:03:54 AM
With new decorative weapon type and ability to assign scripts i suppose you can do something like that. Look at shipAPI, shieldsAPI and weaponAPI files. There might be some clues.

Ill look into it then :)

I would love to figure it out, but sadly i feel its outside my league, never messed with these files,
(saying ahead - chances of me making it work are slim, no promises here  :D )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 13, 2013, 07:13:44 AM
Has anyone looked at what's possible with Weapon and Beam effects yet? Like, for instance a missile that does damage over time after impacting the enemy?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 13, 2013, 07:29:04 AM
Has anyone looked at what's possible with Weapon and Beam effects yet? Like, for instance a missile that does damage over time after impacting the enemy?

This, not yet supported;

My turn to ask for something, is there a way to get the EXACT coords of weapons or/and ships, i've had huge issues grabbing points inside the bounds, even with the polygon methods on the library that lazy shared. This would be useful for a huge number of projects for every mod that now using decorative weapons or modified combat engines
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 13, 2013, 09:00:27 AM
With new decorative weapon type and ability to assign scripts i suppose you can do something like that. Look at shipAPI, shieldsAPI and weaponAPI files. There might be some clues.

Ill look into it then :)

I would love to figure it out, but sadly i feel its outside my league, never messed with these files,
(saying ahead - chances of me making it work are slim, no promises here  :D )

Have you tried drones similar to the sensor drones on the Apogee, but making their accel & top speed values very high so that they are able to maintain position perfectly?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 13, 2013, 10:03:35 AM
Okay, thank you very much Alex, my bad.
I thought in missions ships where still associated with factions.
And yes in campaign mode it works properly.

Thank you again and sorry for wasting your time ;)

No problem, glad that's all it was :)

IS there anyway to make it so when a mirv splits it doesn't leave a crapload of particles behind?

Apparently, no - looking at that code, it's entirely hardcoded. Ugh. You know, it'd really help to have a list of "things that aren't moddable that would be nice to have be moddable" somewhere, as *I* don't tend to run into them, but you guys do. So something like this, shield colors/custom tech styles, etc. Not talking about something at the level of new features - just things that the engine clearly already does that just happen to not be exposed at all. Then I could just cherry-pick a few with each subsequent release and hopefully make a good dent in the list over time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 13, 2013, 10:06:59 AM
Is there some easy way to mod the value of one flux capacitor?  I'm thinking in particular of Okim's Ironclads mod, where the original ship flux capacities & shield strengths were built around the old 100 flux per capacitor value - resulting in the current game making flux capacitors (arguably) "too good" relative to where they should be.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 13, 2013, 10:12:45 AM
Is there some easy way to mod the value of one flux capacitor?  I'm thinking in particular of Okim's Ironclads mod, where the original ship flux capacities & shield strengths were built around the old 100 flux per capacitor value - resulting in the current game making flux capacitors (arguably) "too good" relative to where they should be.

Also hardcoded - another great candidate for that list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 13, 2013, 12:51:33 PM
It's possible, but you will need the current CombatEngineAPI to do it. Once you have the engine, you can use CombatEngineAPI's getShips(), then filter those with ShipAPI's getOwner().

The easiest/most reusable way to get at the current engine is to add something similar to the following script under data/scripts/plugins:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import java.util.List;

public class CombatUtils implements EveryFrameCombatPlugin
{
    private static CombatEngineAPI engine;
    private static float combatTime = 0f;

    public static CombatEngineAPI getCombatEngine()
    {
        return engine;
    }

    public static float getElapsedCombatTime()
    {
        return combatTime;
    }

    @Override
    public void advance(float amount, List events)
    {
        combatTime += amount;
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        CombatUtils.engine = engine;
        CombatUtils.combatTime = 0f;
    }
}
So question here. I tried to take a shortcut and simply call CombatEngineAPI:

Code
        public CombatEngineAPI engine;

However, it's always returning null (I know this because I nested a number of ifs to see what exactly I was getting a null pointer from, and it's this).
I was trying to keep all the code in this one java file, but it's looking like I might need to simply write the plugin file as you have there. Is this true, or is there some other way I can keep CombatEngineAPI from returning a null value?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 13, 2013, 01:22:59 PM
So question here. I tried to take a shortcut and simply call CombatEngineAPI:

Code
        public CombatEngineAPI engine;

However, it's always returning null (I know this because I nested a number of ifs to see what exactly I was getting a null pointer from, and it's this).
I was trying to keep all the code in this one java file, but it's looking like I might need to simply write the plugin file as you have there. Is this true, or is there some other way I can keep CombatEngineAPI from returning a null value?

All that line of code does is create an empty variable (if I wrote "public String warAndPeace;", I wouldn't automatically have the book's text assigned to that variable ;)). You need to get the engine the game is using, which is what the plugin does.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 13, 2013, 01:26:07 PM
So question here. I tried to take a shortcut and simply call CombatEngineAPI:

Code
        public CombatEngineAPI engine;

However, it's always returning null (I know this because I nested a number of ifs to see what exactly I was getting a null pointer from, and it's this).
I was trying to keep all the code in this one java file, but it's looking like I might need to simply write the plugin file as you have there. Is this true, or is there some other way I can keep CombatEngineAPI from returning a null value?

All that line of code does is create an empty variable (if I wrote "public String warAndPeace;", I wouldn't automatically have the book's text assigned to that variable ;)). You need to get the engine the game is using, which is what the plugin does.
Got it. I'm lazy, apparently.  :)




In other news: Arg, why does TachyonLanceEffect have to be compiled code?  :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 13, 2013, 01:27:32 PM
In other news: Arg, why does TachyonLanceEffect have to be compiled code?  :(

Check out starfarer.api.zip in starfarer-core, it has the source for that included.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 13, 2013, 02:17:16 PM
In other news: Arg, why does TachyonLanceEffect have to be compiled code?  :(

Check out starfarer.api.zip in starfarer-core, it has the source for that included.
Holy crap, that's what I needed.

Hopefully final question for a while: is there a way to print out lines to the starsector.log file for debugging?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 13, 2013, 02:27:39 PM
In other news: Arg, why does TachyonLanceEffect have to be compiled code?  :(

Check out starfarer.api.zip in starfarer-core, it has the source for that included.
Holy crap, that's what I needed.

Hopefully final question for a while: is there a way to print out lines to the starsector.log file for debugging?

Not as far as I know, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 13, 2013, 08:02:02 PM
Not as far as I know, unfortunately.

Where does stuff go if using System.out.println()? If that doesn't end up in the log, it should end up on the console - so if you run starsector.bat instead of the .exe, you should see its output in the console window the .bat pops up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 14, 2013, 11:32:52 AM
Is it possible to get the value for a ship's sight range? I can see how to find out the current bonus to the sight range, but not the actual sight range?

I ask because I'm trying to make a ship provide allied bonuses (and enemy debuffs) but would rather it do it only within its sight range rather than across the entire map.


On that same note, is it possible to have a ship system cause status messages to show up on the player's screen if the system is being used by another ship? Same system--it would be nice to tell the player that they are being debuffed by an enemy ship, or receiving buffs from a friendly AI-controlled ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 14, 2013, 02:16:33 PM
How can I make a weapon animate in a different way than playing the animation over and over as long as the mouse button is held down? I'd like for the animation to play to completion after the weapon has fired a bullet and then rest at the initial frame until the next time it fires. Or at the very least, have the animation reset whenever a new round is fired.

E: (http://i14.photobucket.com/albums/a350/cycerin/SolenoidQuenchCannon_zps9c3fd01f.gif)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 14, 2013, 03:00:54 PM
That depends on the firerate of the weapon and the number of frames. You can time it so that the animation finishes after a bullet was fired and resets before a new one is fired.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 14, 2013, 04:50:48 PM
Is it possible to get the value for a ship's sight range? I can see how to find out the current bonus to the sight range, but not the actual sight range?

I ask because I'm trying to make a ship provide allied bonuses (and enemy debuffs) but would rather it do it only within its sight range rather than across the entire map.

On that same note, is it possible to have a ship system cause status messages to show up on the player's screen if the system is being used by another ship? Same system--it would be nice to tell the player that they are being debuffed by an enemy ship, or receiving buffs from a friendly AI-controlled ship.

No, on both counts. Both make good candidates for the "hardcoded/not exposed, would be nice if was made moddable" list. Although the combat message widget is something I'm not happy with and would like to revisit extensively at some point, if I can.

How can I make a weapon animate in a different way than playing the animation over and over as long as the mouse button is held down? I'd like for the animation to play to completion after the weapon has fired a bullet and then rest at the initial frame until the next time it fires. Or at the very least, have the animation reset whenever a new round is fired.

You could either 1) sync up the animation with the rate of fire of the weapon - it's likely that it may get out of sync after a long time spent firing continuously, but has the virtue of being a simple solution, or 2) write a custom EveryFrameWeaponEffectPlugin to play the animation - probably based on weapon.getRemainingCooldown()/weapon.isFiring()/weapon.getAnimation().setFrame(int), etc.

Note that for #1, it should play through the entire animation cycle and eventually reset to the first frame, even if you only tap the mouse. If that's not happening, and you can send me a mod with a working example of that, I'll be happy to take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 14, 2013, 05:10:19 PM

As a workaround then, what is the maximum normal sight range on ships?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 14, 2013, 06:03:37 PM
3000.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 14, 2013, 07:07:33 PM
Awesome, thanks.

Also: I'm pretty sure there isn't, but is there a way to force a ship's AI to change targets?

Asking because I'm wondering if there is a way to force the AI to shoot a friendly besides temporarily switching the owner
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 14, 2013, 07:10:57 PM
No, there isn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 15, 2013, 02:30:56 AM
You could either 1) sync up the animation with the rate of fire of the weapon - it's likely that it may get out of sync after a long time spent firing continuously, but has the virtue of being a simple solution, or 2) write a custom EveryFrameWeaponEffectPlugin to play the animation - probably based on weapon.getRemainingCooldown()/weapon.isFiring()/weapon.getAnimation().setFrame(int), etc.

Note that for #1, it should play through the entire animation cycle and eventually reset to the first frame, even if you only tap the mouse. If that's not happening, and you can send me a mod with a working example of that, I'll be happy to take a look.

The issue is that I want a chargeup time for the weapon, and the weapon starts animating while it's charging. That probably forces me to make a plugin... hmm. This is getting complicated.

Still great that the game supports this sort of thing already, though. Seriously.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on January 15, 2013, 02:52:18 PM
Hey, how difficult would it be to have ballistics weapons have shell casings fly out and float off into space? I thought it would be a nice little detail to add...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 15, 2013, 07:49:40 PM
I've just created a system that allows a carrier to teleport a player's most damaged wing to itself. It works great, the only problem is that the fighters don't get the phase teleport animation.

Since I cannot find any code for the phase teleporter or skimmer, I can't see any examples of how to tell the game that it should be playing the phase teleport animations. Is there any way for me to do this, or is it a feature that is currently unmoddable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LostInTheWired on January 15, 2013, 09:30:33 PM
I've been looking in the files of a mod, trying to figure out why a carrier in it isn't...acting like a carrier (won't rally at Rally Carrier commands).  Is this set anywhere?  It has a launch bay, so if that's how it selects carriers, it's not quite working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 15, 2013, 09:53:44 PM
I've been looking in the files of a mod, trying to figure out why a carrier in it isn't...acting like a carrier (won't rally at Rally Carrier commands).  Is this set anywhere?  It has a launch bay, so if that's how it selects carriers, it's not quite working.
you need to put CARRIER in the 'hint' column in the ships,csv file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 17, 2013, 10:13:01 AM
Is it possible that you can't have more than 4 backgrounds?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nekora on January 17, 2013, 11:29:13 AM
Using the new hit effects system is it possible to have a beam weapon bounce to hit another target, like a chain lightning type weapon, or could a projectile weapon do the same?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 17, 2013, 12:53:05 PM
Using the new hit effects system is it possible to have a beam weapon bounce to hit another target, like a chain lightning type weapon, or could a projectile weapon do the same?

Yes, you can do that with projectiles easily. We can't spawn beams in our code yet, but you could make something similar with lightning arcs (since you mentioned chain lightning, that might work better anyway). :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nekora on January 17, 2013, 12:57:51 PM
Yes, you can do that with projectiles easily. We can't spawn beams in our code yet, but you could make something similar with lightning arcs (since you mentioned chain lightning, that might work better anyway). :)

Cool, could you show me an example of this? i started a thread asking for examples here > http://fractalsoftworks.com/forum/index.php?topic=5423.msg84776#msg84776
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on January 20, 2013, 10:41:25 AM
Is it possible to get an existing station and set it to a new orbit\location?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 20, 2013, 11:30:09 AM
Im having trouble getting a TractorBeam to work, its for the startreker mod, its suppose to be a borg weapon of doom that feeds on player tears, but right now its feeding on my tears  :'(

Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;
import org.lwjgl.util.vector.Vector2f;
import org.lazywizard.lazylib.MathUtils;

public class TractorBeamEffect implements BeamEffectPlugin {

private CombatEntityAPI currentArc = null;
private IntervalUtil fireInterval = new IntervalUtil(0.2f, 0.3f);

public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {

if (currentArc != null) {
if (!engine.isEntityInPlay(currentArc)) {
currentArc = null;
}//if
}//if

CombatEntityAPI target = beam.getDamageTarget();
if (target != null && target instanceof ShipAPI && (target.getShield() == null || !target.getShield().isWithinArc(beam.getTo()))) {
if (beam.getBrightness() >= 1f) {
fireInterval.advance(amount);
if (fireInterval.intervalElapsed()) {
Vector2f dir = Vector2f.sub(beam.getTo(), beam.getFrom(), new Vector2f());
if (dir.lengthSquared() > 0) dir.normalise();
dir.scale(5f);
Vector2f point = Vector2f.sub(beam.getTo(), dir, new Vector2f());
float emp = beam.getWeapon().getDerivedStats().getBurstDamage() * .667f;
float dam = emp * 0.25f;
engine.spawnEmpArc(beam.getSource(), point, beam.getDamageTarget(), beam.getDamageTarget(),
//engine.spawnEmpArc(beam.getSource(), beam.getFrom(), beam.getSource(), beam.getDamageTarget(),
  DamageType.ENERGY,
  dam, // damage
  emp, // emp
  100000f, // max range
  "tachyon_lance_emp_impact",
  30f, // thickness
  new Color(68,250,50,255),
  new Color(212,255,192,255)
  );
                                                Vector2f velocity, direction;
                                                float distance;

                                                velocity = beam.getDamageTarget().getVelocity();
                                                distance = MathUtils.getDistance(beam.getDamageTarget(), beam.getSource());
                                                // Normalized directional vector
                                                direction = MathUtils.getDirectionalVector(beam.getDamageTarget(), beam.getSource());

                                                float strength = distance * 300f;
                                                velocity.set(velocity.x + (direction.x * strength * amount), velocity.y + (direction.y * strength * 100f));
                                }//if
}//if
}//if
}//advance
}//class

Based on LazyWizard blackhole code and a copy of the tachyon lance vanila weapon effect.

It semi works, it not pulling but it stops a ship from moving, heres a sneak peak:
Spoiler
(https://dl.dropbox.com/u/32263294/screenshot000.png)
[close]

I still need to make a "weaker" version of it, based on hull sizes for the other factions, this one should not care what size the ship is, he will pull it in like it was nothing while getting emp dmg on it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 20, 2013, 12:17:46 PM
Mind if I use that "movement stopper" code for Rejection? Because that would totally fit an EW-frigate!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 20, 2013, 12:21:50 PM
Im having trouble getting a TractorBeam to work, its for the startreker mod, its suppose to be a borg weapon of doom that feeds on player tears, but right now its feeding on my tears  :'(

Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;
import org.lwjgl.util.vector.Vector2f;
import org.lazywizard.lazylib.MathUtils;

public class TractorBeamEffect implements BeamEffectPlugin {

private CombatEntityAPI currentArc = null;
private IntervalUtil fireInterval = new IntervalUtil(0.2f, 0.3f);

public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {

if (currentArc != null) {
if (!engine.isEntityInPlay(currentArc)) {
currentArc = null;
}//if
}//if

CombatEntityAPI target = beam.getDamageTarget();
if (target != null && target instanceof ShipAPI && (target.getShield() == null || !target.getShield().isWithinArc(beam.getTo()))) {
if (beam.getBrightness() >= 1f) {
fireInterval.advance(amount);
if (fireInterval.intervalElapsed()) {
Vector2f dir = Vector2f.sub(beam.getTo(), beam.getFrom(), new Vector2f());
if (dir.lengthSquared() > 0) dir.normalise();
dir.scale(5f);
Vector2f point = Vector2f.sub(beam.getTo(), dir, new Vector2f());
float emp = beam.getWeapon().getDerivedStats().getBurstDamage() * .667f;
float dam = emp * 0.25f;
engine.spawnEmpArc(beam.getSource(), point, beam.getDamageTarget(), beam.getDamageTarget(),
//engine.spawnEmpArc(beam.getSource(), beam.getFrom(), beam.getSource(), beam.getDamageTarget(),
  DamageType.ENERGY,
  dam, // damage
  emp, // emp
  100000f, // max range
  "tachyon_lance_emp_impact",
  30f, // thickness
  new Color(68,250,50,255),
  new Color(212,255,192,255)
  );
                                                Vector2f velocity, direction;
                                                float distance;

                                                velocity = beam.getDamageTarget().getVelocity();
                                                distance = MathUtils.getDistance(beam.getDamageTarget(), beam.getSource());
                                                // Normalized directional vector
                                                direction = MathUtils.getDirectionalVector(beam.getDamageTarget(), beam.getSource());

                                                float strength = distance * 300f;
                                                velocity.set(velocity.x + (direction.x * strength * amount), velocity.y + (direction.y * strength * 100f));
                                }//if
}//if
}//if
}//advance
}//class

Based on LazyWizard blackhole code and a copy of the tachyon lance vanila weapon effect.

It semi works, it not pulling but it stops a ship from moving, heres a sneak peak:
Spoiler
(https://dl.dropbox.com/u/32263294/screenshot000.png)
[close]

I still need to make a "weaker" version of it, based on hull sizes for the other factions, this one should not care what size the ship is, he will pull it in like it was nothing while getting emp dmg on it

You're probably having problems because you have the pull effect inside of the if (fireInterval.intervalElapsed()) block. That means it will only execute once about every 15 frames - since the velocity change from the black hole code is implemented gradually, this means there will be almost no effect at all.

Code
float strength = distance * 300f;

You might want to change this as well. Strength equals the net change in velocity per second, and with this you'll be pulling a ship in at max speed, probably crushing them against your hull. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 20, 2013, 12:33:18 PM
You're probably having problems because you have the pull effect inside of the if (fireInterval.intervalElapsed()) block. That means it will only execute once about every 15 frames - since the velocity change from the black hole code is implemented gradually, this means there will be almost no effect at all.
Code
float strength = distance * 300f;

You might want to change this as well. Strength equals the net change in velocity per second, and with this you'll be pulling a ship in at max speed, probably crushing them against your hull. :)

Yes

and actually its making it spinning instead of crushing into the hull (it doesnt matter if it does do that, we are the borg, we couldnt care less what happens to your puny ships), i had one ship destroyed while under its effect that it literally got falcon punched out of the combat zone while spinning at a astronomical rate

How about setting depending on ship mass:
float strength = distance * (float)Math.abs((beam.getSource().getMass() - beam.getDamageTarget().getMass()));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 20, 2013, 12:34:25 PM
Mind if I use that "movement stopper" code for Rejection? Because that would totally fit an EW-frigate!

Sure, but it needs tuning to actually not roflstomb anything regardless the hull size or velocity it has
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 20, 2013, 12:39:09 PM
and actually its making it spinning instead of crushing into the hull (it doesnt matter if it does do that, we are the borg, we couldnt care less what happens to your puny ships), i had one ship destroyed while under its effect that it literally got falcon punched out of the combat zone while spinning at a astronomical rate

Code
velocity.set(velocity.x + (direction.x * strength * amount), velocity.y + (direction.y * strength * 100f));

Why is the y velocity change being multiplied by 100 instead of amount? Since amount will usually be about 0.016, that's a significant difference in power. ;) That might be why it's spinning (the AI trying to compensate for being shoved aside).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 20, 2013, 12:41:19 PM
Goes without saying, will propably have a hefty flux buildup.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 20, 2013, 12:49:38 PM
and actually its making it spinning instead of crushing into the hull (it doesnt matter if it does do that, we are the borg, we couldnt care less what happens to your puny ships), i had one ship destroyed while under its effect that it literally got falcon punched out of the combat zone while spinning at a astronomical rate

Code
velocity.set(velocity.x + (direction.x * strength * amount), velocity.y + (direction.y * strength * 100f));

Why is the y velocity change being multiplied by 100 instead of amount? Since amount will usually be about 0.016, that's a significant difference in power. ;) That might be why it's spinning (the AI trying to compensate for being shoved aside).



ops, i was testing something, its already amount on my side not 100f, heh

Its a nice Master of Orion 2 Gyro copy perse

---

EDIT: with the ship mass vs target mass, seems to hold the enemy ship in place, still spins a little if it tries to move away (expected) but doesnt pull

EDIT 2: Also noticed that i cant change the width of the beam depending on the targets size, theres no API support for it ex:
Spoiler
(http://allforthecustomer.com/wp-content/uploads/2011/07/Tractor-Beam.jpg)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 21, 2013, 06:44:45 AM
Ok, is it possible that the current build can't use additional backgrounds?

Turns out when you are in dev mode changes to the background appearently get scrapped. Weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 21, 2013, 09:57:14 AM
Ok, is it possible that the current build can't use additional backgrounds?

Turns out when you are in dev mode changes to the background appearently get scrapped. Weird.

Yeah - reason is to speed up combat loading, as - due to its size - the background is the one thing that isn't just loaded on startup, and is actually loaded from disk whenever it needs to change. A matter of a few seconds, but those add up to quite an annoyance when you're doing it all the time :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 21, 2013, 10:15:55 AM
Yeah I thought so, was really confused at first though :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nekora on January 22, 2013, 04:54:43 AM
Regarding the spawnEmpArc() the notes say that you can target this to a specific location by passing in a custom class as the combatentity target: "@param empTargetEntity Target of the EMP arc. If it's a ship, it will randomly pick an engine nozzle/weapon to arc to. Can also pass in a custom class implementing CombatEntityAPI to visually target the EMP at a specific location (and not do any damage)."

Does anyone know a way to do this?

I was thinking allong the lines of useing addSmoothParticle(beam.getTo(), target.getVelocity(), 1f, 0f, .5f, CORE_COLOR); to create a teporary entity to target but couldnt get this to work >_<

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on January 22, 2013, 05:14:21 AM
Got an issue I've not been able to solve, and it has made editing ships harder since I can't use Trybolot's ship editor.

Here's the thing. I had to add in custom engines manually for the ships. I found it easier to edit the hull files manually after changing the layout of the hull text from:

Spoiler
(http://i1022.photobucket.com/albums/af343/erick_doe/Starfarer/code_01_zpsb6476261.png)
[close]

to

Spoiler
(http://i1022.photobucket.com/albums/af343/erick_doe/Starfarer/code_02_zps4642aab8.png)
[close]

Unfortunately, I don't know how to change back the layout without manually changing every little thing. Because while Starsector has no problem with my new layout, Trybolot's ship editor does.

Any help would be appreciated.

http://fractalsoftworks.com/forum/index.php?topic=2381.450
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on January 22, 2013, 05:47:41 AM
Posted a reply on your original topic
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 22, 2013, 02:38:00 PM
Me and EnderNerdcore have been trying to refine the Burst Maneuvering Jets system for a while now. It's currently the major thing preventing me from releasing a new Blackrock version. At this point, it works a lot like intended, except the system tries to bump you in a "straight east/west/north/south" direction if you use it while travelling diagonally at any decent speed. It seems like it has trouble clamping in the correct way... if that makes any sense.

The goal is still to give the ship a short, elegant burst of speed like a fish moving underwater. I half suspect that a lot of the current trouble is due to messing around with deceleration to prevent the ship from being able to change direction in a sudden jerk mid-burst, and endless attempts to get the clamping right to take the boost smoothly from full effect down to normal max speed.

Code:
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import data.scripts.plugins.CombatUtils;
import java.lang.Math;

public class DesdinovaBurstJetsStats implements ShipSystemStatsScript {

        public CombatEntityAPI ourShip;
        public ShipAPI ship;
        public CombatEngineAPI engine;
        CombatUtils utility = new CombatUtils();
        public Math math;
       
public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
                ourShip = stats.getEntity();
                boolean fluxIsAtZero = false;               
                ship = utility.getOwner(stats);
                if (ship != null) {
                    if (ship.getFluxTracker().getFluxLevel() == 0f) { fluxIsAtZero = true; }
                }
if (state == ShipSystemStatsScript.State.OUT) {
                        if (effectLevel < 1f) {
                            stats.getMaxSpeed().modifyFlat(id, (effectLevel)*stats.getMaxSpeed().getModifiedValue()); // to slow down ship to its regular top speed while powering drive down
                            stats.getDeceleration().unmodify(id);
                           
                            //start clamping our Y velocity
                            if (ourShip.getVelocity().getY() > stats.getMaxSpeed().getBaseValue() && !fluxIsAtZero) {
                                ourShip.getVelocity().set(ourShip.getVelocity().getX(), (stats.getMaxSpeed().getModifiedValue()));
                            } else if (ourShip.getVelocity().getY() > stats.getMaxSpeed().getBaseValue() && fluxIsAtZero) {
                                ourShip.getVelocity().set(ourShip.getVelocity().getX(), (50f + stats.getMaxSpeed().getModifiedValue()));
                            }
                           
                            //start clamping our X velocity
                            if (math.abs(ourShip.getVelocity().getX()) > stats.getMaxSpeed().getBaseValue() && !fluxIsAtZero) {
                                if (ourShip.getVelocity().getX() > 0f) {
                                    ourShip.getVelocity().set((stats.getMaxSpeed().getModifiedValue()), ourShip.getVelocity().getY());
                                } else if (ourShip.getVelocity().getX() < 0f) {
                                    ourShip.getVelocity().set((-1.0f * stats.getMaxSpeed().getModifiedValue()), ourShip.getVelocity().getY());
                                }
                            } else if (math.abs(ourShip.getVelocity().getX()) > stats.getMaxSpeed().getBaseValue() && fluxIsAtZero) {
                                if (ourShip.getVelocity().getX() > 0f) {
                                ourShip.getVelocity().set((50f + stats.getMaxSpeed().getModifiedValue()), ourShip.getVelocity().getY());
                                } else if (ourShip.getVelocity().getX() < 0f) {
                                    ourShip.getVelocity().set((-1.0f * stats.getMaxSpeed().getModifiedValue() - 50f), ourShip.getVelocity().getY());
                                }
                               
                            }
                        }
} else  {
                        stats.getMaxSpeed().modifyFlat(id, 200f);
stats.getAcceleration().modifyFlat(id, 600f * effectLevel);
stats.getDeceleration().modifyMult(id, 0.2f);
stats.getTurnAcceleration().modifyFlat(id, 90f * effectLevel);
stats.getTurnAcceleration().modifyPercent(id, 200f * effectLevel);
stats.getMaxTurnRate().modifyMult(id, 2f * effectLevel);
stats.getMaxTurnRate().modifyPercent(id, 130f * effectLevel);
                }

}
public void unapply(MutableShipStatsAPI stats, String id) {
                stats.getMaxSpeed().unmodify(id); // to slow down ship to its regular top speed while powering drive down
                stats.getMaxTurnRate().unmodify(id);
                stats.getDeceleration().unmodify(id);
                stats.getMaxSpeed().unmodify(id);
                stats.getMaxTurnRate().unmodify(id);
                stats.getTurnAcceleration().unmodify(id);
                stats.getAcceleration().unmodify(id);
                stats.getDeceleration().unmodify(id);
                ourShip = stats.getEntity();
                boolean fluxIsAtZero = false;
                ship = utility.getOwner(stats);
                if (ship != null) {
                    if (ship.getFluxTracker().getFluxLevel() == 0f) { fluxIsAtZero = true; }
                }               
                if (ourShip.getVelocity().getY() >= stats.getMaxSpeed().getBaseValue() && !fluxIsAtZero) {
                    ourShip.getVelocity().set(ourShip.getVelocity().getX(), stats.getMaxSpeed().getBaseValue());
                } else if (ourShip.getVelocity().getY() >= stats.getMaxSpeed().getBaseValue() && fluxIsAtZero) {
                    ourShip.getVelocity().set(ourShip.getVelocity().getX(), (stats.getMaxSpeed().getBaseValue() + 50.0f));
                }
                if (math.abs(ourShip.getVelocity().getX()) >= stats.getMaxSpeed().getBaseValue() && !fluxIsAtZero) {
                    if (ourShip.getVelocity().getX() > 0) {
                        ourShip.getVelocity().set(stats.getMaxSpeed().getBaseValue(), ourShip.getVelocity().getY());
                    } else if (ourShip.getVelocity().getX() < 0) {
                        ourShip.getVelocity().set(-1.0f * stats.getMaxSpeed().getBaseValue(), ourShip.getVelocity().getY());
                    }
                   
                } else if (math.abs(ourShip.getVelocity().getX()) >= (stats.getMaxSpeed().getBaseValue() + 50f) && fluxIsAtZero) {
                    if (ourShip.getVelocity().getX() > 0) {
                        ourShip.getVelocity().set((stats.getMaxSpeed().getBaseValue() + 50.0f), ourShip.getVelocity().getY());
                    } else if (ourShip.getVelocity().getX() < 0) {
                        ourShip.getVelocity().set((-1.0f * stats.getMaxSpeed().getBaseValue() - 50.0f), ourShip.getVelocity().getY());
                    }
                }
               
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("increased engine power", false);
} else if (index == 1) {
return new StatusData("cannot decelerate", false);
}
return null;
}
}

The CSV values for the system are 0.2 chargeup, 0.2 active, 1.1 out. No clamping in the .system file. Stacks with 0-flux boost.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 03:08:09 PM
(and yes, I realize my code there could be simplified a bit, but it shouldn't change the functionality ;))
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 22, 2013, 03:14:04 PM
Cycerin: The issue there is that you're clamping X and Y independently of each other.  What you actually want to do is clamp speed, not velocity.x & velocity.y.

So, some psuedocode:
float speed = Math.sqrt( velocity.x * velocity.x + velocity.y * velocity.y );
float targetspeed = some calculation involving current speed, max speed, & deceleration - basically, what speed do you actually want to be going at right now.
float multiplier = targetspeed / speed;
velocity.x = velocity.x * multiplier;
velocity.y = velocity.y * multiplier;

You may also want to do some extra work with your fluxIsAtZero value & hard-coded zero-flux speed boost of 50 to account for possible skill perks (which can allow "zero flux" to persist up to 25% flux, and/or, cause the zero flux speed boost to be 75 instead of 50.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 03:47:56 PM
Cycerin: The issue there is that you're clamping X and Y independently of each other.  What you actually want to do is clamp speed, not velocity.x & velocity.y.

So, some psuedocode:
float speed = Math.sqrt( velocity.x * velocity.x + velocity.y * velocity.y );
float targetspeed = some calculation involving current speed, max speed, & deceleration - basically, what speed do you actually want to be going at right now.
float multiplier = targetspeed / speed;
velocity.x = velocity.x * multiplier;
velocity.y = velocity.y * multiplier;

You may also want to do some extra work with your fluxIsAtZero value & hard-coded zero-flux speed boost of 50 to account for possible skill perks (which can allow "zero flux" to persist up to 25% flux, and/or, cause the zero flux speed boost to be 75 instead of 50.)
I'll reply since I wrote a lot of that code:

We tried some of that. The problem is that there is no direct code method to clamp speed itself (you can set maxSpeed but the game does not force the ship down to that if it is over that max speed and coasting, only if the player is actively holding a direction key), so you have to deal with the Vector2f velocity in some way.

So the issue isn't that it's not working--it is working--but rather that under some conditions (triggered with diagonal movement) there is a small "bump" in a cardinal direction near the end of the system working.

Part of the problem is that from what I can tell, Starsector uses the deceleration value of a ship to determine how fast it can change its velocity vector between the X and Y directions. (as a bit of explanation, in Starsector the velocity vector X is side-to-side movement relative to the ship's heading, and Y is forward-backward movement relative to the ship's heading). So, we drop the deceleration value to prevent players from slowing down rapidly in the Y direction (you can't move forward and then stop on a dime).

Good point about the skill perks though. If we can get this last "bump" figured out, I'll also update the code. Anyone know of an easy way to do this, or does it just involve calling some character skill functions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 22, 2013, 03:55:03 PM
We tried some of that. The problem is that there is no direct code method to clamp speed itself (you can set maxSpeed but the game does not force the ship down to that if it is over that max speed and coasting, only if the player is actively holding a direction key), so you have to deal with the Vector2f velocity in some way.

Which is why I provided pseudocode to take a vector that's specified in x and y terms, and clamp by speed.  For example, if targetspeed in the pseudocode I provided ended up at 100, then - after setting velocity.x and velocity.y - the overall speed would be 100.  (Maybe because velocity was 100,0, or 0,100, or -70.71,70.71, or any other vector with a magnitude of 100, give or take small variations due to inaccuracies in floating point calculations.)

Edit: By comparison, if you clamp by X and Y separately, then, with a target speed of 100, you'd end up with maybe 100,0, or 100,100 - in other words, when moving diagonally, you'll end up going faster than if not moving diagonally.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 22, 2013, 03:58:29 PM
Part of the problem is that from what I can tell, Starsector uses the deceleration value of a ship to determine how fast it can change its velocity vector between the X and Y directions. (as a bit of explanation, in Starsector the velocity vector X is side-to-side movement relative to the ship's heading, and Y is forward-backward movement relative to the ship's heading). So, we drop the deceleration value to prevent players from slowing down rapidly in the Y direction (you can't move forward and then stop on a dime).

That may be the problem, then, because that's not true.

1) The velocity x and y are in absolute coordinates, not relative to the facing of the ship. x is left to right and y is down to up, just like on a math graph.

2) When you set those values directly, the ship's deceleration value doesn't play into it (nor does anything else - it's just set to whatever you set it to. Well, it'll also get clamped to 600 by the engine, but that's it.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 04:06:37 PM
Part of the problem is that from what I can tell, Starsector uses the deceleration value of a ship to determine how fast it can change its velocity vector between the X and Y directions. (as a bit of explanation, in Starsector the velocity vector X is side-to-side movement relative to the ship's heading, and Y is forward-backward movement relative to the ship's heading). So, we drop the deceleration value to prevent players from slowing down rapidly in the Y direction (you can't move forward and then stop on a dime).

That may be the problem, then, because that's not true.

1) The velocity x and y are in absolute coordinates, not relative to the facing of the ship. x is left to right and y is down to up, just like on a math graph.

2) When you set those values directly, the ship's deceleration value doesn't play into it (nor does anything else - it's just set to whatever you set it to. Well, it'll also get clamped to 600 by the engine, but that's it.)
Oh, I know that about #2, which is exactly why we're doing it that way (to essentially set our own forced rapid deceleration). It seemed like this was having an influence on what was happening when the player changed which keys they were pressing during the operation of the system (such as going diagonally then switching to forward-only motion while the system was engaged).

#1 makes sense then. I had initially assumed it was in polar coordinates (angle, magnitude) but testing showed that that wasn't true. I'm not sure if that actually changes how this system works, though, since it never takes facing into account...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 04:08:44 PM
We tried some of that. The problem is that there is no direct code method to clamp speed itself (you can set maxSpeed but the game does not force the ship down to that if it is over that max speed and coasting, only if the player is actively holding a direction key), so you have to deal with the Vector2f velocity in some way.

Which is why I provided pseudocode to take a vector that's specified in x and y terms, and clamp by speed.  For example, if targetspeed in the pseudocode I provided ended up at 100, then - after setting velocity.x and velocity.y - the overall speed would be 100.  (Maybe because velocity was 100,0, or 0,100, or -70.71,70.71, or any other vector with a magnitude of 100, give or take small variations due to inaccuracies in floating point calculations.)

Edit: By comparison, if you clamp by X and Y separately, then, with a target speed of 100, you'd end up with maybe 100,0, or 100,100 - in other words, when moving diagonally, you'll end up going faster than if not moving diagonally.
Got it. While that shouldn't matter too much for our forced-deceleration clamping (it may have an effect, but it will be small), that actually might be what is wrong with our end-of-system capping (as opposed to clamping) where we make sure that the ship isn't moving faster than it should be. That actually would explain the cardinal-direction "bump".

Oversight on my part. Rusty java skills + smoking weed while doing vector calculations made me completely overlook the fact that we could end up with too much magnitude of velocity.


Now, if only velocity was being expressed in polar coordinates...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 22, 2013, 04:22:45 PM
I'd strongly suggest fixing it in both places - dealing with x and y separately is a great way to get a system that has biases either towards or against cardinal directions.

For another example, suppose you're taking a ship moving at 100,200 (actual speed ~223), and you want to reduce its speed to 100.  Simply setting velocity to 100,100 will not only not reduce the speed to 100 (it'll actually be moving at ~141), it also changes the direction in which the ship is moving.  The actual correct behavior would result in a velocity vector of roughly 45,89 - which is actually at speed ~100, and, just as important, going in the same direction as the initial vector.
(Note: values in above example rounded to nearest whole number for brevity.)

This is a slightly extreme example to make the point - but even if you're making small adjustments, you'll still get behavior that's slightly off.  For your forced deceleration clamping, for example, you might actually see something like:
100,200, clamped to speed 200: your result: 100,200; accurate result: 89.4,178.9
100,200, clamped to speed 190: your result: 100,190; accurate result: 85.0,169.9
etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 04:25:59 PM
That's a fair point, though those conditions are most likely to happen in the (very) small frame of time during the initial system activation while the acceleration is very high if the player is rapidly changing the directions they are trying to move in.

I suppose fixing it in one place will generate re-usable code to fix it in the other.  :)


EDIT: it's either that or I write a library to convert the whole thing to polar coordinates and back again. Harder to write at the beginning but so much easier to deal with for future systems.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 22, 2013, 04:28:38 PM
Yup!  And LazyWizard's utility library probably has functions already built to do this sort of thing for you; I just have no idea what they are because I haven't looked at it yet.

Edit: I'd avoid polar coordinates, myself.  I find them to be a bit of a nuisance - though it depends on what you're doing.  For just adjusting speed, yeah, polar saves you a call to square root; if you ever need to add two vectors, though, it's a pain and a half.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 22, 2013, 04:37:50 PM
Oversight on my part. Rusty java skills + smoking weed while doing vector calculations made me completely overlook the fact that we could end up with too much magnitude of velocity.

Let's not go there on this forum.


As far as velocity being polar vs cartesian, it's fairly simple to convert between the two with trig functions :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 06:24:19 PM
Well that makes things... rather simpler. Quick and dirty version below. Does NOT take into account player skills.


Code
                float currentSpeed = (float) math.sqrt((ourShip.getVelocity().getX() * ourShip.getVelocity().getX()) + (ourShip.getVelocity().getY() * ourShip.getVelocity().getY()));
                float desiredSpeed = stats.getMaxSpeed().getBaseValue();
                if (fluxIsAtZero) { desiredSpeed += 50f; }
                float multiplier =  desiredSpeed / currentSpeed;
                
                if (currentSpeed > desiredSpeed) {                    
                    ourShip.getVelocity().x *= multiplier;
                    ourShip.getVelocity().y *= multiplier;
                }
                  

EDIT4: that seems to do the trick. Now I just need to fetch player skills for the zero flux speed
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 22, 2013, 06:36:29 PM
Ah... not quite.  You'll want to add the +50 to desiredSpeed, not velocity.x and velocity.y.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 06:40:27 PM
Ah... not quite.  You'll want to add the +50 to desiredSpeed, not velocity.x and velocity.y.
Yep, just realized that in the past 30 seconds lol
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 22, 2013, 07:01:27 PM
Simpler than I thought, just had to use:

stats.getZeroFluxSpeedBoost().getModifiedValue();

and instead of comparing the flux to zero, I check that it is less than or equal to:

stats.getZeroFluxMinimumFluxLevel().getModifiedValue()


The lesson from all of this?
If your initial code is based on an incorrect assumption (in my case, that Velocity was in polar coordinates) then it's better to wipe clean and start over than to incrementally improve your code, because you'll end up with a mess.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 23, 2013, 02:44:29 PM
Thanks a lot to everyone for big help on getting this to work. It runs like a charm right now. ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 23, 2013, 07:14:55 PM
Hey guys, I'm getting a null pointer error in here that I'm unable to track down. I'm writing an onHit effect for a weapon shot. Basically, it deals bonus energy damage if it impacts the ship (and not its shields).

The game throws the NPE when this happens (i.e., testing against a Buffalo mk2)

The NPE from the log is here:
Code
36959 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
at data.scripts.weapons.ShardOnHitEffect.onHit(ShardOnHitEffect.java:27)
at com.fs.starfarer.combat.entities.BallisticProjectile.super(Unknown Source)
at com.fs.starfarer.combat.entities.BallisticProjectile.notifyDealtDamage(Unknown Source)
at com.fs.starfarer.combat.class.super.O0OO.super(Unknown Source)
at com.fs.starfarer.combat.class.B.o00000(Unknown Source)
at com.fs.starfarer.combat.class.B.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.F.ÖÖÒ000(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

And here's the concerned area of code:

Code
public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
if (!shieldHit && target instanceof ShipAPI) {
                        particleVelocity.x = ((float) Math.random() * 10f); //give the particle a random velocity.
                        particleVelocity.y = ((float) Math.random() * 10f); //Math.random() results in a number between 0.0 and 1.0
engine.applyDamage(target, point, damageAmount, DamageType.ENERGY, empAmount, false, dealsSoftFlux, engine);
                        engine.addHitParticle(point, particleVelocity, particleSize, particleBrightness, particleDuration, particleColor);
soundToPlay.playSound(soundName, pitch, volume, point, particleVelocity);
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nekora on January 23, 2013, 10:46:17 PM
Sometesting of the code shows that
Code
            particleVelocity.x = ((float) Math.random() * 10f); //give the particle a random velocity.
            particleVelocity.y = ((float) Math.random() * 10f); //Math.random() results in a number between 0.0 and 1.0

are causeing the problems. As for the corect code? not sure ill look into it.
Oh also the damage spawning line of code, you had "engine" as the source of the damage. I changed that to projectile.getSource(), dont know if that has any relevance though as it didnt fix the problem till i got rid of the .x .y lines of code.

EDIT*
After some testing i got the code to work... as for why? i dont know. Maybe its because i set up the particalVelocity vairable useing getVelocity()... not idea. Well:

heres what i used that worked without error:
Code
package data.scripts.weapons;

import java.awt.Color;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;

public class ExtraHitEffect implements OnHitEffectPlugin {

public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
if (!shieldHit && target instanceof ShipAPI)
{
//set vairables for the partical. Could do inside the call but will do it here
float particleSize = 15f;
float particleBrightness = 1f;
float particleDuration = 2f;
Color particleColor = new Color(85, 25, 215, 255);
Vector2f particleVelocity = projectile.getVelocity(); // Lines below were causing issues, so i replaced them for testing
                        particleVelocity.x = ((float) Math.random() * 10f); //give the particle a random velocity.
                        particleVelocity.y = ((float) Math.random() * 10f); //Math.random() results in a number between 0.0 and 1.0

//set damage vairables
float damageAmount = projectile.getDamageAmount() * .25f; //extra damage is 1/4 of full
float empAmount = projectile.getEmpAmount(); //extra emp is... well full amount of normal hit

engine.applyDamage(target, point, damageAmount, DamageType.ENERGY, empAmount, false, false, projectile.getSource());
                        engine.addHitParticle(point, particleVelocity, particleSize, particleBrightness, particleDuration, particleColor);
//soundToPlay.playSound(soundName, pitch, volume, point, particleVelocity);
}
}
}

Also, anyone able to take a look at my question earlier yet? http://fractalsoftworks.com/forum/index.php?topic=5061.msg85513#msg85513
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 23, 2013, 11:11:18 PM
Solved it. Turns out I can't just call the sound player like that. Instead, I have to use:

Global.getSoundPlayer().playSound(soundName, pitch, volume, point, projectile.getVelocity());

To use that, we have to add:

import com.fs.starfarer.api.Global;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nekora on January 24, 2013, 12:18:32 AM
Nice catch thereEnder nerd code, didnt even see that one. Okay heres another, trying to make a shot bounce off sheilds. i can spawn the shots by this:
Code
		if (shieldHit && target instanceof ShipAPI)
{
float angle = ((float) Math.random() * 360f) - 180f;
engine.spawnProjectile(projectile.getSource(), projectile.getWeapon(),
projectile.getWeapon().getId(), point, angle, null);
}
Now i know that i can get the location of the projectile by useing "point" and i can get the location or the target by useing target.getLocation(), but can anyone show me how to calculate the angle from point to target.getLocation()? Im asumeing theres trig involved >_<
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 24, 2013, 06:09:58 AM
Nice catch thereEnder nerd code, didnt even see that one. Okay heres another, trying to make a shot bounce off sheilds. i can spawn the shots by this:
Code
		if (shieldHit && target instanceof ShipAPI)
{
float angle = ((float) Math.random() * 360f) - 180f;
engine.spawnProjectile(projectile.getSource(), projectile.getWeapon(),
projectile.getWeapon().getId(), point, angle, null);
}
Now i know that i can get the location of the projectile by useing "point" and i can get the location or the target by useing target.getLocation(), but can anyone show me how to calculate the angle from point to target.getLocation()? Im asumeing theres trig involved >_<

Code
float angle = (float) Math.toDegrees(Vector2f.angle(point, target.getLocation());

Just a heads up, there's a bug in the current version (http://fractalsoftworks.com/forum/index.php?topic=5409.0) that causes redirected ballistic projectiles to not render correctly.

Edit: never mind, you're not redirecting, you're creating an entirely new projectile. Carry on. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 24, 2013, 06:14:36 PM
When I use:

engine.applyDamage(target, point, damageAmount, DamageType.KINETIC, empAmount, false, dealsSoftFlux, engine);

Does it just straight-up apply "damageAmount" to the ship ignoring armor and the damage type, or does it internally deal some fraction of that damage based on whether it hits armor or hull?  (I'm assuming not hitting shields, here).

The reason I ask is that I want this next line to show the amount of damage it really did:

engine.addFloatingDamageText(point, damageAmount, Color.blue, target, projectile.getSource().getMutableStats().getEntity());


EDIT: Updated the question for Kinetic since Energy always does 100% damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 25, 2013, 04:20:34 PM
The applyDamage will spawn the floating text if appropriate (i.e. if the target is visible, and a few other considerations). And yes, it takes armor etc into account.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on January 25, 2013, 04:28:32 PM
Quick question: is there any way to determine the render order of weapons? I've got large decorative weapons that seem to randomly overlap certain weapons.

(http://imageshack.us/a/img209/4712/avinf.jpg)

(http://imageshack.us/a/img716/3238/avclean.jpg)


As you can see, there should be two harpoon batteries in the middle there, but they're completely covered underneath the infection effects. It also seems to overlap the graviton beam hardpoints a bit as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 25, 2013, 04:56:19 PM
All the hardpoints get rendered before all turrets.
Within that, larger sizes get rendered last.
Within each size, racked missiles (i.e. like Harpoon, not like Swarmer) get rendered first.

After that, it's not deterministic. So, you want a small hardpoint - that won't quite take care of everything, but at least all the turrets (i.e, the stuff that moves a lot) will be over it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on January 25, 2013, 05:05:02 PM
Ah, that helps--thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 25, 2013, 05:20:00 PM
The applyDamage will spawn the floating text if appropriate (i.e. if the target is visible, and a few other considerations). And yes, it takes armor etc into account.
Strange. We actually weren't seeing the floating text until we added the floating text code.

Or was it (more likely) just adding the applyDamage amount to the normal damage floating text of the weapon itself?  (basically this is bonus damage that has a chance to occur if it hits the armor or hull instead of shields).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 25, 2013, 06:32:42 PM
The applyDamage will spawn the floating text if appropriate (i.e. if the target is visible, and a few other considerations). And yes, it takes armor etc into account.
Strange. We actually weren't seeing the floating text until we added the floating text code.

Or was it (more likely) just adding the applyDamage amount to the normal damage floating text of the weapon itself?  (basically this is bonus damage that has a chance to occur if it hits the armor or hull instead of shields).

It only shows floaties for stuff damaged by the player's ship (and that is also visible). It also shows floaties for anything that already has floaties - the thinking being that it was attacked by the player recently, and floaties over it may be useful. That second behavior may explain what you're seeing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on January 26, 2013, 03:53:21 PM
Noob question: why is this giving me "Line 516, Column 32: Expression "i" is not an rvalue"

(http://i.imgur.com/MYuFQbE.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 26, 2013, 05:04:49 PM
once "i" is used on the for cycle, its removed from the memory, you need to make it into the for cycle or add another integer incremental in the for cycle and use it instead
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on January 26, 2013, 05:50:23 PM
Argh, can you help me with a basic example of implementation of adding another integer incremental?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on January 26, 2013, 06:47:14 PM
Argh, can you help me with a basic example of implementation of adding another integer incremental?
use j, k, l, m, n, whatever you want. You can even name it integer1, integer2, etc
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on January 26, 2013, 06:57:20 PM
depending on what ur trying to do, why dont you just place those if(){player.setReputation} covering the for cycle
example

String[] SOV = ....
if(uscData.USC_FACTIONCHOICE.equals("SOV"))
for(int i = 0; i < SOV.length; i++)
{
player.setREP....
....
}

if i actually understood the code ur trying to implement for the starting player rep


else just declare  a few int values outside those for cycles

then inside those cycles add ++
example:

for(...)
randominteger++; or randominteger = i; or randominteger += 1;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on January 26, 2013, 07:00:08 PM
Thanks to both. I actually use this piece of code to both set the player initial standing and the general factions relationships, so it has a "player dependent" part and a "static" part.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 27, 2013, 01:19:18 AM
Hi there,

i have 2 questions.

1. is it possible to have a script that would firstly replace the starsector_title_alpha.png and secondly randomize that with every start of starsector another title would appear?

2. The number of burst determines the times a certain sound is played when a weapon is fired, right?
Is it possible to have one fixed sound for a burst of 6 projectiles. This sound would then play only once the weapon is fired.
At the moment i have a premade sound for a burst of 6 and the game is staggering the sound 6 times and that sounds ugly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 27, 2013, 09:47:52 AM
1. is it possible to have a script that would firstly replace the starsector_title_alpha.png and secondly randomize that with every start of starsector another title would appear?

2. The number of burst determines the times a certain sound is played when a weapon is fired, right?
Is it possible to have one fixed sound for a burst of 6 projectiles. This sound would then play only once the weapon is fired.
At the moment i have a premade sound for a burst of 6 and the game is staggering the sound 6 times and that sounds ugly.

1. No. All you can do is replace the image itself, but not dynamically via a script.

2. It's possible (using fireSoundOne - see heavymg.wpn for an example of something that plays a startup sound per burst and then individual sounds per shot). It's probably not a good idea to have all the shot sounds in the same file, though - it could desynced if the fps drops, or the gun could stop firing (due to ship being destroyed, weapon being disabled, flux running out, a vent or phase cloak being initiated, etc), but the full 6 sounds would play anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 27, 2013, 10:30:43 AM
Regarding your suggestion i used fireSoundOne. The issue with this was that whenever i pressed the mousebutton it would play
the sound. On continous fire (mousebutton pressed down) it would only play the sound once and fire the weapon after the first burst in silent mode. ;)

I changed the soundfile and am using fireSoundTwo now. works like a charm

thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on January 27, 2013, 10:49:08 AM
Is it possible to make a weapon with a "UNIVERSAL" type?, I don't mean universal hardpoints or turrets inside a ship file, but instead on the weapon itself, so it can be used in MISSILE, ENERGY, BALLISTIC and UNIVERSAL slots.

I'm kinda trying to make a hardpoint/turret cover "weapon", as sometimes ships benefit of not having all their slot filled, but I think open slots don't look very good.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 27, 2013, 10:55:59 AM
Is it possible to make a weapon with a "UNIVERSAL" type?, I don't mean universal hardpoints or turrets inside a ship file, but instead on the weapon itself, so it can be used in MISSILE, ENERGY, BALLISTIC and UNIVERSAL slots.

It's not. I guess you could make covers of every type and size :) (Fun!)

I'm kinda trying to make a hardpoint/turret cover "weapon", as sometimes ships benefit of not having all their slot filled, but I think open slots don't look very good.

There's a decent chance this may end up in the game at some point. We've talked about it internally - I think the idea is good, but it's just such a low priority right now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 28, 2013, 11:02:54 AM
I am trying to give the typing sound an 80's analog computer feeling and already have a sound ready.
The problem is there is still this little beep from the old typing sound, and i cant find it ;)

I tried the replace argument in the mod_info.json, failed for me, sound still there.

This is what i have at the moment:
sounds.json
Code
	"ui_typer_type":{ # played when text is gradually "typed out" on screen, like in the mission descriptions
"sounds":[
{"file":"sounds/TL/fx/ui/thule_ui_type01.ogg","pitch":1.0,"volume":0.3},
        ],
},
"ui_typer_buzz":{
"sounds":[
{"file":"sounds/TL/fx/ui/thule_ui_type01.ogg","pitch":0.5,"volume":0.3},
],
},

I am sure i overlook something, can somebody please tell?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 29, 2013, 03:39:50 AM
Another problem i ran into is the following.

I defined a special backgroundpicture for a single mission and it's not showing up.
I tried defining it as "background6" in the settings.json and id didnt work.

the format is .jpg, the path is correct. What could be the problem?

Code
{
"title":"Test Mission Punk Junker",
"difficulty":"HARD",
"icon":"icon.jpg",
"background":"graphics/backgrounds/background_punk.jpg"
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on January 29, 2013, 03:46:16 AM
@Thule

Is it the right size? Default Starsector backgrounds are 2048 x 2048. Not sure if that will matter though.

Is the filename all lower case, just like in the path "graphics/backgrounds/background_punk.jpg"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 29, 2013, 03:48:12 AM
Are you in dev mode? Because other backgrounds(except the default one) will not render when in that mode.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on January 29, 2013, 04:14:30 AM
right size (2048x2048) - check
lower case - check
dev mode disabled - there it is.

wow, didnt know that. Gets you thinking...
(http://cdn.memegenerator.net/instances/400x/31612783.jpg)

Thank you guys.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 29, 2013, 04:18:22 AM
NP, I did run into that same problem a few days ago ^^
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 29, 2013, 03:13:06 PM
So, having worked through the plugin, I am going to re-ask the question about how to add a starting ship in a more concrete way, here is my current code, and it doesn't seem to work:
Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.characters.CharacterCreationPlugin;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
import java.util.List;

public class IndustryCharacterCreation extends data.scripts.plugins.CharacterCreationPluginImpl {
    // Not using an enum for this because Janino doesn't support it.
    // It does, apparently, support using enums defined elsewhere - just can't compile new ones.

    private ResponseImpl OPTION1 = new ResponseImpl("Option 1");
    private ResponseImpl OPTION2 = new ResponseImpl("Option 2");
    private int stage = 0;
    private boolean isEntr = false;

    @SuppressWarnings("unchecked")
    @Override
    public List getResponses() {
        List result = super.getResponses();
        if (stage == 0) {
            result.add(OPTION1);
        } else if (stage == 1) {
            if (isEntr) {
                result.add(OPTION2);
            }
        }

        return result;
    }

    @Override
    public void submit(CharacterCreationPlugin.Response response, CharacterCreationPlugin.CharacterCreationData data) {
        super.submit(response, data);
        
        stage++;
        MutableCharacterStatsAPI stats = data.getPerson().getStats();

        if (response == OPTION1) {
            stats.addAptitudePoints(1);
            stats.addSkillPoints(2);
            data.getStartingCargo().getCredits().add(2000);
            isEntr = true;
        }
        if (response == OPTION2) {
            stats.addAptitudePoints(1);
            stats.addSkillPoints(2);
            data.addStartingShipChoice("buffalo_Standard");
            data.getStartingCargo().getCredits().add(2000f);
        }

    }

    @Override
    public void startingShipPicked(String variantId, CharacterCreationPlugin.CharacterCreationData data) {
        super.startingShipPicked(variantId, data);

        if (variantId.equals("buffalo_Standard")) {
            data.getStartingCargo().addFuel(20);
            data.getStartingCargo().addSupplies(20);
            data.getStartingCargo().addItems(CargoAPI.CargoItemType.RESOURCES, "omncompl_uncmaterial", 200);
            data.getStartingCargo().addCrew(CrewXPLevel.GREEN, 10);
            data.getStartingCargo().addMarines(2);
        }
    }
}

Edit: Well, this is "funny". After a small light bulb lit, I tried to move the file to plugins folder instead of world, and it is now working correctly >_<. Also had to change startignShipPicked as the super class was adding unnecesarry crew and resources due to no matching ship in it.
edited code:
Code
package data.scripts.plugins;

...

    @Override
    public void startingShipPicked(String variantId, CharacterCreationPlugin.CharacterCreationData data) {
        if (variantId.equals("buffalo_Standard")) {
            data.getStartingCargo().addFuel(20);
            data.getStartingCargo().addSupplies(20);
            data.getStartingCargo().addItems(CargoAPI.CargoItemType.RESOURCES, "omncompl_uncmaterial", 200);
            data.getStartingCargo().addCrew(CrewXPLevel.GREEN, 10);
            data.getStartingCargo().addMarines(2);
            return;
        }
        super.startingShipPicked(variantId, data);
    }
I'll leave the question here as there doesn't seem to be an explanation for this elsewhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 29, 2013, 09:29:55 PM
Well the reason your script works now is because the package points to the world folder, not the script folder, if you wanted that to be different, just change the package.

As for your question; I think the campaign holds the functions you are looking for, if I remember correctly though its pretty much the same thing as your script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 04:36:52 AM
Well the reason your script works now is because the package points to the world folder, not the script folder, if you wanted that to be different, just change the package.

As for your question; I think the campaign holds the functions you are looking for, if I remember correctly though its pretty much the same thing as your script.
With world, are you talking about data\scripts\world (which it was pointing to) or data\world? For your answer, I was asking about adding or replacing the ship you start with, not place it in your starting fleet (if that was how you understood it, the asnwer was rather vague).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 30, 2013, 04:54:04 AM
"package data.scripts.world;" this means the script will only run in data/scripts/world, if you want it to run somewhere else eg: data/scripts/startingstuff you have to change the package ->
package data.scripts.startingstuff;

Isn't CharacterCreationPluginImpl.java the place to look for this? Since it creates your starting ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 05:28:20 AM
"package data.scripts.world;" this means the script will only run in data/scripts/world, if you want it to run somewhere else eg: data/scripts/startingstuff you have to change the package ->
package data.scripts.startingstuff;

Isn't CharacterCreationPluginImpl.java the place to look for this? Since it creates your starting ship?
I also did, as you can see it extends that class. The issue was that I had package data.scripts.world and it was in data\scripts\world, but didn't run. Changing it to package data.scripts.plugins and putting it in data\scripts\plugins however made it run.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on January 30, 2013, 05:39:01 AM
Since this is the offical way of creating the starting ships, I don't think there are more direct ways, was what I was trying to say ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 30, 2013, 06:55:04 AM
I also did, as you can see it extends that class. The issue was that I had package data.scripts.world and it was in data\scripts\world, but didn't run. Changing it to package data.scripts.plugins and putting it in data\scripts\plugins however made it run.

This is because data/scripts/plugins is a special folder. All scripts in this folder that implement a plugin will be automatically added to the game, and for all plugins except combat plugins (which can be added via mission definitions) this is the only way to activate them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 07:39:48 AM
I also did, as you can see it extends that class. The issue was that I had package data.scripts.world and it was in data\scripts\world, but didn't run. Changing it to package data.scripts.plugins and putting it in data\scripts\plugins however made it run.

This is because data/scripts/plugins is a special folder. All scripts in this folder that implement a plugin will be automatically added to the game, and for all plugins except combat plugins (which can be added via mission definitions) this is the only way to activate them.
I figured it was something along those lines, but had to learn it the hard way xD. Thanks for the clarification, might help avoid similar issues in the future.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on January 30, 2013, 07:41:49 AM
How do you mod the starting player fleet? And the various explanations for each variable inside it.

Been a while....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 08:04:13 AM
How do you mod the starting player fleet? And the various explanations for each variable inside it.

Been a while....
To be more clear, is it just the fleet you want to modify (add ships, resources, weapons, etc.) or modify/add the starting options?

I think (haven't tried) you can type this in your generator, if you just want to add extra stuff:
Code
        CargoAPI cargo = Global.getSector().getPlayerFleet().getCargo();
        cargo.addItems(CargoAPI.CargoItemType.RESOURCES, "supplies", 20);
        cargo.addMothballedShip(FleetMemberType.SHIP, "ID", null);
        cargo.addWeapons("id", 3);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on January 30, 2013, 08:09:24 AM
Starting options :),

Like how, before the last update, you would just do it in the data/world/factions/player.faction file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 09:15:51 AM
Starting options :),

Like how, before the last update, you would just do it in the data/world/factions/player.faction file

Okay, I'll try and break down my working example, although it doesn't do everything you can do and might not be implemented in an optimal way (but it works).

Code
package data.scripts.plugins;

import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.characters.CharacterCreationPlugin;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
import java.util.ArrayList;
import java.util.List;

public class IndustryCharacterCreation extends data.scripts.plugins.CharacterCreationPluginImpl {
    // Not using an enum for this because Janino doesn't support it.
    // It does, apparently, support using enums defined elsewhere - just can't compile new ones.

The basic stuff for setting up the rest. As was mentioned before, this needs to be in data\scripts\plugins to work properly. I have given the class its own name, so it should not overwrite anything else and potentially become incompatibly with other mods. I extend the class in starsector-core instead of implementing the interface characterCreationPlugin. I can't comment on what would be best to do, expecially in context with compatibility with other mods.

Code
    private ResponseImpl OPTION1 = new ResponseImpl("option 1 text");
    private ResponseImpl OPTION2 = new ResponseImpl("option 2 text");
    private int stage = 0;
    private boolean isEntr = false;

Here we set up the fields we will use. ResponseImpl is from the class that we extended and if you implemented the interface then you would have to make your own (could just copy-paste it from the extended class). They are the ones that the player can choose from, though we will have to specify when they are shown in getResponses(). Aside from that we have stage as the one in the extended class is private and then a boolean as I only wanted to show the second response if the first was selected.

Code
    @SuppressWarnings("unchecked")
    @Override
    public List getResponses() {
        List result = new ArrayList();
        
        if (stage == 0) {
            result.add(OPTION1);
        } else if (stage == 1) {
            if (isEntr) {
                result.add(OPTION2);
            }
        }
        result.addAll(super.getResponses());
        return result;
    }

Before talking about this code, I want to mention that there is a method before it called getPrompt(). You will only need to override it if you need to change the amount of times the player selects a response. There is also a field called prompts that you can override if you want to change the text above options (the one asking the "questions") or change the amount of times the player selects a response.

About the code itself. The repsonses the player selects from is based of a list. This method, getResponses(), is where we create that list. We start by creating the list and then check what stage we are in. If we're in the second stage (stage == 1) then we also check if the previous choice was our first option through our field isEntr. After this we call the same method from our extended class and put the responses in the list that it returns in our list. Finally we return our list.

Code
    @Override
    public void submit(CharacterCreationPlugin.Response response, CharacterCreationPlugin.CharacterCreationData data) {
        super.submit(response, data);
        
        stage++;
        MutableCharacterStatsAPI stats = data.getPerson().getStats();

        if (response == OPTION1) {
            stats.addAptitudePoints(1);
            stats.addSkillPoints(2);
            data.getStartingCargo().getCredits().add(2000);
            isEntr = true;
        }
        if (response == OPTION2) {
            stats.addAptitudePoints(1);
            stats.addSkillPoints(2);
            data.addStartingShipChoice("buffalo_Standard");
            data.getStartingCargo().getCredits().add(2000f);
        }

    }

The next method is submit(). This method is called after a response is selected. We start with calling the same method from the extended class, in case that one of ours wasn't selected. Afterwards we increment stage by 1 and create a variable to access player stats so we won't have to type the whole thing again. Then using an if for each possible repsonse we dertermine which response was selected and do the stuff we want to if it was one of ours. To see how to increase a specific skill or apptitude look at the extended class.

Code
    @Override
    public void startingShipPicked(String variantId, CharacterCreationPlugin.CharacterCreationData data) {
        if (variantId.equals("buffalo_Standard")) {
            data.getStartingCargo().addFuel(20);
            data.getStartingCargo().addSupplies(20);
            data.getStartingCargo().addItems(CargoAPI.CargoItemType.RESOURCES, "omncompl_uncmaterial", 200);
            data.getStartingCargo().addCrew(CrewXPLevel.GREEN, 10);
            data.getStartingCargo().addMarines(2);
            return;
        }
        super.startingShipPicked(variantId, data);
    }
}

b]getPrompt()[/b] will return null once stage exceeds the amount of prompts availaible. Once that happens, the player will be given a selection of ships to pick from based of the data.addStartingShipChoice(String Variantid) method. When a ship is selected, this method will be called. We have access to the same amount of information as in submit() and can thus do the same amount of things. In this case, I just add the starting resources including one from my mod. I added a return; in the if and only call the extended class method at the end, because it has an option if none of the ships it expected was picked and will add extra resources to our ship, which we are not interested in.

The end.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on January 30, 2013, 09:18:16 AM
Since when is it this complicated :O
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 09:18:49 AM
Full code of my implemention:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.characters.CharacterCreationPlugin;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
import java.util.ArrayList;
import java.util.List;

public class IndustryCharacterCreation extends data.scripts.plugins.CharacterCreationPluginImpl {
    // Not using an enum for this because Janino doesn't support it.
    // It does, apparently, support using enums defined elsewhere - just can't compile new ones.

    private ResponseImpl OPTION1 = new ResponseImpl("You started a company which became sucessful...");
    private ResponseImpl OPTION2 = new ResponseImpl("... and lost it all to pirates.");
    private int stage = 0;
    private boolean isEntr = false;

    @SuppressWarnings("unchecked")
    @Override
    public List getResponses() {
        List result = new ArrayList();
        
        if (stage == 0) {
            result.add(OPTION1);
        } else if (stage == 1) {
            if (isEntr) {
                result.add(OPTION2);
            }
        }
        result.addAll(super.getResponses());
        return result;
    }

    @Override
    public void submit(CharacterCreationPlugin.Response response, CharacterCreationPlugin.CharacterCreationData data) {
        super.submit(response, data);
        
        stage++;
        MutableCharacterStatsAPI stats = data.getPerson().getStats();

        if (response == OPTION1) {
            stats.addAptitudePoints(1);
            stats.addSkillPoints(2);
            data.getStartingCargo().getCredits().add(2000);
            isEntr = true;
        }
        if (response == OPTION2) {
            stats.addAptitudePoints(1);
            stats.addSkillPoints(2);
            data.addStartingShipChoice("buffalo_Standard");
            data.getStartingCargo().getCredits().add(2000f);
        }

    }

    @Override
    public void startingShipPicked(String variantId, CharacterCreationPlugin.CharacterCreationData data) {
        if (variantId.equals("buffalo_Standard")) {
            data.getStartingCargo().addFuel(20);
            data.getStartingCargo().addSupplies(20);
            data.getStartingCargo().addItems(CargoAPI.CargoItemType.RESOURCES, "omncompl_uncmaterial", 200);
            data.getStartingCargo().addCrew(CrewXPLevel.GREEN, 10);
            data.getStartingCargo().addMarines(2);
            return;
        }
        super.startingShipPicked(variantId, data);
    }
}

Full code of the extended class:
Code
package data.scripts.plugins;

import java.util.ArrayList;
import java.util.List;

import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.characters.CharacterCreationPlugin;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;

public class CharacterCreationPluginImpl implements CharacterCreationPlugin {

public static class ResponseImpl implements Response {
private String text;
public ResponseImpl(String text) {
this.text = text;
}
public String getText() {
return text;
}
}

// Not using an enum for this because Janino doesn't support it.
// It does, apparently, support using enums defined elsewhere - just can't compile new ones.
private ResponseImpl SUPPLY_OFFICER = new ResponseImpl("Served as a junior supply officer in an independent system's navy");
private ResponseImpl GUNNER = new ResponseImpl("Hired out as a gunner on a mercenary ship");
private ResponseImpl ENGINEER = new ResponseImpl("Found employment as an assistant engineer on an exploration vessel");
private ResponseImpl COPILOT = new ResponseImpl("Spent time as a co-pilot on a patrol ship in an independent system");
private ResponseImpl SOMETHING_ELSE_1 = new ResponseImpl("Did something else");
private ResponseImpl ADJUTANT = new ResponseImpl("Served as an adjutant in the Hegemony Navy");
private ResponseImpl QUARTERMASTER = new ResponseImpl("Performed the duties of a quartermaster on an independent warship");
private ResponseImpl HELM = new ResponseImpl("Helmed a patrol ship operating in a backwater system");
private ResponseImpl COMBAT_ENGINEER = new ResponseImpl("Took over the duties of chief combat engineer during a lengthy campaign");
private ResponseImpl SOMETHING_ELSE_2 = new ResponseImpl("Did something else");

private int stage = 0;
private String [] prompts = new String [] {
"Early in your career, you...",
"More recently, you...",
};

public String getPrompt() {
if (stage < prompts.length) return prompts[stage];
return null;
}

@SuppressWarnings("unchecked")
public List getResponses() {
List result = new ArrayList();
if (stage == 0) {
result.add(SUPPLY_OFFICER);
result.add(GUNNER);
result.add(ENGINEER);
result.add(COPILOT);
result.add(SOMETHING_ELSE_1);
} else if (stage == 1) {
result.add(ADJUTANT);
result.add(QUARTERMASTER);
result.add(HELM);
result.add(COMBAT_ENGINEER);
result.add(SOMETHING_ELSE_2);
}
return result;
}


public void submit(Response response, CharacterCreationData data) {
if (stage == 0) { // just in case
data.addStartingShipChoice("shuttle_Attack");
}

stage++;

MutableCharacterStatsAPI stats = data.getPerson().getStats();
if (response == SUPPLY_OFFICER) {
stats.increaseAptitude("leadership");
stats.increaseSkill("fleet_logistics");
stats.increaseSkill("command_experience");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == GUNNER) {
stats.increaseAptitude("combat");
stats.increaseSkill("ordnance_expert");
stats.increaseSkill("target_analysis");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == ENGINEER) {
stats.increaseAptitude("technology");
stats.increaseSkill("field_repairs");
stats.increaseSkill("mechanical_engineering");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == COPILOT) {
stats.increaseAptitude("combat");
stats.increaseSkill("helmsmanship");
stats.increaseSkill("evasive_action");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == SOMETHING_ELSE_1) {
stats.addAptitudePoints(1);
stats.addSkillPoints(2);
data.getStartingCargo().getCredits().add(1000f);
}

else if (response == ADJUTANT) {
stats.increaseAptitude("leadership");
stats.increaseSkill("fleet_logistics");
stats.increaseSkill("advanced_tactics");
data.addStartingShipChoice("lasher_Standard");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == QUARTERMASTER) {
stats.increaseAptitude("technology");
stats.increaseSkill("navigation");
stats.addSkillPoints(1);
data.addStartingShipChoice("wolf_CS");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == HELM) {
stats.increaseAptitude("combat");
stats.increaseSkill("helmsmanship");
stats.increaseSkill("evasive_action");
data.addStartingShipChoice("vigilance_Standard");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == COMBAT_ENGINEER) {
stats.increaseAptitude("combat");
stats.increaseSkill("damage_control");
stats.increaseSkill("flux_modulation");
data.addStartingShipChoice("lasher_Standard");
data.getStartingCargo().getCredits().add(3000f);
} else if (response == SOMETHING_ELSE_2) {
stats.addAptitudePoints(1);
stats.addSkillPoints(2);
data.addStartingShipChoice("hound_Assault");
data.getStartingCargo().getCredits().add(1000f);
}
}

public void startingShipPicked(String variantId, CharacterCreationData data) {
MutableCharacterStatsAPI stats = data.getPerson().getStats();
stats.addAptitudePoints(1);
stats.addSkillPoints(2);

if (variantId.equals("vigilance_Standard")) {
data.getStartingCargo().addFuel(20);
data.getStartingCargo().addSupplies(30);
data.getStartingCargo().addCrew(CrewXPLevel.REGULAR, 20);
data.getStartingCargo().addMarines(5);
} else
if (variantId.equals("lasher_Standard")) {
data.getStartingCargo().addFuel(20);
data.getStartingCargo().addSupplies(20);
data.getStartingCargo().addCrew(CrewXPLevel.REGULAR, 40);
data.getStartingCargo().addMarines(10);
} else
if (variantId.equals("wolf_CS")) {
data.getStartingCargo().addFuel(20);
data.getStartingCargo().addSupplies(20);
data.getStartingCargo().addCrew(CrewXPLevel.REGULAR, 22);
data.getStartingCargo().addMarines(7);
} else
if (variantId.equals("shuttle_Attack")) {
data.getStartingCargo().addFuel(10);
data.getStartingCargo().addSupplies(10);
data.getStartingCargo().addCrew(CrewXPLevel.REGULAR, 10);
data.getStartingCargo().addMarines(3);
} else
if (variantId.equals("hound_Assault")) {
data.getStartingCargo().addFuel(30);
data.getStartingCargo().addSupplies(40);
data.getStartingCargo().addCrew(CrewXPLevel.REGULAR, 25);
data.getStartingCargo().addMarines(15);
} else {
data.getStartingCargo().addFuel(20);
data.getStartingCargo().addSupplies(20);
data.getStartingCargo().addCrew(CrewXPLevel.REGULAR, 20);
data.getStartingCargo().addMarines(10);
}
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 09:22:16 AM
Since when is it this complicated :O

0.54  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 30, 2013, 09:26:09 AM
The basic stuff for setting up the rest. As was mentioned before, this needs to be in data\scripts\plugins to work properly. I have given the class its own name, so it should not overwrite anything else and potentially become incompatibly with other mods. I extend the class in starsector-core instead of implementing the interface characterCreationPlugin. I can't comment on what would be best to do, expecially in context with compatibility with other mods.

According to Alex, the game will only accept one implementation of any one type of plugin*, and it will use the first implementation it finds. Any mod that has it own character creation plugin would be incompatible with your mod.

* Except EveryFrameCombatPlugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on January 30, 2013, 09:30:35 AM
The basic stuff for setting up the rest. As was mentioned before, this needs to be in data\scripts\plugins to work properly. I have given the class its own name, so it should not overwrite anything else and potentially become incompatibly with other mods. I extend the class in starsector-core instead of implementing the interface characterCreationPlugin. I can't comment on what would be best to do, expecially in context with compatibility with other mods.

According to Alex, the game will only accept one implementation of any one type of plugin*, and it will use the first implementation it finds. Any mod that has it own character creation plugin would be incompatible with your mod.

* Except EveryFrameCombatPlugin.
Thank you for the clarification. That kinda blows :/
Do you know if character creation is called before the generators?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 30, 2013, 09:33:54 AM
The basic stuff for setting up the rest. As was mentioned before, this needs to be in data\scripts\plugins to work properly. I have given the class its own name, so it should not overwrite anything else and potentially become incompatibly with other mods. I extend the class in starsector-core instead of implementing the interface characterCreationPlugin. I can't comment on what would be best to do, expecially in context with compatibility with other mods.

According to Alex, the game will only accept one implementation of any one type of plugin*, and it will use the first implementation it finds. Any mod that has it own character creation plugin would be incompatible with your mod.

* Except EveryFrameCombatPlugin.
Thank you for the clarification. That kinda blows :/
Do you know if character creation is called before the generators?

I'm fairly certain it is. I remember running into an issue implementing CAELUS's character creation plugin because of the run order, at least. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on January 31, 2013, 06:06:08 AM
Been trying to use the sounds.json to modify ship system sounds based on hullsize, like what is done with engine sounds and whatnot in the core game. Seems like the game refuses to run though, no matter how I format it, using the examples provided in the core json. Is this even supported right now?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 31, 2013, 06:11:58 AM
I'm not sure, but you could try manually playing the correct sounds in the system script using Global.getSoundPlayer() (you can check if a system is turning on, active, or turning off in the script, so AFAIK you should be able to replicate the sound settings in the .system file).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on February 04, 2013, 05:50:24 AM
Solved: Thanks to Alex for the help. The problem was caused by NetBeans including old and deleted files in the .jar. To solve this I used the Clean option and it then build the proper .jar.

Okay, I am having a really weird bug. I am not sure if I am missing something obvious or it is a bug with the game. I have tried to implement my first skill which enable you to produce more weapons and ships. The limit is calculated by passing the level to a class, called ProdInfo, when you initialize it and then you can use two methods for getting the description information. This is were things start to get weird.

The class ProdInfo is in my .jar while while the skill related files are in my mod. I first only had one method to return the string called getString(). This worked fine. I then made it to two methods, getStringTotal and getStringLevel. This resoulted in an error saying that it couldn't find method (can't remember if it specified a name). I then tried to make a getString() method returning "ProdInfo". This was now shown in the skills description. Now whatever I tell the skill to return as string, it won't show anything but "ProdInfo". I even tried to tell it to just: return "Total"; and return "Level"; directly, but it would still only show "ProdInfo".

ProdInfo was initially an inner class, but I then made it an outer class to see if that helped. All of this was tested in character creation.
Any ideas?

Edit: I tried removing the omncompl_RepairComplexEffect.java file which didn't resoult in an error. This would indicate a dublicate of sorts, but I can't find one, even when searching the whole starsector folder.

Skill effect:
Code
package data.characters.skills.scripts;

import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
import data.scripts.world.ProdInfo;

public class omncompl_RepairComplexEffect implements CharacterStatsSkillEffect
{
  
    @Override
    public void apply(MutableCharacterStatsAPI stats, String id, float level)
    {
    }

    
    @Override
    public void unapply(MutableCharacterStatsAPI stats, String id)
    {
        
    }


    @Override
    public String getEffectDescription(float level)
    {
        //ProdInfo pro = new ProdInfo((int)level);
        return "Total";
    }

  
    @Override
    public String getEffectPerLevelDescription()
    {
        //ProdInfo pro = new ProdInfo(0);
        return "Level";
    }

  
    @Override
    public ScopeDescription getScopeDescription()
    {
        return ScopeDescription.ALL_OUTPOSTS;
    }
}

ProdInfo:
Code
package data.scripts.world;

import java.util.ArrayList;

public final class ProdInfo {
    ArrayList<Integer> wepAmount = new ArrayList<Integer>();
    ArrayList<Integer> shipAmount = new ArrayList<Integer>();

    public ProdInfo(int level) {
        wepAmount.add(2 * level + 2);
        wepAmount.add(1 * level + 1);
        wepAmount.add(1 * level + 1);
        wepAmount.add((int) Math.floor(0.5 * level));
        shipAmount.add((int) Math.floor(1.5 * level) + 1);
        shipAmount.add(1 * level + 1);
        shipAmount.add((int) Math.floor(2D / 3D * level));
        shipAmount.add((int) Math.floor(0.5 * level));
        shipAmount.add((int) Math.floor(2D / 7D * level));
    }

    public ProdInfo() {
        wepAmount.add(0);
        wepAmount.add(0);
        wepAmount.add(0);
        wepAmount.add(0);
        shipAmount.add(0);
        shipAmount.add(0);
        shipAmount.add(0);
        shipAmount.add(0);
        shipAmount.add(0);
    }

    public String getTotal() {
        return "Weapons:" + w(0) + w(1) + w(3) + ", ships:" + s(0) + s(1) + s(2) + s(3) + s(4);
    }

    public String getLevel() {
        return "Weapons: + 2 + 1 + 1/2, ships: + 1 1/2 + 1 + 2/3 + 1/2 + 2/7";
    }

    public String getString() {
        if (true) {
            return getLevel();
        }
        else {
            return getTotal();        
        }
    }

    public String w(int size) {
        return " + " + wepAmount.get(size);
    }

    public String s(int size) {
        return " + " + shipAmount.get(size);
    }
    
    
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on February 05, 2013, 02:20:54 PM
The basic stuff for setting up the rest. As was mentioned before, this needs to be in data\scripts\plugins to work properly. I have given the class its own name, so it should not overwrite anything else and potentially become incompatibly with other mods. I extend the class in starsector-core instead of implementing the interface characterCreationPlugin. I can't comment on what would be best to do, expecially in context with compatibility with other mods.

According to Alex, the game will only accept one implementation of any one type of plugin*, and it will use the first implementation it finds. Any mod that has it own character creation plugin would be incompatible with your mod.

* Except EveryFrameCombatPlugin.

A correction to this. I just accidently started Uomoz's Corvus 17 with my Frieghter Start mod and it worked. I am not sure if it is a coincidence, due to Uomoz's having the same name as the original file in starsector-core and thus overwriting it, and mine inherits from it (so it ends up inheriting Uomoz's?).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 05, 2013, 02:29:44 PM
A correction to this. I just accidently started Uomoz's Corvus 17 with my Frieghter Start mod and it worked. I am not sure if it is a coincidence, due to Uomoz's having the same name as the original file in starsector-core and thus overwriting it, and mine inherits from it (so it ends up inheriting Uomoz's?).

Yes. Your code extends CharacterCreationPluginImpl, and Uomoz's Corvus overwrites the vanilla version of that file, so your code would be Uomoz's character creation plugin plus whatever changes you made on top of it.

Edit: if your plugin was chosen, that is; otherwise it would just be Uomoz's Corvus chargen. I don't know exactly how loading priority is handled, but I don't think you can guarantee your plugin would be the one picked.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruntmaster1 on February 05, 2013, 03:17:11 PM
A correction to this. I just accidently started Uomoz's Corvus 17 with my Frieghter Start mod and it worked. I am not sure if it is a coincidence, due to Uomoz's having the same name as the original file in starsector-core and thus overwriting it, and mine inherits from it (so it ends up inheriting Uomoz's?).

Yes. Your code extends CharacterCreationPluginImpl, and Uomoz's Corvus overwrites the vanilla version of that file, so your code would be Uomoz's character creation plugin plus whatever changes you made on top of it.

Edit: if your plugin was chosen, that is; otherwise it would just be Uomoz's Corvus chargen. I don't know exactly how loading priority is handled, but I don't think you can guarantee your plugin would be the one picked.

Based on the log, loading priority is by gui name. 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on February 07, 2013, 10:52:55 AM
What is the amount of "pushing power" the impact has on the weapons csv, based on the target mass the weapon hits.

For example the projectile has 500 impact, the target hit by it has 100 mass, what the speed this target ship will be pushed back by the impact
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Romeo_One on February 07, 2013, 11:09:13 AM
I thought that impact didn't work the way it was intended?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on February 07, 2013, 11:13:47 AM
I thought that impact didn't work the way it was intended?

It does, Test out a graviton beam on a fighter, it has 10 on the impact
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 07, 2013, 03:02:56 PM
"impact" only works for beams. It's kind of a holdover - it's nice enough for the Graviton Beam, which is why it's still in the game, but really didn't work well when applied to other weapons. Just didn't feel right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on February 07, 2013, 03:19:30 PM
"impact" only works for beams. It's kind of a holdover - it's nice enough for the Graviton Beam, which is why it's still in the game, but really didn't work well when applied to other weapons. Just didn't feel right.

Quite what i need, for the Star Trek, thats why i asked, most of its weapons are beams
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 07, 2013, 03:51:07 PM
I can't give you an exact answer as to the "pushing power". Just have to experiment with it until it feels right. It's in the same units and scale as mass, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on February 07, 2013, 05:24:15 PM
I can't give you an exact answer as to the "pushing power". Just have to experiment with it until it feels right. It's in the same units and scale as mass, though.

So if we we're using a beam with 100 impact on a ship with 100 mass, it would "stop" moving?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 07, 2013, 05:36:53 PM
Probably not. It ends up applying a force opposite at the point of impact, but the details are quite fiddly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 08, 2013, 06:24:59 PM
How to forcefully despawn\destroy a fleet? If I call a go_to_location_and_despawn they keep on roaming around following enemy fleets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2013, 07:31:26 PM
Hmm. Not explicitly possible at the moment, but how about creating a location to despawn at that's really far away, as in way off the map, and then setting the fleet's location to those coordinates? As long as it's out of the range of anything to distract it, it will probably work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 08, 2013, 07:59:55 PM
Yeah but it gets distracted while it stays in the center of the system roaming around. It doesen't even start to move towards the despawn location. Is there any way to fleet.setlocation in a different method then the one used to spawn the fleet? is there any way to manipulate a fleet position after it's being created, like using completion scripts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhoopieMonster on February 09, 2013, 02:47:47 AM
I've search but can't seem to find anything.

How would I go about adding a description to a ship, so that it would show up in the codex?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on February 09, 2013, 03:25:37 AM
data/strings/descriptions.csv

look for the one in the core for examples on format
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhoopieMonster on February 09, 2013, 04:01:17 AM
Thanks dude :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2013, 09:19:22 AM
Yeah but it gets distracted while it stays in the center of the system roaming around. It doesen't even start to move towards the despawn location. Is there any way to fleet.setlocation in a different method then the one used to spawn the fleet? is there any way to manipulate a fleet position after it's being created, like using completion scripts?

fleet.getLocation().set(x, y);

You can do this with every method that returns a Vector2f, though how much of a good idea that is varies based on the specifics.

Here's the javadoc for Vector2f, for reference:
http://lwjgl.org/javadoc/org/lwjgl/util/vector/Vector2f.html
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 09, 2013, 11:37:04 AM
Yeah but it gets distracted while it stays in the center of the system roaming around. It doesen't even start to move towards the despawn location. Is there any way to fleet.setlocation in a different method then the one used to spawn the fleet? is there any way to manipulate a fleet position after it's being created, like using completion scripts?

fleet.getLocation().set(x, y);

You can do this with every method that returns a Vector2f, though how much of a good idea that is varies based on the specifics.

Here's the javadoc for Vector2f, for reference:
http://lwjgl.org/javadoc/org/lwjgl/util/vector/Vector2f.html

I think he was asking how to keep the reference to the fleet object outside of the method that creates it.


If all you want is to have access to the fleet in its assignment script, you can write your own implementation of Script that accepts a CampaignFleetAPI as an argument in its constructor. Something like this:

Code
package data.scripts;

import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;

public abstract class FleetScript implements Script
{
    private final CampaignFleetAPI fleet;

    public FleetScript(CampaignFleetAPI fleet)
    {
        this.fleet = fleet;
    }

    public CampaignFleetAPI getFleet()
    {
        return fleet;
    }

    public abstract void run();
}

With this, all you need to do is change the new Script() { // blah } to new FleetScript(fleet) { // blah } in your convoy file, and you'll have access to the fleet object in your run() method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2013, 12:02:02 PM
Oh, I think you're right, I totally misread that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 09, 2013, 06:25:13 PM
Thanks Alex and LW :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vilu on February 10, 2013, 04:15:03 AM
Is it possible to have mods load up on old saves?

I'm asking because i got quite good game going on Uomoz's Corvus and would like to add Fleet Control to the mix, but don't feel like starting yet again from start :( (few too many restarts recently)


(if this has been asked and answered before, sorry that i missed it)

edit: the skills from FC add up to old save, however the planets do not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 10, 2013, 10:22:12 AM
Is it possible to have mods load up on old saves?

I'm asking because i got quite good game going on Uomoz's Corvus and would like to add Fleet Control to the mix, but don't feel like starting yet again from start :( (few too many restarts recently)


(if this has been asked and answered before, sorry that i missed it)

edit: the skills from FC add up to old save, however the planets do not.

This is relevant to my interests. (https://bitbucket.org/LazyWizard/sfconsole/src/7fe506419cfef52a9700c32f6de72ee0b8a00e0f/SFConsole/data/scripts/console/commands/ActivateMod.java?at=default) :)

The mod's generator will not run if you add it to an existing game, so stations, planets, spawn points etc won't be set up. Any vanilla content that's modified by the mod might work, unless it references something that doesn't exist in the current save. In other words, a rebalance of the Tactical Laser would work, a rewrite of a vanilla spawn point that tries to tie into a mod-added economy won't.

As you've already noticed, stuff from CSVs like skills will be loaded (you might get errors if you try to put points in them), but ships won't automatically appear in stations (they might appear in vanilla fleets if the mod changes their composition). Added weapons will eventually start appearing since the vanilla convoys choose from every weapon loaded when they select cargo.

Factions are only created at the start of a new game, so you can't activate a mod's generator manually if it refers to a new faction. Station placement will also be off (if the mod tells a station to orbit at 270 degrees because that's opposite where another station spawns, it will still choose 270 degrees even if that other station is currently at 269 degrees itself).

Some mods can force themselves to activate in an old save via very hacky methods. The Respec Mod (http://fractalsoftworks.com/forum/index.php?topic=5570.0) I wrote does so. Again, this is limited to mods that don't add new factions, and the mod authors will have to implement it themselves.

tl;dr: it's complicated. ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 11, 2013, 05:18:14 AM
Yeah but it gets distracted while it stays in the center of the system roaming around. It doesen't even start to move towards the despawn location. Is there any way to fleet.setlocation in a different method then the one used to spawn the fleet? is there any way to manipulate a fleet position after it's being created, like using completion scripts?

fleet.getLocation().set(x, y);

You can do this with every method that returns a Vector2f, though how much of a good idea that is varies based on the specifics.

Here's the javadoc for Vector2f, for reference:
http://lwjgl.org/javadoc/org/lwjgl/util/vector/Vector2f.html

I think he was asking how to keep the reference to the fleet object outside of the method that creates it.


If all you want is to have access to the fleet in its assignment script, you can write your own implementation of Script that accepts a CampaignFleetAPI as an argument in its constructor. Something like this:

Code
package data.scripts;

import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;

public abstract class FleetScript implements Script
{
    private final CampaignFleetAPI fleet;

    public FleetScript(CampaignFleetAPI fleet)
    {
        this.fleet = fleet;
    }

    public CampaignFleetAPI getFleet()
    {
        return fleet;
    }

    public abstract void run();
}

With this, all you need to do is change the new Script() { // blah } to new FleetScript(fleet) { // blah } in your convoy file, and you'll have access to the fleet object in your run() method.

I created the new implementation of Script and Netbeans says it's allright, BUT, in campaign the script is not activating:

Spoiler
   private void BOSS_Spawn(StarSystemAPI system, SectorEntityToken despawn_location, String boss_base, String boss_faction, String boss_id, String boss_name, String boss_hello)   {
        SectorEntityToken base = system.getEntityByName(boss_base);
        if (EventsTimerReset == 0) {
            Global.getSector().addMessage("EVENT: " + boss_name + " is in the system! All Frequency Message incoming.", Color.YELLOW);
        }
        if (EventsTimerReset == -1) {
        Global.getSector().addMessage(boss_hello, Color.magenta);
        CampaignFleetAPI fleet = getSector().createFleet("events", boss_id);
        system.spawnFleet (base, 0, 0, fleet);
        Event_Faction_Change (boss_faction);
        event_ON = true;
        Script script = null;
        script = DespawnScript(fleet);
        fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 10, script);
        fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, despawn_location, 10);
        }
    }
    private Script DespawnScript(final CampaignFleetAPI fleet)  {                              <-------------------- ALL THIS STUFF NEVER HAPPENS
        return new UomozFleetScript(fleet) {
            public void run() {
                fleet.getLocation().set(30000, 30000);
                event_ON = false;
                EventsTimerReset = (int) (10 + (Math.random() * 6));
            }
            };
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on February 11, 2013, 10:23:37 AM
Where in your code are you calling DespawnScript(fleet)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 11, 2013, 10:38:42 AM
After the RAID_SYSTEM completion.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on February 11, 2013, 11:52:53 AM
Oh, duh, there it is. Huh. Unfortunately that's starting to stretch my Java knowledge there, I've never used a Script like that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 13, 2013, 12:06:01 PM
Trying to create a CharacterCreationPlugin where choices creates other (selective) choices is not working:

Spoiler
   public List getResponses() {
      List result = new ArrayList();
      if (stage == 0) {
         result.add(SUPPLY_OFFICER);
         result.add(GUNNER);
         result.add(ENGINEER);
         result.add(COPILOT);
         result.add(SOMETHING_ELSE_1);
      } else if (stage == 1) {
         result.add(ADJUTANT);
         result.add(QUARTERMASTER);
         result.add(HELM);
         result.add(COMBAT_ENGINEER);
         result.add(SOMETHING_ELSE_2);
      } else if (stage == 2) {
         result.add(SOV);
         result.add(SUP);
         result.add(PIR);
         result.add(COR);
         result.add(INV);
         result.add(NOBLOC);
                } else if (stage == 3) {
                       if (result.contains(SOV)) {
         result.add(HE);
         result.add(IF);
      } else if (result.contains(SUP)) {
         result.add(TT);
         result.add(SI);
      } else if (result.contains(PIR)) {
         result.add(PP);
         result.add(JP);
                        result.add(GD);
      } else if (result.contains(COR)) {
         result.add(BR);
         result.add(NC);
      } else if (result.contains(INV)) {
         result.add(AN);
         result.add(TL);
      } else if (result.contains(NOBLOC)) {
         result.add(AS);
      }
                        result.add(NOFAC);
      }
      return result;
[close]

The else if chain in stage 3 is not appearing in the response list in-game while NOFAC (out of the else if chain) option appears. Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheHappyFace on February 13, 2013, 10:08:35 PM
if you don't want to start over again you could also guess whats the worth of your fleet in credits and edit your new save to have this amount.
you would be able to rebuy most of your ships and weaponry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on February 15, 2013, 11:40:33 AM
Is there any way to force the hit glow radius on a beam weapon? I made a custom graphic beam with a really wide sprite and the hit glow is enormous. Since beams dont have a proj file I'm not sure where to rectify this. And yes, I've tried adding glow radius and hitglow radius to the weapon file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 15, 2013, 12:22:32 PM
Huh, could've sworn that's possible, but no, it's not - it's always 3x the width of the beam.

A really wide beam is going to have some other issues, btw, since hit detection will only be done for the middle of the beam. So, it'll look odd when it's not hitting something it's obviously overlapping, or when something that's not big enough to interrupt it, does.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on February 15, 2013, 01:29:49 PM
Well, the beam itself is narrow. It's the "corona" that necessitates the wideness.

I managed to make it look better with a much narrower beam, though, so no sweat either way. ;D Kudos for the quick answer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DelicateTask on February 15, 2013, 07:42:50 PM
Is there any way to force the hit glow radius on a beam weapon? I made a custom graphic beam with a really wide sprite and the hit glow is enormous. Since beams dont have a proj file I'm not sure where to rectify this. And yes, I've tried adding glow radius and hitglow radius to the weapon file.
What if you leave blank space in the sprite on either side of the beam to force it smaller? If it's always 3X the size, then making the sprite bigger, if not the actual visible part, would force the engine to scale it down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on February 15, 2013, 09:51:23 PM
Hey guys,

for my bioships i wanted to implement a mechanic which lets age the ships.
design wise i thought the bioships would come in fixed variants depending on the actual age of the ship. The ships
would have only build-in weapons. Only hullmods and the number of vents and capacitators could be changed.
For example you could buy a newborn ship (the stats like speed, armor etc. would reflect the age of the ship although)
and after a specific time the ship would have aged enough to enter its next phase of life.

Would something like this be moddable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 16, 2013, 11:46:08 AM
Hey guys,

for my bioships i wanted to implement a mechanic which lets age the ships.
design wise i thought the bioships would come in fixed variants depending on the actual age of the ship. The ships
would have only build-in weapons. Only hullmods and the number of vents and capacitators could be changed.
For example you could buy a newborn ship (the stats like speed, armor etc. would reflect the age of the ship although)
and after a specific time the ship would have aged enough to enter its next phase of life.

Would something like this be moddable?

You wouldn't be able to transfer any damage the ship had taken to the next phase and the player would need to manually re-add the vents/caps/hullmods each time it evolved; other than that, I don't see any problems with the concept.

It might be frustrating if the player has no control over when it happens, though. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on February 17, 2013, 11:48:07 AM
I wished to ask, if it is possible to render a weapon below the ship sprite ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on February 17, 2013, 12:46:30 PM
I was wondering this too. Space ships, despite the 2D nature of the game, should have to have on the bottom of them. Even just having the weapon render under the ship sprite would be good, since most of them would probably be mounted on the main body of a ship and you'd just have barrels sticking out from the bottom.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2013, 12:53:59 PM
I wished to ask, if it is possible to render a weapon below the ship sprite ?

Not possible. If you're curious as to why:
http://fractalsoftworks.com/forum/index.php?topic=2844.msg39103#msg39103
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on February 17, 2013, 01:30:50 PM
If you're curious as to why:
http://fractalsoftworks.com/forum/index.php?topic=2844.msg39103#msg39103

Not even a small missile?  :(

On a serious note - i see why its not implemented. Will have to deal with it, somehow..

Thanks Alex :)


Edit - Just, out of pure and obscene curiosity .. Do Large "Decorative" weapons render above small (missile) weapon mounts ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2013, 02:20:00 PM
Edit - Just, out of pure and obscene curiosity .. Do Large "Decorative" weapons render above small (missile) weapon mounts ?

So long as they're in a "turret" type slot, yeah. Turrets render above hardpoints, and within each type, larger weapons render later.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on February 17, 2013, 02:28:22 PM
So long as they're in a "turret" type slot, yeah. Turrets render above hardpoints, and within each type, larger weapons render later.

Please dont take it, like I want to stubornly go against "rules" at all costs, its a.. visual matter really. But basicly what I would like is to get two, what an outsider viewer would see as
"two pipes" above a rocket pod. Now.. what I thought to do was somewhere in the lines..

1) make a sprite as usual
2) the missile pad (which would be a hardpoint)
3) on top of that place a "decorative" weapon - turret, as I believe you would advice, which would merely be those two pipes and with 0° arc it would stick
in position. (and be above the missile pod)

So.. in hull codex you would see a ship, without any "weird extra stuff".. and in variant codex - the real stuff. If composed on top of each other correctly and precisly,
the result would be a "fake" perspective, as the pod in below the pipes (in my case at lower part of the frigate).

Basicly..just help the current system with a "fake" ship part, which is small, so in battle it shouldnt be noticable.

Would that work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2013, 10:12:59 PM
Sounds like it should work. If the decorative weapon was built-in, it should even show up in the hull codex entry.

Definitely not taking it the wrong way. The link I posted above explains why *I* am not doing that or adding explicit support for it. You, on the other hand, are welcome to abuse the system in whatever ways you want :) In fact, I'm looking forward to seeing the results!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on February 18, 2013, 11:27:37 AM
In fact, I'm looking forward to seeing the results!

As you wish, though I have to say Im not pleased with how the ship sprite actually turned out,
will probabyl still swap colors around, but - everything else works, as its suposed to. :)

Spoiler
(http://oi48.tinypic.com/9hnxwp.jpg)
[close]

Spoiler
(http://oi49.tinypic.com/2w5umn7.jpg)
[close]

Spoiler
(http://oi45.tinypic.com/2nbujgk.jpg)
[close]

Spoiler
(http://oi46.tinypic.com/50l79.jpg)
[close]


If I add another vertical line on the "Wing Articulation" as I named the weapon,  (or simply-pipe) I think it wouldnt even be recongnizable, that theres an additional layer above the normal sprite at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sdmike1 on February 18, 2013, 12:23:42 PM
Very cool!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on February 18, 2013, 12:41:48 PM
Thank you :) Heres the "final" sprite, with the changes I proposed earlier.
As I said, with additional vertical line - an uninitiated viewer wouldnt know better.
(otherwise.. change the shading, had a leap of logic there..)

Spoiler
(http://oi48.tinypic.com/2uti6g3.jpg)
[close]

Edit - ill stop advert. right here. :p


Another question rises. I had an idea of using a "glow" from weapons to appear as..
sort of a energy barrier (for carrier hangars for example..)

However.. it doesnt show up in game, so my question is - is it possible to just use
"glow" from decorative weapons at all?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on February 18, 2013, 02:37:52 PM
Error while loading, not sure what it means. All I did to change from the past version of the mod that is working was add one weapon 'irpulser' to the .csv and a renamed clone of the normal irpulse.

Code
7197 [Thread-6] WARN  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Weapon [irpulser] from weapon_data.csv not found in store
7197 [Thread-6] WARN  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Weapon [disruptors] from weapon_data.csv not found in store
7198 [Thread-6] INFO  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Applying data from weapon_data.csv to [flarelauncher1]
7265 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.IllegalArgumentException: No enum const class com.fs.starfarer.api.combat.WeaponAPI$AIHints.36
java.lang.IllegalArgumentException: No enum const class com.fs.starfarer.api.combat.WeaponAPI$AIHints.36
at java.lang.Enum.valueOf(Enum.java:196)
at com.fs.starfarer.loading.K.super(Unknown Source)
at com.fs.starfarer.loading.WeaponSpreadsheetLoader.Ò00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
at com.fs.starfarer.loading.H.super(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

Halp?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sdmike1 on February 18, 2013, 06:01:34 PM
i THINK (that is a big think by the way :P) one or more of the weapon API hints is causing problems but i am not entirely sure
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 20, 2013, 08:22:12 AM
Thank you :) Heres the "final" sprite, with the changes I proposed earlier.
As I said, with additional vertical line - an uninitiated viewer wouldnt know better.
(otherwise.. change the shading, had a leap of logic there..)

Spoiler
(http://oi48.tinypic.com/2uti6g3.jpg)
[close]

Edit - ill stop advert. right here. :p


Another question rises. I had an idea of using a "glow" from weapons to appear as..
sort of a energy barrier (for carrier hangars for example..)

However.. it doesnt show up in game, so my question is - is it possible to just use
"glow" from decorative weapons at all?

Looks like part of the sprite to me, even in the first version. And yeah, no glow for decorative weapons.

Spoiler
Error while loading, not sure what it means. All I did to change from the past version of the mod that is working was add one weapon 'irpulser' to the .csv and a renamed clone of the normal irpulse.

Code
7197 [Thread-6] WARN  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Weapon [irpulser] from weapon_data.csv not found in store
7197 [Thread-6] WARN  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Weapon [disruptors] from weapon_data.csv not found in store
7198 [Thread-6] INFO  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Applying data from weapon_data.csv to [flarelauncher1]
7265 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.IllegalArgumentException: No enum const class com.fs.starfarer.api.combat.WeaponAPI$AIHints.36
java.lang.IllegalArgumentException: No enum const class com.fs.starfarer.api.combat.WeaponAPI$AIHints.36
at java.lang.Enum.valueOf(Enum.java:196)
at com.fs.starfarer.loading.K.super(Unknown Source)
at com.fs.starfarer.loading.WeaponSpreadsheetLoader.Ò00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
at com.fs.starfarer.loading.H.super(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

Halp?
[close]


Right, probably something misspelled in the "hints" column in weapon_data.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on February 21, 2013, 09:56:24 AM
Im been thinking of somehow add a hullmod on the Startreker mod thats on a hold up for now, the general idea would be, depending on the damage type done to ship shields, that damage would be reduced on increased, so how it works. You can add a hullmod for 0 OP that will change make your shield stronger against a certain damage type, right now on vanila theres 4 types (not including EMP) High Explosive, Kinetic, Fragmentation and Energy, so adding a possible mod that when it takes Energy damage would reduce that damage by 50%, but if it took damage from High Explosive would take additional 50% damage, this becomes even better if you can create damage types just so you could use this mechanic to a whole new level, lets see, your in a Federation ship and you usually take on Dominion ships, so being able to take more hits from POLARON damage type would be ideal, so you equip a hullmod called Polaron Shield Polarity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on February 24, 2013, 03:15:12 AM
You wouldn't be able to transfer any damage the ship had taken to the next phase and the player would need to manually re-add the vents/caps/hullmods each time it evolved; other than that, I don't see any problems with the concept.

It might be frustrating if the player has no control over when it happens, though. :)

Thanks for anwsering.

Would there be a way to have the aging be reliant on let's say some kind of refitting.
So when a ship has reached a certain age it will be able to be refitted into the next lifephase through
a certain item or supplies?

As i wanted to implement a bio specific skilltree i wanted to add a designed flaw to the bio ships.
To reflect the fact that these ships are half sentient beings with a kind of free will it would be cool
to have a "forced" autopilot who kicks in randomly during battle and can't be cancled but with the right skill.

Would something like this be moddable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on March 02, 2013, 03:10:42 PM
This is probably a silly question if you understand the Java structure, but my Fortran-addled mind is struggling- how would I apply a change to a mutableStat by 'default'? I'm trying to construct a hull that has a naff shield counterbalanced by a reduced overload time, which is doable with getOverloadTimeMod() in a hullmod but I'm not entirely sure how to make that a property of the vessel itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on March 02, 2013, 03:48:29 PM
During balance testing for Starfighter I noticed that the Command (Player-usable) variants of fighters have very different tactics than the fighters.

Will changing the Command Fighter's class from Frigate to Fighter change anything aside from the AI's tactics? Not sure if that would make them unable to be piloted by the player or not :/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on March 02, 2013, 06:28:08 PM
So, was trying to do some balance adjustments to skills... is there any way to make a skill that adds a fixed amount of ordnance points that varies by hull size?  I can make one that, for example, adds +10 ordnance points to all ships... which is nice for frigates, but almost meaningless for capital ships.  Ideally, I'd like a skill that, at 10 ranks, adds +10/+20/+40/+80 ordnance points, to frigates / destroyers / cruisers / capital ships, respectively.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2013, 07:40:02 AM
This is probably a silly question if you understand the Java structure, but my Fortran-addled mind is struggling- how would I apply a change to a mutableStat by 'default'? I'm trying to construct a hull that has a naff shield counterbalanced by a reduced overload time, which is doable with getOverloadTimeMod() in a hullmod but I'm not entirely sure how to make that a property of the vessel itself.

The way to do that would be to write an EveryFrameCombatPlugin that applies this penalty, using ShipAPI.getHullSpec().getHullId() to figure out what ship to apply it to, and taking care to only apply it once.


During balance testing for Starfighter I noticed that the Command (Player-usable) variants of fighters have very different tactics than the fighters.

Will changing the Command Fighter's class from Frigate to Fighter change anything aside from the AI's tactics? Not sure if that would make them unable to be piloted by the player or not :/

Changing the collisionClass won't make a difference to the AI. So long as it's a ship, it'll continue using the ship AI, and not the fighter one - there's no way around that atm.

So, was trying to do some balance adjustments to skills... is there any way to make a skill that adds a fixed amount of ordnance points that varies by hull size?  I can make one that, for example, adds +10 ordnance points to all ships... which is nice for frigates, but almost meaningless for capital ships.  Ideally, I'd like a skill that, at 10 ranks, adds +10/+20/+40/+80 ordnance points, to frigates / destroyers / cruisers / capital ships, respectively.

Hmm. No way to vary it by hull size. A percentage bonus would be the best fallback, though I'm sure you'd already thought of that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on March 05, 2013, 07:58:23 AM
So, was trying to do some balance adjustments to skills... is there any way to make a skill that adds a fixed amount of ordnance points that varies by hull size?  I can make one that, for example, adds +10 ordnance points to all ships... which is nice for frigates, but almost meaningless for capital ships.  Ideally, I'd like a skill that, at 10 ranks, adds +10/+20/+40/+80 ordnance points, to frigates / destroyers / cruisers / capital ships, respectively.

Hmm. No way to vary it by hull size. A percentage bonus would be the best fallback, though I'm sure you'd already thought of that.

Dang.  That's a shame.  Even just looking at classic, we've got frigate hulls varying from 20-60 ordnance points (30-60 if we exclude freighters, 35-60 if we exclude the hound, too); I was hoping to adjust +OP skills to more evenly boost everything, rather than the current state where percentage bonuses make the best ships better, but don't do nearly as much for those ships that weren't quite as strong to start with.

Edit: Hm... Double-checking again, and - in general - larger ships tend to show less differences in ordnance points; it's mostly just frigates that have such wide variances.  Perhaps if I include a flat +10 ordnance points alongside a percentage bonus?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on March 13, 2013, 06:29:32 AM
Trying to sort out my position light decorative, everything is working perfectly, but its still shooting shredders shells, and i can't get it out of the weapon groups. how do i go about fixing this?

My "Light" file
Spoiler
Quote
{
    "id":"light",
    "specClass":"projectile",
    "type":"DECORATIVE",
    "size":"SMALL",
 
   "everyFrameEffect":"data.scripts.plugins.isHulkCheck",
 
    "turretSprite":"graphics/weapons/decorative/light00.png",
    "hardpointSprite":"graphics/weapons/decorative/light00.png",
 
    "numFrames":9,
    "frameRate":6,
    "alwaysAnimate":"true",
   
    "turretOffsets":[0, 0],
    "turretAngleOffsets":[0],
    "hardpointOffsets":[0, 0],
    "hardpointAngleOffsets":[0],
 
    "barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
    "animationType":"MUZZLE_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE
    "muzzleFlashSpec":{"length":0.0,   # only used if animationType = MUZZLE_FLASH
                  "spread":10,
                  "particleSizeMin":4.0,
                  "particleSizeRange":18.0,
                  "particleDuration":0.2,
                  "particleCount":25,
                  "particleColor":[255,150,30,200]},
                  
    "projectileSpecId":"shredder_shot",  # projectile that will be fired
   "fireSoundOne":"gun_mechanicals_medium_up_whirr",
   "fireSoundTwo":"gun_medium_2",   
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 13, 2013, 03:04:30 PM
my turn !
im having trouble with the sound effect line in weapon codes. the file name entered dosent match the file name in the sound folder.
e.g.: in the pulse laser's weapon data, the sound effect line reads "energy_pulse" even tho the sound file that is used for this gun is "fire_beam_burst01"

so im wondering, when ill be modding my guns, what am i supposed to write on that line ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 13, 2013, 03:28:35 PM
my turn !
im having trouble with the sound effect line in weapon codes. the file name entered dosent match the file name in the sound folder.
e.g.: in the pulse laser's weapon data, the sound effect line reads "energy_pulse" even tho the sound file that is used for this gun is "fire_beam_burst01"

so im wondering, when ill be modding my guns, what am i supposed to write on that line ?

The sounds used in your weapon files and code are defined in data/config/sounds.json. If you look at this file, you'll see that it maps a key (in this case energy_pulse) to different sound files (fire_beam_burst01). So you put the key in your weapon file, and Starsector looks up what sound file is assigned to it.

Why is Starsector set up this way? Well, first of all, it means if you change your sound effect file, you only need to modify sounds.json instead of every single place that sound is used in the code. Second, you can have multiple sounds for the same key, in which case the game chooses a random sound from that list. This is very useful for repeating sounds like explosions or bullet collisions, since having the exact same sound play 30 times in a row is very noticeable. Finally, this setup means that multiple mods can add extra sounds for the same key without having conflicts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 13, 2013, 06:36:42 PM
my turn !
im having trouble with the sound effect line in weapon codes. the file name entered dosent match the file name in the sound folder.
e.g.: in the pulse laser's weapon data, the sound effect line reads "energy_pulse" even tho the sound file that is used for this gun is "fire_beam_burst01"

so im wondering, when ill be modding my guns, what am i supposed to write on that line ?

The sounds used in your weapon files and code are defined in data/config/sounds.json. If you look at this file, you'll see that it maps a key (in this case energy_pulse) to different sound files (fire_beam_burst01). So you put the key in your weapon file, and Starsector looks up what sound file is assigned to it.

Why is Starsector set up this way? Well, first of all, it means if you change your sound effect file, you only need to modify sounds.json instead of every single place that sound is used in the code. Second, you can have multiple sounds for the same key, in which case the game chooses a random sound from that list. This is very useful for repeating sounds like explosions or bullet collisions, since having the exact same sound play 30 times in a row is very noticeable. Finally, this setup means that multiple mods can add extra sounds for the same key without having conflicts.

oooooh okay...
thanks !
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on March 13, 2013, 09:03:55 PM
How would one go about updating .csv files after an update? I only started modding at 0.54.a so I haven't had to deal with an update yet. Do I have to add any new stats from the update to each ship (assuming there are any)?


If so, do I just stick them in any old column? Or do they have to be in the same order they're on in the vanilla .csv?



/annoyingquestionvoice
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 13, 2013, 09:18:58 PM
ok, another one but very insignifiant.
in-game, in the weapon cards, under the weapon's name where it says stuff like "assault", "PD" and "no description yet"
where do i go to change that ? i cant seem to find it  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 14, 2013, 06:35:18 AM
Make this green please?
Code
	"fringeColor":[50,50,155,255],
"coreColor":[255,255,255,100],
"glowColor":[100,100,255,255],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on March 14, 2013, 06:56:56 AM
Make this green please?
Code
	"fringeColor":[50,50,155,255],
"coreColor":[255,255,255,100],
"glowColor":[100,100,255,255],

http://www.colorpicker.com/
R G B
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 14, 2013, 07:02:27 AM
Thanks :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 14, 2013, 07:04:19 AM
Will someone help me turn a beam weapon into a kind of autopulse cannon please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 14, 2013, 10:04:52 AM
Will someone help me turn a beam weapon into a kind of autopulse cannon please?

if im not wrong, you just have to go in the weapon.csv and put the charge-up at 0 and the charge-down time at something like 0.2/0.1 and burst to something like 0.2/0.3 while making sure the WPN file for your gun is a beam type instead of projectile type.

this should make a beam gun like the burst laser that shoots like a machinegun
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 14, 2013, 02:04:07 PM
Got it sorted, How does one add portraits to the game? :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 14, 2013, 02:06:47 PM
In data/world/factions/<faction>.faction, under portraits. Add them to player.faction if you want them to be selectable at character creation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 14, 2013, 02:14:50 PM
In data/world/factions/<faction>.faction, under portraits. Add them to player.faction if you want them to be selectable at character creation.
Thankyou :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pelly on March 14, 2013, 02:19:39 PM
In data/world/factions/<faction>.faction, under portraits. Add them to player.faction if you want them to be selectable at character creation.
Thankyou :D
Your lucky I had to look through the files to find out how to do it :( (I like Orky Portraits)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 14, 2013, 02:54:08 PM
Haha
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 14, 2013, 02:56:53 PM
Your lucky I had to look through the files to find out how to do it :( (I like Orky Portraits)

Questions in this thread have a better-than-normal chance of being answered quickly. Since this thread has been around for a while, more modders are subscribed to new posts in it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 14, 2013, 02:59:23 PM
Is it possible to link a decorative weapon to a ship system? Because I'll be turning the Anamar in my BattleFarer forever mod to open out into it's current stage and have the outer engines engage for extra thrust. Can someone do this for me?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on March 14, 2013, 04:29:10 PM
can someone send me the SensorDishRotationEffect.java file? I can't find it on my computer...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 14, 2013, 04:31:42 PM
ok, another one but very insignifiant.
in-game, in the weapon cards, under the weapon's name where it says stuff like "assault", "PD" and "no description yet"
where do i go to change that ? i cant seem to find it  ???

i must reiterate.
help please ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on March 14, 2013, 04:33:06 PM
ok, another one but very insignifiant.
in-game, in the weapon cards, under the weapon's name where it says stuff like "assault", "PD" and "no description yet"
where do i go to change that ? i cant seem to find it  ???

i must reiterate.
help please ?

Description.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 15, 2013, 04:53:46 PM
ok, another one but very insignifiant.
in-game, in the weapon cards, under the weapon's name where it says stuff like "assault", "PD" and "no description yet"
where do i go to change that ? i cant seem to find it  ???

i must reiterate.
help please ?

Description.csv

O_o
i checked that one. it merely changed a sub-title in the codex, not the weapon card itself...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on March 15, 2013, 04:57:44 PM
Quote
"light_antimatter_laser","WEAPON","A smaller version of the antiproton cannon, firing high intesity bolts in long bursts at huge distances, its high energy consumtion limits it to destroyers and above.",Assault,,

its supposed to look like this, it will say what role the weapon has and its description on the weapon when you mouse over it in refit or codex or whatever.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 15, 2013, 05:22:35 PM
Quote
"light_antimatter_laser","WEAPON","A smaller version of the antiproton cannon, firing high intesity bolts in long bursts at huge distances, its high energy consumtion limits it to destroyers and above.",Assault,,

its supposed to look like this, it will say what role the weapon has and its description on the weapon when you mouse over it in refit or codex or whatever.

well that makes it doubly strange since thats exactly what i tweaked last time and it did nothing...
oh well, if you say thats the thing, then ill just roll with it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 17, 2013, 03:00:23 PM
Hi guys,

Is it possible to have a decorative weapon effect to be bound to engines? Like an animation for idle, acceleration, decceleration and zero flux speed buff?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 17, 2013, 07:58:47 PM
how do weapon sounds work? I checked the directory and it doesn't match up with the ones in the file

EDIT: got it, it's in config/sounds.json
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 17, 2013, 08:23:28 PM
setting.json sounds.json *cough* defines the sound id and the actual path to the soundfile
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 17, 2013, 10:31:53 PM
Is it possible to have a decorative weapon effect to be bound to engines? Like an animation for idle, acceleration, decceleration and zero flux speed buff?

Should be possible, though reliably getting the current state of the engines (i.e. idle/accelerating/etc) may be tricky.

The only way I can think of right now would be keeping track of the velocity changes from frame to frame - which might be good enough in many cases, but will fail if there are velocity changes due to collisions.

For the zero flux speed boost, you could check that
ship.getMutableStats().getMaxSpeed().getFlatStatMod("zero_flux_boost") != null

So, you'd be doing these checks in a script attached to the decorative weapon via a "everyFrameEffect", and then playing whatever animations you need using weapon.getAnimation() and some logic to actually manage the animation frames etc.


Made note to add stuff to the API that exposes engine status directly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 18, 2013, 03:16:56 PM
Thank you Alex for the quick reply.

Here is a concept of what i want to achieve.
(http://i.imgur.com/zpIm1fq.gif)(http://i.imgur.com/0PKDDG2.gif)
Depending on speed the Alphavalue would change and the speed of the rotation of the image.
I guess it is possible to have the decorative weapon be rendered under the actual ship sprite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 18, 2013, 03:21:35 PM
AWESOME!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 18, 2013, 03:37:49 PM
omg thule !! this is freakin awesome !
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2013, 05:12:06 PM
Spoiler
Thank you Alex for the quick reply.

Here is a concept of what i want to achieve.
(http://i.imgur.com/zpIm1fq.gif)(http://i.imgur.com/0PKDDG2.gif)
Depending on speed the Alphavalue would change and the speed of the rotation of the image.
I guess it is possible to have the decorative weapon be rendered under the actual ship sprite?
[close]

Hm, crap. I don't think that's going to work - there's no way to render weapons under the ship sprite, nor is there a way to dynamically adjust the alpha. (Well, aside from having specific frames with differing alpha values, but that's practical for a continuous fade or some such.)

Added methods to AnimationAPI to adjust the alpha (not that that's any good in the short term). Hmm. Let me see about allowing decorative slots to render under the hull...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 18, 2013, 07:12:10 PM
is it possible to change how fast a weapon rotates while firing/on cooldown independent of default rotate speed?

I'm trying to make an "assault beam" weapon that doesn't rotate too fast while idle but can still catch up to frigs n stuff while firing
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 18, 2013, 10:05:33 PM
okie, i haz yet another question.
in the ship csv, there's a column simply named "8/6/5/4%" and i have no idea what it means. i cant figure out either since most essential stats seems to be covered in the csv anyway.

what is this black sorcery  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 18, 2013, 11:31:20 PM
pretty sure it's dev hints that's not meant to be used

the forum, afaik, has found no use for it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 19, 2013, 12:02:36 AM
Actually *does* nothing. Just a balance reminder for myself - the flux vent rate is generally 8/6/5/4% of the capacity, depending on hull size (smaller = vent faster). The value in that column is what the capacity would be if it were based solely on that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 19, 2013, 04:08:55 AM
Hmm. Let me see about allowing decorative slots to render under the hull...

Can you also do this for all weapons PLEASE :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sdmike1 on March 19, 2013, 07:32:57 AM
Hmm. Let me see about allowing decorative slots to render under the hull...

Can you also do this for all weapons PLEASE :D
I think he said sometime or another that there was an issue with the shots rendering funky when he did that :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 19, 2013, 08:46:20 AM
is it possible to change how fast a weapon rotates while firing/on cooldown independent of default rotate speed?

I'm trying to make an "assault beam" weapon that doesn't rotate too fast while idle but can still catch up to frigs n stuff while firing

Not possible, that multiplier is both global (i.e. not per-weapon) and hardcoded.

(The game started out without that, btw. It turned out to be exceedingly annoying to have weapons turn that slowly when they're not firing. There wasn't a sweet spot where weapons both turn slowly enough for the turn rate to actually matter in-game and quickly enough to where I didn't want to break things while waiting for them to turn. Hence, faster turn rate while idle.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 21, 2013, 02:23:03 AM
shame... guess I'll have to compromise on that....

maybe I'll make it work on ammo instead of cooldown, this way it could be "idle" between shots and still work like I want

does ammo regen start ticking when the weapon is not full? Or is it like it ticks regularly and just gives u a shot when it reaches the point?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2013, 02:40:33 PM
The latter (ticks regularly), which isn't intentional and doesn't seem good. Changed so that it only starts ticking when ammo is less than full.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 21, 2013, 05:42:06 PM
oh... guess my weapon will have to wait till next version...

thanks alex :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Durandal4532 on March 22, 2013, 11:57:55 AM
So is there absolutely no way to randomize dialog?

I'd love to have people say something other than a single phrase when I met their fleets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 22, 2013, 12:11:54 PM
So is there absolutely no way to randomize dialog?

I'd love to have people say something other than a single phrase when I met their fleets.

Would be cool if it would work like with the soundfiles, where it picks one randomly if offered multiple choices.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Durandal4532 on March 22, 2013, 12:27:56 PM
So is there absolutely no way to randomize dialog?

I'd love to have people say something other than a single phrase when I met their fleets.

Would be cool if it would work like with the soundfiles, where it picks one randomly if offered multiple choices.

Yeah!

Lacking any real ability to create sprite art, I was hoping to just plug in a gigantic amount of extra dialog to make things less same-y.

I was even thinking maybe having levels of rarity for the sayings and adding variables so that things didn't wind up obviously repeating too quickly. Maybe once every 5000, someone says "Hey, is that [playername]? We were [whatever the player selected at start]'s together! Happy trails!", but also have 10-20 stock hails that could be explained as unfamiliar people reading from a phrasebook.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 23, 2013, 04:01:42 PM
hey hey its me again, noob apprentice mod maker.

this time, the problem is with one of my weapon.

its branded as a PD weapon with 3 barrels (like the heavy autocannon), lower damage than average but much faster fire-rate. its turn rate is the same as the vulcan.

yet, unless the missile is coming dead-on the gun, they cant track them and keep lagging behind.

say a harpoon streak by the ship, the gun just keep shooting, lagging only slightly behind the missile :S
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 23, 2013, 04:08:40 PM
hey hey its me again, noob apprentice mod maker.

this time, the problem is with one of my weapon.

its branded as a PD weapon with 3 barrels (like the heavy autocannon), lower damage than average but much faster fire-rate. its turn rate is the same as the vulcan.

yet, unless the missile is coming dead-on the gun, they cant track them and keep lagging behind.

say a harpoon streak by the ship, the gun just keep shooting, lagging only slightly behind the missile :S

I think I remember someone having a similar problem a while back. If I recall correctly, you need to have the middle barrel of your gun be the first defined in the .weapon file so it uses that one to aim.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 23, 2013, 04:53:14 PM
hey hey its me again, noob apprentice mod maker.

this time, the problem is with one of my weapon.

its branded as a PD weapon with 3 barrels (like the heavy autocannon), lower damage than average but much faster fire-rate. its turn rate is the same as the vulcan.

yet, unless the missile is coming dead-on the gun, they cant track them and keep lagging behind.

say a harpoon streak by the ship, the gun just keep shooting, lagging only slightly behind the missile :S

I think I remember someone having a similar problem a while back. If I recall correctly, you need to have the middle barrel of your gun be the first defined in the .weapon file so it uses that one to aim.

ah, i thought it would be a similar oddity. but i also recall when i did those weapons, the weapon recoil didint properly animated until i put the "-" in a very specific order.
he, ill just do what you said and see what happens

edit : it just occured to me i was trying to have my PD be able to gun down salamenders. are PD supposed to be able to gun those as easily as harpoons and the like ? if no, then my PD are fine after all. if yes, then they are still lagging behind despite doing what lazywizard suggested
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 23, 2013, 05:05:34 PM
Target leading accuracy isn't perfect, it depends on your ship's crew level and your character's skills. Try testing with Elite crew and see if there's a difference. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 23, 2013, 05:23:34 PM
Target leading accuracy isn't perfect, it depends on your ship's crew level and your character's skills. Try testing with Elite crew and see if there's a difference. :)

yup it did. i guess that means my PDs are perfectly fine.

thanks

check the sig to try it out ;) (yeah i no, dont spam ads for my mod :P)

running the modding gauntlet up to now has really been daunting. im really scared for the campaign part. its much more stuff than what i did up to now
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 24, 2013, 01:50:04 PM
Hi guys,

i was wondering how i could specify a certain sound for the explosions of my weapons.

i guess it works like with the flak explosion sound.
the code of the shot looks like this:
Code
{
"id":"thule_light_hunker_shot",
"specClass":"projectile",
"spawnType":"BALLISTIC",
"collisionClass":"PROJECTILE_FF",
"collisionClassByFighter":"PROJECTILE_FIGHTER",
"length":20.0,
"width":4.5,
"fadeTime":0.2,
"fringeColor":[165,75,255,255],
"coreColor":[245,235,255,255],
"textureScrollSpeed":64.0,
"pixelsPerTexel":5.0,
"bulletSprite":"graphics/TL/missiles/thule_shell_medium.png",
"behaviorSpec":{"behavior":"PROXIMITY_FUSE",
"range":25,
"explosionSpec":{"duration":0.1f,
"radius":35,
"coreRadius":25, # full damage within core radius - also equal to proximity fuse range
"collisionClass":PROJECTILE_FF,
"collisionClassByFighter":PROJECTILE_FIGHTER,
"particleSizeMin":2.5,
"particleSizeRange":3.0,
"particleDuration":1,
"particleCount":100,
"particleColor":[245,235,255,255],
"sound":"thule_explosion_hunker"},
}

}

what parameters would i have to change (if possible) that it's not triggered like a PROXIMITY_FUSE rather then a normal on_hit effect.?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on March 24, 2013, 01:53:44 PM
I wish there was a more straightforward way for it,

http://fractalsoftworks.com/forum/index.php?topic=2918.0

I don't think there was a way, but the shard autocannon from BRDY does change the sound using the on_hit effect,
If it 's an alternative I think it's hardcoded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 24, 2013, 02:03:34 PM
Okay i looked it up.

That's a shame, i made the sounds before i even checked if it was possible ;)
Coudn't find the shard autocannon from BRDY unfortunatly, is it in the latest release?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on March 24, 2013, 02:05:08 PM
It should definitely be in atleast UC 17.1 or BRDY 0.30 though if you want to use the code, I'd suggest a pm to Cycerin,  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 24, 2013, 02:08:48 PM
hmm, the version i have are the same as you mentioned, strange.

i guess you're right about the pm then ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on March 25, 2013, 10:42:43 AM
Shouldnt it be on the plugins? I dont see anywhere else he could have placed/code them in
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 25, 2013, 11:36:16 AM
found it, and yes it's under plugins ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on March 27, 2013, 07:26:56 AM
I'm creating a (will create once i get home) slug casings animation for the Gatling, id like to ask if anyone managed to make a projectile spin once you launch it, this would make a much realistic effect on those projectiles once they are "shoot" into space. Also i intent to make this for everyone, both mods im working dont need this
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 27, 2013, 11:08:38 AM
I'm creating a (will create once i get home) slug casings animation for the Gatling, id like to ask if anyone managed to make a projectile spin once you launch it, this would make a much realistic effect on those projectiles once they are "shoot" into space. Also i intent to make this for everyone, both mods im working dont need this

sounds like a lot of work for nothing. you virtually never see the actual projectile fired when using cannons.

the idea is cool tho
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 28, 2013, 09:48:38 AM
Okay, So I'm looking to hire a weapon specialist for my Battlefarer Forever mod, As I'm useless at decorative weapons and offsets, Any takers? I really need one to get the Anamar done
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 28, 2013, 10:44:39 AM
Okay, So I'm looking to hire a weapon specialist for my Battlefarer Forever mod, As I'm useless at decorative weapons and offsets, Any takers? I really need one to get the Anamar done
what do you need the person to do exactly ?
(im asking cause my skillset is limited, but if its of use to you, id volunteer)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on March 28, 2013, 11:41:25 AM
I might be able to help, but I've got prep testing for the SAT in the coming days. :P Maybe next week, unless I'm not totally immersed in the CoH 2 beta, then I can help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2013, 11:56:51 AM
Guys, please start another thread for that. I keep looking here to see if there's a legit question, so this is distracting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 28, 2013, 12:35:17 PM
Oh, Okay then, I was just trying to reduce clutter
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 28, 2013, 03:14:38 PM
how does the game engine determine which part of the recoil sprite is an individual barrel? As far as I can see all the barrels are in the same image with no apparent distinction...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 28, 2013, 03:50:05 PM
how does the game engine determine which part of the recoil sprite is an individual barrel? As far as I can see all the barrels are in the same image with no apparent distinction...

thats funny, ive been wondering this myself since i started modding, altho i never got up to actually asking it.
maybe it reconize what part of the sprite is separated by transparent zones and assume different groups of colored pixels consitute a barrel
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 28, 2013, 04:04:17 PM
the offset value, 1 barrel , xy offset
2 barrels 2 xy offsets and so on
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 28, 2013, 04:07:03 PM
the offset value, 1 barrel , xy offset
2 barrels 2 xy offsets and so on

oh ? thats it ? i thought the offset were just there to indicate where the barrel ended and the projectile animation was to "appear"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on March 28, 2013, 04:15:29 PM
hmm, on second thought you might be right, it's to late, sorry not helpful ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2013, 06:23:37 PM
No, that's right, it uses the offsets to figure out what the spacing between barrels should be, and then just slices it up vertically. If you had a triple-barreled weapon with uneven spacing, it probably wouldn't work right.

The barrels can be specified in any order, though - iirc it sorts them from left to right before figuring out where the dividing lines are.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 28, 2013, 06:30:04 PM
Is there any way to set it so decorative weapons can get damage on them? So that we can make ship parts appear damaged even if they move
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on March 28, 2013, 06:32:56 PM
My only question about the barrel recoil is there any way to have it not always shoot from right to left? Ice if you had a 4 barrel weapon in alternating with only 2 shot burst firing the outer 2 then inner 2, I've tried setting the offsets in the order of how I'd want them to to fire but the recoil does its own thing and decides right to left.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on March 28, 2013, 08:19:36 PM
I think the order matters in the order you put the weapon offset coordinates in (I uninstalled SS to get a fresh start after somehow destroying the core files, haven't gotten to time to reinstall it yet, so that's just from what I remember).  For example, if you have coordinates at {4, 4}, {4, -4}, {4, 2} and  {4, -2}, if you put it into the .wpn file in that order, that's how the barrels will fire.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on March 28, 2013, 08:26:50 PM
It doesn't work, I did try, it just offsets where the projectiles fire while the barrel mismatches, offsets don't seem to affect the order in barrel recoil.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on March 28, 2013, 08:30:59 PM
You changed the order of them, right?  I vaguely remember doing something like that with a quad barrel flak cannon early in my days of weapons making...hmm.  Guess either something change or I can't remember for shite. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2013, 10:10:12 PM
My only question about the barrel recoil is there any way to have it not always shoot from right to left? Ice if you had a 4 barrel weapon in alternating with only 2 shot burst firing the outer 2 then inner 2, I've tried setting the offsets in the order of how I'd want them to to fire but the recoil does its own thing and decides right to left.

Looking at the heavyac.wpn file, you have:
"hardpointOffsets":[25, -5, 27, 0, 25, 5],
And it fires from right to left.

If you change it to:
"hardpointOffsets":[25, 5, 27, 0, 25, -5],
It will fire from left to right. Just verified it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on March 28, 2013, 10:46:33 PM
My only question about the barrel recoil is there any way to have it not always shoot from right to left? Ice if you had a 4 barrel weapon in alternating with only 2 shot burst firing the outer 2 then inner 2, I've tried setting the offsets in the order of how I'd want them to to fire but the recoil does its own thing and decides right to left.

Looking at the heavyac.wpn file, you have:
"hardpointOffsets":[25, -5, 27, 0, 25, 5],
And it fires from right to left.

If you change it to:
"hardpointOffsets":[25, 5, 27, 0, 25, -5],
It will fire from left to right. Just verified it.

its weird that you say that because i have two triple-barreled weapons in my mod, and they both showed huge problems if theire offset werent done from right to left.
on my biggest one, there was no recoil animation at all until i putted the right-most barrel first in the offset.

and strangely enough, on my PD one, it kept mistracking target until i putted the middle barrel first in the offset list, and it still fired right-to-left.

maybe there wa san underlying problem but i remember pretty well i was cursing for "having putted the minus on the wrong side"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on March 28, 2013, 11:12:38 PM
Not exactly what I had in mind, I'll try elaborating

(http://i.imgur.com/KPYjQJj.png)

My original offsets were to of been
   
Code
"turretOffsets":[10, -4.5, 5, 11.5, 10, 4.5, 5,-11.5],

Starting from the middle left barrel to far right barrel, then to middle right barrel and then to far left, and repeat, it didn't work out, as it'll recoil in a right to left fashion while the projectiles were spawned in the method I wanted.

Firing Offset Pattern (projectile spawn)

xOxx
xxxO
xxOx
Oxxx

Ingame Recoil pattern (Sprite Recoil)

xxxO
xxOx
xOxx
Oxxx

Another firing pattern I tried was firing both outer barrels at the same time and then firing the middle 2.
Also unable,

OxxO
xOOx

In the end I had to settle for the only offset that matched the recoil
Code
	"turretOffsets":[5,-11.5, 10, -4.5, 10, 4.5, 5, 11.5],

If I used the reverse,
Code
	"turretOffsets":[5,11.5, 10, 4.5, 10, -4.5, 5, -11.5],
The projectiles wouldn't match up to the recoil,

Firing Offset Pattern (projectile spawn)

Oxxx
xOxx
xxOx
xxxO

Ingame Recoil pattern (Sprite Recoil)

xxxO
xxOx
xOxx
Oxxx

My only question about the barrel recoil is there any way to have it not always shoot from right to left? Ice if you had a 4 barrel weapon in alternating with only 2 shot burst firing the outer 2 then inner 2, I've tried setting the offsets in the order of how I'd want them to to fire but the recoil does its own thing and decides right to left.

Looking at the heavyac.wpn file, you have:
"hardpointOffsets":[25, -5, 27, 0, 25, 5],
And it fires from right to left.

If you change it to:
"hardpointOffsets":[25, 5, 27, 0, 25, -5],
It will fire from left to right. Just verified it.
I'm not sure if I'm doing this correctly But I just tried it on my own version and the recoil doesn't fire in the correct direction,
Code
	"turretOffsets":[20, 5, 22, 0, 20, -5],
"turretAngleOffsets":[0, 0, 0],
"hardpointOffsets":[25, 5, 27, 0, 25, -5],
"hardpointAngleOffsets":[0, 0, 0],

In the screenshots I took (by the way I was getting an OOM*? error every 5-6 screenshots consistently, with and without mods, )
The first barrel to recoil with the new offset doesn't match up,

The right most barrel recoils, but the offset is set to the leftmost barrel,
Spoiler
Firing Offset Pattern (projectile spawn)


Oxx
xOx
xxO

Ingame Recoil pattern (Sprite Recoil)

xxO
xOx
Oxx


(http://i.imgur.com/S4ZVT6q.jpg)

[close]
Spoiler
Firing Offset Pattern (projectile spawn)

Oxx
xOx
xxO


Ingame Recoil pattern (Sprite Recoil)

xxO
xOx
Oxx

(http://i.imgur.com/PaT0Nuk.jpg)

[close]


Kudos to the barrel recoil sprite splitting system on my mod weapon, I actually didn't believe it'll split the barrels seeing as there was no spacing between them, Not to bash or anything even with the above, The recoil system is more than I'd of hoped for :)
Not sure if I got the point across, but this was my best try :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2013, 08:15:20 AM
Is there any way to set it so decorative weapons can get damage on them? So that we can make ship parts appear damaged even if they move

Not at the moment, no, but I'll add it to the list of things to look at (not necessarily do). Need to decouple being damageable from capable of being disabled, though.


@FlashFrozen: Ah, thank you for clarifying, I see that now. I think I was just paying too much attention to the muzzle flash and didn't see the fact that the barrels were going in the wrong order. I blame it being late :) Anyway, this is fixed for the next release.

(What was happening is it would use the sorted barrel order for figuring out which one pick for recoil, while using unsorted order for figuring out which to fire, both using the same index. Btw, now that I've looked at it again, some detail on how the cutting is done: it'll pick the midpoint between adjacent barrels - adjacent after being sorted in a right-to-left order. So, non-uniformly-spaced barrels should work fine.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 29, 2013, 10:06:08 AM
Great, Thanks!

Guys, How do I make a kind of arc effect? That connects to a central beam from other weapons? :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 29, 2013, 10:32:03 AM
Cause I want this:
(http://i.imgur.com/YO5zkHp.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2013, 10:35:10 AM
Hmm. Try spawning EMP arcs with the API, I suppose - that's about as close as you can get.

Was it really necessary to post this here and send me a PM with the same exact thing? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 29, 2013, 11:03:47 AM
I didn't know if it was possible, so if it wasn't, you could make a note :P

I would rather if it was just a case of "mini laser A begin point A" in the weapons file, with an offset as the start and a "Mini laser A end point A" desired length and rotation

Would "somehow" make it a lot easier for this sorta thing :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on March 29, 2013, 06:32:45 PM
You'll need to create a complex animation for the firing while you "Spam" the emps from the side, another great way would be to make the emp arc range very small and fast in the point where it will fire the beam to make it look like "IMMA FIRING MAH LAZOR"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Doom101 on March 29, 2013, 10:10:20 PM
here's a question, how would i go about adding in music to the game? i dug through the files in the core, to try and learn like i did with ships and such but i got nothing. anyone willing to lend a hand?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 30, 2013, 01:46:11 AM
on data/config/sounds:

Quote
   "music":{
      # "source" can also be a directory
      "music_campaign":[
         {"file":"StianStark-Starfarer-Exploration_Alpha.ogg","source":"sounds/music/music.bin"}
      ],
      "music_title":[
         {"file":"StianStark-Starfarer-Exploration_Alpha.ogg","source":"sounds/music/music.bin"}
      ],
      "music_combat":[
         {"file":"battle_ambience_01_v02_loudest.ogg","source":"sounds/music/music.bin"}
      ],
   },
   

on data/sounds/music you can find the bin file it's referring to
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on April 01, 2013, 03:35:16 PM
Being the baddie I am at java, anyone know how to make a fleet spawn only once in the gen file?

      
Code
for (int i = 1; i == 1; i--)U1spawn.spawnFleet();
   

is my latest attempt but i have no idea what i'm doing anymore,
 
I've tried the line as this by itself

      
Code
U1spawn.spawnFleet();	
but it'll spew ships continuously just as if it was in a for loop above.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 01, 2013, 03:39:35 PM
Being the baddie I am at java, anyone know how to make a fleet spawn only once in the gen file?

      
Code
for (int i = 1; i == 1; i--)U1spawn.spawnFleet();
   

is my latest attempt but i have no idea what i'm doing anymore,
 
I've tried the line as this by itself

      
Code
U1spawn.spawnFleet();	
but it'll spew ships continuously just as if it was in a for loop above.

Why not a if i =! 1:

Spawnfleet
I++
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on April 01, 2013, 03:42:19 PM
It'll just readd the ships once you defeat them on the map since i think it sets i = 0 when there's none on the  map
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 01, 2013, 03:55:07 PM
It'll just readd the ships once you defeat them on the map since i think it sets i = 0 when there's none on the  map

Hmmm, message lazy wizard
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 01, 2013, 05:07:08 PM
Is there a way to deny certain events from happening in the "battle" engine, for example, weapons cant be deactivated or overloading, this is mainly to do with Star Control mod, theres no such mechanic in that game, i intent to do the same with the mod

2nd Question, mainly directed to ze verylazywizard, on your work with the black hole, im trying to make the special weapon for the Avatar, that using energy (flux) you can pull ships to your ship, without using a beam and limited to one target (probably this part is not doable) and only enemy targets. I know by increasing the radius you set on the weapon u made i can make it, the problem is, to affect only enemy ships

3rd Question, how can i change the stats of the Asteroids, so it has 1 hp and 1 armor to avoid doing catastrophic damage to ships and still get one-shot by point-defense lasers
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2013, 07:28:04 PM
Is there a way to deny certain events from happening in the "battle" engine, for example, weapons cant be deactivated or overloading, this is mainly to do with Star Control mod, theres no such mechanic in that game, i intent to do the same with the mod

Make the weapon slot hidden or decorative to make it not damageable. As far as overloading, you could have a script run every frame and call FluxTrackerAPI.stopOverload(), but that wouldn't work so well with shields - it'd make the ship more or less invulnerable.

3rd Question, how can i change the stats of the Asteroids, so it has 1 hp and 1 armor to avoid doing catastrophic damage to ships and still get one-shot by point-defense lasers

Can't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 02, 2013, 07:22:40 AM
Alright, i guess ill have to make asteroids reaaaaaaaly rare to avoid unwanted "ramming", also anyone managed to have 2 drones deploying at the same time from 2 different directions? This is for the Dreadnought, it deployed a pair of fighters at the same time?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 02, 2013, 08:18:52 AM
I have a problem, i made two sounds for "outOfUsesSound" for a new shipsystem.
Only problem is it isnt working, no error message or anything just no sound at all. what am i missing?

Code
	"thule_hgno":{"sounds":[
{"file":"sounds/TL/fx/systems/thule_hgno01.ogg","pitch":1,"volume":0.75},
{"file":"sounds/TL/fx/systems/thule_hgno02.ogg","pitch":1,"volume":0.75},
]},
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 02, 2013, 09:46:09 AM
I have a problem, i made two sounds for "outOfUsesSound" for a new shipsystem.
Only problem is it isnt working, no error message or anything just no sound at all. what am i missing?

Code
	"thule_hgno":{"sounds":[
{"file":"sounds/TL/fx/systems/thule_hgno01.ogg","pitch":1,"volume":0.75},
{"file":"sounds/TL/fx/systems/thule_hgno02.ogg","pitch":1,"volume":0.75},
]},

im not sure i should even try helping you due to my lack of experience but why add the extra {"sounds": ? and not just directly write

Code
{"thule_hgno":[
           {"file":"sounds/TL/fx/systems/thule_hgno01.ogg","pitch":1,"volume":0.75},
           {"file":"sounds/TL/fx/systems/thule_hgno02.ogg","pitch":1,"volume":0.75},
           ],
}

also, im just comparing to vanilla code but your } was in front of the comma instead of behind on the very last line

im not sure im qualified but i wrote this while comparing it to the vanilla coding

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2013, 10:12:06 AM
@Thule: that looks right to me. Can you make sure that the sounds actually play in-game if you use them elsewhere? (i.e. point one of the weapons to use "thule_hgno" as the firing sound - just to make sure they actually play.) Conversely, you could try pointing your new "thule_hgno" sound to existing oggs that are known to work.

What I'm getting at is there's a possibility that something about the ogg doesn't work with the game. Are the sounds super short, btw? IIRC there was some issue with loading really, really small oggs, and I don't remember if it was fixed or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 02, 2013, 10:41:39 AM
the sound is working, just bound it to a weapon and it played in game just fine.
To be clear, i wouldn't have to specify the sound "outOfUsesSound" anywhere else besides the .system file right?

And to be clear it should play the moment the system is not active, recharging, or ist it specificly for systems that have lets say three uses per battle and i would have to use another "trigger"?

The sounds itself can be heard here, they are i would say normal in length.

https://soundcloud.com/invaderoz/thule-hgno01

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2013, 10:48:10 AM
And to be clear it should play the moment the system is not active, recharging, or ist it specificly for systems that have lets say three uses per battle and i would have to use another "trigger"?

Ah, that might be the problem. The "outOfUsesSound" plays whenever the player tries to use the system but can't because it's out of charges/ammo/whatever.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 02, 2013, 10:54:47 AM
The system itself is recharging. So "whatever" means anything system related as long as the system ist not "active". Then it should play, but it doesn't ;(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2013, 10:57:39 AM
Looking at the code: it'll play in response to an failed attempted activation (i.e. not enough ammo or flux), but NOT if it's on cooldown.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 02, 2013, 03:43:40 PM
Oh, okay, then the mystery is solved i guess.
Didn't know that. Thanks for the help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maffo on April 03, 2013, 10:53:40 AM
i am working on my first little step into a basic mod which will hopefully add some ships to the pirate faction. But i ran into an error that i do understand, but i cant find where to fix it:

Quote
229011 [Thread-6] ERROR com.fs.starfarer.combat.D  - org.json.JSONException: Expected a ':' after a key at 6 [character 7 line 1]
org.json.JSONException: Expected a ':' after a key at 6 [character 7 line 1]
   at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
   at org.json.JSONObject.<init>(JSONObject.java:208)
   at org.json.JSONObject.<init>(JSONObject.java:311)
   at com.fs.starfarer.loading.LoadingUtils.void(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.Ö00000(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpecLoader.super(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpecLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.H.super(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)

Could anyone help me?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 04, 2013, 06:32:32 AM
Syntax error at the point said at the top of that code :)

Question: How does one add a chargeup sound? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 04, 2013, 06:40:02 AM
1. is it possible to have a script that would firstly replace the starsector_title_alpha.png and secondly randomize that with every start of starsector another title would appear?

2. The number of burst determines the times a certain sound is played when a weapon is fired, right?
Is it possible to have one fixed sound for a burst of 6 projectiles. This sound would then play only once the weapon is fired.
At the moment i have a premade sound for a burst of 6 and the game is staggering the sound 6 times and that sounds ugly.

1. No. All you can do is replace the image itself, but not dynamically via a script.

2. It's possible (using fireSoundOne - see heavymg.wpn for an example of something that plays a startup sound per burst and then individual sounds per shot). It's probably not a good idea to have all the shot sounds in the same file, though - it could desynced if the fps drops, or the gun could stop firing (due to ship being destroyed, weapon being disabled, flux running out, a vent or phase cloak being initiated, etc), but the full 6 sounds would play anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 04, 2013, 06:45:12 AM
Danke! :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 04, 2013, 07:22:55 AM
Anyone got a sound file for a heavy gauss rifle charge up lasting 10 seconds
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 04, 2013, 08:51:27 AM
1. http://www.freesound.org/
2. http://audacity.sourceforge.net/
3. https://www.google.de/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=en&safe=off&sclient=psy-ab&q=audacity%20tutorials&oq=&gs_l=&pbx=1&fp=516e8a442f24f228&ion=1&bav=on.2,or.r_qf.&bvm=bv.44770516,d.Yms&biw=950&bih=974

Try it out, it's really fun mixing sounds and adding effects ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maffo on April 04, 2013, 12:19:57 PM
i know sprog, but which file is it? Am i missing it and does there a shipspec loader existing or is it a other file?EDIT: nvm, found it with the help of lazy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 05, 2013, 09:51:42 AM
The file that is used to do the chargeup sound is declared as FireSoundOne

The gun firing sound is FireSoundTwo
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on April 07, 2013, 12:27:17 AM
Trying to load custom missile sound, got this error:
Code
47305 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.io.IOException: Unable to load: sounds/starfighterfx/rocketfire1.ogg
java.lang.RuntimeException: java.io.IOException: Unable to load: sounds/starfighterfx/rocketfire1.ogg
at sound.Sound.<init>(Unknown Source)
at com.fs.starfarer.loading.H.super(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.IOException: Unable to load: sounds/starfighterfx/rocketfire1.ogg
at sound.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
... 6 more

Here's what's in sounds.json:
Code
{
"light_rocket_fire":[{"file":"sounds/starfighterfx/rocketfire1.ogg","pitch":1, "volume":0.80}],
}

First time working with sounds, used NeutrinoCorp as a reference for what to do >.>

What do?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 07, 2013, 05:15:50 AM
Can you send me a copy of the mod as it is? I'll see if I can take a peak, check file structure etc
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 07, 2013, 07:37:43 AM
Ive been trying to get the Dreadnought hull hp to go down depending on how many drones are outside, but it seems i cant do this on the shipsystems for some reason, heres the code i got in right now:
~
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;

public class DreadnoughtFighters implements ShipSystemStatsScript {

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
        ShipAPI ship = (ShipAPI) stats.getEntity();

        if (ship == null) {
                return;
            }

        //int HPAmountPerFighter = (int)ship.getMaxHitpoints() / 42;
        float PercPerFighter = 42 / 100; //Grab current perc

            if(ship.getDeployedDrones().isEmpty()) {
                stats.getHullRepairRatePercentPerSecond().modifyFlat(id, (ship.getDeployedDrones().size() * PercPerFighter));
            }
            else {
                stats.getHullRepairRatePercentPerSecond().modifyFlat(id, -(ship.getDeployedDrones().size() * PercPerFighter));
            }
           
}
public void unapply(MutableShipStatsAPI stats, String id) {
stats.getMaxHullRepairFraction().unmodify(id);
        stats.getHullRepairRatePercentPerSecond().unmodify(id);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("Releasing Autonomous Fighters.", false);
}
return null;
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on April 07, 2013, 09:04:18 PM
Mmm, As a question on ship system ai priority... say I have a phase ship, with a ship system that is also phase cloak, the ai will activate both, (redundant yes)

now say that I have a modified ship system that uses the phase_cloak ai (because it's what i sorta want, a system to use when it detects projectiles and missiles, unlike flare which is strictly missile, )

Is there any way to create a way to make it use the ship system as a last ditch instead of concurrently?

I can see in the sample ai of the fast missile racks where there's logic deny it from using the system when high on flux ( I want the exact opposite; use when near critical )
As the ai's aren't public I doubt I could recreate the phase cloak ai in any way shape or form :P


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 07, 2013, 10:30:53 PM
real quick and easy one.
how do fighters determine when to resupply ?
say a wing of 4 ships equipped with 500 rounds of autocannon and 2 harpoon each.

when will they de-engage for resupply ?
im asking cause im modding very resilient and heavily armed fighters that have a powerful main gun along with a few missiles and i wouldnt want them to prematurely de-engage to resupply theire missiles when they can still aptly fight with theire main gun .
(im worried because in this design, the missiles are only there for powerful opportunity strikes, the fighter's main automatic gun is actually the main weapon and i wouldnt want the AI to act the wrong way)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on April 08, 2013, 07:07:02 AM
They will resupply when all of their ammo is gone depending on what role they have, or when the wing as a whole has taken 50% total damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 08, 2013, 11:01:04 AM
They will resupply when all of their ammo is gone depending on what role they have, or when the wing as a whole has taken 50% total damage.

which fighter role should i put in the csv so that it act like i previously described ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on April 08, 2013, 04:07:37 PM
Do anyone knows what an error like this is related to?

Code
455068 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.ai.CampaignFleetAI.private.Object(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleet.advance(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.A.super(Unknown Source)
   at com.fs.starfarer.A.ÖÖÒ000(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 08, 2013, 04:34:17 PM
Anyone know if there's a way to have a bullet sprite with multiple frames of animation?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 09, 2013, 02:42:49 PM
Alrighty, 'nother question:

I'm in the process of setting up an ai for the Elysiums drive system in the hopes that it will stop crashing into things and if hit a bit of an issue.  I based the ai rather heavily off of the ai example Psiyon put together for his Fire Control system; unfortunately the proximity based nature of it seems to be causing the ai to generate false positives from asteroids and thus leads to the ai repeatedly cycling the system on and off.

I know that the Burn Drive "looks ahead" of itself when deciding whether to activate or not.  Is there, either through the default api or through lazylib, some method by which I could get the ship the check in front of itself when deciding if the system is safe to use or not?  I suspect I could probably use getDirectionalVector from lazylib, but I'm not sure how to implement such a thing.

The actual code trying to imitate a decision making process is as follows:

Spoiler
Quote
//Credit goes to Psiyon for his firecontrol AI script.

package data.shipsystems.scripts.ai;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import data.scripts.plugins.CombatUtils;
import java.util.Iterator;
import org.lazywizard.lazylib.MathUtils;
import org.lwjgl.util.vector.Vector2f;
import com.fs.starfarer.api.util.IntervalUtil;

public class ms_drivechargerai implements ShipSystemAIScript {
    private ShipSystemAPI system;
    private ShipAPI ship;
    private float sinceLast = 0f;   
    private IntervalUtil tracker = new IntervalUtil(1f, 2f);
   
    //This just initializes the script.
    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine)
    {
        this.ship = ship;
        this.system = system;
    }
   
    //So here we will tell the ship how to make use of the system.
    @Override
    public void advance (float amount, Vector2f position, Vector2f collisionDanger, ShipAPI target)
    {
        tracker.advance(amount);
       
        sinceLast += amount;
        //Once the interval has elapsed...
   if (tracker.intervalElapsed()) {
            //First we check if the ship is within closing distance of a target, or imminent danger of colliding with something:
            float check_combat = 1000f;
            float check_close = 750f;
            float check_collide = 100f;
            float cutoff_chance = 0f;
            float impact_alert = 0f;
           
            //Then we set it up so that we can track ships
            int ships = 0;
            ShipAPI ship_tmp;
           
            //Now we iterate through all ships on the map
            for (Iterator iter = CombatUtils.getCombatEngine().getShips().iterator();
                iter.hasNext();)
            {
                ship_tmp = (ShipAPI) iter.next();
               
                //We can't collide with fighters, so ignore 'em
                if (ship_tmp.isFighter()) continue;
                if (ship_tmp.isHulk()) continue;
               
                if (CombatUtils.getDistance(ship_tmp, ship) <= (check_combat)) {
                       
                    ships++;
                   
                    if ((CombatUtils.getDistance(ship_tmp, ship) <= (check_close))) {
                        cutoff_chance += 1f;
                    }
               
                    if ((CombatUtils.getDistance(ship_tmp, ship) <= (check_collide))) {
                        impact_alert += 1f;
                    }
               
                    float fluxLevel = ship.getFluxTracker().getFluxLevel();
               
                    //First, lets make it so if no hostile ships are nearby, and the system isn't active, the vessel will turn on the system:
                    if (cutoff_chance <= 1 && !system.isActive() && (ships <= 3) && fluxLevel <=0.35 && ((float) Math.random() > 0.1f)) {
                        ship.useSystem();
                    }
                    //If the ship is only near a few enemies and the system is active, she has moderate chance of turning the system off:
                    else if  (cutoff_chance >= 2 && system.isActive() && (ships >= 3) && ((float) Math.random() > 0.6f)) {
                        ship.useSystem();
                    }
                    //More hostiles means the ship is more like to use the cutoff:
                    else if  (cutoff_chance >= 3 && system.isActive() && (ships >= 4) && ((float) Math.random() > 0.2f)) {
                        ship.useSystem();
                    }
                    //If there are too many ships in the area the system is too risky to use, so the ship will just shut it down period:
                    else if  (cutoff_chance >= 4 && system.isActive() && (ships >= 5)) {
                        ship.useSystem();
                    }
                    //Also, if the ships flux gets too high and the ships system is active, shut it down:
                    else if  (system.isActive() && fluxLevel >=0.85) {
                        ship.useSystem();
                    }
                    //And, for a bit of fun, if enemy ships are within the combat radius, but not too many, and flux is low enough, the ship might turn the system on:
                    else if  (cutoff_chance <= 3 &&  impact_alert == 0 && !system.isActive() && (ships <= 3) && fluxLevel >=0.35 && ((float) Math.random() > 0.8f)) {
                        ship.useSystem();
                    }
                    //Finally if the ship detects an enemy in the direction she's headed inside the collision radius, and her system is on, we'll turn it off:
                    else if  (impact_alert >= 1  && system.isActive()) {
                        ship.useSystem();
                    }
                } else { return; }
            }
        }
    }
}
[close]

The code above "functions" but is terribly finicky, as already mentioned.  In truth I'd like to cut down on the variables just to seeing if the ship is in a range where it's probably in combat or not and seeing if it's likely to collide with something if it keeps the drive online/turns it on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 09, 2013, 04:28:51 PM
Hi guys,

Endercore provided me with a modified version of his wing teleporting system. The system in the original would check if a wing was damaged and teleport it back to the carrier where the system was installed.
The new modified one does simply teleport all deployed ships nearby the ship the system is installed. The big question is how could the system itself made more fancier, visual more pleasing as it it lacking this right now.

endercore's code:
Spoiler
Quote
package data.shipsystems.scripts;

import java.util.List;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import data.scripts.plugins.CombatUtils;
import org.lwjgl.util.vector.Vector2f;
import java.util.Random;


/**
 *
 * @author Ender
 */
public class Fleet_Teleporter implements ShipSystemStatsScript {

    private ShipAPI shipsapi;
    private ShipAPI final_shipsapi;
    private CombatEntityAPI combatEntity;
    private CombatEntityAPI currentShip;
    private CombatEngineAPI engine;
    private MutableShipStatsAPI eachShip;
    private boolean hasRun = false;
   
   
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
        CombatUtils combatEngine = new CombatUtils();
        engine = combatEngine.getCombatEngine();
       
        if (engine != null && !hasRun) {           
            if (engine.getShips() != null) {
                       
                        Random randomNum = new Random();
                        List ships = engine.getShips();  //get a list of all active ships
                        List shipList = null;
                        currentShip = stats.getEntity(); //we need our current ship so that we know who owns it
                        Vector2f location = currentShip.getLocation();
                        for (int i = 0; i < ships.size(); i++) { //now we loop through the entire list of ships
                            shipsapi = (ShipAPI) (ships.get(i)); //assign the current ship to the ShipAPI so we can give it bonuses or penalties
                            eachShip = shipsapi.getMutableStats(); //now we need something Mutable
                            combatEntity = eachShip.getEntity(); //we need to assign it as an entity as well so we can see who owns it
                           
                            //in here, we're checking to find friendly ships
                            if ((combatEntity.getOwner() == currentShip.getOwner()) && (eachShip != null) && (combatEntity != stats.getEntity())) {
                                float randomX = (randomNum.nextInt(5) - 2) * 400;
                                float randomY = (randomNum.nextInt(5) - 2) * 400;
                                shipsapi.getLocation().x = (location.x + randomX);
                                shipsapi.getLocation().y = (location.y + randomY);
                            }
                        }
                        hasRun = true;
            }           
        }
    }

   
    public void unapply(MutableShipStatsAPI stats, String id) {
      //there's nothing to unapply here, so we can leave this block of code empty
                hasRun = false;
    }
   
    public StatusData getStatusData(int index, State state, float effectLevel) {
      if (index == 0) {
         return new StatusData("Teleporting fleet to near", false); //display status message to the player
      }
      return null;
   }
}
[close]

The ship i had in mind would be this one:(http://i.imgur.com/AdWBgby.png)

Kind of a "deep diver" or long range Phase ship which could sneak behind enemy lines unharmed, teleport the deployed fleet and make its tactical retreat.
The electric thingy and the shape of the ship reminded me of some kind of portal and i guess some emp arcs spawning around or over the ship would be quite suitable.
Or would it be possible to have a decorative weapons take the part of an animation?

Maybe someone has a clue if one or all or none of the above would be possible to code?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 09, 2013, 04:31:40 PM
I just so happen to have arc emitter weapon codes and scripts :)

LazyWizard created them, and you'd have to wait until tomorrow toget them
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on April 09, 2013, 04:37:14 PM
I think some of Flash's newer weapons for Neutrino have animated projectiles, you could take a look at those.

Thule: The energy-looking things in the middle of the circle portion of the hull look like some kind of field generator, Maybe each bit would fire into the middle and cause some kind of EMP (Like, AoE EMP) to nearby ships? Just speculation, I imagine you already have a use for it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 09, 2013, 04:43:00 PM
@vinya

yeah the ship above and the energy looking things in the middle where supposed to match the shipsystems teleporting ability by spawning "visual" emp arcs.
I thought i already made that clear in my text, but i guess not. Sorry for that as english is not my first language ;) but thanks for the input anyway, and i had quite the same in mind
as i made the ship some time ago.

@sprog
Thanks buddy. i guess you wouldnt be able to combine your lazy wizard code with the one endercore created? ^^
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 09, 2013, 05:59:24 PM
I have a couple of questions that I've been wondering about, but Im not really a programmer.

Is there any way to create a projectile that impacts other projectiles? Or at the very least, a missile that doesnt get targeted by PD?

Also, I'd like to know if there is a way to create a projectile that is able to penetrate multiple targets.

Any answers, even "No", would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 09, 2013, 06:10:05 PM
I have a couple of questions that I've been wondering about, but Im not really a programmer.

Is there any way to create a projectile that impacts other projectiles? Or at the very least, a missile that doesnt get targeted by PD?

Also, I'd like to know if there is a way to create a projectile that is able to penetrate multiple targets.

Any answers, even "No", would be greatly appreciated.

what do you mean "a projectile that impacts other projectile ?"
and im pretty sure PDs are hardwired to shoot at missile, its kindof part of the balance mechanism versus missiles. i mean, your missile will become way too strong if its homing and cant be hit by PDs, and if its not homing and youre worried about PDs, then why even make it a missile ?

also, i recall seeing a mod somewhere on another forum of starsector that had a penetrating mechanism, but that was done with modding illegally so of the code
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 09, 2013, 06:22:57 PM
I think some of Flash's newer weapons for Neutrino have animated projectiles, you could take a look at those.

Well, I've given it a look-see and it seems like Flash managed to spoof projectile animations by cunningly using MIRV styled missiles for his projectiles; literally spawning the next frame of animation through the projectile mechanics.

Cunning.  Not sure how applicable it'll be, but quite clever.  At the very least it's given me some ideas.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 09, 2013, 06:31:58 PM
Actually, the emitter just targets the closest weapon with the Id you set it in the script, that will allow you to create a central "weapon" that the arcs can aim at to give that awesome portal look
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 09, 2013, 06:44:11 PM

what do you mean "a projectile that impacts other projectile ?"
and im pretty sure PDs are hardwired to shoot at missile, its kindof part of the balance mechanism versus missiles. i mean, your missile will become way too strong if its homing and cant be hit by PDs, and if its not homing and youre worried about PDs, then why even make it a missile ?

also, i recall seeing a mod somewhere on another forum of starsector that had a penetrating mechanism, but that was done with modding illegally so of the code

Well, what I meant was a projectile that can impact other projectiles like a missile does. I wasn't sure if there was something I could do with the Collision Class string in the proj file. Im looking to make a weapon that is used to destroy enemy projectiles, either by firing a large projectile, or an array of smaller ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 09, 2013, 06:48:25 PM
I know what you mean, like how to ballistic weapons can't intersect, correct? But a missile can hit another missile, and ballistic can hit missile
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 09, 2013, 06:51:00 PM
Exactly
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 09, 2013, 07:18:51 PM
Ah, I see. Well you COULD just set up a bunch of missile weapons to mimic ballistics xD
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 09, 2013, 07:36:15 PM
Wouldnt PD attack the projectile then? That would look wierd havinga giant shockwave getting shot at by PD lasers ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 09, 2013, 07:47:18 PM
Wouldnt PD attack the projectile then? That would look wierd havinga giant shockwave getting shot at by PD lasers ;)

Shock waves? Doesn't Uozmoz Corvus have a ship in it that creates a huge shock wave? Causing all ships, ballistic and missiles to bounce away
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 09, 2013, 08:19:04 PM
I haven't seen any ship that creates a shockwave in UC.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EnderNerdcore on April 09, 2013, 09:33:46 PM
Wouldnt PD attack the projectile then? That would look wierd havinga giant shockwave getting shot at by PD lasers ;)

Shock waves? Doesn't Uozmoz Corvus have a ship in it that creates a huge shock wave? Causing all ships, ballistic and missiles to bounce away
You're thinking of the gravity system on the capital ship in Blackrock Drive Yards, but it doesn't do that, it just slows ballistics and missiles down (unless there is something else like it)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 09, 2013, 10:05:48 PM
Wouldnt PD attack the projectile then? That would look wierd havinga giant shockwave getting shot at by PD lasers ;)

Shock waves? Doesn't Uozmoz Corvus have a ship in it that creates a huge shock wave? Causing all ships, ballistic and missiles to bounce away
You're thinking of the gravity system on the capital ship in Blackrock Drive Yards, but it doesn't do that, it just slows ballistics and missiles down (unless there is something else like it)

i know thule's been working on the herzog new system, the heimdall generator that basicly does a huge shockwave
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on April 10, 2013, 03:25:23 AM
The shockwave system is on the Vatican Mk IV from the Valkyrians mod. The code is being reused for Thule's new system. :)

Also, I'd like to know if there is a way to create a projectile that is able to penetrate multiple targets.

also, i recall seeing a mod somewhere on another forum of starsector that had a penetrating mechanism, but that was done with modding illegally so of the code

That would be xangle13's armor penetration system (http://fractalsoftworks.com/forum/index.php?topic=5819.0), and it's actually implemented entirely within the API. Unfortunately it works by spawning a new projectile every frame there is a hit, so weapon ranges get really messed up.

I've had some luck making true armor piercing rounds by giving projectiles the CollisionClass NONE and using an EveryFrameCombatPlugin to handle collision checks/damage myself. I can polish up that code and release it if you want. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 10, 2013, 06:55:35 AM
The shockwave system is on the Vatican Mk IV from the Valkyrians mod. The code is being reused for Thule's new system. :)

That would be xangle13's armor penetration system (http://fractalsoftworks.com/forum/index.php?topic=5819.0), and it's actually implemented entirely within the API. Unfortunately it works by spawning a new projectile every frame there is a hit, so weapon ranges get really messed up.

I've had some luck making true armor piercing rounds by giving projectiles the CollisionClass NONE and using an EveryFrameCombatPlugin to handle collision checks/damage myself. I can polish up that code and release it if you want. :)

I appreciate the offer, but I dont know the first thing about coding, and I wouldn't know how to implement such code. Makes me wish I had a better C++ teacher back in high school who wasn't teaching out of C++ for dummies :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on April 10, 2013, 06:59:19 AM
No worries, all you need to do is add a single line to the plugin and it does all the work. :)

Example:
Code
        // Projectile ID (String), pierces shields (boolean)
        PROJ_IDS.put("impaler_shot", false);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 10, 2013, 07:18:44 AM
Well, Im still working on sprites and such, so theres no rush at all. But if it get implimented in LazyLib, I know I'll use it :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 14, 2013, 07:05:39 PM
not sure how the weapon.getId() works

does it return the id, display name, or something else?

so for example, if I get a mining blaster to call that, what's the return gonna be?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 15, 2013, 05:18:05 AM
not sure how the weapon.getId() works

does it return the id, display name, or something else?

so for example, if I get a mining blaster to call that, what's the return gonna be?

The number id on the CSV weapon_data, as a String
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on April 15, 2013, 10:36:21 AM
So I'm working on a system or two for custom ships, not sure how to go about it though.

Essentially the system just allows PD Lasers all over the ship to actually fire while locking other weapon systems.

If possible, the PD matrix should be able to replace shields like phase-tech, but if not it should disable shields.

The other system is an ECM Jamming system that while turned on, any missiles locked onto the ship will lose tracking, and any missiles fired at the ship will lose tracking. Possible by using invisible flares?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 15, 2013, 10:51:10 AM
So I'm working on a system or two for custom ships, not sure how to go about it though.

Essentially the system just allows PD Lasers all over the ship to actually fire while locking other weapon systems.

If possible, the PD matrix should be able to replace shields like phase-tech, but if not it should disable shields.

The other system is an ECM Jamming system that while turned on, any missiles locked onto the ship will lose tracking, and any missiles fired at the ship will lose tracking. Possible by using invisible flares?



considering some of the ship systems cycerin got into his mod (the nevermore and the kurmaraja especially) i'd say that you just need to find a talented coder to get all those awesome ideas working perfectly
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 15, 2013, 09:02:14 PM
is there a way of hiding decorative weapons from the grouping bug? Or are we just waiting on a fix at this point?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 19, 2013, 11:55:33 AM
Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2013, 11:57:56 AM
is there a way of hiding decorative weapons from the grouping bug? Or are we just waiting on a fix at this point?

Waiting for a fix.

Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk

Yeah, you could iterate through ships every frame and detect when isHulk() starts returning true. There's no way to revive a ship, though. Not that I can think of, anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 19, 2013, 12:03:17 PM

Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk

Yeah, you could iterate through ships every frame and detect when isHulk() starts returning true. There's no way to revive a ship, though. Not that I can think of, anyway.

Well, maybe if the ships hp are about to reach 0 or lower then 0, trying to find a way to replicate the Fury http://wiki.uqm.stack.nl/Fury special ability
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on April 19, 2013, 01:43:06 PM

Is there a way to grab the event of a ship being destroyed? I need to make a passive system that "revives" a ship once its turned into a hulk

Yeah, you could iterate through ships every frame and detect when isHulk() starts returning true. There's no way to revive a ship, though. Not that I can think of, anyway.

Well, maybe if the ships hp are about to reach 0 or lower then 0, trying to find a way to replicate the Fury http://wiki.uqm.stack.nl/Fury special ability

You could try spawning the same ship again, something like the following:
Code
        engine.getFleetManager((ship.getOwner() == 0 ? FleetSide.PLAYER : FleetSide.ENEMY))
                .spawnShipOrWing(ship.getHullSpec().getHullId(),
                ship.getLocation(), ship.getFacing());
        engine.removeEntity(ship);

You would probably want to change ship.getHullSpec().getHullId() to the variant name. I don't think there's a way to get the variant ID through the API yet, so it would have to be hardcoded (you could use ship.getVariant().getDisplayName() to select between the various default variants).

You'd lose anything customized on the old ship - name, hullmods, vents/caps, etc. I've never used spawnShipOrWing before so I don't know if the ship is added to your fleet, so it's possible you'd lose the ship after the battle anyway.

All in all, not a great solution outside of missions, but it's the best I can see as possible right now. :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on April 19, 2013, 01:51:57 PM
Slightly better solution (not tested):

Code
    public static String getVariantId(ShipAPI ship)
    {
        CampaignFleetAPI tmpFleet;
        FleetMemberAPI tmpShip;
        for (Iterator fleets = ((StarSystemAPI) Global.getSector().getStarSystems().get(0))
                .getFleets().iterator(); fleets.hasNext();)
        {
            tmpFleet = (CampaignFleetAPI) fleets.next();
            for (Iterator ships = tmpFleet.getFleetData().getMembersListCopy().iterator(); ships.hasNext();)
            {
                tmpShip = (FleetMemberAPI) ships.next();
                if (tmpShip.getId().equals(ship.getFleetMemberId()))
                {
                    return tmpShip.getSpecId();
                }
            }
        }

        return ship.getHullSpec().getHullId();
    }

    public static void revive(ShipAPI ship, CombatEngineAPI engine)
    {
        engine.getFleetManager((ship.getOwner() == 0 ? FleetSide.PLAYER : FleetSide.ENEMY))
                .spawnShipOrWing(getVariantId(ship), ship.getLocation(), ship.getFacing());
        engine.removeEntity(ship);
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on April 19, 2013, 04:09:16 PM
Hey guys I have a weird report for my mod and I'm not sure what it may be related to, any clue?

Spoiler
51418 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ArrayIndexOutOfBoundsException: 2
java.lang.ArrayIndexOutOfBoundsException: 2
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus.OÒ0000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleetMemberView.super(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleetView.private.String(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleet.render(Unknown Source)
   at com.fs.starfarer.campaign.BaseCampaignEntity.render(Unknown Source)
   at com.fs.graphics.LayeredRenderer.Õ00000(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.render(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.render(Unknown Source)
   at com.fs.starfarer.campaign.A.Óô0000(Unknown Source)
   at com.fs.starfarer.A.ÖÖÒ000(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 21, 2013, 09:42:41 AM
Alright so, for those who dont know, ive been working on a mod for SC2, that means, creating a few mechanics that arent present in the vanilla.
Right now im stuck with a weapon i cant manage to work, know as the Variable power blaster.
More info: http://wiki.uqm.stack.nl/Trader

So how does it work?
It spawns a projectile infront of the ship, that projectile can be used as a shield and its consumed if used like that, but, the more time you charge the weapon, the stronger that projectile gets. The weapon has 4 stages, a green one that does 2000 dmg, next comes the blue does 4000 dmg, then the purple/magenta, does 8000 damage and last comes the red one doing 16000 damage. While the projectile with stay still as long as you keep "firing", meaning holding the LMB, when you release, it will release the projectile that was currently created. While i cant make the weapon permanently chargeable, ive been trying to at list do the projectile animation infront of the ship and once you released the charge it would reset the animation and would spawn the projectile for the current charge level.
So far the weapon plugin i worked on with Lazy's help has ignored every condition i/he set to avoid spawning projectiles with 0 cd.
Heres the code ive changed and got in so far:

Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import java.awt.Color;

public class TraderVariablePowerBlasterEffect implements EveryFrameWeaponEffectPlugin
{  
    // weapon takes 7 seconds to fully charge
    private int currentCharge = 0;
    private float currentChargelvl = 0;

public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
        {
            ShipAPI ship = weapon.getShip();
            if (ship == null)
            {
                return;
            }
            currentChargelvl = weapon.getChargeLevel();
            AnimationAPI animation = weapon.getAnimation();
            
            if (weapon.isFiring())
            {
                ship.getMutableStats().getFluxDissipation().modifyFlat(ship.getHullSpec().getHullId().toString(), 0); //while chargins the dissipation should be set to 0
                
                if (currentChargelvl <= 0.33f)
                {
                    //Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                    if(currentCharge == 0)
                    {
                        engine.addFloatingText(ship.getLocation(), "Power Level 1",25f,Color.GREEN,weapon.getShip(),0f,0f);
                        currentCharge = 1;
                        animation.setFrame(1);
                        animation.play();
                    }
                    
                    if(animation.getFrame() == 5)
                    {
                        animation.setFrame(1);
                        animation.play();
                    }
                }
                
                if (currentChargelvl <= 0.66f && currentChargelvl > 0.33f)
                {
                    if(currentCharge == 1)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 2",25f,Color.BLUE,weapon.getShip(),0f,0f);
                        currentCharge = 2;
                        animation.setFrame(6);
                        animation.play();
                    }

                    if(animation.getFrame() == 10)
                    {
                        animation.setFrame(6);
                        animation.play();
                    }
                }
                
                if (currentChargelvl <= 0.99f && currentChargelvl > 0.66f)
                {
                    if(currentCharge == 2)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 3",25f,Color.MAGENTA,weapon.getShip(),0f,0f);
                        currentCharge = 3;
                        animation.setFrame(11);
                        animation.play();
                    }
                    
                    if(animation.getFrame() == 15)
                    {
                        animation.setFrame(11);
                        animation.play();
                    }
                }
                
                if(currentChargelvl > 0.99f)
                {
                    if(currentCharge == 3)
                    {
                        engine.addFloatingText(ship.getLocation(), "Max Power Level",25f,Color.RED,weapon.getShip(),0f,0f);
                        currentCharge = 4;
                        animation.setFrame(16);
                        animation.play();
                    }

                    if(animation.getFrame() == 20)
                    {
                        animation.setFrame(16);
                        animation.play();
                    }
                }
            }  
            else
            {
                switch (currentCharge)
                {
                    case 1:
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_s1_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                        engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s1", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                        ship.getFluxTracker().increaseFlux(500, false);
                        weapon.setRemainingCooldownTo(1f);
                        break;
                    }
                    case 2:
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_s2_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                        engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s2", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                        ship.getFluxTracker().increaseFlux(500, false);
                        weapon.setRemainingCooldownTo(1f);
                        break;
                    }
                    case 3:
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_s3_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                        engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster_s3", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                        ship.getFluxTracker().increaseFlux(500, false);
                        weapon.setRemainingCooldownTo(1f);
                        break;
                    }
                    default:
                    // Whatever happens if it isn't charged
                }
                ship.getMutableStats().getFluxDissipation().unmodify();
                currentCharge = 0;
            }
            
    }//advance
}  

With the code atm, will spawn the lvl 1 projectile without charging anything.

heres a video: http://www.youtube.com/watch?v=FEYfYxM7iVA
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2013, 10:13:36 AM
Hmm. I don't think you're using the AnimationAPI correctly. play() will loop the animation, so relying on code like this:
if(animation.getFrame() == 15)
{
    animation.setFrame(11);
    animation.play();
}
Is a mistake because you're not guaranteed to actually stop on that frame. It might get missed due to a frame rate hiccup. If the animation is slow enough (<30fps), I suppose it might work, since the engine won't go below that (but will slow time instead)... but still, a bit iffy.

So, if you're going to use setFrame(), you should go all the way and use it to drive the whole animation rather than using play().


Beyond that, I don't see anything glaringly wrong, though it was a rather quick look. I'd suggest adding some messages to the log to help figure out what's going on here (or running with an IDE and hooking a debugger up to the JVM, so you can actually use breakpoints, but that's more involved.)

For logging:
Logger log = Logger.getLogger(this.getClass());
log.info("whatever string you want to print");


Opening up the log file with a text editor capable of updating it on the fly would be helpful if you do that, too. Or using something like "tail" on it (which you could do if you installed cygwin, if you're running Windows).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 23, 2013, 01:13:37 PM
no luck so far, would using IntervalUtil help? Also i do not know exactly how it works, if its a interval from X to X
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on April 23, 2013, 01:32:34 PM
no luck so far, would using IntervalUtil help? Also i do not know exactly how it works, if its a interval from X to X

It's basically a repeating timer where you can have different intervals each iteration.

The values you pass in are the minimum and maximum intervals. It picks a random number in the range between them as its 'target' (you can just pass in the same number for both for a normal timer behavior). You need to call advance(<amount to advance>) for the IntervalUtil to work; usually you will use the time since the last frame as the amount argument. You can then check intervalElapsed() to see if it hit its target. You need to check intervalElapsed() after each advance(), because it will only return true for one frame. The next frame after time is up, a new random interval in the range you gave is chosen, and the process starts over.

You can change the interval ranges at any time with setInterval(min, max).

IntervalUtil is in the API, by the way, so you can view the source in starfarer.api.zip.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 23, 2013, 04:59:22 PM
hi there,

i am trying to set up a decorative weapon.
i get an error message i can't figure out. It's looking for filenames that arent specified anywhere. Is there a certain file suffix neccesary`?

Code
java.lang.RuntimeException: Error loading [graphics/TL/weapons/decor/thule_heimdahl_0059_Frame-1.png01.png] resource, not found in [D:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\LazyLib,D:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\StealThisStuff,D:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Thule Legacy,../starfarer.res/res,CLASSPATH]
at com.fs.util.C.Ò00000(Unknown Source)
at com.fs.util.C.Object(Unknown Source)
at com.fs.graphics.K.String(Unknown Source)
at com.fs.graphics.K.Ò00000(Unknown Source)
at com.fs.graphics.K$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2013, 05:16:32 PM
graphics/TL/weapons/decor/thule_heimdahl_0059_Frame-1.png01.png

That part looks suspect, but I can't say without seeing your filenames and what you've got in the .wpn file.

The naming convention has to be:
graphics/weapons/shredder/chaingun2_turret_base00.png
graphics/weapons/shredder/chaingun2_turret_base01.png
graphics/weapons/shredder/chaingun2_turret_base02.png
...
graphics/weapons/shredder/chaingun2_turret_base99.png
graphics/weapons/shredder/chaingun2_turret_base100.png
graphics/weapons/shredder/chaingun2_turret_base101.png
etc. So, has to end in .png, and the number has to precede that, and it has to be 2 digits unless it's 100 or over (i.e. you can't do 001, iirc).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 23, 2013, 05:43:04 PM
ah, i see, okay i guess there is the problem. the frames are numbered in three digits and the number is not at the end of the filename.

What i did:
I took okims mod "ironclad" and tried to mimic his landing lights.

The following files are involved:

D:\Program Files (x86)\Fractal Softworks\Starsector\mods\Thule Legacy\data\scripts\plugins\isHulkCheck.java
Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.FluxTrackerAPI;

public class isHulkCheck implements EveryFrameWeaponEffectPlugin
{

 public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
  {
   if (engine.isPaused()) return;

   AnimationAPI animation = weapon.getAnimation();
 
   if (weapon.getShip().isHulk())
    {
    animation.pause();
    }

   else
    {
     animation.play();
    } 

  }

}




D:\Program Files (x86)\Fractal Softworks\Starsector\mods\Thule Legacy\data\weapons\thule_deco_heimdahl.wpn
Code
{
"id":"thule_deco_heimdahl",
"specClass":"projectile",
"type":"DECORATIVE",
"size":"MEDIUM",

"everyFrameEffect":"data.scripts.plugins.isHulkCheck",

"turretSprite":"graphics/TL/weapons/decor/thule_heimdahl_Frame-01.png",
"hardpointSprite":"graphics/TL/weapons/decor/thule_heimdahl_Frame-01.png",

"numFrames":60,
"frameRate":15,
"alwaysAnimate":"true",

"turretOffsets":[0, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[0, 0],
"hardpointAngleOffsets":[0],

"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE
"muzzleFlashSpec":{"length":0.0,   # only used if animationType = MUZZLE_FLASH
   "spread":10,
   "particleSizeMin":4.0,
   "particleSizeRange":18.0,
   "particleDuration":0.2,
   "particleCount":25,
   "particleColor":[255,150,30,200]},

"projectileSpecId":"thule_barbarossa_shot",  # projectile that will be fired
"fireSoundTwo":"thule_barbarossa",
"fireSoundOne":"thule_barbarossa_overload",
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 23, 2013, 05:51:58 PM
the current naming convention looks like this: thule_heimdahl_Frame01.png, ..., thule_heimdahl_Frame60.png

it's still lokking for graphics/TL/weapons/decor/thule_heimdahl_Frame01.png01.png
Don't know how it gets the idea ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2013, 06:37:23 PM
A-ha! Looking at the code, the frames have to start with 00. Have fun renaming all the files :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 23, 2013, 07:57:54 PM
ouch...

that can't be fun....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on April 23, 2013, 08:04:40 PM
NO IT WASN'T FUN!!! ;) but at least it did the trick ;)

Thanks alex for the help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 23, 2013, 08:21:42 PM
oh wow XD thats the kind of mistake that makes you feel dumb when they happens  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on April 23, 2013, 09:09:11 PM
Yeah, I had that problem when I was doing my first animations. Thankfully I've been animating various things for years already so I'm used to finding problems like that. That was nothing compared to this game some guy had me work on. I had to 3D animate a whole helicopter- engine and everything. 0_0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 24, 2013, 12:35:28 AM
anyway, I have found that there seem to be a limited number of smoke particles that can exist simultaneously in a battle, but other particles (like smooth particle) seem to be unlimited. I assume this is intended since a limit like that has to be coded in somehow (unless it's a part of LWJGL?)

is this for performance? If so why isn't smooth particle limited as well? Is there a way to set how many particles can be in a battle?

thanks

gunny
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 24, 2013, 10:40:01 AM
There's a limit for both kinds; as you guessed, for performance reasons. It's currently hardcoded, and I don't know that changing that makes sense.

These are never going to be something you can just spawn at will without worrying about performance. Generally speaking, if whatever effect you're going for requires a LOT of them, then it's probably best to either 1) make sure the effect doesn't happen often or 2) reconsider how the effect's visuals are implemented.

It's sort of like that with EMP arcs, too - yeah, you can go overboard and spawn a lot of them and it looks cool, but that doesn't make it a good idea performance-wise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarducar_Dun on April 24, 2013, 01:02:48 PM
Errrrm I think this should go here. I'm thinking of starting a mod and I'm trying to get some ideas down on paper, I'm wondering what kind of health and armourvalues vanilla missiles have to balance my P.D. and missiles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on April 24, 2013, 01:50:28 PM
Errrrm I think this should go here. I'm thinking of starting a mod and I'm trying to get some ideas down on paper, I'm wondering what kind of health and armourvalues vanilla missiles have to balance my P.D. and missiles?

your best bet is to check the weapon csv and compare values. from there you can do some math yourself and see what works for you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 24, 2013, 05:04:03 PM
There's a limit for both kinds; as you guessed, for performance reasons. It's currently hardcoded, and I don't know that changing that makes sense.

well... I feel that would belong in options rather than anything else. I seem to remember quite a few games (such as GSB i believe) have a slider of number of allowed particles there. But this is a discussion for suggestions I suppose so I'll drop it here and maybe start a thread at some point...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarducar_Dun on April 24, 2013, 11:45:13 PM
Ah thanks.
Where do I find the CSV's though? I've looked on the forum and yes that's exactly what I need but I don't know where to look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on April 25, 2013, 12:01:38 AM
/Fractal Softworks/Starsector/starsector-core/data/weapons

check in there, anything that ends in .wpn is well... a weapon, what you're looking for is weapon_data.csv


/Fractal Softworks/Starsector/starsector-core/data/hulls

for ships it is ship_data.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarducar_Dun on April 25, 2013, 12:22:58 AM
Ahhhh that makes sense. Thanks a bunch.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowFox on April 25, 2013, 01:50:12 AM
So my question is a bit strange, and perhaps might be irrelevant since it may make little sense to keep within Starsector, but I am looking to see if it is at all possible to make it so when max flux is reached and overload happens, can the weapons still be used. I am working on the Star Wars Mod, and I want to try and make it as close to lore as possible. I have no idea if this is possible or not, but it would go a long way to making the mod play how I want it to.

Obviously if that can't be done, I will work around it. But I'm hoping there is some workaround. My weapons generate 0 flux, so flux is only a  measure of shield strength. Thanks in advance to any help with this matter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 25, 2013, 08:09:57 AM
Custom beam graphics

How does one set the Projectile graphic of a pulse shot, kinda like the Autopulse shot, To be a custom sprite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 25, 2013, 03:07:28 PM
How does one set the Projectile graphic of a pulse shot, kinda like the Autopulse shot, To be a custom sprite?

"textureType":"SMOOTH",

That line in the .proj file can also point to an array of graphics filenames, like so:
"textureType":["filename1.png","filename2.png"]

IIRC the first one is the fringe and the second one the core of the beam/pulse projectile, but I might have that reversed.


So my question is a bit strange, and perhaps might be irrelevant since it may make little sense to keep within Starsector, but I am looking to see if it is at all possible to make it so when max flux is reached and overload happens, can the weapons still be used. I am working on the Star Wars Mod, and I want to try and make it as close to lore as possible. I have no idea if this is possible or not, but it would go a long way to making the mod play how I want it to.

Obviously if that can't be done, I will work around it. But I'm hoping there is some workaround. My weapons generate 0 flux, so flux is only a  measure of shield strength. Thanks in advance to any help with this matter.

Not possible, sorry :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 25, 2013, 03:12:23 PM
But doesn't that set it up to just as a shaped beam, I'm trying to get it to work like a bullet sprite :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on April 25, 2013, 06:43:17 PM
So my question is a bit strange, and perhaps might be irrelevant since it may make little sense to keep within Starsector, but I am looking to see if it is at all possible to make it so when max flux is reached and overload happens, can the weapons still be used. I am working on the Star Wars Mod, and I want to try and make it as close to lore as possible. I have no idea if this is possible or not, but it would go a long way to making the mod play how I want it to.

Obviously if that can't be done, I will work around it. But I'm hoping there is some workaround. My weapons generate 0 flux, so flux is only a  measure of shield strength. Thanks in advance to any help with this matter.

You could have a plugin that constantly scans the ships on the battlefield, and when it finds one that is overloading it stops the overload, sets the shield unfold rate to zero, and starts a timer to remove the malus X seconds from now. This would (sort of) disable the shields when an overload happens without the rest of the effects of an overload. I think that's as close as you can get to what you want in the current version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 25, 2013, 07:55:44 PM
But doesn't that set it up to just as a shaped beam, I'm trying to get it to work like a bullet sprite :)

You can use the ballistic projectile spawn type, then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 25, 2013, 07:58:17 PM
I'm unsure what you mean, sorry :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 25, 2013, 08:22:26 PM
What I mean is, if you're trying to get it to work like a bullet sprite, use a bullet, like the ballistic weapons do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 25, 2013, 08:31:09 PM
And how is this accomplished? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on April 25, 2013, 08:42:04 PM
Is it possible to make a 'weapon' that in reality is just an external cargo pod mounted instead of a weapon? Therefore it wouldn't turn or anything- just cost a few OP and add cargo space.

If not, would be a good suggestion.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on April 25, 2013, 10:14:14 PM
I wouldn't mind something similar to add armour or better shielding. Cover up all those mounts I've no use for, or have run out of OP to fit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 27, 2013, 07:41:42 PM
On another note, I was wondering if any in fact had a way to make projectiles that impacted other projectiles? One of the systems Im working on is basically an anti-projectile system. Basically what I'm building is a weapon that fires a quick burst of projectiles with a wide firing pattern, and destroys other projectiles in a short range in front of the ship. I know I could use missiles, but I find that a missile-based system limits the longevity of this ship considerably due to ammo (I dont want to make too many solid weapon systems that simply regen ammo). Plus, when I have the missile slow down to a crawl and the PDs still focus the non-damaging missiles down, it looks kind of silly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sarducardun on April 28, 2013, 01:51:55 AM
Beat me to it arumac. I was looking for a way to not need shields on a high tech ship and I had just settled on powerful integrated pd that will hit anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on April 28, 2013, 05:06:07 AM
I tried to create a mod and add a ship in it. First time it worked, but the engines where too bright, so i used Trylobot Ship Editor to change them a bit. Now Starsector dont want to start, i got this in the logs, however i'm not too sure what i am looking at:

Spoiler
--------------------------------
4635 [Thread-6] ERROR com.fs.starfarer.combat.D  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.H.super(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
[close]

Some help please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 28, 2013, 06:26:09 AM
How to get a ship to show up in the station?

I have the image, the .ship file, the variant; I've added it to the string and ship_data.cvs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 28, 2013, 06:54:57 AM
Now add it to it's initial cargo, find the station generator you want and ad it :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on April 28, 2013, 07:23:20 AM
One of two ways, you could either open your save game, look at the name of a ship that's currently in the station and search for that ship in your save game's data, then convert that ship into your new one by changing things like the hull ID.
Example;
Here's the KK Kamchatka II, a Novgorod-class cruiser (http://scr.hu/0zoz/27a8n).
Here's the Kamchatka in my savegame (http://scr.hu/0zoz/f6xu7).

A little bit of fiddling, and now the Kamchatka is a Moscow-class battleship (http://scr.hu/0zoz/fax9x).
And here's the Kamchatka in my savegame (http://scr.hu/0zoz/ejmxy).

The other method involves diving into the core files, or mod files if you're tampering with a mod.
You'll wanna go to the data folder, then scripts, then world, then corvus. In the corvus folder, you'll find corvus.java. If you open corvus.java, it'll look something like this (http://scr.hu/0zoz/ldi0o). Now, if you're tampering with a mod that's already been made, you can just search for a ship that you know you always find in a station at the start of the game. Here, I'm using the Moscow battleship again. Duping that line there as many times as I want will let me have as many Moscows as I want in a station at the start of the game.

Another method is fiddling with a convoy to have a really high chance of delivering the ship you want. However, I don't know how to do that. I assume it'd be similar to fiddling with the generation files.
Hope that helped.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 28, 2013, 07:27:56 AM
Yea, I'm using Ironclad mod and I'm adding my own ships, but the game keeps crashing.

Can anyone tell me where the log file is located?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 28, 2013, 07:38:53 AM
Starsector core :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 28, 2013, 09:23:42 AM
What? I checked there twice. It was the first location I checked....how he hell did I miss it?  ??? ??? ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 28, 2013, 09:47:38 AM
If you know not of what you are searching for, you may never find the answer

Extract from the Sproginian decree. Book of Sprog Number 4
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Upgradecap on April 28, 2013, 10:18:52 AM
Yea, I'm using Ironclad mod and I'm adding my own ships, but the game keeps crashing.

Can anyone tell me where the log file is located?

Because it needs to be generated, for one. Might be something to look out for, if you delete it. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 28, 2013, 10:29:28 AM
And how is this accomplished? :)

Take a look at any of the weapons that work that way - say, the Assault Chaingun.

I tried to create a mod and add a ship in it. First time it worked, but the engines where too bright, so i used Trylobot Ship Editor to change them a bit. Now Starsector dont want to start, i got this in the logs, however i'm not too sure what i am looking at:

Spoiler
--------------------------------
4635 [Thread-6] ERROR com.fs.starfarer.combat.D  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.H.super(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
[close]

Some help please?

Seems like the ship_data.csv might be malformed - looks like it's not finding the "id" column in it. If looking at it doesn't help, might be worth it to create a separate thread for this and post the .ship and the .csv there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 28, 2013, 11:01:40 AM
Is it possible to make a 'weapon' that in reality is just an external cargo pod mounted instead of a weapon? Therefore it wouldn't turn or anything- just cost a few OP and add cargo space.

If not, would be a good suggestion.

Oh, missed this one. No, not possible. Well, not practical, anyway - you could maybe rig something up with an over-abundance of decorative slots that respond to a ship having a certain hullmod...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on April 28, 2013, 11:32:46 AM
Anyone? Any of the smart programmers on here have any idea how one could make a projectile that collides with other projectiles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on April 28, 2013, 01:37:11 PM
Seems like the ship_data.csv might be malformed - looks like it's not finding the "id" column in it. If looking at it doesn't help, might be worth it to create a separate thread for this and post the .ship and the .csv there.

Thank you, i found my problem, the ID column has indeed been weirded up by Open Office.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on April 29, 2013, 01:21:12 PM
I need to somehow make a projectile move as long as you keep "firing" the weapon, once it stops (!weapon.IsFiring()) the projectile will fade/despawn and spawn several projectiles clockwise (in this case 6 so its 60,120,180,240,300 and 360) around it with a high velocity.

if i do manage to get the first part running ill be able to replicate the Marauder (http://wiki.uqm.stack.nl/Marauder) Spin-blade and the Broodhome (http://wiki.uqm.stack.nl/Broodhome) Crystal Shard
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 29, 2013, 01:24:16 PM
Oh thats a tuffy, Maybe see how the Harlem Shake spawned other ships, and reverse engineer it to:

 isWeaponFiring !=True
{
  SpawnProjectiles
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 29, 2013, 11:15:14 PM
Shielded fighters?

I saw one or two in the screenshots, but so far I'm unable to replicate it. I tried several types of shields and various values, but my fighters still don't have shields.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 29, 2013, 11:45:21 PM
D they have a shield generator on their ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 30, 2013, 02:36:29 AM
Yeah I did put it in.....
unless.... I removed it by accident when I was re-workign all the stats. Now I'll have to check.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on April 30, 2013, 04:36:12 AM
It's Happened to me loads of times man dw about it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 30, 2013, 08:26:52 AM
I need to somehow make a projectile move as long as you keep "firing" the weapon, once it stops (!weapon.IsFiring()) the projectile will fade/despawn and spawn several projectiles clockwise (in this case 6 so its 60,120,180,240,300 and 360) around it with a high velocity.

if i do manage to get the first part running ill be able to replicate the Marauder (http://wiki.uqm.stack.nl/Marauder) Spin-blade and the Broodhome (http://wiki.uqm.stack.nl/Broodhome) Crystal Shard

I'd suggest a beam weapon that fires a short-range, invisible, 0-damage, minimal charge up/down time beam, just so that isFiring() behaves the way you'd want it to here. Then you could handle all projectile spawning exclusively via scripts, similarly to how the Tachyon Lance handles adding the EMP arc effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 30, 2013, 12:44:32 PM
WEll, I checked hte shadow order mod and I followed hte logical steps..still n oworky...

What I did:


Added this to the hullmods folder:

Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

import java.util.HashMap;
import java.util.Map;

public class InfusedHull extends BaseHullMod {

public static final float REPAIR_FRACTION = 1f;
public static final float REPAIR_BONUS = .99f;

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 3f);
mag.put(HullSize.FRIGATE, 1f);
mag.put(HullSize.DESTROYER, .75f);
mag.put(HullSize.CRUISER, .5f);
mag.put(HullSize.CAPITAL_SHIP, .25f);
}

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getHullRepairRatePercentPerSecond().modifyFlat(id, (Float) mag.get(hullSize));
stats.getMaxHullRepairFraction().unmodify(id);
stats.getMaxHullRepairFraction().modifyFlat(id, REPAIR_FRACTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "1";// + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return ".75";// + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return ".5";// + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return ".25";// + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}
}



Added this line to hullmods.csv

"Nano-Infused Hull","infusedhull",,0,0,0,0,"data.hullmods.InfusedHull","Repairs %s/%s/%s/%s percent of the ships hull per second."



And this is how my fighter variant looks:
Code
{
"displayName":"Advanced Fighter",
"hullId":"PhnH",
"hullMods": [infusedhull]
"variantId":"PhnH_standard",
"fluxVents":0,
"fluxCapacitors":0,
"mods":[], # array of strings

# mode is either LINKED or ALTERNATING
# slot ids (WS ***) must match what's in the .ship file
"weaponGroups":[
{"mode":"LINKED",
"weapons":{
"WS01":"20mm_rc",
"WS02":"20mm_rc",
   },
},

{"mode":"LINKED",
"weapons":{
"WS03":"stingerx2",
   },
},
],
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 01, 2013, 03:14:38 PM
Anyone know if theres a way to make missiles explode rather than fade away after their flight time expires.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 01, 2013, 05:46:35 PM
Anyone know if theres a way to make missiles explode rather than fade away after their flight time expires.

They won't deal damage when they explode (it's basically the same as if they got shot down), but here's a very simple plugin that should do what you asked:

data/scripts/plugins/MissilesExplodeOnFizzlePlugin.java:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.Iterator;
import java.util.List;

public class MissilesExplodeOnFizzlePlugin implements EveryFrameCombatPlugin
{
    private static CombatEngineAPI engine;

    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }

        // Scan all missiles on the field
        MissileAPI missile;
        for (Iterator missiles = engine.getMissiles().iterator(); missiles.hasNext();)
        {
            missile = (MissileAPI) missiles.next();

            // If the missile is fizzling, damage it so it explodes
            if (missile.isFizzling())
            {
                engine.applyDamage(missile, missile.getLocation(), 99999,
                        DamageType.ENERGY, 0f, true, false, null);
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        MissilesExplodeOnFizzlePlugin.engine = engine;
    }
}

If you want a version that does cause damage to nearby targets when a missile explodes, I can make that for you but it would be far more complicated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 01, 2013, 07:28:28 PM
Anyone know if theres a way to make missiles explode rather than fade away after their flight time expires.

They won't deal damage when they explode (it's basically the same as if they got shot down), but here's a very simple plugin that should do what you asked:

data/scripts/plugins/MissilesExplodeOnFizzlePlugin.java:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.Iterator;
import java.util.List;

public class MissilesExplodeOnFizzlePlugin implements EveryFrameCombatPlugin
{
    private static CombatEngineAPI engine;

    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }

        // Scan all missiles on the field
        MissileAPI missile;
        for (Iterator missiles = engine.getMissiles().iterator(); missiles.hasNext();)
        {
            missile = (MissileAPI) missiles.next();

            // If the missile is fizzling, damage it so it explodes
            if (missile.isFizzling())
            {
                engine.applyDamage(missile, missile.getLocation(), 99999,
                        DamageType.ENERGY, 0f, true, false, null);
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        MissilesExplodeOnFizzlePlugin.engine = engine;
    }
}

If you want a version that does cause damage to nearby targets when a missile explodes, I can make that for you but it would be far more complicated.

Now here's the thing, how would I implement that? Will I have to designate it per missile? Or would it do that for every missile fired? I'm not a programmer by any means.

Also, while the extra damage would be nice, I can make due without it, as the exploding missiles in question are actually used to eat projectiles.

And thanks for your help and time, I honestly do appreciate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 01, 2013, 07:49:26 PM
All you would need to do is place the code in a file named MissilesExplodeOnFizzlePlugin.java in data/scripts/plugins, as Starsector automatically loads any plugin placed in that folder.

It should work for all missiles fired, even vanilla. If you want it to only work for certain missiles, that would be an easy change:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class MissilesExplodeOnFizzlePlugin implements EveryFrameCombatPlugin
{
    private static final Set MISSILES_TO_EXPLODE = new HashSet();
    private static CombatEngineAPI engine;

    static
    {
        // Add the projectile IDs of all missiles that should explode here
        // Example: MISSILES_TO_EXPLODE.add("annihilator_rocket");
        MISSILES_TO_EXPLODE.add("proj id goes here");
        MISSILES_TO_EXPLODE.add("any other missiles go in their own line like this");
    }

    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }

        // Scan all missiles on the field
        MissileAPI missile;
        for (Iterator missiles = engine.getMissiles().iterator(); missiles.hasNext();)
        {
            missile = (MissileAPI) missiles.next();

            // If the missile is fizzling, damage it so it explodes
            if (missile.isFizzling() && MISSILES_TO_EXPLODE.contains(missile.getProjectileSpecId()))
            {
                engine.applyDamage(missile, missile.getLocation(), 99999,
                        DamageType.ENERGY, 0f, true, false, null);
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        MissilesExplodeOnFizzlePlugin.engine = engine;
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 02, 2013, 04:41:35 AM
Silly question:do comments (// texthere ) in .ship and .variant files work?


I would really help with turret groups, especially since I'm working with similar ships with different weapon setups
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 02, 2013, 04:50:50 AM
Silly question:do comments (// texthere ) in .ship and .variant files work?


I would really help with turret groups, especially since I'm working with similar ships with different weapon setups

Yes, except you use # instead of //.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on May 02, 2013, 07:58:58 AM
Oh thanks for the missile script lazy, i had something very close to what u got here for the podship plasmoid, i didnt know about the .isFizzling() existing so i based of with a timer.

Heres an example if you want to "despawn" the old missile and spawn a new one in its place:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.Iterator;
import java.util.List;

public class PodshipHomingPlasmoid implements EveryFrameCombatPlugin
{

    private String SHELL_ID_1 = "podship_plasmoid";
    private String SHELL_ID_2 = "podship_plasmoid_2";
    private String SHELL_ID_3 = "podship_plasmoid_3";
    private String SHELL_ID_4 = "podship_plasmoid_4";
    private CombatEngineAPI engine;
    
    public void init(CombatEngineAPI engine) {
        this.engine = engine;
    }
    
    public void advance(float amount, List events)
    {
        if (engine.isPaused()) {
            return;
        }    

        for (Iterator allMissiles = engine.getMissiles().iterator();
                allMissiles.hasNext();)
        {
            MissileAPI plasmoid = (MissileAPI) allMissiles.next();
                
            if(plasmoid.isFizzling())
            {
                if(SHELL_ID_1.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_2, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_2.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_3, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_3.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_4, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else {
                    return;
                }
            }  
        }
    }//advance
}//class
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 02, 2013, 01:04:19 PM
Lazy you're a gentleman and a scholar. Thank you soo much for your help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 02, 2013, 01:19:10 PM
No problem, glad to help. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 02, 2013, 02:12:43 PM
I'm experiencing the wierdest bug ever.

I made my own faction, addied it to the game (using Ironclad mod) and it's ships (3 fighters, 1 frigate, 2 de's, 1 battleship)

Thing is, the 2 DE's down show up graphics-wise. They are in the System Defene Fleet, but they are invisible. The other ship show up normally.

I checked, double-checked and tripple-checked everything. Cant' find anything wrong or off. When I load the ship file in the editor, it opens the ship image normally.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on May 02, 2013, 02:28:20 PM
Check that the image has been saved with a bit depth greater than 8
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 02, 2013, 03:45:50 PM
Oh thanks for the missile script lazy, i had something very close to what u got here for the podship plasmoid, i didnt know about the .isFizzling() existing so i based of with a timer.

Heres an example if you want to "despawn" the old missile and spawn a new one in its place:
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import java.util.Iterator;
import java.util.List;

public class PodshipHomingPlasmoid implements EveryFrameCombatPlugin
{

    private String SHELL_ID_1 = "podship_plasmoid";
    private String SHELL_ID_2 = "podship_plasmoid_2";
    private String SHELL_ID_3 = "podship_plasmoid_3";
    private String SHELL_ID_4 = "podship_plasmoid_4";
    private CombatEngineAPI engine;
    
    public void init(CombatEngineAPI engine) {
        this.engine = engine;
    }
    
    public void advance(float amount, List events)
    {
        if (engine.isPaused()) {
            return;
        }    

        for (Iterator allMissiles = engine.getMissiles().iterator();
                allMissiles.hasNext();)
        {
            MissileAPI plasmoid = (MissileAPI) allMissiles.next();
                
            if(plasmoid.isFizzling())
            {
                if(SHELL_ID_1.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_2, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_2.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_3, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else if(SHELL_ID_3.equals(plasmoid.getProjectileSpecId())) {
                    engine.spawnProjectile(plasmoid.getSource(), plasmoid.getWeapon(), SHELL_ID_4, plasmoid.getLocation(), plasmoid.getWeapon().getArcFacing(), plasmoid.getVelocity());
                    engine.applyDamage(plasmoid, plasmoid.getLocation(), 99999,DamageType.ENERGY, 0f, true, false, null);
                }
                else {
                    return;
                }
            }  
        }
    }//advance
}//class

Wow, honestly I could use that as well, you guys are amazing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 02, 2013, 11:15:46 PM
Check that the image has been saved with a bit depth greater than 8

I did, that wasn't the problem.
And for some reason the ships started working. Funnily enough, I had to open them in the editor and re-save them. Why did that work?
Your guess is as good as mine....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on May 03, 2013, 12:06:16 AM
No idea mate, it happens to me often, just shrug it off
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Upgradecap on May 03, 2013, 01:53:50 AM
Probably because the editor might've gotten stuck or written to the file incorrectly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on May 04, 2013, 12:50:17 PM
Alrighty, while trying implement a suggestion from strompt I've hit a bit of a brick wall and I'm not entirely certain how to proceed.  Getting the following error:

Code
[Thread-6] ERROR com.fs.starfarer.combat.O0OO  - java.lang.ClassCastException: data.scripts.weapons.WavebeamMaster cannot be cast to com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin
java.lang.ClassCastException: data.scripts.weapons.WavebeamMaster cannot be cast to com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin
at com.fs.starfarer.loading.specs.dosuper.õo0000(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.oooO.<init>(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.while.o00000(Unknown Source)
at com.fs.starfarer.title.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.title.oOOO.String(Unknown Source)
at com.fs.starfarer.title.oOOO.String(Unknown Source)
at com.fs.starfarer.title.oOOO.super(Unknown Source)
at com.fs.starfarer.combat.super.OoOO.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.title.B.o00000(Unknown Source)
at com.fs.starfarer.super.this.do$super(Unknown Source)
at com.fs.A.super.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

From firing this code:

Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.ShipAPI;

public class WavebeamMaster implements EveryFrameWeaponEffectPlugin
{
    private ShipAPI ship;
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        if (engine.isPaused()) {
            return;
        }
       
        {
            if(weapon.isFiring())
            {
                engine.spawnProjectile(ship, weapon, "ms_1wave", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                engine.spawnProjectile(ship, weapon, "ms_2wave", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                engine.spawnProjectile(ship, weapon, "ms_3wave", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
            }
        }
    }
   
}

The error is not entirely clear, and netbeans is giving the script its okay, which is making figuring out what's wrong a bit too tricky for me.  Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on May 04, 2013, 01:05:10 PM
instead of declaring the ship outside the advance declare it inside and then using the weapon, get ur ship object:

ShipAPI ship = weapon.getShip();

Also be very careful how your spawning projectiles using when weapon.IsFiring();
Heres an example of a code, that while its not perfect, it shows how many conditions i had to go tro with just so it only spawned the right projectile at the right time:

Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;

public class TraderVariablePowerBlasterEffect implements BeamEffectPlugin

    // weapon takes 7 seconds to fully charge
    private IntervalUtil weaponcooldownlvl = new IntervalUtil(4.0f, 4.0f);
   
    private static int currentCharge = 0;
   
    private static boolean chargedlvl1 = true;
    private static boolean chargedlvl2 = false;
    private static boolean chargedlvl3 = false;
    private static boolean chargedlvl4 = false;

        public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
        {
            ShipAPI ship = beam.getSource();
            if (ship == null)
            {
                return;
            }
           
            AnimationAPI animation = beam.getWeapon().getAnimation();
            WeaponAPI weapon = beam.getWeapon();

                if(ship.isHulk())
                {
                    animation.setFrame(0);
                    animation.pause();
                }
               
                    //Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());           
                if(weapon.isFiring())
                {
                    weaponcooldownlvl.advance(amount);
                     
                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 1) {
                        chargedlvl2 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 2) {
                        chargedlvl3 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 3) {
                        chargedlvl4 = true;
                    }
                   
                    if(chargedlvl1 && weapon.getCooldownRemaining() == 0)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        //engine.addFloatingText(ship.getLocation(), "Power Level 1",15f,Color.GREEN,weapon.getShip(),0f,0f);
                        chargedlvl1 = false;
                        currentCharge = 1;
                        animation.setFrame(1);
                        animation.play();
                    }
                   
                    if (chargedlvl2)   
                    {
                        chargedlvl2 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 2",20f,Color.BLUE,weapon.getShip(),0f,0f);
                        currentCharge = 2;
                        animation.setFrame(6);
                        animation.play();
                    }
                   
                    if (chargedlvl3)
                    {
                        chargedlvl3 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 3",25f,Color.MAGENTA,weapon.getShip(),0f,0f);
                        currentCharge = 3;
                        animation.setFrame(11);
                        animation.play();
                    }
                   
                    if(chargedlvl4)
                    {
                        chargedlvl4 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Max Power Level",30f,Color.RED,weapon.getShip(),0f,0f);
                        currentCharge = 4;
                        animation.setFrame(16);
                        animation.play();
                    }
                   
                    switch (currentCharge)
                    {
                        case 0:
                        {

                            animation.setFrame(0);
                            animation.pause();
                            break;
                        }
                        case 1:
                        {
                            if(animation.getFrame() == 5)
                            {
                                    animation.setFrame(1);
                                    animation.play();
                            }
                            break;
                        }
                        case 2:
                        {
                            if(animation.getFrame() == 10)
                            {
                                animation.setFrame(6);
                                animation.play();
                            }
                            break;
                        }
                        case 3:
                        {
                            if(animation.getFrame() == 15)
                            {
                                animation.setFrame(11);
                                animation.play();
                            }
                            break;
                        }
                        case 4:
                        {
                            if(animation.getFrame() == 20)
                            {
                                animation.setFrame(16);
                                animation.play();
                            }
                            break;
                        }
                    }
                }
                if(weapon.getChargeLevel() <= 0.1f)
                {
                    switch (currentCharge)
                    {
                        case 1:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s1_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s1", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                        case 2:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s2_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s2", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                        case 3:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s3_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster_s3", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                        case 4:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s4_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                    }       
                }
    }//advance
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 04, 2013, 02:55:13 PM
AAAAAAAAAAAAArgh.....

Code
7921 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Error compiling [data.scripts.world.corvus.Corvus]
java.lang.RuntimeException: Error compiling [data.scripts.world.corvus.Corvus]
at com.fs.starfarer.loading.scripts.ScriptStore$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: Compiling unit "data/scripts/world/corvus/Corvus.java"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:212)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:164)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more
[b]Caused by: org.codehaus.commons.compiler.CompileException: Source file "data/scripts/world/corvus/xleattackSpawnPoint.java" does not declare class "data.scripts.world.corvus.xleattackSpawnPoint"[/b]


WTFUQ?
How the hell does it not contain?


This is the XLEattackSpawnPoint.java
Code
package data.scripts.world.corvus;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

import data.scripts.world.BaseSpawnPoint;

public class XLEattackSpawnPoint extends BaseSpawnPoint {

private final SectorEntityToken station;

public XLEattackSpawnPoint(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor, SectorEntityToken station) {
super(sector, location, daysInterval, maxFleets, anchor);
this.station = station;
}

@Override
protected CampaignFleetAPI spawnFleet() {


String type = null;
float r = (float) Math.random();
if (r > .5f) {
type = "scouts";
} else {type = "armada";}


CampaignFleetAPI fleet = getSector().createFleet("XLE", type);
getLocation().spawnFleet(getAnchor(), 0, 0, fleet);


if (type.equals("scouts")) {
fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 10);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
} else {
fleet.addAssignment(FleetAssignment.ATTACK_LOCATION, station, 50);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
}

return fleet;
}

}


This is in the Corvus.java
Code
				//XLE strike force
XLEattackSpawnPoint xleattackSpawn = new xleattackSpawnPoint(sector, system, 20, 1, RSFStation, VNSStation);
system.addSpawnPoint(xleattackSpawn);
for (int i = 0; i < 2; i++)
xleattackSpawn.spawnFleet();



The XLE have their fleets,, relatiosn are set to hostile...WWWTTTFFF????
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 04, 2013, 03:05:13 PM
@MShadowy: That source file looks good (except for the ship thing), I don't see why you're getting that error. Tried it myself and it works (again, aside from the ship always being null.) I'd make sure that you're actually running the game with the files you think you're running the game with. A quick way to make sure would be to totally mangle that file so it doesn't compile and make sure the game reflects that (i.e., doesn't even start).

@TrashMan: Language, sir. (Filenames and class names are case sensitive in Java.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on May 04, 2013, 06:28:13 PM
Well, I have the code working now, but the shots keep desynching.  Fiddling with the floating values just changes when they desynch, so I'm putting the idea off for now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on May 05, 2013, 01:21:08 PM
Ive made the Trader weapon using the Beam as you have suggested Alex, my problem now is, when it stops firing it should "release" the projectile. it seems that !weapon.IsFiring() doesnt work for this, you know any other method to do this?

Heres my code right now (everything's working fine, that includes the animation since they are running blow 30 frames), while i use the weapon.getChargeLevel() to pick up the beam going down, it also means it will spawn quite a few shots before it actually passes that condition:

Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;

public class TraderVariablePowerBlasterEffect implements BeamEffectPlugin
{  
    // weapon takes 7 seconds to fully charge
    private IntervalUtil weaponcooldownlvl = new IntervalUtil(4.0f, 4.0f);
    
    private static int currentCharge = 0;
    
    private static boolean chargedlvl1 = true;
    private static boolean chargedlvl2 = false;
    private static boolean chargedlvl3 = false;
    private static boolean chargedlvl4 = false;

        public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
        {
            ShipAPI ship = beam.getSource();
            if (ship == null)
            {
                return;
            }
            
            AnimationAPI animation = beam.getWeapon().getAnimation();
            WeaponAPI weapon = beam.getWeapon();

                if(ship.isHulk())
                {
                    animation.setFrame(0);
                    animation.pause();
                }
                
                    //Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());            
                if(weapon.isFiring())
                {
                    weaponcooldownlvl.advance(amount);
                    
                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 1) {
                        chargedlvl2 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 2) {
                        chargedlvl3 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 3) {
                        chargedlvl4 = true;
                    }
                    
                    if(chargedlvl1 && weapon.getCooldownRemaining() == 0)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        //engine.addFloatingText(ship.getLocation(), "Power Level 1",15f,Color.GREEN,weapon.getShip(),0f,0f);
                        chargedlvl1 = false;
                        currentCharge = 1;
                        animation.setFrame(1);
                        animation.play();
                    }
                    
                    if (chargedlvl2)  
                    {
                        chargedlvl2 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 2",20f,Color.BLUE,weapon.getShip(),0f,0f);
                        currentCharge = 2;
                        animation.setFrame(6);
                        animation.play();
                    }
                    
                    if (chargedlvl3)
                    {
                        chargedlvl3 = false;
                        weaponcooldownlvl.setInterval(4.0f, 4.0f);
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 3",25f,Color.MAGENTA,weapon.getShip(),0f,0f);
                        currentCharge = 3;
                        animation.setFrame(11);
                        animation.play();
                    }
                    
                    if(chargedlvl4)
                    {
                        chargedlvl4 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Max Power Level",30f,Color.RED,weapon.getShip(),0f,0f);
                        currentCharge = 4;
                        animation.setFrame(16);
                        animation.play();
                    }
                    
                    switch (currentCharge)
                    {
                        case 0:
                        {

                            animation.setFrame(0);
                            animation.pause();
                            break;
                        }
                        case 1:
                        {
                            if(animation.getFrame() == 5)
                            {
                                    animation.setFrame(1);
                                    animation.play();
                            }
                            break;
                        }
                        case 2:
                        {
                            if(animation.getFrame() == 10)
                            {
                                animation.setFrame(6);
                                animation.play();
                            }
                            break;
                        }
                        case 3:
                        {
                            if(animation.getFrame() == 15)
                            {
                                animation.setFrame(11);
                                animation.play();
                            }
                            break;
                        }
                        case 4:
                        {
                            if(animation.getFrame() == 20)
                            {
                                animation.setFrame(16);
                                animation.play();
                            }
                            break;
                        }
                    }
                }
                if(weapon.getChargeLevel() <= 0.1f)
                {
                    switch (currentCharge)
                    {
                        case 1:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s1_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s1", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                        case 2:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s2_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s2", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                        case 3:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s3_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster_s3", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                        case 4:
                        {
                            Global.getSoundPlayer().playSound("trader_var_blaster_s4_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                            engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                            ship.getFluxTracker().increaseFlux(500, false);
                            weapon.setRemainingCooldownTo(0.5f);
                            animation.setFrame(0);
                            animation.pause();
                            weaponcooldownlvl.setInterval(4.0f, 4.0f);
                            currentCharge = 0;
                            chargedlvl1 = true;
                            chargedlvl2 = false;
                            chargedlvl3 = false;
                            chargedlvl4 = false;
                            return;
                        }
                    }        
                }
    }//advance
}

2nd Question:
Ive got very little experience with movement vectors, and its one of my main problems i got since i need to change the actual ship movement on SS to be like SC2, my main issues are with the Probe, its movement is in the diagonal so up, down, left and right would be 45º, 225º , 315º, 135º. they also dont "reverse" movement, so pressing back would only make them stop and not reverse.
If the Probe movement was actually replicated the Skiff movement would be literally a copy/paste.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on May 10, 2013, 01:41:34 PM
I've got a quick question: is there any way to get the ShipAPI object from a CombatEntityAPI object, assuming the combat entity is an instance of ShipAPI? I've tried quite a few things, and just when I think something should work just fine, I get this when I shoot my beam weapon:



Spoiler
Code
39601 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.VerifyError: (class: data/asc/weapons/mhyp_effect, method: advance signature: (FLcom/fs/starfarer/api/combat/CombatEngineAPI;Lcom/fs/starfarer/api/combat/BeamAPI;)V) Register 7 contains wrong type
java.lang.VerifyError: (class: data/asc/weapons/mhyp_effect, method: advance signature: (FLcom/fs/starfarer/api/combat/CombatEngineAPI;Lcom/fs/starfarer/api/combat/BeamAPI;)V) Register 7 contains wrong type
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.fs.starfarer.loading.scripts.ScriptStore.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.supersuper.ÕÓ0000(Unknown Source)
at com.fs.starfarer.combat.entities.BeamWeaponRay.<init>(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.OOoO.õO0000(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.OOoO.createBeam(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.return.super(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.o0OO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.o0OO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.A.OoOO.return.super(Unknown Source)
at com.fs.starfarer.combat.entities.A.A.OOoO.advance(Unknown Source)
at com.fs.starfarer.combat.systems.WeaponGroup.String(Unknown Source)
at com.fs.starfarer.combat.systems.WeaponGroup.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.super(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.F.ÖÖÒ000(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
[close]


Here's the problematic code in question:


Spoiler
Code
		   ShipAPI ship;
   ShipAPI tmp;
   
   for (Iterator iter = engine.getShips().iterator(); iter.hasNext();) {

tmp = (ShipAPI) iter.next();

if (tmp.getLocation() == target.getLocation()) { //If these two entities are in exact same location, then they're obviously the same ship. Also, target is a CombatEntityAPI object.
ship = tmp;
break;
}

}


//Here's what causes the crash on firing the beam. Technically, none of this should even be ran, as it's only supposed to be ran if the beam is actually hitting a ship. I'm using the same requirements for the tachyon lance's every frame effect.
FluxTrackerAPI flux = ship.getFluxTracker();
flux.forceOverload(2.0f);

[close]


Any help would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 10, 2013, 01:58:04 PM
This looks like a bug with Janino, the error is being thrown because the compiled bytecode it generates is invalid, so it doesn't even get to run.

I've seen this before, too. I think if you make sure to initialize all variables, it'll get around the issue. Alternatively, you could bite the bullet, set up an IDE, and use jar files for your code, sidestepping on-startup compilation via Janino entirely.

Spoiler

         ShipAPI ship;
         ShipAPI tmp;
         
         for (Iterator iter = engine.getShips().iterator(); iter.hasNext();) {
         
         tmp = (ShipAPI) iter.next();
         
            if (tmp.getLocation() == target.getLocation()) { //If these two entities are in exact same location, then they're obviously the same ship. Also, target is a CombatEntityAPI object.
               ship = tmp;
               break;
            }
            
         }
         
         
         //Here's what causes the crash on firing the beam. Technically, none of this should even be ran, as it's only supposed to be ran if the beam is actually hitting a ship. I'm using the same requirements for the tachyon lance's every frame effect.
            FluxTrackerAPI flux = ship.getFluxTracker();
            flux.forceOverload(2.0f);

            
[close]
So, in the above, change it to
ShipAPI ship = null;
ShipAPI tmp = null;
Btw, when you're using == to compare locations, what's happening is you're comparing that the objects (Vector2f for each location) are the same, not that the objects' contents are the same. In this case, that's actually what you want, but using if (tmp == target) would make more "sense".

(Also: code tags in spoliers don't work so well. [pre][/pre] tags seem to work better.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on May 10, 2013, 02:48:14 PM
Huh, that's an odd bug. Your suggestion worked perfectly though; thank you.

Btw, when you're using == to compare locations, what's happening is you're comparing that the objects (Vector2f for each location) are the same, not that the objects' contents are the same. In this case, that's actually what you want, but using if (tmp == target) would make more "sense".
Oh, cool, good to know that works. I was in "Oh god everything is crashing let's not try to do anything that might not work" mode when I was tinkering with this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 10, 2013, 06:34:50 PM
Glad that worked. Barely remembered it from a previous time (searching on the forum turned up nothing, guess it was via PM - a good argument for keeping questions to the forum rather than PMs...)

It was a rather odd one, yeah. Janino has some ... issues. It mostly works, and it's nice for a lower barrier-to-entry for some of the scripting, but I've pretty much entirely moved away from using scripts from new dev because of it, and its lack of support for a few things like generics and anonymous classes. Putting new moddable stuff inside an impl package in starfarer.api.jar, with the source code being available in starfarer.api.zip. (A current example would be the on-hit script for the Tachyon Lance, and other such.)

Oh, cool, good to know that works. I was in "Oh god everything is crashing let's not try to do anything that might not work" mode when I was tinkering with this.

Ah yes, I'm quite familiar with that :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on May 10, 2013, 08:58:09 PM
Sorry, I'm sure I'm asking things I could find my own answers to but the forum has bloated quite a bit over the months I've been on Starsector hiatus.

There are decorative weapons now, yes? How do they work?

Have ships, in general, had any major changes since Ship Systems were introduced?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 10, 2013, 09:03:17 PM
yes, there are decorative weapons now, they're still a little bugged though so I'd recommend not using them until the next patch...

to make one, you can start by looking at the sensor dish in starsector-core/data/weapons. the simplest one to make would be just renaming it and changing the picture, then adding the entry on weapons.csv

I'm not quite sure how to put it on a ship, though, at least by code. The newest version of trylobot sfedit has the decorative weapon slot feature so you can use that


no, I don't think ships have had any major changes since ship systems...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on May 10, 2013, 11:43:43 PM
Thanks, Gunny, I'll hold off on decorative weapons for now. Though, out of curiosity, do any vanilla ships currently use them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 10, 2013, 11:53:28 PM
onslaught, but that was stated as unintentional and will be removed by next version
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on May 11, 2013, 12:56:35 PM
How would one go about adding a crap-ton of new graphics to the debris section? Would I just add them into a mod or is there some code changing needed...?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 11, 2013, 02:50:31 PM
Any chance for a shipsystem that when active, generates Command Points at an incredibly slow rate? I'm looking to make command ships have something to do with tactical commands, rather than just slapping snesor increases on them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on May 11, 2013, 03:20:38 PM
Any chance for a shipsystem that when active, generates Command Points at an incredibly slow rate? I'm looking to make command ships have something to do with tactical commands, rather than just slapping snesor increases on them.
I'd love to see that!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on May 11, 2013, 03:23:09 PM
That'd definitely have to be scripted rather than done with in-game mechanics, but I can't help you any further than that. Neat idea, by the way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pelly on May 13, 2013, 01:50:05 AM
Is there any way to have the campaign character creation questions before picking a portrait picture?

e.g.

"I was a Imperial captain" --> Which would only allow me to use certain portraits depending upon which option I choose

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on May 13, 2013, 10:15:33 AM
Also, is it feasible to change station graphics yet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on May 16, 2013, 06:48:14 PM
Is there an easy and efficient way to modify mutable stats for every ship in combat at once? Essentially, I want the effects of a specific hullmod to be universal on all ships in combat. The best I can think of is having an every-frame combat plugin that cycles through all the ships in play every few seconds, and then applies the modifications to each of them. That, however, seems really stupid to me, and I'm curious if there's a better way.


@Austupaio: You can change station graphics as a whole, but not individually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 16, 2013, 06:58:16 PM
An EveryFrameCombatPlugin would probably be the way to go. If you're worried about efficiency, a simple optimization would be to have it only run when the amount of ships on the field changes.

Code
public class Test implements EveryFrameCombatPlugin
{
    private CombatEngineAPI engine;
    private int numShips = 0;

    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
            return;
        
        List allShips = engine.getShips();
        if (allShips.size() != numShips)
        {
            numShips = allShips.size();
            
            // Number of ships has changed, iterate through and re-apply bonus
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
        numShips=0;
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on May 16, 2013, 07:12:56 PM
Ah, okay. That's too bad... but, with your optimization, using EveryFrameCombatPlugin for this shouldn't feel too stupid. Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on May 17, 2013, 01:17:26 PM
Forgive the double post, but there seems to be an issue with the above solution.


Code
...
public static final float RANGE_BONUS = 150f;
private static final float HEALTH_BONUS = 1100f;
private static final float ENGINE_BONUS = 450f;
...



if (interval.intervalElapsed()) {

List ships = engine.getShips();

if (ships.size() != numShips) {

numShips = ships.size();
ShipAPI ship = null;

for (Iterator iter = ships.iterator(); iter.hasNext();) {

ship = (ShipAPI) iter.next();
if (ship.isHulk()) continue;


MutableShipStatsAPI stats = ship.getMutableStats();
stats.getWeaponHealthBonus().modifyPercent(ship.getFleetMemberId(), HEALTH_BONUS); //Will not apply bonus to ship.
stats.getEngineHealthBonus().modifyPercent(ship.getFleetMemberId(), ENGINE_BONUS); //Will not apply bonus to ship.
//stats.getBallisticWeaponRangeBonus().modifyPercent(ship.getFleetMemberId(), RANGE_BONUS); //Bonus is applied to ship.
//stats.getEnergyWeaponRangeBonus().modifyPercent(ship.getFleetMemberId(), RANGE_BONUS); //Bonus is applied to ship.
//engine.addFloatingText(ship.getLocation(), "!!", 15f, textColor, ship, 2f, 0.2f);
}
}
}

For some reason, the ship's weapon health and engine health will not be modified. The two commented-out lines, however, will apply the proper bonuses to weapon range without a problem. Any reason why this might be happening? The only thing I can think of is that for the hullmod, these bonuses were applied in "applyEffectsBeforeShipCreation", rather than "applyEffectsAfterShipCreation". So maybe these particular health modifications can't actually be applied while in combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2013, 01:28:04 PM
Is there any way to have the campaign character creation questions before picking a portrait picture?

There isn't.

Also, is it feasible to change station graphics yet?

No, not yet.


For some reason, the ship's weapon health and engine health will not be modified. The two commented-out lines, however, will apply the proper bonuses to weapon range without a problem. Any reason why this might be happening? The only thing I can think of is that for the hullmod, these bonuses were applied in "applyEffectsBeforeShipCreation", rather than "applyEffectsAfterShipCreation". So maybe these particular health modifications can't actually be applied while in combat?

Right. That, along with the hull hitpoints, flux capacity, the armor rating, and possibly a few other values, only get used at ship creation. You do, on the other hand, have stats to control the damage taken by weapons etc to work around that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on May 17, 2013, 01:37:23 PM
Right. That, along with the hull hitpoints, flux capacity, the armor rating, and possibly a few other values, only get used at ship creation. You do, on the other hand, have stats to control the damage taken by weapons etc to work around that.
Oh, derp. Totally forgot about all the other methods that could accomplish the same goal...

Thanks for the answer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on May 17, 2013, 03:54:39 PM
How would one go about adding a crap-ton of new graphics to the debris section? Would I just add them into a mod or is there some code changing needed...?

Need to know.

>feel ignored
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2013, 04:02:25 PM
Sorry, missed it :) The debris graphics are in these locations:
graphics/debris/debris_sml0.png
graphics/debris/debris_sml1.png
graphics/debris/debris_sml2.png
graphics/debris/debris_sml3.png
graphics/debris/debris_med0.png
graphics/debris/debris_med1.png
graphics/debris/debris_lrg0.png
graphics/debris/debris_lrg1.png
You can replace them, but can't add new ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on May 17, 2013, 04:30:23 PM
/sadface


They have to referenced somewhere, right? Changing the API would be relatively easy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on May 24, 2013, 11:48:58 PM
I don't think this exists, but I'd love to be wrong: can we get a hook for just after a battle with a reference to the fought fleet (or their name)? For modifying faction relations for example.

If not, has anyone written a tracking script to hack around it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 25, 2013, 12:12:26 AM
I don't think this exists, but I'd love to be wrong: can we get a hook for just after a battle with a reference to the fought fleet (or their name)? For modifying faction relations for example.

If not, has anyone written a tracking script to hack around it?

For player-vs-AI battles, you can use a custom BattleCreationPlugin implementation that broadcasts the fleets passed in. That will let you know what fleet the player is fighting, though obviously only if things get to the battle map stage.

For AI-vs-AI battles, I don't know of a good way to do it in the current version. I think the best you could do is constantly scan all fleets in the system for FP loss, then see if there was a nearby enemy fleet who could be the culprit. Not exactly the most accurate system (and accidents would really throw it off, obviously). :(

It's a moot point, though; the upcoming .6a patch's custom autoresolve plugin (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/impl/campaign/BattleAutoresolverPluginImpl.html) will give us access to all AI-vs-AI battles, leaving just the above solution for player-vs-AI for complete monitoring. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 25, 2013, 10:17:09 PM
Got a question. Is ther any way to make a projectile that doesn't inherit velocity? Or at the very least bring it's velocity down to 0?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on May 26, 2013, 09:03:16 AM
Got a question. Is ther any way to make a projectile that doesn't inherit velocity? Or at the very least bring it's velocity down to 0?

Space Mines?

Maybe by adding a burndrive-like script to the projectile. Basically missiles with some burndrive system, and when it run out, slow down to zero. Dunno if it could work with other weapons though.

I also got a question. Is it possible to make a weapon that ignore armor? Like hitting directly the hull of the enemy ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on May 26, 2013, 09:46:11 AM
I did it for a MIRV weapon, It's in my Battlefarer Forever mod, Dunno whether it's in current release :P

All i did was set the first projectile to have 0 top speed and acceleration, but 400000ish deceleration, with an insane launch speed, The launch speed controls distance :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2013, 11:11:33 AM
Right, a missile with a 0 top speed ought to do it.

I also got a question. Is it possible to make a weapon that ignore armor? Like hitting directly the hull of the enemy ship?

Could do it with an on-hit effect and directly setting the hull value/spawning floaties as appropriate. See the ion cannon .wpn file for more details on an on-hit effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 26, 2013, 11:14:47 AM
I also got a question. Is it possible to make a weapon that ignore armor? Like hitting directly the hull of the enemy ship?

Could do it with an on-hit effect and directly setting the hull value/spawning floaties as appropriate. See the ion cannon .wpn file for more details on an on-hit effect.

We can set the hull level manually? Where is that defined in the API? I feel like an idiot for missing it all this time...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2013, 11:20:53 AM
Erm. Sorry about that; ShipAPI.get/setHitpoints() will actually only be in 0.6a. Thought it was there already, but I was mistaken.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 26, 2013, 01:45:24 PM
Right, a missile with a 0 top speed ought to do it.

It still seems to inherit the speed of the launching ship. I have it sat as a phase_charge missile type because I need to have an AoE effect, I'm not sure if there's a missile type or something like that that doesn't inherit velocity and still enables the proximity fuse effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2013, 02:04:31 PM
If the missile has a non-zero acceleration value, yeah, it'll inherit the speed's velocity, but then it'll gradually stop - more quickly if the acceleration is high.

You could also add an EveryFrameCombatPlugin that checks all the projectiles every frame, and when it sees them for the first time, subtracts the source's velocity from the projectile's. I think that the currently-released API has all the methods to let you do that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on May 26, 2013, 02:09:12 PM
My way did it, but a big problem was that it sticks to the first target it sees, and will not change, regardless of distance
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 26, 2013, 02:19:35 PM
Right, a missile with a 0 top speed ought to do it.

It still seems to inherit the speed of the launching ship. I have it sat as a phase_charge missile type because I need to have an AoE effect, I'm not sure if there's a missile type or something like that that doesn't inherit velocity and still enables the proximity fuse effect.

As Alex said, you could have an EveryFrameCombatPlugin to strip the inertia. Here's some example code that would allow this (not tested!):
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.input.InputEventAPI;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.lwjgl.util.vector.Vector2f;

public class RemoveShipInertia implements EveryFrameCombatPlugin
{
    // This is the ID of the projectile you want to remove imparted inertia from
    private static final String PROJECTILE_ID = "insert projectile ID here";
    // Contains the projectiles that have had their inertia stripped
    private Set done = new HashSet();
    // The engine instance for this battle, used to get all projectiles
    private CombatEngineAPI engine;

    @Override
    public void advance(float amount, List<InputEventAPI> events)
    {
        if (engine.isPaused())
        {
            return;
        }

        // Scan all projectiles on the map each frame
        DamagingProjectileAPI tmp;
        for (Iterator iter = engine.getProjectiles().iterator(); iter.hasNext();)
        {
            tmp = (DamagingProjectileAPI) iter.next();
            // Check if this projectile is the proper type and
            // hasn't had its imparted velocity removed yet
            if (PROJECTILE_ID.equals(tmp.getProjectileSpecId())
                    && tmp.getSource() != null && !done.contains(tmp))
            {
                // Subtract the veloctiy imparted by the firing ship
                Vector2f.sub(tmp.getVelocity(), tmp.getSource().getVelocity(),
                        tmp.getVelocity());
                done.add(tmp);
            }
        }

        // Remove all expired projectiles from the 'finished' list
        for (Iterator iter = done.iterator(); iter.hasNext();)
        {
            if (!engine.isEntityInPlay((CombatEntityAPI) iter.next()))
            {
                iter.remove();
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
        // I'm 99% sure plugins aren't persistent, but just in case...
        done.clear();
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on June 02, 2013, 05:23:40 PM
I haven't had the chance to try that script out until tonight. It works perfectly, literally perfectly. Thanks for your time Lazy, I honestly appreciate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on June 08, 2013, 05:08:16 AM
Quote
AI Hints for weapons, we could use a few more of those. Myself I could very much use the following, or at least a few of them.
BAD_TRACKING: similar to the STRIKE hint for torpedoes, the weapon has a very poor turn rate so watch where you fire it.

HIGH_FLUX: the weapon uses a lot of flux whenever it fires or builds up flux very rapidly, so don't put it on autofire unless you have the flux to spare.

LOW_AMMO(should be AI integrated): The weapon has a very low ammo count or is running out of ammo, so try to make sure every single shot fired connects with the target.

Quote
We could also use a few more SHIP hints, like the following.

SLOW: The ship in question is very slow or does not maneuver very well, so fly it accordingly

HEAVY: The ship in question has a lot of mass to it, so if you have an opportunity to ram your enemy, do it ;D

WEAK: The ships armor or shields are very weak and perhaps does not have a very impressive armament, so this ship is clearly not designed for slugging with other ships, but rather flanking them and letting others ships do the slugging for you, so do exactly that.

STRONG: This ship has very strong armor or shields and powerful weapons, it's clearly designed to be in your face or be slugging against enemies, use it that way.

BALANCED: This ship has moderate of all the above, Use it for whatever job you need it to do.

BROADSIDER: This ships weapons are all mounted on its side(s), try to keep its side(s) facing the enemy.
Quote
Ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on June 08, 2013, 07:51:30 AM
Quote
AI Hints for weapons, we could use a few more of those. Myself I could very much use the following, or at least a few of them.
BAD_TRACKING: similar to the STRIKE hint for torpedoes, the weapon has a very poor turn rate so watch where you fire it.

HIGH_FLUX: the weapon uses a lot of flux whenever it fires or builds up flux very rapidly, so don't put it on autofire unless you have the flux to spare.

LOW_AMMO(should be AI integrated): The weapon has a very low ammo count or is running out of ammo, so try to make sure every single shot fired connects with the target.

Quote
We could also use a few more SHIP hints, like the following.

SLOW: The ship in question is very slow or does not maneuver very well, so fly it accordingly

HEAVY: The ship in question has a lot of mass to it, so if you have an opportunity to ram your enemy, do it ;D

WEAK: The ships armor or shields are very weak and perhaps does not have a very impressive armament, so this ship is clearly not designed for slugging with other ships, but rather flanking them and letting others ships do the slugging for you, so do exactly that.

STRONG: This ship has very strong armor or shields and powerful weapons, it's clearly designed to be in your face or be slugging against enemies, use it that way.

BALANCED: This ship has moderate of all the above, Use it for whatever job you need it to do.

BROADSIDER: This ships weapons are all mounted on its side(s), try to keep its side(s) facing the enemy.
Quote
Ideas?

+1, especially for the broadside.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on June 08, 2013, 07:33:39 PM
Is it possible to make a weapon fire flares, and for the flares to actually work? Always wanted to make a flare turret but was never quite sure where to start/if it was possible.



Also, can missile weapons have recoil sprites? It'd make bay doors way easier if I could just have the door slide off with recoil, rather than animating it.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on June 09, 2013, 05:08:30 PM
Any tips how to create a list of a specific class of ships Mothballed in a station?

To start:

List station_ships = station.getCargo().getMothballedShips().getMembersListCopy(); <-- This gets me a complete list of ships

Then I add this to the mix:

for (int i = 0; i < station_ships.size(); i++) {
                                MemberAPI = (FleetMemberAPI)station_ships.get(i);
                                if  (MemberAPI.isCapital()) {
                                Missing the needed line here to create a list of MemberAPI ships with only Capitals in it.
                                }
                            }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on June 09, 2013, 09:17:14 PM
Any tips how to create a list of a specific class of ships Mothballed in a station?

To start:

List station_ships = station.getCargo().getMothballedShips().getMembersListCopy(); <-- This gets me a complete list of ships

Then I add this to the mix:

for (int i = 0; i < station_ships.size(); i++) {
                                MemberAPI = (FleetMemberAPI)station_ships.get(i);
                                if  (MemberAPI.isCapital()) {
                                Missing the needed line here to create a list of MemberAPI ships with only Capitals in it.
                                }
                            }

You'd need to declare the List of capitals outside the for loop, like this:
Code
List capitalShips = new ArrayList();
Then the line you would use in the for loop would be:
Code
 if  (MemberAPI.isCapital()) capitalShips.add(MemberAPI);


Also, you might want to be careful how you name things. It can be very confusing for other people to read your code if you don't follow standard naming conventions (http://java.about.com/od/javasyntax/a/nameconventions.htm).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on June 10, 2013, 02:51:04 AM
I see your point LW, but I never ever read anything about java and when a document talk me about identifiers I have no idea what is talking about.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on June 10, 2013, 05:07:17 AM
No worries, it was just an idle comment. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on June 12, 2013, 06:14:03 AM
CSV files, how do they work?

That's not the first time it happen to me. When i edit the CSV file and save it, no problem. But when i re-open the file, some numbers aren't in the right columns. So how do i get my CSV files to stay still and not doing weird stuffs whenever i modify them? I tried with OpenOffice and silentstormpt CSV Editor.

Also, what does "8/6/5/4%" means? I read somewhere that this column is unused, yet i see some mods using it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on June 12, 2013, 11:04:16 AM
CSV files, how do they work?

That's not the first time it happen to me. When i edit the CSV file and save it, no problem. But when i re-open the file, some numbers aren't in the right columns. So how do i get my CSV files to stay still and not doing weird stuffs whenever i modify them? I tried with OpenOffice and silentstormpt CSV Editor.

Also, what does "8/6/5/4%" means? I read somewhere that this column is unused, yet i see some mods using it.


i have no clue why your csv wont stay still (sounds weird) but i can answer for the 8/6/5/4 thingy, its only a benchmark on flux dissipation that alex did, it is indeed useless and if you see mods that do use it, its most likely because the mod maker is using that column for the same reason alex initially putted it.

dont worry about it, it really is unused as far as mechanical ship stats goes

answer from : personal experience, i asked that very question months ago when i started modding  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on June 12, 2013, 02:12:54 PM
Another question. Still on the CSV. Especially the weapon CSV.

How do i put number with decimals? Let's say i want the burst delay of my weapon to be 0,5. But when i put a number with a "," the game register it as a zero and the weapon fire extremely fast.  While using the value 1 it work, but is too slow for my taste.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on June 12, 2013, 02:14:49 PM
you put a dot instead of a comma. ,0.5,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on June 12, 2013, 04:27:59 PM
Another question. Still on the CSV. Especially the weapon CSV.

How do i put number with decimals? Let's say i want the burst delay of my weapon to be 0,5. But when i put a number with a "," the game register it as a zero and the weapon fire extremely fast.  While using the value 1 it work, but is too slow for my taste.

Seeing as the CSV is formatted with commas, that would read simply as "0" to the game and the gun would presumably have a fire rate of "2147arblghtoofast"
So do it the normal american way instead of the european way and use a period. I assume you also know how the decimal point works? 0.5 is twice a second, 0.25 is 4 times a second, 0.1 is 10 times a second, yada yada yada.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pelly on June 13, 2013, 12:51:33 PM
Well.....

I have made a Fatal error and have no idea what it is (I have checked the code ect and its correct) The fatal message was:

Fatal: 1
Check  starfarer.log for more info.

Had a look through the logs and could not find anything that was glaringly obvious, this was caused by changing the default text in the settings file to one i made....though when Silent did it in his thread he didn't have any problems....

Heres the Error Log:

 13837 [Thread-8] INFO  com.fs.profiler.Profiler  - ID                     Calls   Duration    Percent
 13837 [Thread-8] INFO  com.fs.profiler.Profiler  - --------------------------------------------------
 13838 [Thread-8] ERROR com.fs.starfarer.combat.String  - java.lang.ArrayIndexOutOfBoundsException: 1
 java.lang.ArrayIndexOutOfBoundsException: 1
   at com.fs.graphics.super.O0OO.o00000(Unknown Source)
   at com.fs.graphics.super.O0OO.o00000(Unknown Source)
   at com.fs.starfarer.loading.H.o00000(Unknown Source)
   at com.fs.super.A.?00000(Unknown Source)
   at com.fs.starfarer.combat.String.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:680)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on June 25, 2013, 12:08:55 PM
Hi folks,

i returned to the Thule Meteor Missile to change the color.

in the .proj file there is always the part about the engineslots:
   
Code
"engineSlots":[{"id":"ES1",
"loc":[-38, 0],
    "style":"TORPEDO_ATROPOS",
    "width":50.0,
    "length":100.0,
    "angle":180.0}]
if i change the style to a customized engine it gets an error. To make things worse i can't find the id "ES1" anywhere.
Anyone a hint for me?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on June 26, 2013, 06:49:04 PM
I have a ship system that basically boosts the systems of the ship for a set amount of time (Shield efficiency, flux dissipation, etc). When I use the ship it works fine, but when I run against it in a simulation it crashes the game. It's currently using the manuvering jets AI. I'm not sure if it has to do with that, or if I can somehow make my own system AI. Anyone have any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 08, 2013, 06:53:13 AM
Where is defined that Guardian PD got multiple beams, their number and position?
I am able to recreate tachyon beam with all its´ effects, but can´t find this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 08, 2013, 09:11:37 AM
@Thule:  The problem there is that you're using an incompatible style, I think.  Build a custom engine style:

Code
	"engineSlots":[
{"id":"ES1",
"loc":[0, 0],
    "style":"CUSTOM",
"styleSpec":{
"engineColor":[100,255,100,255],
"contrailParticleSizeMult":6,
"contrailParticleDuration":2,
"contrailMaxSpeedMult":-0.2,
"contrailAngularVelocityMult":0f,
"contrailColor":[55,255,55,35],
"type":"GLOW" # GLOW or SMOKE
},
    "width":9.0,
    "length":10.0,
    "angle":180.0},
   ]

@Arumac:  You can code a custom System AI that will regulate the System according to your wishes.  See the API documentation for details about how to implement this.

@Ravendarke:  You need to add a line to the wpn, after defining all of your firing points: 

Code
"convergeOnPoint":true,

Bear in mind that the first point must be the one closest to zero on the Y axis; the first firing point is the one used to aim the weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on July 08, 2013, 06:47:54 PM
Xeno thanks for the code, the colorchange worked fine ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on July 08, 2013, 07:43:48 PM

@Arumac:  You can code a custom System AI that will regulate the System according to your wishes.  See the API documentation for details about how to implement this.


Thanks, I'm not really a coder, but I like to fiddle around with things. I never knew there was any kind of actual API documentation on the web. After you mentioned it I started digging and found http://fractalsoftworks.com/starfarer.api/ which I think is what you're talking about.

Thanks again for pointing me in the right direction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 12, 2013, 01:40:20 PM
Looking for script that makes possible beam weapon with charge up time (not that smooth build up that can be done by default, but really charge up with possible frame by frame deco animation as some projectile weapons got).

Just checking if this was done before, if not, I will look into it myself, thx.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on July 13, 2013, 04:27:07 PM
AFAIK, being a weapons expert (albeit kind of rusty), I don't think it's possible.

Although I do remember from the Ironclads mod a weapon that's pretty close to the one you want, called the "Heavy Beamer."  At least, if I remember what it was. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on July 13, 2013, 04:45:17 PM
Looking for script that makes possible beam weapon with charge up time (not that smooth build up that can be done by default, but really charge up with possible frame by frame deco animation as some projectile weapons got).

Just checking if this was done before, if not, I will look into it myself, thx.

Try the Trader ship on the Star Control 2 mod im doing and see if its that what ur searching for
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 15, 2013, 03:39:47 PM
Do you mean variable blaster?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on July 15, 2013, 04:17:33 PM
Do you mean variable blaster?
Yes, while  it shoots projectiles, its actually a beam weapon, it where i based the death ray
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on July 15, 2013, 05:28:20 PM
This part of the code I'm working on gives me a lot of errors.

Spoiler

139116 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.StackOverflowError
java.lang.StackOverflowError
   at java.util.Arrays.mergeSort(Arrays.java:1270)
   at java.util.Arrays.sort(Arrays.java:1210)
   at java.util.Collections.sort(Collections.java:159)
   at com.fs.starfarer.campaign.fleet.FleetData.ÖøÕ000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)

[close]

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

        private void Cycle (CampaignFleetAPI fleet) {   
                float a = (float) Math.random();
                if (a > 0.3)    {
                    fleet.addAssignment(FleetAssignment.PATROL_SYSTEM, null, (int) Math.random()*10 + 5);
                    } else {
                    fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), (int) Math.random()*10 + 5);
                    }   
                Script script = null;
      script = createArrivedScript(fleet, getAnchor());
                fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, getAnchor(), 10, script);
                }
       

   private Script createArrivedScript(final CampaignFleetAPI fleet, final SectorEntityToken station ) {
      return new FleetScript(fleet, station) {
                    public void run() {
                    Cycle(fleet);

...
... various checks on the fleet using many local variables and parameters changing the cargo of the fleet and the fleet composition. ...
...
                }
            };
   }

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

Is there any way I can make it prettier or less prone to crashes? It seems that this things I try to do gets smashed quickly by StackOverflow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 16, 2013, 03:51:54 AM
Do you mean variable blaster?
Yes, while  it shoots projectiles, its actually a beam weapon, it where i based the death ray

It is using "projectile" tag, and therefor it is using charge up for projectile weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on July 16, 2013, 09:48:14 AM
Is is possible to have one .wpn file be the base for different weapons?  For example, I've got "mmm_1.wpn" and I want to make two different versions of it, same sprite, etc. but one has more ammo than the other.  That possible without having to copy the "mmm_1.wpn" twice?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on July 16, 2013, 09:53:49 AM
Why not just have mmm_1_2?
It'd mean greater control if the weapon was built-in for example. You can tweak the built-in and non-built in versions to offset their natures.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on July 16, 2013, 09:55:20 AM
It's not so much tweaking it.  It's that the base weapons for both are exactly the same (aside from the stuff inside the weapons.cvs file), and it'd save me a few headaches when coding into the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 16, 2013, 10:00:00 AM
Spoiler
This part of the code I'm working on gives me a lot of errors.

Spoiler

139116 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.StackOverflowError
java.lang.StackOverflowError
   at java.util.Arrays.mergeSort(Arrays.java:1270)
   at java.util.Arrays.sort(Arrays.java:1210)
   at java.util.Collections.sort(Collections.java:159)
   at com.fs.starfarer.campaign.fleet.FleetData.ÖøÕ000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.getHangarSpace(Unknown Source)

[close]

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

        private void Cycle (CampaignFleetAPI fleet) {   
                float a = (float) Math.random();
                if (a > 0.3)    {
                    fleet.addAssignment(FleetAssignment.PATROL_SYSTEM, null, (int) Math.random()*10 + 5);
                    } else {
                    fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), (int) Math.random()*10 + 5);
                    }   
                Script script = null;
      script = createArrivedScript(fleet, getAnchor());
                fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, getAnchor(), 10, script);
                }
       

   private Script createArrivedScript(final CampaignFleetAPI fleet, final SectorEntityToken station ) {
      return new FleetScript(fleet, station) {
                    public void run() {
                    Cycle(fleet);

...
... various checks on the fleet using many local variables and parameters changing the cargo of the fleet and the fleet composition. ...
...
                }
            };
   }

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

Is there any way I can make it prettier or less prone to crashes? It seems that this things I try to do gets smashed quickly by StackOverflow.
[close]

Changing the fleet composition is what's triggering this. It's a bug in the game, fixed it a little while ago actually.


Is is possible to have one .wpn file be the base for different weapons?  For example, I've got "mmm_1.wpn" and I want to make two different versions of it, same sprite, etc. but one has more ammo than the other.  That possible without having to copy the "mmm_1.wpn" twice?

No.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on July 16, 2013, 12:10:55 PM
Do you mean variable blaster?
Yes, while  it shoots projectiles, its actually a beam weapon, it where i based the death ray

It is using "projectile" tag, and therefor it is using charge up for projectile weapons.

It uses the "advance" and pre-set timers while its "weapon.IsFiring()", once a timer condition is met, the actual animation loop is changed.
The reason im using a beam for this would be because i can keep track of how long its been firing and also i can use the beam brightness to check if it stopped firing.
If you try the ship on a mission you can understand how the code works. Theres a small problem tho, when you release (fire) it still shoots a few extras due to the brightness condition still triggering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 17, 2013, 04:24:35 AM
Do you mean variable blaster?
Yes, while  it shoots projectiles, its actually a beam weapon, it where i based the death ray

It is using "projectile" tag, and therefor it is using charge up for projectile weapons.

It uses the "advance" and pre-set timers while its "weapon.IsFiring()", once a timer condition is met, the actual animation loop is changed.
The reason im using a beam for this would be because i can keep track of how long its been firing and also i can use the beam brightness to check if it stopped firing.
If you try the ship on a mission you can understand how the code works. Theres a small problem tho, when you release (fire) it still shoots a few extras due to the brightness condition still triggering.

I am not sure we are talking about same version, the newest version of star control II, uses 4 weapons to define variable blaster, each of them just energy PROJECTILE with default chargup mechanism for projectile weapons, not using any scripts. (basicly there are 4 different PROJECTILE blasters in one group, with different charge up time, no script etc).

And by the way, is there way how to modify engines other then engine_styles.json ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on July 17, 2013, 03:39:16 PM
Theres 2 Mods of SC2, one made by Trylobot: http://fractalsoftworks.com/forum/index.php?topic=171.0
And a newer one by me: http://fractalsoftworks.com/forum/index.php?topic=3984.0

Im very sure you downloaded Try's mod, thats why its lacking the scripts and weapons
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 17, 2013, 04:26:40 PM
I've got a small question. In my Bushi mod there's a dark matter weapon available, which charges up when you fire it and then releases its projectile.
The problem is: If you rapidly click your fire button, the sounds will overlap eachother, like you're firing a ton of shots, but the weapon only has 1 ammunition. Ofcourse it only fires once.

Is there a way to stop the charge-up sound from playing if you're out of ammo? Or some other way to only have the sound play once?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on July 17, 2013, 04:59:03 PM
I'd like to know as well, so that I can go off and fix every weapon that has this issue. IFed Mass Drivers, IFed Hadrons, Thule Barbarossas, Hiigaran Singularity Cannons, to name a few.

So long as the trigger is held, the weapon will continue to fire. In the case of the Hadron, it's caused me to take quite significant damage due to being under the impression that the Hadron Accelerator is not in use as I haven't recently heard the long and distinct charge up.

Preferably, there should be an option to force the charge-up sound effect every time the weapon has the ability to fire. I say option because otherwise weapons like vanilla Thumpers would produce ghastly sounds as they whir up and simultaneously fire several times a second.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on July 18, 2013, 12:09:54 AM
I've noticed this as well and it's became a really bother for me in the past.

I'd say that there is no solution from my experience, but perhaps some bright minds know better :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on July 18, 2013, 01:05:28 AM
MWahahah I'll dig up old relevant quotes,

It's probably not a good idea to have the whole burst in the same sound file - consider what would happen if the ship overloaded / started venting / ran out of flux / etc mid-burst. Also consider that hull mods can change the rate of fire for a weapon.

That said, it shouldn't be playing the pre-burst sound if the weapon is on cooldown or can't fire for any other reason - I'll take a look.

The charge up/fireSoundOne is still imo a little wonky, it can play on chargedown/cooldown, empty ammo, while firing.

It something weird, all I know is that some of the problem comes from releasing the trigger before it fires, but having the weapon still play the sound,
It's fine if it charges up all the way fully (without releasing the trigger), but if you start clicking like mad, it just doesn't work well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 18, 2013, 03:31:43 AM
That's a bummer.  :-\ I'll hope for a fix in the next update then. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on July 18, 2013, 04:46:18 AM

And by the way, is there way how to modify engines other then engine_styles.json ?

Like this:

Code
      "style": "CUSTOM",
      "styleSpec": {
        "type": "GLOW",
        "engineColor": [
          68,
          250,
          50,
          255
        ],
        "contrailColor": [
          68,
          250,
          50,
          80
        ],
        "contrailParticleSizeMult": 1.0,
        "contrailParticleDuration": 0.25,
        "contrailMaxSpeedMult": 0.075,
        "contrailAngularVelocityMult": 0.0
      },
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 18, 2013, 06:32:37 AM

And by the way, is there way how to modify engines other then engine_styles.json ?

Like this:

Code
      "style": "CUSTOM",
      "styleSpec": {
        "type": "GLOW",
        "engineColor": [
          68,
          250,
          50,
          255
        ],
        "contrailColor": [
          68,
          250,
          50,
          80
        ],
        "contrailParticleSizeMult": 1.0,
        "contrailParticleDuration": 0.25,
        "contrailMaxSpeedMult": 0.075,
        "contrailAngularVelocityMult": 0.0
      },

Yep I know about this, I mean other properties, like texture etc, or if this ("engine_styles.json") is all we can redefine for engines.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 18, 2013, 06:50:24 AM
I think engine editing is fairly limited now, but I think I read somewhere that engines and shields will be able to custimized more in the upcoming version.
Please correct me if I'm wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 21, 2013, 06:05:36 PM
Hello,

This script makes a decorative weapon turn 360 degrees and joy, it sure works. (Code is taken from Ironclads. Hope you don't mind!)
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.ShipAPI;

public class BushiVentilatorRotationEffect implements EveryFrameWeaponEffectPlugin {

private float currDir = Math.signum((float) Math.random() - 0.5f);

public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
if (engine.isPaused()) return;
if (weapon.getShip().isHulk()) return;

float curr = weapon.getCurrAngle();
curr += currDir * amount * 100f;
float arc = weapon.getArc();

weapon.setCurrAngle(curr);
}

public static float normalizeAngle(float angleDeg) {
return (angleDeg % 360f + 360f) % 360f;
}
}

Unfortunately there's magic in it which makes the object turn left or right at a random chance, and I'd like it to only go left.
Does anyone know what magic to remove or adjust in order to get the decoration go left?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on July 22, 2013, 01:17:08 AM
Gotcha!:

The variable currDir is responsible for direction, and is randomly set to 1 or -1 near the top. If you want to rotate counterclockwise, change it to always be 1f. For clockwise, it'd be -1f.

If you want to change the rotation speed, you would change the amount * 100f to amount * <degrees per second>.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 22, 2013, 04:47:04 AM
Thanks! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 22, 2013, 03:56:03 PM
I should probably try it before I ask, but still: Is it possible to make PD that will target even incoming projectiles? I know it is possible to set pierce set to actually hit projectile, but I need PD to actively target them.

I would also like to ask if there is a way how to make hull mods and weapons unusable by player in mission. I mean different way them make everything inbuilt.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on July 22, 2013, 04:42:55 PM
1 is not possible afaik

2 can be done, if nothing else you can make something cost like 1000 OP and give them to the AI via variant editing. But depending on what exactly you're trying to do I might be able to suggest a more elegant solution
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flare on July 22, 2013, 07:03:32 PM
I'm making a general hullmod, and one issue that came up was the IDs and the names.

In hullmods.csv There's a column for "names", "id", and "script".

In the individual hullmods files like heavy armor, there's only one term that references the terms in hullmods.csv and that is:

Code
public class HeavyArmor

Lets say that I'm adding a range of armor hullmods, and am working with one file right now.

What references "HeavyArmor"? Is it "names" or "id"? I know "script" pretty much already points to the file the csv file needs to look at, so what are the other two? Is "id" for heavy armor in public class heavy armor in the hullmod file, and name is what shows up in game? Isn't the "id" redundant since the csv file already points to the hullmod file in question?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on July 22, 2013, 11:10:50 PM
I would also like to ask if there is a way how to make hull mods and weapons unusable by player in mission. I mean different way them make everything inbuilt.

Look up my mod, the R.U.N.E hull mod was coded by Lazywizard in a way that only ships with the hull id prefix "thule_xxx" can use it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 23, 2013, 12:58:06 AM
I would also like to ask if there is a way how to make hull mods and weapons unusable by player in mission. I mean different way them make everything inbuilt.

Look up my mod, the R.U.N.E hull mod was coded by Lazywizard in a way that only ships with the hull id prefix "thule_xxx" can use it.

Great, thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 23, 2013, 01:19:58 AM
The other way to approach that is to simply code up a Plugin that regulates any player-only features specifically for them and only if played by the AI.  Then it's a silent buff that players can't have and won't see.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on July 23, 2013, 06:10:48 AM
I'm making a general hullmod, and one issue that came up was the IDs and the names.

In hullmods.csv There's a column for "names", "id", and "script".

In the individual hullmods files like heavy armor, there's only one term that references the terms in hullmods.csv and that is:

Code
public class HeavyArmor

Lets say that I'm adding a range of armor hullmods, and am working with one file right now.

What references "HeavyArmor"? Is it "names" or "id"? I know "script" pretty much already points to the file the csv file needs to look at, so what are the other two? Is "id" for heavy armor in public class heavy armor in the hullmod file, and name is what shows up in game? Isn't the "id" redundant since the csv file already points to the hullmod file in question?


None of the three need to be the same (look at Insulated Engine Assembly).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 24, 2013, 06:42:21 AM
Did I miss something or there isn´t way how to repair armor during battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 24, 2013, 07:29:23 AM
There is no method to repair Armor during battle at this time.

However, you can repair Hull and make it act almost identically to regenerating Armor in terms of effects on damage.  That gets a little complicated, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 24, 2013, 10:13:11 AM
Yeah, thx. I wished for armor regeneration, due to psychological effect: Damaged armor can be seen on the ship, it´s like.. "yeaaah, I´ve finally get through shields, I will finish it sooner or later"... but when ship could, even by graphic effect, repair itself to state when it is "like a new" it should couse: "Oh my god, what is this think".

Anyway thank you for answer :)

Let´s continue in my spam of questions: I know this isn´t probably possible, but maybe someone will have workaround
I would like to make mission where player will pilot only one ship. There should be two fleets, one allied (or neutral) to player, second hostile to all. I know I can make that the player has flagship that he can´t leave (transfer command), but I don´t want him to be able to command other ships... hmm thinking about it, maybe some way how to limit command points to 1?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 24, 2013, 11:23:04 AM
Command points are set via the mission's code.  So just remove all the CP. 

It won't make the "friendly" fleet behave very intelligently, though- they'll be on default Search 'n Destroy orders; to achieve that goal you'll have to set their AIs during the initial phase via a plugin and occasionally give them new orders.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 24, 2013, 12:04:19 PM
That will be fine, it suppose to be slaughter anyway :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 24, 2013, 12:19:20 PM
Bear in mind that all their losses will count against the player when the score's tabulated, though  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 25, 2013, 02:00:01 PM
Yeah, that doesn´t matter, it suppose to be really impossible mission, just a part of story telling. So no score above 0% expected.

Question about pierce sets: I tried few combinations, created ship piercing beam and such, but I didn´t manage to create beam weapon that actually collide and destroy projectiles (tho they have hitpoints), ideas?

Btw is there some mod using plugins to setup missions? (So I could get some inspiration and see what is possible)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 25, 2013, 07:48:40 PM
LazyWizard provided an example and I've written one that does a pretty explicit job of creating a specific environment (I created a bunch of "space junk" as part of the mission). 

There are some minor hangups I've been having, primarily having to do with assigning things to neutral parties (for 3-way missions and other tasks) but it's very flexible, only major limitations on mission structures are time and coding skill.  You could make a simple RPG mission with FedEx questing and the like, even.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on July 27, 2013, 06:46:05 PM
Is there a way to reproduce the explosion effect form a large ship (screen whiteout) with a missile? Also, for the same missile, how do I get large AoE EMP damage?

If you can't tell I'm trying to make realistic-ish nukes >.>
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on July 28, 2013, 10:45:46 AM
I got a problem with my first weapon ever. I got the sprite in the game with no errors, but it doesn't fire when you use LMB. It has its own projectile file, .wpn and graphics for both of the above. The only thing it doesn't have is a custom sound file. (I just took the vanilla sound config and put it in my mod for now). It uses the light_needler_gun sound. Is ther any reason why it won't fire? I'm really excited for my mod!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 28, 2013, 10:54:09 AM
Can you post your weapon_data.csv and your .weapon file?

Edit: I too have a desire for help.

I'm making two mini factions, and the game starts fine when these are enabled. But the Nexus fleets do not seem to attack enemies and vice versa. When another fleet meets with a Nexus fleet, they just stack on top of eachother like two mating flies. What gives? O_o

Download: Nexus (http://avatar.home.xs4all.nl/crap/Nexus_v001.rar)

Two screenshots, Tritachyon and Nexus just sitting there, nothing happening:
Spoiler
(http://avatar.home.xs4all.nl/crap/screenshot011.png)
(http://avatar.home.xs4all.nl/crap/screenshot012.png)
[close]


And the Free Miners Guild fleets simply won't appear. *scratches head*
They should appear in the same manner as independent fleets, that was my goal.

Download: Free Miners Guild (http://avatar.home.xs4all.nl/crap/FreeMinersGuild_v001.rar)

Can someone help me out please? :-X
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on July 28, 2013, 05:39:24 PM
http://www.mediafire.com/download/owv7bl7794py26p/Citadel_Defenders_0.5pre.zip (http://www.mediafire.com/download/owv7bl7794py26p/Citadel_Defenders_0.5pre.zip)

Alright, here is the link to download my pre-release. The weapon is called fox_lightacel. By the way, the sounds are the sounds of the needler, so I just renamed the needler shots and changed their addresses in the sound config file. Thanks!

Also, how do you get only one station defense fleet to spawn? Do you just create another spawn point that only spawns defense fleets with one max fleet, or what?


Oh yeah, another question. When do the convoys spawn? I don't know how to get them to spawn. It doesn't create and error, so I assume its ok.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on July 28, 2013, 06:04:16 PM
Can you post your weapon_data.csv and your .weapon file?

Edit: I too have a desire for help.

I'm making two mini factions, and the game starts fine when these are enabled. But the Nexus fleets do not seem to attack enemies and vice versa. When another fleet meets with a Nexus fleet, they just stack on top of eachother like two mating flies. What gives? O_o

Download: Nexus (http://avatar.home.xs4all.nl/crap/Nexus_v001.rar)

Two screenshots, Tritachyon and Nexus just sitting there, nothing happening:
Spoiler
(http://avatar.home.xs4all.nl/crap/screenshot011.png)
(http://avatar.home.xs4all.nl/crap/screenshot012.png)
[close]


And the Free Miners Guild fleets simply won't appear. *scratches head*
They should appear in the same manner as independent fleets, that was my goal.

Download: Free Miners Guild (http://avatar.home.xs4all.nl/crap/FreeMinersGuild_v001.rar)

Can someone help me out please? :-X

Did you make sure nexus and the Tritachyons are actually hostile to each other?

http://www.mediafire.com/download/owv7bl7794py26p/Citadel_Defenders_0.5pre.zip (http://www.mediafire.com/download/owv7bl7794py26p/Citadel_Defenders_0.5pre.zip)

Alright, here is the link to download my pre-release. The weapon is called fox_lightacel. By the way, the sounds are the sounds of the needler, so I just renamed the needler shots and changed their addresses in the sound config file. Thanks!

Also, how do you get only one station defense fleet to spawn? Do you just create another spawn point that only spawns defense fleets with one max fleet, or what?


Oh yeah, another question. When do the convoys spawn? I don't know how to get them to spawn. It doesn't create and error, so I assume its ok.

When you create the spawn point higher up in the file, there's an argument that sets how many fleets it can create maximum - I believe it's the fourth argument. Set that to zero; this means the spawn point only works when you call it manually. Then later in the gen file, call YourNameHerespawn.spawnFleet();

Example:
Code
	HegemonyPatrolSpawnPoint patrolSpawn = new HegemonyPatrolSpawnPoint(sector, system, 10, 0, hegemonyStation);
system.addSpawnPoint(patrolSpawn);
patrolSpawn.spawnFleet();

Anyone know how to slow down a ship to it's current max top speed while the ship system is active?

Think a maneuvering jets but slows you down to the current maximum speed ( of 0 units ).

I know the Burn drive slows you down at the end of it's use but does it work for active use?

Code
	public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
if (state == ShipSystemStatsScript.State.OUT) {
stats.getMaxSpeed().unmodify(id);
} else {
stats.getMaxSpeed().modifyFlat(id, 200f * effectLevel);
stats.getAcceleration().modifyFlat(id, 200f * effectLevel);
}
}

Into:

Code
	public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
if (state == ShipSystemStatsScript.State.OUT) {
stats.getMaxSpeed().modifyFlat(id, 100f * effectLevel);
stats.getAcceleration().modifyFlat(id, 100f * effectLevel);
} else {
stats.getMaxSpeed().unmodify(id);
}
}

Lol idk.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on July 28, 2013, 06:09:23 PM
Thanks!
I'm still having trouble with my light ACEL weapon though. Any help on that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on July 28, 2013, 06:18:30 PM
Not sure what the problem is with your gun, it works fine for me,

Spoiler
(http://i.imgur.com/U843CQE.png)
[close]

Though my only concern is that they use a lot of flux to fire, are you sure the ship you mount them on has enough flux for them to fire?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 28, 2013, 06:21:19 PM
@Foxer360: It works for me. BUT. I think the ship you're using might not have enough flux to fire it, since it uses an insane amount of flux.
You make it burstfire 25 rounds and each shot will use 55 energy. That's 55x25=1375 flux with one burst.
Edit: Ninja'd by FlashFrozen.

@FlashFrozen: Yes, they're enemies. I included two screenshots too. It's very weird. I don't understand it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on July 28, 2013, 06:23:45 PM
Whoops. I think I went a bit overboard on the flux. I mounted my ACEL on the hound, but it didn't have enough capacity to fire.
XD Oh yeah, and the Zenta you used doesn't drain soft flux with its shields up ATM.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on July 28, 2013, 06:39:54 PM
@FlashFrozen: Yes, they're enemies. I included two screenshots too. It's very weird. I don't understand it.

Check the StarSector log; sometimes the game will throw an exception that is caught, and it should appear in the log. IIRC I had a similar problem once and exceptions were appearing in the log but StarSector carried on merrily :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 28, 2013, 07:22:43 PM
Quote
Is there a way to reproduce the explosion effect form a large ship (screen whiteout) with a missile?
Largish numbers of really huge glow particles in the AOE definition of the projectile.

Quote
Also, for the same missile, how do I get large AoE EMP damage?
EMP is handled just like regular damage.  If it has 20K EMP damage, everything in the AOE that is able to collide is going to take 20K EMP.

Quote
Anyone know how to slow down a ship to it's current max top speed while the ship system is active?
Just do Burn Drive's script in reverse, but that will not change current velocity.  If you want to change current velocity when it's active, you need to have it alter the velocity component of the Entity over time (like, just multiply the XY by 0.99f or whatever).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vinya on July 28, 2013, 11:07:54 PM
Also how is AoE determined with weapons?

>.>
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on July 29, 2013, 05:09:12 AM
AoE is determined in the .proj file for it.  As far as I know, only missiles weapons can actually have that setting, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 29, 2013, 05:29:09 AM
Check the StarSector log; sometimes the game will throw an exception that is caught, and it should appear in the log. IIRC I had a similar problem once and exceptions were appearing in the log but StarSector carried on merrily :)

Nothing in the log as well. Go figure.
I am going to create two separate threads for both my issues.

Edit: It suddenly struck me! Gawd, what an idiot I am. I solved the Nexus issue.
They do initiate a fight with the player and after I let my second in command handle the fight (which I tried 2 seconds ago) the enemy all fled! Then this old light bulb began to burn above my head.
Problem is: They have no crew! They're an AI, and only AI. No robots or whatever. So I gave the ships no crew. This generates a huuuge side effect apparently.
Cripes. Hopefully future versions will allow fleets to have no crew or have no option to be conquered.

Edit2: No, scrap all that. Problem still persists. -_-
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 29, 2013, 08:52:14 AM
They must have Crew, Supplies and Fuel, and be hostile.  Start a new game after fixing the no-crew problem and re-try. Other than that... should work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 29, 2013, 10:37:21 AM
I always start a new game after fixing something, to be on the safe side. No luck though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on July 29, 2013, 10:56:25 AM
Ok, I have some free timelater on. I'll get back to you, 4 hours at most.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 29, 2013, 11:36:12 AM
civilian tag by any chance? :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on July 29, 2013, 02:30:54 PM
I think there is a civilian tag, in the ship.cvs in the "HINTS" area.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 29, 2013, 02:57:12 PM
I know, it was just suggestion for Gotcha!... if by any chance he doesn´t set civilian tag for those ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 29, 2013, 03:05:00 PM
I might not be the brightest lightbulb in the christmas tree, but give me SOME credit at least. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 29, 2013, 04:36:20 PM
I am sorry, I have meant no offense, it just could happen while testing something.. it was just idea.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 29, 2013, 05:44:39 PM
Don't worry, I took no offense. I was just kidding with you. ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lightfeather on July 29, 2013, 06:15:16 PM
Hey guys, new to the forums here (although I've stalked it for some time). I had a question about fleet points; I started a new game a couple weeks ago with Exerelin installed (great mod, btw), and I've since reached about as far as I can go with fleet points before risking accidents that make my fleet un-usable. I've tried editing my save to increase my fleet points, the only problem is I load my save and my cap hasn't changed! ??? I'm 95% sure I found the correct Fleet Point value, so any help would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on July 29, 2013, 06:26:06 PM
My fighter squadrons are broked! Oh noes! Can anyone tell me what's wrong?

FoxLWing and FoxGunship are the in-game ID's

http://www.mediafire.com/download/dg8htdrm0x0238r/Citadel_Defenders_0.6pre.zip (http://www.mediafire.com/download/dg8htdrm0x0238r/Citadel_Defenders_0.6pre.zip)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on July 29, 2013, 06:33:21 PM
Anyone know anything about on hit effects for missiles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on July 29, 2013, 06:38:25 PM
Anyone know anything about on hit effects for missiles?

I do believe it is mentioned in 0.60a patch notes... so.. later :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 29, 2013, 06:41:46 PM
@Foxer360: What's broken about them?
I can't add them through the console. Console seems to be ensisting on adding _wing after FoxLWing when I try to add it. (FoxLWing_wing, which ofcourse does not exist.)

Edit: When I add the ships with the addship command and fly in them they seem to work just fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on July 29, 2013, 06:44:54 PM
Anyone know anything about on hit effects for missiles?

I do believe it is mentioned in 0.60a patch notes... so.. later :)

Aha, I haven't read the patchnotes in awhile.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on July 29, 2013, 06:48:46 PM
You aren't supposed to fly them! Is the fox wing an actual fighter wing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 30, 2013, 03:27:55 AM
I guess so, you made them a fighter wing, right? /confused
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on July 31, 2013, 02:48:18 PM
Is there a way to really limit a missile's range? I've created some sort of energy missile (in appearance) and want to have it a range of 800-1000, but it flies really far. Even when setting the range to 0 in weapons.csv it still goes off screen. (Probably because missiles still travel after their engines go out, even though mine doesn't have one.)

Has anyone found a workaround for this?


Edit: Gawd, I am such a tard sometimes. The flight time field was empty. x)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flare on July 31, 2013, 08:49:19 PM
Might want to change the range back up from 0 when you're done. The AI uses that variable when deciding when they should shoot the enemy. On other weapons it might not be all that out of place, but I'm sure you know missiles' flight time and the range are separate values.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on July 31, 2013, 09:40:37 PM
Since the reverse burn drive thing I tried didn't work, on to the next one :D


0.54.1a

Modding:
Beam and burst beam weapons can now be animated (but the glow sprite can not, must remain the same for all frames)

Well I tried to make an animated weapon, but the animation part of it doesn't work >>"

Apology for not being able to take consecutive screenshots, Starsector crashes after just one screenshot, So this is how it looks,

Spoiler
(http://i.imgur.com/uyALNOK.png)

(http://i.imgur.com/2wpy2xT.jpg)
[close]

It shows only the first frame, once you fire, the weapon disappears, and the reappears after what probably means it cycled through all the frames.

Code
{
"id":"neutrino_phasedarray2",
"specClass":"beam",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":1100,
"turretSprite":"graphics/neut/weapons/phasedarray/neutrino_phasedarray_base00.png",
"hardpointSprite":"graphics/neut/weapons/phasedarray/neutrino_phasedarray_base00.png",
"numFrames":16,
"frameRate":30,
"turretOffsets":[-80, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[-80, 0],
"hardpointAngleOffsets":[0],
"fringeColor":[212,60,25,255],
"coreColor":[255,255,255,255],
#"glowColor":[212,60,25,235],
"darkCore":false,
"width":50.0,
"textureType":ROUGH,
#"textureType":["graphics/fx/emp_arcs.png","graphics/fx/emp_arcs.png"],
"textureScrollSpeed":292.0,
"pixelsPerTexel":5.0,
"pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF,FIGHTER],
"fireSoundOne":"neutrino_heavybeam_firing",
"fireSoundTwo":"beam_heavy_loop",
}

Am I missing something  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 31, 2013, 10:23:44 PM
It's type ENERGY; pretty sure it has to be type BALLISTIC.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on July 31, 2013, 10:29:10 PM
It's type ENERGY; pretty sure it has to be type BALLISTIC.

Tried that, it still produces the same result lol.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on August 02, 2013, 05:47:31 AM
Missiles can accelerate after being fired. I wonder, is this also possible for ballistic projectiles? If so, does anyone know a weapon that uses this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: phyrex on August 02, 2013, 08:15:42 AM
Missiles can accelerate after being fired. I wonder, is this also possible for ballistic projectiles? If so, does anyone know a weapon that uses this?

i think it isint possible. its because missiles are objects with theire own propulsion, so they have a "flying" speed and a "launched" speed.

but im not lazywizard either so im not sure :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 02, 2013, 09:22:06 AM
You can by setting its velocity in a script, just grab a interval timer and once it ends you can set a new velocity to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on August 04, 2013, 04:53:01 PM
Anyone know of a way to make an invisible beam? I'm pretty sure I can't get it via the RGBA values :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 04, 2013, 04:55:30 PM
Set it like

0,0,0,255
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on August 04, 2013, 05:48:38 PM
Set it like

0,0,0,255

Wouldn't that just make it black?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on August 04, 2013, 05:51:53 PM
Set it like

0,0,0,255

Wouldn't that just make it black?
Yes, it would--make sure the last of the four numbers is 0 (it's the alpha channel). So, 0,0,0,0. Though the first 3 numbers don't actually matter. Though actually, 0,0,0,255 might work if the beams are only additive.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 04, 2013, 06:16:42 PM
Sorry, it's either 0,0,0,0 or 0,0,0,255
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on August 05, 2013, 04:42:35 PM
Another question. I have a system I want to make, were it will instantly vent a set amount of flux and play an animation. I think I can do that part. However I need a second part were there's a percent chance to damage and overload the ship instead. Basically the ship is an unstable prototype generator with the bare minimum ship parts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on August 07, 2013, 05:43:09 AM
Got a custom beam weapon, seems like
"   "textureType":["graphics/BR/missiles/plasmaray.png","graphics/BR/missiles/plasmaray2.png"],"
is valid and used by the game, the question is which texture is used and why? Is one for the core of the beam and one for the edge?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 07, 2013, 08:13:51 AM
Got a custom beam weapon, seems like
"   "textureType":["graphics/BR/missiles/plasmaray.png","graphics/BR/missiles/plasmaray2.png"],"
is valid and used by the game, the question is which texture is used and why? Is one for the core of the beam and one for the edge?

Exactly, one for core, one for fringe.... second one should be core btw.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on August 07, 2013, 08:52:39 AM
Awesome, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ThePinkPanzer on August 09, 2013, 01:42:04 AM
Can anyone point me towards a custom weapons tutorial? The wiki has nothing and I can not find one for the life of me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on August 09, 2013, 08:01:01 AM
Search up Psyion on youtube. He should have a tutorial for ya'!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 09, 2013, 09:10:25 AM
I'd make one, but can't get fraps to work to record desktop
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ThePinkPanzer on August 09, 2013, 10:48:58 AM
Search up Psyion on youtube. He should have a tutorial for ya'!
Righto, goof stuff. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on August 10, 2013, 09:50:57 AM
(http://i.imgur.com/8xGw2vK.jpg)
I have a few theories myself but don't have time to check right now, what is it that causes the glow to be offcenter from the actual projectile sprite like this? Do I need to add a center value like on a missile? The sprite is square.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2013, 11:24:10 AM
That's just where the engine renders the glow, at the "real" location of the projectile, which is right on the edge between the bullet and the tail. Which is definitely problematic in some cases, I've got to take another look at it.

Don't want to just blanketly change it to be the middle of the bullet, though, as that tends to completely overwhelm the bullet sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on August 11, 2013, 11:42:51 AM
Well, ideally it would be great to have another field to input the offset of the glow from the center of the sprite or something.

A different question, what would be the most practical way to add an effect similar to a 360 muzzle flash to an OnHitEffect? Tons of particles with random vectors? Seems like a bit of a roundabout way to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 11, 2013, 11:44:18 AM
Glow offset would be great.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2013, 11:57:36 AM
A different question, what would be the most practical way to add an effect similar to a 360 muzzle flash to an OnHitEffect? Tons of particles with random vectors? Seems like a bit of a roundabout way to do it.

CombatEngineAPI.addSmoothParticle(), yeah. That's how regular muzzle flash works, the MUZZLE_FLASH spec contents are just parameters to the code that spews them out, nothing more special than that.


Well, ideally it would be great to have another field to input the offset of the glow from the center of the sprite or something.
Glow offset would be great.

Right, that sounds sensible. Added to the (rather long) list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on August 11, 2013, 12:06:56 PM
You da man, Alex. Would it be possible to see the muzzle flash spec blown up into code, just for the sake of learning?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2013, 12:21:00 PM
It just uses polar coordinates to spawn stuff in an arc.

Spoiler

for (int i = 0; i < numParticles; i++) {
   float size = range * (float) Math.random() + min;
   float theta = (float) (Math.random() * Math.toRadians(spread) + Math.toRadians(angle - spread/2f));
   float r = (float) (Math.random() * length);
   float x = (float)Math.cos(theta) * r;
   float y = (float)Math.sin(theta) * r;
   Vector2f pos = new Vector2f(point.x + x, point.y + y);
   Vector2f vel = new Vector2f(x + shipVel.x, y + shipVel.y);
   // add particle here, using size/pos/vel
}
"point" is where the flash starts. Also note that it's using the offset from the point as the velocity, too; there's no reason it *has* to be that way, just happens to work fairly well.
[close]

Edit: I should say, there are definitely other ways to approach generating a muzzle flash. This one is pretty simplistic, but generally seems good enough.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on August 12, 2013, 01:32:12 AM
Does anyone know how to check if a mod is installed, and if so which version?

Currently I am checking if a mod is installed like this (example):
Code
try
{
Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.HiigaraGen");
return true;
}
catch (ClassNotFoundException ex)
{
return false;
}

which works well, but doesn't get me the version of the mod. Anyone have any ideas? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JosephPierce on August 12, 2013, 10:45:27 AM
ah, i see, okay i guess there is the problem. the frames are numbered in three digits and the number is not at the end of the filename.

What i did:
I took okims mod "ironclad" and tried to mimic his landing led light (http://www.niceledlights.com).

The following files are involved:

D:\Program Files (x86)\Fractal Softworks\Starsector\mods\Thule Legacy\data\scripts\plugins\isHulkCheck.java
Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.FluxTrackerAPI;

public class isHulkCheck implements EveryFrameWeaponEffectPlugin
{

 public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
  {
   if (engine.isPaused()) return;

   AnimationAPI animation = weapon.getAnimation();
 
   if (weapon.getShip().isHulk())
    {
    animation.pause();
    }

   else
    {
     animation.play();
    }  

  }

}




D:\Program Files (x86)\Fractal Softworks\Starsector\mods\Thule Legacy\data\weapons\thule_deco_heimdahl.wpn
Code
{
"id":"thule_deco_heimdahl",
"specClass":"projectile",
"type":"DECORATIVE",
"size":"MEDIUM",

"everyFrameEffect":"data.scripts.plugins.isHulkCheck",

"turretSprite":"graphics/TL/weapons/decor/thule_heimdahl_Frame-01.png",
"hardpointSprite":"graphics/TL/weapons/decor/thule_heimdahl_Frame-01.png",

"numFrames":60,
"frameRate":15,
"alwaysAnimate":"true",

"turretOffsets":[0, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[0, 0],
"hardpointAngleOffsets":[0],

"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE
"muzzleFlashSpec":{"length":0.0,   # only used if animationType = MUZZLE_FLASH
  "spread":10,
  "particleSizeMin":4.0,
  "particleSizeRange":18.0,
  "particleDuration":0.2,
  "particleCount":25,
  "particleColor":[255,150,30,200]},

"projectileSpecId":"thule_barbarossa_shot",  # projectile that will be fired
"fireSoundTwo":"thule_barbarossa",
"fireSoundOne":"thule_barbarossa_overload",
}
[/u]
hello were you able to sort out the problem.. I am facing similar issue with my program files so please help.. Please reply thanks in advance:)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on August 12, 2013, 11:10:52 AM
It just uses polar coordinates to spawn stuff in an arc.

Spoiler

for (int i = 0; i < numParticles; i++) {
   float size = range * (float) Math.random() + min;
   float theta = (float) (Math.random() * Math.toRadians(spread) + Math.toRadians(angle - spread/2f));
   float r = (float) (Math.random() * length);
   float x = (float)Math.cos(theta) * r;
   float y = (float)Math.sin(theta) * r;
   Vector2f pos = new Vector2f(point.x + x, point.y + y);
   Vector2f vel = new Vector2f(x + shipVel.x, y + shipVel.y);
   // add particle here, using size/pos/vel
}
"point" is where the flash starts. Also note that it's using the offset from the point as the velocity, too; there's no reason it *has* to be that way, just happens to work fairly well.
[close]

Edit: I should say, there are definitely other ways to approach generating a muzzle flash. This one is pretty simplistic, but generally seems good enough.

Thanks a lot!!! One question, is there a boolean to determine if a weapon is charging? I want to make a reverse muzzle flash animation while the Nevermore's built-in weapon is charging, but I think it could prove somewhat tricky.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 13, 2013, 10:02:00 AM
Spoiler
Does anyone know how to check if a mod is installed, and if so which version?

Currently I am checking if a mod is installed like this (example):
Code
try
{
Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.HiigaraGen");
return true;
}
catch (ClassNotFoundException ex)
{
return false;
}

which works well, but doesn't get me the version of the mod. Anyone have any ideas? :)
[close]

There's nothing official, though you might be able to come up with something even more creative :) Made a note on my list - not sure if I'll be able to get to it, though.

One question, is there a boolean to determine if a weapon is charging? I want to make a reverse muzzle flash animation while the Nevermore's built-in weapon is charging, but I think it could prove somewhat tricky.

You could get a pretty good idea using the various WeaponAPI methods (isFiring(), getCooldownRemaining(), etc).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 13, 2013, 12:45:53 PM
I think it is possible, but just to make absolutely sure (I need to know while spriting and I don´t want to switch to coding until I finish actual ship sprite).

I need to fire few containers in specific directions after firing weapon (projectile). So basically through everyframe plugin I will check if weapon fired, if so I will spawn few containers floating away from ship (they should explode after a while). It is possible, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 13, 2013, 12:54:46 PM
Like cartridges from a gun, yes it possible, you should use a Interval timer to from x to x seconds to make sure its both firing and it doesn't spawn too many "projectiles".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 13, 2013, 01:43:14 PM
Like cartridges from a gun, yes it possible, you should use a Interval timer to from x to x seconds to make sure its both firing and it doesn't spawn too many "projectiles".

There is going to be long cooldown, like 15-20 seconds, it should fire 3 cartridges on each side (basically flux pods for cooldown - so I will basicly hardcode 6x cartridges per shop with preset direction and speed)... but now tricky party: Those cartridges ejectors suppose to be animated... it is possible to create them as deco, attach them to ship and then call them through their ID while main weapons fire to start their few frame animations?

And thank you very much for answer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 13, 2013, 02:00:46 PM
You can play around with animation frames, with a script making it play the animations until it reaches a certain frame, heres a example with a currentCharge being set on the script to avoid overlapping frames:
Code
                    switch (currentCharge)
                    {
                        case 0:
                        {

                            animation.setFrame(0);
                            animation.pause();
                            break;
                        }
                        case 1:
                        {
                            if(animation.getFrame() == 5)
                            {
                                    animation.setFrame(1);
                                    animation.play();
                            }
                            break;
                        }
                        case 2:
                        {
                            if(animation.getFrame() == 10)
                            {
                                animation.setFrame(6);
                                animation.play();
                            }
                            break;
                        }
                        case 3:
                        {
                            if(animation.getFrame() == 15)
                            {
                                animation.setFrame(11);
                                animation.play();
                            }
                            break;
                        }
                        case 4:
                        {
                            if(animation.getFrame() == 20)
                            {
                                animation.setFrame(16);
                                animation.play();
                            }
                            break;
                        }
                    }

I can set 4 different rotations on the decorative animation, you can use a timer to get "the right time" to change the animations
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 13, 2013, 02:10:18 PM
Yeah but it is possible to start animation for different sprite? I mean if it is possible to start animation of some deco while weapon is firing (so basically link deco to weapon). I can, ofc, create weapon sprite big enough to cover main weapon and those cartridges ejectors, but due to ship size and distance between those it would be kinda overkill.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 14, 2013, 12:21:30 AM
Quick question: Can anyone tell me what the "proper" dimensions for weapon sprites are? If they're too big they just seem to not show up in game, but I can't determine any kind of rhyme nor reason to it... i.e. one 68 x 72 weapon sprite will show up and a different one will not despite both being .PNGs with transparent backgrounds and the same dimensions (and hell, only slightly dissimilar actual images). Is there a certain aspect ratio they have to keep to? A certain maximum dimensions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on August 14, 2013, 04:09:17 AM
I don't think there's a max to them. I created a ridiculously large beam weapon (101x368) and it showed up fine.
Maybe you can post the images here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 14, 2013, 05:22:21 AM
Sounds stupid, but did you assign the right images? And did you mount the weapon :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 14, 2013, 01:06:23 PM
Yeah, the same images have been assigned forever, and I haven't renamed them or moved them out of the directory -- doing that causes a crash, so it's easy to catch. I haven't messed with the .variant or .wpn files either. Plus anyway, I can see that they're mounted in the ship refit window (they show up in text under "weapons". The sprite itself just randomly seems to go AWOL sometimes when I edit it.

I'm testing this by loading starsector after every change and going to Missions, so it's not a matter of needing to reload the save either :(

I'll post a screenshot and the weapon sprites in a little bit, I don't have them here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 14, 2013, 01:12:37 PM
May I suggest that you should post whole mod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 14, 2013, 01:34:31 PM
Yeah, Send me the mod in a PM, I'll take a look and get it fixed pal
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 14, 2013, 01:57:11 PM
I'm one of those people who doesn't like to post anything they've done until it's "finished".  :-* Really though, I don't see how it could be anything else in the mod interacting with it. It literally seems to only depend on the dimensions of the weapon sprite.

Here's an imgur album. Composite screenshots of weapons both showing up and not, and the exact weapon sprites i used in each case.

http://imgur.com/a/F3IbI

For now I'm just going to trial-and-error different amounts of negative space around the sprite until everything works, but I would really appreciate someone shedding some light on this. Maybe just a weird bug?

EDIT: Maybe it's not the dimensions alone... A different weapon doesn't show up even with the sprite set to the same dimensions. :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 14, 2013, 02:01:55 PM
My guess is some kind of collision between mod and core data.... I am really not able to help you if you wont post the mod itself.

Edit, how many pixels of space do you have between sprite and canvas borders?

But yeah, sometimes strange thing happens, for example there is glow on one of my ships appearing from nowhere, while it build up together with flux (but also with High energy focus glow boost, tho it is not caused by any weapon)...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 14, 2013, 02:05:35 PM
My guess is some sort of issue with the png itself; I've seen this mentioned before. I suspect just re-saving without changing the canvas size would have fixed it. There's nothing about the size of the sprite that should make a difference here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 14, 2013, 02:15:29 PM
OH I KNOW I REMEMBER!!!

BIT DEPTH LEVEL!!!

Open it in paint.net and resave it with a different bit depth
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 14, 2013, 02:43:49 PM
OH I KNOW I REMEMBER!!!

BIT DEPTH LEVEL!!!

Open it in paint.net and resave it with a different bit depth

My guess is some sort of issue with the png itself; I've seen this mentioned before. I suspect just re-saving without changing the canvas size would have fixed it. There's nothing about the size of the sprite that should make a difference here.

Thanks for the quick responses, guys. :D All good now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 14, 2013, 02:45:45 PM
Yeah but it is possible to start animation for different sprite? I mean if it is possible to start animation of some deco while weapon is firing (so basically link deco to weapon). I can, ofc, create weapon sprite big enough to cover main weapon and those cartridges ejectors, but due to ship size and distance between those it would be kinda overkill.

Just don't forget, the images should not change in size, a script should be limiting the animation frames, you can make it do the animation and spawn the cartridges easily, you'll need to have all your timers set to, the rate of fire your weapons has so the animation and the cartridges don't overlap. you can also have your first X images for a start animation and the script limiting them from going to the cartridges animations, i got a example on Star Control mod,the Trader doesn't have any animation when its not firing, but once it does, a new animation group comes in and replays, this process repeats 4 times (its a weapon that has 4 levels of charge), once fired the animation goes back to the non firing one. Tryout the ship on a mission, ull understand what i mean and hopefully it helps you solve that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on August 14, 2013, 10:19:57 PM
(http://i1022.photobucket.com/albums/af343/erick_doe/Starfarer/Tore%20Up%20Plenty/raidermk2_ff.png)

Any idea why this little fighter doesn't seem to use its bomb bay? It faces backward with a 160 degrees arc. I've also tried having it face forward, but it still won't fire it. Should I decrease the arc? Should I set its role to BOMBER?

Ideally I'd like to see it make a pass at an enemy, then fire off a bomb after passing the target.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on August 15, 2013, 06:02:30 AM
Should I set its role to BOMBER?
I'd definitely try that first. Or maybe second. I'd first try to make the bomb bay face forward and see if the AI uses it then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 15, 2013, 08:30:19 PM
Can anyone tell me what the "8/6/5/4%" field in ship_data.csv is used for?

edit: thanks  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 15, 2013, 08:34:58 PM
Alex uses it for his internal balance purposes.  Can be set to zero without any harm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Chronosfear on August 16, 2013, 10:35:54 AM
Hey guys.

startet to play around with the .csv files.
I´m using OpenOffice, opening the file with following config :
language : English ( USA )
from row : 1
separated by "Comma"

the spreadsheet looks fine.
playing around with the ship_data.csv worked

but when playing around with the weapons, in the end it doesn´t work
some weapons like the machine gun , the assault gun and others will change to an incredible rate of fire, flux/sec, damage ( 21......... Number )

any idea ?
thanks

Chronosfear
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 16, 2013, 10:38:48 AM
be careful when doing the 0.0, some editors use 0,0 instead of 0.0 because here in the EU we use , to separate decimals from integers
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on August 16, 2013, 10:41:32 AM
Don't add comma's anywhere yourself, because they'll be separated into more columns when you save your changes.

My language is Default - English (UK). Maybe try that. I got tons of issues when my native language was selected.

Also enable Quoted field as text.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on August 17, 2013, 12:07:41 PM
Is there any way to get an onhiteffect to activate even when it hits a shield? I have a weapon that's basically a large power jack used to suppliment power to damaged or in construction space stations. I'd like it to crackle with electricity whenever it hits anything, shielded or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 17, 2013, 11:38:04 PM
Quote
Is there any way to get an onhiteffect to activate even when it hits a shield?
It will always work that way in this build, provided that:

1.  The onHitEffect is designed to work that way and doesn't exclude shielded target(s).  IIRC, the only example the API, the Ion Cannon script, excludes shielded targets.  See the stuff I posted to the Radioactive Code Dump thread for some examples of different projectile behaviors.
2.  You haven't tried to combine an onHitEffect with any BehaviorSpecs.  This is supposed to be fixed with 0.6, ideally meaning that we'll be able to run a script when that triggers (but we don't have any details yet other than a hint that classic "flak" weapons may work now).
3. The projectile must be of the correct type to use onHitEffect scripts.  I.E., no BehaviorSpec defined, not a missile of any kind (and yes, dumbfire rockets count- if you want "rockets" that can run onHitEffect, they must be ballistic projectiles and all physics issues such as acceleration would need to get handled via script).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 21, 2013, 05:09:46 PM
I think my head will just pop, here is the problem:

I am creating animated beam weapon, base sprite is loaded and visible, on fire it disappears and become visible at the end of animation. BUT! (and that´s what grinds my gears) if I replace it with different animated sprite, for example shredder or something from different mod it works. BUT WAIT, there is more. If I move that working sprite from different mod to my mod (whole folder with animation), and change path it just stops to work again (same error as in first place). If I move my sprite to different mode and try to load it from there, then again same error. Ideas?

If I move that sprite to my mod (remove it from original folder in another mode) and turn off that mod then same bug as always, on the other hand if the second mod is still active then it is working again. It seems to like there is some config file (similar to sounds config file) that just point on "that is animation". But ffs I went through every single file six times and there is (and actually there is no reason to be) anything like that. So what the hell?

Hmm, maybe I got it

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 21, 2013, 05:29:03 PM
I think my head will just pop, here is the problem:

I am creating animated beam weapon, base sprite is loaded and visible, on fire it disappears and become visible at the end of animation. BUT! (and that´s what grinds my gears) if I replace it with different animated sprite, for example shredder or something from different mod it works. BUT WAIT, there is more. If I move that working sprite from different mod to my mod (whole folder with animation), and change path it just stops to work again (same error as in first place). If I move my sprite to different mode and try to load it from there, then again same error. Ideas?

If I move that sprite to my mod (remove it from original folder in another mode) and turn off that mod then same bug as always, on the other hand if the second mod is still active then it is working again. It seems to like there is some config file (similar to sounds config file) that just point on "that is animation". But ffs I went through every single file six times and there is (and actually there is no reason to be) anything like that. So what the hell?

How is ur sprites named?
Heres an example of a huge animation sprite group:
Spoiler
(https://dl.dropboxusercontent.com/u/32263294/starsector/animation_sprites_example.jpg)
[close]

Do you see anything different from what ur doing (note that the size is not the same for one reason, my weapon is outside the ship)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2013, 05:32:03 PM
Also worth making sure, just in case, that all the frames are saved as 24-bit pngs, not 8-bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 21, 2013, 05:47:00 PM
As I said, when I moved that sprite from other mode to my mod then it wasn´t working again as long as I didn´t had second mode activated (when I activated it it was ok). I´ve named frames according to shredder.. so in this case terror_rail_00.png .... terror_rail_30.png ...

And yeap, format is alright....

Point is this, it looks like, some script is actually checking if there are all frames of sprites while loading the game.

EDIT: I mean, if I remove one frame of shredder (or rename it) for example if I remove chaingun2_hardpoint_base02.png then game crash on loading, where is defined that engine should load this up? How does it know how many frames while starting the game?


AAAA I think I got it... but this is imho bug, let me test it, brb in 5 minutes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 21, 2013, 05:59:58 PM
As I said, when I moved that sprite from other mode to my mod then it wasn´t working again as long as I didn´t had second mode activated (when I activated it it was ok). I´ve named frames according to shredder.. so in this case terror_rail_00.png .... terror_rail_30.png ...

And yeap, format is alright....

Point is this, it looks like, some script is actually checking if there are all frames of sprites while loading the game.

EDIT: I mean, if I remove one frame of shredder (or rename it) for example if I remove chaingun2_hardpoint_base02.png then game crash on loading, where is defined that engine should load this up? How does it know how many frames while starting the game?
In these lines:
Code
	"numFrames":21,
"frameRate":10,
"alwaysAnimate":"false",

And your weapon needs to be the "_00" of the animation sprites:
Quote
   "everyFrameEffect":"data.scripts.plugins.TraderVariablePowerBlasterEffect",
   "turretSprite":       "graphics/missiles/animation/trader_variant_00.png",
   "hardpointSprite":    "graphics/missiles/animation/trader_variant_00.png",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 21, 2013, 06:08:19 PM
Got it, fixed it (workaround) and yes it is a bug... When weapon is set to beam mode then game doesnt suppose that there is going to be animation (when loading game), so it wont load .pngs... tho animation for beam weapons is implemented so then it is trying to render frames that are not loaded (that´s why it disappear)... Work around: Create PROJECTILE weapon, that will load that animation and then just use it in beam weapon (so I just created projectile weapon vs_load_rail that I wont never ever use)... WIN

EDIT: I am not sure if I didn´t lose some of my sanity.. so I am just going to kill few of those pink kitties with shaving blade just to make sure.

Btw: I need to control beam weapon animation through script (pause it for few frames, just it only on beam charging up and such a things) I know it can be done easily for Projectile weapons through implementing EveryFrameWeaponEffect... but I suppose it is going to be pain for beam weapon with BeamEffectPlugin... but let´s see. (actually I suppose the "only" problem will be to prevent beam weapon from animating while it is on cooldown, in case if someone would press fire button... but it is going to be weapon used only by Ai anyway, so not such a big deal I guess)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 21, 2013, 06:39:20 PM
Heres an example (i need to update this code but im waiting for 0.6a to do it):

Code
package data.scripts.plugins;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;

public class TraderVariablePowerBlasterEffect implements BeamEffectPlugin
{  
    // weapon takes 7 seconds to fully charge
    private IntervalUtil weaponcooldownlvl = new IntervalUtil(4.0f, 4.0f);
    
    private static int currentCharge = 0;
    
    private static boolean chargedlvl1 = true;
    private static boolean chargedlvl2 = false;
    private static boolean chargedlvl3 = false;
    private static boolean chargedlvl4 = false;

    @Override
        public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
        {
            ShipAPI ship = beam.getSource();
            if (ship == null)
            {
                return;
            }
            
            AnimationAPI animation = beam.getWeapon().getAnimation();
            WeaponAPI weapon = beam.getWeapon();

                if(ship.isHulk())
                {
                    animation.setFrame(0);
                    animation.pause();
                }
                
                    //Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());            
                if(weapon.isFiring())
                {                    
                    weaponcooldownlvl.advance(amount);
                    
                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 1) {
                        chargedlvl2 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 2) {
                        chargedlvl3 = true;
                    }

                    if(weaponcooldownlvl.intervalElapsed() && currentCharge == 3) {
                        chargedlvl4 = true;
                    }
                    
                    if(chargedlvl1 && weapon.getCooldownRemaining() == 0)
                    {
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        //engine.addFloatingText(ship.getLocation(), "Power Level 1",15f,Color.GREEN,weapon.getShip(),0f,0f);
                        chargedlvl1 = false;
                        currentCharge++;
                        animation.setFrame(1);
                        animation.play();
                    }
                    
                    if (chargedlvl2)  
                    {
                        chargedlvl2 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 2",20f,Color.BLUE,weapon.getShip(),0f,0f);
                        currentCharge++;
                        animation.setFrame(6);
                        animation.play();
                    }
                    
                    if (chargedlvl3)
                    {
                        chargedlvl3 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Power Level 3",25f,Color.MAGENTA,weapon.getShip(),0f,0f);
                        currentCharge++;
                        animation.setFrame(11);
                        animation.play();
                    }
                    
                    if(chargedlvl4)
                    {
                        chargedlvl4 = false;
                        Global.getSoundPlayer().playSound("trader_var_blaster_intro",0.5f, 0.5f, weapon.getLocation(), ship.getVelocity());
                        engine.addFloatingText(ship.getLocation(), "Max Power Level",30f,Color.RED,weapon.getShip(),0f,0f);
                        currentCharge++;
                        animation.setFrame(16);
                        animation.play();
                    }
                    
                    switch (currentCharge)
                    {
                        case 0:
                        {

                            animation.setFrame(0);
                            animation.pause();
                            break;
                        }
                        case 1:
                        {
                            if(animation.getFrame() == 5)
                            {
                                    animation.setFrame(1);
                                    animation.play();
                            }
                            break;
                        }
                        case 2:
                        {
                            if(animation.getFrame() == 10)
                            {
                                animation.setFrame(6);
                                animation.play();
                            }
                            break;
                        }
                        case 3:
                        {
                            if(animation.getFrame() == 15)
                            {
                                animation.setFrame(11);
                                animation.play();
                            }
                            break;
                        }
                        case 4:
                        {
                            if(animation.getFrame() == 20)
                            {
                                animation.setFrame(16);
                                animation.play();
                            }
                            break;
                        }
                    }
                }
                
                if(weapon.getChargeLevel() <= 0.1f && currentCharge > 0)
                {
                    switch (currentCharge)
                    {
                        case 1:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s1_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s1", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                        case 2:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s2_launch", 1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon, "trader_variable_power_blaster_s2", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                        case 3:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s3_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster_s3", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                        case 4:
                        {
                                Global.getSoundPlayer().playSound("trader_var_blaster_s4_launch",1f, 1f, weapon.getLocation(), ship.getVelocity());
                                engine.spawnProjectile(ship, weapon,"trader_variable_power_blaster", weapon.getLocation(), weapon.getCurrAngle(), ship.getVelocity());
                                ship.getFluxTracker().increaseFlux(500, false);
                                weapon.setRemainingCooldownTo(0.5f);
                                animation.setFrame(0);
                                animation.pause();
                                weaponcooldownlvl.forceIntervalElapsed();
                                currentCharge = 0;
                                chargedlvl1 = true;
                                chargedlvl2 = false;
                                chargedlvl3 = false;
                                chargedlvl4 = false;
                            return;
                        }
                    }
                }
    }//advance
}

EDIT: my weapon has    "alwaysAnimate":"false",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on August 21, 2013, 06:47:20 PM
Got it, fixed it (workaround) and yes it is a bug... When weapon is set to beam mode then game doesnt suppose that there is going to be animation (when loading game), so it wont load .pngs... tho animation for beam weapons is implemented so then it is trying to render frames that are not loaded (that´s why it disappear)... Work around: Create PROJECTILE weapon, that will load that animation and then just use it in beam weapon (so I just created projectile weapon vs_load_rail that I wont never ever use)... WIN

EDIT: I am not sure if I didn´t lose some of my sanity.. so I am just going to kill few of those pink kitties with shaving blade just to make sure.

Btw: I need to control beam weapon animation through script (pause it for few frames, just it only on beam charging up and such a things) I know it can be done easily for Projectile weapons through implementing EveryFrameWeaponEffect... but I suppose it is going to be pain for beam weapon with BeamEffectPlugin... but let´s see. (actually I suppose the "only" problem will be to prevent beam weapon from animating while it is on cooldown, in case if someone would press fire button... but it is going to be weapon used only by Ai anyway, so not such a big deal I guess)

Guess you were having the same problem as me, but I guess you solved yours lol

Spoiler
Since the reverse burn drive thing I tried didn't work, on to the next one :D


0.54.1a

Modding:
Beam and burst beam weapons can now be animated (but the glow sprite can not, must remain the same for all frames)

Well I tried to make an animated weapon, but the animation part of it doesn't work >>"

Apology for not being able to take consecutive screenshots, Starsector crashes after just one screenshot, So this is how it looks,

Spoiler
(http://i.imgur.com/uyALNOK.png)

(http://i.imgur.com/2wpy2xT.jpg)
[close]

It shows only the first frame, once you fire, the weapon disappears, and the reappears after what probably means it cycled through all the frames.

Code
{
"id":"neutrino_phasedarray2",
"specClass":"beam",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":1100,
"turretSprite":"graphics/neut/weapons/phasedarray/neutrino_phasedarray_base00.png",
"hardpointSprite":"graphics/neut/weapons/phasedarray/neutrino_phasedarray_base00.png",
"numFrames":16,
"frameRate":30,
"turretOffsets":[-80, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[-80, 0],
"hardpointAngleOffsets":[0],
"fringeColor":[212,60,25,255],
"coreColor":[255,255,255,255],
#"glowColor":[212,60,25,235],
"darkCore":false,
"width":50.0,
"textureType":ROUGH,
#"textureType":["graphics/fx/emp_arcs.png","graphics/fx/emp_arcs.png"],
"textureScrollSpeed":292.0,
"pixelsPerTexel":5.0,
"pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF,FIGHTER],
"fireSoundOne":"neutrino_heavybeam_firing",
"fireSoundTwo":"beam_heavy_loop",
}

Am I missing something  ???
[close]
Do You mind if I ask to see the .wpn file? I tried it with projectile type, but the beam part of the weapon doesn't work now but I've got the animation part, lol sigh.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 21, 2013, 07:06:01 PM
You will just use .wpn for Beam weapon (for animated one), as you suppose to, you just need to create one more .wpn as Projectile weapon, that will load animation sprites (.png sequence) that you are going to use for Beam weapon .wpn file. Ofc you need to have both weapons in weapon_data.csv. If you still need any help I will upload my .wpns files.

silentstormpt: Your weapon is animated all the time, basicly there is no time when player could press button and weapon not to be animated (no CD)... but anyway I think I have solution for that problem.. I have already implemented pause for specific frame of animation (derived from Lazy´s solution for projectile animation pause).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2013, 07:32:05 PM
Ahhh! Thank you for catching that beam-animation-not-loading bug, fixed it up. That's pretty evil.

By the way - beam weapons can have an everyFrameEffect, along with a beamEffect. The difference is that beamEffect will be called for every beam, if the weapon happens to have multiple barrels.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 21, 2013, 07:51:22 PM
Ahhh! Thank you for catching that beam-animation-not-loading bug, fixed it up. That's pretty evil.

By the way - beam weapons can have an everyFrameEffect, along with a beamEffect. The difference is that beamEffect will be called for every beam, if the weapon happens to have multiple barrels.

Np. Observation about that BeamEffectPlugin: lets say I have some declared and defined variables for that class. It seems like (not seems, I am pretty sure) engine resets them to their initial values. Point is this: I need  to animate sprite while charging up (done) then after weapon is firing no more, then I need to finish rest of animation and also there is cooldown for this weapon, in which if someone click fire then animation of sprite is played (which I don´t want to). And now I have to chose, I can prevent animation when weapon is on CD, but then I am unable to finish part of animation after weapon stops to fire... (coz I basicaly stop and prevent animation when weapon.isFiring() = false)... I would create a interval and countdown that will prevent animation from stopping for some time after beam is finished with firing but I am afraid that countdown wont work coz it will be always set to it´s initial value... actually not sure if I even can anyhow manipulated with those done in BeamEffectPlugin when the weapon is not actually firing.....

Hmmmm... I should just rewrite as EveryFrame.. :D

Simply: BeamEffectPlugin isn´t called when beam isn´t active, right? (while everyframe should be called on everyframe no matter what is weapon doing... or do I get it wrong?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2013, 08:15:44 PM
Np. Observation about that BeamEffectPlugin: lets say I have some declared and defined variables for that class. It seems like (not seems, I am pretty sure) engine resets them to their initial values.

Almost sounds like you're creating local variables inside the method, rather than data members inside the class. If you look at  com.fs.starfarer.api.impl.combatTachyonLanceEffect (in starfarer.api.zip), it declares some member variables and those certainly don't get reset, or the effect wouldn't work.

If that's not what you're doing, can you post your code here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 21, 2013, 08:18:31 PM
Nope, variables were right, just observation kinda wrong... so new statement:

BeamEffectPlugin isn´t called when beam is actually not active and when it get active next time it will start with initial values of variables.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on August 21, 2013, 09:03:35 PM
You will just use .wpn for Beam weapon (for animated one), as you suppose to, you just need to create one more .wpn as Projectile weapon, that will load animation sprites (.png sequence) that you are going to use for Beam weapon .wpn file. Ofc you need to have both weapons in weapon_data.csv. If you still need any help I will upload my .wpns files.

silentstormpt: Your weapon is animated all the time, basicly there is no time when player could press button and weapon not to be animated (no CD)... but anyway I think I have solution for that problem.. I have already implemented pause for specific frame of animation (derived from Lazy´s solution for projectile animation pause).

Now I got it working, was a little confused, but It's just a second weapon just to load the sprites itself, sneaky. :D

But why is the dilemmas always similar, Just gotta make the animation hold mid way for couple of seconds, and rather not rename 60 frames of... the same thing.
Though Cycerin has a script that does this, idk how to make it work midway instead at the beginning of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 21, 2013, 09:06:05 PM
You will just use .wpn for Beam weapon (for animated one), as you suppose to, you just need to create one more .wpn as Projectile weapon, that will load animation sprites (.png sequence) that you are going to use for Beam weapon .wpn file. Ofc you need to have both weapons in weapon_data.csv. If you still need any help I will upload my .wpns files.

silentstormpt: Your weapon is animated all the time, basicly there is no time when player could press button and weapon not to be animated (no CD)... but anyway I think I have solution for that problem.. I have already implemented pause for specific frame of animation (derived from Lazy´s solution for projectile animation pause).

Now I got it working, was a little confused, but It's just a second weapon just to load the sprites itself, sneaky. :D

But why is the dilemmas always similar, Just gotta make the animation hold mid way for couple of seconds, and rather not rename 60 frames of... the same thing.
Though Cycerin has a script that does this, idk how to make it work midway instead at the beginning of it.

If you are talking about pausing animation then that isn´t a problem. But I am not sure that I understand what do you mean.

Edit: got everything working, uploading, result in few minutes :)

Result: http://www.youtube.com/watch?v=Gi18_BVSOFY&feature=youtu.be
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 22, 2013, 07:48:01 AM
Nope, variables were right, just observation kinda wrong... so new statement:

BeamEffectPlugin isn´t called when beam is actually not active and when it get active next time it will start with initial values of variables.

Correct. That generally seems desirable for actual beam effects, doesn't it? But probably makes it a bad place to govern the weapon's animation from. There's also the part about it being passed in a BeamAPI, which doesn't exist while the weapon isn't firing, though I suppose that could be null...


(I've got the say, the railgun impact looks pretty amazing. As does the ship itself, but we weren't talking about that :))

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 22, 2013, 08:56:15 AM

Correct. That generally seems desirable for actual beam effects, doesn't it? But probably makes it a bad place to govern the weapon's animation from. There's also the part about it being passed in a BeamAPI, which doesn't exist while the weapon isn't firing, though I suppose that could be null...



Yeah, I understand it now, and probably if it wouldn´t be so late yesterday then I would understand it earlier :D( I´ve simply believed it is everyframe specific to beam weapons, dunno why). I have just changed it to everyframe and it was working without problem, thx for help :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 24, 2013, 09:40:00 AM
Question about png, bit-depth is obvious but what about interlacing and compression? It seems like (by their size) every vanilla png use highest/slowest compression, not sure about interlacing but I guess it even doesnt matter in this case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2013, 10:25:42 AM
Question about png, bit-depth is obvious but what about interlacing and compression? It seems like (by their size) every vanilla png use highest/slowest compression, not sure about interlacing but I guess it even doesnt matter in this case.

Not sure. It's using java's ImageIO.read, so whatever that does.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 24, 2013, 10:36:10 AM
I guess ImageIO doesnt consider it, it is mostly used for web aplication (ability to preload few rows and fill rest with random pixels, then load the rest, basically progressive loading), anyway thx. Still curious about that compression, coz none-fast produce bigger image but they could be actually easier and faster to load by the engine itself, but not completely sure about that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2013, 11:30:32 AM
Still curious about that compression, coz none-fast produce bigger image but they could be actually easier and faster to load by the engine itself, but not completely sure about that.

I'd be shocked if the time spent decoding was significant compared to the time spent loading the image from disk for any non-trivial number of computer setups. Shocked, I tell you :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 24, 2013, 11:46:07 AM
Still curious about that compression, coz none-fast produce bigger image but they could be actually easier and faster to load by the engine itself, but not completely sure about that.

I'd be shocked if the time spent decoding was significant compared to the time spent loading the image from disk for any non-trivial number of computer setups. Shocked, I tell you :)

Went exploring to help you out and found this:
http://lwjgl.org/wiki/index.php?title=Loading_PNG_images_with_TWL's_PNGDecoder
http://lwjgl.org/forum/index.php?topic=4762.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2013, 12:14:39 PM
Ah, thanks :)

I actually experimented with that particular decoder a while ago; it only handled power-of-two-sized pngs and wasn't significantly faster, if at all (refer to part about time to load from disk dwarfing everything else).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 24, 2013, 03:01:54 PM

Well I was not suggesting it is bad, actually I wasn´t 100 percent sure if they are actually compressed or not, just checking if I was using proper format or if it actually matters, so thx for informations.

Observation: Ai compares OP of two enemy ships, if OP of one ship is significaly lower then it is "afraid" of other one and try to avoid combat (run from it, even if it cannot retreat just trying to outrange it all the time)

-correct? Also only weapon OPs count? Or what? If this theory is alright then I am pretty sure only actual OP counts (not maximum ship OP, just current loadout).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2013, 03:16:39 PM
It's ... involved. It considers damage, weapon type/size, shield type/state/efficiency, direction the weapon is pointing at, one-shot damage/dps, etc. Ordnance points are just about the only thing that's actually not considered here, iirc :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 24, 2013, 03:22:46 PM
Point is, I have ship with DPS, shield efficiency and other stats far above any other ships, still it is running even from cruisers. (dps is actually several thousands). Tho it has only inbuilt weapons, so no OP from that.

Edit: I just tried to boost OP from hullmods, actually multiplied it by 3.. now it is much more aggressive. Before it was running from Dominator class, now it is willingly rushing against onslaughts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2013, 03:35:12 PM
Ah yes, that makes sense. If a variant's actual spent OP are below a certain fraction of the maximum OP (30%? not sure what it is in 0.54.1a), the AI considers it a civilian ship and runs away no matter what.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 24, 2013, 03:47:23 PM
Ahhh that would explain a lot
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on August 25, 2013, 01:27:32 PM
Am I missing something, or does MutableShipStatsAPI.getShieldArcBonus not actually function during combat?  Trying to make a ship system that increases shield arc when it's active, and, err, either the method's broken or I'm doing something wrong...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 25, 2013, 01:48:12 PM
Right, that doesn't work dynamically. The shield's initialization depends on knowing its arc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NITROtbomb on August 26, 2013, 07:27:15 AM
I cannot find to log so i don't know how to say this but I am getting a fatal error loading a projectile sprite, in graphics/WFE/Missiles/bomlete3.png I don't know what is happening I have compared my weapon data and stuff to that of other mods and the core files and cannot see what the fatal difference is, any suggestions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on August 26, 2013, 09:51:19 AM
My first suggestion would be to post the mod or people'd take potshots into the dark forever. *pew pew*
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 26, 2013, 09:52:29 AM
I cannot find to log so i don't know how to say this but I am getting a fatal error loading a projectile sprite, in graphics/WFE/Missiles/bomlete3.png I don't know what is happening I have compared my weapon data and stuff to that of other mods and the core files and cannot see what the fatal difference is, any suggestions?

C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\starfarer(.log) but as always best thing would be if you can upload it.

Btw, guys.. I would really, really, really like to create projectile weapon with trail... I have idea for effect that I consider better then anything I done so far (in case if execution will be done correctly).. but I don´t want to use just particles... in the worst case scenario I will just map path of projectile, or actualy keep spawning particles on projectile location, tho I didn´t checked if is possible to return projectile location, but I am pretty sure it is, aynway I would rather spawn beam with same speed as projectile and use it as grahpic effect, problem is, as far as I am aware there is no way how to spawn beam through api, right? (It would be ofc just burst with some decay time, also it need to be beam rather then praticles coz I would creat very specific texture for that trail).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on August 26, 2013, 10:10:13 AM
While i'm not sure if i clearly understand what you are asking for but i think you should look for silentstormpt post where he talk about a ballistic projectile with a beam looking trail behind it. Not sure if it's what you need though.

http://fractalsoftworks.com/forum/index.php?topic=5539.210
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on August 26, 2013, 10:16:58 AM
Nope, I would need that trail to stay on place for few seconds and then slowly disapper, it should behave like trails behind airplanes irl, if you know what I mean (ofc disappering much faster)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 26, 2013, 10:22:01 AM
You can't spawn beams through the API atm, no.

That said, there are various options for short bolts.  Do an operation that spawns particles of a given width in a row, rotate the row after applying velocity.  Should look like a small bolt.  

It's expensive to do it this way though, because it requires quite a few particles for any given length.  

The better way is to spawn an actual projectile that is a short beam segment, using BALLISTIC_AS_BEAM, like the Mining Blaster.  Just make the weapon harmless and set the CollisionType to NONE.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 26, 2013, 10:37:32 AM
You can also make the projectile spawn a smoke on its location every X.X seconds, creating that trail you wanted but it is heavy CPU usage specially if you spam those projectiles
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NITROtbomb on August 26, 2013, 04:56:49 PM
Im on a mac so i think this is what you want?
Spoiler
37757 [Thread-8] ERROR com.fs.starfarer.combat.String  - java.lang.RuntimeException: Error loading [graphics/EFA/missiles/bomblet3.png] resource, not found in [/Users/nicholascruse/Desktop/NOT SCHOOL/Starsector.app/Contents/Resources/Java/../../../mods/Console,/Users/nicholascruse/Desktop/NOT SCHOOL/Starsector.app/Contents/Resources/Java/../../../mods/LazyLib,/Users/nicholascruse/Desktop/NOT SCHOOL/Starsector.app/Contents/Resources/Java/../../../mods/MYMOD,../starfarer.res/res,CLASSPATH]
 java.lang.RuntimeException: Error loading [graphics/EFA/missiles/bomblet3.png] resource, not found in [/Users/nicholascruse/Desktop/NOT SCHOOL/Starsector.app/Contents/Resources/Java/../../../mods/Console,/Users/nicholascruse/Desktop/NOT SCHOOL/Starsector.app/Contents/Resources/Java/../../../mods/LazyLib,/Users/nicholascruse/Desktop/NOT SCHOOL/Starsector.app/Contents/Resources/Java/../../../mods/MYMOD,../starfarer.res/res,CLASSPATH]
   at com.fs.util.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?00000(Unknown Source)
   at com.fs.util.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?00000(Unknown Source)
   at com.fs.graphics.TextureLoader.new(Unknown Source)
   at com.fs.graphics.TextureLoader.o00000(Unknown Source)
   at com.fs.graphics.TextureLoader.o00000(Unknown Source)
   at com.fs.graphics.TextureLoader.o00000(Unknown Source)
   at com.fs.graphics.F.super(Unknown Source)
   at com.fs.starfarer.loading.H.o00000(Unknown Source)
   at com.fs.super.A.?00000(Unknown Source)
   at com.fs.starfarer.combat.String.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:680)
AL lib: FreeContext: (0x1001e5c30) Deleting 77 Source(s)
AL lib: FreeDevice: (0x104162000) Deleting 155 Buffer(s)
logout
/spoiler]
 
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 27, 2013, 12:03:39 AM
Nitro, it would appear that the mod is looking for that specific file somewhere on the desktop, can you post the contents of any weapon files you have made?

Edit: Oh and projectile files
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NITROtbomb on August 27, 2013, 04:11:46 AM
ok I'll look into that

http://www.mediafire.com/folder/rs6o9b536tvd7wl,04e3igji5fkospd,4g66hvf15kk32l4/shared
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on August 27, 2013, 04:43:18 AM
Thanks, I'll look when I'm home tonight
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NITROtbomb on August 27, 2013, 05:45:45 AM
also for those interested here is the mod file, it was just something to fill me over till my spiriting skill improves :P

http://www.mediafire.com/download/58kcbdyhyhzji85/MYMOD.zip
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on August 27, 2013, 06:34:49 AM
Check your spelling, NITROtbomb. Your folder name is missles, not missiles. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NITROtbomb on August 27, 2013, 06:42:14 AM
Oh my god :O I fell like I should be in year 1 not year 12 lol

Ok it loads now but ahh, the weapon does not seem to exist :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on August 27, 2013, 10:25:34 PM
Is there any way to get at what a ship's armed with?  I'm working on a ship system AI; the system in question primarily benefits energy weapons, but the ship has universal slots - I'd like the AI to react intelligently to noticing that it has missiles or ballistics instead of energy weaponry.  (This one I'm pretty sure isn't doable until 0.6, but hey, worth asking right?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on August 31, 2013, 09:19:57 AM
Thought this may be useful:

How to get a ShipAPI from a FleetMemberAPI:
Code
        ListIterator Fleetships = FleetID.getFleetData().getMembersListCopy().listIterator();
        while(Fleetships.hasNext())
        {
            FleetMemberAPI fmember = (FleetMemberAPI)Fleetships.next();
            MutableShipStatsAPI stats = fmember.getStats();
            ShipAPI ship = (ShipAPI) stats.getEntity();
}

not 100% sure it works, if it does, i wish i had found out alot sooner.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 31, 2013, 09:28:39 AM
It doesn't. Rather, it only does if you're calling stats.getEntity() from within combat. A ShipAPI doesn't exist for a FleetMember in the campaign.

Is there any way to get at what a ship's armed with?  I'm working on a ship system AI; the system in question primarily benefits energy weapons, but the ship has universal slots - I'd like the AI to react intelligently to noticing that it has missiles or ballistics instead of energy weaponry.  (This one I'm pretty sure isn't doable until 0.6, but hey, worth asking right?)

I'm not exactly sure what's in it as of 0.54.1a, but take a look at ShipAPI.getVariant(). That may have what you need. Also, is there a ShipAPI.getAllWeapons()? In any event, this will definitely be possible in 0.6a.

... actually, take a look at data.shipsystems.scripts.ai.FastMissileRacksAI. That's doing pretty much what you are talking about.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 03, 2013, 09:40:30 AM
Ive hit a bump here, so far theres alot of work done into making a possible Utilitymod, that adds dynamic starsystem gen, an mining system, more control over each element of a starsystem, factiondata and products, product schematics (allows adding possible cargo creation using 2 or 3 different cargos) and hopefully a economy.
https://bitbucket.org/silentstormpt/starsector-utility-mods/commits/all

Question how would you create a productSchematic class that by providing x productentities will result in a specific productentity?
https://bitbucket.org/silentstormpt/starsector-utility-mods/src/8b77fdbc22bd2db1bcfeec97dcb17f1a26c64c01/data/scripts/world/economy/ProductSchematic.java?at=default

Btw the productEntity is suppose to save info for a certain cargo, so you can see it as a model that saves all the info on that cargo, provided by a CSV or JSON file, so any mod that provides that info can create their specific unique products and schematics, that can be used to create that cargo. For example:

everyday i generate X amount of productEntity.createCargo(yourminingship.getCargo(), productEntity, Quantity);

That productEntity can be "gold" or any type of product you want used as a mineral.

Disclaimer: this is all pretty much work in progress and should only work once 0.6a arrives and i can finally set all the missing methods into this "puzzle"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on September 08, 2013, 02:40:24 PM
What is in your opinion most effective way (resource wise) to convert specific beam weapon to deal hard flux instead of soft?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on September 08, 2013, 03:23:42 PM
Lazy wizard has a implementation that changes beam soft flux damage to hard here

I don't know if this suggestion has been made yet- only read through the last few pages, but here is a possible idea that could balance out the problems with using beams to kite while still giving them killing power.  What if beams did full DPS throughout their range, but scaled from 100% hard flux at zero range to 100% soft flux at max range?  (or maybe something like 50% soft at 20% max range and lower to 100% soft at 80% max range and higher).  You could even put in a slight color or gamma gradient over the beam's range so there is visual feedback on whether you are in the soft or hard flux range bands. 

Thus - if you try to kite with your superior range you're only doing soft flux, but if you want to abuse your manly tri-tac shields you can fly in close for some hard flux damage, but risk the return fire.

I liked this idea so much I decided to try it out. Here's (http://www.mediafire.com/download/rt9b5lirjogrs3h/Alternate_Beam_Mechanics.zip) a small test mod that gives all vanilla beams 0-100% hard flux based on distance to the target (requires LazyLib (http://fractalsoftworks.com/forum/index.php?topic=5444.0)).

I've only tested it briefly, but the most noticeable effect is that the famed Disco Paragon has gone from "able to kill anything smaller than it" to "able to kill anything, period" (including taking on two Conquests and an Onslaught simultaneously). I'll try making a version using the other variant you mentioned, as I think that might be more balanced. :)

http://www.mediafire.com/download/rt9b5lirjogrs3h/Alternate_Beam_Mechanics.zip
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on September 08, 2013, 03:52:18 PM
I believe there was a bug in that version of the code. Here's the version I currently have in my sandbox project:

Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.FluxTrackerAPI;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.DefenseType;
import org.lazywizard.lazylib.combat.WeaponUtils;

public class HardFluxBeam implements BeamEffectPlugin
{
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        if (beam.getDamageTarget() instanceof ShipAPI)
        {
            ShipAPI target = (ShipAPI) beam.getDamageTarget();
            ShieldAPI shield = target.getShield();
            if (shield != null && shield.isWithinArc(beam.getTo()))
            {
                WeaponAPI wep = beam.getWeapon();
                float damage = WeaponUtils.calculateDamagePerSecond(wep,
                        target, DefenseType.SHIELD) * amount;

                // Hard flux dealt is based on distance to target
                float hardFluxRatio = 1f - (MathUtils.getDistance(
                        beam.getFrom(), beam.getTo()) / wep.getRange());
                float softFlux = damage * (1f - hardFluxRatio);
                float hardFlux = damage * hardFluxRatio;


                // Undo the vanilla flux damage, add our custom damage
                FluxTrackerAPI flux = target.getFluxTracker();
                flux.decreaseFlux(damage);
                flux.increaseFlux(softFlux, false);
                flux.increaseFlux(hardFlux, true);
            }
        }
    }
}

It's not 100% accurate, unfortunately. Guessing how much damage is being dealt is complicated, and beam damage especially so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ravendarke on September 08, 2013, 04:59:32 PM
I like that idea with range, really, gave me a idea... using it (for one specific weapon) not just for hard/soft flux ration but for dmg overall, while inverted (longer range = more dmg). Or it could be even used to create weapon with deadzone.. doing lot of dmg on close range, lot of dmg on max range but almost non in middle.. hmm.. anyway thanks a lot :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 09, 2013, 09:19:16 PM
Alrighty, so, the code I'm having trouble with at the moment is this ai script, based off of the ReflectorAI from BRDY.  Honestly, it feels like the problem shouldn't be that hard to deal with, except every time I end up calling up the autocomplete in netbeans the program hangs, which is kind of annoying.

Code
package data.shipsystems.scripts.ai;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import java.util.Iterator;
import org.lwjgl.util.vector.Vector2f;
import org.lazywizard.lazylib.combat.*;
import org.lazywizard.lazylib.MathUtils;

public class ms_siegemodeAI implements ShipSystemAIScript {
    private ShipSystemAPI system;
    private ShipAPI ship;

    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine)
    {
        this.ship = ship;
        this.system = system;
    }

    @Override
    public void advance(float amount, MutableShipStatsAPI stats, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target)
    {
        float goLive = 1200f; //the AI needs to know (roughly) how big the range of our weapons boost is.
        float fuzzyLogic = 0f; //set our logic counter to 0
        
        int ships = 0;
        ShipAPI ship_tmp;
    
        for (Iterator iter = CombatUtils.getCombatEngine().getShips().iterator();
                iter.hasNext();)
        
        {
            ship_tmp = (ShipAPI) iter.next();
            ship_tmp.getMutableStats();
                
            if ((ship_tmp.getOwner() != ship.getOwner()) && (MathUtils.getDistance(ship_tmp, ship) >= (goLive * 1.05f)))
            { //Check hostility and range
                    fuzzyLogic += ship_tmp.getFluxCapacity(); //Watch out for lots of Flux  --  This is the first line bearing an error.
                    fuzzyLogic += ship_tmp.getMaxHitpoints(); //And big hitpoint pools - we can generally presume that vessel with both/either would require sieging
                    fuzzyLogic -= (ship_tmp.getMaxSpeed() * 2.5f); //Of course, we don't really want to hold still when we're dealing with fast targets   --  And this is the second.
            }
        }
        float fluxLevel = ship.getFluxTracker().getFluxLevel();
                
        if (fuzzyLogic > 5000f && !system.isActive() && fluxLevel < 0.95f) {
            //compare our counter to a magic number, make sure the system is already off, and that our flux level isn't too high
            ship.useSystem();
        } else if ((fuzzyLogic <= 2000f || fluxLevel >= 0.95f || goLive >= goLive * 1.15f) && system.isActive()) {
            //if there is little-to-no threat OR if our flux level is too high OR if the enemies are far enough away, turn the system off if it is currently active
            ship.useSystem();
        } else { return; }
    }

}

I've been playing around with MutableShipStatsAPI to see if that would work, but it doesn't seem to be playing nicely with ship_tmp.  Alas.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on September 09, 2013, 09:26:55 PM
You're looking for ship_tmp.getFluxTracker().getMaxFlux(), ship_tmp.getMaxHitpoints(), and ship_tmp.getMutableStats().getMaxSpeed().getModifiedValue().

Quote
Honestly, it feels like the problem shouldn't be that hard to deal with, except every time I end up calling up the autocomplete in netbeans the program hangs, which is kind of annoying.

Try following the instructions here (http://fractalsoftworks.com/forum/index.php?topic=3674.0) to clear Netbean's cache and see if that helps with the hanging issues.


Edit: also, you'll want to change
Code
public void advance(float amount, MutableShipStatsAPI stats, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target)
to
Code
public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 09, 2013, 09:46:22 PM
Unfortunately clearing the cache hasn't seemed to resolve the issue with netbeans.

At least the code is working pretty well now, though.  Thanks for your help, Lazy!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on September 13, 2013, 07:16:01 AM
I completely missed this:

Will we be able to assign specific graphics to stations in 0.6a?

I realise that we can do this now, but as of now it overwrites the graphics of all stations.

To elaborate my question: can we make station graphics faction specific in 0.6a?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2013, 01:53:18 PM
Will we be able to assign specific graphics to stations in 0.6a?

I realise that we can do this now, but as of now it overwrites the graphics of all stations.

To elaborate my question: can we make station graphics faction specific in 0.6a?

No - it's definitely on my list, just couldn't get to it. Hoping to sneak it in in 0.6.1a.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 13, 2013, 11:03:35 PM
Can somebody explain to me in a nutshell, what Jars are, and how they work with Starsector? It seems like a pretty standard Java thing. Funnily enough I don't know much about Java.

(I'm asking because it seems like you need them to get around generics are something. It's hard to explain because I'm realizing just now how little I know about Java.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on September 14, 2013, 01:18:58 AM
Can somebody explain to me in a nutshell, what Jars are, and how they work with Starsector? It seems like a pretty standard Java thing. Funnily enough I don't know much about Java.

(I'm asking because it seems like you need them to get around generics are something. It's hard to explain because I'm realizing just now how little I know about Java.)

Just a note - you don't actually need generics, they just make life slightly easier. You can code pretty much anything without them that you could using them. :)

Anyway, the explanation:

Most mods implement their scripts as loose java files in their mod folders. When the game launches, it finds all these scripts and passes them to Janino. Janino is a very small, very fast compiler that Starfarer uses to compile scripts. While it is fast, the downside is that it doesn't support the full list of Java language features, generics being foremost among that list.

A jar is basically an archive (like a zip or rar) that contains compiled java code (.class files), 'compiled' meaning it's been translated into a form the computer can understand. Since the code in a jar is already readable by the Java VM, the game can load these classes directly into memory, bypassing Janino and its restrictions.

If you are already using an IDE you should have an easy time creating a jar - in NetBeans it'd be Clean and Build (Shift+F11), and you'd find the jar in your NetBeans project folder inside the dist directory. Just put that jar somewhere in your mod folder, then add a line to your mod_info.json telling the game where to find it.

For example, LazyLib's compiled code is stored in jars/LazyLib.jar. So it requires the following line in its mod_info.json:
Code
    "jars":["jars/LazyLib.jar",],

There is one pitfall you have to watch out for. Unless Alex has changed it in .6a, scripts in data/scripts/plugins need to be outside a jar to be automatically loaded by the game.


Again, you don't need to know anything about using generics or jars to write a mod. Just create mods the way you are most comfortable and everything will continue to work. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on September 14, 2013, 06:39:04 AM
How should I implement custom engine sounds in a similar way to the core game without ruining compatibility with other mods?

Code
	"engine_loop":{
"sounds":[
{"file":"sounds/BR/fx/brdyshipsounds/blackrockengine_frig.ogg","pitch":1,"volume":1},    # index:  14
{"file":"sounds/BR/fx/brdyshipsounds/blackrockengine_frig.ogg","pitch":1,"volume":1}, # index:  15
{"file":"sounds/BR/fx/brdyshipsounds/blackrockengine_destroyer.ogg","pitch":1,"volume":1},    # index:  16
{"file":"sounds/BR/fx/brdyshipsounds/blackrockengine_cruiser.ogg","pitch":1,"volume":1},  # index:  17
{"file":"sounds/BR/fx/brdyshipsounds/blackrockengine_capital.ogg","pitch":1,"volume":1},    # index:  18
],

"BLACKROCKHULL":{"sounds":[15,16,17,18,19], "pitch":1, "volume":1},
"FIGHTER":{"sounds":[15], "pitch":1, "volume":0.5},
"FRIGATE":{"sounds":[16], "pitch":0.9, "volume":0.6},
"DESTROYER":{"sounds":[17], "pitch":0.9, "volume":0.7},
"CRUISER":{"sounds":[18], "pitch":0.9, "volume":0.75},
"CAPITAL_SHIP":{"sounds":[19], "pitch":1, "volume":0.8},
},

As far as I can see, if I use an index from 0 and out it uses core sounds. But if a different mod tried to call the same list entries as the ones I'm using, would there be a conflict? Can I do this in a more... isolated fashion?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2013, 10:41:35 AM
As far as I can see, if I use an index from 0 and out it uses core sounds. But if a different mod tried to call the same list entries as the ones I'm using, would there be a conflict? Can I do this in a more... isolated fashion?

Hm, that's a good point, this is a problem. Will take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 14, 2013, 01:46:51 PM
Hey, I've noticed that my ships aren't spawning with the proper names.

If have
Code
    "shipNameSources":{
"regime":1,
},
in the .faction file and then a ship_names.json in data/strings of my mod that looks like this
Code
{
"regime":
[
"Hand of God",
"Repentant",
],
}
is there any reason why my ships are showing up in stations etc. with names pulled from other lists? Bug, or am I overlooking something dumb?

edit: I have quite a few names on there, but I'll add more and see if that fixes anything? I don't think that's it, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 14, 2013, 02:55:33 PM
Maybe your name list is too short so the game gets needed names from other lists as well? (Dunno if it is short, haven't checked.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on September 14, 2013, 02:55:51 PM
Why do ships with 0 crew (As in, unmanned--there shouldn't be any crew) always have 0% combat readiness? Is there a way to override the automatically-assigned 0% CR, or is this a bug?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 14, 2013, 03:14:46 PM
I updated my mod to the new ModPlugin system as per LazyWizard's post and it kept calling the OnEnabled part every time a saved game was loaded -- as if it wasn't reading the "if (!wasEnabledBefore)" or rather I suppose as if wasEnabledBefore never got set. I was under the impression the game's built-in mod handling set it automatically, is there a way I can do it manually in the onNewGame? I'm sure it's really simple but I can't really into java :v

Code
     @Override
     public void onEnabled(boolean wasEnabledBefore)
     {
         if (!wasEnabledBefore)
         {
            // Calling a separate method avoids duplicate code with onNewGame()
            initVayra();
         }
     }

I fixed the problem for now by just commenting that block of code out, but that's obviously nonoptimal as it means I can't add my mod to existing games.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on September 14, 2013, 03:36:12 PM
Why do ships with 0 crew (As in, unmanned--there shouldn't be any crew) always have 0% combat readiness? Is there a way to override the automatically-assigned 0% CR, or is this a bug?

I can't give a why , but I had the same prob.

http://fractalsoftworks.com/forum/index.php?topic=6634.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 14, 2013, 05:53:05 PM
Thanks Lazy, that's pretty helpful. Although I'm still confused, I may as well try to describe what I want to do.

All I wanna do is add special dialogue options for Stations controlled by a specific faction.
Also would like to do a special dialogue that only plays when you interact with a planet.

But things don't ever seem to work the way I want them to.

I should add that I'd like to to NOT replace anything I can avoid replacing, for compatibility.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 14, 2013, 06:18:02 PM
Why do ships with 0 crew (As in, unmanned--there shouldn't be any crew) always have 0% combat readiness? Is there a way to override the automatically-assigned 0% CR, or is this a bug?

Seem like CR is connected to the crew XP, 0 crew will return a bonus of 0f, resulting in 0 CR created.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on September 14, 2013, 06:41:03 PM
Thanks Lazy, that's pretty helpful. Although I'm still confused, I may as well try to describe what I want to do.

All I wanna do is add special dialogue options for Stations controlled by a specific faction.
Also would like to do a special dialogue that only plays when you interact with a planet.

But things don't ever seem to work the way I want them to.

I should add that I'd like to to NOT replace anything I can avoid replacing, for compatibility.

Here's an example of picking an interaction plugin for a specific entity without using generics (this goes in your CampaignPlugin implementation):

Code
    @Override
    public PluginPick pickInteractionDialogPlugin(SectorEntityToken interactionTarget)
    {
        // The Omnifactory uses a special interaction dialog
        if (OmniFac.isFactory(interactionTarget))
        {
            // PluginPick is a wrapper that allows you to assign a priority to a plugin
            // The highest priority plugin returned by all mods' CampaignPlugins will be the one used
            return new PluginPick(new OmniFacInteractionPlugin(),
                    PickPriority.MOD_SPECIFIC);
        }

        // Returning null means this mod doesn't have a specific interaction plugin for this entity
        // If all mods return null, the vanilla interaction behavior for that entity will be used
        return null;
    }

Writing the plugin that handles interaction itself is significantly more complicated. If you open up starfarer.api.zip and look in the com/fs/starfarer/api/impl/campaign/ directory you can find some examples (anything with InteractionDialogPluginImpl in the name). Just note that you might need to change the switch statements to a series of if/else if blocks because Janino can't handle switch on enumerations.


I updated my mod to the new ModPlugin system as per LazyWizard's post and it kept calling the OnEnabled part every time a saved game was loaded -- as if it wasn't reading the "if (!wasEnabledBefore)" or rather I suppose as if wasEnabledBefore never got set. I was under the impression the game's built-in mod handling set it automatically, is there a way I can do it manually in the onNewGame? I'm sure it's really simple but I can't really into java :v

Code
     @Override
     public void onEnabled(boolean wasEnabledBefore)
     {
         if (!wasEnabledBefore)
         {
            // Calling a separate method avoids duplicate code with onNewGame()
            initVayra();
         }
     }

I fixed the problem for now by just commenting that block of code out, but that's obviously nonoptimal as it means I can't add my mod to existing games.

You should write a post in the Bug Reports section. :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on September 14, 2013, 09:16:46 PM
I'm getting an error when I go to start a new game in my mod:


Code
32318 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.K.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.OooO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.O00o.super(Unknown Source)
at com.fs.starfarer.ui.F.processInput(Unknown Source)
at com.fs.starfarer.ui.newsuper.o00000(Unknown Source)
at com.fs.starfarer.new.????00(Unknown Source)
at com.fs.oOOO.super.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

I'm using a very generic SectorGen script, something that, when put alone in a test mod, loads into the campaign just fine. However, in Obsidian Void, it crashes after hitting "start game" in the character screen.

Any ideas on what might be causing this? I'm at a total loss, as I've removed all of my custom campaign code, meaning none of my mod's files are even be aware of com.fs.starfarer.campaign.Hyperspace's existence.

...And interestingly, upon checking, com.fs.starfarer.campaign.Hyperspace doesn't seem to exist in the API. Weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on September 15, 2013, 12:51:11 AM
Welp I've tried basically doing a copy of Askonia and renaming it, but it doesn't appear on the hyperspace map as expected, so now I'm digging through how to actually add my system in, what other file do I need to modify in order to add in a system.

I've seen how Mshadowy does it, but replicating that method seems ill advised since i don't actually know how it'll turn out lol.

Do I need to put in;

Code
import data.scripts.world.systems.CoronaAustralis;

in a gen file ? or something cause idk I'm just lost lol.

Temporary file for my system:

Code
package data.scripts.world.systems;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

public class CoronaAustralis {

public void generate(SectorAPI sector) {
StarSystemAPI system = sector.createStarSystem("Corona Australis");
LocationAPI hyper = Global.getSector().getHyperspace();

system.setBackgroundTextureFilename("graphics/backgrounds/CoronaAustralis.jpg");

// create the star and generate the hyperspace anchor for this system
PlanetAPI CoronaAustralis = system.initStar("neut_star_neutron", // id in planets.json
200f, // radius (in pixels at default zoom)
2500, 3000);   // location in hyperspace

system.setLightColor(new Color(255, 255, 255)); // light color in entire system, affects all entities


/*
* addPlanet() parameters:
* 1. What the planet orbits (orbit is always circular)
* 2. Name
* 3. Planet type id in planets.json
* 4. Starting angle in orbit, i.e. 0 = to the right of the star
* 5. Planet radius, pixels at default zoom
* 6. Orbit radius, pixels at default zoom
* 7. Days it takes to complete an orbit. 1 day = 10 seconds.
*/
PlanetAPI p1 = system.addPlanet(CoronaAustralis, "Deadworld IS7", "neut_rocky_unstable", 0, 150, 2500, 100);
//PlanetAPI a2 = system.addPlanet(star, "Salus", "gas_giant", 230, 350, 7000, 250);

//PlanetAPI a21 = system.addPlanet(a2, "Cruor", "rocky_unstable", 45, 80, 800, 25);
//PlanetAPI a22 = system.addPlanet(a2, "Volturn", "water", 110, 120, 1400, 45);

//PlanetAPI a3 = system.addPlanet(star, "Umbra", "rocky_ice", 280, 150, 12000, 650);

p1.setCustomDescriptionId("neut_planet_IS7");
//a2.setCustomDescriptionId("planet_salus");
//a21.setCustomDescriptionId("planet_cruor");
//a22.setCustomDescriptionId("planet_volturn");
//a3.setCustomDescriptionId("planet_umbra");

p1.getSpec().setPlanetColor(new Color(255,215,190,255));
p1.getSpec().setAtmosphereColor(new Color(160,110,45,140));
p1.getSpec().setCloudColor(new Color(255,164,96,200));
p1.getSpec().setTilt(10);
p1.applySpecChanges();

/*
* addAsteroidBelt() parameters:
* 1. What the belt orbits
* 2. Number of asteroids
* 3. Orbit radius
* 4. Belt width
* 6/7. Range of days to complete one orbit. Value picked randomly for each asteroid.
*/
system.addAsteroidBelt(p1, 50, 1100, 128, 40, 80);


/*
* addRingBand() parameters:
* 1. What it orbits
* 2. Category under "graphics" in settings.json
* 3. Key in category
* 4. Width of band within the texture
* 5. Index of band
* 6. Color to apply to band
* 7. Width of band (in the game)
* 8. Orbit radius (of the middle of the band)
* 9. Orbital period, in days
*/
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1400, 40f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1450, 60f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1500, 80f);

system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1750, 70f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1800, 90f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1850, 110f);

system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2100, 50f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2150, 70f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2200, 80f);
system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 1, Color.white, 256f, 2250, 90f);

system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1400, 40f);
system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1450, 60f);
system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1500, 80f);

system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1750, 70f);
system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1800, 90f);
system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1850, 110f);




JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("Jump Point Alpha");
OrbitAPI orbit = Global.getFactory().createCircularOrbit(p1, 0, 400, 40);
jumpPoint.setOrbit(orbit);
jumpPoint.setRelatedPlanet(p1);
jumpPoint.setStandardWormholeToHyperspaceVisual();
system.addEntity(jumpPoint);

/*
* addPlanet() parameters:
* 1. What the planet orbits (orbit is always circular)
* 2. Name
* 3. Planet type id in planets.json
* 4. Starting angle in orbit, i.e. 0 = to the right of the star
* 5. Planet radius, pixels at default zoom
* 6. Orbit radius, pixels at default zoom
* 7. Days it takes to complete an orbit. 1 day = 10 seconds.
*/

SectorEntityToken NCstation1 = system.addOrbitalStation(CoronaAustralis, 200, 700, 90, "Small Extraction Drill", "neutrinocorp");
SectorEntityToken NCstation2 = system.addOrbitalStation(CoronaAustralis, 200, 1600, 90, "Large Processing Dock", "neutrinocorp");
SectorEntityToken NCstation3 = system.addOrbitalStation(p1, 45, 300, 50, "Small Research Station", "neutrinocorp");

initStationCargo(NCstation1);
initStationCargo(NCstation2);
initStationCargo(NCstation3);

// example of using custom visuals below
// a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
// jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
// station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));

// generates hyperspace destinations for in-system jump points
system.autogenerateHyperspaceJumpPoints(true, true);

system.addSpawnPoint(new neutrinoConvoySpawnPoint(sector, system, 7, 1, token, NCstation2));
neutrinoSpawnPoint NCSpawn1 = new neutrinoSpawnPoint(sector, system, 2, 2, NCstation1);
neutrinoSpawnPoint NCSpawn2 = new neutrinoSpawnPoint(sector, system, 2, 3, NCstation2);
neutrinoSpawnPoint NCSpawn3 = new neutrinoSpawnPoint(sector, system, 2, 1, NCstation3);

system.addSpawnPoint(NCSpawn1);
for (int i = 0; i < 2; i++) NCSpawn1.spawnFleet();
system.addSpawnPoint(NCSpawn2);
for (int i = 0; i < 2; i++) NCSpawn2.spawnFleet();
system.addSpawnPoint(NCSpawn3);
for (int i = 0; i < 2; i++) NCSpawn3.spawnFleet();





system.addScript(new IndependentTraderSpawnPoint(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), NCstation2));
}


private void initStationCargo(SectorEntityToken NCstation2) {
CargoAPI cargo = NCstation2.getCargo();
addRandomWeapons(cargo, 3);

cargo.addCrew(CrewXPLevel.VETERAN, 20);
cargo.addCrew(CrewXPLevel.REGULAR, 500);
cargo.addMarines(80);
cargo.addSupplies(2000);
cargo.addFuel(500);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
}

private void initStationCargo(SectorEntityToken NCstation3) {
CargoAPI cargo = NCstation3.getCargo();
addRandomWeapons(cargo, 5);

cargo.addCrew(CrewXPLevel.VETERAN, 69);
cargo.addCrew(CrewXPLevel.ELITE, 25);
cargo.addMarines(200);
cargo.addSupplies(600);
cargo.addFuel(200);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
}


private void addRandomWeapons(CargoAPI cargo, int count) {
List weaponIds = Global.getSector().getAllWeaponIds();
for (int i = 0; i < count; i++) {
String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
int quantity = (int)(Math.random() * 4f + 2f);
cargo.addWeapons(weaponId, quantity);
}
}

}


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 15, 2013, 12:54:29 AM
I'm getting an error when I go to start a new game in my mod:


Code
32318 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.K.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.OooO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.O00o.super(Unknown Source)
at com.fs.starfarer.ui.F.processInput(Unknown Source)
at com.fs.starfarer.ui.newsuper.o00000(Unknown Source)
at com.fs.starfarer.new.????00(Unknown Source)
at com.fs.oOOO.super.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

I'm using a very generic SectorGen script, something that, when put alone in a test mod, loads into the campaign just fine. However, in Obsidian Void, it crashes after hitting "start game" in the character screen.

Any ideas on what might be causing this? I'm at a total loss, as I've removed all of my custom campaign code, meaning none of my mod's files are even be aware of com.fs.starfarer.campaign.Hyperspace's existence.

...And interestingly, upon checking, com.fs.starfarer.campaign.Hyperspace doesn't seem to exist in the API. Weird.

I am also getting this error. I can remove/add a few things and it won't get this error, but instead I get a NullPointerException at the exact same point.

However, if I leave the single line from StarSector-core's SectorGen.java that creates the system "Corvus" it works (I just end up with an empty system called Corvus I don't want...). If I then try and put the starting position in another system, I can move around it that system but my fleet doesn't show and the framerate plummeted! (it was at this point I decided I was well into the wilderness and should stop hacking around...)

Still, hopefully it is something simple :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 15, 2013, 02:51:21 AM
Is there a functional way I can get a mod to check for other installed mods, and trigger code if they are, without crashing if they aren't?

example: I have both my Kadur Theocracy and MShadowy's Shadowyards Heavy Industries mods installed. Can I somehow write code in the Kadur Theocracy scripts to trigger if SHI is loaded and make a station in the Kadur star system send supply convoys to/from stations in the star system that Shadowyards Heavy Industries adds, without crashing the game if the SHI mod isn't installed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 15, 2013, 03:29:53 AM
Is there a functional way I can get a mod to check for other installed mods, and trigger code if they are, without crashing if they aren't?

example: I have both my Kadur Theocracy and MShadowy's Shadowyards Heavy Industries mods installed. Can I somehow write code in the Kadur Theocracy scripts to trigger if SHI is loaded and make a station in the Kadur star system send supply convoys to/from stations in the star system that Shadowyards Heavy Industries adds, without crashing the game if the SHI mod isn't installed?

This should still work:

Code
try
{
Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.SHIGen");
System.out.println("Shadowyards HI installed");
// TODO STUFF
}
catch (ClassNotFoundException ex)
{
System.out.println("Shadowyards HI not installed");
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 15, 2013, 12:38:42 PM
Guys, did anyone made a workable custom AI to use a specific weapon yet?

Ive got a repair armor beam that needs a custom AI made, but i cant seem to find a good example for me to start from, heres the code of the beam:

Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;

public class RepairArmorBeam implements BeamEffectPlugin
{  
    private IntervalUtil timer = new IntervalUtil(1f, 1f);
            
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        ShipAPI ship = beam.getSource();
        if (ship == null)
        {
            return;
        }

        if(beam.didDamageThisFrame() && timer.intervalElapsed())
        {
            ShipAPI target = (ShipAPI) beam.getDamageTarget();
            int[] armorcell = target.getArmorGrid().getCellAtLocation(beam.getTo());
            
            float armorAmount = target.getArmorGrid().getArmorValue(armorcell[0], armorcell[1]);
            float armorToFix = target.getArmorGrid().getMaxArmorInCell() - armorAmount;
            target.getArmorGrid().setArmorValue(armorcell[0], armorcell[1], armorToFix);
        }
        
        timer.advance(amount);
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on September 15, 2013, 02:46:39 PM
I am also getting this error. I can remove/add a few things and it won't get this error, but instead I get a NullPointerException at the exact same point.

However, if I leave the single line from StarSector-core's SectorGen.java that creates the system "Corvus" it works (I just end up with an empty system called Corvus I don't want...). If I then try and put the starting position in another system, I can move around it that system but my fleet doesn't show and the framerate plummeted! (it was at this point I decided I was well into the wilderness and should stop hacking around...)

Still, hopefully it is something simple :)

Strange. I still have the function call that generates the Corvus system in the Sectorgen file, and my Corvus.java is effectively blank. Still crashes though. It doesn't matter what I do to either of these files, I always get the same error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2013, 02:57:33 PM
Spoiler
I'm getting an error when I go to start a new game in my mod:


Code
32318 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.K.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.OooO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.O00o.super(Unknown Source)
at com.fs.starfarer.ui.F.processInput(Unknown Source)
at com.fs.starfarer.ui.newsuper.o00000(Unknown Source)
at com.fs.starfarer.new.????00(Unknown Source)
at com.fs.oOOO.super.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

I'm using a very generic SectorGen script, something that, when put alone in a test mod, loads into the campaign just fine. However, in Obsidian Void, it crashes after hitting "start game" in the character screen.

Any ideas on what might be causing this? I'm at a total loss, as I've removed all of my custom campaign code, meaning none of my mod's files are even be aware of com.fs.starfarer.campaign.Hyperspace's existence.

...And interestingly, upon checking, com.fs.starfarer.campaign.Hyperspace doesn't seem to exist in the API. Weird.

I am also getting this error. I can remove/add a few things and it won't get this error, but instead I get a NullPointerException at the exact same point.

However, if I leave the single line from StarSector-core's SectorGen.java that creates the system "Corvus" it works (I just end up with an empty system called Corvus I don't want...). If I then try and put the starting position in another system, I can move around it that system but my fleet doesn't show and the framerate plummeted! (it was at this point I decided I was well into the wilderness and should stop hacking around...)

Still, hopefully it is something simple :)
[close]

This should be fixed for 0.6.1a. The crash is triggered by setting the starting location for the player to be in hyperspace.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrDavidoff on September 15, 2013, 03:02:04 PM
Since 0.6a, we cant have unmanned fighters? Because they are not comabt ready, or am I missing something?

Edit - Solved
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2013, 03:06:22 PM
Why do ships with 0 crew (As in, unmanned--there shouldn't be any crew) always have 0% combat readiness? Is there a way to override the automatically-assigned 0% CR, or is this a bug?

Bug, will fix that up for 0.6.1a.

I updated my mod to the new ModPlugin system as per LazyWizard's post and it kept calling the OnEnabled part every time a saved game was loaded -- as if it wasn't reading the "if (!wasEnabledBefore)" or rather I suppose as if wasEnabledBefore never got set. I was under the impression the game's built-in mod handling set it automatically, is there a way I can do it manually in the onNewGame? I'm sure it's really simple but I can't really into java :v

Code
     @Override
     public void onEnabled(boolean wasEnabledBefore)
     {
         if (!wasEnabledBefore)
         {
            // Calling a separate method avoids duplicate code with onNewGame()
            initVayra();
         }
     }

I fixed the problem for now by just commenting that block of code out, but that's obviously nonoptimal as it means I can't add my mod to existing games.

Bug - just fixed it for 0.6.1a.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 15, 2013, 05:42:00 PM
Awesome, the good news is I figured out how to make the Jar, also the game runs without crashing.

The bad news is, I can't tell if it's even using my Planet Interaction. At the moment, I'd expect it to just run the mod's interaction, because I haven't done anything to tell it not to. But no matter what I do to the mod's planet interaction thing, it doesn't change anything.

Can't tell which part I'm doing wrong, quite possibly all of it. The whole class for the Campaign Plugin looks like this:

Code
public class vfleet_CoreCampaignPlugin extends BaseCampaignPlugin {

public String getId() {
return null;
}

public boolean isTransient() {
return false;
}

public PluginPick pickInteractionDialogPlugin(SectorEntityToken interactionTarget) {

if (interactionTarget instanceof PlanetAPI) {
return new PluginPick(new vfleet_PlanetBuildStationDialogPlugin(), PickPriority.MOD_SPECIFIC);
}

/*if (interactionTarget instanceof OrbitalStationAPI) {
return new PluginPick(new OrbitalStationInteractionDialogPluginImpl(), PickPriority.MOD_SPECIFIC);
}*/

/*if (interactionTarget instanceof CampaignFleetAPI) {
return new PluginPick(new FleetInteractionDialogPluginImpl(), PickPriority.MOD_SPECIFIC);
}*/

return null;
}
}

(No, I have no idea what I'm doing.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2013, 05:44:54 PM
Did you register the plugin using Global.getSector().registerPlugin? Since your plugin isn't transient, you should do it in ModPlugin.onNewGame(). (Ideally, you'd do it in ModPlugin.onEnabled(), but that's currently broken and gets called on every game load. Fixed for next release.)

Congrats on putting a jar together!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2013, 05:47:21 PM
@Psiyon/Zaphide: Could one of you guys send me a copy of your mod that's having this issue?
318 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
I'd like to make sure that this is indeed fixed and stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on September 15, 2013, 07:49:39 PM
I must be the only one here who doesn't actually get how to implement systems lol...
Or is the trouble because I'm trying to keep a station in corvus but can't use the gen file to create the 2nd system? blah idk.

It doesn't even give an error, it just doesn't ... show up.. >.>
I've taken the Askonia.java as a base and renamed everything relevant, but what else do I need to do to actually bring it the hyperspace map?
I see lines like in the sectorgen file, but if I add in my own, it'll just crash,
Code
import data.scripts.world.corvus.Corvus;
import data.scripts.world.systems.Askonia;
new Askonia().generate(sector);
new Corvus().generate(sector);


System tutorial please!  ::)
Spoiler
Welp I've tried basically doing a copy of Askonia and renaming it, but it doesn't appear on the hyperspace map as expected, so now I'm digging through how to actually add my system in, what other file do I need to modify in order to add in a system.

I've seen how Mshadowy does it, but replicating that method seems ill advised since i don't actually know how it'll turn out lol.

Do I need to put in;

Code
import data.scripts.world.systems.CoronaAustralis;

in a gen file ? or something cause idk I'm just lost lol.

Temporary file for my system:

Code
package data.scripts.world.systems;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

public class CoronaAustralis {

   public void generate(SectorAPI sector) {
      StarSystemAPI system = sector.createStarSystem("Corona Australis");
      LocationAPI hyper = Global.getSector().getHyperspace();
      
      system.setBackgroundTextureFilename("graphics/backgrounds/CoronaAustralis.jpg");
      
      // create the star and generate the hyperspace anchor for this system
      PlanetAPI CoronaAustralis = system.initStar("neut_star_neutron", // id in planets.json
                               200f,       // radius (in pixels at default zoom)
                               2500, 3000);   // location in hyperspace
      
      system.setLightColor(new Color(255, 255, 255)); // light color in entire system, affects all entities
      

      /*
       * addPlanet() parameters:
       * 1. What the planet orbits (orbit is always circular)
       * 2. Name
       * 3. Planet type id in planets.json
       * 4. Starting angle in orbit, i.e. 0 = to the right of the star
       * 5. Planet radius, pixels at default zoom
       * 6. Orbit radius, pixels at default zoom
       * 7. Days it takes to complete an orbit. 1 day = 10 seconds.
       */
      PlanetAPI p1 = system.addPlanet(CoronaAustralis, "Deadworld IS7", "neut_rocky_unstable", 0, 150, 2500, 100);
      //PlanetAPI a2 = system.addPlanet(star, "Salus", "gas_giant", 230, 350, 7000, 250);
      
      //PlanetAPI a21 = system.addPlanet(a2, "Cruor", "rocky_unstable", 45, 80, 800, 25);
      //PlanetAPI a22 = system.addPlanet(a2, "Volturn", "water", 110, 120, 1400, 45);
      
      //PlanetAPI a3 = system.addPlanet(star, "Umbra", "rocky_ice", 280, 150, 12000, 650);
      
      p1.setCustomDescriptionId("neut_planet_IS7");
      //a2.setCustomDescriptionId("planet_salus");
      //a21.setCustomDescriptionId("planet_cruor");
      //a22.setCustomDescriptionId("planet_volturn");
      //a3.setCustomDescriptionId("planet_umbra");
      
      p1.getSpec().setPlanetColor(new Color(255,215,190,255));
      p1.getSpec().setAtmosphereColor(new Color(160,110,45,140));
      p1.getSpec().setCloudColor(new Color(255,164,96,200));
      p1.getSpec().setTilt(10);
      p1.applySpecChanges();
      
      /*
       * addAsteroidBelt() parameters:
       * 1. What the belt orbits
       * 2. Number of asteroids
       * 3. Orbit radius
       * 4. Belt width
       * 6/7. Range of days to complete one orbit. Value picked randomly for each asteroid.
       */
      system.addAsteroidBelt(p1, 50, 1100, 128, 40, 80);
      
      
      /*
       * addRingBand() parameters:
       * 1. What it orbits
       * 2. Category under "graphics" in settings.json
       * 3. Key in category
       * 4. Width of band within the texture
       * 5. Index of band
       * 6. Color to apply to band
       * 7. Width of band (in the game)
       * 8. Orbit radius (of the middle of the band)
       * 9. Orbital period, in days
       */
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1400, 40f);
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1450, 60f);
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 2, Color.white, 256f, 1500, 80f);
      
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1750, 70f);
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1800, 90f);
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 3, Color.white, 256f, 1850, 110f);
      
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2100, 50f);
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2150, 70f);
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 0, Color.white, 256f, 2200, 80f);
      system.addRingBand(CoronaAustralis, "misc", "rings1", 256f, 1, Color.white, 256f, 2250, 90f);      
      
      system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1400, 40f);
      system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1450, 60f);
      system.addRingBand(p1, "misc", "rings1", 256f, 2, Color.white, 256f, 1500, 80f);

      system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1750, 70f);
      system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1800, 90f);
      system.addRingBand(p1, "misc", "rings1", 256f, 3, Color.white, 256f, 1850, 110f);

      
      
      
      JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("Jump Point Alpha");
      OrbitAPI orbit = Global.getFactory().createCircularOrbit(p1, 0, 400, 40);
      jumpPoint.setOrbit(orbit);
      jumpPoint.setRelatedPlanet(p1);
      jumpPoint.setStandardWormholeToHyperspaceVisual();
      system.addEntity(jumpPoint);

      /*
       * addPlanet() parameters:
       * 1. What the planet orbits (orbit is always circular)
       * 2. Name
       * 3. Planet type id in planets.json
       * 4. Starting angle in orbit, i.e. 0 = to the right of the star
       * 5. Planet radius, pixels at default zoom
       * 6. Orbit radius, pixels at default zoom
       * 7. Days it takes to complete an orbit. 1 day = 10 seconds.
       */
      
      SectorEntityToken NCstation1 = system.addOrbitalStation(CoronaAustralis, 200, 700, 90, "Small Extraction Drill", "neutrinocorp");      
      SectorEntityToken NCstation2 = system.addOrbitalStation(CoronaAustralis, 200, 1600, 90, "Large Processing Dock", "neutrinocorp");            
      SectorEntityToken NCstation3 = system.addOrbitalStation(p1, 45, 300, 50, "Small Research Station", "neutrinocorp");
      
      initStationCargo(NCstation1);
      initStationCargo(NCstation2);
      initStationCargo(NCstation3);
      
      // example of using custom visuals below
//      a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
//      jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
//      station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));
      
      // generates hyperspace destinations for in-system jump points
      system.autogenerateHyperspaceJumpPoints(true, true);
      
      system.addSpawnPoint(new neutrinoConvoySpawnPoint(sector, system, 7, 1, token, NCstation2));
      neutrinoSpawnPoint NCSpawn1 = new neutrinoSpawnPoint(sector, system, 2, 2, NCstation1);         
      neutrinoSpawnPoint NCSpawn2 = new neutrinoSpawnPoint(sector, system, 2, 3, NCstation2);   
      neutrinoSpawnPoint NCSpawn3 = new neutrinoSpawnPoint(sector, system, 2, 1, NCstation3);         
            
      system.addSpawnPoint(NCSpawn1);
      for (int i = 0; i < 2; i++) NCSpawn1.spawnFleet();         
      system.addSpawnPoint(NCSpawn2);
      for (int i = 0; i < 2; i++) NCSpawn2.spawnFleet();      
      system.addSpawnPoint(NCSpawn3);
      for (int i = 0; i < 2; i++) NCSpawn3.spawnFleet();   




   
      system.addScript(new IndependentTraderSpawnPoint(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), NCstation2));
   }
   
   
   private void initStationCargo(SectorEntityToken NCstation2) {
      CargoAPI cargo = NCstation2.getCargo();
      addRandomWeapons(cargo, 3);
      
      cargo.addCrew(CrewXPLevel.VETERAN, 20);
      cargo.addCrew(CrewXPLevel.REGULAR, 500);
      cargo.addMarines(80);
      cargo.addSupplies(2000);
      cargo.addFuel(500);
      
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
   }

   private void initStationCargo(SectorEntityToken NCstation3) {
      CargoAPI cargo = NCstation3.getCargo();
      addRandomWeapons(cargo, 5);
      
      cargo.addCrew(CrewXPLevel.VETERAN, 69);
      cargo.addCrew(CrewXPLevel.ELITE, 25);      
      cargo.addMarines(200);
      cargo.addSupplies(600);
      cargo.addFuel(200);
      
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
   }

   
   private void addRandomWeapons(CargoAPI cargo, int count) {
      List weaponIds = Global.getSector().getAllWeaponIds();
      for (int i = 0; i < count; i++) {
         String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
         int quantity = (int)(Math.random() * 4f + 2f);
         cargo.addWeapons(weaponId, quantity);
      }
   }
   
}




[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 15, 2013, 10:33:47 PM
Thanks! Putting a Jar together seems like something simple, but all of my Java experience was from High School Computer Science and early College Level, so my knowledge is pretty limited, all things considered.

Anyhoo, Talking to planets while holding a "Station Building Contract" after selecting the "Build" option that only appears when you are holding said item works, and does everything I'd ever want it to.

I've started setting up the Interactions for the actual stations, and I'm noticing right off the bat that Eclipse doesn't like the org.lwjgl part of the Keyboard input, "cannot be resolved"

No clue how to fix that >_<
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 16, 2013, 12:33:36 AM
@Psiyon/Zaphide: Could one of you guys send me a copy of your mod that's having this issue?
318 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
java.lang.ClassCastException: com.fs.starfarer.campaign.Hyperspace cannot be cast to com.fs.starfarer.api.campaign.StarSystemAPI
I'd like to make sure that this is indeed fixed and stuff.

Hi Alex,

Sounds like you had already worked it out but I realised after posting that that if I do the following:
Code
sector.setCurrentLocation(system);
sector.setRespawnLocation(system);
sector.getRespawnCoordinates().set(-2500, -3500);

when building my first systems it doesn't have the error (in either the cast exception or the null reference form).

Anyways, to get a version that will throw the error grab this:
https://bitbucket.org/Zaphide/exerelin/get/FactionsRemoved.zip (https://bitbucket.org/Zaphide/exerelin/get/FactionsRemoved.zip)

That doesn't set the current location or spawn location.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on September 16, 2013, 12:40:25 AM
I`ve got a very minor question - what is 'range' used for in 0.6a? We have fuel capacity and fuel per LY that seem to cover the whole fuel system. Range is just fuel/fuel per LY, so it looks like a helper of sorts rather than a major value (like '8/6/5/4%' for flux).

Am i right? Or does it actually have some impact on the game (like telling the AI how long it can fly before running out of fuel)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 16, 2013, 05:28:10 AM
I must be the only one here who doesn't actually get how to implement systems lol...

Fear not! You're not alone.
I am kind of hoping that someone chews out a template for poor idiots like me. >_>
I'll get it right eventually, but all this trial and error'ing is hurting my brain. x)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 16, 2013, 11:58:11 AM
I`ve got a very minor question - what is 'range' used for in 0.6a? We have fuel capacity and fuel per LY that seem to cover the whole fuel system. Range is just fuel/fuel per LY, so it looks like a helper of sorts rather than a major value (like '8/6/5/4%' for flux).

Am i right? Or does it actually have some impact on the game (like telling the AI how long it can fly before running out of fuel)?

You're right, it's just a helper value.


@Zaphide: Thanks! Good to have confirmed that this is indeed the issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 16, 2013, 01:39:00 PM
Actually, note: you should ideally be using CharacterCreationData.setStartingLocationName() in your character creation process. SectorAPI.setCurrentLocation() works too, though.

(If you need to set the starting location to hyperspace, use CharacterCreationData.HYPERSPACE_NAME_TOKEN as the starting location name.)

I've started setting up the Interactions for the actual stations, and I'm noticing right off the bat that Eclipse doesn't like the org.lwjgl part of the Keyboard input, "cannot be resolved"

No clue how to fix that >_<

Probably just need to add the various lwjgl-related jars to your build path. jinput.jar in particular, I *think* Keyboard is there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 16, 2013, 02:36:40 PM
Actually, note: you should ideally be using CharacterCreationData.setStartingLocationName() in your character creation process. SectorAPI.setCurrentLocation() works too, though.

(If you need to set the starting location to hyperspace, use CharacterCreationData.HYPERSPACE_NAME_TOKEN as the starting location name.)
--- snip ---

I think in 0.54 it did the generation after the CharacterCreation stuff, I'm assuming that is still the case? (haven't really looked)

Given the above assumption is correct, and I'm generating a random sector/systems, I won't know the name of a valid system prior to generation? Could take a guess but... :)



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 16, 2013, 03:02:06 PM
Alright, yeah that was pretty simple :p.

So far I've gotten most of it working how I want it to, I'm just trying to find a good way to display what the stations are doing to the player visually.

Is there is a way to have text or other assets displayed on the screen, perhaps underneath the picture that's already there? These UI Panels are making my head spin, and it looks ugly to have it displayed in the text window above.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on September 16, 2013, 03:55:21 PM
Should I call addScript only once onNewGame, or every onGameLoad? (or in onEnabled? I suppose I'm asking where to call sector.addScript() as well as how often :) )

I'm currently guessing onGameLoad - I don't think anything too terrible will happen if it runs more than once, but eventually it's going to start slowing everything down if it's running multiple times, so I'd like to know for sure please.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on September 16, 2013, 04:31:39 PM
Alright, yeah that was pretty simple :p.

So far I've gotten most of it working how I want it to, I'm just trying to find a good way to display what the stations are doing to the player visually.

Is there is a way to have text or other assets displayed on the screen, perhaps underneath the picture that's already there? These UI Panels are making my head spin, and it looks ugly to have it displayed in the text window above.

And thanks to you I got it working too! Given, creating an 1.6jdk jar was a pain to understand (with netbeans).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 16, 2013, 05:48:24 PM
Actually, note: you should ideally be using CharacterCreationData.setStartingLocationName() in your character creation process. SectorAPI.setCurrentLocation() works too, though.

(If you need to set the starting location to hyperspace, use CharacterCreationData.HYPERSPACE_NAME_TOKEN as the starting location name.)
--- snip ---

I think in 0.54 it did the generation after the CharacterCreation stuff, I'm assuming that is still the case? (haven't really looked)

Given the above assumption is correct, and I'm generating a random sector/systems, I won't know the name of a valid system prior to generation? Could take a guess but... :)

setStartingLocationName() is new in 0.6a.

Hmm... yeah, this is a problem. What you could do is set that start location to hyperspace, and then use SectorAPI.setCurrentLocation(), and then remove the fleet from hyper + add it to the system you'd like it to be in. Or just leave it starting hyper. Except that won't work til 0.6.1a, so for now the only real solution is to hardcode at least 1 system name and THEN move it to wherever you actually want it to start.

One note: you'll have to do it in onGameLoad() or onEnabled() and then save a flag in the persisted data, or somewhere else. onNewGame is called before the player fleet actually exists.


Is there is a way to have text or other assets displayed on the screen, perhaps underneath the picture that's already there? These UI Panels are making my head spin, and it looks ugly to have it displayed in the text window above.

There is not. The text always goes in the top left section.


Should I call addScript only once onNewGame, or every onGameLoad? (or in onEnabled? I suppose I'm asking where to call sector.addScript() as well as how often :) )

I'm currently guessing onGameLoad - I don't think anything too terrible will happen if it runs more than once, but eventually it's going to start slowing everything down if it's running multiple times, so I'd like to know for sure please.

Depends on if the script's isTransient() returns true or false. Transient scripts should be added onGameLoad - this is the preferred way to do things because then, if the mod is disabled, the scripts don't stick around and the savegame can be played w/o the mod. If the script is not transient, it should be added onNewGame. (Ideally, onModEnabled(), but right now, due to a bug, that gets called on every load.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 17, 2013, 06:48:00 AM
So, thanks to LazyWizard I now have a sector, which still needs a lot of work.
The one thing that struck me first though was this:

Spoiler
(http://avatar.home.xs4all.nl/crap/screenshotsun1.png)
(http://avatar.home.xs4all.nl/crap/screenshotsun2.png)
[close]

I don't think the Hiigarans will live long, what with this supernova going on.
My star is actually smaller than the Askonian one, I have no idea what's causing this.
The texture used is 1024x512 in size.

Has anyone come across this perhaps?

@silentstormpt VVV - if all else fails I'll do that. x)

Edit: Atmosphere thickness was too high. It was 10 while vanilla value for Corus' sun was 0.25.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 17, 2013, 07:24:24 AM
Alright, just set the  background texture to a white one and change the star color to red.

BANZAI!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 17, 2013, 08:38:37 AM
Ooooookaaaaayyy.  I've been wrestling with a completely bizarre error.  It's only popping up in the Mission List refit screen; good thing too, else the campaign would be unplayable since it leads to a sudden and unhelpful CTD.

I've managed to determine that it is somehow related to the ejector seat hullmod I added to Shadowyards fighters, but I have no idea how.  Comparing it to existing hullmods reveals nothing that should cause the error and the code is obviously not causing this error in campaign.  Since it doesn't appear to be effecting other custom hullmods I've been grasping at straws; I tried removing the hull size limitations, to no effect, as well as removing it from the fighters, as well as turning on onEnable in the ModPlugin file I've added and reverting to generators.csv in increasingly wacky ploys to figure out where this problem is coming from.

The hull mod (which still looks fine)
Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class ms_enjector extends BaseHullMod {

public static final float CASUALTY_REDUCTION = 66f;

    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getCrewLossMult().modifyMult(id, 1f - CASUALTY_REDUCTION * 0.01f);
}

    public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + (int) CASUALTY_REDUCTION;
return null;
}

public boolean isApplicableToShip(ShipAPI ship) {
return (ship.getHullSize() == HullSize.FIGHTER);
}
}


And the completely unhelpful error log.
Code
java.util.UnknownFormatConversionException: Conversion = '.'
java.util.UnknownFormatConversionException: Conversion = '.'
at java.util.Formatter.checkText(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at com.fs.starfarer.loading.specs.voidsuper.new(Unknown Source)
at com.fs.starfarer.coreui.refit.ModPickerDialog$o.<init>(Unknown Source)
at com.fs.starfarer.coreui.refit.ModPickerDialog.Ööo000(Unknown Source)
at com.fs.starfarer.coreui.refit.ModPickerDialog.<init>(Unknown Source)
at com.fs.starfarer.coreui.refit.C.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.O00oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.ui.F.processInput(Unknown Source)
at com.fs.starfarer.ui.T.super(Unknown Source)
at com.fs.starfarer.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.float.if$super(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.super(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

At this point I suspect I may just be getting a bug with openjdk.  Anyone know what's up?

E: Oh, and I should probably note that I know the hullmod is causing it because removing it caused the crashing to stop.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on September 17, 2013, 09:02:00 AM
Hm... I'd guess that the description string isn't formatted right.  Not quite sure where that string is hiding, though, probably some csv file somewhere?

Edit: Note that I'm not talking about the string being returned by getDescriptionParam - that's getting substituted into a description string that lives somewhere else, and it's that other string that probably has formatting issues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 17, 2013, 09:19:41 AM
be careful:

return "" + (int) CASUALTY_REDUCTION;

should be something like

return Integer.toString((int) CASUALTY_REDUCTION);
or
return String.valueOf((int) CASUALTY_REDUCTION);
or
return String.valueOf(CASUALTY_REDUCTION);
or
return Float.toString(CASUALTY_REDUCTION);

personally the best option is the 3rd or 4th since it directly converts float to String.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on September 17, 2013, 09:23:36 AM
@Silentstormpt: Why?  I can't see any particular advantage to using those, and the third option in particular is critically flawed in that it won't round - and, given floating point inaccuracy, you might end up with a string that looks like "3.00000001" instead of the desired "3".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 17, 2013, 09:27:46 AM
@Silentstormpt: Why?  I can't see any particular advantage to using those, and the third option in particular is critically flawed in that it won't round - and, given floating point inaccuracy, you might end up with a string that looks like "3.00000001" instead of the desired "3".

In hes case not really since its a default 66f, if that was the case the 1st and 2nd option i posted would be correct (meaning your right).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 17, 2013, 09:42:31 AM
Hm... I'd guess that the description string isn't formatted right.  Not quite sure where that string is hiding, though, probably some csv file somewhere?

Edit: Note that I'm not talking about the string being returned by getDescriptionParam - that's getting substituted into a description string that lives somewhere else, and it's that other string that probably has formatting issues.

Derp, that was it.  While running my comparisons with other hullmods, I did check the csv file, which does hold the descriptions, but completely failed to realize the using a "%" symbol made a call to an external file, so it was looking for "%." which didn't exist.  Derp derp derpity doop.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 17, 2013, 10:25:07 AM
How much distance in px, does 1 fuel allow?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2013, 10:41:10 AM
Hm... I'd guess that the description string isn't formatted right.  Not quite sure where that string is hiding, though, probably some csv file somewhere?

Edit: Note that I'm not talking about the string being returned by getDescriptionParam - that's getting substituted into a description string that lives somewhere else, and it's that other string that probably has formatting issues.

Derp, that was it.  While running my comparisons with other hullmods, I did check the csv file, which does hold the descriptions, but completely failed to realize the using a "%" symbol made a call to an external file, so it was looking for "%." which didn't exist.  Derp derp derpity doop.

Btw: if you want a % in the description, use %%.


How much distance in px, does 1 fuel allow?

Depends on the fuel per light year stat of the ship. How many pixels per light year is defined in settings.json; currently it's 2000.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 17, 2013, 12:57:30 PM
Are four jump points the minimum? I always get an extra fringe jump point which I don't want, but I can't see a way to remove it.
(My system always has two fringe jump points.)

Does this have anything to do with it?
system.autogenerateHyperspaceJumpPoints(true, true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 17, 2013, 01:26:18 PM
Are four jump points the minimum? I always get an extra fringe jump point which I don't want, but I can't see a way to remove it.
(My system always has two fringe jump points.)

Does this have anything to do with it?
system.autogenerateHyperspaceJumpPoints(true, true);

Yes the first one is if you want to generate hyperspace entrances on Gas Giants,
the second one asks if you want a fringe jump gate generated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2013, 01:27:53 PM
Two fringe points is a symptom of your system being added to the game twice. Probably because you've got it in both onNewGame and onEnabled? Something like that.

For the second question: yes, it does, but that'd only generate one fringe point. Take a look at the javadoc here to see what the parameters mean:
http://fractalsoftworks.com/starfarer.api/index.html?com/fs/starfarer/api/campaign/StarSystemAPI.html


(You don't *have* to autogenerate any jump points, btw. Could do it all by hand, but it's trickier.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 17, 2013, 01:53:54 PM
I did a search through my mod and yes, both OnNewGame and OnEnabled were both present.
Got it fixed now.

Damn, this community is the greatest. Solving problems like there's no tomorrow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 17, 2013, 02:42:15 PM
I've got another question.
This is the script in my mod that causes Hiigaran supply ships to spawn near the border of its system.
Spoiler
Code
package data.scripts.world;

import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;

@SuppressWarnings("unchecked")
public class HiigaraConvoySpawnPoint extends BaseSpawnPoint {

private final SectorEntityToken convoyDestination;

public HiigaraConvoySpawnPoint(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor,
SectorEntityToken convoyDestination) {
super(sector, location, daysInterval, maxFleets, anchor);
this.convoyDestination = convoyDestination;
}

private static int convoyNumber = 0;

@Override
protected CampaignFleetAPI spawnFleet() {
String type = null;
float r = (float) Math.random();
if (r > 0.9f) {
type = "fuelConvoy";
} else if (r > 0.6f) {
type = "explorationFleet";
} else {
type = "supplyConvoy";
}

float angle = (float) ((float) Math.random() * Math.PI * 2f);
float x = (float) (Math.cos(angle) * 18000f);
float y = (float) (Math.sin(angle) * 18000f);

CampaignFleetAPI fleet = getSector().createFleet("hiigaran_descendants", type);
getLocation().spawnFleet(getAnchor(), x, y, fleet);

if (type.equals("supplyConvoy")) {
CargoAPI cargo = fleet.getCargo();
addRandomWeapons(cargo, 8);
}
else if (type.equals("explorationFleet")) {
CargoAPI cargo = fleet.getCargo();
cargo.addCrew(CrewXPLevel.ELITE, 10);
      cargo.addCrew(CrewXPLevel.VETERAN, 50);
      cargo.addCrew(CrewXPLevel.REGULAR, 100);
}
else if (type.equals("fuelConvoy")) {
CargoAPI cargo = fleet.getCargo();
cargo.addFuel(250);
}

addRandomShips(fleet.getCargo(), (int) (Math.random() * 4f));

Script script = null;
if (type.equals("supplyConvoy")) {
script = createArrivedScript();
Global.getSectorAPI().addMessage("A Hiigaran supply convoy is in-system and under way to rendezvous with the New Hiigaran Orbital Station");
}

fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000, script);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);

return fleet;
}

private Script createArrivedScript() {
return new Script() {
public void run() {
Global.getSectorAPI().addMessage("A Hiigaran transport fleet has delivered new equipment to their station");
}
};
}

private void addRandomWeapons(CargoAPI cargo, int count) {
List weaponIds = getSector().getAllWeaponIds();
for (int i = 0; i < count; i++) {
      String weapon = (String) weapons[(int) (weapons.length * Math.random())];
int quantity = (int)(Math.random() * 4f + 2f);
cargo.addWeapons(weapon, quantity);

}
}

private void addRandomShips(CargoAPI cargo, int count) {
List weaponIds = getSector().getAllWeaponIds();
for (int i = 0; i < count; i++) {
if ((float) Math.random() > 0.5f) {
String wing = (String) wings[(int) (wings.length * Math.random())];
cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, wing, null);
} else {
String ship = (String) ships[(int) (ships.length * Math.random())];
cargo.addMothballedShip(FleetMemberType.SHIP, ship, null);
}
}
}

private static String [] ships = {
"hii_fiirkan_Hull",
"hii_jet_Hull",
"hii_kaan_Hull",
"hii_rathan_Hull",
"hii_vraan_Hull",
"hii_vaahrok_Hull",
};

private static String [] wings = {
"hii_tarii_wing",
"hii_toba_wing",
"hii_heeshk_wing",
"hii_raachok_wing",
};

private static String [] weapons = {
"hii_pulsar_beam",
"hii_sustained_ion_beam",
"hii_sustained_ion_beam_xl",
"hii_accelerated_pulsar_beam_sm",
"hii_accelerated_pulsar_beam",
"hii_singularity_cannon",
"hii_flak_cannon",
"hii_kinetic_driver",
"hii_chaingun_medium",
"hii_chaingun_large",
"hii_chaingun_medium_he",
"hii_chaingun_large_he",
"hii_kinetic_burst_cannon",
"hii_kinetic_burst_cannon_large",
"hii_kinetic_burst_cannon_he",
"hii_kinetic_burst_cannon_large_he",
"hii_single_cannon",
"hii_cor_missile_pod",
"hii_cor_missile_pod_xl",
"hii_tviir_launcher",
"hii_torpedo_launcher",
"hii_abas_missile_pod",
"hii_abas_missile_pod_xl",
};
}
[close]

I'd like to have the supply fleets spawn from one of the wormholes instead. But how would that be done?

I take it that I'd need to remove this and that it would need to be replaced with something else?
Code
		float angle = (float) ((float) Math.random() * Math.PI * 2f);
float x = (float) (Math.cos(angle) * 18000f);
float y = (float) (Math.sin(angle) * 18000f);

CampaignFleetAPI fleet = getSector().createFleet("hiigaran_descendants", type);
getLocation().spawnFleet(getAnchor(), x, y, fleet);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 17, 2013, 10:18:24 PM
Is there a functional way I can get a mod to check for other installed mods, and trigger code if they are, without crashing if they aren't?

example: I have both my Kadur Theocracy and MShadowy's Shadowyards Heavy Industries mods installed. Can I somehow write code in the Kadur Theocracy scripts to trigger if SHI is loaded and make a station in the Kadur star system send supply convoys to/from stations in the star system that Shadowyards Heavy Industries adds, without crashing the game if the SHI mod isn't installed?

This should still work:

Code
try
{
Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.SHIGen");
System.out.println("Shadowyards HI installed");
// TODO STUFF
}
catch (ClassNotFoundException ex)
{
System.out.println("Shadowyards HI not installed");
}

Coming back to this now :P

I thought it was working, but as it turns out I need to import chunks of the other mod to do stuff (in this case spawn fleets from it). The problem being, if the mod isn't turned "on" in the mods menu when you start Starsector (or presumably also if it's not installed at all) it crashes trying to import a thing that it can't.

So I guess what I'm really asking is this: Is there either a way to catch failed imports or a way to only import something if it exists? Google has failed me, you guys are my only hope. My approach to scripting/coding is pretty much just bashing my forehead on the keyboard and forgetting commas and semicolons, so my attempts at figuring it out on my own have not met with any success.

edit: I can see that the way Exerelin was doing it did work, since I played that for a long time without the optional faction mods installed and it obv. didn't crash. I'll keep digging and see if I can figure out where I'm going wrong.
Title: Any method of implementing aptitudes/skills in missions?
Post by: TimeDiver on September 17, 2013, 10:55:33 PM
A general search of the forums hasn't provided much info on the following, so I ask in detail: Is implementing aptitudes/skills in missions possible via scripting?

I've seen one mod (Verrius' Fleet Control Mod) that can directly affect the aptitude/skill level(s) of other fleets (in a campaign), but only by calling MutableCharacterStatsAPI via CampaignFleetAPI.

Since playing missions from within the campaign isn't possible from what I've gathered, is there a way to implement the above, much in the same way that running a combat simulation within the campaign factors in the player's aptitudes/skills, unlike when loading said simulation from the Missions menu?

Granted, I'm not expecting to be able to force the 'Character' UI tab to display, but more along the lines of defining friendly/enemy fleet aptitude/skill levels for a single mission in the .java file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 18, 2013, 01:01:34 AM
@Varya
Hmmm i think that loading things from mods a user has disabled is probably not the best approach. They may be disabled for a reason.

The code I posted just checks for the existence of a class. The class you check for should be unique for the mod your checking for, and if that class exists then you can assume that mod in its entirety has been loaded.

Regardless, it sounds like you want to use scripts from the other mod, without those scripts being in you mod. In Exerelin, I just use the other mods assets (art, hulls, variants etc) which are not scripts. Scripts in StarSector are Java classes, and those classes need to exist at compile time (StarSector initial load) otherwise it will say 'class not found'. As this happens at compile time, you can't try/catch to handle any errors.

I think you will either have to write generic scripts that you can use for any faction (similar to the way Exerelin does it) or have copies of the other mods scripts in your mod so that it passes the compile check, and then you can use those scripts only if te other mod is loaded as well (using the above code snippet).

Hopefully that makes (some sort of) sense :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 18, 2013, 01:04:40 AM
@Varya
Hmmm i think that loading things from mods a user has disabled is probably not the best approach. They may be disabled for a reason.

I was trying to get it to only load the scripts if they were enabled, or continue without them if they were disabled.  :P
 
The code I posted just checks for the existence of a class. The class you check for should be unique for the mod your checking for, and if that class exists then you can assume that mod in its entirety has been loaded.

Regardless, it sounds like you want to use scripts from the other mod, without those scripts being in you mod. In Exerelin, I just use the other mods assets (art, hulls, variants etc) which are not scripts. Scripts in StarSector are Java classes, and those classes need to exist at compile time (StarSector initial load) otherwise it will say 'class not found'. As this happens at compile time, you can't try/catch to handle any errors.

I think you will either have to write generic scripts that you can use for any faction (similar to the way Exerelin does it) or have copies of the other mods scripts in your mod so that it passes the compile check, and then you can use those scripts only if te other mod is loaded as well (using the above code snippet).


Hopefully that makes (some sort of) sense :)


This was really helpful, thank you.  ;D

edit: Ok, new question. I have a ship system that is essentially just a burn drive with some variables changed. One of those variables is the flameout on impact chance being 1, i.e. guaranteed to happen if you crash. Problem is, if that happens the ship keeps going -- at it's increased speed, too -- until the engines come back online from the flameout!

How fix? :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 18, 2013, 07:57:06 AM
Heres a piece of code some might be interested in, its basically a self armor repair, all you need is the target (ShipAPI) set and do this condition in a IntervalTimer to prevent a infinite loop:

Code: java
            float[][] armorgrid = target.getArmorGrid().getGrid();      
            for(int line = 0;line < armorgrid.length;line++)
            {
                //for each line, we got several columns
                for(int column = 0;column < armorgrid[line].length;column++)
                {
                    float armorAmount = Math.round(target.getArmorGrid().getArmorValue(line,column));
                    //Math.round prevents unnecessary huge float numbers that might come out from this.
                    float armorToFix = target.getArmorGrid().getMaxArmorInCell() - armorAmount;
                    target.getArmorGrid().setArmorValue(line, column, armorToFix);
                }
            }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 18, 2013, 10:11:35 AM
@TimeDiver: You can set the skills/aptitudes of individual captains, like so:
      FleetMemberAPI fleetMember;
      fleetMember = api.addToFleet(FleetSide.PLAYER, "venture_Balanced", FleetMemberType.SHIP, "ISS Hamatsu", false);
      fleetMember.getCaptain().getStats().setAptitudeLevel(id, level)
      fleetMember.getCaptain().getStats().setSkillLevel(id, level);


Unless I'm forgetting something, it's not possible to apply fleetwide skill effects this way, though - just the "piloted ship" ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on September 18, 2013, 02:45:06 PM
Thanks for that info, Alex! Can't imagine how busy you must be, ironing out the numerous kinks for v0.6.1a...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 18, 2013, 02:51:45 PM
This probably has been asked before, but what do the two numbers do in a spawn line like this?

HiigaraPirateSpawnPoint pirateSpawn = new HiigaraPirateSpawnPoint(sector, system, 1, 40, system.getEntityByName("Kohntala"));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dayshine on September 18, 2013, 03:16:10 PM
This probably has been asked before, but what do the two numbers do in a spawn line like this?

HiigaraPirateSpawnPoint pirateSpawn = new HiigaraPirateSpawnPoint(sector, system, 1, 40, system.getEntityByName("Kohntala"));


From BaseSpawnPoint.java:

Code
public BaseSpawnPoint(SectorAPI sector, LocationAPI location, 
float daysInterval, int maxFleets, SectorEntityToken anchor)

The two numbers are the minimum number of days between two spawns and the maximum number of fleets to be deployed.

Code
if (clock.getElapsedDaysSince(lastSpawnTime) >= daysInterval) {
  //Try to spawn a fleet
}

It just tracks the last time it tried to spawn a fleet, then compares days elapsed to the value.

Code
if (fleets.size() < maxFleets) {
  //Actually spawn a fleet
}

If it is time to spawn a new fleet it prunes all dead fleets then tries to spawn a fleet. If there are too many it doesn't, but still counts this as the last time a fleet was spawned. So it won't try more than every daysInterval, stops insta-replacements I guess.

Of course you can override this behavior by changing the public void advance(float amount) method and make it spawn based on whatever you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 18, 2013, 03:22:12 PM
Ah, thank you. Much obliged.

Of course you can override this behavior by changing the public void advance(float amount) method and make it spawn based on whatever you want.

Well, someone could. But I have no idea what you're talking about. ^_^'
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on September 18, 2013, 03:29:03 PM
the 'public void advance(float amount)' method is a method that exists on all SpawnPoints and EveryFramePlugins.

Basically, if you have one of those, and you put code in advance(), it will be called every frame(if you're in the right location).  The parameter 'amount' will be set to a floating point value (number with a decimal bit, like... 4.8 for example) equal to how many seconds have passed since advance() was last called.

So, if you really wanted a spawnpoint to spawn a fleet every real-time 18.7 seconds, that would be how you do it: Have a variable, add up the amount values each time advance() is called, and when it's greater than 18.7, zero it(sic) and spawn the fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 18, 2013, 03:33:04 PM
*head exploded*
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on September 18, 2013, 07:23:05 PM
Having a bit of a problem: AI fleets don't seem to ever want to engage hostiles. Despite the fact that there's a massive, like, 6-way war going on with about 40 or so fleets in play at once, it's extremely rare to actually see two enemies engage each other. They'll just continue on wandering the system, with their current assignment reading "patrolling" or "raiding". Even if an enemy fleet is right next to them, they'll almost never pursue each other.

So, my question is: is there anything I can do to change the aggressiveness of AI fleets? Because as it stands, I've got a system with maxed-out fleets that are just wandering around and doing nothing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 18, 2013, 09:04:38 PM
I think I broke something, was never good with null pointer errors:

Nevermind

Quote
4455 [Thread-9]
4456 [Thread-6] INFO  com.fs.profiler.Profiler  - ID     Calls   Duration    Percent
4456 [Thread-6] INFO  com.fs.profiler.Profiler  - --------------------------------
4457 [Thread-6] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.loading.FleetCreationSpec.super(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.Ó00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.new(Unknown Source)
   at com.fs.starfarer.loading.OooO.super(Unknown Source)
   at com.fs.oOOO.super.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
4460 [Thread-9] INFO  com.fs.starfarer.loading.scripts.OoOO  - Loading class: com.fs.starfarer.api.fleet.FleetGoal
4460 [Thread-9] INFO  com.fs.starfarer.loading.scripts.OoOO  - Loading class: com.fs.starfarer.api.mission.MissionDefinitionAPI[/s]

 I didn't touch a thing, but it fixed itself. Still a bit curious what it could mean though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 18, 2013, 09:52:48 PM
@TimeDiver: You can set the skills/aptitudes of individual captains, like so:
      FleetMemberAPI fleetMember;
      fleetMember = api.addToFleet(FleetSide.PLAYER, "venture_Balanced", FleetMemberType.SHIP, "ISS Hamatsu", false);
      fleetMember.getCaptain().getStats().setAptitudeLevel(id, level)
      fleetMember.getCaptain().getStats().setSkillLevel(id, level);


Unless I'm forgetting something, it's not possible to apply fleetwide skill effects this way, though - just the "piloted ship" ones.

While we're on this subject, is there a way to set Combat Readiness and Health in the mission java?  I have some ideas for one of my missions but it won't work without that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 18, 2013, 10:04:44 PM
Having a bit of a problem: AI fleets don't seem to ever want to engage hostiles. Despite the fact that there's a massive, like, 6-way war going on with about 40 or so fleets in play at once, it's extremely rare to actually see two enemies engage each other. They'll just continue on wandering the system, with their current assignment reading "patrolling" or "raiding". Even if an enemy fleet is right next to them, they'll almost never pursue each other.

So, my question is: is there anything I can do to change the aggressiveness of AI fleets? Because as it stands, I've got a system with maxed-out fleets that are just wandering around and doing nothing.

There isn't, and they should be quite aggressive. Are the ships in those fleets combat-ready? There's nothing special being done in vanilla to encourage the fleets to fight.

While we're on this subject, is there a way to set Combat Readiness and Health in the mission java?  I have some ideas for one of my missions but it won't work without that.

Should be possible via methods from the FleetMemberAPI, in particular those returning the FleetMemberStatusAPI and RepairTrackerAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on September 18, 2013, 10:34:08 PM
There isn't, and they should be quite aggressive. Are the ships in those fleets combat-ready? There's nothing special being done in vanilla to encourage the fleets to fight.

Yeah, all the ships in the fleets are combat ready. They don't fight enough to actually have their CR decreased.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 18, 2013, 10:38:58 PM
That makes no sense! Hmm. Maybe they're actually fighting, but autoresolve thinks they aren't doing any damage to each other? That shouldn't be possible either, though. The way to tell would be seeing the circle around the fleet flash - it does that after a battle, while the fleet can't be engaged. It's fairly subtle visually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 19, 2013, 12:58:36 AM
What I've done right now, is made a system that takes ships, with their current loadout, from the ones in the Station's Cargo and makes a fleet with them. The problem is, all the ships spawned into the fleet are mothballed, just like in the station. Is there any way to make them functional in the fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cell on September 19, 2013, 05:14:12 AM
how do i go about submitting a mod? the "Mods" board is locked. do i need to start a thread in this board until its deemed worthy of being moved to "Mods"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 19, 2013, 05:28:27 AM
You toss it in the modding section and then you can ask a moderator to move it. :)
It's handled this way to avoid useless topics in the mod section.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cell on September 19, 2013, 05:38:24 AM
thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dayshine on September 19, 2013, 08:39:47 AM
A question about getting the game to run my EveryFrameCombatPlugin. I'm almost certainly just missing something obvious. I've got a simple combat plugin

Spoiler
Code
package data.scripts.plugins;

import java.util.List;

import org.lazywizard.lazylib.combat.CombatUtils;

import com.fs.starfarer.api.combat.BattleCreationContext;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.input.InputEventAPI;


public class DebugEnginePlugin implements EveryFrameCombatPlugin {

private CombatEngineAPI engine;
private BattleCreationContext context;

public DebugEnginePlugin(BattleCreationContext context) {
this.context = context;
}

public void init(CombatEngineAPI engine) {
this.engine = engine;
}
private int spawned =0;
private int delay = 1;
public void advance(float amount, List<InputEventAPI> events) {
engine.getPlayerShip().setCurrentCR(10);
if((CombatUtils.getElapsedCombatTime()/delay)
>=spawned){
//engine.spawnAsteroid(100, 500, 500, 10, 10);
engine.endCombat(5f);
}
}

}
[close]

and a BaseModPlugin:

Spoiler
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import data.scripts.plugins.*;

public class DebugPlugin extends BaseModPlugin
{
    private static void init()
    {
        //Init things here
    }

    @Override
    public void onNewGame()
    {
        // Calling a separate method avoids duplicate code with onEnabled()
        init();
    }

    @Override
    public void onEnabled(boolean wasEnabledBefore)
    {
        if (!wasEnabledBefore)
        {
            // Calling a separate method avoids duplicate code with onNewGame()
            init();
        }
    }
}
[close]

Both inside a MissileDebug.jar and my mod json is:

Spoiler
Code
{
  "id":"dayshine_missiledebug",
  "name":"Missile Debug",
  "author":"Dayshine",
  "totalConversion":"false",
  "utility":"false",
  "version":"0.01",
  "description":"Adds debug info to missiles",
  "gameVersion":"0.60a",
  "modPlugin":"data.scripts.DebugPlugin",
  "jars":["jars/MissileDebug.jar"]
}
[close]

I'm launching without errors and the log says the mod loaded but nothing happens in combat. I know that for Campaign Plugins you register, but I can't find any way to register my Combat Plugins. Examples I found just seem to drop the .java in data/scripts/plugins and it works, but I don't have anything there because I'm using a jar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on September 19, 2013, 09:27:00 AM
That makes no sense! Hmm. Maybe they're actually fighting, but autoresolve thinks they aren't doing any damage to each other? That shouldn't be possible either, though. The way to tell would be seeing the circle around the fleet flash - it does that after a battle, while the fleet can't be engaged. It's fairly subtle visually.
I don't think they're actually fighting. In vanilla, after mousing over a fleet, you can see it as "pursuing (enemy fleet name)" if two fleets are about to engage. However, I'm not seeing that at all--hostile fleets are just wandering past each other without changing direction to engage in the slightest.

Additionally, I've noticed something even stranger: it seems that some fleets have totally lost the ability to reach a destination. One fleet will have the assignment of attacking a planet, yet it will travel randomly as if it were on a patrol assignment. I've seen the same thing happen for resupply assignments too.

The strangest thing of all is that some fleets still work--every once in a while a hostile fleet will turn and decide to pursue me. But as it stands, I can fly through almost any hostile fleet without them batting an eye, even fleets on defense assignments.

I'm guessing you'd probably like me to send you the mod's files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2013, 09:35:19 AM
I'm guessing you'd probably like me to send you the mod's files?

That might be best. This is just extremely, extremely weird.

What I've done right now, is made a system that takes ships, with their current loadout, from the ones in the Station's Cargo and makes a fleet with them. The problem is, all the ships spawned into the fleet are mothballed, just like in the station. Is there any way to make them functional in the fleet?

Something like member.getRepairTracker().setMothballed(false).


@Dayshine: If you want your combat plugin to be automatically included in every battle, you have to put it (or a stub delegating to it, while also implementing EveryFrameCombatPlugin) under data/scripts/plugins.

Otherwise, if you want something unique for a specific mission, you can call MissionDefinitionAPI.addPlugin(...) in the MissionDefinition.

If you'd like a custom plugin for a specific battle, then you'll have to add a CampaignPlugin to the campaign, and override the BattleCreationPlugin for that specific battle, by using CampaignPlugin.pickBattleCreationPlugin() to provide your custom battle creation implementation, which can then use MissionDefinitionAPI.addPlugin(...) to register said custom plugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dayshine on September 19, 2013, 12:03:51 PM

@Dayshine: If you want your combat plugin to be automatically included in every battle, you have to put it (or a stub delegating to it, while also implementing EveryFrameCombatPlugin) under data/scripts/plugins.


Stub extending the real plugin works great. I was stuck for a while on the following error but adding a zero-args constructor fixed it. Do you know why it's necessary?

Spoiler
Code
java.lang.RuntimeException: Error compiling [data.scripts.plugins.DebugEnginePluginStub]
java.lang.RuntimeException: Error compiling [data.scripts.plugins.DebugEnginePluginStub]
at com.fs.starfarer.loading.scripts.ScriptStore$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.RuntimeException: Problem loading class [data.scripts.plugins.DebugEnginePluginStub]
at com.fs.starfarer.loading.scripts.ScriptStore.super(Unknown Source)
... 2 more
Caused by: java.lang.InstantiationException: data.scripts.plugins.DebugEnginePluginStub
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
... 3 more
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2013, 12:07:49 PM
The game is instantiating it using reflection in a way that requires the class to have a zero-arg constructor. I don't think it's necessary to have one unless you also have a non-0-arg one, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dayshine on September 19, 2013, 04:08:11 PM
Interesting...

Something completely different, I've been looking through this post and rest of the forum and haven't found much mention of it.

Is there a way to get control of a few simple ui elements in the battle engine? I'm trying to see how feasible it would be to make the framework for a debug overlay; to show things like AI state, missile fuel time, projectile range and whatever else would be useful.

I've found addFloatingText(...) however without any call to the textbox I can't modify it nor remove it. This means I can only create text every few seconds or end up with a wonderful mess of a few hundred text pieces on top of each other :P. I guess potentially it could be hacked in using sprites, but I can't see a reliable way of doing that.

It's obviously a low priority feature, but it would allow for some more interesting battle engine mods and all it needs is rudimentary text and maybe lines/boxes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2013, 05:10:01 PM
Not possible at the moment, no. Sorry! I understand how it'd be very useful, but like you said, it's low priority, and also happens to be a good bit of work. Not a great combination for something actually getting done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 20, 2013, 06:57:58 AM
Is this possible now?

Code: java
    public List<ShipAPI> getAllShips()
    {
        if(this.FleetID != null)
        {
            ListIterator Fleetships = FleetID.getFleetData().getMembersListCopy().listIterator();
            while(Fleetships.hasNext())
            {
                FleetMemberAPI fmember = (FleetMemberAPI)Fleetships.next();
                ShipAPI ship = (ShipAPI) fmember; //most methods are exactly the same as the ShipAPI, so a cast should be enough.
                FleetShips.add(ship);
            }
            return this.FleetShips;
        }
        else
        {
            return null;
        }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 20, 2013, 09:11:03 AM
When I add a "builtInMods":["tow_cable"], to one of my ships, it crashes the game on startup.
The Ox seems to have one though.

Has another modder created a tug-type ship yet? Did this go well for you? :S
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dayshine on September 20, 2013, 11:25:50 AM
When I add a "builtInMods":["tow_cable"], to one of my ships, it crashes the game on startup.
The Ox seems to have one though.

Has another modder created a tug-type ship yet? Did this go well for you? :S

I just modded ms_seski.ship (from shadowyards) to have a tow cable and it works fine. Just changed last two lines to:

Spoiler
Code
"width": 54,
  "builtInMods":["tow_cable"],
}
[close]

Although that final comma is unnecessary, the Ox has it :P.

What's the error?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 20, 2013, 11:40:55 AM
@Dayshine: You helped me when I read your 'final comma'. I didn't place a comma on the previous line.
Going to hit myself now. ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dayshine on September 20, 2013, 11:44:15 AM
@Dayshine: You helped me when I read your 'final comma'. I didn't place a comma on the previous line.
Going to hit myself now. ::)

When I was testing it I did think to myself "I bet he's just missed that comma" :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 20, 2013, 12:04:02 PM
You barely even know me and you know me better than I know myself. :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dayshine on September 20, 2013, 05:23:20 PM
A question about CombatEngine again. I would like to add various graphical effects to the map. Simple example: A wormhole. Is there any way to place images or trigger weapon effects easily?

My current plan is to try and use ships, but I can't find a way to spawn ships other than via the FleetManager. I could arguably sneak some extra ships into the enemy fleet and then rewrite the victory conditions but it seems a bit heavy-handed and requires a custom BattleCreationPlugin

The other method would be to use asteroids and change their image, but that would interfere with standard asteroid belts so require replacing the BattleCreationPlugin too.

Basically, is there a way to spawn a CombatEntity in battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 20, 2013, 10:44:38 PM
Is there a way to extend the character generation, i.e. to add a dialog option for a new starting ship, without overwriting the whole file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on September 21, 2013, 06:03:19 AM
As far as I can tell, no...

But, you COULD write a mod that overwrites it and then loads files to specify what should go there instead.

and THAT mod could then be included in every mod that wants to change char-creation that isn't a total conversion (with that mod's specific files) - as a result, when a user downloaded and unpacked it, the config files would all go into the same directory, and (assuming the char-cre mod version was the same) all would be well, it would just cope with it fine.

Presumably the vanilla set of options would be the first config file, just distributed with the mod to start with, and then people would steadily add their own from their own mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 21, 2013, 09:48:10 AM
Is their an easy way to just straight up copy a ship? Turns out just taking the ships from a station's cargo is a bad idea, and all kinds of weird things happen (They all seem to be treated as the same ship across all fleets, from what I can tell. So if something happens to one, it happens to all of them.)

So what I did was create completely new ships from the Global.getFactory() thing and copy the variant. This works for ships that already have variants, but not the "custom" variant. That's just a blank hull, even if it's edited.

So I'm trying to do some other fancy things to directly copy the variant, but it seems like a lot of trouble and I'd hate for their to be an easier way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 21, 2013, 02:52:33 PM
@Dayshine: not right now. This part of the game isn't exactly very flexible atm, modding-wise.

@Verrius: How about using ShipVariantAPI.clone() to make a copy of the variant, and then using FleetMemberAPI.setVariant() on the Factory-created FleetMemberAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 21, 2013, 03:08:16 PM
Funny thing, I tried that and it didn't work the first time. I remember being really irritated about myself and figuring it just didn't do what I thought I did.

Turns out I must have done something wrong, now everything looks fine :p. Thanks for the reply.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flare on September 22, 2013, 02:25:38 AM
What does this part from hullmods mean?

.modifyMult(id, 1f - CASUALTY_REDUCTION * 0.01f)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on September 22, 2013, 03:26:04 AM
It's not my hullmod so I can't say absolutely for -sure-, but I think the multiplier in question is the crew death rate.

CASUALTY_REDUCTION is then a percentage value to reduce it by, so if it were 40, that would be 40% less crew death.

Then you get the floating point number version by first multiplying the CASUALTY_REDUCTION by 0.01 (in this example, you'd get 0.4) and then subtracting it from 1 (so in this example, you'd get 0.6).

Then you set the crew death multiplier to that by calling .modifyMult (on the right object, not sure which it is without going and looking), and then somewhere in the combat code it will multiply all crew deaths by 0.6, so you get less of them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on September 22, 2013, 03:39:00 AM
Any ideas as to why a weapon with STRIKE, USE_VS_FRIGATES in the hint field still fires on fighters at all opportunities? Even when grouped by itself?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on September 22, 2013, 09:00:46 AM
Is it possible to create a recharging weapon that recharges say 4 ammo each time?

I have a weapon that fires a barrage of 4 shots, and I intend for it to Autofire, but I don't want it to spam 1 shot every time it recharges one.

so, is it possible to have it recharge 4 shots at once?

Say having it recharge 4 shots every 30 seconds..
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on September 22, 2013, 09:07:22 AM
Sounds like an idea that'd be good for a magazine loaded or autoloaded weapon. I remember such a suggestion some time ago, but everyone shot it down in flames and said gtfo, recharging shots does the same thing (it really doesn't)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on September 22, 2013, 09:14:30 AM
Sounds like an idea that'd be good for a magazine loaded or autoloaded weapon. I remember such a suggestion some time ago, but everyone shot it down in flames and said gtfo, recharging shots does the same thing (it really doesn't)

It would open up options for a very powerful weapon to have multiple shots (not a burst) doing huge amounts of damage, but then having to reload for a long time before you can fire again..


I'm gonna make a post about it in suggestions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on September 22, 2013, 09:20:37 AM
Is it possible to create a recharging weapon that recharges say 4 ammo each time?

I have a weapon that fires a barrage of 4 shots, and I intend for it to Autofire, but I don't want it to spam 1 shot every time it recharges one.

so, is it possible to have it recharge 4 shots at once?

Say having it recharge 4 shots every 30 seconds..

Ehrrrr, like a shotgun?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on September 22, 2013, 09:24:28 AM
Is it possible to create a recharging weapon that recharges say 4 ammo each time?

I have a weapon that fires a barrage of 4 shots, and I intend for it to Autofire, but I don't want it to spam 1 shot every time it recharges one.

so, is it possible to have it recharge 4 shots at once?

Say having it recharge 4 shots every 30 seconds..

Ehrrrr, like a shotgun?

well I guess, I was thinking more akin to the big battle for the city in the Matrix. carts running magazines and reloading the "mechs".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2013, 10:08:20 AM
Any ideas as to why a weapon with STRIKE, USE_VS_FRIGATES in the hint field still fires on fighters at all opportunities? Even when grouped by itself?

If it's on autofire, then it will do that. But the AI is supposed to not set it on autofire with that configuration of flags.

All in all, though, that probably doesn't make sense. As it is now, autofire will happily fire Reapers at a Talon. The idea, iirc, was to keep it fairly dumb (and thus predictable) and keep the responsibility in the hands of whoever toggles autofire. Which is either the player or the ship AI. But it's already making decisions about friendly fire, anyway, and "but these Reapers didn't auto-fire on Talons!" doesn't seem likely to be a player complaint.

So, changed it so that strike weapons won't fire on fighters or frigates unless they have the other flags (PD, PD_ONLY, USE_VS_FRIGATES) set.

Is it possible to create a recharging weapon that recharges say 4 ammo each time?

I have a weapon that fires a barrage of 4 shots, and I intend for it to Autofire, but I don't want it to spam 1 shot every time it recharges one.

so, is it possible to have it recharge 4 shots at once?

Say having it recharge 4 shots every 30 seconds..

I don't think you want regenerating ammo here. Simply a 4-shot burst weapon with a 30 second cooldown will do the job. Like the Plasma Cannon, but with 4 shots per burst and a longer cooldown.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on September 22, 2013, 10:10:50 AM
Sounds like an idea that'd be good for a magazine loaded or autoloaded weapon. I remember such a suggestion some time ago, but everyone shot it down in flames and said gtfo, recharging shots does the same thing (it really doesn't)
Not everyone!  >.>

And this is doable now - not in any simple way, but you can make an EveryFrameCombatPlugin that scans for particular weapons, keeps track of when they were fired, and restores ammo in chunks.

Personally, I'd use that capability for missile racks, and implement per-tube loading times - so if you have, say, a harpoon rack and fire all three in rapid succession, then, two minutes later, all three reload in rapid succession.
Yes, I think missile weapons (and ballistics, for that matter) should all have regenerating ammunition.  Not because the player needs it, mind you, but because the AI needs it.  Right now it's all too easy to, for example, lure a ship into firing off all of its sabot SRMs - and then you can go on to kill it, safe in the knowledge that it can't do that anymore.  Regenerating ammunition would remove that safety; running the enemy out of missile ammo would still be a decent plan, but they'd no longer stay out of ammo indefinitely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on September 22, 2013, 10:27:47 AM
Any ideas as to why a weapon with STRIKE, USE_VS_FRIGATES in the hint field still fires on fighters at all opportunities? Even when grouped by itself?

If it's on autofire, then it will do that. But the AI is supposed to not set it on autofire with that configuration of flags.

All in all, though, that probably doesn't make sense. As it is now, autofire will happily fire Reapers at a Talon. The idea, iirc, was to keep it fairly dumb (and thus predictable) and keep the responsibility in the hands of whoever toggles autofire. Which is either the player or the ship AI. But it's already making decisions about friendly fire, anyway, and "but these Reapers didn't auto-fire on Talons!" doesn't seem likely to be a player complaint.

So, changed it so that strike weapons won't fire on fighters or frigates unless they have the other flags (PD, PD_ONLY, USE_VS_FRIGATES) set.

Is it possible to create a recharging weapon that recharges say 4 ammo each time?

I have a weapon that fires a barrage of 4 shots, and I intend for it to Autofire, but I don't want it to spam 1 shot every time it recharges one.

so, is it possible to have it recharge 4 shots at once?

Say having it recharge 4 shots every 30 seconds..

I don't think you want regenerating ammo here. Simply a 4-shot burst weapon with a 30 second cooldown will do the job. Like the Plasma Cannon, but with 4 shots per burst and a longer cooldown.

That was just one example, I made a thread in suggestions with a bit more detailed example.. http://fractalsoftworks.com/forum/index.php?topic=6874.0

Sounds like an idea that'd be good for a magazine loaded or autoloaded weapon. I remember such a suggestion some time ago, but everyone shot it down in flames and said gtfo, recharging shots does the same thing (it really doesn't)
Not everyone!  >.>

And this is doable now - not in any simple way, but you can make an EveryFrameCombatPlugin that scans for particular weapons, keeps track of when they were fired, and restores ammo in chunks.

Personally, I'd use that capability for missile racks, and implement per-tube loading times - so if you have, say, a harpoon rack and fire all three in rapid succession, then, two minutes later, all three reload in rapid succession.
Yes, I think missile weapons (and ballistics, for that matter) should all have regenerating ammunition.  Not because the player needs it, mind you, but because the AI needs it.  Right now it's all too easy to, for example, lure a ship into firing off all of its sabot SRMs - and then you can go on to kill it, safe in the knowledge that it can't do that anymore.  Regenerating ammunition would remove that safety; running the enemy out of missile ammo would still be a decent plan, but they'd no longer stay out of ammo indefinitely.

True that.. I actually often do that, just waiting for them to fire off all their missiles and/or spend all their ammo and then go in for the kill.. admittedly it can take awhile.. but it's doable..

Regenerating magazines would stop that, while still not letting them fire continuously, or as it is would be with the current recharge system, continuously, just at a slower pace..
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2013, 10:35:19 AM
I think pretty much the same arguments against it as before still apply. My main concern is you add a mechanic like that, you pretty much have to have fine-grained player control over it or it'll be real annoying. Just one example: your Vulcan's magazine is down to 10%. Instead of going off into battle, you instead fire it all off to start with a full clip. Or there are some direct reloading controls, but not even per group, but per-weapon (somehow?). Anyway, this totally isn't the thread for it, so I'll stop here :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 22, 2013, 07:01:24 PM
Is there a way to make a non-neutral station have free cargo transfer?

Code
cargo.setFreeTransfer(true);

works for it when it's neutral, but not when it's, well, not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 22, 2013, 07:10:26 PM
Is there a way to make a non-neutral station have free cargo transfer?

Code
cargo.setFreeTransfer(true);

works for it when it's neutral, but not when it's, well, not.

I think this is covered in the station InteractionDialog now. There is an if/else about neutral stations. I don't think it obeys that flag anymore, could be wrong though!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 22, 2013, 07:10:58 PM
I tried messing around with the dialogues, I can't get it to work either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 22, 2013, 07:31:23 PM
Well, I think you would just need to change the neutral check in OrbitalStationInteractionDialogPluginImpl to instead check the free transfer flag on the station in context (sorry I don't have code in front of me so I can't provide an example but 1 line change I think).

It does mean you'll need to mess around with jar's and so on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on September 22, 2013, 07:39:18 PM
I would think it was this:
Quote
void showCore(CoreUITabId tabId, SectorEntityToken other, boolean noCost, CoreInteractionListener listener);
Doing this:
Quote
visual.showCore(CoreUITabId.FLEET, station, true, this);
Doesn't do free transfers. Unless it's suppose to be false to do free transfers? Iunno, I won't be able to try until tomorrow anyway.

Note that the original looks like this:
Quote
visual.showCore(CoreUITabId.FLEET, station, station.getFaction().isNeutralFaction(), this);

Pretty important part of what I'm trying to do, just been kinda living with it up until this point so I'd like to get this figured out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 22, 2013, 08:07:27 PM
I would think it was this:
Quote
void showCore(CoreUITabId tabId, SectorEntityToken other, boolean noCost, CoreInteractionListener listener);
Doing this:
Quote
visual.showCore(CoreUITabId.FLEET, station, true, this);
Doesn't do free transfers. Unless it's suppose to be false to do free transfers? Iunno, I won't be able to try until tomorrow anyway.

Note that the original looks like this:
Quote
visual.showCore(CoreUITabId.FLEET, station, station.getFaction().isNeutralFaction(), this);

Pretty important part of what I'm trying to do, just been kinda living with it up until this point so I'd like to get this figured out.

Yeah that's it I think. I haven't played round with it much but I'm going to change that tonight to fix an issue. Will report back if successful :)

Also, in case anyone is interested, I'm using IntelliJ IDEA as my Java IDE and have set it up so only the dialogPlugins get compiled into a jar (which is then automatically deposited into the appropriate <mod>/jars directory). This does mean I still can't use generics/enums etc throughout the rest of the mod files but it does maintain that quick-edit functionality for everything other than the dialogPlugins. Although generics are great it's pretty easy to get by without them.

If anyone is making their own dialogPlugins I highly recommend an IDE :) I did try getting it going from the command prompt (prior to setting things up in IntelliJ) but is was pretty painful (I did learn a lot about jars though!).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2013, 10:47:56 PM
Huh, turns out the noCost parameter is actually completely ignored - I think that happened during the move to the new core UI. Added to list of things to fix. My bad :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on September 23, 2013, 06:04:06 AM
How do I set faction relations in 0.6a?

I've tried with:

Quote
      FactionAPI zorg = sector.getFaction("Zorg");

      zorg.setRelationship("hegemony", -1);
      zorg.setRelationship("tritachyon", -1);
      zorg.setRelationship("pirates", -1);
      zorg.setRelationship("independent", -1);
      zorg.setRelationship("player", 0);

in ZorgGen.java

But that doesn't work anymore.


Also:
Working down a checklist. The Zorg mod's campaign is almost ready!

However, I ran into this issue while trying to have a custom image at a station:
Quote
Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/world/zorg/ZorgGen.java, Line 61, Column 82: Cannot determine simple type name "InteractionDialogImageVisual"

That refers to:
Quote
station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "zorg_interior", 1200, 1200));

I can't figure out why it isn't working. There is a "zorg_interior.png" in the illustrations folder. "station" is the token of the station in ZorgGen.java.

Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on September 23, 2013, 08:52:18 AM
Hi everyone - a little help with packaging into jars with Netbeans?

Everything has gone fine until I attempted to have Starsector load the jar. Then I get:Unsupported major.minor version 51.0
as the error.

Looking this up, its because I've compiled the jar for java 7 rather than java 6... have other people run into this issue as well?

Am I correct that the fix is going to be to downloading the jdk 1.6 and compiling with that set as the platform?

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 23, 2013, 08:55:06 AM
@Erick Doe:

#1: No, that's still how it works. Not sure why it's not working for you but that's how it works in vanilla. My first guess would be that this code isn't actually running, for whatever reason.


#2: Guessing you didn't import the InteractionDialogImageVisual class.

import com.fs.starfarer.api.InteractionDialogImageVisual;


Am I correct that the fix is going to be to downloading the jdk 1.6 and compiling with that set as the platform?

Fairly sure you can just tell netbeans to compile for java6 compliance, while still using the java7 jdk. Haven't used netbeans myself, though, so not 100% sure, but I'd be pretty surprised if it didn't let you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on September 23, 2013, 08:58:26 AM
Am I correct that the fix is going to be to downloading the jdk 1.6 and compiling with that set as the platform?

Fairly sure you can just tell netbeans to compile for java6 compliance, while still using the java7 jdk. Haven't used netbeans myself, though, so not 100% sure, but I'd be pretty surprised if it didn't let you.

I use netbeans and it needs the 1.6jdk download to compile for java6.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on September 23, 2013, 09:14:28 AM
Thanks very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: frag971 on September 23, 2013, 02:06:25 PM
Is there any mod that modifies Experience gains? say x3 or x1.1
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 23, 2013, 02:43:45 PM
Iiiii... this isn't actually doing anything, right?

Code
public zzazzPaintUIPlugin(CampaignFleetAPI fleet, ShipAPI ship, FleetMemberAPI hull) {    
                
            String spriteName = initShadowyards.spriteNames.toString();
            String styleName = initShadowyards.getStyles.toString();
            
            for (FleetMemberAPI member : playerFleet.getFleetData().getMembersListCopy()) {    
                String hullType = member.getSpecId();
                
                if (initShadowyards.spriteNames.keySet().contains(hullType)); {
                    //iterate through the available styles
                    List styleList = new ArrayList(initShadowyards.getStyles.values());
                    Collections.sort(styleList);                    
                    
                    //List spriteList = new ArrayList(initShadowyards.spriteNames.values());
                    //Collections.sort(spriteList);
                    
                    List styles = styleList;
                    Iterator iter = styles.iterator();
                    while (iter.hasNext()) {                                                
                        options.getSelectorValue(styles);
                        options.addOption(styleName, styles);
                        Global.getSettings().getSprite(styles + spriteName);
                    }
                    ship.setSprite(hullType, styles + spriteName);
                }
            }
}

E: should probably add that this is segment of code I'm trying to get to handle the sprite replacing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on September 23, 2013, 04:38:24 PM
@Erick Doe:

#1: No, that's still how it works. Not sure why it's not working for you but that's how it works in vanilla. My first guess would be that this code isn't actually running, for whatever reason.


#2: Guessing you didn't import the InteractionDialogImageVisual class.

import com.fs.starfarer.api.InteractionDialogImageVisual;

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on September 23, 2013, 06:38:37 PM
Is there a way of flagging a mod for compatibility (and incompatibility) with other mods?

I've noticed (in other mods) there are a few different variables you can add to mod_info.json along those lines. Do these actually do anything?

Ideally I would like to be able to say 'this mod will only work with these other mods', or failing that, 'this mod will not work with these other mods' and have StarSector enforce that at mod selection time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kiloman on September 24, 2013, 01:23:46 AM
So I've been mulling some ideas for new weapons, in particular I was considering an 'IFF Disruptor' that type missile. The idea was that it would be a simple unguided missile; if you could land a hit on the hull, it would override the ship's IFF transmitter for a period of time, causing missiles friendly to that ship to target it.

In practice, I'm not sure if this is possible for a few reasons:

First of all, I'd need to disable the friendly-fire protections on a per-ship basis. I think I could do this by conditionally changing the collision class to MISSILE_FF when the projectile was sufficiently close to the hacked ship, but I'm not sure.

Second, I'd need to override the missile target selection logic to override the target owner != missile owner check. Theoretically this could be done by extending the core classes under com.fs.starfarer.combat.ai.missile (HeatseakerAI, MirvAI, etc); however the target selection methods are both private and obfuscated, so I would in fact have to completely re-implement all of the various type-specific logic in my mod.

Am I missing anything? Alex, does what I'm describing make any sense?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on September 24, 2013, 05:02:27 AM
@Erick Doe:

#1: No, that's still how it works. Not sure why it's not working for you but that's how it works in vanilla. My first guess would be that this code isn't actually running, for whatever reason.


#2: Guessing you didn't import the InteractionDialogImageVisual class.

import com.fs.starfarer.api.InteractionDialogImageVisual;

Thanks!

Just a heads up:

I had to rename the custom image that I wanted to use to one of the vanilla images, like "cargo_loading". For some reason it didn't work (crash to desktop) when I entered the custom file's name "zorg_interior". It works fine now, but it is still a little odd to me that I can't use a custom name for the file.

To clarify, I had to rename the image file in my mod from "zorg_interior" to "cargo_loading". Otherwise the game crashes to desktop when trying to dock with the station that uses the custom image.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on September 24, 2013, 06:58:21 AM
I can't get a proper convoy to spawn in and deliver goods to the station:


I've tried adding a Zorg convoy to deliver random weapons and ships to Zorg Zeta.


I've added this line to the ZorgGen:
      system.addScript(new ZorgConvoySpawn(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), station));


Maybe I forgot to import something?

ZorgConvoySpawn.java:
Code
package data.scripts.world.systems;

import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;

import data.scripts.world.BaseSpawnPoint;

@SuppressWarnings("unchecked")
public class ZorgConvoySpawn extends BaseSpawnPoint {

private final SectorEntityToken convoyDestination;

public ZorgConvoySpawn (SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor,
SectorEntityToken convoyDestination) {
super(sector, location, daysInterval, maxFleets, anchor);
this.convoyDestination = convoyDestination;
}

private int convoyNumber = 0;

@Override
protected CampaignFleetAPI spawnFleet() {
String type = null;
float r = (float) Math.random();
if (r > .75f) {
type = "prospectors";
} else if (r > 0.5f) {
type = "salvagers";
} else {
type = "assimilators";
}

StarSystemAPI corvus = Global.getSector().getStarSystem("Corvus");
float angle = (float) ((float) Math.random() * Math.PI * 2f);
float x = (float) (Math.cos(angle) * 12000f) + corvus.getLocation().x;
float y = (float) (Math.sin(angle) * 12000f) + corvus.getLocation().y;
SectorEntityToken spawnPoint = Global.getSector().getHyperspace().createToken(x, y);

CampaignFleetAPI fleet = getSector().createFleet("zorg", type);
spawnPoint.getContainingLocation().spawnFleet(spawnPoint, 0, 0, fleet);

fleet.setPreferredResupplyLocation(convoyDestination);

CargoAPI cargo = fleet.getCargo();

addRandomWeapons(cargo, (int) (Math.random() * 3f) + 2);
addRandomShips(fleet, (int) (Math.random() * 2f) + 0);

fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, spawnPoint, 1000);

convoyNumber++;
return fleet;
}

private void addRandomWeapons(CargoAPI cargo, int count) {
List weaponIds = getSector().getAllWeaponIds();
for (int i = 0; i < count; i++) {
String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
int quantity = (int)(Math.random() * 4f + 2f);
cargo.addWeapons(weaponId, quantity);
}
}

private void addRandomShips(CampaignFleetAPI fleet, int count) {
List wings = getSector().getAllFighterWingIds();
List ships = getSector().getAllEmptyVariantIds();
for (int i = 0; i < count; i++) {
if ((float) Math.random() > 0.4f) {
String wing = (String) wings.get((int) (wings.size() * Math.random()));
FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, wing);
fleet.getFleetData().addFleetMember(member);
member.getRepairTracker().setMothballed(true);
} else {
String ship = (String) ships.get((int) (ships.size() * Math.random()));
FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, ship);
fleet.getFleetData().addFleetMember(member);
member.getRepairTracker().setMothballed(true);
}
}
}

}






ZorgGen.java:

I added this line:
system.addScript(new ZorgConvoySpawn(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), station));

Code
package data.scripts.world.zorg;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.InteractionDialogImageVisual;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl;
import java.awt.Color;
import java.util.List;

@SuppressWarnings("unchecked")
public class ZorgGen {

public void generate(SectorAPI sector) {

StarSystemAPI system = sector.createStarSystem("Zorg Zeta");
LocationAPI hyper = Global.getSector().getHyperspace();
system.setBackgroundTextureFilename("graphics/zorg/backgrounds/backgroundzorg3.png");

// create the star and generate the hyperspace anchor for this system
PlanetAPI star = system.initStar("star_zorg", // id in planets.json
200f, // radius (in pixels at default zoom)
10000, -10000);   // location in hyperspace

system.setLightColor(new Color(25, 75, 55)); // light color in entire system, affects all entities


/*
* addPlanet() parameters:
* 1. What the planet orbits (orbit is always circular)
* 2. Name
* 3. Planet type id in planets.json
* 4. Starting angle in orbit, i.e. 0 = to the right of the star
* 5. Planet radius, pixels at default zoom
* 6. Orbit radius, pixels at default zoom
* 7. Days it takes to complete an orbit. 1 day = 10 seconds.
*/
PlanetAPI z1 = system.addPlanet(star, "Zeta I", "rocky_metallic", 0, 100, 5000, 100);

PlanetAPI z2 = system.addPlanet(star, "Zeta II", "rocky_metallic", 90, 150, 10000, 150);



JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("Inner System Jump");
OrbitAPI orbit = Global.getFactory().createCircularOrbit(z1, 0, 1000, 10);
jumpPoint.setOrbit(orbit);
jumpPoint.setRelatedPlanet(z1);
jumpPoint.setStandardWormholeToHyperspaceVisual();
system.addEntity(jumpPoint);


    FactionAPI zorg = sector.getFaction("zorg");

      zorg.setRelationship("hegemony", -1);
      zorg.setRelationship("tritachyon", -1);
      zorg.setRelationship("pirates", -1);
      zorg.setRelationship("independent", 0);
      zorg.setRelationship("player", 0);


SectorEntityToken station = system.addOrbitalStation(star, 180, 500, 10, "Unimatrix", "zorg");
initStationCargo(station);

station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 640, 400));

// example of using custom visuals below
// a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
// jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
// station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));

// generates hyperspace destinations for in-system jump points
system.autogenerateHyperspaceJumpPoints(true, true);

                ZorgSpawnPoint ZSpawn = new ZorgSpawnPoint(sector, system, 3, 12, station);
system.addSpawnPoint(ZSpawn);
    for (int i = 0; i < 3; i++) ZSpawn.spawnFleet();


system.addScript(new ZorgConvoySpawn(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), station));
                   
                   
                sector.registerPlugin(new CoreCampaignPluginImpl());
}


private void initStationCargo(SectorEntityToken station) {
CargoAPI cargo = station.getCargo();
addRandomWeapons(cargo, 10);

cargo.addCrew(CrewXPLevel.VETERAN, 20);
cargo.addCrew(CrewXPLevel.REGULAR, 500);
cargo.addCrew(CrewXPLevel.GREEN, 500);
cargo.addMarines(300);
cargo.addSupplies(2000);
cargo.addFuel(1000);
cargo.addWeapons("adaptorray", 3);
cargo.addWeapons("concussionray", 3);
cargo.addWeapons("disruptorray", 3);
cargo.addWeapons("handlerray", 5);
cargo.addWeapons("interdictorray", 5);
cargo.addWeapons("transmitterray", 3);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_allocator_Active"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_control_matrix_Active"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_control_matrix_Armoured"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_drone_ActiveY"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_drone_ActiveZ"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_surveyor_ActiveY"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_surveyor_ActiveZ"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_tactical_overseer_Active"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "zorg_tactical_probe_Active"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "zorg_worker_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "zorg_worker_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "zorg_disabler_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "zorg_disabler_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "zorg_probe_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "zorg_probe_wing"));

}


private void addRandomWeapons(CargoAPI cargo, int count) {
List weaponIds = Global.getSector().getAllWeaponIds();
for (int i = 0; i < count; i++) {
String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
int quantity = (int)(Math.random() * 4f + 2f);
cargo.addWeapons(weaponId, quantity);
}
}

}


Help?  :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on September 24, 2013, 10:59:43 AM
does it just straight up not spawn? Or is there like a crash or something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on September 24, 2013, 11:28:15 AM
I'd be surprised if that doesn't crash... the add script method needs an implementation of EveryFrameScript, not a spawnpoint.

A different question: is it currently possible to change the amount of money enemy fleets give on death, or to change the amount of loot they drop? (I'm interested in drastically reducing both).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2013, 12:33:23 PM
Just a heads up:

I had to rename the custom image that I wanted to use to one of the vanilla images, like "cargo_loading". For some reason it didn't work (crash to desktop) when I entered the custom file's name "zorg_interior". It works fine now, but it is still a little odd to me that I can't use a custom name for the file.

To clarify, I had to rename the image file in my mod from "zorg_interior" to "cargo_loading". Otherwise the game crashes to desktop when trying to dock with the station that uses the custom image.

Did you add your zorg_interior to the "illustrations" section in settings.json? That'll ensure the image is actually loaded when the game runs. If you did and it still didn't work: what does the crash log say?


A different question: is it currently possible to change the amount of money enemy fleets give on death, or to change the amount of loot they drop? (I'm interested in drastically reducing both).

Yes, but you'd have to provide a custom implementation of the FleetEncounterInteractionPlugin. The changes themselves would be pretty minor, but it's just a question of providing your adjusted implementation via a CoreCampaignPlugin and building a jar with all the right stuff. Basically, you'd want to start with the core implementation and tweak it a bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 24, 2013, 12:53:02 PM
Alex, is it possible to create some possibility to have certain items and ships persistent onboard a station, at least until the player buys them?

Both my mods use (quest)items that unlock higher class ships.
- When these items disappear (and they do) then players won't be able to access these higher class ships.
- Only a limited number of these ships are unlocked and traders are not delivering new ones, meaning players can lose their chance to have these specific ships.

I hereby desperately beg for a way to make items and ships a permanent presence until the player buys them.

Like:
Code
Cargo.addMothballedShip(FleetMemberType.SHIP, "hii_sajuuk_Hull", null,persistent:true);
Code
Cargo.addItems(CargoAPI.CargoItemType.RESOURCES, "hiigaran_badge_of_admiralty", 1,persistent:true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on September 24, 2013, 02:53:14 PM
...

A different question: is it currently possible to change the amount of money enemy fleets give on death, or to change the amount of loot they drop? (I'm interested in drastically reducing both).

Yes, but you'd have to provide a custom implementation of the FleetEncounterInteractionPlugin. The changes themselves would be pretty minor, but it's just a question of providing your adjusted implementation via a CoreCampaignPlugin and building a jar with all the right stuff. Basically, you'd want to start with the core implementation and tweak it a bit.

Ah, I see. In the following:
Code
case CONTINUE_LOOT:

visual.setVisualFade(0, 0);
dialog.hideTextPanel();

visual.showLoot("Salvaged", context.getLoot(), new CoreInteractionListener() {

...

context.getLoot() returns a cargoAPI that I could edit to my hearts content before passing is to visual. (And later is the credits, same deal but with float/ints.)

When registering the edited CoreCampaignPlugin, its enough to just make a ModPlugin that calls Global.getSector().registerPlugin(new MyCampaignPlugin()), right? And with priority MOD_GENERAL the new implementation will be default rather than the old?


Sorry for so many questions, I'm just still wrapping my head around how the plugins work. Thanks for all the help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2013, 04:16:21 PM
context.getLoot() returns a cargoAPI that I could edit to my hearts content before passing is to visual. (And later is the credits, same deal but with float/ints.)

Yep, you could do that. Or you could make a copy of FleetEncounterContext and adjust the scrapDisabledShipsAndGenerateLoot() method, and also edit your FleetEncounterInteractionPlugin version to call your customized FleetEncounterContext version. It's also got a computeCreditsLooted() method. Either way should be fine.


When registering the edited CoreCampaignPlugin, its enough to just make a ModPlugin that calls Global.getSector().registerPlugin(new MyCampaignPlugin()), right? And with priority MOD_GENERAL the new implementation will be default rather than the old?

Correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on September 25, 2013, 04:01:05 AM
IIRC there was a mechanic that allowed you to raise your hardflux in prior releases. Cant quite remember when last i saw it.
Would it be possible to mod this kind of mechanic, preferable as a hullmod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on September 25, 2013, 06:44:46 AM
I believe this has been asked before, but I simply couldn't find it.

Is it possible to set a score of music for an individual system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2013, 08:22:24 AM
IIRC there was a mechanic that allowed you to raise your hardflux in prior releases. Cant quite remember when last i saw it.
Would it be possible to mod this kind of mechanic, preferable as a hullmod?

It's possible, but afaik it was gone via scripting. Take a look at the FluxTrackerAPI and HullModEffect.applyInCombat()

Is it possible to set a score of music for an individual system?

Not at the moment.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on September 25, 2013, 08:39:20 AM
Gotta let us do that soon, Alex. ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 25, 2013, 08:54:34 AM
Okay, yeah, I'm about at the limits of my ability here.  The boolean for optionSelected keeps returning "void" no matter what boolean I end up putting in there.  Only thing that occurs to me is that I must have gone entirely in the wrong direction.  Fah, I should probably ask someone who's actually put together new interactions how they did it.

Spoiler
Code
	public zzazzPaintDialogPlugin( ShipAPI ship) {    
            if (station.getName() == "Zzazz Painters") {

            //Makes strings of the mapped lists from the init file
            String spriteName = initShadowyards.spriteNames.toString();
            String styleName = initShadowyards.getStyles.toString();
           
            for (FleetMemberAPI member : playerFleet.getFleetData().getMembersListCopy()) {   
            String hullType = member.getSpecId();
               
                    if (initShadowyards.spriteNames.keySet().contains(hullType)); {
                        //iterate through the available styles
                        List styleList = new ArrayList(initShadowyards.getStyles.values());
                        Collections.sort(styleList);                   
                   
                        //List spriteList = new ArrayList(initShadowyards.spriteNames.values());
                        //Collections.sort(spriteList);
                   
                        List styles = styleList;
                        Iterator iter = styles.iterator();
                        while (iter.hasNext()) {   
                            //Dynamically add options based on the number of styles available in the styleList and name it appropriately from the styleName
                            options.addOption(styleName, styles);
                            options.getSelectorValue(styles);
                       
                            //kludge together the styles directory and spriteName to show the adjusted ship sprite on mouseover
                            worker.optionMousedOver(styleName, Global.getSettings().getSprite(styles + spriteName));
                       
                            //if the option is selected, change the ships sprite to match
                            if (worker.optionSelected(styleName, ship.equals(styles))) { //always void, all the time!
                                ship.setSprite(hullType, styles + spriteName);
                            }
                        }
                    }
                }
            }
}
[close]

And just in case the problem is the list assembly:

Spoiler
Code
package data.scripts.world;

import java.util.*;

public final class initShadowyards
{
   
    public static final Map spriteNames;
    public static final Map getStyles;
   
    //InteractionDialogAPI zazz = (); //get the location of the InteractionPlugin here:
   
    static
    {
    Map spriteNamesTmp = new HashMap();
        //Charybdis
        spriteNamesTmp.put("ms_charybdis",
                (new String[]
                {
                    "ms_charybdis.png"
                }));
   
        //Elysium
        spriteNamesTmp.put("ms_elysium",
                (new String[]
                {
                    "ms_elysium.png"
                }));
       
        //Enlil
        spriteNamesTmp.put("ms_enlil",
                (new String[]
                {
                    "ms_enlil.png"
                }));
       
        //Inanna
        spriteNamesTmp.put("ms_inanna",
                (new String[]
                {
                    "ms_inanna.png"
                }));
       
        //Mimir
        spriteNamesTmp.put("ms_mimir",
                (new String[]
                {
                    "ms_mimir.png"
                }));
       
        //Morningstar
        spriteNamesTmp.put("ms_morningstar",
                (new String[]
                {
                    "ms_morningstar.png"
                }));
       
        //Sargasso
        spriteNamesTmp.put("ms_sargasso",
                (new String[]
                {
                    "ms_sargasso.png"
                }));
       
        //Seski
        spriteNamesTmp.put("ms_seski",
                (new String[]
                {
                    "ms_seski.png"
                }));
       
        //Shamash
        spriteNamesTmp.put("ms_shamash",
                (new String[]
                {
                    "phase/ms_shamash.png"
                }));
       
        //Tartarus
        spriteNamesTmp.put("ms_tartarus",
                (new String[]
                {
                    "ms_tartarus.png"
                }));
               
        //Scylla
        spriteNamesTmp.put("ms_scylla",
                (new String[]
                {
                    "phase/ms_scylla.png"
                }));
   
        spriteNames = Collections.unmodifiableMap(spriteNamesTmp);
    }
   
    static
    {
    Map getStylesTmp = new HashMap();
   
        getStylesTmp.put("Blue",
            (new String[]
            {
                "graphics/shadow_ships/blue/"
            }));
   
        getStylesTmp.put("Mercenary",
            (new String[]
            {
                "graphics/shadow_ships/mercenary/"
            }));
   
        getStylesTmp.put("Red Wing",
            (new String[]
            {
                "graphics/shadow_ships/redwing/"
            }));
   
        getStylesTmp.put("Default",
            (new String[]
            {
                "graphics/ships/shadow_ships/"
            }));
   
        getStyles = Collections.unmodifiableMap(getStylesTmp);
    }
   
    private initShadowyards()
    {
        // just to keep this from being instantiated or subclassed I guess
    }

    // Minor convenience tweak for better readability in the static initializer
    private static List createGraphicsList(String[] graphics)
    {
        return Collections.unmodifiableList(Arrays.asList(graphics));
    }
   
    //the following two sections attempt to turn the list data into a useable string
    //public static void setHull(FleetMemberAPI ship, FleetDataAPI data)
    //{
       
        //get the sprites
        //spriteNames.toString();
    //    String hullType = ship.getSpecId();
    //    if (!spriteNames.keySet().contains(hullType))
    //    {
    //        showError("No alternate sprites found for '" + hullType + "'!");
    //        return;
    //    }
       
        //get the supported hulls
    //    String hullStyle = spriteNames.toString();
    //    String styleDirs = getStyles.toString();
       
    //}
   
}
[close]

Any help would be appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 25, 2013, 09:32:12 AM
I am making a mission where the player needs to take out 3 specific ships, but I'm doing it wrong.

Taken from Dire Straits, I modified this line, just throwing extra ships in, but that doesn't work:

Code
api.defeatOnShipLoss("HSS Bullwark", "HSS Stainless", "HSS Deep Dive");

Does anyone know what I would need to do?

Edit: I did it like this, and it seems to work:
Code
api.defeatOnShipLoss("HSS Bullwark, HSS Stainless, HSS Deep Dive");
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2013, 10:29:29 AM
Gotta let us do that soon, Alex. ;D

Not entirely sure how well that'd work. Inter-system transitions could be very common; it might make sense to instead base music on larger regions.



Also: I put together a custom interaction dialog example; you can check it out here (http://fractalsoftworks.com/forum/index.php?topic=6926.0). It doesn't require using jar files.


@MShadowy: Hmm. I don't think that's going to work. Not sure what you mean by "always void" (perhaps "null"?), but you can only get a ShipAPI object when in battle. They don't, generally, exist in the campaign. The way you would want to go about what you're doing is by creating a separate .ship file for each paintjob, and then replace the player's ship with a custom variant when they choose what they want. Copying the variant over will be a bit of a pain, since the underlying .ship is different.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 25, 2013, 10:35:47 AM
"void" is what netbeans keeps telling me: "expected boolean but found 'void'" which probably means a null error, as you pointed out.

Well, thanks for the advice; time to do mass copying of .ship files I guess.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on September 25, 2013, 10:53:37 AM
"void" is what netbeans keeps telling me: "expected boolean but found 'void'" which probably means a null error, as you pointed out.

Well, thanks for the advice; time to do mass copying of .ship files I guess.

That means theres a method/function that is of type void (ex: public void somethingfunction() ) and its expecting to be returning a boolean instead (ex: public boolean isLoading(){ return true; } ).

Your probably using a method in a condition (for example a if(true) ) using a method that is a public void and not a public boolean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on September 26, 2013, 05:27:10 AM
I just found out that Starsector creates 45 mb large savegames when both my mods, Bushi and Hiigaran Descendants are active.
This can't be normal, right?

Does anyone have an idea why this could happen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on September 26, 2013, 05:52:38 AM
Just a heads up:

I had to rename the custom image that I wanted to use to one of the vanilla images, like "cargo_loading". For some reason it didn't work (crash to desktop) when I entered the custom file's name "zorg_interior". It works fine now, but it is still a little odd to me that I can't use a custom name for the file.

To clarify, I had to rename the image file in my mod from "zorg_interior" to "cargo_loading". Otherwise the game crashes to desktop when trying to dock with the station that uses the custom image.

Did you add your zorg_interior to the "illustrations" section in settings.json? That'll ensure the image is actually loaded when the game runs. If you did and it still didn't work: what does the crash log say?

Thank you. That was exactly the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on September 26, 2013, 06:48:22 AM
I appear to have invisible ship sprites, and no matter what I do to the .png it doesn't show up in game. It is a 32 bit save setting, so no problem there. I did replace the .ship file in by Trylobot's Ship Editor, but I only overwrote the entire thing. Any help?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 28, 2013, 05:42:09 AM
Is there a way to make ships affected by an AoE ship system buff or debuff get a weapon glow, like the one phase teleporters, high energy focus, ammo feed, etc. give?

I'm sure if it's possible it's really simple (probably involving EveryFrameWeaponEffectPlugin?), but I'm p. bad with java and don't really understand how to use the API unless I have a concrete example in front of me, and the core ship systems that have a weapon glow have it built in rather than created in the script files.  :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on September 28, 2013, 06:44:10 AM
Christ, additively blended cosmetic weapons look crazy on the refit screen compared to ingame. I wonder if I can somehow circumvent that.

(http://i.imgur.com/Be5HSar.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on September 28, 2013, 09:50:53 AM
I just found out that Starsector creates 45 mb large savegames when both my mods, Bushi and Hiigaran Descendants are active.
This can't be normal, right?

Does anyone have an idea why this could happen?

The only way to be SURE is to look through the save file.

Normal saves are about 4mb, and... roughly, 52 thousand lines long (near game start anyway).

Collapse the XML, go through looking for a BIG (hundreds of thousands of lines) line number jump, that has worked for me before. It's still a long, slow and uncomfortable process - but you can probably start looking in the mod specific sections :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on September 29, 2013, 05:44:01 AM
Another thing about deco weapons: they seem to force weapon flux per second readout in the refit screen to show up as zero. Also, it would be helpful to have a hint to choose if deco weapons should always be drawn underneath non-deco weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on September 29, 2013, 06:05:56 AM
Apologies if this is already in the thread somewhere: I couldn't find it with the search function.

Is there a way to throw an exception from mod code and have it handled by Starsector (i.e. popping up the dialog box as normal then crashing with the exception logged)?

I am attempting to write a version update function, and sometimes I want it to just fail, report to the users that sadly no, I can't update from this version they have, and they'll need to start a new game.  I thought the best way of doing this would be via exceptions, but as none of the API functions expect me to throw exceptions I'm not sure it's going to work.

Another suggestion that does much the same would be fine too, but I thought the general question about Exceptions would be valuable here as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on September 29, 2013, 07:30:30 AM
Apologies if this is already in the thread somewhere: I couldn't find it with the search function.

Is there a way to throw an exception from mod code and have it handled by Starsector (i.e. popping up the dialog box as normal then crashing with the exception logged)?

I am attempting to write a version update function, and sometimes I want it to just fail, report to the users that sadly no, I can't update from this version they have, and they'll need to start a new game.  I thought the best way of doing this would be via exceptions, but as none of the API functions expect me to throw exceptions I'm not sure it's going to work.

Another suggestion that does much the same would be fine too, but I thought the general question about Exceptions would be valuable here as well.

Well, if you want to deliberately crash the game you would use:
Code
throw new RuntimeException("Message goes here");

The exception and stack trace should be logged just like a regular crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on September 29, 2013, 10:37:58 AM
I have so many of these lately - sorry if anyone is getting bored of my questions!

If I have a CargoStackAPI cargoStack, can I safely cargoStack.subtract(cargoStack.getSize()) ?

If not, what is the best way to remove a cargostack from a cargo, ideally without calling CargoAPI.removeItems() (because that method is hard to use when you might be dealing with a dozen different very similarly named things that you want to treat as a unified quantity)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on September 29, 2013, 11:19:35 AM
The question is concerning decorative weapons.

The new ringengines animation, Lazywizard has provided the code for, show at the beginning of some battles or if your press "C" to reduce the speed to zero some kind of jittering as if the animation would jump frames.
After ruling out it is only my machine this is happening i found some helpful souls on the forum, and some of them reported back with the same observation.

Lazy brought up an idea that it could be the "selection flash". The falsh for example you can witness on weapons if you toggle through weapongroups incombat.
As the system is dealt as weapon this seems quite logical, and judging by the nature of the jittering it could be in fact Lazys guess.

Alex maybe you can confirm this if decorative weapons could show this "selection flash"



PS.: i was quite sure that the bug where decorative weapons would show up in weapon group 1 was solved. what would i have to change to prevent this kind of behaviour concerning the heimdahl generator.
I guess it's the was the decorative weapon is "saved" in the variant file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fengyuan on September 29, 2013, 12:57:36 PM
     I am trying to save custom game data and find that CampaignClockAPI.getHour() always returns zero after game loaded.
That breaks my custom hour counter. Is it a bug?

    I write a heartbeat script to print the date in format (hour, day, month, cycle).

(http://s8.postimg.org/wtvcru5ap/screenshot002.png) (http://postimg.org/image/wtvcru5ap/)

(http://s8.postimg.org/wv5al974h/screenshot003.png) (http://postimg.org/image/wv5al974h/)

The heartbeat code:
Code
package data.scripts.world.pld;

import static data.scripts.world.pld.event.EventType.HEARTBEAT_CYCLE;
import static data.scripts.world.pld.event.EventType.HEARTBEAT_DAY;
import static data.scripts.world.pld.event.EventType.HEARTBEAT_HOUR;
import static data.scripts.world.pld.event.EventType.HEARTBEAT_MONTH;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignClockAPI;
import com.fs.starfarer.api.campaign.SectorAPI;

import data.scripts.world.pld.event.BaseEvent;
import data.scripts.world.pld.event.EventBus;
import data.scripts.world.pld.event.EventType;
import data.scripts.world.pld.event.SectorChangeEvent;
import data.scripts.world.pld.misc.LogSink;

/**
 * generate time heartbeat event.
 * when game loaded, 'hour' will reset to zero.
 * @author fengyuan
 *
 */
public class Heartbeat implements EveryFrameScript{

/**
* hour, day, month, cycle
*/
private int[] lastTimeVector;

/**
* use EveryFrameScript to save eventbus and its related instance
*/
private EventBus eventbus;
private SectorAPI sector;

public Heartbeat(EventBus eventbus) {
lastTimeVector = new int[4];
for (int i = 0; i < 4; i++) {
lastTimeVector[i] = -1;
}
this.eventbus = eventbus;
}

@Override
public boolean isDone() {
return false;
}

@Override
public boolean runWhilePaused() {
return false;
}

@Override
public void advance(float amount) {
SectorAPI sector = Global.getSector();
if (this.sector != sector){
this.sector = sector;
eventbus.raiseEvent(new SectorChangeEvent(eventbus));
}

eventbus.raiseEvent(new BaseEvent(EventType.HEARTBEAT_FRAME));
CampaignClockAPI clock = sector.getClock();
if (performHeartbeat(0, clock.getHour(), HEARTBEAT_HOUR)
&& performHeartbeat(1, clock.getDay(), HEARTBEAT_DAY)
&& performHeartbeat(2, clock.getMonth(), HEARTBEAT_MONTH)
&& performHeartbeat(3, clock.getCycle(), HEARTBEAT_CYCLE)){
;
}
}

/**
* check if time update and raise heartbeat event
*/
private boolean performHeartbeat(int vectorIdx, int value, EventType heartbeatEventType){
if (lastTimeVector[vectorIdx] != value){
lastTimeVector[vectorIdx] = value;
eventbus.raiseEvent(new BaseEvent(heartbeatEventType));

if (heartbeatEventType == EventType.HEARTBEAT_HOUR)
LogSink.getLogSink(Heartbeat.class).info(
"("+lastTimeVector[0]+","+lastTimeVector[1]+","+lastTimeVector[2]+","+lastTimeVector[3]+")");

return true;
}else{
return false;
}
}

}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2013, 01:05:28 PM
Another thing about deco weapons: they seem to force weapon flux per second readout in the refit screen to show up as zero. Also, it would be helpful to have a hint to choose if deco weapons should always be drawn underneath non-deco weapons.

Fixed; for now giving them some reasonable stats (i.e. a rof that doesn't result in a divide-by-0) should work.

As far as being underneath: noted. For now, making it "SMALL" will at least make it render under everything bigger, except for missiles.

If I have a CargoStackAPI cargoStack, can I safely cargoStack.subtract(cargoStack.getSize()) ?

If not, what is the best way to remove a cargostack from a cargo, ideally without calling CargoAPI.removeItems() (because that method is hard to use when you might be dealing with a dozen different very similarly named things that you want to treat as a unified quantity)

That should work. But really, that's what removeItems() is for.


The new ringengines animation, Lazywizard has provided the code for, show at the beginning of some battles or if your press "C" to reduce the speed to zero some kind of jittering as if the animation would jump frames.
After ruling out it is only my machine this is happening i found some helpful souls on the forum, and some of them reported back with the same observation.

Lazy brought up an idea that it could be the "selection flash". The falsh for example you can witness on weapons if you toggle through weapongroups incombat.
As the system is dealt as weapon this seems quite logical, and judging by the nature of the jittering it could be in fact Lazys guess.

Looking at the code, that shouldn't be possible as only weapons that are in a group ever get that method (the one that starts a flash) called.

PS.: i was quite sure that the bug where decorative weapons would show up in weapon group 1 was solved. what would i have to change to prevent this kind of behaviour concerning the heimdahl generator.
I guess it's the was the decorative weapon is "saved" in the variant file?

To make sure: are you still getting them to show up in weapon group 1?

If the decorative weapon is builtIn, that shouldn't happen; if it is, that's definitely a bug. If that's what's happening here, do you have any idea how to reproduce it?



     I am trying to save custom game data and find that CampaignClockAPI.getHour() always returns zero after game loaded.
That breaks my custom hour counter. Is it a bug?

Yep, bug - thanks for reporting it. Fixed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on September 29, 2013, 01:10:54 PM
Another thing about deco weapons: they seem to force weapon flux per second readout in the refit screen to show up as zero. Also, it would be helpful to have a hint to choose if deco weapons should always be drawn underneath non-deco weapons.

Fixed; for now giving them some reasonable stats (i.e. a rof that doesn't result in a divide-by-0) should work.

As far as being underneath: noted. For now, making it "SMALL" will at least make it render under everything bigger, except for missiles.
Just as a note, there are some interesting and useful use-cases for decorative weapons that render above other weapons, too.  Possibly even some cases for weapons that render inbetween other weapons.  @Cycerin: This quote may be of some use to you - the thread it's in isn't pinned, but is findable via this thread of useful threads (http://fractalsoftworks.com/forum/index.php?topic=5309.0):
Quick question: is there any way to determine the render order of weapons? I've got large decorative weapons that seem to randomly overlap certain weapons.
All the hardpoints get rendered before all turrets.
Within that, larger sizes get rendered last.
Within each size, racked missiles (i.e. like Harpoon, not like Swarmer) get rendered first.

After that, it's not deterministic. So, you want a small hardpoint - that won't quite take care of everything, but at least all the turrets (i.e, the stuff that moves a lot) will be over it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on September 29, 2013, 01:34:02 PM
i checked the .ship file and it is set as built_in. What i found in the variant on the other hand explains a lot i think.
It was as a matter of fact listed in weapongroup 1  ::) I will now go and be ashamed of my self for quite a bit ;)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on September 29, 2013, 09:28:41 PM
What properties does the ai use to decide when to vent?

I'm trying to increase the the ai's frequency of venting, but it always decides to slowly lose flux the normal way.

Either if it the flux dissipation is too high and pick just dropping shields until a threshold like ... 75-85% of max flux and cycles over and over, even when in the same period it could of cleared all buildup with a vent relatively safely.
Same case when you have too much flux capacity and the it knows that it will be exposed for while but it still rather suffer an overload and doing no effective damage instead of venting.

The only times I see something vent, is when something else is venting, it's really really far away, or it's about to die.

Hoping for some way to make the ai reliably vent when it just gets really high flux.

Edit: also does the ai count venting times when it's modified by hull mods as well?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 29, 2013, 09:59:22 PM
edit: i think i solved my own problem. turns out initializing values is good and forgetting parentheses is bad  :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on September 30, 2013, 12:50:48 AM
I'm wondering if it's possible to make a missile have proxy fuse (like the phase charge)

I have tried copying and pasting the behavior code from phase charge but nothing seems to happen
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on September 30, 2013, 03:46:16 AM
What properties does the ai use to decide when to vent?

I'm trying to increase the the ai's frequency of venting, but it always decides to slowly lose flux the normal way.

Either if it the flux dissipation is too high and pick just dropping shields until a threshold like ... 75-85% of max flux and cycles over and over, even when in the same period it could of cleared all buildup with a vent relatively safely.
Same case when you have too much flux capacity and the it knows that it will be exposed for while but it still rather suffer an overload and doing no effective damage instead of venting.

The only times I see something vent, is when something else is venting, it's really really far away, or it's about to die.

Hoping for some way to make the ai reliably vent when it just gets really high flux.

Edit: also does the ai count venting times when it's modified by hull mods as well?


This has been a headscratcher for me too ever since I tried to balance Blackrock around requiring active venting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 30, 2013, 04:18:06 AM
Another thing about deco weapons: they seem to force weapon flux per second readout in the refit screen to show up as zero. Also, it would be helpful to have a hint to choose if deco weapons should always be drawn underneath non-deco weapons.

Fixed; for now giving them some reasonable stats (i.e. a rof that doesn't result in a divide-by-0) should work.

This doesn't seem to be working for me -- even if I directly copy the stats of a functional weapon into the statline for the decorative blinky light, which is really weird. Anyone got any tips?

Cycerin, the blinky lights on BRDY ships don't set the weapon flux/second readout to 0 in the refit screen for me, how'd you manage that?


I can't say for sure that I figured it out, but it's working now. vOv I'm going to assume it's what Cycerin has in the "number" column on the weapon_data.csv, because copying that fixed mine.

Either that or the specClass of the .wpn file has to match up with the statline. One of those two things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DragonV2 on September 30, 2013, 04:56:31 AM
So im trying to kick off my own little mod with custom ships (basically taking the ships from one game and putting em in here) the only bits i don't know yet are

1) what are the approximate image sizes that are used for the various classes? i guess its measured in pixels but im not so sure

2a) what defines the locations for the hard points etc? as in where is the origin of the grid and how is it measured
2b) what is an easy way of finding the coordinates?

3) is there a resolution limit on ship sprites, or do they have to be 8-bit

also since i know i will need to know this later - how do recoil animations work? i poked my head around and based of what i saw it is simply an image of the barrel and it is moved back and forth, how is this defined?
 
thanks for your advice in advance
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 30, 2013, 06:13:19 AM
So im trying to kick off my own little mod with custom ships (basically taking the ships from one game and putting em in here) the only bits i don't know yet are

1) what are the approximate image sizes that are used for the various classes? i guess its measured in pixels but im not so sure

2a) what defines the locations for the hard points etc? as in where is the origin of the grid and how is it measured
2b) what is an easy way of finding the coordinates?

3) is there a resolution limit on ship sprites, or do they have to be 8-bit

also since i know i will need to know this later - how do recoil animations work? i poked my head around and based of what i saw it is simply an image of the barrel and it is moved back and forth, how is this defined?
 
thanks for your advice in advance

Firstly, check out Trylobot's ship editor: http://fractalsoftworks.com/forum/index.php?topic=375.0

It does a lot of work for you, and I think nearly every mod that gets put out uses it. It really is an amazing tool.

To answer your first question, though: there's no hard cap on sprite size by ship class that I know of

the biggest ships in vanilla are as follows:
fighter 38x45
frigate 80x80
destroyer 120x234
cruiser 140x280 or 220x180
capital 320x440

so those are probably good sizes to aim for, very roughly (lots of mods have bigger or smaller ships without problems)

as for hardpoint locations, that's a good case to use the ship editor in I think. It makes it more or less dead simple.
For resolutions, I have no real idea what you're talking about -- if you mean size of the image, I don't think there's an upper limit but past a certain point you can't zoom out anymore and it won't fit on a screen or in the refit window. If you mean bit depth, I usually just leave paint.NET on the automatic setting and haven't had problems with ship images... It does sometimes cause a display bug where weapons won't show up if they're saved at a certain bit depth though. I'm not sure what that is, someone else might have more info.

As for recoil animations, you've got it. There's a line in the .wpn file that determines how far back the image moves, I think in pixels.
Looks like this:
Code
	"visualRecoil":8.0,  # the gun sprites are only used if this is non-0

Digging around in the files in starsector/starsector-core/data is a good way to learn how things work. The game files are really transparent and easy to read, and usually have helpful comments in them too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2013, 10:59:14 AM
What properties does the ai use to decide when to vent?

I'm trying to increase the the ai's frequency of venting, but it always decides to slowly lose flux the normal way.

Either if it the flux dissipation is too high and pick just dropping shields until a threshold like ... 75-85% of max flux and cycles over and over, even when in the same period it could of cleared all buildup with a vent relatively safely.
Same case when you have too much flux capacity and the it knows that it will be exposed for while but it still rather suffer an overload and doing no effective damage instead of venting.

The only times I see something vent, is when something else is venting, it's really really far away, or it's about to die.

Hoping for some way to make the ai reliably vent when it just gets really high flux.

Edit: also does the ai count venting times when it's modified by hull mods as well?


This has been a headscratcher for me too ever since I tried to balance Blackrock around requiring active venting.

It's... complicated. Lots of things get considered, including incoming damage and missiles, the state of its weaponry (too much stuff disabled? might as well vent), the time-to-vent vs estimated time after which it'll be at risk, etc. It's not something you can mod without rewriting the AI completely, although...

Without looking at the code, I suspect increasing the vent rate drastically will make it more likely to vent, since it'll consider it less of a risk. So you could add a vent rate buff in a script, and then remove it the instant a ship starts venting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on September 30, 2013, 12:37:10 PM
solved it myself, just needed to resize the turet sprite and add empty space at the back...
Spoiler
how do I fix this(image below):
(http://i.imgur.com/zKWAa7p.png?8121)
I am trying to get the turret to sit on its mounting point but it is ignoring Offsets...
how do I fix this so the turret sits directrly ontop of the mount
my weapon code:
Code
{
"id":"LBH3",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"BALLISTIC",
"size":"LARGE",
"turretSprite":"/graphics/biso/weapons/LBH3_t.png",
"turretGunSprite":"/graphics/biso/weapons/LBH3_b.png",
"hardpointSprite":"/graphics/biso/weapons/LBH3_t.png",
"hardpointGunSprite":"/graphics/biso/weapons/LBH3_b.png",
"visualRecoil":11,
"renderHints":[RENDER_BARREL_BELOW],
"turretOffsets":[55, 0],
"turretGunOffsets":[55, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[55, 0],
"hardpointAngleOffsets":[0],
"barrelMode":"LINKED", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",
"muzzleFlashSpec":{"length":24.0,   # only used if animationType = MUZZLE_FLASH
  "spread":50.0,
  "particleSizeMin":10.0,
  "particleSizeRange":40.0,
  "particleDuration":2.5,
  "particleCount":100,
  "particleColor":[100,100,100,255]},
"autocharge":true,  # whether the weapon will continue charging and fire if the LMB is tapped instead of held
"projectileSpecId":"khs_l_flechette",  # projectile that will be fired
"fireSoundTwo":"gauss_cannon_fire",
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DragonV2 on September 30, 2013, 01:44:03 PM
-snip-

alrighty thanks for that, this will at least get the basics going although im not looking forward to how my initial ships will look like... haven't done any kind of drawing for like 2 years... its gonna be a while before i get anything half decent.

but ill ask for art advice in the "rate my sprite" thread :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on October 01, 2013, 09:11:41 PM
Spoiler
What properties does the ai use to decide when to vent?

I'm trying to increase the the ai's frequency of venting, but it always decides to slowly lose flux the normal way.

Either if it the flux dissipation is too high and pick just dropping shields until a threshold like ... 75-85% of max flux and cycles over and over, even when in the same period it could of cleared all buildup with a vent relatively safely.
Same case when you have too much flux capacity and the it knows that it will be exposed for while but it still rather suffer an overload and doing no effective damage instead of venting.

The only times I see something vent, is when something else is venting, it's really really far away, or it's about to die.

Hoping for some way to make the ai reliably vent when it just gets really high flux.

Edit: also does the ai count venting times when it's modified by hull mods as well?


This has been a headscratcher for me too ever since I tried to balance Blackrock around requiring active venting.
[close]
It's... complicated. Lots of things get considered, including incoming damage and missiles, the state of its weaponry (too much stuff disabled? might as well vent), the time-to-vent vs estimated time after which it'll be at risk, etc. It's not something you can mod without rewriting the AI completely, although...

Without looking at the code, I suspect increasing the vent rate drastically will make it more likely to vent, since it'll consider it less of a risk. So you could add a vent rate buff in a script, and then remove it the instant a ship starts venting.

I've tried an absurd hullmod that gives near instant vent (3000x vent speed), but even then it refuses to vent as long as an enemy with a weapon is shooting nearby.

Another variation is a vent that takes 20 seconds, but even when the ship is literally out of detection range, it still won't vent.
In similar setup to above, the ship is basically pushed into almost overload, shields are down, it gets hit by tachyon lances everythings basically disabled, but it will still rather sit for 200+ seconds with a barely opened shield ( it also drops said shields when an attack even comes near, which is dumb...) rather than using a 20 second vent.

No way of specifying vent parameters (safe distance?, allowable damage time, )  I'm assuming?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fengyuan on October 02, 2013, 09:24:53 AM
How to speed up the game loadding time? I have to test again and again and spend too much time on loadding the texture and sounds files.

Is there any way of reloading scripts without restart the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 02, 2013, 10:00:51 AM
...

No way of specifying vent parameters (safe distance?, allowable damage time, )  I'm assuming?

No, there isn't. It's more, ah, fuzzy than that. Could obviously be improved, but the ways to improve it aren't obvious :)


How to speed up the game loadding time? I have to test again and again and spend too much time on loadding the texture and sounds files.

Is there any way of reloading scripts without restart the game.

1) Run with sound disabled, that'll help a lot
2) In devMode, while in combat (and only in combat), you can 1) press F5 to reload all textures and 2) press F8 to reload all data files and scripts. This may cause the game to crash at some later point.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alfalfa on October 02, 2013, 04:27:29 PM
What exactly does the acceleration stat for ships signify?

Just looking at the numbers, I'm assuming speed is in pixels-traversed-per-second, so would acceleration be pixels-traversed-per-second-per-second?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 02, 2013, 06:28:38 PM
Correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alfalfa on October 02, 2013, 08:03:48 PM
Correct.

Awesome, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on October 03, 2013, 12:17:32 AM
This is a general request to anyone who is good at javascript/reading XML files/hunting down elusive sources of save file bloat. :-[

It looks like my Kadur Theocracy mod causes saves to grow quite large (~50mb after around 10-15 minutes of play), and while hunting through the save file xml has shown me what I think is some optimization I could do (having scripts initialized only once with functions that let them do different things i.e. attack different stations etc. rather than initialized once for each station to attack etc.) I'm pretty sure it isn't the main source of whatever's making the save files huge. If anyone could help me figure out what's causing the save files to balloon, either by looking through the mod's code or by saving a game with it active and poring over the save file, I'd really appreciate it!

Download link for the latest version is here: https://dl.dropboxusercontent.com/u/35692174/Vayra1.1.7.rar (https://dl.dropboxusercontent.com/u/35692174/Vayra1.1.7.rar)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on October 03, 2013, 01:52:06 AM
Is it possible to create a new cargo type that functions exactly like a regular crewmember, counts toward crew, but doesn't get affected by XP?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Turdicus on October 03, 2013, 02:36:43 AM
So I'm just trying to get my first dinky little fighter into the game, I have everything all set up. The only thing is that apparently LibreOffice, the program I am using to edit and save the CSV files, seems to break the CSV file somehow. Do I have to use Excel? Or is there another program that I can use?

Thanks guys
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on October 03, 2013, 02:39:48 AM
Personally I use OpenOffice. Trouble is, I got it so long ago that I don't remember if you have to pay for it or not.

Either way, it is great for the purposes of editing the CSVs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Turdicus on October 03, 2013, 03:07:31 AM
Aye, LibreOffice is the new project of the OpenOffice guys after they got bought out by some mean people. I'm sure your version is fine, just the newer versions are full of bloatware.

The error I get from simply opening a ship.csv file and then saving it (libreoffice tells me that some formatting in a text csv format might not be saved properly) is this:

Spoiler
2941 [Thread-6] ERROR com.fs.starfarer.combat.D  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.new(Unknown Source)
   at com.fs.starfarer.loading.OooO.super(Unknown Source)
   at com.fs.oOOO.super.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)
[close]

Don't know if that looks familiar to anyone. It's probably something very simple.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on October 03, 2013, 04:31:45 AM
I believe that is indeed caused by your spreadsheet program not playing nice with the spreadsheets.

I'm not sure how LibreOffice setup works, but here's a helpful image I found by searching the forums on how to set up OpenOffice to properly open starsector .csv files (these were the default options on my copy, but ymmv):

(https://dl.dropbox.com/u/15428102/separators.png)

My fresh install of Microsoft Excel 2010 also worked perfectly, though it's less than ideal because you can't open two docs with the same name at once (i.e. the vanilla ship_data.csv and the one in your mod)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on October 03, 2013, 06:01:15 AM
OpenOffice is free and great, except for dutchies like me.
Language settings will have to be set to US or UK english, or OpenOffice will wreak havoc upon your .csv files. Took me a lot of googling to find out that language settings were the cause.

In my case OpenOffice crashed a couple of times and apparently it resets the language settings afterwards. Not knowing this I completely torpedo'd several .csv files.

Long story short: Keep backups!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Trylobot on October 03, 2013, 07:19:38 AM
you can't open two docs with the same name at once (i.e. the vanilla ship_data.csv and the one in your mod)
    I still cannot believe that Microsoft has never fixed that. What a piece of junk software.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Trylobot on October 03, 2013, 08:33:49 AM
Aye, LibreOffice is the new project of the OpenOffice guys after they got bought out by some mean people. I'm sure your version is fine, just the newer versions are full of bloatware.

To be fair, I'm not sure I would call Apache as a company "mean." But all office suites are bloated. Microsoft's, OpenOffice, LibreOffice... bloat is the name of the game when it comes to productivity. Welcome to software.

Currently LibreOffice is the only one I have installed, but I'm not sure it's really best.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on October 03, 2013, 09:29:17 AM
A non ideal solution is to use your favourite text editor, such as Scite or notepad++. You might need to be able to count, and be a tiny bit patient, but file format issues should be non-existent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2013, 09:42:34 AM
Is it possible to create a new cargo type that functions exactly like a regular crewmember, counts toward crew, but doesn't get affected by XP?

Not directly, the way that works is pretty rigid. The best you might be able to do is create an item that allows one to install a hullmod that reduces the skeleton crew, or something along those lines.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2013, 10:04:20 AM
This is a general request to anyone who is good at javascript/reading XML files/hunting down elusive sources of save file bloat. :-[

It looks like my Kadur Theocracy mod causes saves to grow quite large (~50mb after around 10-15 minutes of play), and while hunting through the save file xml has shown me what I think is some optimization I could do (having scripts initialized only once with functions that let them do different things i.e. attack different stations etc. rather than initialized once for each station to attack etc.) I'm pretty sure it isn't the main source of whatever's making the save files huge. If anyone could help me figure out what's causing the save files to balloon, either by looking through the mod's code or by saving a game with it active and poring over the save file, I'd really appreciate it!

Download link for the latest version is here: https://dl.dropboxusercontent.com/u/35692174/Vayra1.1.7.rar (https://dl.dropboxusercontent.com/u/35692174/Vayra1.1.7.rar)

Took a quick look; I'm not sure there's anything necessarily wrong, though I could easily have missed some duplication. A save is naturally going to get larger compared to its size on startup as ships get damaged and more fleets spawn, the question is, does it continue to grow, or does it top out at a certain point? If you simply have 50mb worth of stuff, I'd suggest turning on save file compression. Should reduce file size by a factor of 20, and improve the save/load times a good deal.

(I'll have to deal with this at some point, ofc, as the vanilla Sector grows larger. Regardless of other measures, pretty sure that save compression will be on by default in some future release.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Turdicus on October 03, 2013, 01:47:49 PM
Man it takes FOREVER to make an original sprite and get it into the game, I have a LOT more respect for you modders now, whew.

I suppose my question is how do you spriters usually star out with fresh art? I tried starting big, like 1000 pixels high, and then shrinking to 100 pixels for a frigate, but of course it really dilutes the image and makes it looks quite childish. Do you guys usually start at the pixel size you want?

Getting a detailed model into 100 pixels is incredible, the artists for this game and the mods have some genuine talent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on October 03, 2013, 02:17:41 PM
Took a quick look; I'm not sure there's anything necessarily wrong, though I could easily have missed some duplication. A save is naturally going to get larger compared to its size on startup as ships get damaged and more fleets spawn, the question is, does it continue to grow, or does it top out at a certain point? If you simply have 50mb worth of stuff, I'd suggest turning on save file compression. Should reduce file size by a factor of 20, and improve the save/load times a good deal.

(I'll have to deal with this at some point, ofc, as the vanilla Sector grows larger. Regardless of other measures, pretty sure that save compression will be on by default in some future release.)

Thank you! That's a load off my mind, then. I'll do what optimization I can and stop worrying about it so much.

Man it takes FOREVER to make an original sprite and get it into the game, I have a LOT more respect for you modders now, whew.

I suppose my question is how do you spriters usually star out with fresh art? I tried starting big, like 1000 pixels high, and then shrinking to 100 pixels for a frigate, but of course it really dilutes the image and makes it looks quite childish. Do you guys usually start at the pixel size you want?

Getting a detailed model into 100 pixels is incredible, the artists for this game and the mods have some genuine talent.

I believe most people who make sprites from scratch draw them at 10x or 4x eventual scale and then shrink them at do detail work, cleanup, etc. at actual final scale, yes. :)

I don't know if you've read it already or not, but this thread has a lot of good info: http://fractalsoftworks.com/forum/index.php?topic=3342.0 (http://fractalsoftworks.com/forum/index.php?topic=3342.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Turdicus on October 03, 2013, 02:23:43 PM
Yeah that thread has been a godsend, among many other useful portions of this forum, and quite a few posts by you too, Vayra. I've taken it upon myself to make a decent ship, and with almost zero experience spriting I've managed to get myself to make a basic frigate sprite in under four hours =P One day I'll make something worth putting up for you guys to see, I hope.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on October 04, 2013, 10:09:12 AM
So I have this 'ere script that spawns Nexus ships randomly in Corvus.
Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;

public class NexusGen implements SectorGeneratorPlugin{

public void generate( SectorAPI sector ){
StarSystemAPI system = sector.getStarSystem( "Corvus" );

NexusSpawnPoint nexusSpawn1 = new NexusSpawnPoint(sector, system, 14, 100,
system.getEntityByName("star"),"nexus","nexus1");
system.addSpawnPoint(nexusSpawn1);
for( int i = 0; i < 2; i++ ) nexusSpawn1.spawnFleet();

NexusSpawnPoint nexusSpawn2 = new NexusSpawnPoint(sector, system, 28, 100,
system.getEntityByName("star"),"nexus","nexus3");
system.addSpawnPoint(nexusSpawn2);
for( int i = 0; i < 1; i++ ) nexusSpawn2.spawnFleet();
        }
}

But I'd like to spawn these guys in Hyperspace. Is that possible? If so, can someone explain how?
Does the Hyperspace have a 'system' name like a regular system? (I've been looking in the api file, but could not locate it.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Magician on October 04, 2013, 06:07:59 PM
I found this thread http://fractalsoftworks.com/forum/index.php?topic=6519.0 which states that it is possible to change hull sprites, including boundaries, during combat, if weapon mounts stay untouched.
Now my question is if it is possible to create visual effect as if old hull slowly transforms into new. I can only think of animated sprite with one-time playback. And to transform back in same manner, it will require to use another animated hull sprite only to show reverse transformation; and after that default static hull sprite will be finally used.
Along with question if its possible at all, I am also interested to know if such extensive use of animation will strain game alot. I read somewhere that it is recommended to use small and simple animations, because game will not handle bigger ones. But this was aimed to animations which are used in normal hulls - thus always visible and active. So if animation is only used during activation of shipsystem and after that used normal static hull sprite, does it affect game performance alot?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 05, 2013, 05:11:24 PM
But I'd like to spawn these guys in Hyperspace. Is that possible? If so, can someone explain how?
Does the Hyperspace have a 'system' name like a regular system? (I've been looking in the api file, but could not locate it.)

Use:
LocationAPI hyperspace = sector.getHyperspace()

I found this thread http://fractalsoftworks.com/forum/index.php?topic=6519.0 which states that it is possible to change hull sprites, including boundaries, during combat, if weapon mounts stay untouched.
Now my question is if it is possible to create visual effect as if old hull slowly transforms into new. I can only think of animated sprite with one-time playback. And to transform back in same manner, it will require to use another animated hull sprite only to show reverse transformation; and after that default static hull sprite will be finally used.
Along with question if its possible at all, I am also interested to know if such extensive use of animation will strain game alot. I read somewhere that it is recommended to use small and simple animations, because game will not handle bigger ones. But this was aimed to animations which are used in normal hulls - thus always visible and active. So if animation is only used during activation of shipsystem and after that used normal static hull sprite, does it affect game performance alot?

It'll eat a lot of memory just to keep all the sprites loaded, so a long animation for a large ship would probably be a bad idea. Frame-rate-wise the game won't care one bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on October 05, 2013, 05:38:53 PM
If I made a starbase with its own defence fleet that could be attacked, by basically making a ship with no move speed, how could I prevent it from ever getting boarded? I don't particularly want players to be playing with the starbases.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 06, 2013, 12:18:30 AM
halp its broken!!!
https://www.dropbox.com/s/tdc7jzbx80aqlju/Biso%20broken.7z
I think...   ???

I cant get my mothballed ships to show up in the corvus Corporate HQ,
based it off vayra's tutorial for the halcyon carier

spawnpoint code
Spoiler
Code
// the "package" is the folder it's in, pretty self-explanatory
package data.scripts.world;

// you have to import anything that's not in the package that you want to use
// we need a lot of stuff to spawn a supply fleet and add ships to it
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import data.scripts.world.BaseSpawnPoint;

// btw, i copied this almost entirely from the existing scripts in the vanilla game and then tweaked it until it served my purposes
// this is essentially how i do everything, and unless you're a coding god it is what i would reccommend doing yourself

@SuppressWarnings("unchecked")
public class BISOSpawnPoint extends BaseSpawnPoint {

// basic setup stuff, initialize a convoyDestination variable
private final SectorEntityToken convoyDestination;

// ...and the class for the whole script
public BISOSpawnPoint(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor,
SectorEntityToken convoyDestination) {
super(sector, location, daysInterval, maxFleets, anchor);
this.convoyDestination = convoyDestination;
}

@Override
protected CampaignFleetAPI spawnFleet() {
// first things first, create a tritachyon supply fleet
// the faction has to line up with a faction that exists, and the fleet has to line up with a fleet that exists for that faction
// so if you wanted to change that to "Advent" and "Halcyon Carrier Delivery Fleet" or w/e you'd need to first create an Advent
// faction file and a halcyon carrier delivery fleet entry within it
CampaignFleetAPI fleet = getSector().createFleet("tritachyon", "supplyfleet");
// then we spawn the fleet we just created
getLocation().spawnFleet(getAnchor(), 0, 0, fleet);

// addShips is a function that we'll define later in this file
// it's what we're going to use to add the Halcyon Carrier to a tri-tachyon supply fleet
// (which obviously doesn't contain one by default)
addShips(fleet);

// we're also going to add enough crew and supplies to the fleet for it to be able to field the halcyon, heh
CargoAPI cargo = fleet.getCargo();
cargo.addCrew(CrewXPLevel.VETERAN, 4000);
cargo.addSupplies(5000);

// createDockedScripts is a function that we'll define later in this file
// we're going to use it to display a message when the supply fleet docks with the station
Script dockScript = null;
dockScript = createDockedScript(fleet);

// we're also going to tell the fleet what to do so it doesn't just wander around lost
fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000, dockScript);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);

return fleet;
}

private Script createDockedScript(final CampaignFleetAPI fleet) {
return new Script() {
public void run() {
if (fleet.isInCurrentLocation()) {
Global.getSector().addMessage("The Tri-Tachyon long distance tech trading expedition has docked");
// this is pretty self-explanatory, if the player's fleet is in Corvus when the halcyon supply fleet docks it displays a message
}
}
};
}

private void addShips(CampaignFleetAPI fleet) {
for (int i = 0; i < 4; i++) { // this line is a fancy way of saying "do the following 4 times"
FleetMemberAPI wasp = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "wasp_wing");
fleet.getFleetData().addFleetMember(wasp);
// so we just added 4 Wasp wings to the fleet (to escort the Halcyon, since it IS a carrier)
}
for (int i = 0; i < 2; i++) { // this line is a fancy way of saying "do the following 2 times"
FleetMemberAPI xyphos = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "xyphos_wing");
fleet.getFleetData().addFleetMember(xyphos);
// so we just added 2 Xyphos wings to the fleet (to escort the Halcyon, since it IS a carrier)
}
FleetMemberAPI activeC1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "C1_S");
fleet.getFleetData().addFleetMember(activeC1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedC1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "C1_S");
fleet.getFleetData().addFleetMember(mothballedC1);
mothballedC1.getRepairTracker().setMothballed(true);
// and last but not least, one mothballed Halcyon to be dropped off at the station! :)

FleetMemberAPI activeB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "B1_S");
fleet.getFleetData().addFleetMember(activeB1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "B1_S");
fleet.getFleetData().addFleetMember(mothballedB1);
mothballedB1.getRepairTracker().setMothballed(true);

FleetMemberAPI activeD1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "D1_S");
fleet.getFleetData().addFleetMember(activeD1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedD1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "D1_S");
fleet.getFleetData().addFleetMember(mothballedD1);
mothballedD1.getRepairTracker().setMothballed(true);

FleetMemberAPI activeR1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB1_S");
fleet.getFleetData().addFleetMember(activeR1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedRB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB1_S");
fleet.getFleetData().addFleetMember(mothballedRB1);
mothballedRB1.getRepairTracker().setMothballed(true);

FleetMemberAPI mothballedRB2 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB2");
fleet.getFleetData().addFleetMember(mothballedRB2);
mothballedRB2.getRepairTracker().setMothballed(true);

FleetMemberAPI mothballedX1 = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "X1_variant_wing");
fleet.getFleetData().addFleetMember(mothballedX1);
mothballedX1.getRepairTracker().setMothballed(true);

FleetMemberAPI mothballedRA1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RA1");
fleet.getFleetData().addFleetMember(mothballedRA1);
mothballedRA1.getRepairTracker().setMothballed(true);
}
}



[close]

gen code
Spoiler
Code
// the "package" is the folder it's in, pretty self-explanatory
package data.scripts.world;

// you have to import anything that's not in the package that you want to use
// we need a fair bit of stuff to do the basic generating
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;

@SuppressWarnings("unchecked")
public class BISOGen {

// this is where the magic happens
public void generate(SectorAPI sector) {
// first we declare that "system" is Corvus so we can call it "system" later on instead of the whole sector.getStarSystem etc every time
StarSystemAPI system = sector.getStarSystem("Corvus");
// then we do the same but for "hyper" and hyperspace
LocationAPI hyper = Global.getSector().getHyperspace();
// then we do the same for the tri-tachyon station in Corvus
SectorEntityToken corvusttbase = Global.getSector().getStarSystem("Corvus").getEntityByName("Corporate HQ");

// then we do the same for the cargo interface IN the tt station in Corvus
CargoAPI cargo = corvusttbase.getCargo();
// and now the fun part: we add two mothballed Halcyon hulls to the station
// the _Hull variant is an empty variant automatically generated by the game for any ship
cargo.addMothballedShip(FleetMemberType.SHIP, "D1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "C1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "B1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RB1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "D1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "C1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "B1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RB1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RB2", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RA1", null);
cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "X1_variant_wing", null);

// now we do the other cool thing: we initialize a script that spawns a supply fleet
// the parameters are this: which sector it's in (there's only one), which system will handle the spawning (in this case, hyperspace)
// how many days will pass in between spawns (28) and how many max fleets there can be at once (1)
// where it will spawn (-6000, 2000 in hyperspace), and where it's going (the tt station in Corvus)
system.addScript(new BISOSpawnPoint(sector, hyper, 1, 1, hyper.createToken(-6000, 2000), corvusttbase));
// the script HalcyonCarrierSpawnPoint also needs to actually exist and have more code in it, so lets go read that one next

}

}















[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: etherealblade on October 06, 2013, 03:38:44 AM
1)Is it possible to mod a weapon that fires a projectile, only the projectile expands (gets bigger) as it travels?

2)Is it possible to have a weapon that fires a projectile that stays persistent on the screen and does damage over time?

3) I've seen weapons push ships away, is it possible to have a projectile that pulls them inward.

Even if it is theoretically possible I shall find the possiblity or workaround necessary. I just needed to know since there is many with much experience in tinkering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Fireball14 on October 06, 2013, 04:06:46 AM
Ok, im trying to create new skill, its showin on game fine, i can spend points on it, but it dose not modfy anything.

Code
{
"id":"aptitude_precursor",
"governingAptitude":"precursor",
"effectGroups":[
{
"effects":[
{
"type":"SHIP",
"script":"data.characters.skills.scripts.PrecursorAptitudeEffect1",
},
]
},
],
}

and

Code
package data.characters.skills.scripts;

import com.fs.starfarer.api.characters.ShipSkillEffect;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class PrecursorAptitudeEffect1 implements ShipSkillEffect {

    public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
stats.getCRPerDeploymentPercent().modifyPercent(id, -1f * PA_SkillData.APTITUDE_CR_LOSS_PER_SECOND_REDUCTION_PERCENT * level);
    }

    public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
stats.getCRPerDeploymentPercent().unmodify(id);
    }

public String getEffectDescription(float level) {
return "Decrease combat readiness consumption after peak efficiency time by " + (int)(PA_SkillData.APTITUDE_CR_LOSS_PER_SECOND_REDUCTION_PERCENT * level) + "%";
}

public String getEffectPerLevelDescription() {
return "" + (int)(PA_SkillData.APTITUDE_CR_LOSS_PER_SECOND_REDUCTION_PERCENT) + "%";
}

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

}

Any idea why it dosent show up on ships stats info?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on October 06, 2013, 05:32:06 AM
halp its broken!!!
https://www.dropbox.com/s/tdc7jzbx80aqlju/Biso%20broken.7z
I think...   ???

I cant get my mothballed ships to show up in the corvus Corporate HQ,
based it off vayra's tutorial for the halcyon carier

spawnpoint code
Spoiler
Code
// the "package" is the folder it's in, pretty self-explanatory
package data.scripts.world;

// you have to import anything that's not in the package that you want to use
// we need a lot of stuff to spawn a supply fleet and add ships to it
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import data.scripts.world.BaseSpawnPoint;

// btw, i copied this almost entirely from the existing scripts in the vanilla game and then tweaked it until it served my purposes
// this is essentially how i do everything, and unless you're a coding god it is what i would reccommend doing yourself

@SuppressWarnings("unchecked")
public class BISOSpawnPoint extends BaseSpawnPoint {

// basic setup stuff, initialize a convoyDestination variable
private final SectorEntityToken convoyDestination;

// ...and the class for the whole script
public BISOSpawnPoint(SectorAPI sector, LocationAPI location,
float daysInterval, int maxFleets, SectorEntityToken anchor,
SectorEntityToken convoyDestination) {
super(sector, location, daysInterval, maxFleets, anchor);
this.convoyDestination = convoyDestination;
}

@Override
protected CampaignFleetAPI spawnFleet() {
// first things first, create a tritachyon supply fleet
// the faction has to line up with a faction that exists, and the fleet has to line up with a fleet that exists for that faction
// so if you wanted to change that to "Advent" and "Halcyon Carrier Delivery Fleet" or w/e you'd need to first create an Advent
// faction file and a halcyon carrier delivery fleet entry within it
CampaignFleetAPI fleet = getSector().createFleet("tritachyon", "supplyfleet");
// then we spawn the fleet we just created
getLocation().spawnFleet(getAnchor(), 0, 0, fleet);

// addShips is a function that we'll define later in this file
// it's what we're going to use to add the Halcyon Carrier to a tri-tachyon supply fleet
// (which obviously doesn't contain one by default)
addShips(fleet);

// we're also going to add enough crew and supplies to the fleet for it to be able to field the halcyon, heh
CargoAPI cargo = fleet.getCargo();
cargo.addCrew(CrewXPLevel.VETERAN, 4000);
cargo.addSupplies(5000);

// createDockedScripts is a function that we'll define later in this file
// we're going to use it to display a message when the supply fleet docks with the station
Script dockScript = null;
dockScript = createDockedScript(fleet);

// we're also going to tell the fleet what to do so it doesn't just wander around lost
fleet.addAssignment(FleetAssignment.DELIVER_RESOURCES, convoyDestination, 1000, dockScript);
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);

return fleet;
}

private Script createDockedScript(final CampaignFleetAPI fleet) {
return new Script() {
public void run() {
if (fleet.isInCurrentLocation()) {
Global.getSector().addMessage("The Tri-Tachyon long distance tech trading expedition has docked");
// this is pretty self-explanatory, if the player's fleet is in Corvus when the halcyon supply fleet docks it displays a message
}
}
};
}

private void addShips(CampaignFleetAPI fleet) {
for (int i = 0; i < 4; i++) { // this line is a fancy way of saying "do the following 4 times"
FleetMemberAPI wasp = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "wasp_wing");
fleet.getFleetData().addFleetMember(wasp);
// so we just added 4 Wasp wings to the fleet (to escort the Halcyon, since it IS a carrier)
}
for (int i = 0; i < 2; i++) { // this line is a fancy way of saying "do the following 2 times"
FleetMemberAPI xyphos = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "xyphos_wing");
fleet.getFleetData().addFleetMember(xyphos);
// so we just added 2 Xyphos wings to the fleet (to escort the Halcyon, since it IS a carrier)
}
FleetMemberAPI activeC1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "C1_S");
fleet.getFleetData().addFleetMember(activeC1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedC1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "C1_S");
fleet.getFleetData().addFleetMember(mothballedC1);
mothballedC1.getRepairTracker().setMothballed(true);
// and last but not least, one mothballed Halcyon to be dropped off at the station! :)

FleetMemberAPI activeB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "B1_S");
fleet.getFleetData().addFleetMember(activeB1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "B1_S");
fleet.getFleetData().addFleetMember(mothballedB1);
mothballedB1.getRepairTracker().setMothballed(true);

FleetMemberAPI activeD1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "D1_S");
fleet.getFleetData().addFleetMember(activeD1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedD1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "D1_S");
fleet.getFleetData().addFleetMember(mothballedD1);
mothballedD1.getRepairTracker().setMothballed(true);

FleetMemberAPI activeR1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB1_S");
fleet.getFleetData().addFleetMember(activeR1);
// we also added one Halcyon that is fully armed and operational (this is what the crew and supplies were for, mainly)

FleetMemberAPI mothballedRB1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB1_S");
fleet.getFleetData().addFleetMember(mothballedRB1);
mothballedRB1.getRepairTracker().setMothballed(true);

FleetMemberAPI mothballedRB2 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RB2");
fleet.getFleetData().addFleetMember(mothballedRB2);
mothballedRB2.getRepairTracker().setMothballed(true);

FleetMemberAPI mothballedX1 = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "X1_variant_wing");
fleet.getFleetData().addFleetMember(mothballedX1);
mothballedX1.getRepairTracker().setMothballed(true);

FleetMemberAPI mothballedRA1 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "RA1");
fleet.getFleetData().addFleetMember(mothballedRA1);
mothballedRA1.getRepairTracker().setMothballed(true);
}
}



[close]

gen code
Spoiler
Code
// the "package" is the folder it's in, pretty self-explanatory
package data.scripts.world;

// you have to import anything that's not in the package that you want to use
// we need a fair bit of stuff to do the basic generating
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;

@SuppressWarnings("unchecked")
public class BISOGen {

// this is where the magic happens
public void generate(SectorAPI sector) {
// first we declare that "system" is Corvus so we can call it "system" later on instead of the whole sector.getStarSystem etc every time
StarSystemAPI system = sector.getStarSystem("Corvus");
// then we do the same but for "hyper" and hyperspace
LocationAPI hyper = Global.getSector().getHyperspace();
// then we do the same for the tri-tachyon station in Corvus
SectorEntityToken corvusttbase = Global.getSector().getStarSystem("Corvus").getEntityByName("Corporate HQ");

// then we do the same for the cargo interface IN the tt station in Corvus
CargoAPI cargo = corvusttbase.getCargo();
// and now the fun part: we add two mothballed Halcyon hulls to the station
// the _Hull variant is an empty variant automatically generated by the game for any ship
cargo.addMothballedShip(FleetMemberType.SHIP, "D1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "C1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "B1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RB1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "D1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "C1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "B1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RB1", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RB2", null);
cargo.addMothballedShip(FleetMemberType.SHIP, "RA1", null);
cargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "X1_variant_wing", null);

// now we do the other cool thing: we initialize a script that spawns a supply fleet
// the parameters are this: which sector it's in (there's only one), which system will handle the spawning (in this case, hyperspace)
// how many days will pass in between spawns (28) and how many max fleets there can be at once (1)
// where it will spawn (-6000, 2000 in hyperspace), and where it's going (the tt station in Corvus)
system.addScript(new BISOSpawnPoint(sector, hyper, 1, 1, hyper.createToken(-6000, 2000), corvusttbase));
// the script HalcyonCarrierSpawnPoint also needs to actually exist and have more code in it, so lets go read that one next

}

}















[close]

In the file named "BISOModPlugin.java", you need to replace the line "import data.scripts.world.HalcyonCarrierGen;" with "import data.scripts.world.BISOGen;"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 06, 2013, 08:50:14 AM
thanks xalendi!  ;D
i knew it was some silly mistake like that but i just couldnt see where it was   ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Andy H.K. on October 06, 2013, 09:09:14 AM
Is there any way in mission to make 2 ships on different team spawn in stationary position, facing each other, and make their AI keep shooting regardless of risk in overloading?

EDIT. never mind, I'll take a different approach in the design.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 06, 2013, 09:46:09 AM
Spoiler
(http://fc00.deviantart.net/fs71/i/2011/361/4/b/fuuuu4rlz_by_justananimefreak123-d4kg8en.png)
[close]
me

the broken (https://www.dropbox.com/s/i21s3nr604y5vj5/Bisos%20test.7z)
same issue again, i fixed what xendi spotted, but aparently they still dont feel like spawning in the stations sale screen
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 06, 2013, 06:31:10 PM
A question about Java and persistent data:

Code: java

public class ascData {

/*
csix
okt
thi
esk
kta
lys
*/

public static String ERA = "ASC";

public static String ASC_FACTIONCHOICE = "csix";

public static boolean ASC_TEAM_KILLER = false;
public static float ASC_FACTION_RELATION = 0;

public static boolean ASC_EASY_MODE = false;

public static String isWorkingFor = " ";
public static boolean hasContract = false;

public static Map FC_RECEIVING_BONUS = new HashMap(50);

}

Is there a really fast and effective way to save and retrieve these few variables from persistent data? Maybe it's just my current state of mind, but I can't seem to figure it out. Any tips or quick examples would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 06, 2013, 09:03:49 PM
A question about Java and persistent data:

...
Is there a really fast and effective way to save and retrieve these few variables from persistent data? Maybe it's just my current state of mind, but I can't seem to figure it out. Any tips or quick examples would be greatly appreciated.

Yup, no problem.

1) Semi-related, but in general don't use static with modding. It screws with the way the game saves the object graph and can cause duplication (or at least thats what I've gathered from reading stuff Alex posted).

2) To add:

Code: java

Global.getSector().getPersistentData().put("ascDataInstance",new ascData());


To use (fetching the ERA string for example):

Code: java

string theERA = Global.getSector().getPersistentData().get("ascDataInstance").ERA;


Or if you include get/set methods for the ascData class, you can call those the same way. You can also just pull the whole object if that suits your needs better.

[edit] You could also store each value individually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on October 07, 2013, 01:46:09 AM
1) Semi-related, but in general don't use static with modding. It screws with the way the game saves the object graph and can cause duplication (or at least thats what I've gathered from reading stuff Alex posted).

Can anyone expand on this, or link me to whatever it is that you read that suggested that? Super curious, and it might help me fix whatever is causing my mod to explode save files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on October 07, 2013, 03:01:28 AM
1) Semi-related, but in general don't use static with modding. It screws with the way the game saves the object graph and can cause duplication (or at least thats what I've gathered from reading stuff Alex posted).

Can anyone expand on this, or link me to whatever it is that you read that suggested that? Super curious, and it might help me fix whatever is causing my mod to explode save files.

Static class variables (i.e private static string myVariable) are not saved to the save files. You should really only be using statics for data that doesn't change, or for data that you explicitly and manually manage between new/load/save games.

Static class variables are retained across games within the StarSector application executable. So, always bear in mind that if you are using statics for mutable data it is probably not a good idea, or you will need to ensure you manually manage it. An example that can lead to duplication is maintaining a list of objects that you add to. If this list is declared static it will not be reset between games (unless explicitly in code by you) and so you will be adding things to an existing list if you are not careful.

For more info look up Java static class members, serialization (the process StarSector uses to create the save game files) and perhaps even singleton classes (a (anti)pattern for using static classes).

So, statics are fine to use but use with caution :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on October 07, 2013, 06:37:00 AM
Got 3 questions.

Did anyone manage to remove the requirement to use stars as their jumppoint?

Also can you trigger the jump system UI by checking how far is a fleet from the star?

Is there a way to remove or "mitigate" the need for supplies and CR?


These are a few problems ive been having while trying to get a campaign for the SC2 mod out so far, but i feel some of these would be useful for other mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Trylobot on October 07, 2013, 07:45:04 AM
silentstormpt,

I solved two of those problems in The Nomads.
http://fractalsoftworks.com/forum/index.php?topic=162.0

Look at the java code behind my sector generation, you'll notice I don't actually call initStar anywhere; it's only later on that I explicitly add one-way jump points for my stars; but, I didn't have to. I could have linked any entity with any other entity using slightly lower-level API's than is typical.

As for the Supplies/CR problem, look at the AutomatedNanobotsFabricators hullmod; it reduces apparent supply usage of the fleet that contains the ship on which it's equipped, to zero. The only requirement is that the fleet have enough supplies to cover one frame of usage, which is usually a small amount (less than 1.0 supplies)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on October 08, 2013, 10:30:26 AM
How do I set mod load priority?

I have a bunch of mods downloaded and instead of editing them and losing all the changes when they update I make my own mod with the changes I want. but I want to make sure it loads last of all so as all the changes are loaded last and overwrite the original mod.

Is there currently such a command? if so what file do I put it in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on October 08, 2013, 10:51:22 AM
is it possible to make a missile have proxy fuse (like the phase charge)?

I have tried copying and pasting the behavior code from phase charge but nothing seems to happen :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on October 08, 2013, 11:33:23 AM
silentstormpt,

http://fractalsoftworks.com/forum/index.php?topic=162.0

As for the Supplies/CR problem, look at the AutomatedNanobotsFabricators hullmod; it reduces apparent supply usage of the fleet that contains the ship on which it's equipped, to zero. The only requirement is that the fleet have enough supplies to cover one frame of usage, which is usually a small amount (less than 1.0 supplies)

Something like this?

Spoiler
Code: java
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class StarControlHullMod extends BaseHullMod
{
@Override
public void applyEffectsBeforeShipCreation( HullSize hullSize, MutableShipStatsAPI stats, String id )
{
stats.getBaseSupplyUsePerDay().modifyPercent(id, -100f);
                stats.getCRLossPerSecondPercent().modifyPercent(id, -100f);
                stats.getCRPerDeploymentPercent().modifyPercent(id, -100f);
                stats.getEngineDamageTakenMult().modifyPercent(id, -100f);
                stats.getWeaponDamageTakenMult().modifyPercent(id, -100f);
                stats.getDamageToTargetEnginesMult().modifyPercent(id, -100f);
                stats.getDamageToTargetWeaponsMult().modifyPercent(id, -100f);
                stats.getVentRateMult().modifyPercent(id, -100f); //Try venting now! Muhahhahha!
                stats.getOverloadTimeMod().modifyPercent(id, -100f); //No overloading for you.
                stats.getBaseRepairCost().modifyPercent(id, -100f); //No costs on repairs tho, hull hp = crew
                stats.getZeroFluxSpeedBoost().modifyPercent(id, -100f); //No zero-flux bonus
}
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on October 08, 2013, 03:33:23 PM
I took [another] long hiatus from the forums and game for a while so I have a couple of questions.

Can I have transparent lighting effects outside of the ship's silhouette without them accumulating a damage overlay in someway now?

Is it possible to have a station with unique graphics or have unique station/planet like objects in space?

What's the best tool to dig into whatever files that aren't Excel? Jsons, I'm guessing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on October 08, 2013, 04:26:53 PM
I took [another] long hiatus from the forums and game for a while so I have a couple of questions.

Can I have transparent lighting effects outside of the ship's silhouette without them accumulating a damage overlay in someway now?

Is it possible to have a station with unique graphics or have unique station/planet like objects in space?

Hi there man, long time no see!

1) Yes, look at Blackrock lensflare (decorative weapon).

2) Not yet unless you want ring shaped things around planets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on October 08, 2013, 04:36:17 PM
Question time (deserves it's own post).

Is it possible to have a super brief tutorial on how to use the getPersistentData method to add and edit a string like,

public static String player_faction_id = "player";

to the persistent data?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 08, 2013, 07:59:16 PM
Question time (deserves it's own post).

Is it possible to have a super brief tutorial on how to use the getPersistentData method to add and edit a string like,

public static String player_faction_id = "player";

to the persistent data?

Sure, but 1 caveat first:

IF you are using static, there is no need at all to use persistent data. Whatever class containing the static variable can be called directly. If the class name is: IDVars, then use: IDVars.player_faction_id;
Note this is not an instance of the class, it is the class itself. However, you should not use static if you ever want to change said variable. To be honest, static is not necessary in any circumstance for modding (better coding, yes, but not necessary).

Short tutorial:
The getPersistentData method returns a map from string to object. That means that any object - for our purposes everything - can be stored by name. First step is to get the map - then you use either 'put' or 'get' to put a value into the map or get one from it.

Code: java

    Global.getSector().getPersistentData().put("MyString", "A String"); 

    String aHandle = Global.getSector().getPersistentData().get("MyString");


You can also store bigger objects as well, such as instances of full classes. The behavior is exactly the same: pick a name for it, then use put and get.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Aenslaed on October 08, 2013, 08:33:26 PM
How much scripting is there allowed for weapons/projectiles? I took a cursory glance into it and it seems like its all pretty straight forward spreadsheet numbers and projectile colors. I was thinking of certain unconventional weapons/hull abilities like a manual triggered mine+MIRV weapon to let you bait out ships to hit them from behind. 

Another idea is a hull ability that uses built up hard flux + shields to do a short range detonation/emp. Run a very hot ship, get in close, get as close as you can to overload, and just vent your flux into damage on them in a sort of all-in gamble.

Another one would be dragging a chain of explosives and/or high mass object behind your ship like a fishing trawler or semi trailer and combine that with a fast and quickly turning ship to wrecking ball a ship.  If you had ships like that, then it would bring some use of the command shuttlepod as you'd call in a ship like this as reinforcement, take manual control, use your towed one time use weapon on a capital, then retreat it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on October 09, 2013, 12:15:52 AM
How much scripting is there allowed for weapons/projectiles? I took a cursory glance into it and it seems like its all pretty straight forward spreadsheet numbers and projectile colors. I was thinking of certain unconventional weapons/hull abilities like a manual triggered mine+MIRV weapon to let you bait out ships to hit them from behind. 

Another idea is a hull ability that uses built up hard flux + shields to do a short range detonation/emp. Run a very hot ship, get in close, get as close as you can to overload, and just vent your flux into damage on them in a sort of all-in gamble.

Another one would be dragging a chain of explosives and/or high mass object behind your ship like a fishing trawler or semi trailer and combine that with a fast and quickly turning ship to wrecking ball a ship.  If you had ships like that, then it would bring some use of the command shuttlepod as you'd call in a ship like this as reinforcement, take manual control, use your towed one time use weapon on a capital, then retreat it.

You can get preeeetty in-depth. Take a look at Shadowyards Heavy Industries and Blackrock Driveyards for some examples -- the Elysium (IIRC) has a built-in weapon with some cool scripting and BRDY Shard Autocannons rely on scripts too. A manually triggered mine is almost definitely possible, and so is the hull ability (ship system, I think you meant) that you mentioned. A dragged object would be a lot more difficult, but you might be able to cobble something together using the scripts for drones?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on October 09, 2013, 03:43:30 AM
How much scripting is there allowed for weapons/projectiles? I took a cursory glance into it and it seems like its all pretty straight forward spreadsheet numbers and projectile colors. I was thinking of certain unconventional weapons/hull abilities like a manual triggered mine+MIRV weapon to let you bait out ships to hit them from behind.  

Another idea is a hull ability that uses built up hard flux + shields to do a short range detonation/emp. Run a very hot ship, get in close, get as close as you can to overload, and just vent your flux into damage on them in a sort of all-in gamble.

Another one would be dragging a chain of explosives and/or high mass object behind your ship like a fishing trawler or semi trailer and combine that with a fast and quickly turning ship to wrecking ball a ship.  If you had ships like that, then it would bring some use of the command shuttlepod as you'd call in a ship like this as reinforcement, take manual control, use your towed one time use weapon on a capital, then retreat it.

My mod (no current download available unless you ask nicely) is extremely scripted, well everything. Weapon behaviors and attributes, missile randomizers and custom AI (Macross Missile Massacre incarnate), Repulsor fields instead of shields, chain lightning guns, and all sorts of craziness. It's to the point where it's risking blowing out my aneurysm trying to balance it against vanilla and make it compatible with all other mods (http://www.planetsmilies.com/smilies/scared/scared0002.gif)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cosmitz on October 09, 2013, 03:49:46 AM
You sir, got put under watch. :) One of the best things that can come out of this is expanding the scene for other people and having even weirder mods. Maybe some will blow back in the development itself aswell. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on October 09, 2013, 03:52:46 AM
Thanks Thaago!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on October 09, 2013, 10:37:37 AM
Now before I get too involved... with Hyperspace being implemented, can mods be more free-form with installation?

Could Mod A add it's own star-system and Mod B add it's own star-system and be compatible while not interacting in anyway?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Trylobot on October 09, 2013, 11:37:32 AM
Could Mod A add it's own star-system and Mod B add it's own star-system and be compatible while not interacting in anyway?

Yep.
Where is your Mod? - System Map of the known Modiverse (http://fractalsoftworks.com/forum/index.php?topic=6727.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on October 09, 2013, 01:06:43 PM
Perfect, ideally I'd like my mods to just be dropped in and be perfectly separate and compatible with everything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on October 09, 2013, 02:48:58 PM
Code
	public static final float REPAIR_PENALTY = 25f;

I'm trying to edit the Augmented Engine Hullmod, but I can't make heads or tails of this function..

The description ingame says engines will take twice as long to repair, why is this number then 25f? would 25 not mean the engine takes 75% longer to repair?

I'm assuming setting this to 50f would indeed be twice as long repair time?

75f would be 25% longer to repair?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 10, 2013, 05:05:52 AM
how do i get rid of the shrapnel animation when a MIRV missiles splits

Spoiler
Code
	"behaviorSpec":{"behavior":"MIRV",
"splitRange":900,
"minTimeToSplit":0.12,
"numShots":1,
"damage":800,
"emp":25,
"damageType":HIGH_EXPLOSIVE,
"hitpoints":300,
"arc":220,
"spreadSpeed":1000,
"projectileSpec":"MBT3_m",
#"emptySpec":"MBFc1_Fc1e",
"smokeSpec":{"particleSizeMin":0.0,
"particleSizeRange":0.0,
"cloudParticleCount":0,
"cloudDuration":0.0,
"cloudRadius":0.0,
"blowbackParticleCount":0,
"blowbackDuration":0,
"blowbackLength":0,
"blowbackSpread":0,
"particleColor":[255,100,50,0]}
}    
}
[close]
this dose not work, animation still happens
comenting it out just causes a crash...

plz help or my MBT3 will cause lag when a onslaught fires them
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 10, 2013, 11:43:06 AM
Code
	public static final float REPAIR_PENALTY = 25f;

I'm trying to edit the Augmented Engine Hullmod, but I can't make heads or tails of this function..

The description ingame says engines will take twice as long to repair, why is this number then 25f? would 25 not mean the engine takes 75% longer to repair?

I'm assuming setting this to 50f would indeed be twice as long repair time?

75f would be 25% longer to repair?

The description is wrong; already fixed for next version. The engines take 25% longer to repair.

how do i get rid of the shrapnel animation when a MIRV missiles splits

Can't, that's hardcoded in the MIRV AI. You could write a custom missile AI to get around the issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on October 10, 2013, 02:25:31 PM
I keep getting a Null error that I cannot wrap my head around..

Code
11796 [Thread-6] ERROR com.fs.starfarer.combat.String  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.loading.specs.HullVariantSpec.super(Unknown Source)
at com.fs.starfarer.loading.specs.HullVariantSpec.<init>(Unknown Source)
at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
at com.fs.starfarer.loading.null.super(Unknown Source)
at com.fs.super.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)

That seems to me something to do with variants? yet the mod that causes it has no variants in it, not anything that calls to any variants?!

the only thing in the mod that causes it is:
ship_data.csv
4 .ship files (2 renamed models, new stats 2 just redone stats)
2 graphic files (for the renamed ships)
and the hull_mod.csv

EDIT: Solved Apparently I had forgotten a .ship at the end of one of the .ship files.. :P I feel like such an idiot :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alfalfa on October 10, 2013, 03:13:57 PM
Ok this is driving me bats.  I need to get the hull size of a ship.

The ship is contained in a CombatEntity variable named 'entity.'  I check if entity isinstanceof ShipAPI, then I call entity.getHullSize().  Starsector crashes, insisting that no such method exists.  I have imported CombatEntity, ShipAPI, ShipAPI.HullSize, etc.  I have typecast the variable as ShipAPI.  I have tried entity.HullSize.

I know this method exists.  I opened up ShipAPI and the photons proving its existence are entering my cornea right now.

What the bejeezus is going on?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on October 10, 2013, 03:53:14 PM
Hm.  Try ((ShipAPI)entity).getHullSize() - that should either work, or throw a class cast exception, or a null pointer exception.  I think.

Posting the line it crashes on & the text of the exception might also be useful in giving us enough information to help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kiloman on October 10, 2013, 05:21:56 PM
Hm.  Try ((ShipAPI)entity).getHullSize() - that should either work, or throw a class cast exception, or a null pointer exception.  I think.

the getHullSize method is actually from the ShipHullSpecAPI, so you want:
Code
((ShipAPI)entity).getHullSpec().getHullSize()

When in question, check the JavaDocs:
http://fractalsoftworks.com/starfarer.api/ (http://fractalsoftworks.com/starfarer.api/)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alfalfa on October 10, 2013, 06:47:09 PM
Here's the relevant piece of code:

Code
velocityMod = x / MAXIMUM_MASS * FIELD_STRENGTH;
            if (entity instanceof ShipAPI){
            HullSize shipClass = (HullSize) ((ShipAPI) entity).getHullSize();
            if (shipClass == (HullSize) ShipAPI.HullSize.valueOf("FIGHTER")) {
            velocityMod *= 1;
            } else if (shipClass == (HullSize) ShipAPI.HullSize.valueOf("FRIGATE")) {
            velocityMod *= 1;   
            } else if (shipClass == (HullSize) ShipAPI.HullSize.valueOf("DESTROYER")) {
            velocityMod *= DESTROYER_MOD;
            } else if (shipClass == (HullSize) ShipAPI.HullSize.valueOf("CRUISER")) {
            velocityMod *= CRUISER_MOD;
            } else if (shipClass == (HullSize) ShipAPI.HullSize.valueOf("CAPITAL_SHIP")) {
            velocityMod *= CAPITAL_SHIP_MOD;
            } else {
            velocityMod *= 1;
            }
            /*switch (shipClass) {
            case (HullSize) DESTROYER: velocityMod *= DESTROYER_MOD;
            case (HullSize) CRUISER: velocityMod *= CRUISER_MOD;
            case (HullSize) CAPITAL_SHIP: velocityMod *= CAPITAL_SHIP_MOD;
            }*/
            }

Thank you for the replies to my earlier question.  It seems it was an issue with how I was handling the Enumerator type.  I've now gotten past the syntax errors and have encountered a logic one.  The 'field' generated by this code is supposed to be modified for all ships larger than a frigate.  Instead it is modified for all ships.  Nothing should happen to fighters or frigates with that code.  The only possibility is that this method of differentiating the different Enumerator values is not working.

I did not know what an Enumerator was before today, but now I hate them oh so very, very, much.  I came up with the solution in about 10 minutes, and have now spent hours attempting to use this Enumerator to perform an incredibly simple task, one I could have accomplished within 40 seconds had the classes been represented with integers.

Anyone know about Enumerators?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kiloman on October 10, 2013, 08:04:42 PM
Inability to switch on an Enum is a limitation of Janino. It's mentioned in a few different places. The usual suggestion is to either use compiled code in a JAR file, or just use an IF statement. There are examples elsewhere, but in a nutshell it looks like this:

Code
import com.fs.starfarer.api.combat.ShipAPI.*

if (entity instanceof ShipAPI){
HullSize size = ((ShipAPI)entity).getHullSpec().getHullSize();
if (size == HullSize.DESTROYER){
// do something for a destroyer
} else if (size == HullSize.FRIGATE){
// do something for a frigate
}
}


Note the getHullSpec before getHullSize, this is another thing you were missing... you can't just cast the hullSpec to a hullSize and expect it to work. You also don't need to use ValueOf, you can just specify the enum directly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 10, 2013, 08:31:55 PM
A general question:

What sort of things have a heavy impact on framerate in the campaign? I'm getting 50+ FPS on average with 0-10% CPU idle, which is quite bad considering I'm running an FX 8350. It seems that viewing large fleets just annihilates my framerate. Don't ever remember that sort of thing happening before. I've only got 5 systems total--most of which have nothing happening in them at all, with the exception of the main one.

I've also got an every frame campaign script running every 2.5 seconds, but it's just a small wall of "if" statements that shouldn't put any sort of strain on the game. Removing this doesn't yield any notable increase in framerate either, so it's pretty much irrelevant.

Any thoughts on what I could do to increase framerates, short of stripping the systems of the majority of their fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 10, 2013, 08:42:04 PM
...

I did not know what an Enumerator was before today, but now I hate them oh so very, very, much.  I came up with the solution in about 10 minutes, and have now spent hours attempting to use this Enumerator to perform an incredibly simple task, one I could have accomplished within 40 seconds had the classes been represented with integers.

...

This is how I felt about most java features before I started using an IDE. Java is insanely picky about usages - it completely crippled my programming for the first 10 ish hours I used it because things that I know work in several other languages would fail for no 'good' reason. Being able to do rapid experimentation in an IDE (I use netbeans) and get instant feedback as to when I make a syntax error was key to me learning the rules.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alfalfa on October 10, 2013, 09:04:20 PM
So I somehow failed to notice the array of is[ShipClass]() boolean methods  :-X, so I switched over to those and things were working much better.  Also, I found a logical error in a loop break I had which was causing inappropriate and erratic behaviour (the most infuriating to debug).  So I think I've got everything sorted out now, thanks again for all your replies.  Obviously I need to clean up my code a bit.

...

I did not know what an Enumerator was before today, but now I hate them oh so very, very, much.  I came up with the solution in about 10 minutes, and have now spent hours attempting to use this Enumerator to perform an incredibly simple task, one I could have accomplished within 40 seconds had the classes been represented with integers.

...

This is how I felt about most java features before I started using an IDE. Java is insanely picky about usages - it completely crippled my programming for the first 10 ish hours I used it because things that I know work in several other languages would fail for no 'good' reason. Being able to do rapid experimentation in an IDE (I use netbeans) and get instant feedback as to when I make a syntax error was key to me learning the rules.

I certainly find Java to be picky to the point of being pedantic.  I am in fact using an IDE, Eclipse, though I suspect I haven't set up many soul-preserving features.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 10, 2013, 11:46:52 PM
What sort of things have a heavy impact on framerate in the campaign? I'm getting 50+ FPS on average with 0-10% CPU idle, which is quite bad considering I'm running an FX 8350. It seems that viewing large fleets just annihilates my framerate. Don't ever remember that sort of thing happening before. I've only got 5 systems total--most of which have nothing happening in them at all, with the exception of the main one.

I've also got an every frame campaign script running every 2.5 seconds, but it's just a small wall of "if" statements that shouldn't put any sort of strain on the game. Removing this doesn't yield any notable increase in framerate either, so it's pretty much irrelevant.

Any thoughts on what I could do to increase framerates, short of stripping the systems of the majority of their fleets?

Just how many fleets have you got, and how large are they? Even a large fleet will still only display up to 20 of the various ships in it. One possibility is if you've got really, really high numbers of engine glows on some of the hulls - that could possibly drag things down. Might be worth making sure you're actually running the game using the main graphics card and not something integrated. Also: what kind of frame rate are you getting in vanilla, when a few large fleets (such as the SDF) are on screen, and how do those compare to the modded fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 11, 2013, 06:00:16 AM
Is there any method of creating a hullmod to allow/prevent character aptitude/skill/perk bonuses from being applied to a specific ship only when equipped?

Or, taken from the opposite perspective, how to modify those aforementioned entries to only apply their effects when a specific hullmod is/isn't installed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 11, 2013, 09:34:40 AM
Just how many fleets have you got, and how large are they? Even a large fleet will still only display up to 20 of the various ships in it. One possibility is if you've got really, really high numbers of engine glows on some of the hulls - that could possibly drag things down. Might be worth making sure you're actually running the game using the main graphics card and not something integrated. Also: what kind of frame rate are you getting in vanilla, when a few large fleets (such as the SDF) are on screen, and how do those compare to the modded fleets?
There are still quite a lot of fleets--probably around 50 when every spawn point is maxed out. That number used to be like 75. As for engine glows, I don't think that's the case--the vanilla game uses far more engine glows than I do. I'm running the game on a 6950, which is a mid-range graphics card. Don't have any other graphics devices, so there can't be any mix-up there. Regarding the framerates in vanilla, it stays at a stable 60 FPS with minimal stuttering. The CPU idle will sometimes dip pretty low (if I'm around a lot of fleets, or large fleets), but usually it hovers around 20-40%. However, when I'm viewing a large / many fleets in Obsidian Void, the framerate starts to suffer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 11, 2013, 10:32:02 AM
Quote
Can't, that's hardcoded in the MIRV AI. You could write a custom missile AI to get around the issue.
how? is there something i can base it on?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2013, 12:02:19 PM
@TimeDiver: Hmm. Nothing immediately comes to mind, though you could probably do *something* creative to get around that.

Or, taken from the opposite perspective, how to modify those aforementioned entries to only apply their effects when a specific hullmod is/isn't installed?

That's probably the more promising approach, but, again, not entirely sure you could get it to work cleanly.


@Psiyon: Hmm. I suppose it's possible that's just running up against some bottleneck on your graphics card. Do you happen to have lots of ring systems? (Like in Askonia) What about the resolution of the background?


Quote
Can't, that's hardcoded in the MIRV AI. You could write a custom missile AI to get around the issue.
how? is there something i can base it on?

Take a look at ModPlugin.pickMissileAI() and MissileAPI.giveCommand().
http://fractalsoftworks.com/starfarer.api/index.html?com/fs/starfarer/api/ModPlugin.html

This trivial missile AI makes all missiles launched from the 3-shot harpoon rack accelerate and constantly turn right:
Code: java
public PluginPick<MissileAIPlugin> pickMissileAI(final MissileAPI missile, final ShipAPI launchingShip) {
if (missile.getWeapon() != null && missile.getWeapon().getId().equals("harpoon")) {
return new PluginPick<MissileAIPlugin>(new MissileAIPlugin() {
public void advance(float amount) {
missile.giveCommand(ShipCommand.TURN_RIGHT);
missile.giveCommand(ShipCommand.ACCELERATE);
}
}, PickPriority.MOD_GENERAL);
}
return null;
}

(Edit: man, I love the syntax highlighting plugin. So nice. Thanks, Trylobot!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 11, 2013, 01:00:54 PM
thanks, :D

Spoiler
you do know you just game an insane person candy!!!

the BISO will now have even weirder weapons, weapons so illogical they will simply shatter the minds of the enemy crew by their mere presence!

and yes I will use the BISO as my playground and lore friendly excuse to make weapons that are totaly non-vanila, infact they will be so non-vanilla they will be chocolate! chocolate coated strobery flavoured serbet!
we put crazy people in padded cells
[close]
Quote
http://fractalsoftworks.com/starfarer.api/index.html?com/fs/starfarer/api/ModPlugin.html
oooo shiny!!!!
stickypost a link to this in the moding and modding resources forum, this is super shiny and usefull to nabs like me who want to become less nab
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 11, 2013, 03:07:07 PM
This trivial missile AI makes all missiles launched from the 3-shot harpoon rack accelerate and constantly turn right:
Code: java
public PluginPick<MissileAIPlugin> pickMissileAI(final MissileAPI missile, final ShipAPI launchingShip) {
if (missile.getWeapon() != null && missile.getWeapon().getId().equals("harpoon")) {
return new PluginPick<MissileAIPlugin>(new MissileAIPlugin() {
public void advance(float amount) {
missile.giveCommand(ShipCommand.TURN_RIGHT);
missile.giveCommand(ShipCommand.ACCELERATE);
}
}, PickPriority.MOD_GENERAL);
}
return null;
}

humm where do i put this? i tried placing it inside ModPlugin like so
Spoiler
Code: java
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

import data.scripts.world.BISOGen;


public class BISOModPlugin extends BaseModPlugin
{
    private static void initBISO()
    {
new BISOGen().generate(Global.getSector());
    }

public PluginPick<MissileAIPlugin> pickMissileAI(final MissileAPI missile, final ShipAPI launchingShip) {  
       if (missile.getWeapon() != null && missile.getWeapon().getId().equals("harpoon")) {  
          return new PluginPick<MissileAIPlugin>(new MissileAIPlugin() {  
             public void advance(float amount) {  
                missile.giveCommand(ShipCommand.TURN_RIGHT);  
                missile.giveCommand(ShipCommand.ACCELERATE);  
             }  
          }, PickPriority.MOD_GENERAL);  
       }  
       return null;  
    }  

    @Override
    public void onNewGame()
    {
        initBISO();
    }

// the following code doesn't work right now, but it will in 0.6.1a!
// its stuff that will let you add it to existing saved games, rather than just new games

    // @Override
    // public void onEnabled(boolean wasEnabledBefore)
    // {
        // if (!wasEnabledBefore)
        // {
           // // Calling a separate method avoids duplicate code with onNewGame()
           // initBISO();
        // }
    // }
}
[close]
but it dosent like that, sorry i know I am a noob, but I am learning slowly
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2013, 05:41:58 PM
@dmaiski: That should work. Are you perhaps expecting it to work on Harpoon Pods or the single-shot Harpoon launchers? That'll only work for 3-shot Harpoon racks, the ones with the weapon id "harpoon".

Aha - I'm not sure Janino actually supports anonymous classes, that might be it. You may need to extract the missile AI implementation into its own class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 11, 2013, 06:27:10 PM
@Psiyon: Hmm. I suppose it's possible that's just running up against some bottleneck on your graphics card. Do you happen to have lots of ring systems? (Like in Askonia) What about the resolution of the background?
Nope, I've got one system that uses rings, and it's only like 3 or 4 bands. The only other use of rings is around jump points, but they have a very small radius. The background images are 2048x2048 JPG.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on October 12, 2013, 05:15:44 AM
Code: json
	"burstjetfire":{
"sounds":[
{"file":"sounds/BR/fx/systems/burstjetfire.ogg","pitch":0.91,"volume":0.75},    # index:  1
{"file":"sounds/BR/fx/systems/burstjetfire.ogg","pitch":0.9,"volume":0.75}, # index:  2
{"file":"sounds/BR/fx/systems/burstjetfire.ogg","pitch":0.92,"volume":0.74},    # index:  3
],

"BLACKROCKHULL":{"sounds":[1,2,3], "pitch":1, "volume":1},
"FIGHTER":{"sounds":[1,2,3], "pitch":1.2, "volume":0.85},
"FRIGATE":{"sounds":[1,2,3], "pitch":1.14, "volume":0.96},
"DESTROYER":{"sounds":[1,2,3], "pitch":1.0, "volume":0.98},
"CRUISER":{"sounds":[1,2,3], "pitch":0.96, "volume":1.00},
"CAPITAL_SHIP":{"sounds":[1,2,3], "pitch":0.90, "volume":1.00},
},

This returns a Fatal: Index 3, Size 3 out of bounds error on game start. Is engine sounds and shield sounds the only thing you can use this type of sound entry for, or am I doing something wrong? It's for a ship system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 12, 2013, 05:57:59 AM
I must admit I am not entirely sure how to do this

i tried
Spoiler
Code: java
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

import data.scripts.world.BISOGen;

public class BISOModPlugin extends BaseModPlugin
{
    private static void initBISO()
    {
        // Create an instance of every generator here and call its generate() method
new BISOGen().generate(Global.getSector());
new MissileAI()
    }



    @Override
    public void onNewGame()
    {
        // Calling a separate method avoids duplicate code with onEnabled()
        initBISO();
    }

// the following code doesn't work right now, but it will in 0.6.1a!
// its stuff that will let you add it to existing saved games, rather than just new games

    // @Override
    // public void onEnabled(boolean wasEnabledBefore)
    // {
        // if (!wasEnabledBefore)
        // {
           // // Calling a separate method avoids duplicate code with onNewGame()
           // initBISO();
        // }
    // }
}

public class BISOpickMissileAI extends pickMissileAI
{
public PluginPick<MissileAIPlugin> pickMissileAI(final MissileAPI missile, final ShipAPI launchingShip) { 
       if (missile.getWeapon() != null && missile.getWeapon().getId().equals("harpoon")) { 
          return new PluginPick<MissileAIPlugin>(new MissileAIPlugin() { 
             public void advance(float amount) { 
                missile.giveCommand(ShipCommand.TURN_RIGHT); 
                missile.giveCommand(ShipCommand.ACCELERATE); 
             } 
          }, PickPriority.MOD_GENERAL); 
       } 
       return null; 
}
}
[close]
and a few other things like extends BaseModPlugin ect.
but it is still throwing errors

help me please :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 12, 2013, 09:32:32 AM
Code: json
	"burstjetfire":{
"sounds":[
{"file":"sounds/BR/fx/systems/burstjetfire.ogg","pitch":0.91,"volume":0.75},    # index:  1
{"file":"sounds/BR/fx/systems/burstjetfire.ogg","pitch":0.9,"volume":0.75}, # index:  2
{"file":"sounds/BR/fx/systems/burstjetfire.ogg","pitch":0.92,"volume":0.74},    # index:  3
],

"BLACKROCKHULL":{"sounds":[1,2,3], "pitch":1, "volume":1},
"FIGHTER":{"sounds":[1,2,3], "pitch":1.2, "volume":0.85},
"FRIGATE":{"sounds":[1,2,3], "pitch":1.14, "volume":0.96},
"DESTROYER":{"sounds":[1,2,3], "pitch":1.0, "volume":0.98},
"CRUISER":{"sounds":[1,2,3], "pitch":0.96, "volume":1.00},
"CAPITAL_SHIP":{"sounds":[1,2,3], "pitch":0.90, "volume":1.00},
},

This returns a Fatal: Index 3, Size 3 out of bounds error on game start. Is engine sounds and shield sounds the only thing you can use this type of sound entry for, or am I doing something wrong? It's for a ship system.
Pretty sure indexes for sounds start at 0, not 1. So you'd have to change all those indexes to [0,1,2].
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on October 12, 2013, 10:33:01 AM
Groan, how dense of me. Oh well, it doesn't crash the game now, but there seems to be zero different in pitch between hull sizes. Hmmmm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2013, 10:48:12 AM
@Psiyon: I suppose it's just having trouble handling that many fleets, then. From what you're saying, doesn't sound like there's a sudden performance drop, it seems to follow more fleets -> lower performance.

@dmaiski: I'd suggest a separate thread for this. Also, I'd suggest reading up (http://docs.oracle.com/javase/tutorial/) on Java a bit :) Also, general note: saying that something is causing errors without specifying what the errors are isn't very useful.

@Cycerin: That scheme only works for the sounds that are set up like that in the vanilla sounds.json. I'd suggest setting up multiple copies of the system if you want to get different sounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on October 12, 2013, 11:18:28 AM
If I made a starbase with its own defence fleet that could be attacked, by basically making a ship with no move speed, how could I prevent it from ever getting boarded? I don't particularly want players to be playing with the starbases.

Two ways.

1. - put a check into fleetinteraction dialog that checks for boardable ships. If starbase = no boarding. This requires a jar file to be created.
2. - make a script that automatically destructs the specified hulls during combat. Destroyed = no boarding.

Both options are used in Ironclads, though only the last one can be freely taken (as the first one is hidden in jar). The file that you need is 'isHuskCheck' in scripts/plugins.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on October 12, 2013, 12:02:06 PM
Im stuck on a null error that happens whenever a ship is created, due to the lack of any useful info on the log file, cant seem to find what exactly is crashing it.

Code
18219 [Thread-6] ERROR com.fs.starfarer.combat.String  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.ship.OooO.String(Unknown Source)
at com.fs.starfarer.combat.entities.ship.OooO.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.title.OoOO.super(Unknown Source)
at com.fs.starfarer.OoOO.øÒÒ000(Unknown Source)
at com.fs.super.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2013, 12:14:46 PM
@silentstormpt: I think that's got something to do with the ship's engines, but can't tell exactly what.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on October 12, 2013, 12:17:17 PM
@silentstormpt: I think that's got something to do with the ship's engines, but can't tell exactly what.

Probably this hullmod ive been working on, trying to "remove" some of the non-required stats for the SC2 mod:

Code: java
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class StarControlHullMod extends BaseHullMod
{
    @Override
    public void applyEffectsBeforeShipCreation( HullSize hullSize, MutableShipStatsAPI stats, String id )
    {
        //stats.getBaseSupplyUsePerDay().modifyPercent(id, -100f);
        stats.getBaseSupplyUsePerDay().modifyFlat(id, -(stats.getBaseSupplyUsePerDay().getBaseValue()));
        stats.getCRLossPerSecondPercent().modifyPercent(id, -100f);
        //stats.getCRLossPerSecondPercent().modifyFlat(id, -(stats.getCRLossPerSecondPercent().getBaseValue()));
        stats.getCRPerDeploymentPercent().modifyPercent(id, -100f);
        //stats.getCRPerDeploymentPercent().modifyFlat(id, -(stats.getCRPerDeploymentPercent().getBaseValue()));
        //stats.getEngineDamageTakenMult().modifyPercent(id, -100f);
        stats.getWeaponDamageTakenMult().modifyFlat(id, -(stats.getWeaponDamageTakenMult().getBaseValue()));
        //stats.getWeaponDamageTakenMult().modifyPercent(id, -100f);
        stats.getDamageToTargetEnginesMult().modifyFlat(id, -(stats.getEngineDamageTakenMult().getBaseValue()));
        //stats.getDamageToTargetEnginesMult().modifyPercent(id, -100f);
        stats.getDamageToTargetWeaponsMult().modifyFlat(id, -(stats.getDamageToTargetWeaponsMult().getBaseValue()));
        //stats.getDamageToTargetWeaponsMult().modifyPercent(id, -100f);
        stats.getVentRateMult().modifyFlat(id, -(stats.getVentRateMult().getBaseValue())); //Try venting now! Muhahhahha!
        //stats.getVentRateMult().modifyPercent(id, -100f);
        //stats.getOverloadTimeMod().modifyFlat(id, -(stats.getOverloadTimeMod().getFlatBonus())); //No overloading for you.
        stats.getOverloadTimeMod().modifyPercent(id, -100f);
        //stats.getBaseRepairCost().modifyPercent(id, -100f);
        stats.getBaseRepairCost().modifyFlat(id, -(stats.getBaseRepairCost().getBaseValue())); //No costs on repairs tho, hull hp = crew
        stats.getZeroFluxSpeedBoost().modifyPercent(id, -100f); //No zero-flux bonus
    }
}

Never made a hullmod this extreme....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 13, 2013, 03:05:27 AM
Question:
I want to make a ship with missile pods...actually built in-missile launchers. Actually missile silos. So not tracking turrets.

Now I know one can animate a weapon to play the animation when it fires...but can one trigger animation in different circumstances? Like - when selecting a weapon group or similar.
I'm not sure what the best way to do this weapon would be.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 13, 2013, 03:32:35 AM
@TrashMan
look at my BISO (http://fractalsoftworks.com/forum/index.php?topic=7041.0) mod, many BISO (http://fractalsoftworks.com/forum/index.php?topic=7041.0) ships have missile silos instead of missile pods

@Alex
(http://www.reactiongifs.com/wp-content/uploads/2013/02/happy-dancing.gif)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 13, 2013, 04:10:44 AM
Thanks, but that doesnt actually answer all of my questions.

I do wonder how you prevent the turret from tracking?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 13, 2013, 06:47:54 AM
Weapons.csv
Turn rate
0

Roughly, I'm writing from memory on an iPhone

Depending on how you want it to launch do:
Launch velocity 0
Max/min spread 0

That's all in weapons.csv


Also if you have a large multi missile silo you may want to add turret offsets in the .wpn file and an alternative sprite to represent your missile loaded vertically in the silo


In weapons.csv you define your missiles max speed with projectile speed and launch velocity with same named column

To define the missiles accel you have to go into the missiles .proj file there the code is self explanatory

1warning missiles will not accelerate unless they are facing target(or you made custom ai script) so make sure you give an appropriate turn rate
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on October 13, 2013, 08:21:49 AM
What exactly can a .system file modify? I know you can add glows to weapons, jitter overlay to the ship, and mod the engines - but how much can you mod when it comes to the engines? Can you increase contrail smoke particle duration and amount/size, for instance?

EDIT: It would be cool if the AI became aware of the new position of a phase teleporting ship during the effect itself as opposed to when it's finished/arrives, it's quite noticeable with slow phase teleporters when the AI can't see the huge ominous Karkinos fading in and doesn't try to get out of the way, and shouldnt make a difference to the Hyperion. IDK.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 13, 2013, 08:58:25 AM
nevermind misunderstood you.

you can increase engine glow length and size, probably more ill look it up

Spoiler
Code
	"engineGlowColor":[255,0,0,255],
"engineGlowContrailColor":[0,0,255,255],

"engineGlowContrailWidthMult":.1,
"engineGlowContrailLengthMult":.1,
"engineGlowContrailGlowMult":.1,

"engineSmokeContrailWidthMult":.1,
"engineSmokeContrailLengthMult":.1,
"engineSmokeContrailGlowMult":.1,

"engineSmokeWidthMult":.1,
"engineSmokeLengthMult":.1,
"engineSmokeGlowMult":.1,

"engineContrailWidthMult":.1,
"engineContrailLengthMult":.1,
"engineContrailGlowMult":.1,

"engineGlowLengthMult":2.5,
"engineGlowWidthMult":3,
"engineGlowGlowMult":2,

"flameoutOnImpactChance":0.5,
[close]
all had no effect (although i can turn engines red and contrail blue
so go poke alex
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 13, 2013, 02:39:42 PM
I'm having a hell of a time trying to get persistent data to work. No matter what I do, the data never actually makes it into the savegame file.

Here's what I'm doing with my scripts that need access to the data:

(Link to the ascData class: http://fractalsoftworks.com/forum/index.php?topic=5061.msg116257#msg116257 )

       ascData DATA = (ascData) Global.getSector().getPersistentData().get("ASCDATA");
I declare DATA as a class data member, and assign it to the ascData instance stored under the key "ASCDATA".

............

     if (DATA == null) {
           DATA = new ascData();
     }
Because that might be null if nothing was stored there, so I make sure to create a new instance.


......... Then my scripts do whatever it is they do, and they usually end up modifying "DATA" in some way.

At the end of the script:
     Global.getSector().getPersistentData().put("ASCDATA", DATA);
I place the modified DATA object into the game's persistent data map under the key "ASCDATA".

The way I see it, this should be happening:

My scripts, when they run, load in the persistent data. They modify it as necessary. They save it back into the persistent data map, replacing the former "DATA" object. The next time a script runs, it uses the updated "DATA" object, and everything is fine.

This works as long as the game isn't restarted. As soon as it is, everything goes back to the ascData class's defaults for some reason. I don't understand why it isn't saving. This is all that appears in the savegame:

        <string>ASCDATA</string>
        <data.asc.ascData></data.asc.ascData>

Obviously, the persistent data for the key "ASCDATA" is totally empty, other than the reference to the class itself.

Is there something blatantly obvious that I'm doing wrong here? Because I've searched for hours and tried a million different things, and have had absolutely no progress whatsoever.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 13, 2013, 02:48:19 PM
@Psiyon: All your data members in AscData are static. Only non-static data members get saved since only non-static data members are actually part of the object. Static data members are part of the class.

@Cycerin: I'm fairly certain that everything that exists is used by one of the vanilla systems, so I'd look through all those.

EDIT: It would be cool if the AI became aware of the new position of a phase teleporting ship during the effect itself as opposed to when it's finished/arrives, it's quite noticeable with slow phase teleporters when the AI can't see the huge ominous Karkinos fading in and doesn't try to get out of the way, and shouldnt make a difference to the Hyperion. IDK.

Right, that makes sense. Not exactly trivial to do, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on October 13, 2013, 02:49:29 PM
I'm having a hell of a time trying to get persistent data to work. No matter what I do, the data never actually makes it into the savegame file.

Here's what I'm doing with my scripts that need access to the data:

(Link to the ascData class: http://fractalsoftworks.com/forum/index.php?topic=5061.msg116257#msg116257 )

       ascData DATA = (ascData) Global.getSector().getPersistentData().get("ASCDATA");
I declare DATA as a class data member, and assign it to the ascData instance stored under the key "ASCDATA".

............

     if (DATA == null) {
           DATA = new ascData();
     }
Because that might be null if nothing was stored there, so I make sure to create a new instance.


......... Then my scripts do whatever it is they do, and they usually end up modifying "DATA" in some way.

At the end of the script:
     Global.getSector().getPersistentData().put("ASCDATA", DATA);
I place the modified DATA object into the game's persistent data map under the key "ASCDATA".

The way I see it, this should be happening:

My scripts, when they run, load in the persistent data. They modify it as necessary. They save it back into the persistent data map, replacing the former "DATA" object. The next time a script runs, it uses the updated "DATA" object, and everything is fine.

This works as long as the game isn't restarted. As soon as it is, everything goes back to the ascData class's defaults for some reason. I don't understand why it isn't saving. This is all that appears in the savegame:

        <string>ASCDATA</string>
        <data.asc.ascData></data.asc.ascData>

Obviously, the persistent data for the key "ASCDATA" is totally empty, other than the reference to the class itself.

Is there something blatantly obvious that I'm doing wrong here? Because I've searched for hours and tried a million different things, and have had absolutely no progress whatsoever.

Are your ascData class members still all static? If they are they will not save into the save file. Given how you have laid out above how you are using it I'm fairly sure they don't need to be statics to meet your purposes :)

ED: ninja'd :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 14, 2013, 07:15:36 AM
Ah, I see. Thanks for the help. I figured that statics would be saved if I used persistent data. Seems I was wrong.

Too bad I can't directly manipulate instance variables within the class itself... oh well. I guess converting everything to use persistent data won't be too painful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 14, 2013, 08:33:42 AM
Ah, I see. Thanks for the help. I figured that statics would be saved if I used persistent data. Seems I was wrong.

Too bad I can't directly manipulate instance variables within the class itself... oh well. I guess converting everything to use persistent data won't be too painful.

What do you mean by directly manipulate instance variables? That sounds like exactly the thing you can and should be doing. I think the only thing you need to do is get rid of those statics!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on October 14, 2013, 09:10:05 AM
Derp derp, api.setBackgroundSpriteName("graphics/BR/backgrounds/obsidianBG.jpg"); during the public void part of a mission definition doesn't crash the game, but it doesn't actually change the background either. What am I doing wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 14, 2013, 09:47:47 AM
Derp derp, api.setBackgroundSpriteName("graphics/BR/backgrounds/obsidianBG.jpg"); during the public void part of a mission definition doesn't crash the game, but it doesn't actually change the background either. What am I doing wrong?

Use descriptor.json instead. I'm pretty sure whatever is in there overrides what you might have set via setBackgroundSpriteName().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 14, 2013, 09:50:57 AM
Ah, I see. Thanks for the help. I figured that statics would be saved if I used persistent data. Seems I was wrong.

Too bad I can't directly manipulate instance variables within the class itself... oh well. I guess converting everything to use persistent data won't be too painful.

What do you mean by directly manipulate instance variables? That sounds like exactly the thing you can and should be doing. I think the only thing you need to do is get rid of those statics!
I mean I can't directly alter the variables in the class like className.variable = anothervariable; without using statics.

If I could, I would just get and save the persistent data on each load/save, and wouldn't bother doing it inside the scripts themselves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kiloman on October 14, 2013, 10:05:30 AM
I mean I can't directly alter the variables in the class like className.variable = anothervariable; without using statics.

If I could, I would just get and save the persistent data on each load/save, and wouldn't bother doing it inside the scripts themselves.

No, you can't do className.variableName unless they are static, because if they're not static they're instance variables, as in, you create a new instance of the class and then modify their value on that object, usually with setter/getter methods.

http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html (http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psiyon on October 14, 2013, 10:18:26 AM
I know, I was just explaining what I meant to Thaago. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 14, 2013, 05:35:45 PM
Ah, I see what you mean. Its very tempting to use statics and classes for data storage, but I've found (in my admittedly limited java programming) that things just get screwed up for a variety of reasons. Its also a pain if you ever want multiple copies of your data - with statics its extremely difficult if not impossible. With instances... you make a new instance :P.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on October 14, 2013, 07:20:04 PM
Has someone made any usage of the ShipAPI.setSprite("thisshipcategoryid","thisshipgraphics2")

Code: java
	/**
* Note: If also changing bounds, make sure they are still within the armor grid
* of the ship, which is determined by the original sprite.
* @param category under "graphics" in settings.json
* @param key id under category.
*/
void setSprite(String category, String key);

Im very interested get 2 "transformer" ships in
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on October 16, 2013, 08:37:43 AM
Is it possible to allow a fighter wing capability to be usable in boarding actions in the campaign?  Think a wing of small boarding craft.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: etherealblade on October 17, 2013, 02:16:48 AM
Well I got awesome news. My mod now loads my empty ships and 2 weapons into the game without crashes. Thats a great step however. Only 6 of the 10 ship sprits show in the codex. What is the remedy for this derp? The files are in the right places and are .png. They happen to be frigates. The only thing that shows in the pictures are lights where the engines are.
YERP!!!! ;D
Spoiler
(http://i191.photobucket.com/albums/z294/atherealprime/screenshot004.png) (http://s191.photobucket.com/user/atherealprime/media/screenshot004.png.html)
[close]

DERP!!!  :'(
Spoiler
(http://i191.photobucket.com/albums/z294/atherealprime/screenshot000.png) (http://s191.photobucket.com/user/atherealprime/media/screenshot000.png.html)
[close]

I should also mention that yes the name of the .png and the name in the .shp file is the same, otherwise I woulda gots a crash
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 17, 2013, 02:42:30 AM
the .png needs to be in 32bit encoding
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on October 17, 2013, 05:56:22 PM
Is it at all possible to have a mission only be available when a set of specified mods are installed, and have that mission use ships from all mods involved? This would be incredibly useful for things like cross-mod/faction missions, and would also provide some interesting synergy between mods.

Just an idea I had whilst chatting with MesoTroniK, and wondered if it can be done.

If I didn't make sense... Ask Meso, he knows what I'm on about.

Edit:

I just realised this could be done with extras/side mods... But that's not nearly as fun.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 17, 2013, 11:01:26 PM
maybe try to make the ModPlugin check if it can find the mods you want, and then if it dose load an alternative mission_list.cvs?

kinda like the exterin
Spoiler
{
        try
        {
            Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.ExerelinGen");
        }
        catch (ClassNotFoundException ex)
        {
            new XXXX().generate(Global.getSector());
        }
}
[close]

well its an idea i dont really have time atm to try it out
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 18, 2013, 02:02:47 PM
Is it possible in dialogs to add options without replacing the whole dialog? For example, say I want to make a mod that adds an option on top of the base choices when interacting with a specific station. I know I can do that by copying the base files and replacing the whole interaction dialog plugin. However, if all I wanted was to add an option with some logic, that seems wasteful and also non-compatible with any other mod that wants to modify the same entity. (A 'supplemental' pickPriority that instead of generating a whole new dialog receives as an argument the existing dialog of the highest priority non-supplemental thing. Getting its optionSelected argument called might be a bit of an issue, depending on how things are structured under the hood...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2013, 02:15:54 PM
Is it possible to allow a fighter wing capability to be usable in boarding actions in the campaign?  Think a wing of small boarding craft.

It's possible, but not simple. It involves providing a different version of the fleet interaction dialog plugin.

maybe try to make the ModPlugin check if it can find the mods you want, and then if it dose load an alternative mission_list.cvs?

kinda like the exterin
Spoiler
{
        try
        {
            Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.ExerelinGen");
        }
        catch (ClassNotFoundException ex)
        {
            new XXXX().generate(Global.getSector());
        }
}
[close]

well its an idea i dont really have time atm to try it out

Yeah, that approach should work.


Is it possible in dialogs to add options without replacing the whole dialog? For example, say I want to make a mod that adds an option on top of the base choices when interacting with a specific station. I know I can do that by copying the base files and replacing the whole interaction dialog plugin. However, if all I wanted was to add an option with some logic, that seems wasteful and also non-compatible with any other mod that wants to modify the same entity. (A 'supplemental' pickPriority that instead of generating a whole new dialog receives as an argument the existing dialog of the highest priority non-supplemental thing. Getting its optionSelected argument called might be a bit of an issue, depending on how things are structured under the hood...)

It's not currently possible, but I completely get what you're asking for/where you're coming from. Basically, this would require structuring the core implementation of the interaction plugin so that it itself could have plugins. That's potentially doable, but also kind of commits station interactions to that specific structure, and that's not something I'm comfortable doing.

I may end up doing just that later on down the line for sanity reasons - say, when expanding the fleet interaction dialog - perhaps with actual dialog - gets unmanageable without some kind of overarching structure. This kind of thing always works best when there's a vanilla use case to drive it, not just because it also directly contributes to dev progress but because it makes it much easier to get the design right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 18, 2013, 02:18:49 PM
Fair enough! I've come up with a work around for the specific thing I was doing, so no rush from me :).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 18, 2013, 05:07:06 PM
now, as many of you may have seen i have created quite an abomidable piece of code due to my unsatisfaction with curent MIRV behaviour...

now what do i do with it?

this is how far i have gotten (help me im stupid and dont actualy know how to get it to work!!!)
Spoiler
Code: java
package data.scripts.EveryFrameCombatPlugin;


import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lwjgl.util.vector.Vector2f;

import java.util.List;

import static org.lazywizard.lazylib.combat.CombatUtils.getShipsWithinRange;

public class Scatterb implements EveryFrameCombatPlugin {

    private IntervalUtil tracker = new IntervalUtil(0.35f, 0.4f);
    private static CombatEngineAPI activeEngine;

    public void advance(float amount, MissileAPI missile, CombatEntityAPI target, CombatEngineAPI engine, java.lang.String SBKR1, List events) {

        if (getShipsWithinRange(missile.getLocation(), 400f, true).get(0).isAlive())
        {
            target = getShipsWithinRange(missile.getLocation(), 400f, true).get(0);
            {
                //create variables
                //capitalized can be changed

                //insert targeter code here (anything goes, you may need to change it so T gives tx/ty a float value
                //see at bottom for possible code
                CombatEntityAPI T = target;//end point of " " (enemy api/point in space/ect) for targeter
                MissileAPI P = missile;    //start point of " " for weapon
                float px = P.getLocation().getX();   //get location og p (for center of dakakakaka)
                float py = P.getLocation().getY();
                //float mvx = missile.getVelocity().getX();
                //float mvy = missile.getVelocity().getY();
                float tx = T.getLocation().getX();   //get location of t (for center of pew pew)
                float ty = T.getLocation().getY();
                double rxd = .5 - Math.random(); //generate a random double with -vs component, range -.5 to +.5
                float rx = (float)rxd*2;          // convert to float
                double ryd = .5 - Math.random();
                float ry = (float)ryd*2;
                double rpd = Math.random(); //+ve random
                float rp = (float)rpd;
                float Tvar = 50f; //radius of t (sets mirv spread (angular))
                float Pvar = 1f;   //variable for vectors can use random float
                double prany = py/Math.abs(py)*Pvar;
                double pranx = px/Math.abs(px)*Pvar;
                float prx = (float)pranx;
                float pry = (float)prany;
                float Rvar = 5f; //how much the velocities of projectiles can vary
                double rvd = .5 - Math.random(); //generate random velocity multiplier for smooth function (to arr roughness back in
                float rv = (float)rvd*Rvar;



                //math

                float Fx = (tx * rx * Tvar);  //create randomized point field to shoot at
                float Fy = (ty * ry * Tvar);
                float Vx = (Fx * px * prx);         //create vectors for pewpews to follow
                float Vy = (Fy * py * pry);
                double Smoothv = (Math.sqrt(((tx-px)*(tx-px))+((ty-py)*(ty-py)))/Math.sqrt((Vx*Vx)+(Vy*Vy)))*rv;   //smoothes out ragged shot
                float Sv = (float) Smoothv;
                Vector2f Pjv = new Vector2f(Vx*Sv, Vy*Sv);   //make the actual vector

                engine.spawnProjectile(null, null,
                        SBKR1,
                        missile.getLocation(), 0,Pjv);

                engine.removeEntity(missile); //make missile go poof
            }

    }
    }



    @Override
    public void advance(float amount, List events) {




    }

    @Override
    public void init(CombatEngineAPI engine) {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
[close]

i am trying to attach it to missiles so it will run as an every frame script and check for a ship in range (and when ship is in range trigger my special MIRV behaviour)

i would love even the most basic example of how to implement this(so i can run it ingame), i can probably work out how to customize it to do what i want after that. (i already have the script up, but how to stick it onto a missile?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Magician on October 19, 2013, 01:01:55 PM
Didn't want to create thread, so I will ask here. Though questions not really about modding, I'm sorry. Hope Alex or someone else will know the answer.

1) Why in vmparams used "-server"?
2) Why used "-XX:CompilerThreadPriority=1" and what exactly will happen if I remove it?
Now here is a short backstory. I switched native jre folder to JRockit jre. Launcher doesn't even start if -XX:CompilerThreadPriority=1 is present in vmparams, but without it game works. And iirc, JRockit by default uses "-server" mode, and when I tested game without "-server"(but in case of JRockit this parameter looks like this "-jrockit") and with it, game was running with almost twice lower FPS and also game speed was almost twice slower. Though cpu usage was lower. But after I added "-client" parameter, and run Starsector with JRockit jre(-XX:CompilerThreadPriority=1 still removed), game was running perfectly normal with 55-60FPS and average cpu load.

As you may notice, I tried to solve Out of memory problem/problem of 1.5Gb limit for java on 32-bit system. I found that JRockit manages memory differently and may give additional memory to Starsector.

3) I noticed that most of Out of memory errors are associated with game trying to load system or hyperspace background. Out of 6 errors about 5 are same: game trying to load background4.jpg or similiar texture. Can this information be usefull?
I for quite some time thought if it is possible to turn off or enable simplified backgrounds/textures for some things in game to remove some load.

4) And finally I'd like to know if there is some reliable and fast way to recreate Out of memory error. I spent couple of hours flying around whole sector, warping in systems and back, engaging multiple battles, using save loading, just to recreate error with different vmparams settings. I know for a fact that with default installation and few mods enabled (to increase memory usage) game also starts to stutter at some point, if you use hyperspace often. I'd like to test few things, but it will take quite some time if I will just play and wait if errors/stuttering will kick in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 19, 2013, 01:28:39 PM
@dmaiksi: I think that's a bit too involved for this thread.

1) Why in vmparams used "-server"?
2) Why used "-XX:CompilerThreadPriority=1" and what exactly will happen if I remove it?

The -server parameter allows the JVM to compile frequently-used code segments into optimized native code, making the game run faster overall. This compilation can take a little time (not a lot, but enough for a slight stutter); the thread priority parameter makes it low priority to minimize that effect. The -server parameter isn't necessary for the game to work.

3) I noticed that most of Out of memory errors are associated with game trying to load system or hyperspace background. Out of 6 errors about 5 are same: game trying to load background4.jpg or similiar texture. Can this information be usefull?

That's just because loading a new background needs a bunch of new memory, and if there's not enough left, it's likely to trigger the OOM. That doesn't mean the background is the underlying cause, though - it's just the most likely thing to trigger it. If it wasn't there, something else would.

4) And finally I'd like to know if there is some reliable and fast way to recreate Out of memory error. I spent couple of hours flying around whole sector, warping in systems and back, engaging multiple battles, using save loading, just to recreate error with different vmparams settings. I know for a fact that with default installation and few mods enabled (to increase memory usage) game also starts to stutter at some point, if you use hyperspace often. I'd like to test few things, but it will take quite some time if I will just play and wait if errors/stuttering will kick in.

Probably not, unless there's an actual memory leak, in which case doing whatever triggers the leak would do it. Stuttering... that depends. I know Exerelin stutters a bit just because of the scripts its running; I'd imagine the load those generate goes up as there are more fleets, so that could explain some instances of it. Other mods could have similar behavior. It could also happen if it's really close to maxing out memory usage and struggles to free enough.

Using hyperspace often really shouldn't factor into this, though. Hmm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on October 19, 2013, 03:01:30 PM
Is it possible to allow a fighter wing capability to be usable in boarding actions in the campaign?  Think a wing of small boarding craft.

It's possible, but not simple. It involves providing a different version of the fleet interaction dialog plugin.


I don't suppose you could elaborate on this?

Also, is it just me or is it not feasible to have a fighter wing with only one member in it?  It seems like if you attempt it, the fighter wing will run out of combat-capable craft if it dies, despite available CR and replacement chassis.  This could be a bug, or it could be a consequence of how the system works; i.e. does the system "queue" wings up for replacement, or does the wing become combat-incapable if all its members die and a replacement isn't being prepared on a carrier?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on October 19, 2013, 03:18:29 PM
Is it possible to allow a fighter wing capability to be usable in boarding actions in the campaign?  Think a wing of small boarding craft.

It's possible, but not simple. It involves providing a different version of the fleet interaction dialog plugin.


I don't suppose you could elaborate on this?

Also, is it just me or is it not feasible to have a fighter wing with only one member in it?  It seems like if you attempt it, the fighter wing will run out of combat-capable craft if it dies, despite available CR and replacement chassis.  This could be a bug, or it could be a consequence of how the system works; i.e. does the system "queue" wings up for replacement, or does the wing become combat-incapable if all its members die and a replacement isn't being prepared on a carrier?

For the 2nd bug, I've reported it - http://fractalsoftworks.com/forum/index.php?topic=6796.0
So two crafts are the minimum, lone craft won't resupply, and also will be killed off if they die.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 19, 2013, 03:52:25 PM
http://fractalsoftworks.com/forum/index.php?topic=7260.0
i made topic, somone please come help me!!!

on a related note how do i create a java.lang.String for:
Code: java
engine.spawnProjectile(null, null,
                        java.lang.String,
                        missile.getLocation(), 0, Pjv);
and

how do i get an engine.spawnProjectile to work in MissileAIPlugin for:
Code: java
 @Override
    public void advance(float amount)
    {

        if (MathUtils.getDistance(target, missile.getLocation()) < 400)
        {
            engine.spawnProjectile(null, null,
                    java.lang.String,
                    missile.getLocation(), 0, Pjv);
            engine.removeEntity(missile);
        }

????
help plz
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 21, 2013, 08:18:37 AM
(http://i.imgur.com/iOaiJnE.png?1)
the BISO heavy weapons reaserch department presents THOR missiles!

god that took longet then it whould have... but now i have a custom missile AI and custom mirv script that can shoot any weapon i want from a missile!!!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on October 22, 2013, 03:08:10 AM
Spoiler
(http://i.imgur.com/iOaiJnE.png?1)
[close]
the BISO heavy weapons reaserch department presents THOR missiles!

god that took longet then it whould have... but now i have a custom missile AI and custom mirv script that can shoot any weapon i want from a missile!!!

can you mount a turret on a missile?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 22, 2013, 03:45:04 AM
:P i can, see the code dump for mun code that dose stuff
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sirboomalot on October 22, 2013, 11:00:39 AM
:P i can, see the code dump for mun code that dose stuff

You can!? I know nothing of coding, or what I am looking at when I look at code, but I would love to see a "missile" that is designed to circle an enemy ship whilst shooting at it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 26, 2013, 01:13:01 PM
Is there a fixed limit on how many 'hidden'-mount weapon slots that a single custom .ship file can have?

'cause I've been getting the following crash and error message repeatedly (.ship in question has 16 'hidden' type slots, doesn't occur when reduced to 10 or below):

Code
129829 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving to ..\saves/save_Testing_8759369790073092877...
130468 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Finished saving
195523 [Thread-5] INFO  com.fs.starfarer.combat.CombatEngine  - FP1: 0, FP2: 435, maxFP1: 120, maxFP2: 180
248951 [Thread-5] ERROR com.fs.starfarer.combat.String  - java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.specs.Oo0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.getHiddenAngleOffset(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOO.B.Object(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOO.J.fireProjectile(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.String.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.String(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOO.J.advance(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.F.øÒÒ000(Unknown Source)
at com.fs.super.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2013, 01:19:27 PM
@TimeDiver: Looks like a problem with one of the hidden weapons, not slots. Probably a mismatch in the number of offsets and angleOffsets, or something along those lines. (I.E. if you have 4 values for offsets - two points from which the weapon fires - but only one value for angleOffset, instead of two.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 26, 2013, 01:40:15 PM
@TimeDiver: Looks like a problem with one of the hidden weapons, not slots. Probably a mismatch in the number of offsets and angleOffsets, or something along those lines. (I.E. if you have 4 values for offsets - two points from which the weapon fires - but only one value for angleOffset, instead of two.)
Turns out that was exactly the case; when I switched the 'hidden' mount(s) that had the faulty weapon equipped to 'turret', I mis-interpreted the results.

Thanks for clearing that one up, Alex.  :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on October 26, 2013, 08:58:30 PM
problem on Sound json in Config folder:
I was just looking to adding a custom engine and flux sound:

1) from the core I see
Spoiler
Quote
   "engine_loop":{
      "sounds":[
         {"file":"sounds/sfx_engines/engine_01_lotek_00_fighter.ogg","pitch":0.67,"volume":1}, # index:  0
         {"file":"sounds/sfx_engines/engine_01_lotek_01_frigate.ogg","pitch":1,"volume":1},    # index:  1
         {"file":"sounds/sfx_engines/engine_01_lotek_02_destroyer.ogg","pitch":1,"volume":1},  # index:  2
         {"file":"sounds/sfx_engines/engine_01_lotek_03_cruiser.ogg","pitch":1,"volume":1},    # index:  3
         {"file":"sounds/sfx_engines/engine_01_lotek_04_capital.ogg","pitch":1,"volume":1},    # index:  4
         {"file":"sounds/sfx_engines/engine_02_midtek_00_fighter.ogg","pitch":0.67,"volume":1},# index:  5
         {"file":"sounds/sfx_engines/engine_02_midtek_01_frigate.ogg","pitch":1,"volume":1},   # index:  6
         {"file":"sounds/sfx_engines/engine_02_midtek_02_destroyer.ogg","pitch":1,"volume":1}, # index:  7
         {"file":"sounds/sfx_engines/engine_02_midtek_03_cruiser.ogg","pitch":1,"volume":1},   # index:  8
         {"file":"sounds/sfx_engines/engine_02_midtek_04_capital.ogg","pitch":1,"volume":1},   # index:  9
         {"file":"sounds/sfx_engines/engine_03_hitek_00_fighter.ogg","pitch":0.67,"volume":1}, # index: 10
         {"file":"sounds/sfx_engines/engine_03_hitek_01_frigate.ogg","pitch":1,"volume":1},    # index: 11
         {"file":"sounds/sfx_engines/engine_03_hitek_02_destroyer.ogg","pitch":1,"volume":1},  # index: 12
         {"file":"sounds/sfx_engines/engine_03_hitek_03_cruiser.ogg","pitch":1,"volume":1},    # index: 13
         {"file":"sounds/sfx_engines/engine_03_hitek_04_capital.ogg","pitch":1,"volume":1},    # index: 14
         ],

      "LOW_TECH":{"sounds":[0,1,2,3,4], "pitch":1, "volume":0.5},
      "MIDLINE":{"sounds":[5,6,7,8,9], "pitch":1, "volume":0.3},
      "HIGH_TECH":{"sounds":[10,11,12,13,14], "pitch":1, "volume":0.5},
      "FIGHTER":{"sounds":[0,5,10], "pitch":1, "volume":0.4},
      "FRIGATE":{"sounds":[1,6,11], "pitch":1, "volume":0.7},
      "DESTROYER":{"sounds":[2,7,12], "pitch":1, "volume":0.7},
      "CRUISER":{"sounds":[3,8,13], "pitch":1, "volume":0.7},
      "CAPITAL_SHIP":{"sounds":[4,9,14], "pitch":1, "volume":1},   
      },
[close]

and from the other mod i see if I add any engine sound the first sound needed to be starting at #15.

so..when I already have another mod that did the same thing, say added the #15 engine sound, how will I know when I am adding mine it will be #15 or #16?

and if i treat it as #16, later when disable that mod and just use my mod that added #16 sound which naturally become #15, my "CAPITAL_SHIP":{"sounds":[16], "pitch":1, "volume":1},   will then be invalid right?


same goes for the flux....since the core already use #0 so i am very confused when other mod use #1 and should I use #2 and never disable that mod...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2013, 09:11:06 AM
Yeah that... doesn't work very well, as far as being extensible by mods. Something I need to take a look at; it's on my list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on October 27, 2013, 11:41:39 AM
@ dmaiski that seems extremely useful, very well done!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 27, 2013, 05:25:59 PM
is it just me, or is .setAngularVelocity() and .getAngularVelocity() broken/not returning corect values/non functional

Code: java
proj.setAngularVelocity(2000f);  //what i tried in an EveryFrameCombatPlugin, result:no projectile is fired at all
proj.setAngularVelocity(.getAngularVelocity()*1.5f);    //next attempt, result:projectile is fired, no change in speed
// when  I try to use getAngularVelocity() in AI scripts (i write alot of these)
// it returns wrong values  that are completly diffrent from   .getVelocity().lengthSquared()
//.getVelocity().lengthSquared() returns the correct values BTW...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2013, 06:01:29 PM
Angular velocity is only applicable to ships and missiles, and is, well, the angular velocity. It's how fast something is turning, in degrees per second.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on October 28, 2013, 12:13:49 AM
ah... that sort of makes sense
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 29, 2013, 09:49:28 PM
Is there any way to get to WeaponAPI (or WeaponSlotAPI) from FleetMemberAPI (or ShipVariantAPI)? Are the way variants are implemented and the way slots are represented in combat just completely different?

What I'm really looking for is information about arc and facing of weapon slots from the campaign level. I can get string identifiers of weapons from methods in ShipVariantAPI and from there get the WeaponSpecAPI to get me the weapon type, but I can't get turret arc or boolean isHardpoint etc methods.

Also, are the values returned by ShipHullTypeAPI.getFluxCapacity() and friends base values unmodified by caps/vents installed and/or skills? As they don't call character stats I'm thinking they are base, but I'm not sure.

I'm looking at writing a basic variant producer routine... who knows if it will work, but its worth a shot. Also with persistent data I could make a genetic algorithm out of it muahahahaha (but I won't).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 30, 2013, 09:20:35 AM
Is there any way to get to WeaponAPI (or WeaponSlotAPI) from FleetMemberAPI (or ShipVariantAPI)? Are the way variants are implemented and the way slots are represented in combat just completely different?

What I'm really looking for is information about arc and facing of weapon slots from the campaign level. I can get string identifiers of weapons from methods in ShipVariantAPI and from there get the WeaponSpecAPI to get me the weapon type, but I can't get turret arc or boolean isHardpoint etc methods.

Right, WeaponSpecAPI isn't exactly fleshed out. Also, that wouldn't have facing/arcs etc, that'd just be weapon data.

Take a look at List<WeaponSlotAPI> getAllWeaponSlotsCopy(); in ShipHullSpecAPI, though - that should have what you need.

Edit: you'd get at that via ShipVariantAPI.getHullSpec().

Also, are the values returned by ShipHullTypeAPI.getFluxCapacity() and friends base values unmodified by caps/vents installed and/or skills? As they don't call character stats I'm thinking they are base, but I'm not sure.

Base, unmodified.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 30, 2013, 11:25:50 AM
Thanks very much!
...
Right, WeaponSpecAPI isn't exactly fleshed out. Also, that wouldn't have facing/arcs etc, that'd just be weapon data.

Take a look at List<WeaponSlotAPI> getAllWeaponSlotsCopy(); in ShipHullSpecAPI, though - that should have what you need.

Edit: you'd get at that via ShipVariantAPI.getHullSpec().
...

Unfortunately getAllWeaponSlotsCopy isn't in the API yet for .6.1a, but I'm not really in a hurry :D.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 31, 2013, 09:51:10 AM
Unfortunately getAllWeaponSlotsCopy isn't in the API yet for .6.1a, but I'm not really in a hurry :D.

Ooops :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on October 31, 2013, 07:09:06 PM
I use the simulator in the debug version of StarSector a lot for balancing my ships...but it only lets me fight vanilla ships, and then, only one of each. So. My questions are:

1) How do I fight my own ships in the simulator (so I can see how the AI handles them)?

2) How do I fight multiples of the same ship?

3) How do I remove the 60pt limit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on October 31, 2013, 10:18:32 PM
You can extend data/campaign/sim_opponents.csv in your mod to include any mod ship you would like. To fight the same ship more than once simply put it in the csv more than once and select them. I'm not sure about the 60 fp limit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on October 31, 2013, 10:34:39 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Magician on November 03, 2013, 02:05:46 PM
After some messing with notepad and mod template I have few questions.

1) Is there any documentation about all those parameters used in CSV files,wpn, proj and others? I found some bits of information here and there, but part of the information missing.

2) I want to create a very large, about 100x100 pixels, projectile for plasma weapon. Increasing numbers in default plasma cannon file indeed makes projectile bigger. But it looks more like a star-shaped tentacle monster and less like plasma ball. Is it a limitation of how plasma effect created in Starsector or am I missing something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on November 05, 2013, 11:03:32 AM
Are there any functions that return a list of systems in the campaign? Like the one that return the current list of weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on November 05, 2013, 12:13:54 PM
Are there any functions that return a list of systems in the campaign? Like the one that return the current list of weapons?

Code
List systems = Global.getSector().getStarSystems();

:)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 05, 2013, 01:49:42 PM
1) Is there any documentation about all those parameters used in CSV files,wpn, proj and others? I found some bits of information here and there, but part of the information missing.

There were some threads here talking about them in some detail; probably linked to from here (http://fractalsoftworks.com/forum/index.php?topic=633.0). Beyond that, there's the official modding documentation section, but that's a work in progress and I haven't been able to devote very much time to it. Things like .wpn/.proj etc are lower priority, too, because there are lots of examples in the vanilla portion of the game. Easiest thing to do is take a weapon that's similar to what you want and go from there.

2) I want to create a very large, about 100x100 pixels, projectile for plasma weapon. Increasing numbers in default plasma cannon file indeed makes projectile bigger. But it looks more like a star-shaped tentacle monster and less like plasma ball. Is it a limitation of how plasma effect created in Starsector or am I missing something?

Limitation. The effect is hardcoded (aside from the colors/size) and will only look good up to a certain size.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on November 06, 2013, 06:28:43 AM
Code
List systems = Global.getSector().getStarSystems();
:)
Great, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on November 06, 2013, 08:02:26 AM
Sorry if the question has already been asked. How to make activation shipsystem play frame-by-frame animation of decorative weapon and stopped as soon as the system stopped working?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on November 06, 2013, 08:24:56 AM
Sorry if the question has already been asked. How to make activation shipsystem play frame-by-frame animation of decorative weapon and stopped as soon as the system stopped working?

The simplest way is to create an EveryFrameWeaponEffectPlugin that controls when the animation plays. That'd look something like this:
Code: java
package data.scripts.weapons;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;

public class AnimateWhenSystemActive implements EveryFrameWeaponEffectPlugin
{
    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        // Using isActive() instead will make the animation play during chargedown as well
        if (weapon.getShip().getSystem().isOn())
        {
            weapon.getAnimation().play();
        }
        else
        {
            weapon.getAnimation().setFrame(0);
            weapon.getAnimation().pause();
        }
    }
}

And then you'd add the following line to your decorative weapon's .wpn file to tell it to use that plugin:
Code
    "everyFrameEffect":"data.scripts.weapons.AnimateWhenSystemActive",		

That seems like it should work. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on November 06, 2013, 08:53:51 AM
OH GAWD HE'S ALIVE =O
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on November 06, 2013, 03:29:16 PM
Is there any way I can get ShipHullName() from a FleetMemberAPI? I can get the Id, or the variant full name via the .getVariant().getFullDesignationWithHullName(), still I could't find a way to find the Hull Name.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on November 06, 2013, 04:03:07 PM
Is there any way I can get ShipHullName() from a FleetMemberAPI? I can get the Id, or the variant full name via the .getVariant().getFullDesignationWithHullName(), still I could't find a way to find the Hull Name.

Thanks!

I don't actually think there is a way (unless it has been added recently) :(
(I'm assuming you want it with _Hull or _wing so that it can be spawned in station etc.)

I do this:
Code
fmAPI = null; //TODO set this to your FleetMemberAPI object

String shipId = fmAPI.getHullId(); // The ship hull id
FleetMemberType memberType = fmAPI.getType(); // The fleet member type

if(memberType == FleetMemberType.FIGHTER_WING)
   shipId = shipId + "_wing";
else if (memberType == FleetMemberType.SHIP)
   shipId = shipId + "_Hull";


There may be a better way.

The FIGHTER_WING stuff is especially messy when mods don't follow the convention of <fightername>_wing. There is a bit of handling code in Exerelin for fighter wings in mods that don't follow the convention.

See here (https://bitbucket.org/Zaphide/exerelin/src/9c2cd23f67b70b2ac3284587f2dc1bbabf1780bb/data/scripts/world/exerelin/ExerelinUtils.java?at=master) for the full code (with handling stuff) (go to the addRandomFactionShipsToCargo method).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on November 06, 2013, 04:10:21 PM
Thanks Zaph! I actually want something like "Buffalo mk2" instead of "buffalo2" to put into dialogues, I have no problem spawning stuff into stations as I compiled a full list for all the factions in UsS ^^!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on November 06, 2013, 04:32:17 PM
Ah OK, yeah I typed that out then thought 'hmmm perhaps that was not being asked' but posted it anyways :P

So you want the hullName? Yeah I can't see anything promising in the API either sorry :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 06, 2013, 04:43:22 PM
how do i get the max speed of a missile

missile.getWeapon().getProjectileSpeed dose not work...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Magician on November 07, 2013, 07:54:11 AM
How do I go about making arc-like projectile? Ideally its something like beam projectile which flies expanding, keeping original form. I probably can copy shotgun examples from other mods, but I really wanted to make something just like shown on picture.
As a secondary idea, projectile passes through everything in its way, dealing damage once. This would be perfect implementation of what I imagine.
Example:
Spoiler
(http://i.imgur.com/GsphDWr.gif)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2013, 09:35:15 AM
Thanks Zaph! I actually want something like "Buffalo mk2" instead of "buffalo2" to put into dialogues, I have no problem spawning stuff into stations as I compiled a full list for all the factions in UsS ^^!

Ooops - added Added ShipHullSpecAPI.getHullName() to the api.

how do i get the max speed of a missile

missile.getWeapon().getProjectileSpeed dose not work...

Currently can't for guided missiles, though it does work for rockets.

How do I go about making arc-like projectile? Ideally its something like beam projectile which flies expanding, keeping original form. I probably can copy shotgun examples from other mods, but I really wanted to make something just like shown on picture.
As a secondary idea, projectile passes through everything in its way, dealing damage once. This would be perfect implementation of what I imagine.
Example:
Spoiler
(http://i.imgur.com/GsphDWr.gif)
[close]

This isn't something the engine supports directly. You could maybe do something similar by using emp arcs and invisible projectiles to do actual damage, or having a dense spread of projectiles. A "beam" like that just won't work. Well, I suppose I shouldn't say that, as someone might come up with a way, but I can't see how :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sirboomalot on November 07, 2013, 10:43:44 AM
How do I go about making arc-like projectile? Ideally its something like beam projectile which flies expanding, keeping original form. I probably can copy shotgun examples from other mods, but I really wanted to make something just like shown on picture.
As a secondary idea, projectile passes through everything in its way, dealing damage once. This would be perfect implementation of what I imagine.
Example:
Spoiler
(http://i.imgur.com/GsphDWr.gif)
[close]

This isn't something the engine supports directly. You could maybe do something similar by using emp arcs and invisible projectiles to do actual damage, or having a dense spread of projectiles. A "beam" like that just won't work. Well, I suppose I shouldn't say that, as someone might come up with a way, but I can't see how :)

Perhaps with the projectiles constantly splitting just enough to keep the shape as it grows?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 07, 2013, 11:48:24 AM
constantly splitting projetiles is verry laggy if you want to get enough density to for a line...

im thinking non-coliding projectiles and addSmoothParticle stream going between them
then code to check if anything is crossing the line between the non-coliding bullets

would need:
script to convert 1 bullet(fired from weapon) into 4 bullets (named a,b,c, d) wich form the angular points(and ends) on the wave
script to make the particle stream (and calculate the direction to shoot them at)
script to check if a ship will take damage from the wave

(im sort of half working on something similar but for pew pew arking seekig beams of death(cause missiles are not wtf enough, mind you the C1's ray of twisty death is pretty epic))
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Magician on November 07, 2013, 04:35:33 PM
Another two questions.
How to make drones automatically recall after certain time?
Is it possible to have two different drones within one shipsystem?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on November 07, 2013, 04:50:09 PM
Have no idea for the first one. Doesn't seem impossible to do however.

For the second, how about the first drone that spawn the second one?

Or else, i think Pysion managed to add a second ship system to a ship (the Harlem shake ship). I don't think the IA can handle it very well though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on November 09, 2013, 10:03:03 AM
Is it just me or does it seem like missiles don't get custom explosion sounds from a proximity fuse? It just plays the normal impact sound from the core game no matter what sound I specify.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 09, 2013, 10:04:23 AM
prox fuse dose not even work with missiles...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on November 09, 2013, 10:14:51 AM
It works with PHASE_CHARGE missile type.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Magician on November 10, 2013, 04:15:35 AM
I wonder if its possible to have custom animated weapon sprite for certain weapon mount. And this animation will override any sprite of weapons mounted in this slot.
The idea is to create large launching pod for missiles. You can choose any ingame missile weapon, but weapon sprite and animation will stay of the custom launching pod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on November 12, 2013, 03:31:45 PM
Sorry for all the questions - I'm trying to create a station with an extra dialogue topic, added using its own dialog plugin, but unfortunately the default station code uses enums & cases. I've been through and tweaked a pile of things but I'm still getting this error:
Code
Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/BountyInteractionDialogPlugin.java, Line 213, Column 77: 
A method named "isFighterWing" is not declared in any enclosing class nor any supertype, nor through a static import
Referring to this completely unmodified line of code:
Code
if (playerFleet.getFleetData().getMembersListCopy().get(0).isFighterWing()) {

However, I do import FleetMemberAPI in the file. I also import pretty much everything in the example asteroid plugin, and everything in the station plugin, and a few other things I needed to add lists & iteration to replace bits of the station code that wouldn't compile:
Code
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.lwjgl.input.Keyboard;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CoreInteractionListener;
import com.fs.starfarer.api.campaign.CoreUITabId;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.InteractionDialogPlugin;
import com.fs.starfarer.api.campaign.OptionPanelAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.TextPanelAPI;
import com.fs.starfarer.api.campaign.VisualPanelAPI;
import com.fs.starfarer.api.combat.EngagementResultAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;             <========
import com.fs.starfarer.api.ui.ValueDisplayMode;
What might be causing this error? Is tipping everything and the kitchen sink onto the pile causing issues, or am I just missing something.

Full code in spoilers:
Spoiler
Code
package data.scripts;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.lwjgl.input.Keyboard;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CoreInteractionListener;
import com.fs.starfarer.api.campaign.CoreUITabId;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.InteractionDialogPlugin;
import com.fs.starfarer.api.campaign.OptionPanelAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.TextPanelAPI;
import com.fs.starfarer.api.campaign.VisualPanelAPI;
import com.fs.starfarer.api.combat.EngagementResultAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.ui.ValueDisplayMode;


public class BountyInteractionDialogPlugin implements InteractionDialogPlugin, CoreInteractionListener {

private static class OptionId {
public static OptionId INIT = new OptionId();
public static OptionId INIT_NO_TEXT = new OptionId();
public static OptionId TRADE_CARGO = new OptionId();
public static OptionId TRADE_SHIPS = new OptionId();
public static OptionId REFIT = new OptionId();
public static OptionId REPAIR_ALL = new OptionId();
public static OptionId LEAVE = new OptionId();
public static OptionId BOUNTY_MENU = new OptionId();
}
private InteractionDialogAPI dialog;
private TextPanelAPI textPanel;
private OptionPanelAPI options;
private VisualPanelAPI visual;

private CampaignFleetAPI playerFleet;
private SectorEntityToken station;

private static final Color HIGHLIGHT_COLOR = Global.getSettings().getColor("buttonShortcut");

public void init(InteractionDialogAPI dialog) {
this.dialog = dialog;
textPanel = dialog.getTextPanel();
options = dialog.getOptionPanel();
visual = dialog.getVisualPanel();

playerFleet = Global.getSector().getPlayerFleet();
station = (SectorEntityToken) dialog.getInteractionTarget();

visual.setVisualFade(0.25f, 0.25f);
dialog.setOptionOnEscape("Leave", OptionId.LEAVE);

optionSelected(null, OptionId.INIT);
}

private EngagementResultAPI lastResult = null;
public void backFromEngagement(EngagementResultAPI result) {
// no combat here, so this won't get called
}

public void optionSelected(String text, Object optionData) {
if (optionData == null) return;

OptionId option = (OptionId) optionData;

if (text != null) {
textPanel.addParagraph(text, Global.getSettings().getColor("buttonText"));
}

if (option == OptionId.INIT){
addText(getString("approach"));
}
else if (option == OptionId.INIT_NO_TEXT){
createInitialOptions();
if (station.getCustomInteractionDialogImageVisual() != null) {
visual.showImageVisual(station.getCustomInteractionDialogImageVisual());
} else {
visual.showImagePortion("BountyGraphics", "BountyStationIllustration", 400, 400, 0, 0, 400, 400);
}
}
else if (option == OptionId.TRADE_CARGO){
addText(getString("tradeCargo"));
options.clearOptions();
visual.showCore(CoreUITabId.CARGO, station, station.getFaction().isNeutralFaction(), this);
}
else if (option == OptionId.TRADE_SHIPS){
addText(getString("tradeShips"));
options.clearOptions();
visual.showCore(CoreUITabId.FLEET, station, station.getFaction().isNeutralFaction(), this);
}
else if (option == OptionId.REFIT){
addText(getString("refit"));
options.clearOptions();
visual.showCore(CoreUITabId.REFIT, station, station.getFaction().isNeutralFaction(), this);
}
else if (option == OptionId.REPAIR_ALL){
performRepairs();
createInitialOptions();
}
else if (option == OptionId.LEAVE){
Global.getSector().setPaused(false);
dialog.dismiss();
}
else if (option == OptionId.BOUNTY_MENU){
options.clearOptions();
addText("You browse range of bounties posted at the station.");
}
}

private void performRepairs() {
addText(getString("repair"));
float supplies = playerFleet.getCargo().getSupplies();
float needed = playerFleet.getLogistics().getTotalRepairSupplyCost();

textPanel.highlightLastInLastPara("" + (int) needed, HIGHLIGHT_COLOR);

//for (FleetMemberAPI member : playerFleet.getFleetData().getMembersListCopy()) {
List fleetMembersList = playerFleet.getFleetData().getMembersListCopy();
for( int i=0;i< fleetMembersList.size();i++){
FleetMemberAPI member = (FleetMemberAPI) fleetMembersList.get(i);
member.getStatus().repairFully();
float max = member.getRepairTracker().getMaxCR();
float curr = member.getRepairTracker().getBaseCR();
if (max > curr) {
member.getRepairTracker().applyCREvent(max - curr, "Repaired at station");
}
}
if (needed > 0) {
playerFleet.getCargo().removeSupplies(needed);
}
}

private void createInitialOptions() {
options.clearOptions();

if (station.getFaction().isNeutralFaction()) {
options.addOption("Transfer cargo or personnel", OptionId.TRADE_CARGO);
options.setShortcut(OptionId.TRADE_CARGO, Keyboard.KEY_I, false, false, false, true);
options.addOption("Transfer ships to or from this station", OptionId.TRADE_SHIPS);
options.setShortcut(OptionId.TRADE_SHIPS, Keyboard.KEY_F, false, false, false, true);
options.addOption("Make use of the dockyard's refitting facilities", OptionId.REFIT);
options.setShortcut(OptionId.REFIT, Keyboard.KEY_R, false, false, false, true);
} else {
options.addOption("Trade, or hire personnel", OptionId.TRADE_CARGO);
options.setShortcut(OptionId.TRADE_CARGO, Keyboard.KEY_I, false, false, false, true);
options.addOption("Buy or sell ships", OptionId.TRADE_SHIPS, null);
options.setShortcut(OptionId.TRADE_SHIPS, Keyboard.KEY_F, false, false, false, true);
options.addOption("Make use of the dockyard's refitting facilities", OptionId.REFIT);
options.setShortcut(OptionId.REFIT, Keyboard.KEY_R, false, false, false, true);
options.addOption("Check posted bounties", OptionId.BOUNTY_MENU);
}

if (station.getFaction().getRelationship(playerFleet.getFaction().getId()) >= 0) {
float needed = playerFleet.getLogistics().getTotalRepairSupplyCost();
float supplies = playerFleet.getCargo().getSupplies();
options.addOption("Repair your ships at the station's dockyard", OptionId.REPAIR_ALL);
options.setShortcut(OptionId.REPAIR_ALL, Keyboard.KEY_A, false, false, false, true);

Color[] highlights = { HIGHLIGHT_COLOR, HIGHLIGHT_COLOR};
String[] repairtext = { "" + (int) needed, "" + (int) supplies};

if (needed <= 0) {
options.setEnabled(OptionId.REPAIR_ALL, false);
options.setTooltip(OptionId.REPAIR_ALL, getString("repairTooltipAlreadyRepaired"));
} else if (supplies < needed) {

options.setEnabled(OptionId.REPAIR_ALL, false);
options.setTooltip(OptionId.REPAIR_ALL, getString("repairTooltipNotEnough"));
options.setTooltipHighlightColors((Object) OptionId.REPAIR_ALL, highlights);
options.setTooltipHighlights((Object) OptionId.REPAIR_ALL, repairtext);
} else {
options.setTooltip(OptionId.REPAIR_ALL, getString("repairTooltip"));
options.setTooltipHighlightColors((Object) OptionId.REPAIR_ALL, highlights);
options.setTooltipHighlights((Object) OptionId.REPAIR_ALL, repairtext);
}
}

options.addOption("Leave", OptionId.LEAVE);
}


private OptionId lastOptionMousedOver = null;
public void optionMousedOver(String optionText, Object optionData) {

}

public void advance(float amount) {

}

private void addText(String text) {
textPanel.addParagraph(text);
}

private void appendText(String text) {
textPanel.appendToLastParagraph(" " + text);
}

private String getString(String id) {
String str = Global.getSettings().getString("stationInteractionDialog", id);

String fleetOrShip = "fleet";
if (playerFleet.getFleetData().getMembersListCopy().size() == 1) {
fleetOrShip = "ship";
if (playerFleet.getFleetData().getMembersListCopy().get(0).isFighterWing()) {
fleetOrShip = "fighter wing";
}
}
str = str.replaceAll("\\$fleetOrShip", fleetOrShip);
str = str.replaceAll("\\$stationName", station.getFullName());

float needed = playerFleet.getLogistics().getTotalRepairSupplyCost();
float supplies = playerFleet.getCargo().getSupplies();
str = str.replaceAll("\\$supplies", "" + (int) supplies);
str = str.replaceAll("\\$repairSupplyCost", "" + (int) needed);

return str;
}


public Object getContext() {
return null;
}

public void coreUIDismissed() {
optionSelected(null, OptionId.INIT_NO_TEXT);
}
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 12, 2013, 03:44:08 PM
Another two questions.
How to make drones automatically recall after certain time?
Is it possible to have two different drones within one shipsystem?

1) Can't.
2) No (unless drones spawn drones, as mentioned).

Is it just me or does it seem like missiles don't get custom explosion sounds from a proximity fuse? It just plays the normal impact sound from the core game no matter what sound I specify.

Yeah, that's just kind of how it works. At the moment, anyway, though I don't see getting to change that any time soon.


@Talkie Toaster: Janino doesn't support generics, so the result of .get(0) is an Object rather than a FleetMemberAPI. You'll need to cast it, i.e.:
if (((FleetMemberAPI)playerFleet.getFleetData().getMembersListCopy().get(0)).isFighterWing()) {
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 12, 2013, 06:37:17 PM
also ypu may want to look into geting an IDE(they are free) it makes things much faster, and the good ones can even tell you when your doing it wrong (the awsome ones even give sugestions XD)

i would sugest IntelliJ, cause i use it... but thats just me(btw open source comunit edition is free)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on November 13, 2013, 04:43:42 AM
I'm trying to get my mod so shields and weapons work like every other game - as in, seperate. How do I make my weapons able to fire whilst the ship is overloaded, so flux can be purely shield strength?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on November 13, 2013, 05:09:14 AM
@Talkie Toaster: Janino doesn't support generics, so the result of .get(0) is an Object rather than a FleetMemberAPI. You'll need to cast it, i.e.:
if (((FleetMemberAPI)playerFleet.getFleetData().getMembersListCopy().get(0)).isFighterWing()) {

Ah, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 13, 2013, 04:37:03 PM
I'm trying to get my mod so shields and weapons work like every other game - as in, seperate. How do I make my weapons able to fire whilst the ship is overloaded, so flux can be purely shield strength?

You can't. There's no way to make weapons be able to fire while a ship is overload (never mind what changing that would do to the AI!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sirboomalot on November 13, 2013, 07:33:41 PM
I'm trying to get my mod so shields and weapons work like every other game - as in, seperate. How do I make my weapons able to fire whilst the ship is overloaded, so flux can be purely shield strength?

You could make the ships have a drone that controls the shield while your ship controls weaponry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on November 17, 2013, 12:55:07 AM
Hi all again. Many thanks for answering my previous question. Again I need a piece of advice. Is there a way to make hullmod, which would have increased the effectiveness of boarding with the participation of the ship on which it is installed? Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 18, 2013, 08:59:26 AM
Hi all again. Many thanks for answering my previous question. Again I need a piece of advice. Is there a way to make hullmod, which would have increased the effectiveness of boarding with the participation of the ship on which it is installed? Thanks in advance.

there is, getMarineEffectivnessMult() can apply the stat you want
look through the repair gantry hull mod scrips and the campaign plugins if you want an idea of what can be done with this...
find it in
\Starsector\starsector-core\starfarer.api.zip

starfarer.api.zip\com\fs\starfarer\api\impl\campaign\RepairGantry.java

or at least that should get you started, i dont have an exact method for you to use...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 18, 2013, 02:36:04 PM
whats the WeaponAPI equivelant of: ShipAPI launchingShip
ie something that works irregardless of the ship/weapon being alive/active/still in play
need badly for my AI systems
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 18, 2013, 04:49:24 PM
WeaponAPI.getShip() returns the ship the weapon is mounted on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 18, 2013, 11:53:01 PM
WeaponAPI.getShip() returns the ship the weapon is mounted on.
but i need the weapon that fired it, not the ship
and once ship dies all getWeapon return null...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: etherealblade on November 19, 2013, 11:02:52 PM
Is it possible to add your own custom music track that only plays when you enter a specific system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 21, 2013, 06:28:06 PM
1. is there some way to use phase skimm blurr effect in a script without using phase skim?

2. is htere some way to make a ships shileld non-coliding, so it dose not interact with attacks?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on November 21, 2013, 06:35:26 PM
I don't think no. 1 can be done atm, but no. 2 can be done by forcing the shield to zero-size.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on November 21, 2013, 08:04:29 PM
Is it just me or does it seem like missiles don't get custom explosion sounds from a proximity fuse? It just plays the normal impact sound from the core game no matter what sound I specify.

Copying my AOE missiles I see...  ;)

At the moment, it looks like all missile or projectile impacts are coded to use only the default weapon impact sounds. If I recall correctly, that gives a choice of kinetic, high explosive, energy, or beam impact sounds to choose from. You could potentially add impact sounds to each category in the sounds.json file, but then everything else in the category would use them too. What you'd need to do is create a separate projectile impact class (like KINETIC2) and give that class its own set of impact sounds. At the moment, I don't think this is possible, but if you figure out a way, let me know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on November 21, 2013, 10:02:03 PM
Just use playSound()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 21, 2013, 11:27:37 PM
I don't think no. 1 can be done atm, but no. 2 can be done by forcing the shield to zero-size.

how? when i do it from ship files it causes bug
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on November 23, 2013, 08:24:27 PM
Hi,

       I get an error 15085 [Thread-6] ERROR com.fs.starfarer.combat.String  - org.json.JSONException: JSONObject["displayName"] not found.
I think I've nailed it down to my faction file. However I simply don't understand what's going on. I've looked all over the place for an answer to this. I'll post my faction file, if anyone's willing to look at it, maybe I'm just not looking in the correct place, or I'm overlooking something.

Spoiler
Quote
{
   id:"MercCom",
   "color":[54,89,86,255],
   "displayName":"Merc Com",
   "shipNamePrefix":"MCV",
   "shipNameSources":{
      "ROMAN":2,
      "GREEK":1,
     "MCOM_MISC":2,
   },
   "description":"A diverse union of mercenaries and tradesmen engaged in all manner of conduct.",
   "names":{
      "old english":1,
     "fringe":1,
     "modern":1,
   },
   "portraits":{
      "standard_male":[
         "graphics/portraits/portrait_hegemony01.png",
         "graphics/portraits/portrait_hegemony02.png",
         "graphics/portraits/portrait_hegemony05.png",
         "graphics/portraits/portrait_mercenary01.png",
         "graphics/portraits/portrait_mercenary03.png",
         "graphics/portraits/portrait13.png",
         "graphics/portraits/portrait15.png",
      ],
      "standard_female":[
         "graphics/portraits/portrait_hegemony03.png",
         "graphics/portraits/portrait_hegemony04.png",
         "graphics/portraits/portrait_mercenary02.png",
         "graphics/portraits/portrait16.png",
      ],
   },
   "fleetCompositions":{
      "patrol":{
         "displayName":"Scout",
         "maxFleetPoints":12,
         "daysWorthOfSupplies":[30, 50],
         "lyWorthOfFuel":[30, 50],
         "extraCrewPercent":[1, 5],
         "marinesPercent":[2, 3],
         "ships":{
            "harasser_Guerilla":[1, 4],
         "harasser_Skrimisher":[1, 4],
         "raptor_stock":[0,1],
         },
      },
     "huntkill":{
      "displayName":"Hunter Killer",
      "maxFleetPoints":36,
      "daysWorthOfSupplies":[20, 40],
      "lyWorthOfFuel":[20, 40],
      "extraCrewPercent":[80, 80],
      "marinesPercent":[20, 20],
      "ships":{
         "vespa_stock":[1,2],
         "whelp_wing":[0,1],
         "daggus_fighter_wing":[0,1],
         "harasser_huntkill":[0,1],
      },
      "raid":{
         "displayName":"Raiding Party",
         "maxFleetPoints":50,
         "daysWorthOfSupplies":[30, 50],
         "lyWorthOfFuel":[30, 50],
         "extraCrewPercent":[5, 10],
         "marinesPercent":[5, 10],
         "ships":{
            "harasser_Guerilla":[0, 4],
            "harasser_Skrimisher":[0, 4],
         "daggus_fighter_wing": [1,2],
         "wishbone_obsolete":[0, 2],
         "wishbone_adv":[0, 2],
         "ahiga_wing": [2, 4],
         "cadeus_assault": [0, 1],
         "korban_stock": [0, 1],
         "raptor_stock": [1,3],
         "steward_stock":[1,1],
         "steward_assault":[0,1],
         "polkan_wing":[0,1],
         "whelp_wing":[0,1],
         "cataman_stock":[0,1],
         },
      },
      "attack":{
         "displayName":"Assault Squadron",
         "maxFleetPoints": 260,
         "daysWorthOfSupplies":[30, 50],
         "lyWorthOfFuel":[30, 50],
         "extraCrewPercent":[5, 10],
         "marinesPercent":[5, 10],
         "ships":{
            "harasser_Skrimisher":[0, 1],
         "harasser_huntkill":[0,2],
         "daggus_fighter_wing": [2,4],
         "wishbone_adv":[1, 4],
         "rndhd_elite":[0, 2],
         "stainless_stock": [0,2],
         "wishbone_e_adv": [0,1],
         "ahiga_wing": [0, 2],
         "cadeus_assault": [1, 3],
         "cadeus_support": [0, 2],
         "korban_stock": [0, 2],
         "raptor_stock": [0,3],
         "steward_stock":[1,2],
         "steward_assault":[1,2],
         "diplomat_stock": [1,4],
         "victory_obsolete": [0,1],
         "victory_assault": [1,2],
         "romach_assault": [1,3],
         "whelp_wing":[2,3],
         "cataman_stock":[1,2],
         "cataman_closesupport":[0,1],
         "velites_standard":[2,3],
         "polkan_wing":[2,3],         
         },
      },
      "systemDefense":{
         "displayName":"Defense Fleet",
         "maxFleetPoints":320,
         "daysWorthOfSupplies":[30, 50],
         "lyWorthOfFuel":[30, 50],
         "extraCrewPercent":[5, 10],
         "marinesPercent":[5, 10],
         "ships":{
         "rndhd_elite":[1, 8],
         "wishbone_adv":[1, 2],
         "daggus_fighter_wing": [2,6],
         "polkan_wing":[2,4],
         "harasser_huntkill":[0,2],
         "harasser_Skrimisher":[1, 3],
         "stainless_stock": [0,3],
         "wishbone_e_adv": [0,1],
         "ahiga_wing": [2, 4],
         "cadeus_assault": [1, 4],
         "cadeus_support": [1, 3],
         "korban_stock": [1,3],
         "raptor_stock": [0,3],
         "diplomat_stock": [2,5],
         "victory_assault": [1,4],
         "romach_assault": [3,4],
         "cataman_stock":[2,3],
         "cataman_closesupport":[1,2],
         "rook_standard":[3,5],
         "whelp_wing":[2,4],
         },
      },
      "supplyConvoy":{
         "displayName":"Supply Fleet",
         "maxFleetPoints":100,
         "daysWorthOfSupplies":[100, 150],
         "lyWorthOfFuel":[30, 50],
         "extraCrewPercent":[5, 10],
         "marinesPercent":[5, 10],
         "ships":{
            "atlas_Standard":[2, 4],
            "wishbone_obsolete":[2, 4],
         "daggus_fighter_wing": [1,2],
         "harasser_Skrimisher":[3, 6],
         "buffalo_Standard":[0, 3],
         "stainless_stock": [0,1],
         "wishbone_e_adv": [0,1],
         "ahiga_wing": [1, 2],
         "raptor_stock": [0,1],
         "diplomat_stock": [1,1],
         "romach_assault": [0,1],
         },
      },
      "fuelConvoy":{
         "displayName":"Fuel Barge",
         "maxFleetPoints":100,
         "daysWorthOfSupplies":[30, 50],
         "lyWorthOfFuel":[120, 200],
         "extraCrewPercent":[5, 10],
         "marinesPercent":[5, 10],
         "ships":{
            "phaeton_Standard":[1, 3],
         "daggus_fighter_wing": [1,2],
         "dram_Light":[3, 6],
         "harasser_Skrimisher":[3, 6],
         "wishbone_obsolete":[2, 4],
         "rndhd_obsolete":[0, 2],   
         "stainless_stock" :[0,1],
         "ahiga_wing": [1, 2],
         "cadeus_assault": [0,1],
         "raptor_stock": [0,1],
         "romach_assault": [0,1],
         },
         },
      },
      "personnelConvoy":{
         "displayName":"Personnel Convoy",
         "maxFleetPoints":80,
         "daysWorthOfSupplies":[30, 50],
         "lyWorthOfFuel":[30, 50],
         "extraCrewPercent":[5, 10],
         "marinesPercent":[10, 20],
         "ships":{
            "valkyrie_Elite":[2, 4],
            "harasser_Skrimisher":[3, 6],
         "daggus_fighter_wing": [1,2],
         "wishbone_obsolete":[2, 4],
         "rndhd_obsolete":[0, 1],
         "stainless_stock": [0,1],
         "ahiga_wing": [1, 2],
         "cadeus_assault": [0,1],
         "raptor_stock": [0,1],
         "romach_assault": [0,1],
         },
      },         
   
   "traits":{
      "admiral":{
         
      },
      "captain":{
         "cowardly":1,
         "cautious":1,
         "steady":1,
         "aggressive":1,
         "suicidal":1,
         "fearless":1,
      },
   },
   "dialogue":{
      "greetingFriendly":"Greetings. Can we do something for you?",
      "greetingNeutral":"We are Members of the Mercenary Commonwealth. Inquiries are filed at our nearest Orbital base.",
      "greetingHostileAggressive":"Is there any place in particular you want us to send your bits?",
      "greetingHostileTimid":"We're currently on assignment. We'll allow you to leave this time.",
   }
   },
},
[close]

Any and all help is greatly appreciated
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 23, 2013, 08:33:03 PM
its unhappy with one of your "displayNAME" stats, try systematicaly deleting anything that uses that one at a time till it stops giving you the error. then you found your bug
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maximilianyuen on November 24, 2013, 07:00:12 AM
just to quick check if anyone can help narrow down where should I look at to fix this error....

I checked all the "id" parts in my code in .ship/.wpn/.system/.proj which got this line

{
   "id":"eonex_main",  # this id must match what's in the spreadsheet

which is the only place i know could lead to this error....

Spoiler
Code
8453 [Thread-9] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [org.lazywizard.lazylib.LazyLib] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
8614 [Thread-6] ERROR com.fs.starfarer.combat.String  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
at org.json.JSONObject.get(JSONObject.java:406)
at org.json.JSONObject.getString(JSONObject.java:577)
at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
at com.fs.starfarer.loading.WeaponSpreadsheetLoader.new(Unknown Source)
at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
at com.fs.starfarer.loading.null.super(Unknown Source)
at com.fs.super.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on November 24, 2013, 07:23:35 AM
I'm confused as to where do I edit the general price of things. I'm trying to duplicate some ships and weapons on vanilla for testing purposes and I know what I need to edit in terms of graphics and stats, but when it comes to pricing and availability I have no idea where to look. I've seen the " base value" entry in the weapons CSV but I don't think that's it. In fact, what is that? The values there are nowhere near the ones I see in stations and the CSV thread is outdated.

Another question I have is what the AI takes into account before engagement. What values does it look at for it to decide if it will run or engage? The total fleet deployment value?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on November 24, 2013, 07:41:44 AM
@maximilianyuen
same method as above, delete parts of your code 1 by 1 till the error stops, last thing you deleted was causing the error
(also complain to alex for better error logs)
its unhappy with one of your "displayNAME" stats, try systematicaly deleting anything that uses that one at a time till it stops giving you the error. then you found your bug

@Cyan Leader
the .cvs files  like ship/wing/weapon_data.cvs
theres a column labled base value... its the fourth column
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on November 24, 2013, 08:01:31 AM
@Cyan Leader
the .cvs files  like ship/wing/weapon_data.cvs
theres a column labled base value... its the fourth column

Oh nvm, I made a mistake when I was going through the files. What about my second question, any ideas? It's basically: what would I have to do in order to have a huge fleet and still have every AI opponent be aggressive to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on November 26, 2013, 05:43:51 PM
its unhappy with one of your "displayNAME" stats, try systematicaly deleting anything that uses that one at a time till it stops giving you the error. then you found your bug

Unfortunately, that didn't work. I tried that several times, even copying lines from the hegemony faction file. I also did the displayName of the faction aswell. Am I missing something here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on November 30, 2013, 04:06:02 AM
Thanks again for answering my previous question. I need your advice again.
I created a ship whose main weapon is a slow but powerful built-in long-range laser. And testing has shown that it is quite effective when controlled by the player. But when it is run by AI, strange happens. He just flies in circles around the enemy using only his PD weapons. At the same time from the main weapon he shoots an average of two - three times per battle. What could be the problem? May need to specify some additional tips for AI in the properties of the ship or weapons?
Or may need to somehow adjust the performance ship or weapons so AI understood how to use them?
Thanks in advance for your reply.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on November 30, 2013, 06:51:05 PM
@Runoved:  Basically, the AI for the game has two main issues:

1.  It doesn't always prioritize facing based on potential weapon damage well.  I.E., you can give the AI a huge-damage weapon and it won't necessarily make getting it to face an enemy a priority.

2.  If the weapon's arc is really low, the AI rarely fires it.  It doesn't pre-fire like a player does, and it wants to line up the arc with the enemy ship center.

Therefore, the best solutions are:

1.  Increase the arc until it works OK (and change the DPS if that's incredibly OP in player hands).  This is how I've solved it (generally speaking) for my ships with fixed-mount weapons that were having problems, and it generally fixed the problems with the AI not prioritizing it and with it choosing to fire.

2.  Write a custom weapon AI that will fire it more often and attempt to prefire better, by getting whether you can generate a point on a circle that's smaller than the collision circle but is within the weapon's arc.  Not sure if anybody's tried to do this yet, but it's probably not too hard.  Maybe ask dmaiski, as he's done more digging into weapon AI stuff than anybody else thus far.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on December 03, 2013, 08:04:17 AM
Hi there,

is there a way to have ships produce a constant amount of hardflux?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 03, 2013, 11:18:51 AM
Yes.  You can manipulate ships' Flux directly through FluxTrackerAPI, which can be accessed through ShipAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 05, 2013, 06:39:08 AM
Is there any render hint that lets you render missiles below the launcher?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on December 05, 2013, 06:44:53 AM
sadly, no =( wish there was.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thule on December 05, 2013, 07:43:17 AM
Is there any render hint that lets you render missiles below the launcher?

a way to do this would be the use of a decorative weapon i guess
a decorative weapon set up to medium covers up a small weapon iirc.
would be quite easy for a hardpoint or even built in weapon i guess, for turrets i dont know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 05, 2013, 07:58:23 AM
Way too complicated. Has to look the same on all ships that carry the weapon in a missile slot, or there is no coherence.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on December 05, 2013, 08:06:29 AM
I think it's a design decision. Something on the line of "you have the right to see what will be fired at you".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 05, 2013, 08:36:43 AM
If I dont want to show missiles at all, there is a render hint that lets me. What I want is to have the tips of the missiles peeking out from a box-type launcher :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 05, 2013, 10:02:49 AM
Is there any render hint that lets you render missiles below the launcher?
can you use an animation or write a script that will put a second sprite on top of it?

i think you can using
http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/graphics/SpriteAPI.html
setHeight()

havent tested it, but probably
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2013, 11:06:26 AM
That comes up now and again, mostly in the form of layered ship sprites, but this is another manifestation of it. Here's (http://fractalsoftworks.com/forum/index.php?topic=2844.msg39103#msg39103) a bit of detail on why things work the way they do and why this is not practical.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 06, 2013, 09:20:44 AM
Is there a way to start up a Dialog via a timed event?  I want to make a "how 2 play" dialog for my mod that runs immediately after game-start.

[EDIT] Answer:  yes; write a showInteractionDialog event, pointing at the appropriate Plugin.  So easy! [/EDIT]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: oranoron on December 06, 2013, 12:20:38 PM
Here is a question worth asking. Does anyone else want to fix my mods in exchange for their name in the credits and a warm fuzzy feeling for helping others?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 06, 2013, 06:49:39 PM
Done fixing your stuff. (http://fractalsoftworks.com/forum/index.php?topic=7471.msg122621#msg122621)  In the future:

A.  Install one of the IDEs, because it will tell you what's buggy, and why; if you aren't already a coder and generally know a lot about how that stuff works, having an IDE will really, really help.  Setting up Netbeans takes less than an hour if you just follow LazyWizard's directions.

B.  Expect this part to be hard.  It's not really hard to build a very basic Faction mod, but anything past that requires some expertise, because it's not just copy-pasta.  Learning to code from the start can be pretty hard, and Java's not exactly the best "my first programming language" to learn, so it's a pretty steep hill.  Just how it goes.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: oranoron on December 06, 2013, 06:57:09 PM
You're the best. I am going to try and figure out how to do things better now. By the end of tomorrow night I hope to have the first proper release version of the mod finished.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on December 07, 2013, 03:10:37 PM
Are there any sound filter types other than low pass to be set in a .system file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 08, 2013, 11:02:38 AM
Is there any render hint that lets you render missiles below the launcher?
another way is to use animations, animate the missile leaving the launcher, then spawn your missile at the point where the missile animation ends...
that may actualy be the best way to do it considering SS dosent have support for layers
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2013, 01:12:36 PM
Are there any sound filter types other than low pass to be set in a .system file?

No, that's the only one that works - this pretty much maps directly to what OpenAL supports.


Is there any render hint that lets you render missiles below the launcher?
another way is to use animations, animate the missile leaving the launcher, then spawn your missile at the point where the missile animation ends...
that may actualy be the best way to do it considering SS dosent have support for layers

That's a really good idea - it gets around all the problems that layers would cause in this type of setup, never mind the fact that they're not supported to begin with. If you were careful in placing the fire points of the weapon, I think you could actually get that to look completely seamless, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 08, 2013, 02:44:01 PM
That's a great idea, Dmaiski, thanks for sharing :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 09, 2013, 06:11:43 AM
Trying to add a sound to my custom weapon, but every time I try to test it, Starsector crashes to desktop with an error saying that the sound has no class. Any ideas?

SOLVED: I'd completely forgotten about the Sounds.json
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 09, 2013, 03:55:55 PM
quick question, how are AI vs AI battles simulated?

I ask this because my mod (and the stuff I am curently working on(slowly, ill do more nearer to chrismas)) uses alot of scriptrocities that derive alot of their effect from the scripts attached to them rather then the weapon itself, so i am woried about intresting things happening (like allways loosing) in AI vs AI battles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 09, 2013, 04:21:36 PM
Short answer: ship strength is based on the deployment point value. As long as those are balanced, it should be fine.

Long answer: take a look at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 10, 2013, 03:28:50 AM
ahh k thats good, my armor redistributors won't cause any trouble in that case
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flare on December 11, 2013, 08:04:07 PM
I'm trying to get a weak faction to spawn in Corvus' star to give new people a bit of a turkey shoot before they go onto the real fights. I think I've gotten the factionspawnpoint down pat, but I'm not sure how to make a gen file because Paul's tutorial seems a little dated on the topic. Does it matter what I name the file? Is all that the gen file does is add lines to corvus.java?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on December 12, 2013, 03:02:30 AM
How do i get hold of all the ShipAPI objects in a CampaignFleetAPI or FleetMemberAPI, if i remember correctly this is now possible on 0.6 right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on December 12, 2013, 11:26:03 AM
How do i get hold of all the ShipAPI objects in a CampaignFleetAPI or FleetMemberAPI, if i remember correctly this is now possible on 0.6 right?

I don't believe it's possible yet. You might be thinking of the new DeployedFleetMemberAPI, which allows you to get at the FleetMemberAPI (and thus all the campaign-level info) from a ShipAPI...


Spoiler
For anyone who finds this searching for information on DeployedFleetMemberAPI, that works like this (it's a bit unwieldy):
Code: java
Global.getCombatEngine().getFleetManager(ship.getOriginalOwner()).getDeployedFleetMember(ship).getMember()
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on December 13, 2013, 06:56:36 PM
Query: Is it possible to override a hull's default-assigned ship system with another through scripting, say, by applying a hullmod?

E.g., replacing/upgrading a standard flare launcher system with the active flare type, or another ship system entirely?

Looking through the modding API didn't point out the obvious solution; unless of course, I completely missed it... which isn't all that unlikely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 14, 2013, 08:24:09 AM
I need a way to get the WeaponAPI for a particular gun into a script, does anyone have a getter for these?

btw i am not talking about geeWeapon getter, I need to be able to be independent from ship
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 14, 2013, 09:25:34 AM
I'm trying to get a weak faction to spawn in Corvus' star to give new people a bit of a turkey shoot before they go onto the real fights. I think I've gotten the factionspawnpoint down pat, but I'm not sure how to make a gen file because Paul's tutorial seems a little dated on the topic. Does it matter what I name the file? Is all that the gen file does is add lines to corvus.java?

It doesn't matter what you name the file, as long as you also have a generators.csv in your mod and it refers to the gen file. It doesn't add lines to Corvus.java, but instead runs (after it) on new game creation. All the generators do that.

Query: Is it possible to override a hull's default-assigned ship system with another through scripting, say, by applying a hullmod?

E.g., replacing/upgrading a standard flare launcher system with the active flare type, or another ship system entirely?

Looking through the modding API didn't point out the obvious solution; unless of course, I completely missed it... which isn't all that unlikely.

It's not possible, but it's a neat idea.

I need a way to get the WeaponAPI for a particular gun into a script, does anyone have a getter for these?

btw i am not talking about geeWeapon getter, I need to be able to be independent from ship

You can get a WeaponAPI from a ship that has a weapon mounted. These don't exist apart from a ShipAPI; they need to be connected to a ShipAPI to function.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 14, 2013, 09:58:36 AM
You can get a WeaponAPI from a ship that has a weapon mounted. These don't exist apart from a ShipAPI; they need to be connected to a ShipAPI to function.

is there some way to temporarily mount a weapon on a ship mid combat and then remove it again?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 14, 2013, 10:28:13 AM
Not that I'm aware of. (Just to make sure: you know about CombatEngineAPI.spawnProjectile(), right? Depending on what you're trying to do, that might be enough.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 14, 2013, 10:40:26 AM
im trying to spawn beams :P

btw verry odd bug?


Code: java
        if (MouseT==null)
        {
            MouseT = (Vector2f)missile.getSource().getMouseTarget();
        }
this code gives a constantly updating location, not a V2f
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 14, 2013, 10:42:28 AM
Ah yeah, won't be able to spawn beams without a weapon, and need ships for that. Just how it works under the hood.

(You're getting a reference to the vector, not a copy of a vector. If you want a copy, do new Vector2f((Vector2f)missile.getSource().getMouseTarget()).)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 14, 2013, 10:44:51 AM
ahh thanks

im gona try using a beam weapon to spawn a missile, that will then use that weapon to spawn a beam

Spoiler
(http://www.indiegamemag.com/media/Edge-of-space-sharks.png)
soon my pretties soon!!!!
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 14, 2013, 10:58:18 AM
To spawn a beam, I think you just need to:

1.  Instantiate a new ShipAPI object at the desired position using an invisible ship with an invisible weapon, with the Beam on a fixed-forward mount.  Turn the ShipAPI to where it needs to point, if necessary.

2.  Send ShipCommand.FIRE to the ship.

3.  Erase the Ship after the beam's done firing, presumably by a timed EveryFrameScript intantiated by that special ShipAPI.

Anyhow, I think this is pretty much it.  I was going to try this out at some point, to make beam-MIRV "missiles" ala Peter Hamilton's "combat wasps", which I always thought were a cool idea :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ambient on December 14, 2013, 04:44:46 PM
Is it possible to change the consumption rate of Supplies?
If not how about changing the price of them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on December 14, 2013, 04:53:34 PM
Is it possible to change the consumption rate of Supplies?
If not how about changing the price of them?

Prob not on consumption, unless you want to edit ship values to change the at the source,

on Pricing of supplies, check  /Starsector/starsector-core/data/campaign/resources.csv and change the value to whatever you like, even negatives if you want to earn money when buying supplies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 14, 2013, 05:31:26 PM
is there a way to define something as phase cloaked?

for example missiles or projectiles
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on December 15, 2013, 05:17:05 PM
I've got a script I'd like to access the properties of from interaction dialogs- what would be the best way to do that? There doesn't seem to be a sector.getScript(), so I'm guessing that I could declare the script in my sector gen plugin, register it, then store the resulting pointer(?) in persistent data and read *that* in the interaction dialogs? Like:
Code: java
MyScriptClass MyScript = new MyScriptClass (A, B , C);
Global.getSector().addScript(MyScript);
sector.getPersistentData().put(MyScript_PD_ID, MyScript);
Code: java
MyScriptClass MyScript_Retrieved = (MyScriptClass sector.getPersistentData().get(MyScript_PD_ID);
MyScript_Retrieved.A = SOMETHING;
It seems a bit like it's hijacking the persistent data system to do something it's not really intended for so I'd be glad to hear of a better way.

Another thing I'd like to do is track when a specific fleet is destroyed; I can't see a way to attach a script to a fleet (beyond via 'fleet assignment ends' scripts, and they don't seem to run on death/despawn). All I can see is to add extra autoresolve/fleet interaction plugins for encounters involving that fleet that are vaguely transparent, just calling the default autoresolve then checking to see if the fleet of interest survived, e.g. an extension of BattleAutoresolverPluginImpl containing:
Code: java
public void resolve()
    BattleAutoresolverPluginImpl DefaultResolve = new BattleAutoresolverPluginImpl (fleetSpecial, fleetOther);
    DefaultResolve.resolve();
    if ( !fleetSpecial.isAlive() ){
        SOMETHING;
    }
The downside to this though is it blocks other mods' uses of new autoresolve/encounter implementations when I'm not actually interested in changing autoresolve or fleet encounter dialogs.
Can anyone suggest any less cludgy way of doing it?
Thanks :).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on December 15, 2013, 06:09:43 PM
--- Interaction Dialog Data ---

Is it data you set/change when a dialog is running?

If so, I think a better solution would be the dialog to write said data into PersistentData, and then your other thing to retrieve that item from persistentData when needed, rather than storing the entire plugin instance.

--- Catch and Do Something on Fleet Destruction ---

Perhaps a simpler way is to have a list/array in PersistentData that stores references to all your SpecialFleets. Add your fleets to this when you build your special fleets. Then have an EveryFrameScript check the list/array for IsAlive() and if dead, *do something* and remove from collection.

Yeah I agree, it is annoying to not be able to catch a fleet despawn event.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on December 16, 2013, 03:29:48 AM
Is it data you set/change when a dialog is running?

If so, I think a better solution would be the dialog to write said data into PersistentData, and then your other thing to retrieve that item from persistentData when needed, rather than storing the entire plugin instance.
Yep, I'll be adding ships to a list when the dialog spawns them. But would the entire thing be being stored in persistent data? I'm not entirely clear on what is/isn't a pointer- is it the case that if I store MyScript in persistentData that actually stores the whole thing, rather than just a pointer to it, even though it's already persistent and thus already stored in the save? So does that then mean it would diverge from the script I register with the sector after a load?

Perhaps a simpler way is to have a list/array in PersistentData that stores references to all your SpecialFleets. Add your fleets to this when you build your special fleets. Then have an EveryFrameScript check the list/array for IsAlive() and if dead, *do something* and remove from collection.

Yeah I agree, it is annoying to not be able to catch a fleet despawn event.
Unfortunately I've tried having EveryFrameScripts run (originally by just spawning a new one per fleet as an inefficient first pass at the problem) but they were unsuitable as it's for registering bounty completions, so I need to be able to tell if the ship actually died or just decided to despawn after being damaged & escaping.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on December 16, 2013, 04:43:46 AM
Is it data you set/change when a dialog is running?

If so, I think a better solution would be the dialog to write said data into PersistentData, and then your other thing to retrieve that item from persistentData when needed, rather than storing the entire plugin instance.
Yep, I'll be adding ships to a list when the dialog spawns them. But would the entire thing be being stored in persistent data? I'm not entirely clear on what is/isn't a pointer- is it the case that if I store MyScript in persistentData that actually stores the whole thing, rather than just a pointer to it, even though it's already persistent and thus already stored in the save? So does that then mean it would diverge from the script I register with the sector after a load?

Perhaps a simpler way is to have a list/array in PersistentData that stores references to all your SpecialFleets. Add your fleets to this when you build your special fleets. Then have an EveryFrameScript check the list/array for IsAlive() and if dead, *do something* and remove from collection.

Yeah I agree, it is annoying to not be able to catch a fleet despawn event.
Unfortunately I've tried having EveryFrameScripts run (originally by just spawning a new one per fleet as an inefficient first pass at the problem) but they were unsuitable as it's for registering bounty completions, so I need to be able to tell if the ship actually died or just decided to despawn after being damaged & escaping.

Well, it will put a reference (pointer-ish?) in PersistentData (so not much at all :) ) but that will mean that the plugin can't be garbage collected and it will be also be saved to the save file. Then when a new dialog is needed it will create a second instance, but the first instance will still not be garbage collected, and then you save THAT into PersistantData (perhaps over the top of the other one?). Anyway, I think you get the idea :)

I think the usage style (I could easily be wrong) with plugin's is that they are only created when needed (like only when you want to interact with something, see pickInteractionDialogPlugin, it returns a new instance every call). Otherwise they are not retained in memory (unless you force it by putting a reference in PersistentData).

I still think it would be better to create a separate class for transferring the data between the plugin and whatever script you have running :)

It's interesting, I'm actually doing exactly what you said above in Exerelin (most recent DEV). I am creating fleets in the dialog, but saving a reference of the fleets into an object I have in PersistentData. I then have a script that checks those fleets etc. Although I don't mind how they despawn so that makes it easier :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on December 16, 2013, 08:01:24 AM
Well, it will put a reference (pointer-ish?) in PersistentData (so not much at all :) ) but that will mean that the plugin can't be garbage collected and it will be also be saved to the save file. Then when a new dialog is needed it will create a second instance, but the first instance will still not be garbage collected, and then you save THAT into PersistentData (perhaps over the top of the other one?). Anyway, I think you get the idea :)

I think the usage style (I could easily be wrong) with plugin's is that they are only created when needed (like only when you want to interact with something, see pickInteractionDialogPlugin, it returns a new instance every call). Otherwise they are not retained in memory (unless you force it by putting a reference in PersistentData).

I still think it would be better to create a separate class for transferring the data between the plugin and whatever script you have running :)
I'm a little bit unsure about how the garbage collection works. The interactionDialogPlugin would just fill a local reference to an EveryFrameScript (declared elsewhere in my sectorGen) in this case, which I wouldn't think would be any different to an interactionDialog grabbing a reference to, say, a system or a planet via getStarSystem() or similar? What are the criteria for a script not being collected?

Quote
It's interesting, I'm actually doing exactly what you said above in Exerelin (most recent DEV). I am creating fleets in the dialog, but saving a reference of the fleets into an object I have in PersistentData. I then have a script that checks those fleets etc. Although I don't mind how they despawn so that makes it easier :)
Great, it's good to know that it works :).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on December 16, 2013, 04:30:35 PM
I'm a little bit unsure about how the garbage collection works. The interactionDialogPlugin would just fill a local reference to an EveryFrameScript (declared elsewhere in my sectorGen) in this case, which I wouldn't think would be any different to an interactionDialog grabbing a reference to, say, a system or a planet via getStarSystem() or similar? What are the criteria for a script not being collected?

The garbage collector cannot dispose objects that are still referenced. So, if you store a reference to the DialogPlugin it cannot be garbage collected until you null that reference (or remove it from list etc), and until that anything that that DialogPlugin references cannot be garbage collected either.

Things like Sector, Systems, SectorEntityToken's, Fleets etc. hang about in memory as they are generally in constant use and are always available via Global.getSector().

I don't believe InteractionDialogPlugins hang about (as they are not referenced once the dialog is finished, although Alex would know that for sure :) ) and if you store a reference in PersistantData you will force it to hang about. Even if you then only use that reference from within a method (say in EveryFrameScript.advance()) Java will still retain the whole object chain as it is still going to be referenced from PersistantData. It will also save it to the save file and I don't really think that's desirable either :)

As to your question, I'm not sure which way round you are doing things? Is your script going to use the plugin, or vice versa? I would imagine your script needs data from the plugin?

An EveryFrameScript won't be collected as it needs to run every frame :)

I would structure it like this:
 - InteractionDialogPlugin creates a new CustomDataStoreObject and adds it to PersistantData
 - EveryFrameScript checks PersistantData for CustomDataStoreObject and if it exists retrieves it and *does stuff*

As an example, how I do this in Exerelin is I have one object (SectorManager) in PersistentData. I then tack everything (well, almost) else I want to store/pass-about onto this object:
 - On game creation I create a new SectorManager and put it in PersistentData
 - I have a static method SectorManager.getCurrentSectorManager() that retrieves the current games SectorManager object and returns it
 - Then I just use that everywhere :)
    - e.g. SectorManager.getCurrentSectorManager.getCustomExerelinDataObject()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2013, 05:05:58 PM
@Zaphide: that's definitely the right way to go about this.

You *really* don't want to store a dialog in the persistent data, the object graph is going to go places you don't want it to go.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on December 16, 2013, 05:57:53 PM
Just wondering, has anyone noticed why asteroids are such damage sponges when it comes to beam weapons?

Large asteroids can take in 10000 of energy beam damage but yield to less than 2k of normal energy weapons, I think they even explode faster to high explosives (3 hellbores 1.5k dmg HE)
Or are asteroids just flying chunks of armor because it only takes 3 shots of Gauss (2100 kinetic) to pop them, or am I just on something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on December 16, 2013, 06:10:10 PM
The garbage collector cannot dispose objects that are still referenced. So, if you store a reference to the DialogPlugin it cannot be garbage collected until you null that reference (or remove it from list etc), and until that anything that that DialogPlugin references cannot be garbage collected either.

Things like Sector, Systems, SectorEntityToken's, Fleets etc. hang about in memory as they are generally in constant use and are always available via Global.getSector().

I don't believe InteractionDialogPlugins hang about (as they are not referenced once the dialog is finished, although Alex would know that for sure :) ) and if you store a reference in PersistantData you will force it to hang about. Even if you then only use that reference from within a method (say in EveryFrameScript.advance()) Java will still retain the whole object chain as it is still going to be referenced from PersistantData. It will also save it to the save file and I don't really think that's desirable either :)

As to your question, I'm not sure which way round you are doing things? Is your script going to use the plugin, or vice versa? I would imagine your script needs data from the plugin?
The script is going to use data generated in the plugin, yup. The way I was thinking of doing it was:
SectorGen -> Make new EveryFrameScript
SectorGen -> Add EveryFrameScript to sector
SectorGen -> Add reference to EveryFrameScript to PersistentData
InteractionDialogPlugin -> Pull reference to EveryFrameScript from PersistentData
InteractionDialogPlugin -> Make new CampaignFleet (based on user selection)
InteractionDialogPlugin -> Call EveryFrameScript.AddNewFleet( NewCampaignFleet )

Which as far as I can tell shouldn't result in any problems/leave anything uncollected then? It doesn't store references to an InteractionDialogPlugin anywhere.

I would structure it like this:
 - InteractionDialogPlugin creates a new CustomDataStoreObject and adds it to PersistantData
 - EveryFrameScript checks PersistantData for CustomDataStoreObject and if it exists retrieves it and *does stuff*.

As an example, how I do this in Exerelin is I have one object (SectorManager) in PersistentData. I then tack everything (well, almost) else I want to store/pass-about onto this object:
 - On game creation I create a new SectorManager and put it in PersistentData
 - I have a static method SectorManager.getCurrentSectorManager() that retrieves the current games SectorManager object and returns it
 - Then I just use that everywhere :)
    - e.g. SectorManager.getCurrentSectorManager.getCustomExerelinDataObject()
Okay, I'll give that a shot - ta!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 18, 2013, 06:13:12 PM
having issues...
my code...
query.getVelocity().set(query.getVelocity());

result
the objects velocity is set to a value much lower then the original

tested with needlers


on LMG this has the expected effect of the bullets retaining their velocity (apears to be near the speed cap)
scaling the vector by 10x had no effect on the actual velocity observed

tested, getVelocity().set() is capped to 600 max speed
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 18, 2013, 10:59:54 PM
@dmaiski: Fairly sure you're missing something in what you're doing. I'm as close to sure as one can be that the velocity for projectiles is not clamped; multiple tests here confirm that it's not.

For example this, in an EveryFrameCombatPlugin:
Code: java
List projectiles = Global.getCombatEngine().getProjectiles();
for (int i = 0; i < projectiles.size(); i++) {
DamagingProjectileAPI proj = (DamagingProjectileAPI) projectiles.get(i);
proj.getVelocity().set(2000, 0);
}
Does what you'd expect. All projectiles fly to the right at speed 2000.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 19, 2013, 12:29:54 AM
ahhh, another aspect of the script was changing their col classes to hits ships and asteroids to do cheap friendly fire colision.

clamps on methods are annoying in many ways, clamps should really be in the scripts that run ship motion not the setter methods themselves.

can I request fix for this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2013, 09:03:44 AM
Well, you could request a "fix", but, honestly, I don't see going back to muck with this now. Especially since it's not broken :)

(Btw: not that this matters much, but the clamping is done inside the main loop of the engine, not in the method. But, eh, functionally that's pretty similar since it happens every frame, in that it's not something mods can change either way. I wouldn't call what you're asking for a "fix", though, since that implies something isn't working right. What you're asking for is a modability enhancement.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on December 19, 2013, 04:15:30 PM
(Btw: not that this matters much, but the clamping is done inside the main loop of the engine, not in the method. But, eh, functionally that's pretty similar since it happens every frame, in that it's not something mods can change either way. I wouldn't call what you're asking for a "fix", though, since that implies something isn't working right. What you're asking for is a modability enhancement.)
:P would be much appreciated if you could, .setCollisionClass(CollisionClass.HITS_SHIPS_AND_ASTEROIDS); is pretty much the only way to make missiles perform friendly fire on the launching ship without messing up their ai or causing them to switch sides(both undesirable)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 19, 2013, 09:39:58 PM
Can't you just do your own collision test for those objects, though?  Yeah, I know, not so cheap and it's duplicating work, but it'd work.  I did that for a few things where I needed it and it wasn't too bad if it wasn't being spammed to thousands of things :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 23, 2013, 10:38:16 PM
I'm in need of assistance from one of you kind souls. Please have mercy if I'm overlooking something obvious. I'm still getting used to the API.  :-\

So I'm trying to implement ShipAIPlugin for the drones of a ship system. I've got my drones to the point where they do everything I want except for recalling to the mothership when they're told to. I can make them recall via drone.beginLandingAnimation(mothership), but I can't figure out how to find out if the mothership is trying to recall them. mothership.getSystem().isOn() and .isActive() don't seem to do the trick (they're always false), and DroneLauncherShipSystemAPI doesn't seem to have any applicable methods. How should I go about getting this information?

Any help is appreciated. 537 points to the one with the answer.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2013, 09:58:53 AM
I don't know if I'll earn any of those points for the answer, but this looks like an embarrassing oversight by yours truly. I don't think there's a method for this.

Just added getDroneOrders() to DroneLauncherShipSystemAPI (which you can cast the ShipSystemAPI to, if it's a drone launcher).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 24, 2013, 04:27:43 PM
I hereby award you full points for your prompt reply and for making .getDroneOrders() :)

Let's not consider it an embarrassing oversight. I, for one, would prefer for you to spend your time creating shiny new features for us rather than incessantly combing through the API looking for little gaps like this. There's no embarrassment in having your priorities straight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2013, 05:14:12 PM
The part that was embarrassing was that the DroneOrders enum was actually exposed via the API already, but there was no method to retrieve it. But, right, let's sweep that under the rug.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 24, 2013, 06:19:34 PM
I know it's possible for one ship to have multiple variants. But is it possible for each variant to have it's own sprite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on December 25, 2013, 08:27:10 AM
It's a bit hacky, but ModPlugin's pickShipAI() is called every time a ship is created, even in the codex and in menus (including the ship shown when you hit escape on the campaign map). If setSprite() works out of battle, you could check the variant in pickShipAI() and call setSprite() with the custom paint job there. :)

Edit: for example, you could create a "paintjobs" category under the "graphics" section in your mod's settings.json and add your sprites there, like this:
Code
{
"graphics":{
"paintjobs":{
"valkyrieStandard":"graphics/ships/variants/valyrie_Standard.png",
},
}

Then use something like the following to set the sprite:
Code: java
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import java.util.HashMap;
import java.util.Map;

public class PaintJobModPlugin extends BaseModPlugin
{
    private static final Map CUSTOM_SPRITES = new HashMap();

    static
    {
        // Put the variant ID, followed by the id you gave its sprite in your settings.json
        CUSTOM_SPRITES.put("valkyrie_Standard", "valkyrieStandard");
    }

    private static void pickPaintJob(ShipAPI ship, String variantId)
    {
        if (CUSTOM_SPRITES.containsKey(variantId))
        {
            ship.setSprite("paintjobs", (String) CUSTOM_SPRITES.get(variantId));
        }
    }

    @Override
    public PluginPick pickShipAI(FleetMemberAPI member, ShipAPI ship)
    {
        pickPaintJob(ship, ship.getVariant().getHullVariantId());

        // Do regular pickShipAI() stuff, or just return null
        return null;
    }
}

Note that the above code doesn't alter the bounds, so the sprite should stay the same shape.

If your mod didn't have a ModPlugin already, you'll have to register it for it to work. Just add the following to your mod_info.json:
Code
"modPlugin": "data.scripts.PaintJobModPlugin",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 25, 2013, 04:24:22 PM
Trying to figure out a UI issue with textPanel.  I've set up this code:

Code: java
textPanel.highlightInLastPara(HIGHLIGHT_COLOR, "" + (int) needed);

But only the first numeral of the number gets highlighted.  I R confused :)

Example:

(http://www.wolfegames.com/TA_Section/example_textpanel.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 25, 2013, 04:37:01 PM
Hmm. Are you actually sure that "needed" isn't 1? I just tried it (changed to used that method to highlight the credits looted, like so:

textPanel.highlightInLastPara(HIGHLIGHT_COLOR, creditsLooted);

And that seems to work. Would be pretty odd if what you're doing didn't.

Edit: you could also try highlightFirstInLastPara and see if that works. I'd be pretty surprised if one works and not the other, but I suppose it's possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 25, 2013, 04:55:35 PM
It's the float result of multiplying the number of Supplies needed by 100f. 

So it's probably 1.18. 

Just tried that change; same results.  Will try rounding before multiplying.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 25, 2013, 05:09:30 PM
Thanks for the help. Seems a bit complicated, and I'm not much of a coder...but now I know where to start, I should be able to get it working. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 25, 2013, 05:14:46 PM
Finally figured it out.

I did hit a rounding error (and I had some goofy stuff in my Tooltip code there, where it was wrong, vs. the Repair message, where it was right) but expressing it like this worked just fine:

Code: java
int needed = (int) Math.round(playerFleet.getLogistics().getTotalRepairSupplyCost() * 100f);

Anyhow... that gets rid of Minor Bug #1494512.  Hoping that I have enough energy / not enough eggnog to finish this Christmas present :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 25, 2013, 06:26:46 PM
If I get a Fatal: null error, how can I figure out exactly what has gone wrong? I've narrowed it down to my custom weapons, and I'm pretty sure it's an id error, either in the weapon, the projectile, or the sound. But how do I work out which, and which weapon?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 25, 2013, 07:17:30 PM
The error will tell you the line it crashed on :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 25, 2013, 07:57:12 PM
The error box reads:

Code
Fatal: null
Check starsector.log for more info.

When checking starsector.log, the most recent error reads:

Code
3765 [Thread-9] INFO  com.fs.starfarer.loading.scripts.B  - Loading class: com.fs.starfarer.api.campaign.FactionAPI
3765 [Thread-9] INFO  com.fs.starfarer.loading.scripts.B  - Loading class: com.fs.starfarer.api.campaign.PlanetAPI
3765 [Thread-9] INFO  com.fs.starfarer.loading.scripts.B  - Loading class: com.fs.starfarer.api.campaign.SectorGeneratorPlugin
3765 [Thread-6] ERROR com.fs.starfarer.combat.String  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.loading.specs.a.setProjectileSpec(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
at com.fs.starfarer.loading.SpecStore.Ò00000(Unknown Source)
at com.fs.starfarer.loading.null.super(Unknown Source)
at com.fs.super.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on December 25, 2013, 08:27:08 PM
Look further up in the log for the last line that starts with [Thread-6]. That's the thread that had the error, so the last file it started loading will be where the problem lies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 25, 2013, 08:52:26 PM
Ah, so that's how to do it! Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on December 26, 2013, 04:12:01 PM
I have been screwing around with a custom hullmod, and there is a strange wall I have hit.

Spoiler
org.json.JSONException: JSONObject["cost_frigate"] is not a number.
   at org.json.JSONObject.getDouble(JSONObject.java:451)
   at org.json.JSONObject.getInt(JSONObject.java:468)
   at com.fs.starfarer.loading.SpecStore.if(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.?0000(Unknown Source)
   at com.fs.starfarer.loading.null.super(Unknown Source)
   at com.fs.super.oOOO.?0000(Unknown Source)
   at com.fs.starfarer.combat.String.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

I have no idea what I did wrong, but its probably stupid. I looked at other hull_mods.csv's, but they were not any different than mine!

CSV:
Spoiler
name,id,unlocked,cost_frigate,cost_dest,cost_cruiser,cost_capital,script,desc,sprite
Citadel Experimental Systems,citadelsystems,true,0 (cost_frigate),0,0,0,data.hullmods.citadelsystems,"Increases the engine durabilty by 250% and the armor by 25%, but comes at the cost of25% less cargo space. Also reduces the flux venting rate by 90, but increases the passive dissapation by 75%.",graphics/hullmods/heavy_armor.png
[close]

Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;

public class CitadelSystems extends BaseHullMod {

public static final float HEALTH_BONUS = 250f;
public static final float VENT_BONUS = 90f;
public static final float DISSAPTION_BONUS = 75f;

public void applyEffectsBeforeShipCreation(MutableShipStatsAPI stats, String id) {
stats.getEngineHealthBonus().modifyPercent(id, HEALTH_BONUS);
stats.getVentRateMult().modifyPercent(id, VENT_BONUS*-1f);
stats.getFluxDissipation().modifyPercent(id, DISSAPTION_BONUS);
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on December 26, 2013, 04:27:55 PM
Health is not a thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2013, 04:38:39 PM
@Foxer360: Probably not the problem, but in the mod description, when you're using %, you should be using %% instead. (% is a special character and is used to insert variables into the mod's description. If you have %s in the description you can return the value to be inserted there using getDescriptionParam(int index).)

Not seeing the cause of the issue you're asking about, though. Are you pasting the contents of the CSV from some spreadsheet editing program, or from something like notepad? You'd see this issue if everything was in quotes, for example "0" vs just 0.

Health is not a thing.

It is in a couple of the API methods, but, yeah, it's not *really* health. But the method he's calling exists.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on December 26, 2013, 05:44:10 PM
Thanks for the quick response!

The description has been changed to say "75 percent", so no problems there.

I am pasting it from an notepad++ opened file. Unfortunately, nothing in that file has quotes anywhere. I even checked to see if both the CSV and the hullmod file were similar to another from Blackrock!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 26, 2013, 05:46:52 PM
Ok, trying to play around with my ships' shields...trying to get them to act a bit more like traditional shields
 I'm trying to:
1) once raised, disable the 'lower shields' button
2) once ship has been overloaded, disable 'raise shields' button

and if possible, though I don't think it is:

3) disable overload, and just have the shields lower and stay lowered once the flux meter reaches full.

is any of this possible, and if so, how?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2013, 05:48:00 PM
Thanks for the quick response!

The description has been changed to say "75 percent", so no problems there.

I am pasting it from an notepad++ opened file. Unfortunately, nothing in that file has quotes anywhere. I even checked to see if both the CSV and the hullmod file were similar to another from Blackrock!

Are you certain this hullmod is the culprit? Are there other hullmods in your mod, are you running with other mods, or have you touched the vanilla files? Might make sense to try running w/o the mod enabled etc just to sanity-check that this is the issue. Could also copy one of the lines in the .csv from vanilla and change the ID + name, as another sanity check.

Another thing to make absolutely sure of is that the file you're looking at is actually the one being used by the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2013, 05:55:08 PM
@Xalendi: You could probably hack this in by giving a ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK command to the ship (from a script) during any frame that the shield is on and you want it to be off.

3) disable overload, and just have the shields lower and stay lowered once the flux meter reaches full.

Just a thought - since flux is always dissipating, the flux meter is almost never actually full.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on December 26, 2013, 05:57:58 PM
Fixed, it works nao!

It was actually a import problem, I did not import the basic ship API. Thanks for the help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 27, 2013, 02:56:13 PM
So Xalendi, I was thinking about how to make your conventional shields at work today and I have a suggestion. I think you should completely invert how flux interacts with shields. I've tested it, and you can make shields take negative damage by doing this;

stats.getShieldDamageTakenMult().modifyPercent(id, -200);

100% - 200% = -100% (i.e. damage to your shield now dissipates flux)
This way damage to shields will never cause an overload and it will be graphically consistent with conventional shields as a form of regenerating HP (that is, a full green bar would mean full shields)

You'll still need to manually toggle shields and modify flux levels (probably with an EveryFrameCombatPlugin), but this way you won't have overloads and the flux bar will look more like a shield bar. On the downside, this would likely screw up how other damage modifiers affect shields, so it might only be viable for a total conversion.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on December 27, 2013, 03:33:57 PM
Hi, It's me again. Uh, With the same hull-mod issue, I'm afraid.   :-\

Dev version with broken hullmod, shhh! (http://www.mediafire.com/download/bnhibm0yaq58ruu/Citadel%20WIP.zip)

It is called Citadel Experimental Systems, and for now it is 0 OP and universal to any ship. The problem is that it does not actually apply the effects it should. Engine health, flux dissapation, active flux venting changes don't show up on the refit screen OR in combat.

My guess is that the effects are called in the "applyEffectsBeforeShipCreation" thingy, but should be called somewhere else? (Don't hurt me, I'm only halfway through an introductory coding class!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 27, 2013, 08:21:46 PM
One silly question for Alex:

What, exactly, determines the size of a fleet's circle in the Travel display (not the radar, the regular view)?  I'm hoping it's not the number of ships, but it isn't the value of DPs (like in the radar view).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on December 27, 2013, 08:27:49 PM
10+DP, first ring 20+DP, second ring 40+DP, third ring 60+DP, fourth ring.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 27, 2013, 08:33:13 PM
It doesn't appear to work for the non-radar view.  I'll set up a proper test.

Oh, wait... you mean in the faction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 27, 2013, 08:33:29 PM
It's a bit involved. Code, since that's probably the most succinct way to explain it:
Code: java
float incr = 10f;
float capRange = Math.min(getNumCapitals(), 3) * incr;
float cruiserRange = capRange + Math.min(getNumCruisers(), 3) * incr;
float destroyerRange = cruiserRange + Math.min(getNumDestroyers(), 3) * incr;
float frigateRange = destroyerRange + Math.min(getNumFrigates(), 3) * incr;
float fighterRange = frigateRange + Math.min(getNumFighters(), 5) * incr;

float result = fighterRange;
if (result < 25) result = 25f;

return result;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 27, 2013, 08:39:44 PM
OK, so to have a max size circle, I need components of all 5 types.  Interesting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on December 28, 2013, 05:00:07 AM
Code
package data.scripts.world;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

import data.scripts.world.corvus.Corvus;

@SuppressWarnings( "unchecked" )
public class TUPGen implements SectorGeneratorPlugin {

public void generate( SectorAPI sector ) {

sector.registerPlugin(new CoreCampaignPluginImpl());

     StarSystemAPI system = sector.getStarSystem("Corvus");

SectorEntityToken sol = system.createToken(0, 0);
   SectorEntityToken token = system.createToken(2500, 15000);
SectorEntityToken TUPstation = system.addOrbitalStation(sol, 300, 800, 100, "Scrapyard", "scavengers");
TUPSpawnPoint TUPSpawn = new TUPSpawnPoint(sector, system, 5, 1, TUPstation);

CargoAPI TUPcargo = TUPstation.getCargo();

TUPcargo.addCrew(CrewXPLevel.VETERAN, 75);
TUPcargo.addCrew(CrewXPLevel.REGULAR, 150);
TUPcargo.addCrew(CrewXPLevel.GREEN, 300);
TUPcargo.addMarines(200);
TUPcargo.addSupplies(500);
TUPcargo.addFuel(500);

system.addSpawnPoint(TUPSpawn);
for (int i = 0; i < 2; i++) TUPSpawn.spawnFleet();

FactionAPI scavengers = sector.getFaction("scavengers");


scavengers.setRelationship("hegemony", 0);
scavengers.setRelationship("tritachyon", 0);
scavengers.setRelationship("pirates", -1);
scavengers.setRelationship("independent", 0);
scavengers.setRelationship("player", 0);

}
}

Am I overlooking something? I am trying to spawn a station around the Corvus sun. I get no errors but the station just won't appear.

NEVERMIND! It is amazing how everytime I struggle with something and finally decide to ask a question I stumble upon the answer myself.  :D

I simply forgot to add the generator for the faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 28, 2013, 10:37:02 AM
Yeah, funny how getting your thoughts organized enough to ask a question is usually enough. Happens to me all the time :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on December 28, 2013, 12:14:11 PM
simple question: Is there a way to prevent drones from ever being recalled? Even so far as once they're deployed, that's it.

A ship of mine has a rather annoying tendency to recall its 60 strong defence network precisely when it is needed most.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 28, 2013, 12:58:14 PM
Write a new AI for it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on December 28, 2013, 02:48:14 PM
One last question before I can release something!
I'm calling this in sectorgen:
Code: java
        PlanetAPI planet = system.addPlanet( star, "Shattered Haven", "toxic", 0, 150, 5400, 256);
        planet.setCustomDescriptionId("planet_bounty_haven");
MOD\data\strings\descriptions.csv contains:
Code
id,type,text1,text2,text3,notes
planet_bounty_haven,PLANET,"BLAH BLAH BLAH",,,
Starsector.log contains:
Code
7500 [Thread-6] INFO  com.fs.starfarer.loading.SpecStore  - Loading descriptions
7500 [Thread-6] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading CSV data from [DIRECTORY: C:\Games\Fractal Softworks\Starsector\starsector-core\..\mods\Bounty]
...
29437 [Thread-6] WARN  com.fs.starfarer.loading.SpecStore  - Description with id planet_bounty_haven_CUSTOM not found
Which is odd. It looks like it's loaded the file properly, especially given when I tried converting descriptions.csv from ANSI->UTF to check if it was encoded wrong it crashed. I've tried changing the id planet_bounty_haven to planet_bounty_haven_CUSTOM in descriptions.csv to match the mention in the error message, but that doesn't seem to fix the problem. Could someone point out where I'm going wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 28, 2013, 03:03:07 PM
@Talkie Toaster: change PLANET to CUSTOM in the second column of the csv.

@Hyph_K31/xenoargh: Yeah, writing a custom AI for that ship's drone launcher is probably the easiest way to go about this. Shouldn't be too involved since you just want to turn it on and that's it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 28, 2013, 03:57:54 PM
@Hyph_K31: I agree about custom AI being the way to go about making drones that can't be recalled, but I just want to make sure you don't make the same mistake I did and try to figure out whether or not the drones are deployed using the API. That won't be available until 6.2a. Instead you might want to just use a boolean to keep track of whether or not it's been turned on. Like this:

Code
package data.shipsystems.scripts.ai;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import org.lwjgl.util.vector.Vector2f;

public class DagkiDroneAI implements ShipSystemAIScript
{
    private ShipAPI ship;
    private boolean dronesAreDeployed = false;
   
    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
        this.ship = ship;
    }

    @Override
    public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target) {
        if(!dronesAreDeployed) ship.useSystem();
    }
}

Be warned though, this solution has a bug. The AI won't know if the player toggles the ship system, so if the player deploys in a Muragatta, deploys the drones, and then switches to another ship, it'll think the system is still off and recall the drones... so you might want to wait until 6.2a when you can use the fancy new getDroneOrders() method Alex is giving us.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on December 28, 2013, 04:06:44 PM
Thanks a bunch guys. I think I'll wait until a more elegant/viable solution is available.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 28, 2013, 06:14:40 PM
You can write conditions into that script, though, like counting the number of drones, checking to see if there are any nearby enemies or missiles, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 08:20:02 AM
@Sundog: That's an interesting solution, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 09:16:49 AM
Ok, I'm terrible at coding. I can modify existing code to suit my purposes, but I am incapable of creating existing code from scratch. That being said, I've thought of a way of making my shields work. I just need a hand making it all code-ish.

Code
when ship enters battlefield, set flux to 99%, set shields On, disable right mouse click
if flux => 99%, pause regen*
stats.getShieldDamageTakenMult().modifyPercent(id, -200); (thanks Sundog)
if flux => 1, shields On
if flux < 1, shields Off

* I figure if I give the flux dissipation stat in the CSV a negative modifier, then it'll add to flux, rather than remove it...right?
 Also, where would I put this code? In the Hull file of each ship?

Any help on this would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 29, 2013, 11:18:27 AM
Two questions:
1. What's the best way to run a script at the beginning and end of each battle?
2. Is an EveryFrameCombatPlugin the best way to automate flux manipulation and shield toggling, or is there some sort of every-frame-per-ship pluggin that would dispense with the need to iterate over each ship and store info about them in a HashMap?

@xenoargh/Hyph_K31: I hadn't thought of counting drones to see if they're deployed. Unless they're at zero or max you'd have to count them over several frames to see if they're increasing or decreasing. Not exactly elegant, but it should work.

@Xalendi: No problem. Thanks for the interesting brain teaser :)

Ok, I'm terrible at coding. I can modify existing code to suit my purposes, but I am incapable of creating existing code from scratch.
It might be easier to write code from scratch than you think. Assuming you don't already, you should use an IDE like Eclipse or NetBeans. These will tell you about most errors before they happen, allow you to explore your possibilities while writing, and automagically fix certain issues, among many other benefits. They're free.
Tutorials to set up IDEs for Starsector:
NetBeans: http://fractalsoftworks.com/forum/index.php?topic=3173.msg45967 (http://fractalsoftworks.com/forum/index.php?topic=3173.msg45967)
Eclipse: http://fractalsoftworks.com/forum/index.php?topic=4344.msg67576#msg67576 (http://fractalsoftworks.com/forum/index.php?topic=4344.msg67576#msg67576)

You could try using a negative flux dissipation, but watch out for unintended side-effects (e.g. flux might jump straight from 98% to 100% and shut off the shield). By manually managing shield regeneration you could avoid this (assuming it happens).

As for where to put the code, you'll need two .java files. You'll probably want to put the shield damage inverting line in a new hull mod script (you can find examples of such in many faction mods (e.g. Blackrock)). I think the rest of your code will go in an EveryFrameCombatPlugin, but I haven't used one yet and I'm not certain it's the appropriate way to do something like this (hence the questions above).

Your pseudo-code looks good, but you might want to use a Halo-style delay before shields begin to regenerate to prevent them from constantly turning back on while they're depleted and under fire.

Now, with all that said, this is a non-trivial undertaking for someone who doesn't have much programming experience. If you're feeling up to the task it would be a great way to learn, and I'd be happy to help you with getting started and troubleshooting any issues you run into.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 12:28:13 PM
That would be appreciated, thank you.
This is all for my Sins mod - I gave up getting it balanced with vanilla, and am now making it a total conversion.

In Sins, shields are constantly regenerating, with no delay, so that's no problem.

I have no idea what an IDE is. I use Notepad++ to play with the code.

Would I be correct in assuming the .java files get called by the mod_info.json, in a similar way to how the "replace files" bit works?

I know what an EveryFrameCombatPlugin sounds like it does - runs a given script every time a battle has a new frame, so something like 60 times per second. However, 1) I have no idea how to do that, and 2) wouldn't that cause massive slowdowns, if it's constantly running a script that fast?

Also, just realised - The V key would have to be disabled, otherwise it'd be a suicide button.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 29, 2013, 12:38:42 PM
Quote
In Sins, shields are constantly regenerating, with no delay, so that's no problem.
Actually getting that to work with SS is going to be pretty hard, but probably it can be done:

1.  Have shields that go up and stay up (custom System AI required, or an extension of the default SS AI).

2.  Shots need to pierce Shields but do damage when inside the Shield, reduced by the percentage of Hard Flux vs. Max Flux. 

3.  If a ship is at 99% of Max Flux or is Overloading, it needs to be immediately made non-Overloading (I think that's possible by reducing the Overload time penalty to nearly-zero) and Shields need to go back up.

4.  Shield opening times probably need to be made a lot faster (built-in Hull Mod).

Shield-piercing shot examples can be found in Vacuum's source (see SpecialShotBehaviors.java and do some reading to see how I did that for Exigency's shield-piercing shots; basically, the shot needs to search for a ShipAPI Entity nearby, and if in bounds, do damage and remove itself).  The rest of it is either Hull Mods, System AI (but very simple- Shields being overridden is a straightforward flag) and an EveryFrameScript.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 01:36:29 PM
I may be being daft here, but why do shots need to pierce shields? They don't in Sins. I agree with knocking down the Overload time to near-zero, though. And the fast shields is a good idea.

Also, is it possible to give shields x and y coordinates, instead of a central point? Then we could have ovoid shields that fit the ship shapes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 29, 2013, 01:53:01 PM
Quote
I may be being daft here, but why do shots need to pierce shields? They don't in Sins.
Because in Sins, shields become less effective as they absorb damage.  SS's mechanic doesn't work that way- a shield is 100% effective at absorbing damage until Overload, period.  To really re-create that mechanic, you'd have to treat Shields and Flux very differently.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 01:57:43 PM
Couldn't there be a line of code that reads something like "shield efficiency = (base shield efficiency) * (flux percentage)"?

EDIT: no, wait, that still wouldn't work...that just makes the shield fall faster, rather than allowing damage through...

EDIT2: How about a line that reads something like,

"ShieldStrength = (base shield efficiency) * (flux percentage)
If flux >= 1, then BonusHullDamage = damage*ShieldStrength"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 29, 2013, 02:10:57 PM
Well, aside from (base shield efficiency)  / (flux percentage) (you want Shields to get weaker as Flux goes up, rather than the inverse), yeah. 

Then you'd need to write an applyDamage() event that ignores Shields (see API).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 02:21:31 PM
well, nah, it'd be the inverse, since we're doing full flux (well - 99%) is full shields.

I didn't know about the applyDamage() command, but that works with the pseudo-code I came up with.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 29, 2013, 02:29:16 PM
I guess that depends on how you define (flux percent), yes- I assumed it started at 100% and went down :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 02:44:05 PM
Yeah. On the other hand, I made a mistake with my maths as well. If we took the

"ShieldStrength = (base shield efficiency) * (flux percentage)
If flux >= 1, then BonusHullDamage = damage*ShieldStrength"

code as is, then the bonus damage would be wrong, causing more total damage than the enemy ship can actually dish out.

 It actually needs to be BonusHullDamage = damage*(1/ShieldStrength), i.e. the inverse, if I've worked my maths out right.

If that makes sense.

EDIT: No, that doesn't work either...hang on.

EDIT2: Right, so the actual formula is:

"ShieldStrength= (baseShieldEfficiency) * (FluxPercentage)
If Flux >= 1, then BonusHullDamage = damage - (damage*ShieldStrength)"

Gods...I hate maths...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 29, 2013, 04:44:24 PM
I haven't had the pleasure of playing Sector of Sins yet. Downloading now.

So we're talking about doing partial damage through shields now? Intimidating...

I wouldn't worry about performance issues from using EveryFrameCombatPlugin unless you're doing something crazy.

An IDE (Integrated Development Environment) is just a fancy text editor with a bunch of features for coding. Some people consider Notepad++ an IDE, but it lacks any of the nifty features I mentioned (unless you go crazy with extensions).

You're right about the V key and venting, as a mater of fact it made me realize just how bad my idea was for inverting flux. I didn't even consider what it would do to the AI (make it suicidal). Please accept my humble apologies for making such an inane suggestion.

To my knowledge, ovoid shields are impossible.

Maybe we should move this to another thread to keep this one uncluttered. This could get complicated  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on December 29, 2013, 05:05:33 PM
I've created a new thread called Traditional Shields
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on January 06, 2014, 05:27:18 PM
I haven't posted in awhile, I haven't had much time to play around with this game recently. However I began to mess around again, and I've got some questions.

I basically have a faction about 90% done, 25 ships in the faction, not counting drones and other misc ships. I used to have a working station in Corvus, and had everything working nicely pre 6.0 or whatever the last big patch was. That patch pretty much broke everything, and I've patched up most of it. However I can't get my new system to show up in hyperspace, therefore I cannot see my faction at all in the campaign.

Basically, the jist of it is, I'd like to know if there's any tutorials to look at, or any mods in particular I can reference to figure out how to add systems, new factions fleets, and modded ship behaviors. I don't want to be an annoyance, but I've been trying on my own for awhile, and I'm not really a programmer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LiquidStang on January 06, 2014, 05:45:56 PM
I haven't posted in awhile, I haven't had much time to play around with this game recently. However I began to mess around again, and I've got some questions.

I will be glad to help.

I basically have a faction about 90% done, 25 ships in the faction, not counting drones and other misc ships. I used to have a working station in Corvus, and had everything working nicely pre 6.0 or whatever the last big patch was. That patch pretty much broke everything, and I've patched up most of it. However I can't get my new system to show up in hyperspace, therefore I cannot see my faction at all in the campaign.

Have you tried to set up the system properly? You should probably check the mods settings before you even think about using the system in hyperspace.

Basically, the jist of it is, I'd like to know if there's any tutorials to look at, or any mods in particular I can reference to figure out how to add systems, new factions fleets, and modded ship behaviors. I don't want to be an annoyance, but I've been trying on my own for awhile, and I'm not really a programmer.

I found some tutorials from youtube. I'm not sure what one will solve the problem you're having, though. I just randomly came across with them. Watch all 3 tutorials then if you have the problem solved tell me what one helped you the most.

http://www.youtube.com/watch?v=-_geS3qALyU

http://www.youtube.com/watch?v=r0dvlSS8Jdc

http://www.youtube.com/watch?v=Tc-KiVg5iV8

Best Regards, David
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 06, 2014, 10:01:27 PM
@Arumac: Here ya go sir; http://fractalsoftworks.com/forum/index.php?topic=1282.0 (http://fractalsoftworks.com/forum/index.php?topic=1282.0)

My guess is you haven't told the game to run the script that generates your system. Like this:

Code
public class MyModPlugin extends BaseModPlugin
{
    @Override
    public void onNewGame()
    {
new MySystemGeneratorClass().generate(Global.getSector());
    }
}

Edit: Hrm. Well after taking a closer look at that tutorial it looks like it doesn't cover creating new systems. I'll try to get the faction I'm working on into the game and let you know what I find out (assuming someone who actually knows how to add systems doesn't beat me to the punch)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 06, 2014, 11:55:13 PM
Ok, so here's a bare-bones mod that adds a new system called Example (really it's just a copy of Akonia)
https://www.dropbox.com/s/02145xsa7dzoxoc/Example%20System.zip (https://www.dropbox.com/s/02145xsa7dzoxoc/Example%20System.zip)

Hope to play your faction soon  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on January 08, 2014, 05:49:31 PM
@Sundog

Thanks a lot. That did the trick, I just wasn't able to follow were I needed to include the ModPlugin file in a couple of places. I appreciate your help, thanks a lot
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 08, 2014, 08:24:30 PM
No problem  :)

Edit: Forgot why I came here in the first place... I have a question. The faction I'm working on is shieldless and very short-ranged, so I'm a little worried about damage caused by the blasts of enemy ships being disabled. Is there any good way to reduce damage from those blasts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on January 09, 2014, 01:56:04 PM
You and increase the speed at which ships recover disabled weapons using hullmods.

All (Most) Gedune ships have such a hull mod, which is based on the automated repair hull mod. for EMP damage resistance, look at resistant flux conduits.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on January 09, 2014, 02:04:03 PM
Sundog, you could give them a special hull mod that provided resistance against certain kinds of damage.

The current unreleased dev of Exi has one that provides 30% mitigation against beam weapons for example.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on January 09, 2014, 02:07:06 PM
Is there any way, to make a custom phasecloak system actually execute an operation before entering phase? And if so, how does one do that?

More specifically I want to make my ship send off some sort of AOE when going into phase. But all my poorly understood copying and pasting/editing of existing ship systems seem to have no effect on the actual phase effect. My IDs internal shipsystem reference IDs should be correctly updated though, so I don't think that is the problem.

Would be very thankful for any help here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 09, 2014, 04:11:58 PM
Yes, you can do that. 

In apply(MutableShipStatsAPI stats, String id, State state, float effectLevel){}  the state tells you whether it's IN, ACTIVE or OUT, see the API.

IN is running during the period when the Phase Cloak is just coming on line, so you can change a boolean state there that fires off your AOE in Advance() (which requires implementing EveryFrameCombatPlugin and your script needs to be in data/scripts/plugins for that to work).

For an example of a script that combines a ShipSystemStatsScript with EveryFrameCombatPlugin, see the Repulsor script I wrote for Vacuum.

Lastly, if I've mis-interpreted what you've said, and what you really want to do is have a System that can use the Phase Cloak "slot" for a special-purpose weapon- i.e., use defense_id for a "phase cloak" that doesn't actually phase... for something like this, you'd want a trigger condition when in State.IN, but have a limited time duration for being phased (0.001f) so that there's only one gameframe where your ship is "phased" and won't be aimed at by the AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 09, 2014, 04:44:27 PM
Sundog, you could give them a special hull mod that provided resistance against certain kinds of damage.

The current unreleased dev of Exi has one that provides 30% mitigation against beam weapons for example.

Good call on giving Exi a buff against beams. 30% seems like a good amount to turn beams into a weakness of Exi rather than a hard counter.

Your suggestion was my first idea too, but unfortunately MutableShipStatsAPI doesn't have anything like getShipExplosionDamageTakenMult() to reduce only that type of damage (Unless I missed it?)

Is there any way, to make a custom phasecloak system actually execute an operation before entering phase?

You can do this by adding a 'Stats' script to an otherwise ordinary copy of the phasecloak system. Add a line that looks like this:
Code
"statsScript":"data.shipsystems.scripts.BurnDriveStats",
to the .system file of your version of the phasecloak, only replace 'BurnDriveStats' with the name of your own script. You'll want to put the .java file for your script in "\data\shipsystems\scripts\"

This method is a little hacky because the type of script you need to use (ShipSystemStatsScript) is only meant for modifying stats, but nothing else. That's why it doesn't provide you with a reference to the ship that's activating the system. To get a reference to the ship you need to look through all the ships on the battlefield and ask them; 'Hey, man, are these your stats?' until one says yes. Or just copy this:
Edit: That was bad advice. Just use stats.getEntity()

Code
        Object[] ships = Global.getCombatEngine().getShips().toArray();
        ShipAPI ship = null;

        for(int i = 0; i < ships.length; ++i) {
            if(stats == ((ShipAPI)ships[i]).getMutableStats()) {
                ship = (ShipAPI)ships[i];
            }
        }
        
        // For some reason the stats don't match any ship.
        if(ship == null) return;

From there you can use the 'state' variable xenoargh mentioned to decide when to do stuff.

Also if you are trying to replace the phasecloak with something else entirely (which I hadn't considered until xenoargh mentioned it) keep in mind that you won't be able to change the AI for the phasecloak without causing a crash when the AI tries to use it.

@xenoargh: I don't understand why an EveryFrameCombatPlugin would be necessary. Will a ShipSystemStatsScript not execute it's 'apply' function each frame?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on January 09, 2014, 05:52:44 PM
Sundog, yea it feels pretty good in practice. While the armor is still intact the mitigation is more than 30%, it only become that flat amount when its hitting bare hull.

I would imagine you would likely just have to give them resistance to HE damage, there is likely not a more elegant solution at the moment.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on January 10, 2014, 12:00:20 PM
Thanks a lot xenoargh and Sundog! I'll try it out and see how it goes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 10, 2014, 03:13:55 PM
No problem, Zudgemud. Good luck.

I would imagine you would likely just have to give them resistance to HE damage, there is likely not a more elegant solution at the moment.

Hrm... I was afraid of that. Maybe if I give them resistance to all damage types but increase damage from all weapon types it'll have the same effect. It's helpful to know those explosions cause HE damage (which makes a lot of sense now that I think about it), so thanks for that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 11, 2014, 02:46:04 PM
I've got a minor display issue. It's hard to explain, so I took a screenshot:
Spoiler
(http://i.imgur.com/YasEmTZ.jpg)
[close]

The armor grid starts out looking correct, but once it's damaged and repaired it looks like that. The silly thing is that this only happens when the AI is piloting the ship. This has never happened to me with a flagship.

I know the armor is actually being repaired because the affected armor cells still prevent hull damage even when the display says the armor is gone.

It's related to ShipAPI.setSprite() somehow, because it doesn't happen when I remove the calls to setSprite from the ship system's script. The system swaps to a different 32-bit .png (of the same dimensions) while the system is active.

The scripts that cause this problem:
Spoiler
Repair armor system:
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.ArmorGridAPI;
import org.lwjgl.util.vector.Vector2f;
import data.scripts.plugins.Utils;
import java.awt.Color;
import java.util.Random;
import org.lazywizard.lazylib.MathUtils;

public class RepairArmorStats implements ShipSystemStatsScript
{
    private final Color SPARK_COLOR = new Color(160, 240, 220);

    @Override
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {

        ShipAPI ship = Utils.getShipFromStats(stats);

        if (ship == null) return;

        ship.setSprite("sun_ice_ship_repair_effects", ship.getHullSpec().getHullId());
       
        if (state == ShipSystemStatsScript.State.OUT) {
ship.setSprite("sun_ice_ships", ship.getHullSpec().getHullId());
}

        ArmorGridAPI armorGrid = ship.getArmorGrid();
        Random rng = new Random();
        float max = armorGrid.getMaxArmorInCell();
        float cellSize = armorGrid.getCellSize();
        int gridWidth = armorGrid.getGrid().length;
        int gridHeight = armorGrid.getGrid()[0].length;
        int cellCount = gridWidth * gridHeight;
        int candidates = 1 + cellCount / 10;
       
        int leaderX = 0, leaderY = 0;
        Vector2f leaderLoc = null;
        float bestRecord = Float.MAX_VALUE;

        for(int i = 0; i < candidates; ++i) {
            int x = rng.nextInt(gridWidth);
            int y = rng.nextInt(gridHeight);
            Vector2f cellLoc = Utils.getCellLocation(ship, x, y);
            float current = armorGrid.getArmorValue(x, y);
            float dist = MathUtils.getDistance(cellLoc , ship.getMouseTarget());
           
            if((dist < bestRecord) && (current < max)) {
                leaderLoc = cellLoc;
                bestRecord = dist;
                leaderX = x;
                leaderY = y;
            }
        }

        if(bestRecord != Float.MAX_VALUE) {
            float current = armorGrid.getArmorValue(leaderX, leaderY);
            float increase = 0.001f * effectLevel * max * cellCount;
            armorGrid.setArmorValue(leaderX, leaderY, Math.min(max, current + increase));

            if(Math.random() < 0.5) { // 50% chance to create visual spark at cell
                leaderLoc.x += cellSize * 0.5f - cellSize * (float)Math.random();
                leaderLoc.y += cellSize * 0.5f - cellSize * (float)Math.random();
                Global.getCombatEngine().addHitParticle(leaderLoc, ship.getVelocity(), 10 * (float)Math.random() + 10, 0.8f, 0.5f, SPARK_COLOR);
            }
        }

        if (state == ShipSystemStatsScript.State.OUT) {
stats.getMaxSpeed().unmodify(id);
stats.getMaxTurnRate().unmodify(id);
} else {
stats.getMaxSpeed().modifyPercent(id, -20f * effectLevel);
stats.getAcceleration().modifyPercent(id, -50f * effectLevel);
stats.getDeceleration().modifyPercent(id, -50f * effectLevel);
            stats.getMaxTurnRate().modifyPercent(id, -20f * effectLevel);
stats.getTurnAcceleration().modifyPercent(id, -50f * effectLevel);
}
    }

    @Override
    public void unapply(MutableShipStatsAPI stats, String id) {
stats.getMaxSpeed().unmodify(id);
stats.getMaxTurnRate().unmodify(id);
stats.getTurnAcceleration().unmodify(id);
stats.getAcceleration().unmodify(id);
stats.getDeceleration().unmodify(id);

        ShipAPI ship = Utils.getShipFromStats(stats);

        if (ship == null) return;

        ship.setSprite("sun_ice_ships", ship.getHullSpec().getHullId());
    }

    @Override
    public StatusData getStatusData(int index, State state, float effectLevel) {
        if (index == 0) return new StatusData("repairing armor", false);
        else if(index == 1) return new StatusData("reduced engine power", false);
        return null;
    }
}

AI:
Code
package data.shipsystems.scripts.ai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI.ShipEngineAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import data.scripts.plugins.Utils;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lwjgl.util.vector.Vector2f;

public class RepairArmorAI implements ShipSystemAIScript
{
    private static final float REFRESH_FREQUENCY = 1f;
    private float timeOfNextRefresh = 0;
    private ShipSystemAPI system;
    private ShipAPI ship;
   

    private float getEnginePerformance() {
        List engines = ship.getEngineController().getShipEngines();

        float acc = 0;
        int count = 0;

        for(Iterator iter = engines.iterator(); iter.hasNext();) {
            ShipEngineAPI engine = (ShipEngineAPI)iter.next();

            if(engine.isSystemActivated()) continue;

            acc += engine.isDisabled() ? 0 : 1;

            ++count;
        }

        return acc / count;
    }
    private float getArmorState() {
        ArmorGridAPI armorGrid = ship.getArmorGrid();
        Random rng = new Random();
        float armorState = 0;
        int gridWidth = armorGrid.getGrid().length;
        int gridHeight = armorGrid.getGrid()[0].length;
        int candidates = 1 + (gridWidth * gridHeight) / 10;

        for(int i = 0; i < candidates; ++i) {
            int x = rng.nextInt(gridWidth);
            int y = rng.nextInt(gridHeight);
           
            armorState += armorGrid.getArmorFraction(x, y);
        }
       
        armorState /= candidates;     
       
        return armorState;
    }
    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
        this.ship = ship;
        this.system = system;
    }

    @Override
    public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target) {
        if(!AIUtils.canUseSystemThisFrame(ship)) return;

        if(timeOfNextRefresh < Global.getCombatEngine().getTotalElapsedTime(false)) {
            timeOfNextRefresh += REFRESH_FREQUENCY;
        } else return;

        // low  [0] - Tested armor was at least half depleted.
        // high [1] - No armor damage found
        float armorState = Math.max(0, (getArmorState() - 0.5f) * 2);

        // low  [0] - No flux
        // high [1] - Full flux
        float fluxLevel = ship.getFluxTracker().getFluxLevel();

        // low  [0] - flameout
        // high [1] - no offline engines
        float enginePerformance = getEnginePerformance();

        // low  [0] - No danger nearby
        // high [1] - Really need to move
        float danger = Utils.estimateIncomingDamage(ship) / 1000;

        // low  [0] - don't need to activate
        // high [1] - need to activate
        float wantActive = (1 - armorState);
        wantActive *= (1 - danger * enginePerformance);
        wantActive *= (1 - (float)Math.pow(fluxLevel, 2));

        if(!system.isActive() && (wantActive > 0.1f)) ship.useSystem();
        else if(system.isActive() && (wantActive < 0.05f)) ship.useSystem();
    }
}
[close]

Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on January 11, 2014, 03:31:51 PM
I wonder, does this display issue remain when entering another battle with the affected ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 11, 2014, 03:42:32 PM
What's the display issue? Unless I'm missing something, that's what it looks like when armor is stripped away.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on January 11, 2014, 04:00:14 PM
Sundog is using a mod that repairs his ship in battle. Correct me if I'm wrong. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 11, 2014, 07:25:36 PM
Sundog is using a mod that repairs his ship in battle. Correct me if I'm wrong. :)
Is truth. This display bug doesn't show up until armor is stripped away and repaired. To be clear; it's a problem with my mod, not Starsector. It might be an API issue though. My guess is that it has something to do with how the ship's silhouette for the armor display is recalculated when setSprite is called. It's just as likely to be me simply doing something dumb though.

I wonder, does this display issue remain when entering another battle with the affected ship?
That's a good question. I've never flown my ships in the campaign though, so I don't know. I'll see if I can find out.

Edit: The issue goes away after entering another battle. Affected ships correctly show full armor in the second battle even when repairs have been suspended since before the first battle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on January 12, 2014, 03:06:37 AM
So, my script to make a ship that sends out an EMP wave when entering phase seems to work fine, my ship goes into phase, sends out an EMP wave with some fancy graphics, all is good. However, for some reason my game keeps crashing when using the system. Not often, but every once in a while (like every 50th time or so that I use the system). This is really annoying as the system works perfectly otherwise, and I have no idea what causes it as the logfile does not bring anything up. 

As I used the BRDY ScalarDeracinator script as a base (with permission) is this something other people have encountered too when modifying this or similar scripts?

Here is the code incase anyone can
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import java.awt.Color;
import java.util.Iterator;
import org.apache.log4j.Level;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;

// Phase teleporter system, with some extras
public class pnPhaseCloakStats implements ShipSystemStatsScript

{
    // "Inhale" effect constants
    private static final int MAX_PARTICLES_PER_FRAME = 30; // Based on charge level
    private static final float PARTICLE_RADIUS = 300f;
    private static final float PARTICLE_SIZE = 6f;
    private static final Color PARTICLE_COLOR = new Color(160, 40, 160);
    private static final float PARTICLE_OPACITY = 0.85f;
    // Explosion effect constants
    private static final Color EXPLOSION_COLOR = new Color(60, 34, 60);
    private static final float EXPLOSION_RADIUS = 500f;
    private static final float EXPLOSION_VISUAL_RADIUS = 600f;
    private static final float EXPLOSION_DAMAGE_AMOUNT = 100f;
    private static final DamageType EXPLOSION_DAMAGE_TYPE = DamageType.ENERGY;
    private static final float EXPLOSION_PUSH_RADIUS = 250f;
    private static final float EXPLOSION_PUSH_FORCE = 10f;
    private static final float STRENGTH_VS_FIGHTER = 1.2f;
    private static final float STRENGTH_VS_FRIGATE = 1.1f;
    private static final float STRENGTH_VS_DESTROYER = 1.0f;
    private static final float STRENGTH_VS_CRUISER = .9f;
    private static final float STRENGTH_VS_CAPITAL = .8f;
    // Local variables, don't touch these
    private boolean isActive = false;

    @Override
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel)
    {
        // instanceof also acts as a null check
        if (!(stats.getEntity() instanceof ShipAPI))
        {
            return;
        }

        ShipAPI ship = (ShipAPI) stats.getEntity();
        // Chargeup, show particle inhalation effect
        if (state == State.IN)
        {
            if (!isActive)
            {}

            // Exact amount per second doesn't matter since it's purely decorative
            Vector2f particlePos, particleVel;
            int numParticlesThisFrame = Math.round(effectLevel * MAX_PARTICLES_PER_FRAME);
            for (int x = 0; x < numParticlesThisFrame; x++)
            {
                particlePos = MathUtils.getRandomPointOnCircumference(
                        ship.getLocation(), PARTICLE_RADIUS);
                particleVel = Vector2f.sub(ship.getLocation(), particlePos, null);
                Global.getCombatEngine().addSmokeParticle(
                        particlePos, particleVel, PARTICLE_SIZE,
                        PARTICLE_OPACITY, 1f, PARTICLE_COLOR);
            }
            // Everything in this block is only done once per chargeup
            if (!isActive)
           
            {
                CombatEngineAPI engine = Global.getCombatEngine();
                engine.spawnExplosion(ship.getLocation(), ship.getVelocity(),
                        EXPLOSION_COLOR, EXPLOSION_VISUAL_RADIUS, 0.2f);
                engine.spawnExplosion(ship.getLocation(), ship.getVelocity(),
                        EXPLOSION_COLOR, EXPLOSION_VISUAL_RADIUS / 2f, 0.2f);

                CombatEntityAPI tmp;
                Vector2f dir;
                float force, damage, mod;
                for (Iterator pushed = CombatUtils.getEntitiesWithinRange(
                        ship.getLocation(), EXPLOSION_PUSH_RADIUS).iterator(); pushed.hasNext();)
                {
                    tmp = (CombatEntityAPI) pushed.next();

                    if (tmp == ship)
                    {
                        continue;
                    }

                    mod = 1f - (MathUtils.getDistance(ship, tmp) / EXPLOSION_PUSH_RADIUS);
                    force = EXPLOSION_PUSH_FORCE * mod;
                    damage = EXPLOSION_DAMAGE_AMOUNT * mod;

                    if (tmp instanceof ShipAPI)
                    {
                        ship = (ShipAPI) tmp;

                        // Modify push strength based on ship class
                        if (ship.getHullSize() == ShipAPI.HullSize.FIGHTER)
                        {
                            force *= STRENGTH_VS_FIGHTER;
                            damage /= STRENGTH_VS_FIGHTER;
                        }
                        else if (ship.getHullSize() == ShipAPI.HullSize.FRIGATE)
                        {
                            force *= STRENGTH_VS_FRIGATE;
                            damage /= STRENGTH_VS_FRIGATE;
                        }
                        else if (ship.getHullSize() == ShipAPI.HullSize.DESTROYER)
                        {
                            force *= STRENGTH_VS_DESTROYER;
                            damage /= STRENGTH_VS_DESTROYER;
                        }
                        else if (ship.getHullSize() == ShipAPI.HullSize.CRUISER)
                        {
                            force *= STRENGTH_VS_CRUISER;
                            damage /= STRENGTH_VS_CRUISER;
                        }
                        else if (ship.getHullSize() == ShipAPI.HullSize.CAPITAL_SHIP)
                        {
                            force *= STRENGTH_VS_CAPITAL;
                            damage /= STRENGTH_VS_CAPITAL;
                        }

                        if (ship.getShield() != null && ship.getShield().isOn()
                                && ship.getShield().isWithinArc(ship.getLocation()))
                        {
                            ship.getFluxTracker().increaseFlux(damage * 2, true);
                        }
                        else
                        {
                            for (int x = 0; x < 5; x++)
                            {
                                engine.spawnEmpArc(ship,
                                        MathUtils.getRandomPointInCircle(
                                        ship.getLocation(), ship.getCollisionRadius()),
                                        ship, ship, EXPLOSION_DAMAGE_TYPE, damage / 10,
                                        damage / 5, EXPLOSION_PUSH_RADIUS, null, 2f,
                                        EXPLOSION_COLOR, EXPLOSION_COLOR);
                            }
                        }
                    }

                    force = Math.min(force / (tmp.getMass() / 1000), EXPLOSION_PUSH_FORCE * 1.5f);
                    dir = (Vector2f) MathUtils.getDirectionalVector(ship, tmp).scale(force);
                    Vector2f.add(tmp.getVelocity(), dir, tmp.getVelocity());
                }

                isActive = false;
            }
        }
    }

    @Override
    public void unapply(MutableShipStatsAPI stats, String id)
    {
    }

    @Override
    public StatusData getStatusData(int index, State state, float effectLevel)
    {
        if (state == State.IN)
        {
            if (index == 0)
            {
                return new StatusData("charging scalar deracinator", false);

            }
            else if (index == 1)
            {
                return new StatusData("weapons and shields inoperable", true);
            }
        }

        return null;
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on January 12, 2014, 12:24:51 PM
Is there a better way to order a fleet to engage another fleet than using FleetAssignment.ATTACK_LOCATION? It seems to not work very well with moving targets- the attacker only updates their position veeeery sporadically, and this can lead to a lot of aimless meandering. When fleets decide to attack a target on their own it seems to work fine, but I can't see how to force that behavior and they can spend days wandering around before they get close enough for it to trigger, then lose track of them and proceed to where their target was half a day ago. I've tried setInteractionTarget() but it doesn't seem to work, or at least doesn't seem to stick (it's hard to tell).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 12, 2014, 12:50:09 PM
What, if any, advantages are there for BALLISTIC_AS_BEAM vs. just using BALLISTIC? 

There isn't a RAY_NO_FF collision class, and if the proj uses BALLISTIC_AS_BEAM, it can't use PROJECTILE_NO_FF without causing issues with collisions not registering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 12, 2014, 12:56:57 PM
What, if any, advantages are there for BALLISTIC_AS_BEAM vs. just using BALLISTIC?  

There isn't a RAY_NO_FF collision class, and if the proj uses BALLISTIC_AS_BEAM, it can't use PROJECTILE_NO_FF without causing issues with collisions not registering.

From a PM:

BALLISTIC_AS_BEAM spawns don't even have hitpoints. That's kind of their thing. Initially, that was the difference - ballistic shots could hit each other and deal damage, while pulse lasery types couldn't.

Didn't work out so well, though. So now, there's not much reason to use one type vs another.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 12, 2014, 01:01:00 PM
Makes sense; I kind of figured it might be like that (after all the Phase Beam and Tachyon Lance once had proj files, too).  To the rubbish bin they go, then :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 12, 2014, 01:42:39 PM
@Zudgemud: Well, I wasn't able to duplicate the error after using the system over 100 times. I might just be unlucky, but have you noticed any circumstances in which it happens more often? I read through your script and noticed a few things that might cause issues:
-isActive is never set to true and doesn't seem to do anything at all.
-You're using a depreciated overload of MathUtils.getDirectionalVector (which doesn't mater now, but might in the future)
-There's a possibility of dividing by zero on line 148 if tmp.getMass() returns zero or very close to zero.

I also noticed your use of stats.getEntity(). How did I overlook that? Sorry for recommending that you iterate through entities manually earlier  :-\

btw, the effect with the emp arks looks great  :)


@Talkie Toaster: I don't have the knowledge to give you a good answer, but, if you haven't already, you might try predicting where the fleet will be after a short time and telling your bounty hunters to go there instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on January 12, 2014, 02:08:29 PM
Is there a better way to order a fleet to engage another fleet than using FleetAssignment.ATTACK_LOCATION? It seems to not work very well with moving targets- the attacker only updates their position veeeery sporadically, and this can lead to a lot of aimless meandering. When fleets decide to attack a target on their own it seems to work fine, but I can't see how to force that behavior and they can spend days wandering around before they get close enough for it to trigger, then lose track of them and proceed to where their target was half a day ago. I've tried setInteractionTarget() but it doesn't seem to work, or at least doesn't seem to stick (it's hard to tell).

setInteractionTarget doesn't move fleets around; I think it is mainly for triggering InteractionDialogPlugins. It is called (or a non-API equivalent is called) when you (the player) clicks a SectorEntityToken on the campaign screen.

There is a setMoveDestination and setMoveDestinationOverride that you can use to move a fleet round manually.

You could have an EveryFrameScript manually move your fleets around? Maybe just run it every 60th frame (or every StarSector hour/day) and then update the fleets move destination appropriately. If it gets close to it's target then you could stop updating so that it allows the automatic movement routine to take over.

So, I'm not sure of your Java level but off the top of my head you could potentially structure it like this:
 - Create a new class (FleetTargetAssignment) that contains two CampaignFleetAPI references; one of the fleet that is doing the chasing, the second of the fleet to be chased
 - Create a class that implements EveryFrameScript (FleetTargetProcessing) that reads FleetTargetAssignment's from PersistantStorage (perhaps stored as a list?) and calls setMoveDestinationOverride on the chasing fleet, passing in the coordinates of the chased fleet
 - When you want one fleet to chase another one, create a new FleetTargetAssignment, save it to PersistantStorage and then your FleetTargetProcessing should pick it up

Couple of thoughts:
 - I'm not sure how it will handle fleets that are in different systems
   - Perhaps leave it on automatic until both fleets are in the same system?
 - It shouldn't impact performance much but I would cap the updates as once every StarSector hour or similar
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on January 13, 2014, 01:34:30 PM
There is a setMoveDestination and setMoveDestinationOverride that you can use to move a fleet round manually.

You could have an EveryFrameScript manually move your fleets around? Maybe just run it every 60th frame (or every StarSector hour/day) and then update the fleets move destination appropriately. If it gets close to it's target then you could stop updating so that it allows the automatic movement routine to take over.

So, I'm not sure of your Java level but off the top of my head you could potentially structure it like this:
 - Create a new class (FleetTargetAssignment) that contains two CampaignFleetAPI references; one of the fleet that is doing the chasing, the second of the fleet to be chased
 - Create a class that implements EveryFrameScript (FleetTargetProcessing) that reads FleetTargetAssignment's from PersistantStorage (perhaps stored as a list?) and calls setMoveDestinationOverride on the chasing fleet, passing in the coordinates of the chased fleet
 - When you want one fleet to chase another one, create a new FleetTargetAssignment, save it to PersistantStorage and then your FleetTargetProcessing should pick it up

Couple of thoughts:
 - I'm not sure how it will handle fleets that are in different systems
   - Perhaps leave it on automatic until both fleets are in the same system?
 - It shouldn't impact performance much but I would cap the updates as once every StarSector hour or similar
Thanks - I'd already got an EveryFrameScript setup evaluating the bounty every .1 days, so I just tacked calling setMoveDestination in there when both fleets are in the same system- I think it improved things a little.

Using setMoveDestinationOverride oddly just broke it; the fleet destinations were entirely wrong. The block that was being called was:
Code
Global.getSector().getPlayerFleet().setLocation(
        getFleet().getLocation().getX(),getFleet().getLocation().getY());
hunterFleet.setMoveDestinationOverride(
        getFleet().getLocation().getX(),getFleet().getLocation().getY());
Where getFleet() returns the target fleet for the bounty, and the player set is in as a check.

Every few seconds I'd snap to the bounty's current position, but the hunters flew in more or less random directions once entering the system and changed heading only every few days. It seems like perhaps override doesn't like being called so regularly, or it just overrides the heading and locks it for the next few days or something like that.

(My Java knowledge is probably advanced beginner level - enough to use implements/extends etc., but not enough to use them sensibly)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on January 13, 2014, 02:21:28 PM
--- setMoveDestination experiments ---

Hmmm interesting!

I'm using setMoveDestination to move the players fleet on top of a planet or station, and it works perfectly for that, but then I'm moving after slower moving objects; perhaps it doesn't work so well for moving after fleets?

Another thing I noticed in my code:
I'm calling setMoveDestination every frame. I think I'm doing this because I'm moving the players fleet around, and so it would respond to mouse clicks between frames, which resulted in some erratic behavior :P Perhaps try changing the script to issue a setMoveDestination (and perhaps also try setMoveDestinationOverride) call every frame?

Sorry I can't be more helpful!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 13, 2014, 07:05:19 PM
The fleet AI is going to call it every frame, since that's how it tells the fleet to move around. So, you want to call the override method every frame.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on January 14, 2014, 01:02:56 AM
The fleet AI is going to call it every frame, since that's how it tells the fleet to move around. So, you want to call the override method every frame.
Ah, thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rst30 on January 15, 2014, 03:49:55 AM
Hmm, still a noob here, instead of playing i just jumped straight into modding.
So i made a single ship, the only thing i need to know is how do you put them into stations so it can be sold?
Also could someone please mention a thread on modding for newbies? (I have read Sproginator's Guide.)
Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Desforrar on January 16, 2014, 02:35:24 PM
Is it possible to hide ship from codex?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 16, 2014, 03:47:40 PM
@rst30: Take a look at the files in 'C:\Program Files\Fractal Softworks\Starsector\starsector-core\data\scripts\world\systems' (At least, that's where it is on my PC). In particular look at the initStationCargo function in Askonia.java. If you're interested in spawning fleets that periodically deliver your ship to stations you should take a look at some of the '...SpawnPoint.java' files.

You can also add ships to stations manually by editing your save file.

I don't know of any modding tutorials that aren't specific to a certain task. A good way to learn is to look through the files of other peoples mods. Playing the game will help you learn how to mod it too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 16, 2014, 05:21:53 PM
@Desforrar:  Not possible right now.  Heck, we can't even hide the Vanilla variants, even if the TC tag is present :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on January 18, 2014, 06:47:29 AM
So, I've tried to figure out a way to associate particular plugins with individual fleets via a mission system. It works pretty well- the appropriate picker in the CampaignPlugin looks up the mission associated with a given fleet, and pulls a PluginPick back. This code runs A-O-K:
In CampaignPlugin
Code: java
MissionAPI mission = getMission((CampaignFleetAPI)interactionTarget);
return ((MissionFleetPlugin) mission).pickBattleAutoresolver(one, two)
In MissionFleetPlugin
Code: java
@SuppressWarnings("unchecked")
    public PluginPick pickBattleAutoresolver(CampaignFleetAPI one, CampaignFleetAPI two) {
        return new PluginPick(
                new MissionBattleAutoresolverPlugin(one, two),
                priority);
    }

    @SuppressWarnings("unchecked")
    public PluginPick pickInteractionDialog() {
        return new PluginPick(
                new MissionFleetInteractionDialogPlugin(),
                priority);
    }
Where MissionBattleAutoresolverPlugin and MissionFleetInteractionDialogPlugin are extensions of their respective non-mission plugins. These methods are part of the abstract class MissionFleetPlugin, and everything works fine for missions that extend MissionFleetPlugin but don't try and override the pick* functions.

However, when I try overriding them in another class, it fails- I get either:
Quote
Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/missions/Bounty/BountyMissionRumour.java, Line 175, Column 19: Member with "/*default*/" access cannot be accessed from type "data.scripts.missions.Bounty.BountyMissionRumour$Rock".
Code: java
        @SuppressWarnings("unchecked")
        public PluginPick pickEncounterContext(InteractionDialogAPI dialog) {
            return new PluginPick(
                    new BountyRumourEncounterContextPlugin(dialog),
                    priority);
        }
Or:
Quote
12226 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.StackOverflowError
java.lang.StackOverflowError
   at sun.nio.cs.StreamDecoder.read(Unknown Source)
   at sun.nio.cs.StreamDecoder.read0(Unknown Source)
   at sun.nio.cs.StreamDecoder.read(Unknown Source)
   at java.io.InputStreamReader.read(Unknown Source)
   at org.codehaus.janino.UnicodeUnescapeReader.read(UnicodeUnescapeReader.java:61)
Code: java
        @SuppressWarnings("unchecked")
        public com.fs.starfarer.api.PluginPick pickInteractionDialog() {
            return new PluginPick(
                    new BountyRumourRockDialogPlugin(),
                    priority);
        }
The first one seems to suggest I'm not allowed to access PluginPicks in that context but I don't really understand why; the first lot of code works fine. Is it just the fact I'm trying to call it in a subclass? Moved code to its own class, still doesn't work. The second error is just baffling.

The actual plugins themselves work fine- if I use the encounterContextPlugin directly through an InteractionDialogPlugin I specify in a CampaignPlugin they both work perfectly. So I'd appreciate any help!

E: Just to outline how this is working for clarity-
1. Player triggers creation of mission BountyMissionRumour$Rock, which creates a fleet (that's a rogue asteroid)
2. Asteroid is tagged with the mission that created it via a buff
3. When a fleet is interacted with, it looks up if it's part of a mission (via searching its buffs)
4. If so, the mission is checked to see if a different plugin need to be used
5. The plugin is returned (or null) to the picker and the picker returns that
6. The player then sees the rogue asteroid-specific dialog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 18, 2014, 04:23:48 PM
How do I prevent parts of a ship from showing the battle damage when hit? I tried not putting those parts in the bounds, but they still get hit by weapons fire, and they still show that glowy orange damage effect. And overload lightning, too, for that matter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 18, 2014, 04:28:25 PM
How do I prevent parts of a ship from showing the battle damage when hit? I tried not putting those parts in the bounds, but they still get hit by weapons fire, and they still show that glowy orange damage effect. And overload lightning, too, for that matter.

You can implement that part of the ship as a decorative weapon. The new "renderBelowAllWeapons" weapon property is designed for this. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 18, 2014, 05:13:25 PM
Ok, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on January 20, 2014, 03:46:32 AM
Hi!

I've got a little questio: Is it possible to play an idle animation for a weopon?
Basically I want to have an animation for a weapon when it's not fired and a diferent one when it is fired.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 20, 2014, 11:17:57 AM
Yes; you could cycle through certain frames / do animation only when the weapon's not being fired, and vice versa.  See SpriteAPI and AnimationAPI for the details.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on January 21, 2014, 01:17:52 PM
OK, I think this is the best place to ask this so here goes: Where can I find the "CR Limits" of Crew levels? I want to try giving Vets a 5% CR level boost and the Elites a 10% boost to allow full access to the CR buffs.

Also, where can I find the crew's "experience thresholds" that state when the crew member is supposed to level up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 21, 2014, 02:11:16 PM
The CR bonuses are in resources.csv, but we have no control over the leveling system, other than buffing / debuffing it, nor is it documented.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on January 21, 2014, 03:28:27 PM
The CR bonuses are in resources.csv, but we have no control over the leveling system, other than buffing / debuffing it, nor is it documented.
I have checked that CSV and the CR bonuses are either not there or I am blind... You ARE talking about the one in the data/campaign folder, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 21, 2014, 05:00:57 PM
Huh; you're right, they don't have stats there; could've sworn they did at one point.  Not seeing what else you can do with Crew, other than give them XP or change what level they are in the API.  Guess that's not really moddable atm- about the only way around that is via a character perk or something.  Depending on what you really wanted to do, this may or may not work :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 21, 2014, 05:10:27 PM
You can change the effects of crew by providing a custom combatReadinessPlugin, specified in settings.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on January 21, 2014, 11:00:15 PM
You can change the effects of crew by providing a custom combatReadinessPlugin, specified in settings.json.
Welp, I'm screwed then... I can't code my way out of a wet paper bag...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 23, 2014, 06:40:32 AM
Is there any way to remove damage decals during combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2014, 09:31:53 AM
Not that I'm aware of. What you're doing with regenerating armor isn't exactly a use case the engine was designed to work with... not that it's impossible, it's just going against the grain a bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 23, 2014, 11:07:54 AM
If armor states are at zero damage and health returns, the damage decals fade out to the point where they're almost invisible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 23, 2014, 01:40:08 PM
Thanks for the tip xenoargh  :)
So if I set the hull hp to 100% along with each cell in the armor grid for at least one frame it should fade the decals? Will I need to use the ship's FleetMemberAPI for this?

What you're doing with regenerating armor isn't exactly a use case the engine was designed to work with
And justifiably so :)
To be honest I never expected to be able to clean up the decals after repairing, but I thought I'd ask just in case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 23, 2014, 11:26:17 PM
No, it'll take time to fade from being damaged.  But the state once it's healed is nearly pristine once the glow heals.  Not quite; the damage is still there; it's just really faint.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 24, 2014, 01:50:59 AM
How do you have custom styles for shields and engines?
I saw the Batavian mod done that, so i have tried the same way they did, by making an engine_color.json file and make a new style.
However after i edited a ship into using that style it didn't work. Please help.
Thank You.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on January 24, 2014, 04:50:46 AM
How do you have custom styles for shields and engines?
I saw the Batavian mod done that, so i have tried the same way they did, by making an engine_color.json file and make a new style.
However after i edited a ship into using that style it didn't work. Please help.
Thank You.

You'll need an engine_styles.json and a hull_styles.json, then for each ship you have to put in your custom style's ID, like so:

"style": "BATAVIA_TECH",

Do this for each engine. Also do this for the hull and shields: (you can find that line right below the spriteName)

"spriteName": "graphics/batavia/ships/pb_cruiser_deruyter.png",
"style": "BATAVIA_TECH",


So, basically you create the .json files and you alter the style in the ship's .SHIP file by entering the ID of your custom style. Did you do all of this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 24, 2014, 05:45:07 AM
I did everything except editing the hull_styles.json, i thought the designation would work fine with the defaults (Frigate)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 24, 2014, 07:03:51 AM
Is it possible to make things like hull mods one-use items that you can buy from the shops? So if I have a frigate, I can buy a mod, and load it into my frigate to improve hull strength, or shield strength, or reactor capacity, but once it's in there it's in there? And only once, so I have to buy it again to use on another ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 24, 2014, 04:40:05 PM
Is it possible to make things like hull mods one-use items that you can buy from the shops? So if I have a frigate, I can buy a mod, and load it into my frigate to improve hull strength, or shield strength, or reactor capacity, but once it's in there it's in there? And only once, so I have to buy it again to use on another ship?

It's possible. CAELUS (a very old megamod) had this feature. I'd have to check the code to see how I accomplished it, but then again with all the API changes since then I'm sure there are far better ways of doing it now. I could update the hullmod for .6.2a and post the revised code if you want. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 24, 2014, 05:13:29 PM
Yes please!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 24, 2014, 05:19:50 PM
Quote
Is it possible to make things like hull mods one-use items that you can buy from the shops? So if I have a frigate, I can buy a mod, and load it into my frigate to improve hull strength, or shield strength, or reactor capacity, but once it's in there it's in there? And only once, so I have to buy it again to use on another ship?
If Hull Mods can have a one-time cost like that, that would definitely be something I'd like to put into Vacuum;  I'd rather give access to Hull Mods through money (both one-time costs, at Stations) and per-install costs than the current system of level unlocks.  If I get some free time over the next week I'll see what can be done there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 24, 2014, 05:41:16 PM
Here's one of the hullmods from CAELUS. I updated the code a bit and added more comments. It's unlocked per hull class (so installing it on a Hound unlocks it for all Hounds), but you can swap out ship.getHullSpec().getHullId() for ship.getFleetMemberId() if you want it to be unlocked per ship:

Spoiler
Code: java
package data.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class EliteTweak extends BaseHullMod
{
    // The ID of the persistent data for unlocked hulls in the current campaign
    private static final String UNLOCKED_DATA_ID = "elite_tweak_unlocked_hulls";
    private static final Map REQUIRED_CARGO = new HashMap();

    static
    {
        // These are all items defined in data/campaign/resources.csv
        // A separate item for each hullsize allows different pricing tiers
        REQUIRED_CARGO.put(HullSize.FRIGATE, "shipmanual_frigate");
        REQUIRED_CARGO.put(HullSize.DESTROYER, "shipmanual_destroyer");
        REQUIRED_CARGO.put(HullSize.CRUISER, "shipmanual_cruiser");
        REQUIRED_CARGO.put(HullSize.CAPITAL_SHIP, "shipmanual_capital");
    }

    private static boolean inCampaign()
    {
        // There's probably a better way of doing this these days,
        // but I couldn't think of one off the top of my head
        return (Global.getSector() != null
                && Global.getSector().getPlayerFleet() != null);
    }

    private static List getUnlockedHulls()
    {
        // This should never trip, but just in case...
        if (!inCampaign())
        {
            return new ArrayList();
        }

        Map persistentData = Global.getSector().getPersistentData();
        List hulls = (List) persistentData.get(UNLOCKED_DATA_ID);

        // Persistent data for hullmod unlocks not found? Create it!
        if (hulls == null)
        {
            hulls = new ArrayList();
            persistentData.put(UNLOCKED_DATA_ID, hulls);
        }

        return hulls;
    }

    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id)
    {
        // < INSERT ANY HULLMOD EFFECT CODE HERE >
        // The rest of this method just checks if we should remove the unlock item
        if (!inCampaign())
        {
            return;
        }

        // Already unlocked for this hull? Don't remove any more unlocking items
        String hullId = ship.getHullSpec().getHullId();
        if (getUnlockedHulls().contains(hullId))
        {
            return;
        }

        // Otherwise, remove the unlocking item...
        String requiredCargo = (String) REQUIRED_CARGO.get(ship.getHullSize());
        Global.getSector().getPlayerFleet().getCargo().removeItems(
                CargoItemType.RESOURCES, requiredCargo, 1f);

        // .. and permanently unlock this hullmod for this hull type
        getUnlockedHulls().add(hullId);
        Global.getSector().getCampaignUI().addMessage(
                "Elite Tweak hullmod unlocked for all ships of class "
                + ship.getHullSpec().getHullName() + ".", Color.GREEN);
    }

    @Override
    public boolean isApplicableToShip(ShipAPI ship)
    {
        // In a mission? Return true
        if (!inCampaign())
        {
            return true;
        }

        // In campaign and hullmod is already unlocked? Return true
        if (getUnlockedHulls().contains(ship.getHullSpec().getHullId()))
        {
            return true;
        }

        // In campaign, locked, and we have the proper unlock item? Return true
        String requiredCargo = (String) REQUIRED_CARGO.get(ship.getHullSize());
        return (Global.getSector().getPlayerFleet().getCargo()
                .getQuantity(CargoItemType.RESOURCES, requiredCargo) >= 1f);
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 24, 2014, 05:57:31 PM
Great, thanks!  I'll need to convert it to use Credits and FleetMemberIds and probably it needs to sweep out non-existent FleetMemberIds so that the save doesn't get cluttered up, but that's really pretty easy, awesome :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 24, 2014, 06:08:38 PM
It's been a long time, but I remember there being some really obnoxious bug with hullmod unlocking in CAELUS. I can't remember what it was, though.

Glancing at the code, I'm going to guess it's that it doesn't differentiate between hullmods on ships in your fleet and ships in NPC fleets. Here's a fix for that (not tested!):
Spoiler
Code: java
package data.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class EliteTweak extends BaseHullMod
{
    // The ID of the persistent data for unlocked hulls in the current campaign
    private static final String UNLOCKED_DATA_ID = "elite_tweak_unlocked_hulls";
    private static final Map REQUIRED_CARGO = new HashMap();

    static
    {
        // These are all items defined in data/campaign/resources.csv
        // A separate item for each hullsize allows different pricing tiers
        REQUIRED_CARGO.put(HullSize.FRIGATE, "shipmanual_frigate");
        REQUIRED_CARGO.put(HullSize.DESTROYER, "shipmanual_destroyer");
        REQUIRED_CARGO.put(HullSize.CRUISER, "shipmanual_cruiser");
        REQUIRED_CARGO.put(HullSize.CAPITAL_SHIP, "shipmanual_capital");
    }

    private static boolean inCampaign()
    {
        // There's probably a better way of doing this these days,
        // but I couldn't think of one off the top of my head
        return (Global.getSector() != null
                && Global.getSector().getPlayerFleet() != null);
    }

    private static List getUnlockedHulls()
    {
        // This should never trip, but just in case...
        if (!inCampaign())
        {
            return new ArrayList();
        }

        Map persistentData = Global.getSector().getPersistentData();
        List hulls = (List) persistentData.get(UNLOCKED_DATA_ID);

        // Persistent data for hullmod unlocks not found? Create it!
        if (hulls == null)
        {
            hulls = new ArrayList();
            persistentData.put(UNLOCKED_DATA_ID, hulls);
        }

        return hulls;
    }

    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id)
    {
        // < INSERT HULLMOD EFFECT CODE HERE >
        // The rest of this method checks if we should remove the unlock item
        if (!inCampaign())
        {
            return;
        }

        // Already unlocked for this hull? Don't remove any more unlocking items
        String hullId = ship.getHullSpec().getHullId();
        if (getUnlockedHulls().contains(hullId))
        {
            return;
        }

        // Is this ship in an NPC fleet? NPCs get it for free ;)
        CampaignFleetAPI player = Global.getSector().getPlayerFleet();
        boolean inPlayerFleet = false;
        for (Iterator iter = player.getFleetData().getMembersListCopy().iterator(); iter.hasNext(); )
        {
            FleetMemberAPI tmp = (FleetMemberAPI) iter.next();
            if (tmp.getId().equals(ship.getFleetMemberId()))
            {
                inPlayerFleet = true;
                break;
            }
        }

        // Only players have to pay the horrible cost of unlocking!
        if (!inPlayerFleet)
        {
            return;
        }

        // Otherwise, remove the unlocking item...
        String requiredCargo = (String) REQUIRED_CARGO.get(ship.getHullSize());
        Global.getSector().getPlayerFleet().getCargo().removeItems(
                CargoItemType.RESOURCES, requiredCargo, 1f);

        // .. and permanently unlock this hullmod for this hull type
        getUnlockedHulls().add(hullId);
        Global.getSector().getCampaignUI().addMessage(
                "Elite Tweak hullmod unlocked for all ships of class "
                + ship.getHullSpec().getHullName() + ".", Color.GREEN);
    }

    @Override
    public boolean isApplicableToShip(ShipAPI ship)
    {
        // In a mission? Return true
        if (!inCampaign())
        {
            return true;
        }

        // In campaign and hullmod is already unlocked? Return true
        if (getUnlockedHulls().contains(ship.getHullSpec().getHullId()))
        {
            return true;
        }

        // In campaign, locked, and we have the proper unlock item? Return true
        String requiredCargo = (String) REQUIRED_CARGO.get(ship.getHullSize());
        return (Global.getSector().getPlayerFleet().getCargo()
                .getQuantity(CargoItemType.RESOURCES, requiredCargo) >= 1f);
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 24, 2014, 10:31:51 PM
Thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 24, 2014, 11:27:02 PM
...This may seem a silly question, but if I've got a double barrelled weapon, how do I make it fire two beams at once, side by side and parellel? And the same for energy bolts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on January 24, 2014, 11:50:04 PM
"barrelMode":"LINKED", # or LINKED.  whether barrels fire at the same time or alternate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 25, 2014, 08:18:42 AM
Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on January 26, 2014, 02:01:38 PM
Hi!

Edit: SOLVED!
So I'm making some decorative moving weapons and I found code for that on the forums but it doesnt't spin at all.
Spoiler
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.ShipAPI;

// Original file with just isHulk check added

public class RotatingDishArc implements EveryFrameWeaponEffectPlugin {


   private float currDir = Math.signum((float) Math.random() - 0.5f);
   
   public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
      if (engine.isPaused()) return;
      
      float curr = weapon.getCurrAngle();
      
      curr += currDir * amount * 25f;
      float arc = weapon.getArc();
      float facing = weapon.getArcFacing() + (weapon.getShip() != null ? weapon.getShip().getFacing() : 0);
      if (!isBetween(facing - arc/2, facing + arc/2, curr)) {
         currDir = -currDir;
      }
      
      weapon.setCurrAngle(curr);
   }

   public static boolean isBetween(float one, float two, float check) {
      one = normalizeAngle(one);
      two = normalizeAngle(two);
      check = normalizeAngle(check);

      //System.out.println(one + "," + two + "," + check);
      if (check >= one && check <= two) return true;
      
      if (one > two) {
         if (check <= two) return true;
         if (check >= one) return true;
      }
      return false;
   }
   
   public static float normalizeAngle(float angleDeg) {
      return (angleDeg % 360f + 360f) % 360f;
   }
}
[close]

This is the script the wings of the rock fly use and I think it's supposed to "flap" those wings but instead it just keeps them steady relative to the ship.
I have no idea on how to coe it properly in java, usuall I simply look at other peaple's coding and inertpret it for myself.

How do I need to change this to rotate back and forth in an angle like 120 degrees?

Or would it be better to modify the original rotating dish which is spinning in one way?

Any help appreciated!

PS: Got my skeleton mod ready, finally I can fly and test the ships I've drawn! So happy!

PPS: Biomancy Genetic Engineering is coming!

Edit: Trying to learn Java now, I'm sick of "codebashing" stuff together. Still, if there's anyone willing to help coding my mod just let me know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on January 26, 2014, 02:58:01 PM
Is there any way to make your ship always accelerate forwards? I dumb and just noticed that my ship system using the following code can actually accelerate BOTH forward and backwards when using the ship system, this was not my intent. The ship system was supposed to give you a massive forward speed boost like the burn drive while also shooting a murderbeam out of the front of the hull.

Code
	"clampTurnRateAfter":true,
"clampMaxSpeedAfter":true,
"alwaysAccelerate":true,

Currently, this makes my shipsystem, intended to be the space equivalent of a high risk lancer charge, a cowards tactic as you can just start the murderbeam while going in reverse, and then you accelerate massively backwards which enables you to run away from danger while still tearing a hole in whatever ship you pointed the ships bow at. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 26, 2014, 07:52:32 PM
Quote
Is there any way to make your ship always accelerate forwards?
You can send it a ship command to force it forwards, or just change the velocity manually, sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 27, 2014, 08:05:22 AM
@Zudgemud: I know it seems counter-intuitive because you need 'alwaysAccelerate' set to true, but I think you need noAccel set to true as well (in the .csv file, not the .system file). That's the way the burn drive is set up in vanilla.

@Tercys: There are any number of reasons that might not be working. My guess is that your weapon isn't connected to the script somehow. The .wpn file for the rockfly's wings have this line:
"everyFrameEffect":"data.scripts.plugins.RotatingDishArc",
Is your weapon similarly connected to the script?

Other things to check that may or may not matter:
-Does your weapon look the same as the sensordish/rockfly wing in your weapon_data.csv file?
-Do you have "type":"DECORATIVE" in your .wpn file, or is it set to another type?
-Similarly, do you have "type": "DECORATIVE" in the weapon slot your weapon is attached to? This would be in the .ship file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on January 27, 2014, 08:30:27 AM
Got it fixed, thanks.
The script works as intended I just forgot to set up an arc for the decorative slot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on January 27, 2014, 03:01:29 PM
@Zudgemud: I know it seems counter-intuitive because you need 'alwaysAccelerate' set to true, but I think you need noAccel set to true as well (in the .csv file, not the .system file). That's the way the burn drive is set up in vanilla.

Yup, that fixed it, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on January 28, 2014, 06:10:22 AM
It's me again!

Just a little one, is it possible to let a weapon use a script when fired to spawn actual drones?
Or is drone spawning only possible via a system?
Basically I want the ship to hava an activatable system (Let's say for example the burn drive) and be able to spawn drones independant from it's system.
To explain this even furhter: I want to use drones with a fixed position relative to the ship which act as destroyable armor.
(I've got some basic ideas for this and it should work but this always needs the drones to be a system)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 28, 2014, 08:04:39 PM
The 'explain your greebles' thread gave me an interesting idea.

Would it be possible to show custom flux vents? As in, the more vents you put in, the more hull panels are removed from your ship sprite, showing appropriate 'flux vent' greebling underneath?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 28, 2014, 08:40:43 PM
Quote
Would it be possible to show custom flux vents? As in, the more vents you put in, the more hull panels are removed from your ship sprite, showing appropriate 'flux vent' greebling underneath?

Yes, that's possible, via getNumFluxVents() and then doing Sprite swapping.  Anything the API allows us to get and measure can be reflected via sprite swaps.

That would be a lot of work for just one ship, though, and unless it was really spectacular visually, largely a waste of effort; it'd probably be more practical to do this via a special type of Decorative Weapon instead, so that it could be done on multiple ships and be easily added on, but the ship art would need to work well with it.  It is also possible to make elements that change size or position according to the number of Vents or Capacitors- for example, a ship could have an animated dial on it, showing the number of Vents, etc.  The SpriteAPI is quite powerful and can do a lot of things already, I just wish it could change DamagingProjectileAPI objects, because that would really open up some things, like flamethrowers and other dynamic projectile presentations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 28, 2014, 09:08:56 PM
is it possible to let a weapon use a script when fired to spawn actual drones?

I don't know of any way to spawn drones arbitrarily (which, to be clear, doesn't mean it can't be done). However, you might be able to use missiles with custom AI instead. I'm considering making PD drones that launch from weapons this way. One big downside here is that missiles don't have bounds, so they're always shaped like a circle for collision purposes. That might be pretty limiting for what you're trying to do. There may be other serious problems with using missiles this way that I haven't thought of.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 28, 2014, 09:20:44 PM
Quote
Would it be possible to show custom flux vents? As in, the more vents you put in, the more hull panels are removed from your ship sprite, showing appropriate 'flux vent' greebling underneath?

Yes, that's possible, via getNumFluxVents() and then doing Sprite swapping.  Anything the API allows us to get and measure can be reflected via sprite swaps.

That would be a lot of work for just one ship, though, and unless it was really spectacular visually, largely a waste of effort; it'd probably be more practical to do this via a special type of Decorative Weapon instead, so that it could be done on multiple ships and be easily added on, but the ship art would need to work well with it.  It is also possible to make elements that change size or position according to the number of Vents or Capacitors- for example, a ship could have an animated dial on it, showing the number of Vents, etc.  The SpriteAPI is quite powerful and can do a lot of things already, I just wish it could change DamagingProjectileAPI objects, because that would really open up some things, like flamethrowers and other dynamic projectile presentations.

I'd probably never do it. It just seemed like an interesting idea. I have hundreds of ideas, all vying for the "must do this" spot...so annoying. Especially since I'm not really compentent enough to do a tenth of them!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on January 29, 2014, 01:15:25 AM
@Sundog: Thanks for the reply. The problem with missiles is that they explode when they touch something, so using them as armor won't work. Or at least not without writing weird code I guess. Then I have to do it via the system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 29, 2014, 10:56:24 AM
I'm trying to make a Ship System, that when activated stops the ship dead in it's track. It should be unable to move, and be unaffected by impacts by meteors - and ships. The ship system CSV file can disabled the engines and prevent acceleration etc. I've tried using mutators to set the maximum ship speed to 0f, and nothing yet.

Just wondering if it's possible in the first place, I mean having an immovable object is impossible in every sense of Newtonian physics.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 29, 2014, 11:43:02 AM
Just wondering if it's possible in the first place, I mean having an immovable object is impossible in every sense of Newtonian physics.

CLANG!

...What the f*** was that?

http://suptg.thisisnotatrueending.com/archive/1709686/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 29, 2014, 11:51:27 AM
I'm trying to make a ship system that takes away shield and engines, increases all damage taken....but gives you massive flux reserve and damage output. Kind of like having a high ground advantage. Everything works but the 'staying in one place aspect' - which again I'm not sure would work. That's like a divide by 0 error.

Basically I want to make a stationary? artillery ship/platform.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 29, 2014, 02:38:25 PM
@Debido:
Cool idea  :)
Try this:   stats.getEntity().getVelocity().scale(1 - effectLevel);

@Tecrys:
The problem with missiles is that they explode when they touch something
Not when you set "collisionClass":"FIGHTER", in their .proj file  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on January 30, 2014, 02:03:50 PM
Hm, does anyone know how to get the BattleCreationPlugin after creating a BCC? I'd like to pass some information to it, and it seems a bit awkward to have to figure out a way to do it via the PluginPick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 30, 2014, 06:22:53 PM
@Debido:
Cool idea  :)
Try this:   stats.getEntity().getVelocity().scale(1 - effectLevel);


Oh hey, this worked great by the way. It really is like Xalendi said, once it activates CLANG! I guess we now know how to have an 'Emergency p-Space anchor'. You get something like the Onslaught up to 75su/s, then activate that and CLANG! Stops dead in it's tracks. On top of that if the ship is hit by any other body such as an asteroid, you see if flicker to 1su/s for a moment before going back to 0.

I feel like I'm going to have to come up with and design a faction to explore java coding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 30, 2014, 07:07:14 PM
Hm, does anyone know how to get the BattleCreationPlugin after creating a BCC? I'd like to pass some information to it, and it seems a bit awkward to have to figure out a way to do it via the PluginPick.

Can you describe what you're doing in a bit more detail? I'm having trouble understanding the question.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 30, 2014, 07:17:28 PM
Glad it worked the way you wanted Debido  :)

I feel like I'm going to have to come up with and design a faction to explore java coding.
You should!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 30, 2014, 07:30:37 PM
Is there any way to force Civilian ships to get deployed, other than using the BattleCreationContext ESCAPE?

I think that's the last little bump on the road here; the AI's looking pretty good and I've written a cut-down FleetEncounterDialog that appears to have gotten rid of problems with spawned things (although I'm not 100% sure of that yet and need to do more testing).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 30, 2014, 08:02:00 PM
One way is to instantiate the enemy side without an admiral AI and to write your own :)

Another would be going through the CombatFleetManagerAPI to deploy them after the default AI deploys stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 30, 2014, 08:16:26 PM
Quote
One way is to instantiate the enemy side without an admiral AI and to write your own :)
What, can I feed it false when instantiating the fleet in combat, then write it from scratch? 

Not even sure where that begins, though; like, how would I issue orders?  Same as the Mission structure?  That could get interesting, though; not just AI Wars, but Admiralty Wars, lol.  Where would I pick up Advance()?  Oh, duh, include a Plugin... right.  It'd be cool if I had a method to also enable it for the Player somehow, let people just concentrate on kicking butt rather than driving their fleet.

That's like, a whole 'nother project, though, lol- just developing a meaningful core for that that did anything past "go capture everything, then kill 'em all" would be a pretty lengthy thing, I suspect.  I think I'd better do it the cheap-tastic way for now, so that I can get a release done, let people fool around with building their own AIs and all that :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 30, 2014, 08:44:02 PM
I'm looking for doco on how I link the impact of my weapon projectile, with a weapon script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 30, 2014, 09:12:32 PM
See Ion Cannon projectile, it's an example, very simple.

There are lots of examples of different implementations of this in Vacuum as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 30, 2014, 09:27:09 PM
Ack, I can't believe I missed it the first time I went through the .proj file. I need to put my glasses on.

Thanks Xenoargh!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 31, 2014, 12:10:46 AM
Ok, trying to create blinking running lights for my ship, and run into this error:
Spoiler
Code
43688 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-6] INFO  sound.Sound  - Loading sound [sounds/sfx_impacts/gun_hit_glancing_01.ogg]
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43719 [Thread-6] INFO  sound.Sound  - Loading sound [sounds/sfx_impacts/gun_hit_glancing_02.ogg]
43719 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43719 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
[close]

...the hell? I didn't tell it to look in the main game files. It should be looking in the mod folder...

Also, how do I tell my ship to use the lights? There doesn't seem to be a '"stormlights.wpn" goes in this Decorative Slot' option in the editor, or the Hull file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 31, 2014, 12:23:42 AM
BWA HA HA HA! I have made weapons that reduce the enemies CR!!

Top tip when testing enemy CR reducing weapons - don't do it in the 'battle simulation' in the refit screen...wierd things happen, or not at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 31, 2014, 12:44:13 AM
You made an entropy gun? awesome.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 31, 2014, 12:59:44 AM
Looking at it, it looks likely to be able to:
+ increase/decrease hitpoints - potentially allowing you to do direct damage to your enemy, or heal an ally?
+ give the effect of being in the nebula, slowing them down, inhibiting lateral movement?
+ spontaneously disable their ship systems, or cause them to enable?
+ change the parameters for their shields?

Going to play around with it, see what kind of havoc can be caused.

I was thinking with the 'entropy gun' it would be good for modders that have a 'biological' race or something like that, where you can 'infect' an enemy ship with spores or whatever and disable or destroy the ship from the inside...then attack them when they're weakest.

I can imagine a range of tactical advantages in using weapons that do something other than 'damage' the target directly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 31, 2014, 01:15:38 AM
Umm what does the Hidden weapon mount do? What is the difference?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on January 31, 2014, 01:30:47 AM
Hm, when it comes to beams and scripts, how often does the script run? Every frame? Are frames related to the frame rate rendered to the computer screen? Or are we talking about different game 'frames' that are discrete units of time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on January 31, 2014, 02:18:28 AM
Hm, does anyone know how to get the BattleCreationPlugin after creating a BCC? I'd like to pass some information to it, and it seems a bit awkward to have to figure out a way to do it via the PluginPick.

Can you describe what you're doing in a bit more detail? I'm having trouble understanding the question.
I'd like to set up a battle with some ships already deployed in the centre of the map. To do this I'd like to pass some lists of fleet members to the new BattleCreationPlugin I'm using, that can pass them to a EveryFrameCombat script to position them. I'm not entirely sure of how to get the data there, though- the fleet interaction dialog makes a new BattleCreationContext, then runs the BCC, but I can't see any way to get the BCPlugin (which I assume is created when the BCC is?).

I could pass the data via the PluginPick for the BCP, through the constructor for the new BCP but that seems slightly odd- as it involves saving data that seems entirely local to the fleet interaction as PersistentData and pulling it out in the CampaignPlugin.
Code: java
return new PluginPick<BattleCreationPlugin>(new MyPlugin(List1,List2), PickPriority.MOD_SPECIFIC)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on January 31, 2014, 02:29:26 AM
Umm what does the Hidden weapon mount do? What is the difference?

It hides the weapon sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2014, 08:29:58 AM
I'd like to set up a battle with some ships already deployed in the centre of the map. To do this I'd like to pass some lists of fleet members to the new BattleCreationPlugin I'm using, that can pass them to a EveryFrameCombat script to position them. I'm not entirely sure of how to get the data there, though- the fleet interaction dialog makes a new BattleCreationContext, then runs the BCC, but I can't see any way to get the BCPlugin (which I assume is created when the BCC is?).

I could pass the data via the PluginPick for the BCP, through the constructor for the new BCP but that seems slightly odd- as it involves saving data that seems entirely local to the fleet interaction as PersistentData and pulling it out in the CampaignPlugin.
Code: java
return new PluginPick<BattleCreationPlugin>(new MyPlugin(List1,List2), PickPriority.MOD_SPECIFIC)

Ah, ok - that's pretty much how I'd do it, yeah. You don't really need to involve the PluginPick, though, could just retrieve the data directly from within the BCP.

The BCC could stand to have a generic map of stuff you could use to pass things like that around, but since it doesn't, this slightly-roundabout way is the best way to go.

You *could* also use a static variable somewhere, but I'd recommend against it - if you're putting references to fleet members and such there, there's a good chance of causing a memory leak when a different save is loaded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2014, 08:32:34 AM
Hm, when it comes to beams and scripts, how often does the script run? Every frame? Are frames related to the frame rate rendered to the computer screen? Or are we talking about different game 'frames' that are discrete units of time.

Yeah, every frame. Frames are tied to the actual framerate, the "float amount" parameter tells you how much time elapsed since the last frame. If the framerate goes below 30, the simulation slows down - so, essentially, for the purposes of whatever scripts you're writing, you can assume the fps never drops below 30. This can be useful for things like collision detection/knowing the maximum amount something can move in a single frame/etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2014, 08:37:19 AM
What, can I feed it false when instantiating the fleet in combat, then write it from scratch? 

Not even sure where that begins, though; like, how would I issue orders?  Same as the Mission structure?  That could get interesting, though; not just AI Wars, but Admiralty Wars, lol.  Where would I pick up Advance()?  Oh, duh, include a Plugin... right.  It'd be cool if I had a method to also enable it for the Player somehow, let people just concentrate on kicking butt rather than driving their fleet.

Yep. There are methods for issuing orders in the CombatFleetManagerAPI. In terms of overall effort, I'd say it's an order of magnitude less to write than ship AI... but that does depend on how deep you want to go.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 31, 2014, 11:12:02 AM
Yeah, I figure a simple version wouldn't be too bad.  Then again, writing a simple AI wasn't too bad, either- it was the polish that was hard; your AI does a heck of a lot of stuff, and the game's more-or-less built around that stuff. 

Just trying to get this release-ready so that people can chew on the first bits, y'know :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on January 31, 2014, 11:19:44 AM
Ah, ok - that's pretty much how I'd do it, yeah. You don't really need to involve the PluginPick, though, could just retrieve the data directly from within the BCP.

The BCC could stand to have a generic map of stuff you could use to pass things like that around, but since it doesn't, this slightly-roundabout way is the best way to go.

You *could* also use a static variable somewhere, but I'd recommend against it - if you're putting references to fleet members and such there, there's a good chance of causing a memory leak when a different save is loaded.
Ah, okay then- thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2014, 11:38:48 AM
Yeah, I figure a simple version wouldn't be too bad.  Then again, writing a simple AI wasn't too bad, either- it was the polish that was hard; your AI does a heck of a lot of stuff, and the game's more-or-less built around that stuff. 

Just trying to get this release-ready so that people can chew on the first bits, y'know :)

Yeah, makes sense. Don't want to do everything all at once.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 31, 2014, 01:37:38 PM
Ok, trying to create blinking running lights for my ship, and run into this error:
Spoiler
Code
43688 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-6] INFO  sound.Sound  - Loading sound [sounds/sfx_impacts/gun_hit_glancing_01.ogg]
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_00.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_01.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_02.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_03.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_04.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_05.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_06.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43703 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_07.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43719 [Thread-6] INFO  sound.Sound  - Loading sound [sounds/sfx_impacts/gun_hit_glancing_02.ogg]
43719 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
43719 [Thread-11] ERROR com.fs.graphics.o0oO  - Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/weapons/decorative/lights/stormlights_08.png] resource, not found in [C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Ò00000(Unknown Source)
at com.fs.util.Object.Ó00000(Unknown Source)
at com.fs.graphics.o0oO.String(Unknown Source)
at com.fs.graphics.o0oO.Ò00000(Unknown Source)
at com.fs.graphics.o0oO$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
[close]

...the hell? I didn't tell it to look in the main game files. It should be looking in the mod folder...

Also, how do I tell my ship to use the lights? There doesn't seem to be a '"stormlights.wpn" goes in this Decorative Slot' option in the editor, or the Hull file

Don't suppose anyone knows how this happened? Sorry for being impatient.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 31, 2014, 04:10:57 PM
It is looking in the mod folder:

Code
C:\Program Files\Fractal Softworks\Starsector\starsector-core\..\mods\Eloi,../starfarer.res/res,CLASSPATH

And it's probably borking becaue you haven't used the right naming conventions- animated weapons need to use 00, 01 etc. at the end of their names, to designate which frame they are.

Lastly, "stormlights.wpn" needs to be weapon_data.csv, like any other weapon.  Then in the editor, you need to set it up with a DECORATIVE BUILT_IN type slot and you'll see it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on January 31, 2014, 05:21:40 PM
Thanks. Between you and MesoTronik, I think I know where I've gone wrong. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on February 02, 2014, 02:24:42 PM
Quick question. Is there an on hit/impact sound for projectiles. I have a projectile that will either explode, or use xenoargh's heat projectile onhit script. I know how to set explosion SFX, however I'm not sure how to apply a different sound for when the projectile hits something without exploding (triggering the heat script).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 02, 2014, 04:52:09 PM
I've been looking at the engine contrail, and editing the engine_styles.json file etc.

The end effect I want is something like the 'tron' cycles or the oldy Homeworld ship trails aka

Spoiler
(http://media.moddb.com/images/mods/1/6/5393/27835.jpg)
[close]

I can get the 'exhaust' to be stationary by setting the "contrailMaxSpeedMult":0f,

Also for me to change the engine glow I needed to replace the engineglow32/s.png file, which then affects all using that engine glow.

How do I set my own style where I can specify my own engine glow and contrail FX files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 02, 2014, 05:04:43 PM
Dude if you get the engine contrails to look like this, you will be my hero. (http://www.youtube.com/watch?v=xWr0Ei1ePN0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gotcha! on February 02, 2014, 05:18:15 PM
...you will be my hero.

And mine too, for obvious reasons. ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 02, 2014, 05:51:34 PM
I have to be honest I'm more of a fan of the Homeworld type contrail. The Tron contrail has not jitter, without that little bit of occasional jitter you get a straight line and you lose the sense of speed a bit. If you have jitter within the stream you get slight variation that human brain then interprets as 'movement'.

I'm thinking I'm going to have to get a lot of help from Xenoargh on this matter. He's done some cool polishing of the projectiles sprites.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on February 02, 2014, 06:48:53 PM
I definitely have to second favoring the Homeworld style contrails, they have a much more organic and pleasing aesthetic to them in my opinion.  I suspect it might be spoofable through using decorative weapon slots in place of the regular engines and having it leave behind a particle trail if the ship happens to be moving, though that would not be the ideal solution I suspect.

In any case, I also have a question.  I can't quite get this code to work for the replacement Pandora; the intended effect is intended to be a kind of "lightning shotgun."  Unfortunately I can't figure out how to get it to implement the override that needs to be done, so it crashes at runtime.

Spoiler
Code
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.lazywizard.lazylib.CollisionUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;

public class PandoraZapMaster implements BeamEffectPlugin, EveryFrameWeaponEffectPlugin
{
    private static float maxTargs = 6f;
    private static float RANGE = 1000f;
    private static float ANGLE = 60f;
    private static float dam = 250f;
    private static float emp = 0f;
    private IntervalUtil fireInterval = new IntervalUtil(0.3f, 0.4f);
    private static final float EMITTER_THICKNESS = 24f;
    private static final Color EMITTER_FRINGE = new Color(125,155,115,150);
    private static final Color EMITTER_CORE = new Color(165,215,145,255);
    private CombatEntityAPI activeArc = null;
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI emitter)
    {
        if (activeArc != null) {
            if (!engine.isEntityInPlay(activeArc)) {
                activeArc = null;
            }
}
       
        ShipAPI ship;
        ShipAPI attacker = emitter.getShip();
       
        WeaponAPI weapon;
       
        for (Iterator iter = Global.getCombatEngine().getShips().iterator(); iter.hasNext();) {           
            ship = (ShipAPI) iter.next(); //Loads the current ship the iterator is on into 'ship'
           
            if (ship == attacker) continue; //No point in counting the firing ship, so skip it
            //check if the ship is in an arc surrounding the weapons facing - TODO
           
            for (int x = 0; x < maxTargs; x++) {
                if (emitter.isFiring() && (MathUtils.getDistance(ship, attacker) <= (RANGE))) { 
                    //spawn emp arcs from the weapon to the target ship(s) and apply damage
                    if (ship != null && ship instanceof ShipAPI) {
                        fireInterval.advance(amount);
                        if (fireInterval.intervalElapsed()) {
                            activeArc = engine.spawnEmpArc(emitter.getShip(), emitter.getLocation(),
                            emitter.getShip(), activeArc, DamageType.ENERGY, dam, emp, RANGE, null,
                            EMITTER_THICKNESS, EMITTER_FRINGE, EMITTER_CORE);
                        }
                    }
                    //apply some fuzzy maths so that the emp arcs aren't all hitting the same point - TODO
                   
                }
            }
        }
       
    }

}
[close]

Some of the packages being loaded aren't necessary I realize but I'll trim the imports when I've got things finalized.  The other thing I need to do is figure out how to implement the new ship system (an engine jammer) but I figure that that can wait until I get to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 02, 2014, 07:05:25 PM
It's easy to get a long contrail, but I don't seem to be editing the right contrail file or something (though there is only one). Also it looks like the default behavior for the contrail is to apply some sort of Gaussian blur, so I can't get that hard defined edge between the main 'core' and the thin 'transparent outer layer'.

The next thing is the engine that spawns the 'contrail' particle is heavily dependent on the speed. So if you go to fast you can breaks in the contrail...making it look awful. Not sure, need better information on this. Currently stabbing away in the dark.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 02, 2014, 10:44:23 PM
Is it possible for a missile to use "behaviorSpec":{"behavior":"PROXIMITY_FUSE", ... } like the flak cannon? I haven't been able to get it to work, but I might just be missing something. Is there an example somewhere?

@McShadowy: The problem with your script is that the third argument of advance needs to be a BeamAPI rather than a WeaponAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 12:06:00 PM
I've got a little question here: I want to have an onhit effect for a weapon that heals hull and armor of the ship which fired the weapon.
I have no idea of coding but if anyone could help me with this please I would be very thankful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 12:09:54 PM
Heal beam or healing projectile? Both?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 12:18:56 PM
Like in some rpgs you have weapons that give a percentage of the damage dealt back as hitpoints.
I want that for my melee weapons but I'm too stupid to code it. I really don't understand Java. A nice place to get started with Java would be cool, too.
PS: Ahealing beam or something similar for dedicated healer ships would help me A LOT as well.

Thanks for the help!

Edit: If that life leech could repair armor as well that would be really awesome!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 12:40:38 PM
Ahh I get it now, you want to leech health from them? Sort of thing? Or is it sort of like a RPG sword where you receive health that is a percentage of the damage dealt...mmm....I guess the equivalent of a vampiric drain attribute?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on February 04, 2014, 12:52:05 PM
For a health leech effect, since iirc there is no event response that gets the amount of damage dealt, the easiest method would be to set the weapon damage to 0 and then code in an on-hit damage effect, checking the target ship's hull before and after the damage and raising the firing ship's hull by an equal amount.  You'll have to hack the weapon description to show the real damage, though.

For a health regain weapon, I forget if there's an OnFire event handler, but if not just make it a 0-damage missile that immediately runs out of flight time (i.e. it instantly hits you) and then raise the firing ship's hull by whatever value you desire.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 12:52:44 PM
Yes something like that. If it actually drains health or just heals your ship for a percentage of the damage dealt is not important. I simply want to sustain may ships at melee range without shields and very little armor and I want to balance my ships around that idea.
i found this regeneration script, maybe someone can help me to repurpose it to an onhit effect:
http://fractalsoftworks.com/forum/index.php?topic=6452.msg120958#msg120958

Also: It would be very cool if this could work while chewing on other ships hull ONLY. So you hit the shield, you don't heal; you hit the hull/armor of a ship, you get healed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 12:54:58 PM
For a health leech effect, since iirc there is no event response that gets the amount of damage dealt, the easiest method would be to set the weapon damage to 0 and then code in an on-hit damage effect, checking the target ship's hull before and after the damage and raising the firing ship's hull by an equal amount.  You'll have to hack the weapon description to show the real damage, though.

For a health regain weapon, I forget if there's an OnFire event handler, but if not just make it a 0-damage missile that immediately runs out of flight time (i.e. it instantly hits you) and then raise the firing ship's hull by whatever value you desire.

That sounds quite cool.
Now how do I set this up? As I said before I have no idea how to use Java, as of now I grabbed code from existing mods and repurposed it but I don't understand most of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 12:55:40 PM
Well here is come code for the 'Healing Beam', it works but needs polishing and removal of debug lines.

Code

package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import org.apache.log4j.Level;

public class HealBeamOnHitEffect implements BeamEffectPlugin
{

    
    private ShipAPI theShip;
    private float health;
    private float repairedHealth;

    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        CombatEntityAPI target = beam.getDamageTarget();
        
        // Check if we hit a ship (not its shield)
        if (target instanceof ShipAPI && beam.didDamageThisFrame())
        {

                health = ((ShipAPI) target).getHullLevel();
                if (health > 0.8f) {
                    Global.getLogger(HealBeamOnHitEffect.class).log(Level.INFO,"Health nearly full");
                } else if (health < 0.8f) {
                Global.getLogger(HealBeamOnHitEffect.class).log(Level.INFO,health);
                repairedHealth = (health + 0.2f) * ((ShipAPI) target).getMaxHitpoints();
                Global.getLogger(HealBeamOnHitEffect.class).log(Level.INFO,repairedHealth);
                ((ShipAPI) target).setHitpoints(repairedHealth);
                Global.getLogger(HealBeamOnHitEffect.class).log(Level.INFO,"Heal Beam Worked");
                } else {
                    Global.getLogger(HealBeamOnHitEffect.class).log(Level.INFO,"Heal Beam didn't work!");

            }
        }
    }
}



and here is one for projectiles

Code

package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import org.lwjgl.util.vector.Vector2f;
import org.apache.log4j.Level;

public class HealShotOnHitEffect implements OnHitEffectPlugin
{

    private float health;
    private float repairedHealth;
    
    

    @Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine)
    {
        // Check if we hit a ship (not its shield)
        if (target instanceof ShipAPI && !shieldHit)
        {
            // Apply extra damage of a random type
 
                CombatEntityAPI damagedTarget = projectile.getDamageTarget();
                                
                
                if (damagedTarget != null){
                health = ((ShipAPI) damagedTarget).getHullLevel();
                Global.getLogger(HealShotOnHitEffect.class).log(Level.INFO,health);
                repairedHealth = (health + 0.2f) * ((ShipAPI) damagedTarget).getMaxHitpoints();
                Global.getLogger(HealShotOnHitEffect.class).log(Level.INFO,repairedHealth);
                ((ShipAPI) damagedTarget).setHitpoints(repairedHealth);
                Global.getLogger(HealShotOnHitEffect.class).log(Level.INFO,"Shot healed target");
                } else {
                    Global.getLogger(HealShotOnHitEffect.class).log(Level.INFO,"Heal didn't work");
                }
                      

        }
    }
}



Then you've still got the problem of getting them into the game as part of your faction, and that's a whole other story. I think there is a doco or tutorial on factions around the forum somewhere.

But anyway you'll still need to add the weapons to your weapon_data.csv file, then have the associated .wpn and .proj JSON files.

In the case of the .wpn file for the heal beam make sure you put the line

   "beamEffect":"data.scripts.weapons.HealBeamOnHitEffect",

somewhere and for the projectile .proj file put

   "onHitEffect":"data.scripts.weapons.HealShotOnHitEffect",

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 01:00:05 PM
Thanks Debido!

I can handle creating new weapons and I think I can add the script to the weapon.
Now that heal beam doesn't do any damage but heals the target hit, right?

Wow, reading that code I might start to understand a few things about the programming language.
Debido, you'll definitely be credited when my mod is finished, thank you!

So if I understand that code the right way I can change ((ShipAPI) damaged target) to something like ((shipAPI ship which shot) (something like that, have to look it up how the ship should be called which fires this weapon) and it gets back health?
I think that should work. Correct me if I'm wrong ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 01:08:06 PM
Might be able to do a leech beam for you. Maybe using BeamAPI uses the ShipAPI getSource() method. It checks the didDamageThisFrame(), gets the source ship and gives health (in theory).

The amount of damage done is inferred from the weapons_data.csv file.

I was thinking though, you might be able to use the CombatEngineAPI.addFloatingText to show health that has been healed, or alternatively leeched and given to your ship.

I haven't played with the addFloatingText method, but it seems worthy of investigation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 01:13:22 PM
Actually I was just thinking about your melee ship, it's going to get a face full of infernium explosion when the reactor goes critical on the death of the enemy ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 01:19:16 PM
Actually I was just thinking about your melee ship, it's going to get a face full of infernium explosion when the reactor goes critical on the death of the enemy ship.
Yes it does. I'm not sure if I can do anything about it. That one is really tough so it can handle it but I want those ships to have quite little armor, no shields but a quite big health pool to play with. I'm taking in account that they will loose quite some health on theyr way but when they reach their target they can compensate. Thi way would be nice for balancing the faction.
I hopt that makes sense ...

Edit: Did you see my teaser trailer? Right in the end just a few seconds before the vid is over you can see clearly that explosion right into it's face.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 01:22:39 PM
Well it was recently discovered by Xenoargh that if you reduce the hull health below 0, it will cause the enemy ship to 'disappear' without any explosion or hulk (IIRC). You could let that happen, but then cover up the ship miraculously disappearing with ...something... like a nice big organic gooey explosion or blood entrails - I don't know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 01:26:08 PM
Yes I read that but I have no idea on how to reduce a ship to 0 HP right away and popping a different object where the explosion is supposed to be. Also that's a bit cheating if you prevent those ships from being hit by the explosion. Maybe a simple damage reduction from AOE damage would do the trick.

Edit: Although replacing the explosion by a hulk quickly melted down by acid would look really cool.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 02:44:42 PM
Hmmm, replacing it with a melted hulk...yeah, need to ask someone with more familiarity on that topic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 03:02:57 PM
Ok, so here is what a 'Leech Beam' could look like, need to do some play testing. What you've got to decide is how much damage you want do to the target ship, whether you want to do damage as a % of it's original health, a static amount, a random amount etc. and also if you want to heal the source by the same amount, or whether it's a %, random, static etc. or maybe you want to have a chance of a critical hit as well.

In the below example I'm draining health every frame(?) as a %, and gaining health as a static amount of 100 points every frame(?)

I'm not sure how often the BeamAPI is called, I'm assuming every frame, but it seems you can also have it apply every other frame or a fraction of the frames etc.

It's going to boil down to how you want this weapon designed.

Code

package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import org.apache.log4j.Level;

public class LeechBeamOnHitEffect implements BeamEffectPlugin
{

   
//    private ShipAPI theShip;
   
    private float targetHealth;
    private float sourceHealth;

   
    private float leechedHealth;
    private float leechGainedHealth;
    private float sourceHitpoints;

    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        CombatEntityAPI target = beam.getDamageTarget();
        CombatEntityAPI source = beam.getSource();
       
        // Check if we hit a ship (not its shield)
        if (target instanceof ShipAPI && beam.didDamageThisFrame())
        {

                targetHealth = ((ShipAPI) target).getHullLevel();
                sourceHealth = ((ShipAPI) source).getHullLevel();
                sourceHitpoints = ((ShipAPI) source).getHitpoints();
               
               
                if (targetHealth < 0.0002f) {
                    Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"Health nearly depleted");
                } else if (targetHealth > 0.001f) {
                Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,targetHealth);
                leechedHealth = (targetHealth - 0.1f) * ((ShipAPI) target).getMaxHitpoints();
                Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"leechedHealth is: " + leechedHealth);
                if (leechedHealth < 0.0001f) {
//                    To do if health less than 0.0001f and ship is deleted
                } else {
                    ((ShipAPI) target).setHitpoints(leechedHealth);
                }
                   

                Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"Leech Beam Worked");
                } else {
                    Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"Leech Beam didn't work!");
                }
               
                if (sourceHealth < 1.2f) {
                    leechGainedHealth = 10f;                   
                    ((ShipAPI) source).setHitpoints(sourceHitpoints + leechGainedHealth);
                   
                    Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"Leech Beam healed source");
                   
                } else {
                    Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"Leech Beam didn't heal source");
                }
        }
    }
}


Again I still have all my debug logging code in there, I'm going to go play with it a bit.

Edit: ok, so modified the script a bit, prevented ship disappearing, but left the code there to do something else if you want it to.

That said this only does hull damage and bypasses the armour cells, you should also note that you can buff the hull past 100% for the source, but not too much mind you.

I think there are people who have already done code for doing custom damage to armour cells, but yeah should be straight forwardish.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 03:31:26 PM
Nice!

Now I've made the weapons shoot projectiles ... What do I need to change to make this work for a projectile?

Edit: Tried myself to make this work for a projectile. I feel like I start to understand stuff! Gonna try it out, Thanks a lot!

Edit2: I thought I had learned something and I tried to modify that script a bit and just play around. Didn't work, I still don't understand anything.
Tested the beam script ingame, does weird things: after the first 3 or 4 hits the onslaught is on about 5% health, armor is completely intact (you wrote it wouldn't do armor damage so that was to expect) and after that doesn't take barely any damage. However, the HP of the testing ship increased with each hit so the healing effect kinda works.

Would it be possible to simplify that code and don't look for the enemy ship hitpoints at all?
Could you simply take the base damage from weapon.csv and heal a percentage of that but still check for shields or not because shield hits should definitely not heal the attacking ship I think?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 04:40:00 PM
@ Edit 2:

Yep, I have been working on that since my last post, after remember something from Vacuum's Megabeam

Code

package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponAPI.DerivedWeaponStatsAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.apache.log4j.Level;

public class LeechBeamOnHitEffect implements BeamEffectPlugin
{

   
//    private ShipAPI theShip;
   
    private float sourceHealth;
   
    private float leechGainedHealth;
    private float sourceHitpoints;
   
    private final IntervalUtil fireInterval = new IntervalUtil(1f,1f);

    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        //how far forward to advance the game engine
        fireInterval.advance(amount);
        //get the beam target
        CombatEntityAPI target = beam.getDamageTarget();
        //get the beam source
        CombatEntityAPI source = beam.getSource();
        //get the beam weapon
        WeaponAPI sourceWeapon = beam.getWeapon();
        //get the statistics for the beam weapon
        DerivedWeaponStatsAPI weaponStats = sourceWeapon.getDerivedStats();
        //get the DPS for the weapon
        float healDps = weaponStats.getDps();
         
       
       
        // Check if we hit a ship (not its shield)
        if (target instanceof ShipAPI && beam.didDamageThisFrame())
        {
                //get the hull level of the source ship as a %
                sourceHealth = ((ShipAPI) source).getHullLevel();
                //get the current hitpoints of the source ship
                sourceHitpoints = ((ShipAPI) source).getHitpoints();
               
                //if the health of the source ship is less then 120% of normal
                if (sourceHealth < 1.2f) {
                   
                    //A bit of a redundant line, could just put healDPS straight into the next line
                    leechGainedHealth = healDps;
                    //Give the amount of damage applied per second to the hit points of the source ship
                    ((ShipAPI) source).setHitpoints(sourceHitpoints + leechGainedHealth);
                   
                    //debug, remove for final
                    Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"Leech Beam healed source" + leechGainedHealth);
                   
                } else {
                    //debug, remove for final
                    Global.getLogger(LeechBeamOnHitEffect.class).log(Level.INFO,"Leech Beam didn't heal source");
                }
        }
    }
}



EDIT: Added comments to the code to make it easier to understand.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 04:45:08 PM
Ok, so here is what a 'Leech Beam' could look like, need to do some play testing. What you've got to decide is how much damage you want do to the target ship, whether you want to do damage as a % of it's original health, a static amount, a random amount etc. and also if you want to heal the source by the same amount, or whether it's a %, random, static etc. or maybe you want to have a chance of a critical hit as well.

Right now I made the weapon to do 450 damage but that was just a number, balancing will take a while usually. I made it a projectile weapon because it is easier to sync with the animation and has a pretty cool effect if you add some impact to the weapon.
Ok, I'm off tomorrow and the day after so I will work a lot on this mod then, probably lots of cosmetic stuff (cause I can't do much else ... I should read some tutorials on Java).

Edit: Reading that new code ... This onne looks like it doesn't do weird stuff with the enemy hp bar I think, also can I simply do this for example:

leechGainedHealth = (healdps/100 * 30)

to make it heal 30%, or how would I do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 04:49:54 PM
*looks through DamagingProjectileAPI*

Yeah looks like you can make it a projectile weapon, and get the source of the projectile and do the rest as normal.

Let me cook something up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 05:04:48 PM
leechGainedHealth = (healdps/100 * 30) would...heal your ship 0.3 (about a third) of the effective DPS.

If you want to make it heal a flat amount of hull health, that is to say, each time you hit you restore 30% of your ship's health then that is a little different but very doable. We need to just get the hullLevel and add 0.3 to it for each hit except where it would make the hullLevel go over 100%.

That weird thing it's doing with the health bar for the source ship, is where it's making it's health go above 100%. I though it would be one one way of getting around exposing your ship to an infernium drive exploding in it's face by giving your critter a small boost of health before he gets a face full of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 04, 2014, 05:10:07 PM
leechGainedHealth = (healdps/100 * 30) would...heal your ship 0.3 (about a third) of the effective DPS.

That's exactly the way it needs to be, If you let the ship heal a percentage of it's own hp it would be near immortal. Most life leech or vampiric weapons work this way, that's perfect!
Thanks for the clarification!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 11:17:04 PM
Ok, so yeah, here you go.

Code

package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import org.lwjgl.util.vector.Vector2f;
import org.apache.log4j.Level;

public class LeechShotOnHitEffect implements OnHitEffectPlugin
{

    private float sourceHealth;
    private float sourceHitpoints;
    //set the below multiplier to change the proportion of the weapon_data.csv file damage effect.
    private final float damageMultiplier = 0.3f;

    @Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine)
    {
        //get the projectile source
        ShipAPI source = projectile.getSource();
       
        //get the amount of damage done by the projectile
        float weaponDamage = projectile.getDamageAmount();
        //apply the damage multiplier
        float finalDamage = weaponDamage * damageMultiplier;
             
       
       
        // Check if it's a valid target, check if it's a ship, check that the projectile didDamage and lastly check if the shield is off.
        if (target != null && target instanceof ShipAPI && projectile.didDamage() && target.getShield().isOff())
        {
                //get the hull level of the source ship as a %
                sourceHealth = source.getHullLevel();
                //get the current hitpoints of the source ship
                sourceHitpoints = source.getHitpoints();
               
                //if the health of the source ship is less then 100% of normal
                if (sourceHealth < 1f) {
                   
                    //check if the leech effect would put the ship over it's Maximum Hitpoints aka health   
                    if ((sourceHitpoints + finalDamage) >= source.getMaxHitpoints()) {
                        // then set the hitpoints to the maximum hitpoints
                        source.setHitpoints(source.getMaxHitpoints());
                       
                        //else if applying final damage would take the ship over 100%, perform as normal. This else if step can be made else after debug is removed.
                    } else if ((sourceHitpoints + finalDamage) < source.getMaxHitpoints()) {

                    //Give the amount of damage applied per second to the hit points of the source ship
                     
                    ((ShipAPI) source).setHitpoints(sourceHitpoints + finalDamage);
                                       
                    //debug, remove for final
                    Global.getLogger(LeechShotOnHitEffect.class).log(Level.INFO,"Leech shot healed source: " + finalDamage);
                   
                } else {
                    //debug, remove for final
                    Global.getLogger(LeechShotOnHitEffect.class).log(Level.INFO,"Leech shot didn't heal source");
                }
        }
    }
    }
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Shellster on February 04, 2014, 11:30:30 PM
I know very little when it comes to coding and I don't know if this has been asked before but is it possible to make a plasma projectile homing like a missile?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 04, 2014, 11:50:55 PM
The answer is, yes, but the solution is making a missile that looks like a plasma projectile. Have you seen the Neuterino photon torpedo launcher? Is that the kind of effect you're looking for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Shellster on February 05, 2014, 12:11:55 AM
Yeah I thought i'd have to do that, the only thing though is that the plasma projectiles don't seem to be just a static sprite but actually animate or something, which I really liked the effect of.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 05, 2014, 01:02:32 AM
Just tried that script, works like a charm. Thank you so much!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 05, 2014, 01:24:02 AM
Great to hear Tecrys, just remember to remove the logging code.

The code needs some polish up before being pushed to clients, but otherwise it's fully functional.

I'd be happy to try coding some other things, as I'm trying to re-learn it again after not touching it for far too many years.

I can't do too much, you should see the work by dmaiski, Xenoargh, Lazywizard etc. they do some crazy stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 05, 2014, 03:11:42 AM
I know what you mean, I've been following them quite a bit. Crazy stuff they can code! Love it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 05, 2014, 03:51:03 AM
If you're looking for a weapon...let's say, your alien being thing can inject and infect the enemy ship with spores...and take it over (for that combat round)

Code

package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import org.lwjgl.util.vector.Vector2f;
import org.apache.log4j.Level;

public class TakeShotOnHitEffect implements OnHitEffectPlugin
{
    @Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine)
    {
        int shipSourceOwner = projectile.getSource().getOwner();
        // Check if we hit a ship (not its shield)
        if (target instanceof ShipAPI && !shieldHit)
        {
                CombatEntityAPI damagedTarget = projectile.getDamageTarget();
               
                if (damagedTarget != null){
                ((ShipAPI) damagedTarget).setOwner(shipSourceOwner);

                Global.getLogger(TakeShotOnHitEffect.class).log(Level.INFO,"Takeover Shot Effect Worked");
                } else {
                    Global.getLogger(TakeShotOnHitEffect.class).log(Level.INFO,"Takeover Shot Effect Didn't work");
                }

        }
    }
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 05, 2014, 05:45:42 AM
I see what it does, fun stuff. ATM I'm trying to figure out on how to get the AI to get in range of those melee weapons.
If I let the AI control my ships it simply circles them on a set distance and it can't get close enough to hit the enemy ship.
I was thinking of a hull mod that simply tells the AI to get very close. Guess I will wait till Xenoargh is ready to present his modded AI with the next release of Vacuum ...

But yeah, that weapon is pretty cool.
Another thing I was thinking about which would solve some of my AI problems as well:
A weapon that works like a grappling hook. It should somehow attach onto an enemy and pull it closer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 05, 2014, 12:29:39 PM
Got my AI problems solved until Xeno is finished with proper AIs. For now I made a weapon based on the repulsor beam and inverted it to pull stuff, did a lot of testing on different ships to make it feel right.
Now even the AI can kill stuff with my ships, hurray!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on February 07, 2014, 05:48:29 PM
Does anyone know of a way to give a weapon the ability to temporarily disable enemy shields (Like a malfunction)? I'm looking to make a weapon that has a small chance to apply some catastrophic effect like one of the three major malfunctions (Engine, shield, weapon) to a target ship. I know how to increase the chance of those things happening to a ship, simply mutable stats, however I'm not sure how I would go about that with an on hit script. I'm not asking anyone to make me anything, but if anyone has any ideas I'd be very appreciative of a nudge in one direction or another.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 07, 2014, 07:18:40 PM
Is it possible to make a weapon's arc 'off-center'? As in, have the weapon facing forwards, but the center of the arc facing off to the side?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: InfinitySquared on February 08, 2014, 11:14:24 AM
What do I do again to make the missile drift or wait for a few seconds before engaging its engines?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 08, 2014, 01:02:20 PM
@InfinitySquared: If there's a setting for this I don't know about it, and I don't remember ever seeing a missile with an engine delay. I think you'd need to write a MissileAIPlugin to accomplish that.

@Xalendi: So you want a weapon to look like it's facing forward but shoot to the side? I think you could make that happen simply by rotating the sprite sideways, but you'd need two different weapons for left/right.

@Arumac: I don't know of a clean way to do that, but I think it could be hacked together. It might be easier for me to just write an example than to explain what I'm thinking in English though. Let me know if you want me to give it a shot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: InfinitySquared on February 08, 2014, 07:19:59 PM
@InfinitySquared: If there's a setting for this I don't know about it, and I don't remember ever seeing a missile with an engine delay. I think you'd need to write a MissileAIPlugin to accomplish that.

That's just it. I remember there being such a setting, but the specifics of it are lost to me. It was used some of the older mods, as I recall.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 08, 2014, 07:33:01 PM
Can someone please explain to me the IntervalUtil class and how it relates to the combat engine and frames? Some examples would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on February 08, 2014, 08:41:01 PM
@InfinitySquared: If there's a setting for this I don't know about it, and I don't remember ever seeing a missile with an engine delay. I think you'd need to write a MissileAIPlugin to accomplish that.

That's just it. I remember there being such a setting, but the specifics of it are lost to me. It was used some of the older mods, as I recall.

I think you might be able to achieve that effect by making a MIRV missile that fires a single projectile, like a SABOT missile. You'd probably have to tweak the MIRV settings, but that might work.

@Sundog : Your help is always welcome and appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 08, 2014, 09:18:12 PM
Does anyone know of a way to give a weapon the ability to temporarily disable enemy shields (Like a malfunction)? I'm looking to make a weapon that has a small chance to apply some catastrophic effect like one of the three major malfunctions (Engine, shield, weapon) to a target ship. I know how to increase the chance of those things happening to a ship, simply mutable stats, however I'm not sure how I would go about that with an on hit script. I'm not asking anyone to make me anything, but if anyone has any ideas I'd be very appreciative of a nudge in one direction or another.

The Star Wars mod (http://fractalsoftworks.com/forum/index.php?topic=5986.0) had a combat plugin that could disable shields temporarily. That might be a good base for what you're trying to do.

If I remember correctly, it did have a problem resetting shield upkeep cost when it re-enabled shields. It actually worked by removing the shield from your ship for the duration then adding a new, identical one once the timer was up, but the API at the time couldn't retrieve shield upkeep so that wasn't stored.


Can someone please explain to me the IntervalUtil class and how it relates to the combat engine and frames? Some examples would be greatly appreciated.

It's pretty simple once you get a handle on it. It's actually not based on the combat engine or frames or even time. This is because it doesn't advance on its own, you call its advance() method manually with the amount to advance by. While this is usually the time since the last frame, it doesn't have to be. You could just as easily use an IntervalUtil to keep track of how many times you fired a weapon for creating a special effect that only happens every <x> shots. :)

So, a basic example. Let's go with a common use, having an event happen occasionally during battle. Say you defined a new IntervalUtil with
Code: java
IntervalUtil example = new IntervalUtil(30f, 50f);
And in an EveryFrameCombatPlugin's advance(), you call example's advance() method with the time since last frame.

In this case, a random target number would be chosen between 30 and 50. When the total amount passed into this IntervalUtil's advance() method reaches that target, a few things happen:

Here's a full example that shows a message every 30-50 seconds:
Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;
import java.util.List;

public class IntervalUtilExample implements EveryFrameCombatPlugin
{
    // Used to have an event occur every 30-50 seconds
    // The 'target' interval will be randomly chosen between these two
    // numbers every time the IntervalUtil starts a new interval
    private final IntervalUtil exampleInterval = new IntervalUtil(30f, 50f);
    private CombatEngineAPI engine;
    
    @Override
    public void advance(float amount, List events)
    {
        // Advances the IntervalUtil by much time has passed since last frame
        exampleInterval.advance(amount);
        
        // Checks if the IntervalUtil has hit its target - will only be true for a single frame
        // Check this EVERY time you call advance(), otherwise you can miss elapsed events
        if (exampleInterval.intervalElapsed())
        {
            // Show a message every 30-50 seconds
            engine.addFloatingText(engine.getViewport().getCenter(),
                    "Interval elapsed!", 50f, Color.CYAN,
                    null, 0f, 0f);
            
            // After the interval has elapsed, IntervalUtil will automatically reset
            // and choose a new random target in the range you provided
            // You can change the IntevalUtil's target range using the following:
            //exampleInterval.setInterval(20f, 60f);
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
    }
}

There are a few other methods you can mess with once you've got the basics down, but that's all you really need to know. The full source for IntervalUtil is included in starfarer.api.zip in starsector-core. It's in com/fs/starfarer/api/util/IntervalUtil.java. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 08, 2014, 09:55:20 PM
Thanks LazyWizard! That makes much more sense now.

The Starsector API has become such an impressive behemoth now now it's almost overwhelming trying to digest it all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 08, 2014, 11:54:49 PM
Cheers, Sundog
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 10, 2014, 02:47:42 AM
Hi everyone!

I'm working on some new weapons and I thought and acid spray would be very cool.
Now what I think that weapon would need a script thet makes it deal damage over time.
I really have no idea how to do that.
I'm pretty sure I can make it look like a spray by using multible projectiles shot in a burst with some spread but how would I make it deal damage for a set amount of time, a few seconds, after the initial hit and only if it hit the hull of the target?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 10, 2014, 04:50:29 AM
@Tecrys

I'll have a quick crack at it before I go to bed, I've been having no joy with my other coding project. One small victory would be nice for today.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 10, 2014, 07:00:16 PM
How do I change the pivot point of my turrets? Currently, it's about where the barrels meet the body of the turret, which puts them off-center when they turn.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 10, 2014, 07:05:57 PM
The pivot point is determined by the center of the sprite XY.  To change that, you need to move the turret base and barrels upwards / downwards / sideways and also change your barrel points.

You can have turrets that are offset from the center, in the sense that, visually, they appear to be offset, but the center of the sprite is always used as the pivot point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 10, 2014, 07:08:44 PM
About weapon center: for turrets, yeah, it's the center of the sprite. For hardpoint weapons, iirc it's the center of the bottom half of the sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 10, 2014, 07:10:13 PM
So it's  Y * 0.75?  OK.  Didn't know that, but I don't worry about hardpoint sprites :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 10, 2014, 07:29:06 PM
Thanks! I added transparent dead space to the end of my turrets, and now they fit properly!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 10, 2014, 09:34:38 PM
@Arumac: It took me some time to get around to it, but I made an example of a weapon that disables shields.
Shield Disabling Example Weapon (https://www.dropbox.com/s/fxdql17f8ij4yf5/ExampleShieldDissable.zip)
Please ignore all the times I wrote 'dissable' instead of disable. It's probably not very close to the type of weapon you're actually trying to make, but hopefully it shows what you need to know. I didn't comment it excessively, so if you have questions about how it works feel free to ask.

@Tecrys: You might find this example useful for making your acid spray weapon as well, as it deals with duration-based on-hit effects too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 11, 2014, 01:28:09 AM
Indded!

That sounds like a cool effect to add to the pincer claws, like that they will rip through everything.
Do you mind if I try that code for BGE or do you intend on using that script yourself?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 11, 2014, 02:43:11 PM
Please feel free Tecrys.

Unless otherwise noted, any code I write is implicitly covered by the DWTFYWWI License.
Note for anyone reading this; don't google that license unless you're comfortable with profanity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 11, 2014, 02:45:29 PM
Thanks!

PS: I think I don't have to google that xD
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: derpy on February 14, 2014, 11:05:16 AM
hello there. i'm writing a custom missile ai, and i want to get source ship's stats, EccmChance and MissileGuidance in particular.
Code
	public MissileAI(MissileAPI missile, ShipAPI source) {
this.missile = missile;
//source = missile.getSource();
this.source = source;
ECCMstat = source.getMutableStats().getEccmChance().getModifiedValue(); // always 0?
GiudanceStat = source.getMutableStats().getMissileGuidance().getModifiedValue(); // always 0?
the problem is it's always 0.0, both of them. even getBaseValue() returns 0.0 all the time. i've even tried rewriting EccmPackage (hullmod), overriding applyEffectsAfterShipCreation instead of applyEffectsBeforeShipCreation. any help? what am i doing wrong?


hint for those who wants their custom missile ai to home on flares:
Spoiler
implement GuidedMissileAI (along with MissileAIPlugin).
i haven't tested it yet, but i believe it works.
Code
package com.fs.starfarer.api.combat;

public interface GuidedMissileAI {
CombatEntityAPI getTarget();

/**
* Missile should switch to following target if this method is called.
* Called as a result of flares causing distractions and such.
* @param target
*/
void setTarget(CombatEntityAPI target);
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: InfinitySquared on February 14, 2014, 11:59:08 AM
Is it possible to make a teleport-style shipsystem that uses the hyperspace point rings as a visual effect? Also, is there a way to force the game to reload its files while its still running? I'd like to see my system change as I'm editing it.

Last one for now: Have shipsystems with passive 'always on' effects been done already?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 15, 2014, 08:24:47 AM
Is it possible to make decorative lights that fade in and out, without having umpteen billion frames?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on February 15, 2014, 08:46:43 AM
have multiple light sprites with different lighting on them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 15, 2014, 10:31:31 AM
Is it possible to make a teleport-style shipsystem that uses the hyperspace point rings as a visual effect? Also, is there a way to force the game to reload its files while its still running? I'd like to see my system change as I'm editing it.

Not possible, the combat engine doesn't have a way to render that effect.

Is it possible to make decorative lights that fade in and out, without having umpteen billion frames?

You can use AnimationAPI.setAlphaMult() from a script attached to that decorative weapon. That'll set the transparency of the animation, which is pretty much what you want. You probably also want to use WeaponAPI.getSprite().setAdditiveBlend() to make it glowy as opposed to just transparent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: InfinitySquared on February 15, 2014, 10:36:19 AM
Is it possible to make a teleport-style shipsystem that uses the hyperspace point rings as a visual effect? Also, is there a way to force the game to reload its files while its still running? I'd like to see my system change as I'm editing it.

Not possible, the combat engine doesn't have a way to render that effect.

Is it possible to make decorative lights that fade in and out, without having umpteen billion frames?

You can use AnimationAPI.setAlphaMult() from a script attached to that decorative weapon. That'll set the transparency of the animation, which is pretty much what you want. You probably also want to use WeaponAPI.getSprite().setAdditiveBlend() to make it glowy as opposed to just transparent.

Aww... Would be cool though. Thanks, Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 15, 2014, 12:25:35 PM
Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 16, 2014, 07:14:13 AM
Hi again!

I have that Repulsion beam from Exigency (used with permission) and I changed it already to pull instead of push enemy ships.
I've got some problems with it and I just can't get it to feel right.
My idea to make it feel better is to pull the ship that fires the beam instead of the ship that is hit by the beam but I can't figure out how to do that.

Here's the code:

Code
public class exigency_RepulsionBeamEffect implements BeamEffectPlugin
{
    private IntervalUtil tracker = new IntervalUtil(0.1f, 0.2f);
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        tracker.advance(amount);
       
        CombatEntityAPI target = beam.getDamageTarget();
        //Do we have a valid Entity to effect?
        if (target != null)
        {
            //Yes!  Is it in range, and the beam's on?
            if (beam.getBrightness() >= 1f)
            {
                if(tracker.intervalElapsed())
                {
                    float force = 0f;
                    Vector2f dir;

                    if(target instanceof ShipAPI)
                    {
                        ShipAPI ship = (ShipAPI) target;
                        ShipSystemAPI cloak = ship.getPhaseCloak();
                        if (cloak != null && cloak.isActive())
                        {
                                return;
                        }

                        if(ship != beam.getSource())
                        {
                            force = 32 - (ship.getMass() /135);

                            dir = (Vector2f) MathUtils.getDirectionalVector(ship, beam.getSource()).scale(force);
                            Vector2f.add(ship.getVelocity(), dir, ship.getVelocity());
                        }
                    }
                    else
                    {
                        if(target != beam.getSource())
                        {
                            force = Math.max(1 / target.getMass() * 15000f, 0.01f);
                            dir = (Vector2f) MathUtils.getDirectionalVector(beam.getSource(), target).scale(force);
                            Vector2f.add(target.getVelocity(), dir, target.getVelocity());     
                        }
                    }
                }
            }
        }
    }
}

Any ideas?

Edit: Nevermind, figured it out, finally. Now that feels a lot better. Gonna be in my next update!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 16, 2014, 09:06:26 AM
The main thing you need to do to get that to work is replace ship/target with beam.getSource() on lines 48 and 57. You also need to re-swap the two on line 47 (and maybe 56?). Are you aware that this still pushes asteroids? Is that your intention?

That will do what you want, but it has a side-effect I didn't anticipate. Using my modifications will cause both ships to go hurling through space in the direction of the target ship. They'll even keep going past the edge of the map  :D
I have no idea why that doesn't happen the other way around.

You might just want to move the target and the ship toward each other. The physics of this is more realistic anyway. Conservation of momentum and all that.

Try this:
Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;

public class exigency_RepulsionBeamEffect implements BeamEffectPlugin
{
    static final float FORCE_MULTIPLIER = 1000.0f;
    IntervalUtil tracker = new IntervalUtil(0.1f, 0.2f);
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        tracker.advance(amount);
       
        CombatEntityAPI target = beam.getDamageTarget();
        ShipAPI ship = beam.getSource();

        if(target == null || !tracker.intervalElapsed()) return;

        Vector2f from = beam.getFrom();
        float force = FORCE_MULTIPLIER * beam.getBrightness();
        Vector2f direction = MathUtils.getDirectionalVector(from, beam.getTo());

        // Move ship toward target
        CombatUtils.applyForce(ship, direction, force);

        // Move target toward ship
        direction.scale(-1);
        CombatUtils.applyForce(target, direction, force);
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 16, 2014, 10:31:04 AM
Thanks!

... but I figured it out already.
Moving both ships is out of question because I actually wanted to eliminate having tons of ship masses which I need to balance this script around but instead I have only the masses of my ships I need to take into account.

I know that this is "physiks" defying but it works much better as a game mechanic, if that makes any sense.

But I might have a different use for that script you sent ...

Edit: Yes it is intended to push asteroids and missiles. The beam using this script is a PD weapon and I wouldn't want to charge right into those.
Since this beam is meant to be a tentacle it makes sense as well: grab and charge enemies, throw other stuff at enemies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DarkAlbino on February 17, 2014, 06:28:58 AM
Does anyone know how you can tell engines (when building your own ship) only to ignite when the aux thrusters are activated?
I searched everywhere but can't find a thing, i also looked into the ship files, no indicator where the difference might be hidden.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 17, 2014, 07:01:46 AM
What auxiliary thrusters do you mean?
Do you actually mean the burn drive?
If yes then have a look at the dominator ship, it has thrusters that only activate when burn drive is activated.
I hope that might help you.

Edit: While I am at it, does anyone know what kind of damage colliding ships suffer or how it is calculated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DarkAlbino on February 17, 2014, 07:55:13 AM
Ah, I meant the maneuvering jets. Mixed that up.
For example the eagle, only when the jets are activated, the engines at the sides show an exhaust trail.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 17, 2014, 08:12:56 AM
Edit: While I am at it, does anyone know what kind of damage colliding ships suffer or how it is calculated?
Collision damage is implemented as kinetic projectile damage.

@DarkAlbino: No idea. I'd like to know how to set that up as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 17, 2014, 08:17:22 AM
Does anyone know how you can tell engines (when building your own ship) only to ignite when the aux thrusters are activated?
I searched everywhere but can't find a thing, i also looked into the ship files, no indicator where the difference might be hidden.

You need to set the engine's "contrailSize" property to 128 (source (http://fractalsoftworks.com/forum/index.php?topic=3140.msg56958#msg56958)).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 17, 2014, 08:42:41 AM
Thanks LazyWizard. That's a very 'creative use of an existing, unused field for binary flags'  :)

Are there any other secret values like that we should know about?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 17, 2014, 08:51:23 AM
Edit: While I am at it, does anyone know what kind of damage colliding ships suffer or how it is calculated?
Collision damage is implemented as kinetic projectile damage.

Thanks for that, that knowledge should make it much easier to balance my stuff because my ships constantly ram others which should hurt the enemy more than my own ships.
I will set up a nice resistance to kinetic damage in the base hull mod for my faction, maybe adjust the hull points downwards after that to compensate and voila, we have a better balance for BGE.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 17, 2014, 08:57:25 AM
Hi there! I was wondering if there was any way to access weapons stats like flux/s outside of the combat layer. Given a variant, ShipVariantAPI.getWeaponSpec(hull_Slot_Id) can fetch me a bunch of stats for the weapon in a given slot, but very few (getAmmoPerSecond, OrdinancePoints).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2014, 09:21:37 AM
I don't think so - nothing that immediately comes to mind. Well, aside from actually loading the csv using Global.getSettings().loadCSV and then figuring out what's what from there... but that's no fun.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 17, 2014, 09:25:27 AM
I don't think so - nothing that immediately comes to mind. Well, aside from actually loading the csv using Global.getSettings().loadCSV and then figuring out what's what from there... but that's no fun.

Damn! Is there any way to get general stats like total flux/s fro weapons, as showed when building a variant inside the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2014, 09:38:50 AM
There's WeaponAPI.getDerivedStats() - but you need a ShipAPI to get to that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 17, 2014, 09:52:57 AM
So I guess that's something you can fetch in battle only.. Too bad, I'll see what else I can do. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 17, 2014, 03:28:01 PM
Is there any way (hacky or otherwise) to arbitrarily add a new StatusData display item* during combat?

*By this I mean the things on the left of the screen that give you information such as zero flux boost, venting time left, and bonuses from objectives or ship systems.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 17, 2014, 03:32:00 PM
Yes, have a look at this script:

Code
@Override


public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel)
{
           
//Declares two objects of type ShipAPI. 'ship' is just a generic holder for ships that are cycled through. 'host_ship' is the ship that is using the system.
           
ShipAPI ship;
           
ShipAPI host_ship = (ShipAPI) stats.getEntity();
           
           
for (Iterator iter = Global.getCombatEngine().getShips().iterator(); iter.hasNext();)
           
{
               
ship = (ShipAPI) iter.next();
//Loads the current ship the iterator is on into 'ship'

if (ship.isHulk()) continue;
//We don't want to bother modifying stats of the ship if it's disabled.
               
if (ship == host_ship) continue; //Doesn't let the host ship receive the benefits it's giving to others.  Probably redundant.


//If the ship is on the same team as the host ship, and it's within range, and its a fighter...

if ((host_ship.getOwner() != ship.getOwner()) && (MathUtils.getDistance(ship, host_ship) <= (RANGE))) 
{


//Modify this ship's stats.

ship.getMutableStats().getAutofireAimAccuracy().modifyPercent(id, ACCURACY_BONUS);

ship.getMutableStats().getBallisticWeaponRangeBonus().modifyPercent(id, RANGE_BONUS);

ship.getMutableStats().getEnergyWeaponRangeBonus().modifyPercent(id, RANGE_BONUS);


//Adds the ship to the hashmap, and associates it with the host ship.

jamming.put(ship, host_ship);
                System.out.println();

               
//If the ship isn't in range but is contained in the hashmap, and the host ship of the ship is indeed this one...

}
else if ((jamming.containsKey(ship)) && (jamming.get(ship) == host_ship))
{


//removes all benefits

ship.getMutableStats().getAutofireAimAccuracy().unmodify(id);

ship.getMutableStats().getBallisticWeaponRangeBonus().unmodify(id);

ship.getMutableStats().getEnergyWeaponRangeBonus().unmodify(id);


//Removes the ship from the hashmap.
jamming.remove(ship);

}       
            }
        }   
       
       
@Override
public void unapply(MutableShipStatsAPI stats, String id)
{


//Removes the effects from the host ship.

stats.getMaxSpeed().unmodify(id);

stats.getMaxTurnRate().unmodify(id);

stats.getTurnAcceleration().unmodify(id);

stats.getAcceleration().unmodify(id);

stats.getDeceleration().unmodify(id);


//same objects as before.

ShipAPI ship;

ShipAPI host_ship  = (ShipAPI) stats.getEntity();

System.out.println();

//Loops through all the ships in the hashmap.
           
for (Iterator iter = jamming.keySet().iterator(); iter.hasNext();)
           
{
               
ship = (ShipAPI) iter.next();


//If the ship in the hash map is receiving benefits from this host ship (which is currently powering-down its system):

//(This makes it so that one host ship bringing down its system doesn't remove benefits that are being applied to other ships by host ships elsewhere.

if (jamming.get(ship) == host_ship) {


//removes all benefits

ship.getMutableStats().getAutofireAimAccuracy().unmodify(id);

ship.getMutableStats().getBallisticWeaponRangeBonus().unmodify(id);

ship.getMutableStats().getEnergyWeaponRangeBonus().unmodify(id);


ship.getMutableStats().getMaxSpeed().unmodify(id);

ship.getMutableStats().getAcceleration().unmodify(id);

}
            }
}

       
@Override

public StatusData getStatusData(int index, State state, float effectLevel)
{


if (index == 0)
{

return new StatusData("wide spectrum jamming active", false);

}
return null;
}
}

In the last line it does what you want to do I think. (Sorry I have to do it this way I'm just a code basher)

Edit: Is there a way to change the damage decals for a faction? So let's say by using prefixes or so?

Has nobody got an idea how that would work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 18, 2014, 02:38:15 PM
Thanks Tecrys. While the code you posted does what I want, it doesn't do it when I want. That code will only show the status data while the system is active. I'd like to be able to show a status display item pretty much whenever I want. That's what I meant by arbitrarily. I guess I should have been more clear about that.

I don't know if there's a way to use custom faction damage decals.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 18, 2014, 03:03:43 PM
Sorry tat wasn't of much use to you.
LazyWizard had a nice idea for the damage textures: excessive use of ship sized decorative weapons.
That hides the normal textures which is good enough, I can still add damage effects via a plugin that generates effects based on damage percent of the hull, although I am not entirely sure how to do that but I think I can figure it out somehow.
If I can't I will get back to you, Debido or LazyWizard.
Without you guys BGE would still be only in my imagination.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nanao-kun on February 18, 2014, 08:19:40 PM
How exactly do you add portraits to the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 19, 2014, 05:12:10 AM
Hi everyone!

I've written a little script which modifies some stats when used and heals the ship using the system. Now I want to make the duration of that buff independant from the system.csv data.
To explain further: The system is used by right click so it replaces the phase cloak. As soon as the system is active projectile collision is being ignored and enemies fire right threw my ship.
To address that issue I want to give the system a very short active time (only a small fraction of a second) to avoid this phase cloak effect but I want to keep the stat increase for 3 seconds.

Can I give the script a built-in duration so that it is active even it's defined activation time is much shorter?

Here's my script:
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;

public class adrenaline_rush implements ShipSystemStatsScript {

public static final float RES_BONUS = 50f;
        public static final float HOT_BONUS = 3.5f;

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {


stats.getEmpDamageTakenMult().modifyPercent(id, RES_BONUS);
                stats.getHighExplosiveDamageTakenMult().modifyPercent(id, RES_BONUS);
                stats.getKineticDamageTakenMult().modifyPercent(id, RES_BONUS);
                stats.getEnergyDamageTakenMult().modifyPercent(id, RES_BONUS);
                stats.getFragmentationDamageTakenMult().modifyPercent(id, RES_BONUS);
                stats.getHullCombatRepairRatePercentPerSecond().modifyFlat(id, HOT_BONUS);
stats.getCombatEngineRepairTimeMult().modifyMult(id, 1f - RES_BONUS * 0.01f);
                stats.getCombatWeaponRepairTimeMult().modifyMult(id, 1f - RES_BONUS * 0.01f);



}
public void unapply(MutableShipStatsAPI stats, String id) {
stats.getEmpDamageTakenMult().unmodify(id);
stats.getHighExplosiveDamageTakenMult().unmodify(id);
stats.getKineticDamageTakenMult().unmodify(id);
stats.getEnergyDamageTakenMult().unmodify(id);
stats.getHullCombatRepairRatePercentPerSecond().unmodify(id);
stats.getCombatEngineRepairTimeMult().unmodify(id);
stats.getCombatWeaponRepairTimeMult().unmodify(id);
stats.getFragmentationDamageTakenMult().unmodify(id);

}
public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 1) {
return new StatusData("thickened armor, regeneration", false);
}

return null;
}
}

It's just an edited ammofeed script bacause I am bad at coding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on February 19, 2014, 09:31:45 AM
How exactly do you add portraits to the game?

There are 'portrait' graphics files located in the /modname/graphics/portraits/. directory.

Each one will not be read in by the game unless it is referenced in the respective .faction file. Find these in the /modname/data/world/factions/. folder.

Open up an existing .faction file for pointers, once you know where to look it's really pretty straightforward.

If you want to add in player portraits, set up a player.faction in your mod with your portraits included.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 19, 2014, 12:14:44 PM
I have a question about custom engines. Looking at the High tech engines, they're blue, with a white core. I copied the high tech code, and made magenta engines - but they have no white core. It's just solid magenta. How do I add the core?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nanao-kun on February 19, 2014, 12:21:40 PM
How exactly do you add portraits to the game?

There are 'portrait' graphics files located in the /modname/graphics/portraits/. directory.

Each one will not be read in by the game unless it is referenced in the respective .faction file. Find these in the /modname/data/world/factions/. folder.

Open up an existing .faction file for pointers, once you know where to look it's really pretty straightforward.

If you want to add in player portraits, set up a player.faction in your mod with your portraits included.
So there's no way to add in independent portraits for me to just fool around with by myself?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on February 19, 2014, 12:33:06 PM
Nanao-kun: sorry, can you elaborate? If you mean by just editing the core files - yes you CAN do this without setting up a mod. It's just a bit messy, prone to go wrong, make sure you back up files etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nanao-kun on February 19, 2014, 01:37:36 PM
Nanao-kun: sorry, can you elaborate? If you mean by just editing the core files - yes you CAN do this without setting up a mod. It's just a bit messy, prone to go wrong, make sure you back up files etc.
I mean being able to add portraits without having to make it part of a faction. Editing the core files is one way I guess. I'll backup my files and try that.

EDIT: Oh, it works! A non-core editing way would probably be better, since I'd need to edit it whenever a new Starsector version comes out/if I need to reinstall it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 19, 2014, 01:45:11 PM
Would it be possible to make a system only active while it is charging down?

I have a stat mod script that should only activate at the time it is powering down and otherwise unapply those stats.

If anyone would know how to do that and maybe provide an example of such a stat mod system I would be very thankful!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 19, 2014, 02:25:27 PM
I have a question about custom engines. Looking at the High tech engines, they're blue, with a white core. I copied the high tech code, and made magenta engines - but they have no white core. It's just solid magenta. How do I add the core?

That white core is a result of additive blending. I'm guessing your magenta is something like (255, 0, 100)? Try dividing each of those values by two and adding 128, but not exceeding 255 (i.e. 100/2+128=178). If you want to understand why it works that way just google additive blending.

Edit: Editing right now... I guess I accidentally submitted somehow?

@Tecrys: There are good reasons you don't see crazy systems bound to right click all over the place. There are several issues and limitations that need to be overcome in order to hack a phase cloak into any ship system you want.
-The system can only be active while the phase cloak is active. Workaround: Use an EveryFrameCombatScript to apply the desired effects whenever you want.
-The collision class of the ship is changed to that of a phased-out ship while the system is active. Workaround: Use a very short system duration or use ((ShipAPI)stats.getEntity()).setCollisionClass(CollisionClass.SHIP); in the advance method to manually reset the collision class.
-The cooldown/warmup bar you can normally see for a ship system isn't visible. Workaround: Some other form of visual feedback.
-The defensive system will always be called a phase cloak in it's description. I don't know of any workaround.
-The AI will always think of it as a phase cloak, both while deciding whether or not to activate it or whether or not to shoot at another ship with this system active. Workaround: Complete AI overhaul. This means that even if you do reset the collision class of a ship that's using this system other ships still won't shoot it.

If anyone sees any mistakes in anything I said above please correct me.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 19, 2014, 02:30:00 PM
Okay, thanks for making that clear.


That line of code seems to fix my issues, am I correct?
Now where do I need to put that line of code? Right at the bginning of the statsscript?

Big thanks, that boggled my mind the whole day, got a headache trying to figure that stuff out.
Drove me almost crazy ...

Edit: Okay, I can't really do any of those from scratch. The EveryFrame Effect seems to be the best way for the stuff I want to do but I think I will give up on that and implement my changed damage stuff instead.
I wish I could code ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 19, 2014, 02:43:43 PM
Eh, we're not quite out of the woods yet Tecrys. Please reread my complete answer (I accidentally submitted it early)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 19, 2014, 03:03:35 PM
But I can still set the duration extremely short and make an instant self heal out of it.
I guess that has to be sufficient.

As I said, I can't write any of the stuff you mentioned from scratch but that self heal is good enough then.

Thanks very much I guess I can sleep now at least.

Edit: Ha! Now I understand why you asked about that arbitrary statedata the other day!
Everything makes sence now ...

There's one good thing about implementing that "clipped" version of the right click system, though:
I can get a lot more hp bar movement on my ships, which should make them more unique, so even if I can't get all that "hardened armor" effect implemented I can still reduce the base resistances by quite a bit and make it a nice little short cooldown self heal.

I am satisfied and happy again after a really bad day.

A little addition: I played around with that stuff a lot today and I think you can use a system defined as a defence system in the ship.csv to make the ship use a custom ship AI. You just need to set the AIType to CUSTOM and set up the systemAIscript accordingly. I tested that only very breefly with an AI that uses the system every time possible so it is always on. Correct me if I am wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 20, 2014, 02:25:25 AM
Can somebody help me please to write an EveryFrameCombat Plugin which checks if a system is being activated and modifies stats for a set duration?
Okay, I got the heal Effect working again, I have no idea why it wasn't working. Maybe it wasn't because I didn't set up a charge up/charge down time for the system.
back to balancing.

Edit: I've played around a bit more and it is actually really easy to make the STAT_MOD Effect active while the system is powering down just as I wanted it to be. Instead of setting the cooldown to 4 seconds I set the charge down to 4 seconds and multiplied all mutable stats with the effect level. Now all stats that are being modified gradually reduce themselves depending on the percentage of the charge down of the system granting a smooth hp regeneration and resistance increase.
So in other words it is more or less possible to make the system active only while powering down. That solves all my problems after 2 days of intense headaches.

No help needed anymore, consider my problems with the right click mechanic solved.

Thanks eeveryone for helping out with this!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 21, 2014, 03:01:58 AM
Hi everyone, it's me again.

I've got this little little script by Dark Revenant which I use to make the blood effects for BGE and I think it draws quite a bit of performance (at least I think my fps is dropping).

How can I make that script less performance heavy?

Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponSize;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.lwjgl.util.vector.Vector2f;

public class WeaponDamageSmoke implements EveryFrameCombatPlugin
{

    private CombatEngineAPI engine;
    private static Map mag = new HashMap();
    static
    {
        mag.put(WeaponSize.SMALL, 1f);
        mag.put(WeaponSize.MEDIUM, 1.5f);
        mag.put(WeaponSize.LARGE, 2.5f);
    }

    private float smokeSize = 0.5f + 0.1f * (float)Math.random();

    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
    }

    private IntervalUtil interval = new IntervalUtil(0.1f, 1f);

    public void advance(float amount, List events)
    {
        if (engine.isPaused()) return;

interval.advance(amount);

        if (interval.intervalElapsed())
        {
            smokeSize = 0.5f + 0.1f * (float)Math.random();
            List ships = engine.getShips();
            Iterator it = ships.iterator();
            while (it.hasNext())
            {
                ShipAPI ship = (ShipAPI) it.next();     
                List weapons = ship.getAllWeapons();
                Iterator it2 = weapons.iterator();
               
                while (it2.hasNext())
                {
                    WeaponAPI weapon = (WeaponAPI) it2.next();
                    if (!ship.getVariant().getHullMods().contains("BGECarapace")) return;
                    if(  weapon.isDisabled() || ship.isHulk() )
                    {
                        float smokeSizeValue = (Float)mag.get(weapon.getSize());

                        float velX = (float)Math.random() * 10f - 5f;
                        float velY = (float)Math.sqrt(25f - velX * velX);
                        if((float)Math.random() >= 0.5f)
                        {
                            velY = -velY;
                        }
                       
                        engine.addSmokeParticle(weapon.getLocation(), new Vector2f(velX,velY), 40f * this.smokeSize * smokeSizeValue, 0.05f, 4f, new Color(200,0,0,200));
                        engine.addSmokeParticle(weapon.getLocation(), new Vector2f(velX,velY), 20f * this.smokeSize * smokeSizeValue, 0.05f, 3f, new Color(200,0,0,200));
                    }
                }
            }
        }
    }

@Override
    public boolean isDone()
    {
return false;
    }

    @Override
    public boolean runWhilePaused()
    {
        return false;
    }


}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on February 21, 2014, 06:34:43 AM
Can you use custom sprites for space stations?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 21, 2014, 07:27:55 AM
As far as I know you can do that but it will change all stations.

Someone asked that before in the modding section before I think.

You might have to search for it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2014, 11:11:12 AM
Can you use custom sprites for space stations?

Custom sprites per station will be possible in the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 21, 2014, 11:19:38 AM
Can you use custom sprites for space stations?

Custom sprites per station will be possible in the next release.

That's fantastic news!

Gonna make a custom station for BGE next week. Looking forward to it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 21, 2014, 07:46:29 PM
@Tecrys: You should be able to reduce the number of particles created by that script by increasing the 0.1f on this line:
private IntervalUtil interval = new IntervalUtil(0.1f, 1f);


My turn:
What exactly dictates overload times?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2014, 07:53:47 PM
What exactly dictates overload times?

There's a base time, with capital ships and fighters having the longest, and frigates the shortest. There's also a component based on the "extra" damage that forced the overload. So, an overload from a beam will be shortest, while eating a Reaper torpedo can result in a very lengthy overload. The total overload time is capped to 15 seconds, regardless of the ship size.

(Before you ask - none of this is directly moddable, and I wasn't really planning to tinker with it :) If you wanted to, though, you could probably manage it w/ FluxTrackerAPI/stop/startOverload.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 21, 2014, 08:07:26 PM
Ah, thanks Alex  :)

I don't actually want to change anything about it at all, just calculate what it would be for AI purposes. For example, I made a weapon that deals a lot of burst kinetic damage but also forces the firing ship to overload. I'm working on autofire AI for this weapon and I'd like to be able to find out whether or not it's advantageous to force both ships to overload by comparing the overload times. So... I can has maths? (If it won't take too long to explain of course)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2014, 08:16:40 PM
Ah, alright.

Base time: 10s (capital, fighter), 8s (cruiser), 6s (destroyer), 4s (frigate).

+1s per every 25 points of flux the ship would have gone over the maximum due to the hit.

Capped at 15s total.


(The weapon idea sounds cool, btw, but man, I don't know how the default AI is going to deal with that.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 21, 2014, 08:22:31 PM
Alex, my debt to you grows by the day. Many thanks  :D

(The weapon idea sounds cool, btw, but man, I don't know how the default AI is going to deal with that.)
Heh, not very well... but I think I can get it to work okay with the nifty AutofireAIPlugin you gave us.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2014, 08:29:42 PM
Alex, my debt to you grows by the day. Many thanks  :D

Oh, pshhh. The way I see it, it's the other way around - I owe you (and other modders) for contributing so much to the community and in general making awesome things for everyone to enjoy. It still blows me away that so many talented people choose Starsector as a platform for expressing their creativity. So, thank you for that; and I'll do what I can to make the game as modding-friendly as I reasonably can.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 21, 2014, 09:53:25 PM
Well, shucks. You shouldn't be surprised. It's a good platform. I see where you're coming from though. Symbiosis.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 22, 2014, 01:49:52 AM
Thanks for answering my question!

That got me a good 15 to 20 fps more now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on February 22, 2014, 05:43:46 AM
So, I have encountered some problems while tinkering with my mod.

1. I just cant manage to implement my own sound effects, and I get the following type of errors.
Spoiler
Quote
ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.L] with id [skt_fire_01] not found
java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.L] with id [skt_fire_01] not found
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.oOOO.J.<init>(Unknown Source)
   at com.fs.starfarer.loading.specs.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.loading.specs.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.coreui.refit.A.ÔOÒ000(Unknown Source)
   at com.fs.starfarer.coreui.refit.A.class(Unknown Source)
   at com.fs.starfarer.coreui.refit.OoOO.o00000(Unknown Source)
   at com.fs.starfarer.coreui.refit.private.Öo0000(Unknown Source)
   at com.fs.starfarer.coreui.refit.private.OÓÓ000(Unknown Source)
   at com.fs.starfarer.coreui.refit.A.o00000(Unknown Source)
   at com.fs.starfarer.coreui.refit.A.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.K.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.I.dismiss(Unknown Source)
   at com.fs.starfarer.coreui.refit.WeaponPickerDialog.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.O00oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.ui.F.processInput(Unknown Source)
   at com.fs.starfarer.ui.O00oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.floatsuper$Oo.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.p.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.p.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.floatsuper.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.p.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.p.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.p.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.p.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.D.int.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.p.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.p.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.K.processInputImpl(Unknown Source)
   at com.fs.starfarer.coreui.refit.WeaponPickerDialog.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.p.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.p.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.K.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.O0OO.if.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.p.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.p.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.K.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.O0OO.interface.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.ui.p.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.p.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInput(Unknown Source)
   at com.fs.starfarer.campaign.A.o00000(Unknown Source)
   at com.fs.starfarer.B.ØÓÒ000(Unknown Source)
   at com.fs.oOOO.A.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

2. Is there any way to attach the tachyon lance beam effect as an "on hit" effect for projectiles?

3. How do you decide where the projectile and muzzle flash should spawn from when you make your own gun?

Any help with this would be greatly appreciated :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 22, 2014, 06:16:01 AM
You have to make a sound config file to make use of custom sounds. Have a look at starsector core/cofig to het an example of such a file.

To use the tachyon lance effect with projectiles you will need to make it a projectile onhiteffect. In vanilla its implemented as a beamonhiteffect.

Weaponturretoffset and weaponhardpointoffset are used to change the point from where the weapon spits out its projectiles/beams, that is also how to change the position of the muzzle flash animation or glow animation.

I hope that might help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on February 22, 2014, 02:31:26 PM
Zudgemud
I assume your issue judging from the fact it cannot find the apparent effects is that you have not set up a sound in the sound.json. This is located in data/config.
Here is an example with this.

   "skt_fire":{
      "sounds":[
         {"file":"sounds/fx/guns/skt_fire_01.ogg","pitch":1,"volume":0.82},
         {"file":"sounds/fx/guns/skt_fire_01.ogg","pitch":0.95,"volume":0.82},
         {"file":"sounds/fx/guns/skt_fire_01.ogg","pitch":0.90,"volume":0.82},
      ],
   },
}
This is assuming your sound is in fx/guns you can change this path if you want.
This is a standalone one as well if you want to continue it then just copy paste after the red bracket
In this case, does the three different versions vary in pitch and volume settings simply so that every round fired sound a bit different (varying between the three I would assume)?

Other than that detail, it was exactly what I wanted to know, thanks!


To use the tachyon lance effect with projectiles you will need to make it a projectile onhiteffect. In vanilla its implemented as a beamonhiteffect.
I'll try to poke around with it a bit more, but I basically tried to do this earlier.


Weaponturretoffset and weaponhardpointoffset are used to change the point from where the weapon spits out its projectiles/beams, that is also how to change the position of the muzzle flash animation or glow animation.
Awesome, just what I wanted to know, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 22, 2014, 03:05:52 PM
Quote
In this case, does the three different versions vary in pitch and volume settings simply so that every round fired sound a bit different (varying between the three I would assume)?
It will pick one of those three settings; it's not defining a random range, no.  If you want a lot of variation, you need to either use more sounds or have more lines there, like I did with the Millenium Gun's sound effect in Vacuum (which sounds pretty close to the original source in-game).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on February 22, 2014, 03:36:58 PM
Perfect, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 24, 2014, 12:10:26 PM
How do I get built-in weapons to glow when firing? They're part of the ship sprite, not their own weapon sprite. Do I have to seperate them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 24, 2014, 12:44:35 PM
How do I get built-in weapons to glow when firing? They're part of the ship sprite, not their own weapon sprite. Do I have to seperate them?

They are actually not part of the ship sprite, they work exactly the same as any other weapon.

The only difference is the mount. You can make a built in hidden or you can make it appear as usual.

So just treat them like any other weapon.

Edit: I think I misunderstood your post a bit.

Yes, Iw ould highly recommend to make them seperate sprites. If you need a good example of an in-built weapon take a look at the Onslaught.

Just reverse engineer the way it was done with that ship and it will be fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xalendi on February 24, 2014, 12:53:00 PM
Ok, so when I'm drawing my ship, leave off the gun barrels and add them later as a weapon? Thanks for the help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 24, 2014, 12:59:14 PM
I would rather leave an ampty space or a mount and do the whole gun seperate including turret and gun barrels.

That way you could make different built-in waepons easy to swap or easily updated if you would ever do a new sprite of the gun.

Also built-in weapons tend to be hardpoint mounted like on the Onslaught.

You can make the barrels move as well, there is an option for that in the weapon file, "visual recoil" and "alternating" or "linked".

Just take a look at the built-in weapons file and graphics from that Onslaught and you will get what I am trying to say.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on February 24, 2014, 03:22:22 PM
Is there any way to use AIUtils.getNearbyEnemyMissiles  (and projectiles as well) to locate entities within a 100 degree arc in front of the ship as well as within a limited range?

Basically, I want the AI to use a system when it detects enemy missiles and projectiles within 600 units, and a 100 degree arc of the front of the ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 24, 2014, 03:26:38 PM
Yes, I am pretty sure that stuff has been done before.

I think Exigency uses an AI like that for the Repulsor, Blackrock as well I think.

Maybe you want to take a look at some AIs used in Xenoargh's Vacuum, he's got some crazy stuff there as well.

Hope that might help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 24, 2014, 06:40:45 PM
I think Exigency uses an AI like that for the Repulsor.

Don't use the one from the old 0.58d version that is still available for download, everything in it is vastly out of date. While it may appear I am dead that is in fact not the case, just working on an absolutely massive update...

Here is the AI to which you are referring but with a lot of improvements made to it.


Edit: The script had a bug fixed and some logic improvements ;)

Code
package data.shipsystems.scripts;

import java.util.List;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.CollectionUtils;
import org.lazywizard.lazylib.CollectionUtils.CollectionFilter;
import org.lazywizard.lazylib.CollisionUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lazywizard.lazylib.combat.CombatUtils;

public class exigency_RepulsorAI implements ShipSystemAIScript
{
    private static final float SECONDS_TO_LOOK_AHEAD = 3f;
    private ShipAPI ship;
    private final IntervalUtil tracker = new IntervalUtil(0.35f, 0.6f);
    private final CollectionFilter filterMisses = new CollectionFilter()
    {
        @Override
        public boolean accept(Object t)
        {
            DamagingProjectileAPI proj = (DamagingProjectileAPI) t;

            // Exclude missiles and our own side's shots
            if (proj instanceof MissileAPI || proj.getOwner() == ship.getOwner())
            {
                return false;
            }

            // Only include shots that are on a collision path with us
            // Also ensure they aren't travelling AWAY from us ;)
            return (CollisionUtils.getCollides(proj.getLocation(),
                    Vector2f.add(proj.getLocation(),
                    (Vector2f) new Vector2f(proj.getVelocity())
                    .scale(SECONDS_TO_LOOK_AHEAD), null),
                    ship.getLocation(), ship.getCollisionRadius())
                    && Math.abs(MathUtils.getShortestRotation(proj.getFacing(),
                    VectorUtils.getAngle(proj.getLocation(),
                    ship.getLocation()))) <= 90f);
        }
    };

    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine)
    {
        this.ship = ship;
    }

    @SuppressWarnings("unchecked")
    @Override
    public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target)
    {
        tracker.advance(amount);
        Vector2f shipLoc = ship.getLocation();

        if (tracker.intervalElapsed())
        {
            // Can we even use the system right now?
            if (!AIUtils.canUseSystemThisFrame(ship))
            {
                return;
            }

            boolean shouldUseSystem = false;
            float repulseRadius = Math.max(ship.getCollisionRadius(), 100f);
            repulseRadius *= 3f;

            List nearbyThreats = CombatUtils.getProjectilesWithinRange(shipLoc, repulseRadius);//Use this to try and defend against weapons fire.
            nearbyThreats = CollectionUtils.filter(nearbyThreats, filterMisses);
            nearbyThreats.addAll(AIUtils.getNearbyEnemyMissiles(ship, repulseRadius));
            if (!nearbyThreats.isEmpty())
            {
                shouldUseSystem = true;
            }

            // If system is inactive and should be active, enable it
            // If system is active and shouldn't be, disable it
            if (ship.getSystem().isActive() ^ shouldUseSystem)
            {
                ship.useSystem();
            }
        }
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 25, 2014, 07:42:07 AM
Hi again!

I've tried to make a campaig integration of Biomancy but I am getting a weird error. I used the files from Blackroch Driveyards and simply modified them because I am not able to write scripts from scratch.

It is done exactly the same as in Blackrock (Gonna change planets and names and so on before I upload, I just wanted to test it before I change the layout and style of the star system) including the variant

randomizer and sovereign spawn point, i simply swapped everything with my stuff.

Why can't the script be cast? I don't understand this ...

Here's the stack pointing to the error:

Code
738628 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.ClassCastException: data.scripts.world.Himmel.BGEGen cannot be cast to com.fs.starfarer.api.campaign.SectorGeneratorPlugin
java.lang.ClassCastException: data.scripts.world.Himmel.BGEGen cannot be cast to com.fs.starfarer.api.campaign.SectorGeneratorPlugin
at com.fs.starfarer.loading.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.K.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.I.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.O00oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.ui.F.processInput(Unknown Source)
at com.fs.starfarer.ui.newsuper.super(Unknown Source)
at com.fs.starfarer.B.ØÓÒ000(Unknown Source)
at com.fs.oOOO.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

If somebody has an idea why that happens I would be very thankfull!

Edit: I triple checked every row of code in all files related to this by now and I still have no idea what I did wrong. I really need some help with this please.
If somebody could tell me what could cause such an error would be very helpful, I have no idea where to look really. Better said, I looked everywhere already ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on February 25, 2014, 12:03:20 PM
Yes, I am pretty sure that stuff has been done before.

I think Exigency uses an AI like that for the Repulsor, Blackrock as well I think.

Maybe you want to take a look at some AIs used in Xenoargh's Vacuum, he's got some crazy stuff there as well.

Hope that might help.

Yea, that's were I started looking as well, I'd basically need to modify those to get it to add another variable. Both range from the shop, and if the ship is facing the projectiles or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 25, 2014, 02:53:05 PM
@Tecrys: I'm not sure what's causing that exception. For some reason Starsector is trying to use your BGEGen as something it isn't, which it doesn't do in the case of Blackrock's BRGen. My guess is that you added something somewhere telling Starsector that BGEGen is a SectorGeneratorPlugin, which it isn't. You might find this (https://www.dropbox.com/s/02145xsa7dzoxoc/Example%20System.zip) bare-bones example system useful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 25, 2014, 03:53:03 PM
I didn't add anything, just renamed a few things according to my faction and the files used like the spawn points.

Okay, I thought it was the variant picker and I removed it and changed everything back but it wasn't that one. Good to know, so I can put that back, handy little thing.

Thanks for the help, I will try to use that template instead, still not sure what I've done wrong.

PS: Producing weird bugs seems to become a hobby of mine ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 27, 2014, 01:49:05 AM
Little question:

Is there a way to make a hull mod change the size of weapon slots?

It's easy to get the weapons by size but changing the size is not in weaponAPI.

Would it be possible to make the mod swap the hull with another?

Because in that case I could make a different hull with all weapon slots one size bigger.

Or could you make it so that an EveryFrameScript makes large weapons applicable to medium slots if the hullmod is installed? (If yes then I will need someone to do that script, such stuff is beyond my coding skills)

In the end it doesn't matter how it is done, the question is if it's possible at all and how.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on February 27, 2014, 08:31:01 AM
Can you make beamweapons bypass shields?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 27, 2014, 04:49:46 PM
I'm not in front of a proper computer right now, but I'd have a look at the Exigency sabot cannon. It is a projectile but it is able to pass through. Either way I'm sure there are means and ways. I believe it's also possible to de-activate the shield if you look at some of. The recent posts in this thread.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 27, 2014, 05:17:25 PM
Quote
Can you make beamweapons bypass shields?
Yes and no; that's a bit too broad of a question.  I presume we're talking stuff like the High Intensity Laser here, rather than "beam bolt" weapons, which can definitely go through shields with a bit of trickery.

Can you get a beamweapon to keep projecting past a shield impact and hit the ship sprite?  No, that's hardcoded behavior.  Nor are we allowed to create beams at arbitrary points in space pointing at arbitrary angles, so we can't fake that visually atm without a lot of hackery.

Can you get a beamweapon to cause damage to a ship even if it's hitting a shield?  Yes, you can, by searching for the ArmorGrid location nearest to the shield impact and damaging it while doing something cute graphically like throwing sparks or whatnot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 27, 2014, 05:21:27 PM
I'm not in front of a proper computer right now, but I'd have a look at the Exigency sabot cannon. It is a projectile but it is able to pass through.

Just to be clear, it has that behavior in Vacuum. Not in the vanilla balanced standalone the update of which I am still working on.

Though they do have other shield piercing weapons in the standalone...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 27, 2014, 05:27:36 PM
Only in Vacuum? Can't say I've played with Exigency much outside of Vacuum.

Another thing you could do is see if you can modify the shield to flicker. I was doing some experimentation with shields that turn off and on rapidly. If you get the vary the flickering to the right frequency range projectiles are stopped almost entirely and beams get through a large portion of the time and do damage.

So you could have it such that partial damage gets through whilst the shield is under duress from your beam, and full damage when the shield is off.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 27, 2014, 05:34:18 PM
Not many have, no worries the patch will fix that.

Your idea for making the shield flicker so some of the beam bleeds through is pretty damn cool 8)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 27, 2014, 06:26:48 PM
Well one day when I can get around to spriting up my own faction I wanted the shields to be unique, so I investigated a modulating shield that spends more 'active' time at the front where most of the damage comes through and less 'active' at the rear where the engines are. More or less I wanted a complete 360 shield but not the inefficiency that comes with it. The compromise is that there is still a chance of projectile and beam damage toward the mid and rear of the ship, but low enough chance that it is still effective.

I think the last one I tried was something like
1/6 of the time it is off
1/6 of the time it is at 60 degrees
1/6 of the time it is at 180 degrees
1/6 of the time it is at 360 degrees
1/6 of the time again at 60
1/6 of the time at 360

Or some variation, I tried a few different permutations and found that is stopped most all damage at the front, but some damage (not all) got to the engines. And anyway I'd rather take partial damage, or stop that heat seaking missile/torpedo ruining my day over no protection at all.

I haven't done comprehensive testing against all incoming weapons to find the sweet spot for the best on/off ratio or shield coverage. It needs some more testing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 27, 2014, 08:27:23 PM
Is there a way to make a hull mod change the size of weapon slots?
I think you're probably out of luck for this one Tecrys. There might be a way, but I wouldn't put money on it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 28, 2014, 04:13:23 AM
Is there a way to make a hull mod change the size of weapon slots?
I think you're probably out of luck for this one Tecrys. There might be a way, but I wouldn't put money on it.

I have found a way of actually doing it, but it is a little clunky to say the least. I would set up all hulls with extra weapon slots which are one size bigger than the ones I actually want to change.

Now I make sure all slots are named the same way on each ship and using the base hullmod of BGE I simply reduce the range of those named weapon slots to zero.

As soon as the hullmod enlarging the weapon slots is installed I swap the range with the original slots. I hope you get what I am trying to say, it is weird to describe.

It kinda activates and deactivates certain weapon slots although they would still be equippable in the refit screen whcih is a problem.

Now to not overload the ship with medium and large weapons I would make an EveryFrame script that scans for weapons with a range of zero and make those invisible on the sprite and removes them from weapon groups.

I think that's a way of making it work but I am not able to code that. Also it would involve explaining how it works in the hullmod description which would break immersion severly.

Just my thoughts on that, thought I should share it.

Another Thought to make it much simpler: the hullmod just changes damage, flux and OP values to emulate a larger slot weapon. Now I iterate through the weapon slots affected (namely medium slots) and simply

enlarge the sprite used by idk 50% or so.

Would that be possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 28, 2014, 01:35:35 PM
I think your second idea might work. I'm not sure you can directly change the OP values of weapons, but I think you can dictate the OP cost of the hullmod based on the ship's weapon slots. I don't know if the increase in weapon size would show up in the fitting screen either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on February 28, 2014, 01:56:38 PM
Sure you can change the OP cost, skills do it so modders can do it too.

Code
package data.characters.skills.scripts;

import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;

public class OrdnanceExpertPerk2 implements CharacterStatsSkillEffect {

public void apply(MutableCharacterStatsAPI stats, String id, float level) {
stats.getSmallWeaponOPCost().modifyFlat(id, -SkillData.ORDNANCE_EXPERT_PERK_OP_REDUCTION_SMALL);
stats.getMediumWeaponOPCost().modifyFlat(id, -SkillData.ORDNANCE_EXPERT_PERK_OP_REDUCTION_MEDIUM);
stats.getLargeWeaponOPCost().modifyFlat(id, -SkillData.ORDNANCE_EXPERT_PERK_OP_REDUCTION_LARGE);
}

public void unapply(MutableCharacterStatsAPI stats, String id) {
stats.getSmallWeaponOPCost().unmodify(id);
stats.getMediumWeaponOPCost().unmodify(id);
stats.getLargeWeaponOPCost().unmodify(id);
}

public String getEffectDescription(float level) {
String s = "";
s += (int)SkillData.ORDNANCE_EXPERT_PERK_OP_REDUCTION_SMALL + "/" +
(int)SkillData.ORDNANCE_EXPERT_PERK_OP_REDUCTION_MEDIUM + "/" +
(int)SkillData.ORDNANCE_EXPERT_PERK_OP_REDUCTION_LARGE;
s += " ordnance point cost reduction for small/medium/large weapons";
return s;
}

public String getEffectPerLevelDescription() {
return null;
}

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

}

See?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 28, 2014, 05:22:47 PM
Yep, I thought you might bring up ordnance expert. The catch is that that script modifies OP cost via a MutableCharacterStatsAPI (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/characters/MutableCharacterStatsAPI.html) rather than a MutableShipStatsAPI (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/MutableShipStatsAPI.html), which is what you use for hullmods and doesn't have the necessary get[Size]WeaponOPCost methods. Furthermore, that script applies the OP reduction to all ships in the fleet, not to a specific ship.

I'm pretty sure this is something Alex conscientiously decided to exclude. There would be a lot of awkward complications involved in any hullmod that fiddles with the OP cost of weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 01, 2014, 12:47:03 AM
Ah, I didn't pay attention to the details.

You're right then, I will make the hullmod cost some op.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 01, 2014, 04:13:54 AM
Quote
Can you make beamweapons bypass shields?
Yes and no; that's a bit too broad of a question.  I presume we're talking stuff like the High Intensity Laser here, rather than "beam bolt" weapons, which can definitely go through shields with a bit of trickery.

Can you get a beamweapon to keep projecting past a shield impact and hit the ship sprite?  No, that's hardcoded behavior.  Nor are we allowed to create beams at arbitrary points in space pointing at arbitrary angles, so we can't fake that visually atm without a lot of hackery.

Can you get a beamweapon to cause damage to a ship even if it's hitting a shield?  Yes, you can, by searching for the ArmorGrid location nearest to the shield impact and damaging it while doing something cute graphically like throwing sparks or whatnot.


Well, the basic idea I have is a weapon that just totally disables a ship, nothing else. The background is that I have made a fat capital ship lacking offensive armament but which has a massive cannon/laser that should disable anything it aims at, I was planning to use the tachyonlance effect but I dont really know how to convert that to a projectile impact effect, so I thought I could make a laser that goes through the shield.

One alternative that I thought of is that it might be possible to somehow give the weapon a massive sheild damage effect to overload whatever it aims at but with a useless armor/hull dps (for example 1 dps base damage with a 1000000x multiplier against sheilds). Though this is not exactly what I intended as this also strips all sheildtanking ships of their defence, I want the targeted ships to become incapacitated and harmless, but preferably not lacking sheilds.

So, do you know which would be the easiest one to make, and would your "armor grid" version be able to apply the appropriate on hit effects (for example by applying EMP damage instead of normal damage)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 01, 2014, 04:23:26 AM
Um, I played a little against your faction and most of your weapons already have that disabling effect.

And that to a very high extend btw. Fighting your faction usually leaves about half my fleet temporarily disabled.

To be honest I wouldn't do more of those disabling effects, it's a pain in the ass constantly being unable to fight back against your ships.

Otherwise have a look a few pages back or take a look at BGE, there is a script which disables shields for ships hit by the projectile.

I am trying to be helpful in two ways here:
- Giving you some advice on balance
- trying to give you a solution to your atual problem.

No offense intended, just feedback.

I hope that might help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 01, 2014, 04:57:48 AM
Um, I played a little against your faction and most of your weapons already have that disabling effect.

And that to a very high extend btw. Fighting your faction usually leaves about half my fleet temporarily disabled.

To be honest I wouldn't do more of those disabling effects, it's a pain in the ass constantly being unable to fight back against your ships.

Otherwise have a look a few pages back or take a look at BGE, there is a script which disables shields for ships hit by the projectile.

I am trying to be helpful in two ways here:
- Giving you some advice on balance
- trying to give you a solution to your atual problem.

No offense intended, just feedback.

I hope that might help.

Yeah I'm trying to get away from the EMP spam effects and the ridiculous speed for all ships thing, I'm planning to limit the EMP arch effect to the fighter, while the 3 ships that have it atm are getting other ship systems or variants of it that do not have the prolonged emp effect, the t2 destroyer is probably losing it for some type of flare, the RS frigate will get maybe just one more powerful spark instead of 8 and the mite I haven't decided on yet but I want it to have some support role, possibly a pointdefence kind of thing. The current idea that I have for the faction is a few really fast ships with extreme stats with a mix of more "normal" ships to perform support duties.

This new capital ship I made is supposed to be harmless without other fragile DPS ships to actually kill what it disables.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 03, 2014, 06:29:24 AM
So, i was making the spreadsheet for one of my ship when i started to think about the Range.
I've once read somewhere that these are currently unused, but the fact that most (or all) ships in the vanilla SS has these fields filled in, i am curious if whether this field is important or will it affect the gameplay in some way when filled with different numbers (or just left empty).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on March 03, 2014, 09:07:59 AM
So, i was making the spreadsheet for one of my ship when i started to think about the Range.
I've once read somewhere that these are currently unused, but the fact that most (or all) ships in the vanilla SS has these fields filled in, i am curious if whether this field is important or will it affect the gameplay in some way when filled with different numbers (or just left empty).

I believe if you check the calculation of fuel capacity vs. fuel/lightyear, you will get the range (for vanilla ships at least). Likely filled in just as a balance checker allowing quick comparison in the CSV sheet itself, but at present it doesn't seem to be used.

At least, inputting arbitrary values for my mods do not seem to affect things - It's just fuel capacity and fuel consumption that matter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 04, 2014, 01:06:14 AM
Oh, okay then thanks.
At first i thought it will be used in the future for how far that enemy fleets will start going after you. Like the Max Burn it will stop chasing after it goes beyond the lowest range in that fleet (or maybe the highest range).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 05, 2014, 12:35:32 AM
Is there a way to find out whether or not a weapon group is currently set to autofire?

Edit: Also - is there a way to find out which group a weapon is assigned to?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2014, 11:54:52 AM
Is there a way to find out whether or not a weapon group is currently set to autofire?

Edit: Also - is there a way to find out which group a weapon is assigned to?

I don't think so. Seems like a bit of a problem - wonder how xenoargh is getting around that in his ship AI. Added to my list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 05, 2014, 04:50:34 PM
Are you talking about the context of the AI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 05, 2014, 05:58:43 PM
Many thanks Alex.
After a quick glance at one of Vacuum's ShipAIPlugins it looks like all weapons are initially set to autofire and the autofire AI handles everything. I almost certainly missed something though. Wouldn't surprise me if xenoargh came up with some brilliant workaround.

Speaking of brilliant workarounds - I had some trouble finding out whether or not a ship was using my custom AI (it switches back and forth to and from the default AI). I couldn't think of a good way to track it manually and (ship.getShipAI() instanceof MyAI) didn't work because getShipAI returns a wrapper (thanks for the warning). Eventually I did something that made me feel very dirty; I made needsRefit return true as a flag for my AI. Not sure if there should be (or already is) a better solution for getting that information.

@xenoarph: If you're out there somewhere - any tips for me?

@Debido: Yep. Ship AI. It's the kind of thing I'd expect to be accessible through a ShipAPI though, so that might be the more relevant context.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 05, 2014, 06:24:20 PM
I just set all the weapons on autofire, all Variants are on Autofire, and I let the weapons, not the ships, decide whether they're allowed to shoot.  It's easier to do it that way; weapons can detect if the ship they're targeting has shields up or if the ship they're attached to doesn't have enough free Flux to fire right now, etc. and that way lets you make very customized solutions for weapons with special problems, if that's necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 05, 2014, 07:00:01 PM
Ah, thank you sir. Unfortunately I'd have to do a lot more work to get that working in this case (namely implementing a comprehensive ShipAIPlugin). By the way, if I ever do decide to create a full ship AI, is it okay with you if I steal code from your AI work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 05, 2014, 11:09:51 PM
Feel free; the only reason why they aren't in the Code Dump is because then I'd have to do a proper write-up about how to set up the implementation and they're not fully polished yet, performance-wise :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2014, 11:17:23 PM
Speaking of brilliant workarounds - I had some trouble finding out whether or not a ship was using my custom AI (it switches back and forth to and from the default AI). I couldn't think of a good way to track it manually and (ship.getShipAI() instanceof MyAI) didn't work because getShipAI returns a wrapper (thanks for the warning). Eventually I did something that made me feel very dirty; I made needsRefit return true as a flag for my AI. Not sure if there should be (or already is) a better solution for getting that information.

Hmm. The wrapper will change when the AI changes, maybe that's enough to keep track? I.E. if you know getShipAI() started returning a different value, then the AI changed. Alternatively, your custom AI could set some global to say "I controlled this ship this frame" (which would then be reset every frame?). But hey, regardless of how dirty it is, the needsRefit() thing works! The less dirty workarounds are more of a hassle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 06, 2014, 12:32:44 PM
I didn't even think about keeping a reference to the wrapper. I like that solution better. I agree about dirtier workarounds generally being less hassle, but they always seem to make me go a little more insane (plus they occasionally  cause a lot of grief down the road)

@xenoargh: Awesome. Many thanks  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 14, 2014, 05:25:42 AM
Is there an article in this forum that tells how to mod a weapon?
There is a lot that i don't know in weapon modding, especially what offsets mean  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 14, 2014, 10:04:31 AM
I think there is a guide on weapon modding somewhere ...

Offsets are used to tell the game where the gun is shooting from.

Can missiles be animated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 14, 2014, 10:07:00 AM
Missiles cannot be animated iirc. So no, difficult to recreate sparkly photon torpedoes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on March 14, 2014, 10:22:08 AM
How about making the missile as a fighter instead? Vacuum use a weapon that launch fighters. Give the fighter a suicide point blank bomb and it's like a missile, with animation on top of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 14, 2014, 10:37:50 AM
Uh, that's even better!

I didn't know that was possible, I'll have a look at Vacuum on how that is done.

If that weapon spits out real fighters there would be some cool possibilities if one gives those fighters a system to use as well.

Unlimited possibilities for some really uniwue weapon systems ...

Can't wait till I am finished at work!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 14, 2014, 10:47:02 AM
Except then you'd need to have a custom AI for it, and a custom detonation script, take into account shields and have your own damage application. It's possible, that said there should already be a suggestion thread for it somewhere...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 14, 2014, 11:06:05 AM
For reference

...

Well - animated projectiles aren't supported by the engine, and it's not something I could just hack in easily. About the only way I'd really give it a go is if something new in the base game required it; adding features for mod-use-only tends to be a pretty big pain because it's hard to adequately test them and ensure they keep working going forward.
...

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 15, 2014, 08:18:57 AM
I had a look at Vacuum for the fighter spawning gun, it's not real fighters it spawns, it is a missile, though heavily modded.

Is it possible to let a gun spawn fighters/drones? I somehow got hooked on that idea now ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 17, 2014, 01:33:33 AM
It's a "missile" that lasts for one game-frame and then gets converted into a Frigate (can't use a Fighter because of CR not working correctly for Wings with only one Fighter in them, grr).  See SpecialShotBehaviors.java.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 17, 2014, 02:45:17 AM
Ah, I see.

I guess I missed that because of the very complex way it is set up.

Then it's exactly what I need, thank you.

Would you mind if I try to reverse engineer that?

Edit: I had a look at it, looks easier than I thought it would be to spawn a ship in battle. Cool stuff. Now onwards to building that parasite launcher ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 17, 2014, 11:53:05 AM
Yeah, it just looks really complicated, because of all the other stuff in that class, anyhow, feel free... but... er... be aware that that's one of the many features that requires Vacuum to remain a TC, because Vanilla's FleetInteractionDialog code is not happy with spawned things and goes all crashy-crashy if they're eligible for capture; there is probably another solution to that issue but bear it in mind :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 20, 2014, 12:44:29 AM
The weapon offsets coordinates, is it taken from the center of the sprite?
And is the coordinates taken when the sprite is facing upward or facing to the right (like how ships are presented it the ship editor)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nanao-kun on March 22, 2014, 05:50:06 PM
So I was trying to merge Starsector+ and Exerelin into one mod for myself so I wouldn't have to bother with keeping both an edited and unedited copy of them, but I can't seem to get it to work.

I can't test if it works or not because it doesn't show up in the mod selection. Checking the starsector log, I find this:
Code
23   [main] INFO  com.fs.starfarer.launcher.ModManager  - Error loading mod from [..\mods\Exerelin Plus]
24   [main] INFO  com.fs.starfarer.launcher.ModManager  - Expected a ',' or ']' at 571 [character 5 line 20]
org.json.JSONException: Expected a ',' or ']' at 571 [character 5 line 20]
at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
at org.json.JSONArray.<init>(JSONArray.java:143)
at org.json.JSONTokener.nextValue(JSONTokener.java:356)
at org.json.JSONObject.<init>(JSONObject.java:210)
at org.json.JSONObject.<init>(JSONObject.java:311)
at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.super(Unknown Source)
at com.fs.starfarer.launcher.ModManager.super(Unknown Source)
at com.fs.starfarer.launcher.ModManager$1.accept(Unknown Source)
at java.io.File.listFiles(Unknown Source)
at com.fs.starfarer.launcher.ModManager.void(Unknown Source)
at com.fs.starfarer.launcher.ModManager.<init>(Unknown Source)
at com.fs.starfarer.launcher.ModManager.String(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
It seems to be a syntax error or something?

EDIT: Scratch that, I found the syntax error. I didn't think that the comma was missing from the end of line 18 considering the blank space between line 18 and 20.

EDIT: And now I have this error:
Code
18142 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
at org.json.JSONObject.get(JSONObject.java:406)
at org.json.JSONObject.getString(JSONObject.java:577)
at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.new(Unknown Source)
at com.fs.starfarer.loading.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.oOOO.A.?00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
From what I've looked up, it has to do with the CSV files or something. I don't know how to check if my CSV files is corrupted or not. They all open fine, and nothing appears to be wrong with them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 22, 2014, 09:32:33 PM
@Lcu

From my knowledge, yes the offsets are taken from the center of the sprite. - on left and right axis stands for left, while no - stands for right, on the up and down axis - stands for back while no - stands for up. If you want your sprite to be on a certain point you would need to add more size to your sprite towards the back or front to move the center.
Kinda like this
(http://i.imgur.com/FaRTXax.png)

If that doesnt make sense then this should
(up) 15, (left) -2.5
(down) -15, (right) 2.5

The coordinates are taken from the weapon when it is facing up.

This is assuming your using data editing like I am, if your using a weapon editor or something then I have no idea.

Yes this is what i was looking for. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on March 23, 2014, 01:57:44 AM
I have absolutely no idea what the "8/6/5/4%" column is (in the ship_data.csv file). Anyone want to help me out?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on March 23, 2014, 02:29:29 AM
Kazi, that is an unused column that does nothing and is safe to leave blank.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 23, 2014, 03:44:42 AM
Kazi, that is an unused column that does nothing and is safe to leave blank.
But will it be used in future versions? I'm afraid later when it was used we gotta go back to the ship_data and edit all of those values, especially for bigger mods (like the Project Ironclads).

Okay so I have a few questions:
1. How do you add Built In weapons in the ship editor?
2. Can you make the built in weapons Hidden?

Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 23, 2014, 06:28:31 AM
You can designate the slot in the ship editor. Mouse over the weapon slot you want to make a hidden built-in weapon and use the arrow keys to choose the right option.
That also means you can make any weapon a hidden built in, it is not a weapon property but a slot property.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on March 23, 2014, 10:26:41 AM
what changed since v61a for this code to stop working?
evrything seems to be functioning except for " proj.getVelocity().set(accel); " wich does not work

Code: java
            for (Iterator iter = engine.getProjectiles().iterator(); iter.hasNext();)
            {
                proj = (DamagingProjectileAPI) iter.next();
                spec = proj.getProjectileSpecId();

                if(PROJ_IDS.contains(spec))
                {
                    Vector2f projvel = proj.getVelocity();
                    Vector2f accel = multV2f(projvel, 2);     //how much faster (every time timer cycles)
                    engine.addFloatingText(proj.getLocation(), "accel=" + accel.x + "   orig=" + projvel.x, 20f, Color.RED, proj.getSource(), 1f, 0f);
                    proj.getVelocity().set(accel);
                    //addFloatingText(Vector2f loc, String text, float size, Color color, CombatEntityAPI attachedTo, float flashFrequency, float flashDuration);
                    //testing

                    //damage needs to be done through a onhiteffect
                }
            }
        }

*edit*
full code:
Spoiler
Code: java
package data.scripts.plugins;


import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lwjgl.util.vector.Vector2f;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.awt.Color;

public class SpecialShotBehaviors implements EveryFrameCombatPlugin
{
    //projectile ids
    private static final Set PROJ_IDS = new HashSet();

    // Add all projectiles that should do X
    static
    {
        PROJ_IDS.add("BR1_p");
    }


    private CombatEngineAPI engine=Global.getCombatEngine();
    //clocks, how often x happens
    //private IntervalUtil slowtracker = new IntervalUtil(1f, 1.5f);
    //private IntervalUtil tracker = new IntervalUtil(0.15f, 0.4f);
    //private IntervalUtil fastTracker = new IntervalUtil(0.1f, 0.15f);
    private IntervalUtil veryFastTracker = new IntervalUtil(0.05f, 0.1f);
    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }
        //moving the clocks forward
        //slowtracker.advance(amount);
        //tracker.advance(amount);
        //fastTracker.advance(amount);
        veryFastTracker.advance(amount);


        DamagingProjectileAPI proj;
        //CombatEntityAPI entity;
        String spec;
        //bullet accelerator
        if(veryFastTracker.intervalElapsed())
        {

            for (Iterator iter = engine.getProjectiles().iterator(); iter.hasNext();)
            {
                proj = (DamagingProjectileAPI) iter.next();
                spec = proj.getProjectileSpecId();

                if(PROJ_IDS.contains(spec))
                {
                    Vector2f projvel = proj.getVelocity();
                    Vector2f accel = multV2f(projvel, 2);     //how much faster (every time timer cycles)
                    engine.addFloatingText(proj.getLocation(), "accel=" + accel.x + "   orig=" + projvel.x, 20f, Color.RED, proj.getSource(), 1f, 0f);
                    projvel.set(accel);
                    //addFloatingText(Vector2f loc, String text, float size, Color color, CombatEntityAPI attachedTo, float flashFrequency, float flashDuration);
                    //testing

                    //damage needs to be done through a onhiteffect
                }
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
    }


    public static Vector2f multV2f(Vector2f Vector1, float Multiplier)
    {
        float v1x = Vector1.getX()*Multiplier;
        float v1y = Vector1.getY()*Multiplier;
        Vector2f v1end = new Vector2f(v1x, v1y);
        return v1end;
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 12:49:29 PM
Well... huh.  It appears that the Repulsor Beam code is also borked.  It works on ShipAPI objects, but not on MissileAPI objects.  Weird.

Code, to compare with.
Spoiler
Code: java
package data.scripts.weapons;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.util.IntervalUtil;

import org.lazywizard.lazylib.VectorUtils;

public class exigency_RepulsionBeamEffect implements BeamEffectPlugin
{
    private final IntervalUtil tracker = new IntervalUtil(0.1f, 0.2f);
    
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        if(engine.isPaused()) return;
        tracker.advance(amount);
        
        CombatEntityAPI target = beam.getDamageTarget();
        //Do we have a valid Entity to effect?
        if (target != null && tracker.intervalElapsed() && target.getOwner() != beam.getSource().getOwner())
        {
            float force;
            Vector2f dir;
            
            if(target instanceof ShipAPI)
            {
                ShipAPI ship = (ShipAPI) target;
                ShipSystemAPI cloak = ship.getPhaseCloak();
                if (cloak != null && cloak.isActive())
                {
                        return;
                }

                force = Math.max(1 / ship.getMass() * 10000f, 0.01f);
                
                dir = (Vector2f) VectorUtils.getDirectionalVector(beam.getSource().getLocation(), ship.getLocation());
                dir = new Vector2f (dir.getX() * force, dir.getY() * force);
                Vector2f vel = ship.getVelocity();
                Vector2f.add(vel, dir, vel);

            }
            if(target instanceof MissileAPI)
            {
                MissileAPI targMissile = (MissileAPI) target;
                force = 0.5f;
                dir = VectorUtils.getDirectionalVector(beam.getSource().getLocation(), targMissile.getLocation());
                dir = new Vector2f (dir.getX() * force, dir.getY() * force);
                Vector2f vel = targMissile.getVelocity();
                Vector2f.add(vel, dir, vel);
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 01:07:57 PM
It doesn't appear to work even on MissileAPI objects whose engines have stopped firing, either. 

Alex, are you strictly enforcing MissileAPI velocities engine-side now? 

If yes, then we could model the "deflection" by replacing the projectiles or changing their AngularVelocity, perhaps...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on March 24, 2014, 03:43:55 PM
intrestingly enough this (verry similar to repulsor beam):
Spoiler
Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lwjgl.util.vector.Vector2f;

import java.awt.*;
import java.util.ArrayList;

import static jar.UtilityKit.V2fPerpendicularDisc;
import static jar.UtilityKit.V2fReSize;
import static org.lwjgl.util.vector.Vector2f.add;
import static org.lwjgl.util.vector.Vector2f.sub;


public class Gravotron implements BeamEffectPlugin {

    private IntervalUtil Interval = new IntervalUtil(0.02f, 0.01f);
    float MaxPoint=400;

    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        if (beam.getBrightness() >= .5f) {
            Interval.advance(amount);

            if (Interval.intervalElapsed()) {
                Vector2f from = beam.getFrom();
                Vector2f to = beam.getTo();
                Vector2f dir = sub(to, from, null);
                float Bang = MathUtils.getFacing(dir);

                ArrayList<CombatEntityAPI> PQueries = new ArrayList<CombatEntityAPI>();
                PQueries.addAll(engine.getAsteroids());
                PQueries.addAll(engine.getProjectiles());

                for (CombatEntityAPI query : PQueries)
                {
                    Vector2f QLoc = query.getLocation();
                    float DtoL = V2fDistanceToLine(from, to, QLoc, true);
                    float AbDtoL = Math.abs(DtoL);
                    if (AbDtoL<MaxPoint
                            && (!(query instanceof DamagingProjectileAPI)        //catch for just launched weapons
                            || (((DamagingProjectileAPI) query).getWeapon()!=null
                            && MathUtils.getDistance(((DamagingProjectileAPI) query).getWeapon().getLocation(), QLoc)>40)))
                    {
                        float PSadj = (MaxPoint-AbDtoL)/40;
                        float Sadj = PSadj*PSadj;

                        Vector2f QVel = query.getVelocity();
                        engine.addFloatingText(QLoc, "Av-> "+QVel, 20f, Color.RED, beam.getSource(), 1f, .5f);
                        //towards line
                        Vector2f ToL = V2fPerpendicularDisc(dir, (Sadj < 100 ? Sadj : 100), (DtoL<0? 1:0));

                        //towards end
                        Vector2f ToE = V2fReSize(dir, (Sadj < 100 ? Sadj : 100));

                        //adjust the velocity
                        Vector2f Qre = new Vector2f(QVel.getX()+ToE.getX()/*+ToL.getX()*/,
                                QVel.getY()+ToE.getY()/*+ToL.getY()*/);

                        QVel.set(Qre);
                        query.setFacing(query.getFacing()+((MathUtils.getFacing(Qre)-query.getFacing())/2));

                        /*
                        //collide with everything
                        if (query instanceof DamagingProjectileAPI) {
                            ShipAPI Ne = ((DamagingProjectileAPI) query).getSource();
                            if (Ne!=null && MathUtils.getDistance(Ne,query.getLocation())>10) {
                                query.setCollisionClass(CollisionClass.HITS_SHIPS_AND_ASTEROIDS);}}
                        */


                        //engine.addHitParticle(QLoc, ToE, 30f, .5f, 1, new Color(235, 157, 43,120));
                    }

                }

                //sparkly beam
                while (Math.random()>.3)
                {
                    Vector2f AdjDir = V2fReSize(dir, (float) (Math.hypot(dir.getX(), dir.getY())*Math.random()));
                    Vector2f Adj2Dir = V2fPerpendicularDisc(dir, (float)(30*Math.random()), .5f);
                    Vector2f RX = add(add(from,Adj2Dir,null), AdjDir, null);
                    engine.addHitParticle(RX, V2fReSize(dir,50), 30f, .5f, 1, new Color(40, 136, 235,120));
                }
            }
        }
    }

    private static double[] V2ftoArray(Vector2f point)
    {
        double[] array = new double[2];
        array[0] = point.getX();
        array[1] = point.getY();
        return array;
    }

    private static Vector2f  ArraytoV2f(double[] point)
    {
        return new Vector2f((float)point[0],(float)point[1]);
    }

    private static double DotProduct(double[] pointA, double[] pointB, double[] pointC)
    {
        double[] AB = new double[2];
        double[] BC = new double[2];
        AB[0] = pointB[0] - pointA[0];
        AB[1] = pointB[1] - pointA[1];
        BC[0] = pointC[0] - pointB[0];
        BC[1] = pointC[1] - pointB[1];
        double dot = AB[0] * BC[0] + AB[1] * BC[1];
        return dot;
    }

    private static double CrossProduct(double[] pointA, double[] pointB, double[] pointC)
    {
        double[] AB = new double[2];
        double[] AC = new double[2];
        AB[0] = pointB[0] - pointA[0];
        AB[1] = pointB[1] - pointA[1];
        AC[0] = pointC[0] - pointA[0];
        AC[1] = pointC[1] - pointA[1];
        double cross = AB[0] * AC[1] - AB[1] * AC[0];
        return cross;
    }
    //Compute the distance from A to B
    private static double ToLineDistance(double[] pointA, double[] pointB)
    {
        double d1 = pointA[0] - pointB[0];
        double d2 = pointA[1] - pointB[1];
        return Math.sqrt(d1 * d1 + d2 * d2);
    }

    private static double[] ToLineVector(double[] pointA, double[] pointB)
    {
        double[] ABC = new double[2];
        ABC[0] = pointA[0] - pointB[0];
        ABC[1] = pointA[1] - pointB[1];
        return ABC;
    }

    //Compute the distance from AB to C
    //if isSegment is true, AB is a segment, not a line.
    private static double LineToPointDistance2D(double[] pointA, double[] pointB, double[] pointC, boolean isSegment)
    {
        double dist = CrossProduct(pointA, pointB, pointC) / ToLineDistance(pointA, pointB);
        if (isSegment)
        {
            double dot1 = DotProduct(pointA, pointB, pointC);
            if (dot1 > 0)
                return ToLineDistance(pointB, pointC);
            double dot2 = DotProduct(pointB, pointA, pointC);
            if (dot2 > 0)
                return ToLineDistance(pointA, pointC);
        }
        return dist;
    }

    public static float V2fDistanceToLine(Vector2f from, Vector2f to, Vector2f point, boolean segment)
    {
        return (float)LineToPointDistance2D(V2ftoArray(from),V2ftoArray(to),V2ftoArray(point), segment);
    }

    // use reverse perpendicular calculation to get vector to line!!!
}

[close]
still works, with is odd... because it also uses velocity.set
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 04:19:48 PM
Perhaps we need to cast the object to the DamagingProjectile class, then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on March 24, 2014, 04:31:20 PM
no it seems to be setting the velocity ok

Spoiler
(http://i.imgur.com/csWAMqi.png?1)
[close]
with code:
Code: java
Vector2f projvel = proj.getVelocity();
                    Vector2f accel = multV2f(projvel, 2);     //how much faster (every time timer cycles)
                    engine.addFloatingText(proj.getLocation(), "accel=" + accel.x + "   orig=" + projvel.x
                            + "                                                                                              ",
                            20f, Color.RED, proj.getSource(), 1f, 0f);
                    projvel.set(accel);
                    engine.addFloatingText(proj.getLocation(), "new=" + projvel.x , 20f, Color.GREEN, proj.getSource(), 1f, 0f);

but the newly set velocity is being imediately reverted back
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 04:40:26 PM
OK, so that is an engine-side thing, then.  Even with Missiles with special AIs, there is nothing in my code that forces velocity (angularVelocity, yes).

But does the working code you showed work on guided missiles?  If yes... then perhaps it's because of how the objects are collected?  Or is it because you re-set the Facing on the same frame, forcing an update?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 04:45:07 PM
Changing the Facing does nothing; casting the MissileAPI to DamagingProjectileAPI does nothing.  Are you absolutely sure it's working on MissileAPI objects?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on March 24, 2014, 05:07:46 PM
yea that code works... no idea why though, by al rights it is identical to previous
Spoiler
(http://i.imgur.com/jSnLsza.png?1)
(http://i.imgur.com/drOMcHy.png?1)

(http://i.imgur.com/QA91ydc.png?1)
when i was testing it with vanilla mirv missiles i found thAt it works on the core mirv missile, but ignored the mirv submunitions wich i found a bit odd...
[close]


this is a conunudrum...
Spoiler
Code: java
package data.scripts.plugins;


import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lwjgl.util.vector.Vector2f;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.awt.Color;

public class SpecialShotBehaviors implements EveryFrameCombatPlugin
{
    //projectile ids
    private static final Set PROJ_IDS = new HashSet();

    // Add all projectiles that should do X
    static
    {
        PROJ_IDS.add("BR1_p");
        PROJ_IDS.add("amblaster_shot");
        PROJ_IDS.add("dualflak_shot");

    }


    private CombatEngineAPI engine=Global.getCombatEngine();
    //clocks, how often x happens
    //private IntervalUtil slowtracker = new IntervalUtil(1f, 1.5f);
    //private IntervalUtil tracker = new IntervalUtil(0.15f, 0.4f);
    //private IntervalUtil fastTracker = new IntervalUtil(0.1f, 0.15f);
    private IntervalUtil veryFastTracker = new IntervalUtil(0.05f, 0.1f);
    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused())
        {
            return;
        }
        //moving the clocks forward
        //slowtracker.advance(amount);
        //tracker.advance(amount);
        //fastTracker.advance(amount);
        veryFastTracker.advance(amount);


        CombatEntityAPI proj;
        DamagingProjectileAPI projB;
        //CombatEntityAPI entity;
        String spec;
        //bullet accelerator
        if(veryFastTracker.intervalElapsed())
        {

            for (Iterator iter = engine.getProjectiles().iterator(); iter.hasNext();)
            {
                proj = (CombatEntityAPI) iter.next();
                projB = (DamagingProjectileAPI) proj;
                spec =  projB.getProjectileSpecId();

                if(PROJ_IDS.contains(spec))
                {
                    Vector2f projvel = proj.getVelocity();
                    Vector2f accel = new Vector2f(multV2f(projvel, .9f));     //how much faster (every time timer cycles)
                    engine.addFloatingText(proj.getLocation(), "accel=" + accel.x + "   orig=" + projvel.x
                            + "                                                                                              ",
                            20f, Color.RED, projB.getSource(), 1f, 0f);
                    projvel.set(accel);
                    engine.addFloatingText(proj.getLocation(), "new=" + projvel.x , 20f, Color.GREEN, projB.getSource(), 1f, 0f);
                    //addFloatingText(Vector2f loc, String text, float size, Color color, CombatEntityAPI attachedTo, float flashFrequency, float flashDuration);
                    //testing

                    //damage needs to be done through a onhiteffect
                }
            }
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
    }


    public static Vector2f multV2f(Vector2f Vector1, float Multiplier)
    {
        float v1x = Vector1.getX()*Multiplier;
        float v1y = Vector1.getY()*Multiplier;
        Vector2f v1end = new Vector2f(v1x, v1y);
        return v1end;
    }
}
[close]
ive tried casting it as CombatEntityAPI: no effect
ive tried using a new Vector2f: no effect
changing numbers: no effect
changing weapon: wtf why moment...

aparently this does work with weapons that use ordinary balistic rounds, and not weapons that use balistic_as_beam
Spoiler
(http://i.imgur.com/8VrjbKm.png?1)
[close]

its moments like these that make we want to scream "WHY CANT YOU KEEP THINGS CONSISTENT IN STARSECTOR CODE!!!"



so conclusions:
1) BeamEffectPlugin are F-ing magic and can ignore certain limits on the more mundane EveryFrameCombatPlugin
2) although the mundane and downright boring EveryFrameCombatPlugin can effect "some" (only basic BALISTIC proj) its not nearly as F-ing magic as BeamEffectPlugin
3) BeamEffectPlugin are F-ing magic
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 05:43:56 PM
But my code's using BeamEffect.  I don't think that's what's going on here :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on March 24, 2014, 05:48:56 PM
Spoiler
(http://stream1.gifsoup.com/view6/2535130/im-not-crazy-o.gif)
[close]
we must poke alex to discover the answer to the Ultimate Question of Life, the Universe, and Everything
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 06:28:04 PM
This works.  It shouldn't, but it does.  Note what state target needs to be in here.

Spoiler
Code: java
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.util.ArrayList;
import java.util.List;
import org.lazywizard.lazylib.MathUtils;

import org.lazywizard.lazylib.VectorUtils;

public class exigency_RepulsionBeamEffect implements BeamEffectPlugin
{
    private final IntervalUtil tracker = new IntervalUtil(0.1f, 0.2f);
   
    private MissileAPI getNearestMissileNearPoint(int owner, Vector2f point)
    {
        List<MissileAPI> enemies = new ArrayList<MissileAPI>();

        for (MissileAPI missile : Global.getCombatEngine().getMissiles())
        {

            if (   
                    missile.getOwner() != owner
                    && MathUtils.isWithinRange(missile,missile,20f)
                )
            {
                enemies.add(missile);
            }
        }
        return enemies.get(0);
    }   
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        if(engine.isPaused()) return;
        tracker.advance(amount);
       
        CombatEntityAPI target = beam.getDamageTarget();
        //Do we have a valid Entity to effect?
        if (target != null && tracker.intervalElapsed() && target.getOwner() != beam.getSource().getOwner())
        {
            float force;
            Vector2f dir;
           
            if(target instanceof ShipAPI)
            {
                ShipAPI ship = (ShipAPI) target;
                ShipSystemAPI cloak = ship.getPhaseCloak();
                if (cloak != null && cloak.isActive())
                return;
            }

            force = Math.max(1 / target.getMass() * 10000f, 0.01f);

            dir = (Vector2f) VectorUtils.getDirectionalVector(beam.getSource().getLocation(), target.getLocation());
            dir = new Vector2f (dir.getX() * force, dir.getY() * force);
            Vector2f vel = target.getVelocity();
            Vector2f.add(vel, dir, vel);
        } else if (tracker.intervalElapsed()){
            MissileAPI missile;
            missile = getNearestMissileNearPoint(beam.getSource().getOwner(),beam.getTo());
            if(missile != null){
                float force;
                Vector2f dir;

                force = Math.max(1 / missile.getMass() * 10000f, 0.01f);

                dir = (Vector2f) VectorUtils.getDirectionalVector(beam.getSource().getLocation(), missile.getLocation());
                dir = new Vector2f (dir.getX() * force, dir.getY() * force);
                Vector2f vel = missile.getVelocity();
                Vector2f.add(vel, dir, vel);
            }
        }
    }
}

[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 24, 2014, 08:14:37 PM
Alex, are you strictly enforcing MissileAPI velocities engine-side now? 

What do you mean by "strictly enforcing"? IIRC just the same 600 pixel/second limit as before, don't recall touching this recently. Just had a look through the codebase; that looks to be the only place where missile speed is set directly, as opposed to applying an acceleration to it.


(Yeah, the whole BALLISTIC vs BALLISTIC_AS_BEAM/BEAM thing is... fun. Legacy from a very early build where BALLISTIC could hit each other, but that didn't work out so well. Don't want to totally refactor it now, though. The main difference currently is in collision detection: BEAM/BALLISTIC_AS_BEAM hit along the entire length, while BALLISTIC hits around the bullet area, not the trail. Which isn't particularly important.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 08:39:16 PM
Ach, sorry for wasting your time; that was early theory-crafting and turned out to be a wrong-headed assumption on my part- I thought that maybe something changed under the hood there, since Dmaiski reported that he was seeing a hit and change to velocity, but it was being immediately "reset", which led me on a bit of a wild goose-chase ::)

What's really going on here is a little weird, though.

We're seeing weird results with beam.getDamageTarget(). 

The last example code I posted last only works correctly when beam.getDamageTarget() is null.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 24, 2014, 08:56:38 PM
Hmm! Do the beams you're testing with have a non-0 "impact" value, by chance? Like the Graviton Beam? If they do, the code that applies this "impact" could be what's undoing whatever velocity changes you're applying.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 08:59:12 PM
<checks>  Nope, it's zero :)

I don't suppose zero isn't quite zero there, as a fudge factor to prevent div-by elsewhere?

Oh, and!

Weird fact:  Beams' beamTo() is at the maximum range or hit range, whichever is greater, instantly.  Produced some weirdness when I wrote some new stuff for the other beam-related stuff this thing exposed.  At the very least, I've gotten a much cleaner re-write of my burst-beam / converge-beam code's interaction with missiles they have not quite hit (mathematically) but appear to have hit, graphically.

Another theory?  Perhaps beam.getDamageTarget() returns null if beam.getBrightness < 1f?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 09:16:04 PM
Aha, it's not instant, but if the beam speed's high enough, it's happening a lot faster than the graphic displays, even if the chargeUp time is zero.

So you can have a beam.getTo() that's way out there and the beam's not even firing yet, visually, but the code runs.  What's weird is that checking beam.getBrightness() doesn't seem to deal with that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 24, 2014, 10:05:26 PM
Weird fact:  Beams' beamTo() is at the maximum range or hit range, whichever is greater, instantly.  Produced some weirdness when I wrote some new stuff for the other beam-related stuff this thing exposed.  At the very least, I've gotten a much cleaner re-write of my burst-beam / converge-beam code's interaction with missiles they have not quite hit (mathematically) but appear to have hit, graphically.
Aha, it's not instant, but if the beam speed's high enough, it's happening a lot faster than the graphic displays, even if the chargeUp time is zero.

So you can have a beam.getTo() that's way out there and the beam's not even firing yet, visually, but the code runs.  What's weird is that checking beam.getBrightness() doesn't seem to deal with that.

That should be fine since if the getTo() is at the target location, then the beam is doing damage and whatever is related to the beam doing damage should also run. I'm not seeing the behavior you're describing, but, right, shouldn't actually matter. And seems unrelated to the issue at hand, right? Which is something setting missile velocity.

Another theory?  Perhaps beam.getDamageTarget() returns null if beam.getBrightness < 1f?

I'm fresh out of ideas, unfortunately. Still kind of liking my impact theory, your statement that the impact is 0 notwithstanding :)

getDamageTarget()'s return value is linked with the beam being shortened by hitting something, one can'tis extremely unlikely to happen without the other.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 10:46:10 PM
Ah, but it can happen if the beam's at maximum range, but only in that case. 

That eliminates a lot of stuff.  There are some other things I need to look at here, in terms of why I'm seeing some strange issues with hits and things, though; I've noticed that Beams seem to miss quite a bit when they really should be hitting, visually.  Perhaps that's just bad values in the collision sizes, though; I'll investigate that.

Not quite sure how to investigate the zero-value impact theory; I tested with a blank in that field value, and it doesn't crash, but until I remove the search for MissileAPIs, I won't know whether it then works.  If it doesn't, then I'm drawing a blank :)

Anyhow, what I've written works, and it's exposed some other weird stuff; it's been a fun diversion from some other stuff this evening :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 24, 2014, 10:59:25 PM
OK, this is part of the puzzle.  Why is this happening?  

Spoiler
(http://www.wolfegames.com/TA_Section/ss_beam_vs_missile.jpg)
[close]

Note the square size; I've made the collision radius 32 here, huge.  No hits.  What's really weird is that it's happening a lot, but not always... so either the real collision radius is teeny, or it's strictly looking for a point collision with a line, where it needs a line collision with a circle.

OK, I see what's up.  It's the PierceSet.  But without the PierceSet... hrmm. 

Will do more testing.

<tests>

Without the PierceSet, I get hits quite consistently, but no change in missile velocity.  That fits the theory that it's related to impact in some way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 25, 2014, 12:29:21 AM
@ Xeno: Why is that happening? Like Dr. Egon Spengler said, don't cross streams!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 25, 2014, 01:00:31 AM
Basically, the PierceSet is allowing it to Pierce, like it should, but without interacting with stuff it pierces, which I guess is the intended behavior.  I'm inclined to remove the PierceSets from everything that doesn't need it; they were put in largely to deal with certain types of FF situations that I don't think apply any more.  But when the Repulsor hits, its still not causing the targets to move, so there's an underlying issue here, probably related to impact; I may try raising the impact values quite a bit and see if it makes them work right in regards to missiles if I have time later this week :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 26, 2014, 03:51:44 AM
Hi guys!

So, I want to make a new system and I want it to scale by the percentage of hp left on the ship using the system and I want it to deal damage continuosly to the ship using it.
Basically I want it to increase damage and fire rate by up to 50% which should be reached at 30% hp left on the ship and it should deal about 2% of total hp damage to the ship each second.
How can I do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on March 26, 2014, 05:22:05 AM
EvryFrameCombatPlugin

intervalUtil timer
if timer.intervalElapsed
{
CombatEngineAPI engine= Global.getCombatEngine();
ArrayList<ShipAPI> active = new ArrayList<ShipAPI>();
for ( ShipAPI query : engine.getShips())
{
if (check for ship system)
{
if (system.isOn)
{
apply damage mod to ship
reduce ship hp by 2%
}
if (system.isOff)
{
remove damage mod
}}}}

bhasicly how you would do it imo
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 26, 2014, 05:35:40 AM
Hm ... okay, I thought it could've been built into the system script itself.
So how do I make the effect scale with the hull level?
Can I just do this for example:
      stats.getBeamWeaponDamageMult().modifyMult(id, 0.5f / getHullLevel());

Basically I want the damage to increase the more the ship is damaged, it is a berserk mode.
Don't mind the numbers too much, they are just an example.

Edit: Nevermind, I managed to do it but it needs some adjustments.
Anyways, I now have a system specifically designed for player use which will absolutely wreck other ships but it has the danger of being instagibbed if the life leech and regeneration ever is too low to sustain all incoming damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 26, 2014, 07:52:41 AM
Okay, here is the code I used:
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;

public class berzerk implements ShipSystemStatsScript {





public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
if (state == ShipSystemStatsScript.State.OUT) {
 // to slow down ship to its regular top speed while powering drive down
stats.getMaxTurnRate().unmodify(id);
} else {
            ShipAPI ship = (ShipAPI)stats.getEntity();

                        ship.setHitpoints(Math.max(1, ship.getHitpoints() - 2));

                stats.getEnergyWeaponDamageMult().modifyPercent(id,  10f / ship.getHullLevel());
                        stats.getBallisticWeaponDamageMult().modifyPercent(id,  10f / ship.getHullLevel());
                        stats.getMissileWeaponDamageMult().modifyPercent(id,  10f / ship.getHullLevel());
                        stats.getEnergyWeaponFluxCostMod().modifyPercent(id, - 10f / ship.getHullLevel());
                        stats.getBallisticWeaponFluxCostMod().modifyPercent(id, - 10f / ship.getHullLevel());
                stats.getMissileWeaponFluxCostMod().modifyPercent(id, - 10f / ship.getHullLevel());
                        stats.getMissileRoFMult().modifyPercent(id,  10f / ship.getHullLevel());
                        stats.getBallisticRoFMult().modifyPercent(id,  10f / ship.getHullLevel());
                        stats.getEnergyRoFMult().modifyPercent(id,  10f / ship.getHullLevel());



stats.getAcceleration().modifyPercent(id, 10f / ship.getHullLevel());
stats.getDeceleration().modifyPercent(id, 10f / ship.getHullLevel());
stats.getTurnAcceleration().modifyPercent(id, 10f / ship.getHullLevel());
stats.getMaxTurnRate().modifyPercent(id, 10f / ship.getHullLevel());
stats.getMaxSpeed().modifyPercent(id, 10f / ship.getHullLevel());





}
}
public void unapply(MutableShipStatsAPI stats, String id) {
                stats.getEnergyWeaponDamageMult().unmodify(id);
                        stats.getBallisticWeaponDamageMult().unmodify(id);
                        stats.getMissileWeaponDamageMult().unmodify(id);
                        stats.getEnergyWeaponFluxCostMod().unmodify(id);
                        stats.getBallisticWeaponFluxCostMod().unmodify(id);
                stats.getMissileWeaponFluxCostMod().unmodify(id);
                        stats.getMissileRoFMult().unmodify(id);
                        stats.getBallisticRoFMult().unmodify(id);
                        stats.getEnergyRoFMult().unmodify(id);



stats.getAcceleration().unmodify(id);
stats.getDeceleration().unmodify(id);
stats.getTurnAcceleration().unmodify(id);
stats.getMaxTurnRate().unmodify(id);
stats.getMaxSpeed().unmodify(id);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 1) {
return new StatusData("+50 top speed", false);
}
return null;
// if (index == 0) {
// return new StatusData("improved maneuverability", false);
// } else if (index == 1) {
// return new StatusData("+50 top speed", false);
// }
// return null;
// if (index == 0) {
// return new StatusData("improved maneuverability", false);
// }
// if (index == 1) {
// return new StatusData("improved maneuverability", false);
// }
// if (index == 2) {
// return new StatusData("+50 top speed", false);
// }
// return null;
}
}

There is some unused stuff in there, don't mind that.
Now I have a serious problem with this:
It pretty much works as intended except that if hp get very very low the bonus to damage and rate of fire gets extremely high usually resulting in both ships death (so this ship and any enemy ship being attacked).
What I would need to do is limit the stat bonus to a set value which should be reached at a certain fraction of total hit points, let's say the max bonus should be reached at 30% total hp.
How can I do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 26, 2014, 01:16:15 PM
If I understand correctly you should be able to do that like this:

Code: java
float modifier = 10f / (float)Math.max(0.3f, ship.getHullLevel());

stats.getWhateverMult().modifyPercent(id,  modifier);

That will also prevent division by zero.

You might already be planning to fix this, but I thought I'd point it out just in case. The ship using the system won't be destroyed properly if it's hitpoints drop below zero using setHitpoints. You can use applyDamage to get that working right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 26, 2014, 02:13:35 PM
Okay, I noticed that just like you said but I don't know how to use the applyDamage thing. I tried simply swapping it with setHitpoints but that made it crash, which I somehow expected.
Do I need to initiate another API for that or is it from Lazylib or something?
I don't quite understand it, maybe you could give me an example based on my script I posted earlier.
BTW: the mathmax thing works nicely, thanks!
(I always have to smile about the things I write here, they always point out that I am really bad at writing code by myself xD)

I think it works fin for now until I figure out how to make that applyDamage stuff.
Your almost always on the brink of destruction while using the system but you deal insane amounts of damage, pretty much the definition of going berserk.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 27, 2014, 01:36:29 AM
I have a few questions,
1. Is the Impact value in the weapon csv file determines the size or the impact of "Impact" or does it determine the "type of impact"?
2. The pierce set. When something is set to pierce the beam/projectile won't hit the thing that is set to pierce right? But will damage still be applied to that target?
Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on March 27, 2014, 09:37:38 AM
impact determines the "gravity push" of the weapon in question. - impact will pull a ship towards the host (good for tractor beams), + impact will push it away when hit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 27, 2014, 01:47:33 PM
@Tecrys:
Code: java
if(ship.getHitpoints() < 0)
    Global.getCombatEngine().applyDamage(ship, ship.getLocation(), 1, DamageType.ENERGY, 0, true, true, ship);
You'll also need to add these import statements at the top of the file.
Code: java
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.DamageType;

@Lcu:
weapon_data.csv:
impact - Mostly not used anymore. At one point weapons would actually rattle the target around as they hit it, but it never felt just right. The only remnant of that is the graviton beam uses it, which makes it totally screw up any fighter it hits, and is not noticeable against anything else.

Not sure what you're asking about the pierce set. You might just want to experiment with it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 27, 2014, 04:36:35 PM
Cool, thanks!

You know what, I am having so much trouble getting BGE balanced that I have to ask for some help here.
I think if I would have a proper AI that likes to really get in touch with enemies I wouldn't have to have so many workarounds.
Could someone make an AI for me?

The other thing I would need help with is my right click regen mechanic. It does it's job atm but I intended to implement it in a different way which would need an everyframecombatplugin which I can't write by myself.

All the things I've been trying still feel somewhat broken or op imo just because vanilla AI can't handle it properly and I end up making the ships overpowered.

So, yeah any help is much appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 27, 2014, 11:53:34 PM
@Lcu:
weapon_data.csv:
impact - Mostly not used anymore. At one point weapons would actually rattle the target around as they hit it, but it never felt just right. The only remnant of that is the graviton beam uses it, which makes it totally screw up any fighter it hits, and is not noticeable against anything else.

Not sure what you're asking about the pierce set. You might just want to experiment with it.
It is not in the weapon_data.csv, but it is in the .wpn file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 28, 2014, 12:16:56 AM
It is not in the weapon_data.csv, but it is in the .wpn file.
I was referring to 'impact' being in weapon_data.csv, not the pierce set.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 28, 2014, 01:41:05 AM
Oh sorry, i was confused earlier, anyway now i have another question:
Can energy weapons have recoil and base sprites? (like the heavy mauler).
Sorry if i was asking too many questions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 28, 2014, 09:39:35 PM
Does anyone know if it's possible to resize the text panel in an InteractionDialogAPI? I'm trying to write a pure-text dialog, so the space reserved for the visual panel is completely wasted in this case. I'd like the text area to be wider so I can fit more information onto a single page.

The setTextWidth() method doesn't appear to work. The text area doesn't resize, although it does move to the left:
Spoiler
(http://i.imgur.com/EQRkzBP.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2014, 04:32:24 PM
Yeah, the .setTextWidth() method is all sorts of broken. I'll have to sit down and fix it at some point; unfortunately it's not an easy, obvious kind of broken.
Title: WeakHashMap and WeakReference
Post by: Debido on March 31, 2014, 06:38:50 AM
Hi Guys,

I'm doing some scripting for the awesome mod that is BGE. The objective is to have a system that you can right click to enable. This ship system will apply mutablestats to your ship for that duration.

This is done through a hack of the PhaseCloak trick to get it to activate with the right click, and I'm sure quite a few people are familiar with that.

So ok, what happens?

Right Click (or AI activates it, whatever)
ShipSystem activates for 0.1seconds and is de-activated 0.1 seconds later an imperceptible time. There isn't any funny thing with bullets passing through you, no sounds, no transparency, nothing like that. The ShipSystem is going to create a token.

Code: java
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;

import data.scripts.plugins.AdrenalineTracker;


       

public class adrenaline_rush implements ShipSystemStatsScript {
   
    private boolean juiceMe = false;

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel)
        {
            if (state == state.IN)
            {
                if (juiceMe == false) {
                    AdrenalineTracker.startAdrenaline(4f,(ShipAPI)stats.getEntity());
                    juiceMe = true;
                }   
               
               
            }
                   
        }
       
public void unapply(MutableShipStatsAPI stats, String id)
        {
            juiceMe = false;

}

public StatusData getStatusData(int index, State state, float effectLevel) {
return null;

}
}

The next part is effectively a gratuitous copy and paste of the incendiary script. Who wrote that? LazyWizard? Anyway people who've used it or read it probably already know it.

Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
//import java.util.WeakHashMap;
import java.util.HashMap;
//import org.apache.log4j.Level;

/* Original script by LazyWizard (I think)
Modified (hit with a mallet) by Debido
So what is this script? This script is a derivitive of the Incendiary script/
It's purpose is to enable someone to activate the script, apply certain mutablestat effects to a ship
After a given time the effects are un-applied to the ship. That is the high level.

What happens at a psuedo-code level is this

- The adrenaline_rush.java script is called when the player right-clicks or is activated by the AI.
- The adrenaline_rush.java file has a single line that calls the startAdrenaline(float duration, shipAPI source) method in this class file
- The startAdrenaline method does several things
1. Applies the desired buffs/effects to the ship
2. Creates a token in the juiced Hashmap

- Conceptually a token is created but token has other connotations in Java so I'll clarify, but I will use the term token in the conceptual sense.
- The 'token' created is a new AdrenalineData object with the public AdrenalineData(float adrenalineDuration, ShipAPI source) method

- The important aspect of this token is that on creation it has a time value 'expiration' that is the current in-game time + adrenalineDuration in seconds that are passed to it from the shipsystem script startAdrenaline method..
- Every frame of the game it will now check this script, iterate through the list of tokens in the juiced HashMap and determine if the current game time is equal to the time in the duration variable.

- IF the game time is EQUAL to the time in the token, then it processes the token.

- The processing of the token is thus:
1. un-apply the mutable stats
2. remove the token from the juiced hashmap


Enjoy and don't have too much fun!

*/


public class AdrenalineTracker implements EveryFrameCombatPlugin
{
    // Stores the currently juiced juiceTokens
    // Having the Set backed by a WeakHashMap helps prevent memory leaks
    //private static final Set juiced = Collections.newSetFromMap(new WeakHashMap());
    private static final Set juiced = Collections.newSetFromMap(new HashMap());

        private static void applyAdrenalineStats(ShipAPI source)
        {
            String id = "steroids"; //id of the buff
            //Global.getLogger(AdrenalineTracker.class).log(Level.INFO,"Running apply"); //debug code
           
            //Apply ship stats
            source.getMutableStats().getMaxCombatHullRepairFraction().modifyFlat(id, 100f);
            source.getMutableStats().getHullCombatRepairRatePercentPerSecond().modifyFlat(id, 155f);
            source.getMutableStats().getEmpDamageTakenMult().modifyPercent(id, - 70f);
            source.getMutableStats().getHighExplosiveDamageTakenMult().modifyPercent(id, - 70f);
            source.getMutableStats().getKineticDamageTakenMult().modifyPercent(id, - 70f);
            source.getMutableStats().getEnergyDamageTakenMult().modifyPercent(id, - 70f);
            source.getMutableStats().getFragmentationDamageTakenMult().modifyPercent(id, - 70f);
            source.getMutableStats().getCombatEngineRepairTimeMult().modifyMult(id, 0.01f);
            source.getMutableStats().getCombatWeaponRepairTimeMult().modifyMult(id, 0.01f);       
        }
       
                private static void unApplyAdrenalineStats(ShipAPI source)
        {
            String id = "steroids"; //id of the buff
            //Global.getLogger(AdrenalineTracker.class).log(Level.INFO,"Running un-apply"); //debug code
           
            //unpply ship stats           
            source.getMutableStats().getMaxCombatHullRepairFraction().unmodify(id);
            source.getMutableStats().getHullCombatRepairRatePercentPerSecond().unmodify(id);
            source.getMutableStats().getCombatEngineRepairTimeMult().unmodify(id);
            source.getMutableStats().getCombatWeaponRepairTimeMult().unmodify(id);
            source.getMutableStats().getEmpDamageTakenMult().unmodify(id);
            source.getMutableStats().getHighExplosiveDamageTakenMult().unmodify(id);
            source.getMutableStats().getKineticDamageTakenMult().unmodify(id);
            source.getMutableStats().getEnergyDamageTakenMult().unmodify(id);
            source.getMutableStats().getFragmentationDamageTakenMult().unmodify(id);       
        }
   
    private CombatEngineAPI engine;


    @Override
    public void advance(float amount, List events)
    {
        if (engine.isPaused() || juiced.isEmpty())
        {
            return;
        }
        // Deal juiceToken damage for all actively juiced ships
        for (Iterator iter = juiced.iterator(); iter.hasNext();)
        {
            AdrenalineData juiceToken = (AdrenalineData) iter.next();

            // Check if the juiceToken has gone out
            if (engine.getTotalElapsedTime(false) >= juiceToken.expiration)
            {
                unApplyAdrenalineStats((ShipAPI)juiceToken.source.get());
                //unApplyAdrenalineStats(juiceToken.source);
                //Global.getLogger(AdrenalineTracker.class).log(Level.INFO,"Running un-apply loop");
                iter.remove();
                //Global.getLogger(AdrenalineTracker.class).log(Level.INFO,"Removed token");
            }
        }
    }

    public static void startAdrenaline(float adrenalineDuration, ShipAPI source)
    {
        //Creates a new token in the juiced list
        juiced.add(new AdrenalineData(adrenalineDuration, source));
        //Applies the mutablestats to the ship
        applyAdrenalineStats(source);
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
        juiced.clear();
    }

    private static class AdrenalineData
    {
        public final WeakReference source;
        //public final ShipAPI source;
        private final float expiration;

        public AdrenalineData(float adrenalineDuration, ShipAPI source)
        {
            //this.hitLoc = new AnchoredEntity(target, hitLoc);
            this.source = new WeakReference(source);
            //this.source = source;
            //sets the time WHEN it will expire
            expiration = Global.getCombatEngine().getTotalElapsedTime(false)
                    + adrenalineDuration;
        }       
    }
}



The problem is I had to use a strong reference and a normal hashmap for it to work, otherwise it was unreliable in activation. What are the repercussions of using a normal hashmap and a strong reference? Memory leaks?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 31, 2014, 06:49:26 AM
Actually it looks like it was just the WeakHashMap that was causing the issue. If I use a WeakReference for the shipAPI it keeps on working fine. Which is good! However I'm still concerned about the use of the HashMap as opposed to the WeakHashMap.

Frankly as far as I'm concerned WeakHashMap and WeakReference are methods I've read about, but frankly they're still black magic to me as far as my comprehension goes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 31, 2014, 02:13:44 PM
(Note: all of the below is to the best of my knowledge but I could be wrong on some points, also bad at explaining things. Blah blah, usual caveats apply.)

Simply put, a WeakReference is a single-item container that doesn't prevent its contents from being garbage collected like a normal, 'strong' reference would. That means if the WeakReference is the only reference to that object it will still be garbage collected (removed and its memory freed for other variables to use). You were having problems because the only place you were storing your variables was in a weak reference so they were immediately eligible for garbage collection.

Code: java
Object obj = new Object();
WeakReference weakObj = new WeakReference(new Object());

In the above code obj is a strong reference to the new Object, and said Object will continue to exist as long as obj is reachable (http://docs.oracle.com/javase/6/docs/api/java/lang/ref/package-summary.html#reachability) and still refers to it. If you did obj = null, that reference to the new Object is gone and it's eligible for garbage collection. If you instead did something like Object obj2 = obj you now have two strong references to that same Object and it can't be collected until both are gone.

weakObj, on the other hand, is considered a weak reference to its containing object and the newly created Object will be garbage collected very soon since there's nothing else referring to it. Notice the 'very soon' part; garbage collection isn't immediate so you can't rely on it to filter out invalid objects for you. That is why the very first thing the incendiary code checks each iteration is that the ship is still on the battle map.

If I had done WeakReference weakObj = new WeakReference(obj), there would be two references, one strong and one weak, to that Object. As long as the strong reference (obj) existed the contents of weakObj wouldn't be collected. Does that make sense?


The code you repurposed stored ShipAPIs as the reference should have stored ShipAPIs as the reference (oops) because there would always be another strong reference to those ships so long as they were alive and tracked by the combat engine. This was done since the design of the incendiary plugin called for some static elements so other scripts could easily add new fire effects, and since there's no method called at the end of the battle where we could clear those variables, any ships that were on fire when battle ended would stay in memory forever with a normal static HashMap.  And since those ships were in memory everything they referenced would stay in memory, possibly up to and including the entire combat engine for every battle you've played this session. Yeah, memory leaks are nasty like that. A WeakHashMap (a Map where the keys are stored as WeakReferences and that handles all the work of removing dead references for you) lets those ships be garbage collected once they were no longer used by the engine, thus preventing the nasty memory leak if everything was written correctly.

I should note there are other, better ways of avoiding memory leaks in the above situation (mostly by avoiding static variables in the first place), but I went with WeakReferences since they only required a couple lines of code. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 31, 2014, 03:03:02 PM
Thank you LazyWizard.

The WeakReference part seems to work fine, but when I used the WeakHashMap it seemed that that my WeakReference or in any case the AdrenalineData object was disappearing before the duration was over. In the case of say 0.1f or maybe 2f there didn't seem to be a problem, but with a duration of 4f the AdrenalineData was only there a half or maybe a third of the time.

With use of the HashMap the disappearing AdrenalineData problem went away at 4f. So for some reason WeakHashMap was letting the garbage collector cleanup my object I imagine?

I could be wrong though, I would have thought the WeakHashMap  would have kept it in memory at lest until the duration of my timer had expired. Is something else going on if the WeakHashMap is deleting my key too early?

By the sounds of it I need to learn more about Java static variables - or at least how and when not to use them
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on March 31, 2014, 03:59:28 PM
Hi everyone!

I've got a little problem again: Enemy ships exploding in my face!

My solution: Write an onhiteffectscript for my melee weapons that increases the resistance to high explosive damage with each hit.

I tried to modify one of Sundogs script to make it but it is throwing a weird bug at me.

here's the modified code:
Code
package data.scripts.weapons;


import com.fs.starfarer.api.Global;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;

import com.fs.starfarer.api.combat.CombatEntityAPI;

import com.fs.starfarer.api.combat.DamagingProjectileAPI;

import com.fs.starfarer.api.combat.OnHitEffectPlugin;

import com.fs.starfarer.api.combat.ShipAPI;

import java.util.HashMap;
import java.util.Iterator;

import java.util.Map;



public class increasehighexresiHitEffect implements OnHitEffectPlugin
{
    
// This is how we store which ships have dissabled shields and how much
    
//  longer they'll be dissabled.
    //
    // Key - ShipAPI (the affected ship)
    
// Value - float (the remaining duration of shield dissable-ization)
    
static Map affectedShips = new HashMap();

    static final float DISSABLE_TIME_PER_HIT = 0.5f;
// In seconds

    
@Override

public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine)
{
        
if (!(target instanceof ShipAPI)) return;

        
ShipAPI ship = projectile.getSource();

        
if(!ship.isAlive()) return;

        
if(affectedShips.containsKey(ship))
{
            
affectedShips.put(ship, (Float)affectedShips.get(ship) + DISSABLE_TIME_PER_HIT);
        
}
else
{
            
affectedShips.put(ship, DISSABLE_TIME_PER_HIT);
        
}

}


// This is called once each frame by the ForceShieldDissablePlugin
    
public static void forceDissableShields(float amount)
{
        
CombatEngineAPI engine = Global.getCombatEngine();

        
if(engine.isPaused()) return;

        
for(Iterator iter = affectedShips.keySet().iterator();
iter.hasNext();)
{
            
ShipAPI ship = (ShipAPI)iter.next();
            
float remainingTime = (Float)affectedShips.get(ship) - amount;

            
if(remainingTime < 0)
{
                
// This removes the current ship from affectedShips
                
iter.remove();
            
}
else
{
                
affectedShips.put(ship, remainingTime);
                
ship.getMutableStats().getHighExplosiveDamageTakenMult().modifyMult(0.1f);            }
        }
    }
}

This was just my try, it is not entirely doing what I want it to do, it should build up the resistance in 10% steps with each hit and the resistance should fade away in 20% steps per second.
And somehow I need to put a limit to it let's say 70% damage resistance max.

Edit: Debido was able to provide a better solution, consider this solved.
Title: *** Janino
Post by: Debido on April 04, 2014, 08:30:54 AM
Annd with one solution comes another problem

....
Caused by: org.codehaus.commons.compiler.CompileException: File data/shipsystems/scripts/AdrenalineToggleAI.java, Line 31, Column 24: Expression "List < WeaponAPI > weapons" is not an lvalue

Now the code is question is a very simple modification of what I believe to be Xenoargh's PhaseCloakAI, I changed like 2 lines and they didn't even have to do with the same function that is erroring out. I changed lines 76 and 80 only, otherwise unchanged

Spoiler
Code: java
package data.shipsystems.scripts;

import java.util.List;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipCommand;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
import com.fs.starfarer.api.util.IntervalUtil;
import java.util.Iterator;
import org.lazywizard.lazylib.combat.AIUtils;
import data.scripts.plugins.AdrenalineToggleTracker;

public class AdrenalineToggleAI implements ShipSystemAIScript {

private ShipAPI ship;
private CombatEngineAPI engine;
private ShipwideAIFlags flags;
private ShipSystemAPI system;
        private float strafeDistance;

private final IntervalUtil tracker = new IntervalUtil(0.2f, 0.3f);
       
    private float bestStrafeDistance(ShipAPI ship){
        List<WeaponAPI> weapons = ship.getAllWeapons();
        float bestRange = 0f;
        for(Iterator iterMe = weapons.iterator(); iterMe.hasNext(); )
        {
            WeaponAPI weapon = (WeaponAPI) iterMe.next();
            if(weapon.getSpec().getType() != WeaponType.DECORATIVE && weapon.getSpec().getType() != WeaponType.LAUNCH_BAY){
                float weaponRange = weapon.getRange();
                if (weaponRange > bestRange){
                    bestRange = weaponRange;
                }
            }
        }
        if(bestRange > 0f){
            return Math.min(bestRange,1900f);
        } else {
            //Safety catch-all for suckage
            return 800f;
        }
    }       

    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
            this.ship = ship;
            this.flags = flags;
            this.engine = engine;
            this.system = system;
    }

    @Override
    public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target) {
        if(engine.isPaused()) return;
        tracker.advance(amount);
        if (tracker.intervalElapsed()) {
            strafeDistance = bestStrafeDistance(ship);       

            boolean shouldUseSystem;
            List nearbyEnemies = AIUtils.getNearbyEnemies(ship, 5000f);
            List nearerEnemies = AIUtils.getNearbyEnemies(ship, strafeDistance -100f);
            shouldUseSystem = !nearbyEnemies.isEmpty() && nearerEnemies.isEmpty();
            if(nearbyEnemies.isEmpty()){
                shouldUseSystem = true;
            }

            // If system is inactive and should be active, enable it
            // If system is active and shouldn't be, disable it
            if (AdrenalineToggleTracker.getSystem.isOff(ship))
            {
                if(shouldUseSystem) ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK,null,0);
                tracker.randomize();
            }else if (AdrenalineToggleTracker.getSystem.isOn(ship)){
                if(!shouldUseSystem) ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK,null,0);
                tracker.randomize();
            }
        }
    }
}
[close]

For reference here is the original PhaseCloakAI

Spoiler
Code: java
package data.shipsystems.scripts;

import java.util.List;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipCommand;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.combat.AIUtils;

public class PhaseCloakAI implements ShipSystemAIScript {

private ShipAPI ship;
private CombatEngineAPI engine;
private ShipwideAIFlags flags;
private ShipSystemAPI system;
        private float strafeDistance;

private final IntervalUtil tracker = new IntervalUtil(0.2f, 0.3f);
       
    private float bestStrafeDistance(ShipAPI ship){
        List<WeaponAPI> weapons = ship.getAllWeapons();
        float bestRange = 0f;
        for (WeaponAPI weapon : weapons) {
            if(weapon.getSpec().getType() != WeaponType.DECORATIVE && weapon.getSpec().getType() != WeaponType.LAUNCH_BAY){
                float weaponRange = weapon.getRange();
                if (weaponRange > bestRange){
                    bestRange = weaponRange;
                }
            }
        }
        if(bestRange > 0f){
            return Math.min(bestRange,1900f);
        } else {
            //Safety catch-all for suckage
            return 800f;
        }
    }       

    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
            this.ship = ship;
            this.flags = flags;
            this.engine = engine;
            this.system = system;
    }

    @Override
    public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target) {
        if(engine == null) return;
        if(engine.isPaused()) return;
        tracker.advance(amount);
        if (tracker.intervalElapsed()) {
            strafeDistance = bestStrafeDistance(ship);       

            boolean shouldUseSystem;
            List nearbyEnemies = AIUtils.getNearbyEnemies(ship, 5000f);
            List nearerEnemies = AIUtils.getNearbyEnemies(ship, strafeDistance -100f);
            shouldUseSystem = !nearbyEnemies.isEmpty() && nearerEnemies.isEmpty();
            if(nearbyEnemies.isEmpty()){
                shouldUseSystem = true;
            }

            // If system is inactive and should be active, enable it
            // If system is active and shouldn't be, disable it
            if (!ship.getPhaseCloak().isOn() || !ship.getPhaseCloak().isActive())
            {
                if(shouldUseSystem) ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK,null,0);
                tracker.randomize();
            }else if (ship.getPhaseCloak().isOn() || ship.getPhaseCloak().isActive()){
                if(!shouldUseSystem) ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK,null,0);
                tracker.randomize();
            }
        }
    }
}
[close]

The error code just seems wrong, it seems a perfectly valid lvalue to me, and as far as I'm aware Xeno's code works. In fact the original PhaseCloakAI.java file is in the same folder, and throws no errors - even though it is compiled as well...so...why? I'm failing to understand something basic here.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dmaiski on April 04, 2014, 09:33:37 AM
needs external compiler?

i think all list functions need external compiler
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2014, 12:09:50 PM
needs external compiler?

Yeah... either that, or just not using generics, which aren't supported by the version of Janino that ships with the game.

Quote
List < WeaponAPI > weapons

You want to change that to "List weapons" and then cast each element to WeaponAPI as you iterate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 04, 2014, 05:12:06 PM
I'm trying to use Global.getSector().getPersistentData().put() in CharacterCreationPluginImpl and it's crashing and burning when I try to retrieve the data in SectorGen.  I'm not sure what I've done wrong here but I get a NPE every time ::)

In CharacterCreationPluginImpl:
Code
Global.getSector().getPersistentData().put((String) "vacuumPersistantData_oldFaction", (String) "tritachyon");

In SectorGen:
Code
String myOldFaction = (String) Global.getSector().getPersistentData().get("vacuumPersistantData_oldFaction");
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2014, 05:31:21 PM
That's never going to work; the persistent data is unique to the savegame, and doesn't even exist until the game is created.

Since you're not saving anything that has reference to other campaign stuff (i.e. you're just saving a String), you could just store it in a static data member somewhere w/o causing a memory leak.

Quote
put((String) "vacuumPersistantData_oldFaction", (String) "tritachyon");
Btw, those casts to (String) are not necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 04, 2014, 05:36:43 PM
OK.  So I should call a singleton and use that as my temp data storage then?  

Or just create a static data member and have everything that needs to get access to that read it?  Will that be saved?

Anyhow, just trying to figure this out; I need to store some data created there permanently and I keep hitting issues with it.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 04, 2014, 06:02:02 PM
OK, I converted it all over to statics.  No NPE... until I exit the game and return.  Then I get NPE.

So, er... if I can't save persistent data in CharacterCreationPluginImpl, but I need to create the persistent data... uh... do I catch that static in the first frame and do it there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2014, 06:11:23 PM
I might be misunderstanding something. If you're trying to save data outside of a savegame so that you can access it after the application is restarted, you can't do that. I mean, if you do save it inside the persistent data, it wouldn't be loaded into memory until you loaded that specific savegame.

If you're just trying to pass some data from the previous game that was loaded within the same application run, that's where the statics would come in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 04, 2014, 06:23:25 PM
What I'm trying to do is:

1.  Write some data at the very start of a game, during CharacterCreationPluginImpl.
2.  Use that data during SectorGen.
3.  Use that data later on, every time a user opens up a save-game.

Basically, at the start of Vacuum, I want players to choose the Faction they were "last working with"; this in turn affects their initial reputation with all other Factions and has a continuing effect on what fleets spawn from their bases and what ships show up in their bases' shops.  Other than setting the initial relationships, it's a minor feature right now but it'll probably become more important later, so I wanted to figure out why this wasn't working quite right.  I had it working during the initial setup via a singleton but when I tested the persistence, NPE. 


I think I found a solution for this; it's not too involved but it's a little counter-intuitive:

1.  Use a static class for the initial pass from CharacterCreationPluginImpl --> SectorGen.  We're just creating some data here we'll use only during the initial session and that allows it to be passed from one class to another.

2.  In the first frame of gameplay, caught during one of the EveryFrameScripts, write the data to PersistentData if there isn't a key already stored.  Needs to check that, otherwise NPE again.  That stores the value permanently.

3.  Read that value in every other EveryFrameScript operation that needs said data.

4.  If you haven't set it before the operations in 3 can run, you're hosed, but so long as there's a one-frame delay (or longer) on EveryFrameScripts to allow this to get set first, it's all good.


This appears to work, although I need to do most testing before I'm sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2014, 06:35:56 PM
Instead of doing 2) inside an EveryFrameScript, why not do it inside SectorGen? The persistent data is available at that point. I just tried:
Global.getSector().getPersistentData().put("blah", "blahblah");
at the very beginning of SectorGen and it worked for me.

Quote
... write the data to PersistentData if there isn't a key already stored.  Needs to check that, otherwise NPE again.

That can't be right - having a value already stored for that key will absolutely not result in an NPE. Something else is going on there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 04, 2014, 06:53:18 PM
Yay, that's a lot less involved; all I have to do is get it there, assign it one time and I'm guaranteed that it's populated from then on, wonderful :)

The NPE was some other mistake, I'm sure; this appears to be working well now.  I'll convert it over to do it in SectorGen so that it's clean right away though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 04, 2014, 09:00:04 PM
Thanks Alex and Dmaiski.

Though can you tell me some more about the getPersistentData method? Is it available during combat?

I'd always had in the back of my mind that it would be useful to be able to extend the Ship class or the Fleet member class so that additional mod specific, persistent and non-persistent information can be held.

At the moment I'm storing a non-persistent token in an EveryFrameCombatPlugin Script for the purposes of tracking whether a Ship has a particular custom buff applied to it. I think it's a little inefficient to be running an every frame script to store such data and it would be easier to store combat related non-persistent with the ship, such that I can call the ShipAPI and see if the toggle state is active.

Another case where non-persistent data associated with a ship would be with AI, let's say I could with a script say "Hey, I'm about to fire the XXX cannon", then I could write some AI modifications so that they can react to the XXX cannon.

The other instance where I have a timer associated with the Ship, well, I'm not at all sure I can get around not using an EveryFrameCombatPlugin Script as time is fairly critical.

Anyway I'll look at making that list so it isn't using generics (which I need to look up that definition now).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 04, 2014, 09:31:43 PM
It's working!!!!

Now, an API request in a moment, I want to be able to place custom status text for a ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 06, 2014, 06:29:59 PM
Alright.  Got a question I've been meaning to ask for while, which I've kept allowing myself to get distracted on.

In short, I'm attempting to set up a hull mod that will be intrinsic to Shadowyards vessels which has the effect of increasing flux dissipation as the ships hard flux rises.  Unfortunately I haven't been able to actually achieve any effect with this.  The code I've got is as follows:

Spoiler
Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;

public class ms_harShields extends BaseHullMod {

private static Map mag = new HashMap();
static {
mag.put(HullSize.FRIGATE, 50f);
mag.put(HullSize.DESTROYER, 40f);
mag.put(HullSize.CRUISER, 30f);
mag.put(HullSize.CAPITAL_SHIP, 20f);
}

    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableCharacterStatsAPI stats, String id, MutableShipStatsAPI hull, ShipAPI ship) {
        ShipAPI this_ship = (ShipAPI) hull.getEntity();
        
        if (ship == this_ship) {
                //hull.getHardFluxDissipationFraction().getBaseValue();
        
hull.getFluxDissipation().modifyPercent(id,
                    1 - hull.getHardFluxDissipationFraction().getBaseValue()
                         * (Float) mag.get(hullSize));
            }
}
    
    public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}

    public boolean isApplicableToShip(ShipAPI ship) {
return (ship.getHullSpec().getHullId().startsWith("ms_") &&
       !ship.getVariant().getHullMods().contains("ms_harShields"));
}
}
[close]

Now I've gotten this to, with some fiddling, have an effect of flux dissipation as the hard flux increases, but it's the exact opposite of what I intended, with the flux dissipation decreasing at higher levels of hard flux, which is distinctly ungood.  Excepting that I've gotten absolutely no effect, and I'm not sure how to get this working properly.

Any help would be much appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 06, 2014, 06:49:23 PM
Since what you want to do is dynamic (i.e. it depends on the ship's current flux level), what you want to do is apply the effects of the hullmod in the
HullModEffect.advanceInCombat(ShipAPI ship, float amount)
method. The method you're doing stuff in only gets called once, when the ship is created.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 07, 2014, 04:34:36 AM
I have little problem I tried to fix but I am not getting this right:
Spoiler
Code
    package data.scripts.plugins;
    
    import com.fs.starfarer.api.Global;
    import com.fs.starfarer.api.combat.CombatEngineAPI;
    import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.FluxTrackerAPI;
    import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;
    import java.lang.ref.WeakReference;
    import java.util.Collections;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Set;
    //import java.util.WeakHashMap;
    import java.util.HashMap;
    import org.apache.log4j.Level;
    
    /* Original script by LazyWizard (I think)
 
    This is nothing like LW's original script!
    
    */
    
    
    public class AdrenalineToggleTracker implements EveryFrameCombatPlugin
    {
        // Stores the currently juiced juiceTokens
        // Having the Set backed by a WeakHashMap helps prevent memory leaks
        //private static final Set juiced = Collections.newSetFromMap(new WeakHashMap());
        private static final Set juiced = Collections.newSetFromMap(new HashMap());
        private CombatEngineAPI engine; //probably don't need this anymore
        private final float INTERVAL_FRACTION = 0.2f;
        private final IntervalUtil tracker = new IntervalUtil(INTERVAL_FRACTION, INTERVAL_FRACTION);
        private final float FLUX_PER_SECOND = 1f*INTERVAL_FRACTION;
      
                @Override
        public void advance(float amount, List events)
        {
            if (engine.isPaused() || juiced.isEmpty())
            {
                return;
            }
          
            tracker.advance(amount);
          
            if (tracker.intervalElapsed())
            {
                for (Iterator iter = juiced.iterator(); iter.hasNext();)
                    {
                        AdrenalineData juiceToken = (AdrenalineData) iter.next();
                        ShipAPI ship = (ShipAPI)juiceToken.source.get();
                        FluxTrackerAPI fluxTracker = ship.getFluxTracker();
                        fluxTracker.increaseFlux(FLUX_PER_SECOND, true);
                    }
            }
 
 
        }
      
    
            private static void applyAdrenalineStats(ShipAPI source)
            {
                String id = "steroids"; //id of the buff
                Global.getLogger(AdrenalineToggleTracker.class).log(Level.INFO,"Running apply"); //debug code
              
                //Apply ship stats
                source.getMutableStats().getMaxCombatHullRepairFraction().modifyFlat(id, 100f);
                source.getMutableStats().getHullCombatRepairRatePercentPerSecond().modifyFlat(id, 4f);
                source.getMutableStats().getEmpDamageTakenMult().modifyPercent(id, - 30f);
                source.getMutableStats().getHighExplosiveDamageTakenMult().modifyPercent(id, - 30f);
                source.getMutableStats().getKineticDamageTakenMult().modifyPercent(id, - 30f);
                source.getMutableStats().getEnergyDamageTakenMult().modifyPercent(id, - 30f);
                source.getMutableStats().getFragmentationDamageTakenMult().modifyPercent(id, - 30f);
                source.getMutableStats().getCombatEngineRepairTimeMult().modifyMult(id, 0.5f);
                source.getMutableStats().getCombatWeaponRepairTimeMult().modifyMult(id, 0.3f);
                source.getMutableStats().getFluxDissipation().modifyPercent(id, 0f);
                source.getMutableStats().getAcceleration().modifyPercent(id,  30f);
                source.getMutableStats().getDeceleration().modifyPercent(id,  30f);
                source.getMutableStats().getTurnAcceleration().modifyPercent(id,  30f);
                source.getMutableStats().getMaxTurnRate().modifyPercent(id,  30f);
                source.getMutableStats().getMaxSpeed().modifyPercent(id,  30f);
                source.getMutableStats().getZeroFluxMinimumFluxLevel().modifyFlat(id,  1f);
      
            }
          
                    private static void unApplyAdrenalineStats(ShipAPI source)
            {
                String id = "steroids"; //id of the buff
                Global.getLogger(AdrenalineToggleTracker.class).log(Level.INFO,"Running un-apply"); //debug code
              
                //unpply ship stats            
                source.getMutableStats().getMaxCombatHullRepairFraction().unmodify(id);
                source.getMutableStats().getHullCombatRepairRatePercentPerSecond().unmodify(id);
                source.getMutableStats().getEmpDamageTakenMult().unmodify(id);
                source.getMutableStats().getHighExplosiveDamageTakenMult().unmodify(id);
                source.getMutableStats().getKineticDamageTakenMult().unmodify(id);
                source.getMutableStats().getEnergyDamageTakenMult().unmodify(id);
                source.getMutableStats().getFragmentationDamageTakenMult().unmodify(id);
                source.getMutableStats().getCombatEngineRepairTimeMult().unmodify(id);
                source.getMutableStats().getCombatWeaponRepairTimeMult().unmodify(id);
                source.getMutableStats().getFluxDissipation().unmodify(id);
                source.getMutableStats().getAcceleration().unmodify(id);
                source.getMutableStats().getDeceleration().unmodify(id);
                source.getMutableStats().getTurnAcceleration().unmodify(id);
                source.getMutableStats().getMaxTurnRate().unmodify(id);
                source.getMutableStats().getMaxSpeed().unmodify(id);
                source.getMutableStats().getZeroFluxMinimumFluxLevel().unmodify(id);      
            }
      
 
    
    
 
    
        public static void startAdrenaline(ShipAPI source)
        {
            //Creates a new token in the juiced list
            juiced.add(new AdrenalineData(source));
            //Applies the mutablestats to the ship
            applyAdrenalineStats(source);
        }
      
        public static void stopAdrenaline(ShipAPI source)
        {
                for (Iterator iter = juiced.iterator(); iter.hasNext();)
                    {
                    AdrenalineData shipToken = (AdrenalineData) iter.next();
                        if (source == (ShipAPI)shipToken.source.get())
                        {
                            iter.remove();
                        }
 
                    }
    
            unApplyAdrenalineStats(source);
        }
      
        public static void toggleAdrenaline(ShipAPI source)
        {
            if (getSystem.getState(source))
            {
                stopAdrenaline(source);
            }
            else
            {
                startAdrenaline(source);
            }
        }
    
        @Override
        public void init(CombatEngineAPI engine)
        {
            this.engine = engine;
            juiced.clear();
        }
    
        private static class AdrenalineData
        {
            public final WeakReference source;
            //public final ShipAPI source;
    
            public AdrenalineData(ShipAPI source)
            {
                this.source = new WeakReference(source);
            }        
        }
      
        public static class getSystem
        {
                //private boolean m_SystemState;
                //private ShipAPI m_Ship;
                public static boolean isOn(ShipAPI ship)
                {
                    //this.m_Ship = ship;
                    boolean l_returnState = false;
                    //get state of system, check if on, then return true
 
                    if (getState(ship)) l_returnState = true;
 
                    return l_returnState;
                }
 
                    public static boolean isOff(ShipAPI ship)
                {
                    //this.m_Ship = ship;
                    boolean l_returnState = true;
                    //get state of system, check if on, then return true
 
                    if (getState(ship)) l_returnState = false;
 
                    return l_returnState;
                }
 
                private static boolean getState(ShipAPI ship)
                {
                    boolean l_returnState = false;
 
                    for (Iterator iter = juiced.iterator(); iter.hasNext();)
                    {
                    AdrenalineData shipToken = (AdrenalineData) iter.next();
                        if (ship == (ShipAPI)shipToken.source.get())
                        {
                            l_returnState = true;
                        }
 
                    }
 
                    return l_returnState;
 
            }
        }
      
    }
[close]

It works basically as intended but I want it to remove the token if the ship using this is venting or overloaded.

Any help is much appreciated, this is getting frustrating

Got it fixed, nevermind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 07, 2014, 03:31:29 PM
Okk, so, here is the brain teaser bug of the century.

I recieve the following error code when attempting to load a certain script:

Spoiler
13247 [Thread-5] WARN  com.fs.starfarer.title.ooOO.D  - Error loading mission preview
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
   at java.util.ArrayList.rangeCheck(Unknown Source)
   at java.util.ArrayList.get(Unknown Source)
   at com.fs.starfarer.loading.scripts.ScriptStore.o00000(Unknown Source)
   at com.fs.starfarer.settings.StarfarerSettings.?00000(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMember.updateStatsBasedOnCrew(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMember.updateOnlyStatsThatCanRelyOnCROrCre w(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMember.updateStats(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMember.<init>(Unknown Source)
   at com.fs.starfarer.combat.super.o00000(Unknown Source)
   at com.fs.starfarer.title.ooOO.K.addToFleet(Unknown Source)
   at com.fs.starfarer.title.ooOO.K.addToFleet(Unknown Source)
   at data.missions.turningthetables.MissionDefinition.defineMission(MissionDefinition.java:37)
   at com.fs.starfarer.title.ooOO.K.<init>(Unknown Source)
   at com.fs.starfarer.title.ooOO.D.o00000(Unknown Source)
   at com.fs.starfarer.title.ooOO.J.o00000(Unknown Source)
   at com.fs.starfarer.title.ooOO.J.<init>(Unknown Source)
   at com.fs.starfarer.title.ooOO.E.<init>(Unknown Source)
   at com.fs.starfarer.title.OoOO.???000(Unknown Source)
   at com.fs.starfarer.title.OoOO.class.for$super(Unknown Source)
   at com.fs.starfarer.B.???000(Unknown Source)
   at com.fs.oOOO.A.?00000(Unknown Source)
   at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


<snip>

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
   at java.util.ArrayList.rangeCheck(Unknown Source)
   at java.util.ArrayList.get(Unknown Source)
   at com.fs.starfarer.loading.scripts.ScriptStore.o00000(Unknown Source)
   at com.fs.starfarer.settings.StarfarerSettings.?00000(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.<init>(Unknown Source)
   at com.fs.starfarer.loading.specs.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.loading.specs.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.loading.specs.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.title.A.?00000(Unknown Source)
   at com.fs.starfarer.title.A.class(Unknown Source)
   at com.fs.starfarer.title.A.o00000(Unknown Source)
   at com.fs.starfarer.combat.oOOO.new.super(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.title.OoOO.o00000(Unknown Source)
   at com.fs.starfarer.B.???000(Unknown Source)
   at com.fs.oOOO.A.?00000(Unknown Source)
   at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Now ordinarily you see compile errors with janino, however the script (if enabled) has a reference to a JAR file. That JAR file appears to be correctly referenced in the mod_info, so doesn't seem to be a problem there.

The Java file in questions that calls the JAR file looks like this:

Spoiler
Code: java

package data.scripts;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
import com.fs.starfarer.api.loading.WingRole;
//import data.scripts.shipai.BrawlerAI;
import bge.ai.BGEMeleeAI;
import bge.ai.PhaseCloakAI;
import data.shipsystems.scripts.AlwaysOnAI; //fungal spores, mord_drone_hyperspace, stem_cell_cure
import data.shipsystems.scripts.IntegrityFieldAI; //flux parasites, female_pheremones
import data.shipsystems.scripts.OnOnceAI; //brut_drone,mord_drone
//import data.shipsystems.scripts.PhaseCloakAI;
import data.shipsystems.scripts.ai.AdrenalineToggleAI;
import data.shipsystems.scripts.ai.HighEnergyFocusAI; //berzerk
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Revan
 */
public class BGEAIPicker {
   
    public static void setBGEAI(CombatEngineAPI engine)
    {
            Global.getLogger(BGEAIPicker.class).log(org.apache.log4j.Level.INFO,"BGEAIPicker has run once");
            List ships = engine.getShips();
        for (Iterator it = ships.iterator(); it.hasNext();) {
            Object shipObject = it.next();
            ShipAPI ship = (ShipAPI)shipObject;
            List weapons = ship.getAllWeapons();
            if (weaponCheck(weapons))
            {
                ship.setShipAI(new BGEMeleeAI(ship,pickSystemAIScript(ship),pickCloakAIScript(ship),shouldStrafe(ship),bestStrafeDistance(ship)));
            }
        }
 
    }
   
    //import data.shipsystems.scripts.AlwaysOnAI; //fungal spores, mord_drone_hyperspace, stem_cell_cure
    //import data.shipsystems.scripts.IntegrityFieldAI; //flux parasites, female_pheremones
    //import data.shipsystems.scripts.OnOnceAI; //brut_drone,mord_drone
    //import data.shipsystems.scripts.ai.AdrenalineToggleAI; adrenalineAI
    //import data.shipsystems.scripts.ai.HighEnergyFocusAI; //berzerk
    //import data.shipsystems.scripts.PhaseCloakAI; //
   
   
            private static ShipSystemAIScript pickSystemAIScript(ShipAPI ship)
        {
            if(ship.getSystem() == null)
            {
                return null;
            } else if (ship.getSystem().getId().contains("fungal_spores") ||
                    ship.getSystem().getId().contains("mord_drone_hyperspace_web") ||
                    ship.getSystem().getId().contains("stem_cell_cure"))
            {
                return new AlwaysOnAI();
            } else if (ship.getSystem().getId().contains("flux_parasites") ||
                    ship.getSystem().getId().contains("female_pheremones"))
            {
                return new IntegrityFieldAI();
            } else if (ship.getSystem().getId().contains("brut_drone") ||
                    ship.getSystem().getId().contains("mord_drone"))
            {
                return new OnOnceAI();
            } else if (ship.getSystem().getId().contains("berzerk"))
            {
                return new HighEnergyFocusAI();
            } else
            {
                return new AlwaysOnAI();
            }
        }
       
        private static boolean weaponCheck(List weapons)
        {
            boolean returnBoolean = false;
        for (Iterator it = weapons.iterator(); it.hasNext();) {
            Object weaponObject = it.next();
            WeaponAPI weaponIDCheck = (WeaponAPI) weaponObject;
            if (weaponIDCheck.getId() == "lrg_scythe_right"
                    || weaponIDCheck.getId() == "lrg_scythe_left"
                    || weaponIDCheck.getId() == "med_scythe_left"
                    || weaponIDCheck.getId() == "med_scythe_right"
                    || weaponIDCheck.getId() == "lrg_pincer_right"
                    || weaponIDCheck.getId() == "lrg_pincer_left"
                    || weaponIDCheck.getId() == "med_pincer_right"
                    || weaponIDCheck.getId() == "med_pincer_left")
            {
                returnBoolean = true;
            }
            else
            {
                returnBoolean = false;
            }
        }
            return returnBoolean;
        }
       
        private static ShipSystemAIScript pickCloakAIScript(ShipAPI ship){
        Global.getLogger(BGEAIPicker.class).log(org.apache.log4j.Level.INFO,ship.getPhaseCloak().getId());
        if(ship.getPhaseCloak() == null)
        {
            return null;
           
        } else if (ship.getPhaseCloak().getId().contains("adrenaline_rush"))
        {
            return new AdrenalineToggleAI();
           
        } else
        {           
            return new PhaseCloakAI();
        }
    }
       
        private static boolean shouldStrafe(ShipAPI ship){
        String systemId = ship.getSystem().getId();
        //Special exception for Burn Drive here, since attempting to strafe with it is counter-productive
        if(systemId.contains("burndrive")) return false;
        if(!ship.isFighter()) return true;//We can change this later
        return ship.getWing().getRole() !=
                WingRole.BOMBER &&
                ship.getWing().getRole() !=
                WingRole.INTERCEPTOR;
    }
   
    private static float bestStrafeDistance(ShipAPI ship){
        List weapons = ship.getAllWeapons();
        float bestRange = 0f;
        for (Iterator it = weapons.iterator(); it.hasNext();) {
            WeaponAPI weapon = (WeaponAPI)it.next();
            if(weapon.getSpec().getType() != WeaponType.DECORATIVE && weapon.getSpec().getType() != WeaponType.LAUNCH_BAY){
                float weaponRange = weapon.getRange();
                if (weaponRange > bestRange){
                    bestRange = weaponRange;
                }
            }
        }
        if(bestRange > 0f){
            return Math.min(bestRange - 150f,1900f);
        } else {
            //Safety catch-all for suckage
            return 800f;
        }
    }
}
[close]

So yes, effectively trying to change the AI of ships during an EveryFrameCombatPlugin script during the advance section...why not though?

It all looks good, it all compiles well, just for some reason the mission preview loading script by Alex doesn't like it?? Wierd.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 07, 2014, 05:24:33 PM
Debido, I think you may have run into the same issue I did in the second post of this thread (http://fractalsoftworks.com/forum/index.php?topic=7720.0). Please forgive the obnoxious pseudo-anachronistic language. I was bored that day. You might just want to skip to the edit at the end of the post.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 07, 2014, 05:50:31 PM
I still don't get it. I managed to get the script above to not crash but it is still not running ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 07, 2014, 11:24:59 PM
Quote
It all looks good, it all compiles well, just for some reason the mission preview loading script by Alex doesn't like it?? Wierd.
IIRC, you need to make sure there is a valid CombatEngine; if not, crashy crash.

But what you're indicating with the one bug you've described is a bug with a List, where you're attempting to grab a list element that doesn't exist.  Probably you have a List you aren't checking to see if .isEmpty() or something.

In terms of the general concept... like I said in PMs... the AI I built isn't really designed for that logic flow.  You're trying to make it do something it really wasn't designed to do, and from a technical perspective, that's actually a bad way to design it, because whenever it switches states, it's going to have run expensive stuff like findBestTarget() all over again, re-register a bunch of variables and all that.

Instead, you should have a logic switch in the AI itself that turns sections off / on based on the status of the System.  I presume that the idea here is that when the System's on, you want it to use a variant movement pattern... that's mainly just copy-pasta from the two versions of steerMe you want, or a new one that does precisely what you need it to do, with a boolean telling it which one to use right now. 

I think you're really over-complicating this (as well as making it harder to debug) by trying to make it change on-the-fly; while that sounds like a nice concept, in practice, it's almost certainly better to build an AI that is customized to the desired business case. 

A logical switch like that costs practically nothing and the control flow is a lot more easy to design, and debugging's simpler, too- here, you have three things that can break (the AIs and whatever you're using to switch between them) which is inviting a lot of trouble; the whole way that the AI is designed, Systems receive one-way messages from the Ship AI; they're not allowed to mess with Ship AIs.  This is how Alex designed his AI, more or less (he uses a somewhat richer communications system than I ended up going with, but it's not that important).

Anyhow, that's why the AI's designed the way it is, with lots of variants instead of just getting bigger, more complicated and harder to read; the whole idea is that it's as short and simple in design as possible, easily customizable and is broken up into logical parts that each do one part of the whole task, so that tweaking a specific area is straightforward. 

In short... walk before you run.  Set it up the way it was intended to operate, get it running as a custom AI with a context switch... then worry about fancy stuff like on-the-fly AI change-outs :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 07, 2014, 11:44:26 PM
Thanks Xeno.

From a design perspective I would have liked to have done it the way you've currently done it in Vacuum, however while the BaseModPlugin...problem hadn't been resolved I went down the path Sundog seemed to be successful with.

After I'd nearly finished the above code, I then found that problem with the mod_info file I mentioned in the PM. The code still looked viable and had some theoretical advantages, such as being able to be compatible with other mods (in theory).

Ideally speaking the script would only ever be run once on any ship unless in future there was a need to do otherwise for some reason. IT's a good idea to have an AI with it's own logic switch inside that turns sections on and off, and a great design but it doesn't solve the overarching problem of being compatible with other mods and not screwing up their AI.

Tecrys was working on getting the Custom AI working in the exact same way you've currently got Vacuum setup, it doesn't sound like he's been successful yet, I'll have to have a look at that.

Anyway I'll have a look at checking the CombatEngine is valid. What are the checks? Is a Null check all that is required? Hm, maybe check that the engine passed is the current global engine?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 12:03:12 AM
Also the BGEMeleeAI is actually just your BrawlerAI compiled in a jar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 12:19:37 AM
You'd think this would do it for combat engine:
Code: java
            if (engine == null || engine != Global.getCombatEngine())
            {
                return;
            }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 08, 2014, 01:50:18 AM
What "BaseModPlugin" problem? 

If everybody extends BaseModPlugin, there shouldn't be any serious issues... not really understanding why that's a problem in the first place, necessitating all this kludging.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 02:12:15 AM
@Xeno: The missing ModPlugin line in the mod_info file.

@Sundog: Anyway, I simply cannot see anywhere I'm incorrectly initialising a float value with an int or anything stupid like that

https://bitbucket.org/biomancy/bge/src/9e922ebc7c4b673643dca49c3375fb7931aba626/data/scripts/BGEAIPicker.java?at=master
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 08, 2014, 02:20:05 AM
Quote
The missing ModPlugin line in the mod_info file.
I presume you've, er, corrected that oversight?  As well as making sure it's not using replace on any areas that will not play nice with others, etc?

If so, that brings you right back to square one, so now all you've got to do is get it working; I humbly suggest doing it as I've described; if you can get it working right, then worry about whether you want to actually initialize new AIs on the fly based on (some condition), which is a secondary problem at best :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 02:38:32 AM
I'm a 100% certain we could do it using your method...and we'll probably go down that code branch I suspect.

In the meantime I found the cause of that bug, the BGEAIPicker needed to moved into the same data.scripts.plugins folder as the AdrenalineToggleTracker.

It makes no sense...but...yeah. I'm going to keep on kludging this method as I really would like to see AI that is modular and doesn't stop the vanilla AI from working. I mean...my interpretation of what your design is, is modplugin method like vacuum, but that turns off anyone elses AI. Yeah?

Oh and thanks for the pointers on preventing it getting invalid combat engines and null lists! Really helpful, that avoided hours of headaches.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 08, 2014, 04:09:22 AM
Quote
I mean...my interpretation of what your design is, is modplugin method like vacuum, but that turns off anyone elses AI. Yeah?
Nope, it's actually pretty open.

Because ModPlugin controls exactly which ships are assigned the AI, you have total control.  I have specific AI examples in Vacuum that only apply to one ship in the entire game- the Boarding Shuttle AI.

If that function in ModPlugin returns null, then Vanilla's AI is used.  So, no, you don't need to force the AI on via a kludge, just use it as designed and build good logic for the specific control problem you're trying to solve :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 04:27:28 AM
Woah...wait...if I have specific AI in my modplugin, it does not effect anyone elses AI? Not even vanilla? The impression I have received is the opposite, that as soon as you implement your own AI, everyone's ship in every mod and even the vanilla ships rely upon your implementation of the AIPicker.

If that is not the case, then I cannot reconcile as to why I've been making this crazy bad script in the first place.

Ughhh the API really needs some better documentation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 04:44:36 AM
Anyway, forget my life. If anyone ever reads through this thread having some bizarre need to modify the AI of ships using an EveryFrameCombatPlugin script to monitor it. Then yeah, it is possible, I have it working.

Otherwise time to throw this in the garbage heap and go back the modplugin method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 08, 2014, 12:18:48 PM
Quote
Woah...wait...if I have specific AI in my modplugin, it does not effect anyone elses AI?
Exactly :)

Otherwise I couldn't leave, say, the Salamander MRM with its Vanilla implementation, by excluding it from all of the missile AI stuff.

Anyhow, I'm sorry that you weren't aware of this from the outset; I thought that was clear from how ModPlugin is structured (i.e., everything there returns null by default in the API unless otherwise specified) but I guess that's something that could be added to the API- a few more comment lines above each section would have been quite helpful to newbies :)

Anyhow, that's how it works; you can have AIs that are customized for one specific ship, weapon, drone or guided projectile if you want to go crazy.  Me, I'm just building good generalist solutions because, er, I have well over a hundred ships in the mod and it gets kinda hard otherwise, lol :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 12:25:17 PM
Ok...fair enough, I do have a problem (or two) with compiling...although one I'm not sure about and don't understand properly is with the ModPlugin, for the AI picker section, what do I return if I have nothing to return? Do I return a null value? Does the SS code then know to keep going and assigning AI like normal with a null value?

EDIT: What I mean is, what do I return if it is NOT one of my ships that is eligible for the AI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 08, 2014, 12:44:55 PM
Quote
what do I return if it is NOT one of my ships that is eligible for the AI?
Null, just like it says in the API (which has better documentation than I remembered):

Code: java
	/**
* Called to pick an AI implementation for a specific ship. Here instead of in CampaignPlugin to support custom
* AI for missions.
*
* @param member Can be null.
* @param ship Can not be null. Could be a ship or a fighter.
* @return null, or a custom AI implementation.
*/
PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 08, 2014, 01:02:34 PM
Ok, just checking to be sure. Thanks! It didn't make sense to return a null.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 08, 2014, 01:24:59 PM
From a design perspective I would have liked to have done it the way you've currently done it in Vacuum, however while the BaseModPlugin...problem hadn't been resolved I went down the path Sundog seemed to be successful with.
The only time I create AIs on the fly is for temporarily overriding vanilla AI for a few seconds. BaseModPlugin.pickShipAI() should be overriden (as xenoargh suggested) any time a ship should start off with custom AI. I suppose I should leave a few warning comments about that near the lines where I use temporary AI   :-\
Heck, I just need to leave more comments in general...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 09, 2014, 12:20:59 PM
OK, I'm missing something, somewhere.

After I move an EveryFrameCombatPlugin from being a loose JAVA file, and compile it into a JAR file with a whole lot of other scripts, the Advance and Init sections are no longer called.

What is the workaround/fix for this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 09, 2014, 02:09:00 PM
Moving it won't change that.  Probably you're not instantiating the EveryFrameCombatPlugin :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 12, 2014, 02:28:22 AM

Edit: Resolved!


Hi everyone!

I was thinking about getting rid of the left and right versions of my melee weapons and I remembered that Xeno wrote a little script that mirrors weapon sprites:
http://fractalsoftworks.com/forum/index.php?topic=6452.msg131073#msg131073

Now that works as intended but since that weapon is animated it doesn:t work all that well, I would need to mirror the whole animation.

How would I need to change that script to mirror each fraeme of the animation?

I figured it out except for the refit screen and one frame (i guess frame 00), here's my modified code:
Code
package data.scripts.weapons;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.graphics.SpriteAPI;
import java.util.*;

public class BaseAnimateOnFireEffect2 implements EveryFrameWeaponEffectPlugin
{
    // Default to 15 frames per second
    private float timeSinceLastFrame, timeBetweenFrames = 1.0f / 140f;
    private Map pauseFrames = new HashMap();
    private int curFrame = 0, pausedFor = 0;
    private boolean isFiring = false;
private boolean runOnce2 = false;
private boolean runOnce3 = false;

    protected void setFramesPerSecond(float fps)
    {
        timeBetweenFrames = 1.0f / fps;
    }

    protected void pauseOnFrame(int frame, int pauseFor)
    {
        pauseFrames.put(frame, pauseFor);
    }


    private void incFrame(AnimationAPI anim)
    {

        if (pauseFrames.containsKey(curFrame))
        {
            if (pausedFor < (Integer) pauseFrames.get(curFrame))
            {
                pausedFor++;
                return;
            }
            else
            {
                pausedFor = 0;
            }
        }

        curFrame = Math.min(curFrame + 1, anim.getNumFrames() - 1);
    }

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        if (engine.isPaused())
        {
            return;
        }

        AnimationAPI anim = weapon.getAnimation();
        anim.setFrame(curFrame);

        if (isFiring)
        {
            timeSinceLastFrame += amount;

            if (timeSinceLastFrame >= timeBetweenFrames)
            {
                timeSinceLastFrame = 0f;
                incFrame(anim);
                anim.setFrame(curFrame);
       if(runOnce2 == false){  
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()  
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            
        }  
    

                if (curFrame == anim.getNumFrames() - 1)
                {
                    isFiring = false;
runOnce2 = true;  
                }
            }
        }
        else
        {
            if (weapon.isFiring() && weapon.getChargeLevel() == 1.0f)
            {
                isFiring = true;
                incFrame(anim);
                anim.setFrame(curFrame);
            }
            else
            {
                curFrame = 0;
                anim.setFrame(curFrame);
       if(runOnce3 == false){  
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()  
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            runOnce3 = true;  
        }
            }
        }
    }
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on April 25, 2014, 10:05:56 AM
Hi there! What's the best way to remove a fleet from the campaign altogether?

CampaignFleetAPI.getFleetData().clear(); ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 25, 2014, 10:37:31 PM
That should do it, yeah. It will make the fleet fade out and then be removed once it's finished fading out.

If you want to remove it immediately, you can do:
if (fleet.getContainingLocation() != null) {
    fleet.getContainingLocation().removeEntity(fleet);
}

The != null check is just for paranoia reasons, that shouldn't ever be true.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on April 27, 2014, 09:42:06 AM
I need to detect if the player has retreated in the campaign or mission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on May 08, 2014, 10:24:46 AM
FleetMemberAPI.isCivilian() returns true even if the ships do not have the HINT: CIVILIAN. May it be related to the fact that I'm using _Hull variants?

EDIT: If that's the case should I use FleetMemberAPI.getHullSpec().getHints().contains(ShipTypeHints.CIVILIAN)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2014, 11:01:45 AM
FleetMemberAPI.isCivilian() returns true even if the ships do not have the HINT: CIVILIAN. May it be related to the fact that I'm using _Hull variants?

EDIT: If that's the case should I use FleetMemberAPI.getHullSpec().getHints().contains(ShipTypeHints.CIVILIAN)?

Yes and yes. The FleetMemberAPI.isCivilian() is more like FleetMemberAPI.isWoefullyUndergunned(). Confusing, I know - sorry about that :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on May 08, 2014, 11:50:12 AM
FleetMemberAPI.isCivilian() returns true even if the ships do not have the HINT: CIVILIAN. May it be related to the fact that I'm using _Hull variants?

EDIT: If that's the case should I use FleetMemberAPI.getHullSpec().getHints().contains(ShipTypeHints.CIVILIAN)?

Yes and yes. The FleetMemberAPI.isCivilian() is more like FleetMemberAPI.isWoefullyUndergunned(). Confusing, I know - sorry about that :)

Can I vote for that to be added to the API as the official name?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2014, 11:54:03 AM
You can. Thinking about, though, I actually prefer FleetMemberAPI.needsMoreDakka().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on May 08, 2014, 12:18:21 PM
if (ship.getHullId().equals("onslaught") {
    !ship.needsMoreDakka();
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 08, 2014, 12:55:17 PM
You can. Thinking about, though, I actually prefer FleetMemberAPI.needsMoreDakka().
I need this function in my life. It's well worth a breaking change.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Aereto on May 08, 2014, 01:42:00 PM
You can. Thinking about, though, I actually prefer FleetMemberAPI.needsMoreDakka().
I need this function in my life. It's well worth a breaking change.
I second that motion. There's one of those days you need a bigger/more guns than the other captain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 12, 2014, 03:05:30 PM
2) In devMode, while in combat (and only in combat), you can 1) press F5 to reload all textures and 2) press F8 to reload all data files and scripts. This may cause the game to crash at some later point.
Is there still a way to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2014, 03:09:33 PM
F5/F8 still work for this (just double checked on my dev version).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 12, 2014, 03:19:28 PM
Thanks for the quick reply Alex  :)
Are there any known limitations? Using F8 crashes for me. I'll see if I can figure out why.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2014, 03:32:02 PM
Nothing specific comes to mind, aside from it being crashy later. Haven't seen it crash right off the bat, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on May 12, 2014, 03:41:58 PM
A have a missile CombatEntityAPI or at leasts it's MissileAPI, however you want to look at it. I want to get the missile's current target to do...stuff to the missile.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2014, 03:57:17 PM
if (missile.getMissileAI() instanceof GuidedMissileAI) {
    CombatEntityAPI target = ((GuidedMissileAI) missile.getMissileAI()).getTarget();
}

Note that this won't work for custom missile AIs, only vanilla, due to a bug I just ran into while looking at this. (Glad this came up! It's now fixed for the next release.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on May 12, 2014, 04:24:01 PM
Fantastic! Thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 12, 2014, 05:14:31 PM
It looks like the F8/script-refresh crash I was getting is related to using jar files. Janino doesn't seem be be able to find/load stuff if it's already been compiled. F8 doesn't cause a crash when the only mod loaded is Junk pirates, which only has .java files and doesn't require LazyLib. Please correct me if I'm wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on May 12, 2014, 05:17:19 PM
@Sundog, I'm finding a similar problem, it keeps on crashing because of the Jarred lazylib class which I have a dependency on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2014, 05:39:14 PM
Hm, yeah, that code path didn't get updated along with the capability to use jars. Fixed for the next release, but unfortunately won't work for now. Thank you for tracking it down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on May 12, 2014, 05:50:49 PM
Hm, yeah, that code path didn't get updated along with the capability to use jars. Fixed for the next release, but unfortunately won't work for now. Thank you for tracking it down.

Again, thanks Alex! That is super fast bug fixing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2014, 05:54:07 PM
Sometimes it's easier to fix them right away than it is to write it down and fix later :)

... actually, replace "sometimes" with "most times". Combine that with the inherent depressiveness of having a bunch of known unfixed bugs, and yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on May 12, 2014, 05:55:55 PM
Actually, if I reload the script and it gets it from the JAR. If I've inserted a live bug-fix patch using Netbeans debugger, I'll probably need to re-apply my live bug-fix patch again?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2014, 06:00:32 PM
Not sure what you mean. If you're talking about hot code replacement from Netbeans, that should just work, within its own limitations - there's no need to reload... oh, I think I see.

You mean you made a change, had Netbeans do hot code replacement, and then press F8? That should pick up the change as well, so it shouldn't be a problem. Unless you've got two copies of the source, but that'd be a bad idea. As a side note, hot code replacement of Janino-compiled scripts is kind of hit or miss.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on May 12, 2014, 06:10:21 PM
Yes, the hot code replacement is a tool I often use when debugging/testing. If F8 picks that up as well, all good.

Anyway I look forward to being able to do live data updates, it will help speed up the testing workflow a lot.

There is this other weird bug I found relating to this VLS missile launcher system , if I leave a missile with a FIGHTER collision class for too long, the game tries to cast it as a ShipAPI and does...weird things. Answer to that problem is not to leave your missile as FIGHTER collision class for too longer.

I think you'd like the look of the VLS missile launch animation and decent onto target, it's pretty cool.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 12, 2014, 07:09:26 PM
Fixed for the next release
Sweet. Many thanks  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: pyg on May 13, 2014, 05:03:55 PM
How are backgrounds (specifically the battle ones) used in a mod, as in how do I change what background is used?  I can find backgrounds in data/config/settings.json but I can't figure out how to specifically change the ones used in a battle.  I'm playing a mod with many absolutely lovely/brilliant backgrounds, so brilliant in fact I can't see a lot of what's happening in battle and would love to simply have battles be like the simulator, or at least toned down some/a lot.  In that vein any tips on how to tone down (turn off) the UI in combat?  I have a small screen (1366x768) and I like the mechanics of target selection but when it's a capital ship the weapons info blankets the screen.  I looked at the api but .graphics has nothing and .ui has mysteriously promising ValueDisplayMode (of which I intuitively choose minimal :)).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: pyg on May 15, 2014, 01:08:32 PM
Well the question about backgrounds I could have answered myself with a little effort.  The battle background is the same as the system and easily changed.  Sorry for the dumb/lazy question.  It might not be pretty but plain black looks more what imagine space would look like anyway.  I'm guessing the combat UI is not really moddable right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 15, 2014, 01:16:17 PM
You can change the colors of various UI elements in settings.json but the look is hardcoded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 15, 2014, 01:55:29 PM
Sorry for the dumb/lazy question.
I don't think your question was dumb or lazy. I think it was just so open ended it made it difficult to answer. There are several ways to change backgrounds. To answer your question thoroughly we'd have to describe each of them. In your situation I would have just modified the images themselves, making them darker.

I don't know much about UI modding, but there's always F11, which will toggle the interface during battle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: pyg on May 17, 2014, 06:36:00 PM
Sorry for the dumb/lazy question.
I don't think your question was dumb or lazy. I think it was just so open ended it made it difficult to answer. There are several ways to change backgrounds. To answer your question thoroughly we'd have to describe each of them. In your situation I would have just modified the images themselves, making them darker.

I don't know much about UI modding, but there's always F11, which will toggle the interface during battle.

You are overgenerous.  It was at least lazy as I didn't try anything first.  I replaced some backgrounds with all black and darkened some, both to the effect I wanted.  I'm going to shrink some stars next.  In terms of UI modding what I had in mind is something between F11 and full on UI.  I really like the stuff on the edge and the flux/hull indicators on friends and foes.  Most of the rest could go, especially all the crap on the bottom left as it confuses the edge indicators for me.  I didn't really expect the UI to be moddable, I just hoped that I was wrong.

@LazyWizard: Thanks for that, I might try and black out/hide some of the stuff I don't need.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 18, 2014, 08:24:02 AM
You are overgenerous.  It was at least lazy as I didn't try anything first.
Meh. Maybe. I'm sure you're better qualified to decide whether or not something you did was lazy than I am. I can't blame someone just for asking a question though. I've taken enough ridiculously long trips down seemingly short rabbit holes to appreciate the value in asking for directions from the beginning.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 20, 2014, 12:47:32 PM
I've run into a weird issue with portraitSprites and fleet Commanders.

1.  My Commanders all have the "default_portrait" set as their portraitSprite.  Their names are fine, but they don't have portraitSprites set.  Why is that?  Is there something I needed to do when I generated the Fleets?

2.  I'm not sure how to get the male / female-ness of the Commanders.  This doesn't seem to be a straightforward thing to evaluate, but I presume if I can convert the JSONArray of male names to check against, I could determine that via a match.

3.  I'm really getting confused by JSONArray sub-arrays.  I wanted to parse the "portraits" to get a random male/female portrait, but this doesn't work:

Code: java
    private String getPortrait(String factionID){
        try {
            JSONObject json = Global.getSettings().loadJSON("data/world/factions/" + factionID + ".faction");
           
            JSONArray maleFemale = json.getJSONArray("portraits");
            JSONArray male = maleFemale.getJSONArray(0);
            JSONArray female = maleFemale.getJSONArray(1);
            if(MathUtils.getRandomNumberInRange(0,100f) <= 50f){
                JSONObject portraitList = male.toJSONObject(male);
                String Name = portraitList.toString((int)MathUtils.getRandomNumberInRange(0,portraitList.length()-1));
                return Name;
            } else {
                JSONObject portraitList = female.toJSONObject(female);
                String Name = portraitList.toString((int)MathUtils.getRandomNumberInRange(0,portraitList.length()-1));
                return Name;
            }
        } catch (IOException | JSONException ex) {
            return "default_portrait";
        }       
        //return "default_portrait";
    }

At this point I'm tempted to dump all of the JSON data into a class as standard string arrays and do this the hard way, lol.  But surely this isn't such a nasty problem.  I think the main issue here is #1; something is preventing the portraits from being auto-generated...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2014, 12:53:36 PM
Real quick, re: #3 -
JSONArray maleFemale = json.getJSONArray("portraits");  
Should be:
JSONObject maleFemale = json.getJSONObject("portraits");  

With all that entails for the rest of the code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 20, 2014, 01:00:57 PM
OK.  I obviously need to practice this if I'm ever going to get better at using JSON, sigh.

I think I caught #1; it had to do with spawning fleets as Neutral, which doesn't have portraits defined.  Not quite sure I was doing that yet, but I presume I had a good reason, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2014, 01:07:01 PM
(Re: #2 - this is something I ran into and added to the API a month or so ago.)

OK.  I obviously need to practice this if I'm ever going to get better at using JSON, sigh.

Yeah, just a question of having a firm grasp on the actual format, I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 20, 2014, 04:36:24 PM
My "good reason" was about avoiding some file clutter, apparently; I was using Neutral to spawn the fake-fleets I use to lower memory consumption (kind of not really needed any more, but I still like the feature of not knowing what's in a fleet) and I guess when the fleets change Faction that doesn't reset the Commanders.  Easy fix for the core problem in the end, but I still need to work on dealing with JSON stuff for a couple of other things I want to try out :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 21, 2014, 12:19:07 PM
In faction JSON files fleets are composed of records with 2 numbers:
Code
	"fleetCompositions":{
"scout":{
"displayName":"Scout",
"maxFleetPoints":11,
"daysWorthOfSupplies":[30, 50],
"lyWorthOfFuel":[40, 60],
"extraCrewPercent":[80, 80],
"marinesPercent":[20, 20],
"ships":{
"tempest_Attack":[1, 1],
"wasp_wing":[1, 1],
},
},
So, I wonder, what does each number stand for?
Code
"tempest_Attack":[1, 1],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2014, 12:26:39 PM
Minimum/maximum number of ships with that variant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 21, 2014, 12:31:17 PM
Thanks a lot! I guessed something like that) But what will happen if "minimum" fleet exceeds the maxFleetPoints limit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2014, 12:36:54 PM
The minimum will still be added to the fleet. Also, at least one ship will be picked, even if the minimums are all 0 and all the ship costs exceed maxFleetPoints.

Edit: Oh, also, just noticed your post count - hi, and welcome to the forum :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 21, 2014, 12:40:39 PM
Quite clear explanation! Thanks for welcome too)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 23, 2014, 06:51:44 AM
Another question:
I try to make a total conversion mod by overriding several files in mod info.
Here's what I have:
Code
	"replace":[
"data/campaign/sim_opponents.csv",
"data/config/title_screen_variants.csv",
#"data/shipsystems/ship_systems.csv",
"data/missions/mission_list.csv",
"data/hulls/ship_data.csv",
"data/hulls/wing_data.csv",
"data/weapons/weapon_data.csv",
"data/world/factions/factions.csv",
],
If ship_systems is commented as above, I get an error:
Spoiler
Code
5355 [Thread-5] ERROR com.fs.starfarer.loading.SpecStore  - Ship system [phaseteleporter] not found in ship_systems.csv
5355 [Thread-5] ERROR com.fs.starfarer.loading.SpecStore  - Ship system [traveldrive] not found in ship_systems.csv
5392 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.RuntimeException: Fatal: ship_systems.csv is missing systems
java.lang.RuntimeException: Fatal: ship_systems.csv is missing systems
at com.fs.starfarer.loading.SpecStore.class(Unknown Source)
at com.fs.starfarer.loading.SpecStore.new(Unknown Source)
at com.fs.starfarer.loading.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.oOOO.A.?00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]
Where the hell is that onslaught? It is not mentioned in any of my files.
Well, I tried to override the systems file too. Even more mysterious:
Spoiler
Code
5483 [Thread-5] ERROR com.fs.starfarer.loading.SpecStore  - Ship system [phaseteleporter] not found in ship_systems.csv
5483 [Thread-5] ERROR com.fs.starfarer.loading.SpecStore  - Ship system [traveldrive] not found in ship_systems.csv
5518 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.RuntimeException: Fatal: ship_systems.csv is missing systems
java.lang.RuntimeException: Fatal: ship_systems.csv is missing systems
at com.fs.starfarer.loading.SpecStore.class(Unknown Source)
at com.fs.starfarer.loading.SpecStore.new(Unknown Source)
at com.fs.starfarer.loading.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.oOOO.A.?00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]
Of course, my file is not empty, so it should contain systems)
All works if I do not override files, but I really need a total conversion. Any ideas?
Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 23, 2014, 11:01:00 AM
Alright, found the reason myself.
Code
	"totalConversion":"true",
The documentation says that
Quote
totalConversion  - If set to "true", then no other mods can be loaded alongside it.
But it seems to be a bit more, since it helped. I guess it prevented something from vanilla jar to be loaded, though I'm not sure.
It would be great if the corresponding description is updated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on May 23, 2014, 03:47:48 PM
Quick question, is there a mod with commented out faction files? I'd like to learn the basics of adding a faction post 6.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 24, 2014, 10:13:29 AM
@celestis: Hmm, this is weird. The ship system related error went away when you set "totalConversion":true? Looking at the code, that seems... unlikely. Did update the mod_info documentation, btw.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 24, 2014, 11:54:45 AM
Quick question, is there a mod with commented out faction files? I'd like to learn the basics of adding a faction post 6.0
Not sure what you're asking for. Commented out faction files? Plenty of mods provide examples of adding factions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on May 24, 2014, 12:56:31 PM
Alright, so, since I have no idea how to proceed with this, time to put out a general call for help I guess.

I've currently got a ship system working on the upcoming Thresher-class CL which boosts all it weapons firing rates for a short period, and then inflict a malus to the ships firing rate while it's OUT; that appears to be functioning as intended though it doesn't appear to be reporting the Malus correctly.

However I want a visual effect to accompany the OUT stage, where the weapon ports emit steam as the ships weapons cool off.

The script I set up to this is as follows; as it's compiling fine I can't figure out why it isn't working, which is making fixing it a bit beyond me.

Spoiler
Code
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponSize;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript.State;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;
import java.util.*;
import org.lwjgl.util.vector.Vector2f;

public class OverheatSteam implements EveryFrameCombatPlugin {
    private CombatEngineAPI engine;
    private static final Map mag = new HashMap();
    private static final Map shipIDs = new HashMap();   
    private State state;
   
    static
    {
        // List those ships equipped with the "ms_overdrive" ship system
        shipIDs.put("ms_thresher", false);
    }

    static {
        mag.put(WeaponSize.SMALL, 1f);
        mag.put(WeaponSize.MEDIUM, 1.5f);
        mag.put(WeaponSize.LARGE, 2.5f);
    }

    @Override
    public void init(CombatEngineAPI engine) {
        this.engine = engine;
    }

    private final IntervalUtil interval = new IntervalUtil(0.1f, 0.1f);

    @Override
    public void advance(float amount, List events) {
        //ShipAPI ship;
        //CombatEntityAPI entity;
       
        //String spec;
       
        if (engine.isPaused()) {
            return;
        }

        interval.advance(amount);

        if (interval.intervalElapsed()) {
            float smokeSize = 0.8f + 0.4f * (float) Math.random();

            List<ShipAPI> ships = engine.getShips();

            for (ShipAPI ship : ships) {
                if (!shipIDs.containsKey(ship)) {
                    continue;
                }     
               
                ShipSystemAPI system = ship.getSystem();
               
                List<WeaponAPI> weapons = ship.getAllWeapons();

                if (system != null) {
                    if (system.isActive() && state == State.OUT) {
                        for (WeaponAPI weapon : weapons) {
                       
                            float smokeSizeValue = (Float) mag.get(weapon.getSize());

                            float velX = (float) Math.random() * 10f - 5f;
                            float velY = (float) Math.sqrt(25f - velX * velX);
                            if ((float) Math.random() >= 0.5f) {
                                velY = -velY;
                            }

                            engine.addSmokeParticle(weapon.getLocation(), new Vector2f(velX, velY), 30f * smokeSize * smokeSizeValue, 0.05f, 4f, new Color(130, 160, 130, 20));
                            engine.addSmokeParticle(weapon.getLocation(), new Vector2f(velX, velY), 15f * smokeSize * smokeSizeValue, 0.05f, 3f, new Color(180, 210, 180, 20));
                        }
                    }
                }
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on May 24, 2014, 03:04:51 PM
MShadowy: You never set your state variable. I don't think you can get the system state outside of a system stats script, though.

if (system.isActive() && !system.isOn()) should be equivalent to checking if the state is OUT, if I recall correctly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on May 24, 2014, 03:43:41 PM
Ah, yeah, that works perfectly.  Thanks, Lazy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 26, 2014, 08:48:20 AM
@Alex
Quote
@celestis: Hmm, this is weird. The ship system related error went away when you set "totalConversion":true? Looking at the code, that seems... unlikely. Did update the mod_info documentation, btw.
Yep, I'm surprised too. But looking through the callstack was of no help. I only added "totalConversion" and that's all. Thanks for updating docs!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 26, 2014, 09:56:50 AM
This is a really dumb question, but how can I add a mod to the forum?) The Mods seems to be locked for adding a new topic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on May 26, 2014, 10:16:32 AM
This is a really dumb question, but how can I add a mod to the forum?) The Mods seems to be locked for adding a new topic.

You make the thread in modding, make sure you have a functional downloadable build. And then ask a moderator to move it for you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on May 26, 2014, 10:21:43 AM
Ok, got it! Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sarducardun on May 27, 2014, 02:11:42 AM
Hey guys, I'm trying to start spriting but using GIMP 2.0 there is no way to create a 'circle 10' tool (the size of a small mount base) or any other even circle, which makes my chosen faction style a massive pain. I'm wondering if there is a free tool out there with even circles or any other tools I should try for SS sprites before settling?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on May 27, 2014, 02:18:22 AM
Hey guys, I'm trying to start spriting but using GIMP 2.0 there is no way to create a 'circle 10' tool (the size of a small mount base) or any other even circle, which makes my chosen faction style a massive pain. I'm wondering if there is a free tool out there with even circles or any other tools I should try for SS sprites before settling?

Try a circular mask?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on May 27, 2014, 02:27:56 AM
Use the circle select tool, create a selection of any size, edit the selection size manually to 10x10 in the tool dialog box (lower left corner for me), fill in circle with desired color or go to 'Edit->Stroke Selection' to create a circular line.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on May 27, 2014, 02:29:09 AM
I would recommend to copy/paste the vanilla mounts or to create a seperate image with the cutout vanilla mount which you could customize for your faction and then take it as a template.

On the other hand you could use Paint to draw circles and import these into Gimp.

I do agree that Gimp might be difficult to get used to but as soon as you get the hang of it it is a very powerful tool.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sarducardun on May 27, 2014, 02:43:37 AM
Well stroke selection refuses to make a ten px circle as well. :(
@ Tecrys, that was my initial idea but my weapons will be orbs, meaning they will need to be the same size or a twelve to work comfortably. Those orbs need dodging with increasingly smaller circles to make a rounded finish (quickly), then I need circular glows, also requiring even circles to centre on the mount effectively. All other weapon sizes have the same problem. Basically I want to be constantly using 'even' circles and gimp doesn't do any. :(
I could do it but it will take ages, I'm hoping there are easier tools.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on May 27, 2014, 03:33:30 AM
Make 'em with paint and import them into Gimp when they are finished.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sarducardun on May 27, 2014, 04:08:06 AM
Ok then, paint it is, Thanks guys.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on May 27, 2014, 08:31:00 AM
Gimp totally does uniform circles. Just hold down shift when using the oval select and it will snap to a circle. The bottom left corner of the image window will have the pixel count. It may be a different button on your computer, but its shift on mine.

It can be a pain to learn it, but Gimp can do anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 29, 2014, 08:08:50 PM
Silly question:

Is the top of the map at engine.getMapHeight() / 2  or engine.getMapHeight() / -2 ?

Got the answer (sorry, kind of a space cadet today, work was fun, lol).  Positive Y is the top of the map.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 29, 2014, 08:30:32 PM
Yep. Everything in the game uses the standard coordinate system, i.e. left to right and bottom to top.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on June 02, 2014, 09:13:49 AM
I'm unable to spawn a floating text:

Vector2f playerShipLoc = engine.getPlayerShip().getLocation();
engine.addFloatingText(playerShipLoc, "test", 20f, Color.red, engine.getPlayerShip(), 1f, 2f);
engine.addHitParticle(playerShipLoc, playerShipLoc, 5, 1, 1, Color.yellow);

This correctly spawns a particle on the ship, but never spawns a floating text. Am I doing something wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2014, 11:35:37 AM
This looks right to me. I just tried adding it to a test combat plugin, and it spawned the text.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on June 02, 2014, 05:43:18 PM
I think I'm doing something really dumb - help me out?

I had a working ship that I was testing - everything worked fine, but I thought it was too small. I resized the sprite, and also cropped off some superfluous transparent pixels at one border. I then redid the .ship file using trylobots editor, setting new bounds, weapons, and engines.

However, in game all of the weapons and engines are wrong! I've double checked that the sprite and .ship files got changed correctly. The editor loads the image and .ship just fine, and everything is in the right spot.

Is there any way the game is using a cached version of the .ship file? Its pretty much the only reason I can think of for this happening.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on June 02, 2014, 06:37:27 PM
I'm aware that it saves variants under /saves/missions

This can cause issues. Delete them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on June 02, 2014, 06:43:02 PM
This looks right to me. I just tried adding it to a test combat plugin, and it spawned the text.

Oh my. Forgot I disabled the floating text inside the options menu xD.

Derp.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on June 07, 2014, 01:23:45 AM
Thaago, I had a similar issue. The reason was that though I changed the image and all weapons&engines in Trylobot, the width and height attributes inside the .ship did not change. So the game treats the new image as having the old size => stretching occurs, moving all stuff from correct position. Try setting width and height manually to match the image dimensions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on June 07, 2014, 11:49:22 AM
Thaago, I had a similar issue. The reason was that though I changed the image and all weapons&engines in Trylobot, the width and height attributes inside the .ship did not change. So the game treats the new image as having the old size => stretching occurs, moving all stuff from correct position. Try setting width and height manually to match the image dimensions.

Oh, thats whats going on! I ended up just remaking the whole .ship file with the editor, but that certainly would have been easier. Thanks a bunch!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on June 07, 2014, 04:10:07 PM
Did a search for the following, but no obvious answers stood out, so here we go:

In a .ship file, does the 'SIZE' parameter make any difference where 'LAUNCH_BAY' or 'SYSTEM' 'TYPE'-weapon slots are concerned?

For that matter, is there any difference whether those same weapon slots, are set to the 'TURRET' or 'HIDDEN' 'MOUNT'-types?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on June 13, 2014, 02:53:58 PM
I haven't used the LAUNCH_BAY for very much - I always thought it was used for Fighter flight decks.  Then the new way of making flight decks came, haven't used it since.

The SIZE doesn't matter for any of those types, although for consistency's sake make them all the same size.

All of those weapon slots you asked will never show up in the game, (maybe SYSTEM will, but I haven't seen one yet).  Keep them as HIDDEN if you want to avoid any bugs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bulzeeb on June 24, 2014, 12:22:36 AM
Is there a way to mod the player's fleet strength to be reduced by a fraction so that ai fleets aren't running away all the time?
Title: The JARs, dammit.
Post by: Hyph_K31 on July 03, 2014, 01:46:31 PM
So, hey guys.

In the course of working on my mod, I've come across a rather curious issue that as yet, has me well and truly stumped. To those well versed in coding and such things, this issue my be trivially easy to fix - I and not one of these people...

So put it in as few words as possible; I am trying to switch my mod around so that the Mission, Hullmods, Scripts and Ship System folders are all contained in a JAR, for the purposes of certain scripts I would like to use, and ShaderLib. Nothing I put into this JAR appears to function in game, although the mod runs perfectly fine until to attempt to use something in the JAR, e.g; the built in hull mod all Gedune ships use. Missions do not appear either.

Would anyone be willing to help me with this little problem of mine?

EDIT;

I am using Netbeans.
Title: Re: The JARs, dammit.
Post by: LazyWizard on July 03, 2014, 01:53:23 PM
[...] Nothing I put into this JAR appears to function in game, although the mod runs perfectly fine until to attempt to use something in the JAR, e.g; the built in hull mod all Gedune ships use. Missions do not appear either.

Would anyone be willing to help me with this little problem of mine?

Judging by that description, the most likely culprit is a missing "jars" entry in your mod_info.json. A typo is also possible (the game won't crash if you enter a non-existent filename). The entry should look something like this:

Code
    "jars": ["jars/YourJarHere.jar"],

Edit: I should also point out that only compiled scripts (.class files) would be in these jars. Putting mission definitions, loose .java files, etc in a jarchive will do nothing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on July 03, 2014, 02:19:20 PM
Thanks a bunch, especially over Skype. Everything is OK now. Guaha-har.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: angrytigerp on July 04, 2014, 04:35:47 PM
So I'm starting to look at putting together a faction of my own, but first things first: artwork.

So looking at the guides for spriting, I find myself daunted at the task, but I am determined to make something of it. Plenty of time when I'm stuck on my ship (navy life tho) to fiddle with artwork. Few questions before I roll into my efforts, though:

1.) Right now, I'm fairly sure most of my ships will be symmetrical. To that extent, I intend to basically craft half the ship in my image program of choice (in my case, GIMP), then mirror it. Is this about right? Most people in their tutorials (i.e. on the spriting tutorial thread) seem to start with a perfectly symmetrical base, and I'm not sure if it's because they're insanely good or this is what they do.

2.) Am I even going along the right lines? Basically, I can't draw (i.e. by hand) to save my life, so I was going to basically be creating my ships' outlines with a line tool, then adding bits and pieces as necessary. I know, the right response is probably "do it however you want", it's not like I'm forced to do it one way or the other, but what major mods in the community are made this way? I just want to see that I can get the result I want, if I put the effort into it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ValkyriaL on July 05, 2014, 03:32:44 AM
Junk pirates are made that way, he draws an outline, adds pieces, and then makes them fit with hand drawn lines and colors, I believe Thule's Legacy are also made that way, i'm not sure on that one tho. most other mods are total kitbashing or hand drawn from top to toe.

if you put enough effort in, anything is possible, allow me to quote my brothers skype message of the day.

"Success is a matter of luck, just ask any failure."

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on July 08, 2014, 11:09:57 AM
Question time, again! ;)

I've recently started working on a new ship system (The basic kind), and I need to know how I might go about having this system degrade CR as it runs. Hopefully, this is easy to accomplish.

The idea here is that the system put enormous strain on the entire ship, and prolonged, repeated use results in the possibility of critical malfunctions. To that same end, It'd also be quite fantastic if there was a minuscule chance of this system overloading the ship on activation.

EDIT:

Tartiflette was kind enough to help me out with this one, although the CR aspect of the system is still proving troublesome.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on July 08, 2014, 06:39:31 PM
Here's one way to reduce CR only while a system is active:

1. Set 'peak CR sec' and 'CR loss/sect' to 0 for the ship in ship_data.csv
2. Add the following to the apply() function of your ShipSystemStatsScript:
Code
stats.getCRLossPerSecondPercent().modifyFlat(id, 5);
3. The '5' in the previous line of code is the percentage of CR loss per second. Set it to what ever you want.
4. Add the following to the unapply() function of your ShipSystemStatsScript:
Code
stats.getCRLossPerSecondPercent().unmodify(id);

Unfortunately, this method has the downside of sounding the CR alarm and saying 'Your flagship's CR is decreasing due to extended deployment.' I'll see if I can figure out a way to prevent that.

Would you mind if I steal this idea from you? One of my ships currently loses hull integrity while it's system is active, and I like this mechanic much more.

Edit 1: Looks like there's a better solution to this after all. For some reason I didn't think ShipAPI.secCurrentCR() existed... I'll post a better solution in a sec.

Edit 2: Ok, so it looks like my new solution has the same problem. I don't think there's a way to get rid of the initial alarm and message about losing CR. On the plus side, at least it's a good way to make sure players know about the mechanic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 08, 2014, 11:21:23 PM
Unfortunately, this method has the downside of sounding the CR alarm and saying 'Your flagship's CR is decreasing due to extended deployment.' I'll see if I can figure out a way to prevent that.
Sadly I had to get rid of the idea having all my ships loosing progressively CR because of the alarm: you'd loose your eardrum each time you'd deploy your fleet :-[

Edit 2: Ok, so it looks like my new solution has the same problem. I don't think there's a way to get rid of the initial alarm and message about losing CR. On the plus side, at least it's a good way to make sure players know about the mechanic.
I tried to use something like that:
@Override
        public void advance(float amount, CombatEngineAPI engine, ShipSystemStatsScript.State state) {

            if (engine.isPaused()) {
            return;
            }

            CLOCK.advance(amount);

            if (CLOCK.intervalElapsed() && state == State.ACTIVE) {
               
                CombatReadinessPlugin.applyCRToShip(CURRENTCR, ShipAPI ship);
                CURRENTCR -= CRDROP;
            }           
        }

But I still don't know how to code in JAVA and can't find the right syntax. I'm not sure this would activate the alarm though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on July 09, 2014, 01:06:56 AM
Would you mind if I steal this idea from you? One of my ships currently loses hull integrity while it's system is active, and I like this mechanic much more.
By all means! Thanks for the help - when I'm next at home I'll see about adding what you've suggested.

I may abandon the CR aspect of this system, depending on how annoying the alarm turns out to be. I hope that some other method exists, that bypasses the alarm.

Thanks again. ^^
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on July 09, 2014, 04:56:23 AM
I need to make sure this works. It isn't as easy to check as, say, a hull penalty (which does work with a negative value under HULL_BONUS), which clearly shows up on the refit screen once added.

I am creating the following hullmod:
(http://i.imgur.com/OtOYyJ1.png)
Batavian decks are fairly exposed and thus their guns are fairly vulnerable. To counter this weakness, Batavian ships often acquire deck crews that can make quick repairs or calibrations on-deck. This leaves the crew vulnerable though.

Quote
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class BatavianDeckCrews extends BaseHullMod {

   public static final float HEALTH_BONUS = 50f;
   public static final float CASUALTY_REDUCTION = -20f;
   public static final float ARMOR_BONUS = 10f;
   
   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
      stats.getArmorBonus().modifyPercent(id, ARMOR_BONUS);
      stats.getCrewLossMult().modifyMult(id, 1f - CASUALTY_REDUCTION * 0.01f);
      stats.getWeaponHealthBonus().modifyPercent(id, HEALTH_BONUS);
   }
   
   public String getDescriptionParam(int index, HullSize hullSize) {
      if (index == 0) return "" + (int) HEALTH_BONUS;
      if (index == 1) return "" + (int) CASUALTY_REDUCTION;
      if (index == 2) return "" + (int) ARMOR_BONUS;
      return null;
   }

    @Override
    public boolean isApplicableToShip(ShipAPI ship)
    {
        // Allows any ship with a batavian hull id
        return ( ship.getHullSpec().getHullId().startsWith("pb_"));   
    }
}

Does this properly have the following effects?:
+50% health bonus for visible weapons
20% casualty penalty
Ship armour bonus of 10
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on July 18, 2014, 03:43:13 AM
In need of some help again.

First I'll thank Dark Revenant for writing the initial script and helping to set it up, and Uomoz for further assistance.

My issue, I think is rather simple and relates to system generation, see below image.

Spoiler
(http://i.imgur.com/mG7romu.png)
[close]

And here is the script in its entirety:

Code
package data.scripts.world;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.SectorEntityToken;


public class GeduneShadowGen implements EveryFrameScript {
    
    boolean isDone = false;

    @Override
    public boolean isDone() {
        return isDone;
    }

    @Override
    public boolean runWhilePaused() {
        return true;
    }

    @Override
    public void advance(float amount) {
        isDone = true;
        // Run the generation code you want
        StarSystemAPI system = Global.getSector().getStarSystem( "Anar" );
        SectorEntityToken star = system.createToken( 0, 0 );
        SectorEntityToken GDstation = system.addOrbitalStation(star,45, 9600, 150,"Raiding Outpost", "gedune");
        GeduneSpawnPoint GDspawn = new GeduneSpawnPoint( sector, system, 6, 8, GDstation );
      
system.addSpawnPoint( GDspawn );
      
for( int i = 0; i < 5; i++ ) GDspawn.spawnFleet();
    }
}

I am currently in the process of getting my mod to interact better with the others, and this problem has fairly well halted my progress.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on July 18, 2014, 12:48:35 PM
Just a guess, but try replacing 'sector' with 'Global.getSector()'

Also, thanks for sharing your CR idea :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hyph_K31 on July 18, 2014, 01:09:31 PM
Thanks sundog, and you were right :D And so was Uomoz over Skype. The code has been changed to:

Code
        StarSystemAPI system = Global.getSector().getStarSystem( "Anar" );        
        SectorEntityToken star = system.createToken( 0, 0 );
        
        SectorEntityToken GDstation = system.addOrbitalStation(star,45, 9600, 150,"Raiding Outpost", "gedune");
        
GeduneSpawnPoint GDspawn = new GeduneSpawnPoint(Global.getSector(), system, 6, 8, GDstation );
        system.addSpawnPoint( GDspawn );
for( int i = 0; i < 5; i++ ) GDspawn.spawnFleet();

Although now there's a new problem!

In the same script. Yikes. What I'm trying to do now is set up a convoy from one location to another. Now... this should be trivial, right? Well, I'm Hyph.

There is now this snippet of code in the same script:

Code
       StarSystemAPI systemD = Global.getSector().getStarSystem("Gedui");
        systemD.addScript(new GeduneRaidConvoySpawnPoint( Global.getSector(), systemD, GDstation, systemD.getEntityByName("Multiplex")));

And it doesn't work, at all. It's supposed to send a convoy from the Raiding Outpost in Anar, to the Multiplex in Gedui.

Netbeans gives this error:

Spoiler
(http://i.imgur.com/iJON6jV.png)
[close]

And you're very much welcome Sundog :)

EDIT:

Dark Revenant has helped fix this! The alarm is off now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 18, 2014, 01:11:12 PM
Does this properly have the following effects?:
+50% health bonus for visible weapons
20% casualty penalty
Ship armour bonus of 10

Sorry - totally missed this.

Yeah, that should work, since your CASUALTY_REDUCTION is negative.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on July 24, 2014, 06:29:38 PM
I have a problem with one of the weapons in my mod.

It is a laser that gives an effect when it reaches maximum beam intensity, but the visual cue for the laser effect is currently pretty poor as you can basically only tell by looking at beam intensity. To try and make it more visible I tried to make the turret sprite animated. So that when you are fireing the gun the animation coinside with the beam effect maxima. However, the problem I have encountered is that if you constantly hold down the mouse button (as for continious fire), the gun animation and the beam intensity becomes out of synch, thus ruining the whole idea of it acting as a visual cue.

I currently have the gun set to the following parameters.

Weapon stats.
Chargeup: 5 sec
Chargedown: 2 sec
Burstsize: 1

Weapon animation.
Number of Frames: 70
Framerate: 10

With these settings the beam intensity and the animation works perfectly fine for the first shot, but for the second shot the animation is ~0,5-1 sec too fast compared to the beam intensity. Why is that?
I thought one would simply match chargeup+chargedown time with animation lenght to make it synched, but apparently I'm missing something.

If anyone could help with this that would be great!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 25, 2014, 12:50:55 AM
For your problem, I think you just missed to add the 1 sec of burst size (witch for beam mean time at full power) so you need a 80 frames animation.

I had some trouble with animations too: using the "base animate on fire effect" script, if you continuously press the firing button, the animation play only once, but the gun keep firing. I'd be VERY interested in a solution for that. There is also the problem with guns chargeup that play their animations even when they don't have enough flux room to actually fire, but this one seems more difficult to solve exept if we someday get the possibility to add several layers of animation on the same weapon...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 26, 2014, 11:28:55 AM
I seem to have problems with variables not getting set / reset in EveryFrameCombatPlugin, which is probably causing a number of bugs. 

Any ideas why I'm having trouble with this code?  Here, I should be seeing an event on frame 20, but it appears I'm not seeing any event here at all.  I'll probably test this with a sound or something to verify that it's that and not a bug in ShaderLib at this point, but it's been pretty frustrating, as I keep getting told that the code I'm invoking should produce an effect, yet nothing happens.

Spoiler
Code: java
package data.scripts.plugins;

import java.util.List;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.CollisionClass;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipHullSpecAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.util.IntervalUtil;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import org.dark.shaders.light.LightShader;
import org.dark.shaders.light.StandardLight;
import org.lwjgl.util.vector.Vector3f;


public class ShipPhysics implements EveryFrameCombatPlugin {

private CombatEngineAPI engine;
        private float height;
        private float width;
        private int wait;
        private StandardLight sunLight = null;
       
        private final IntervalUtil sunInterval = new IntervalUtil(15f, 15f);
       
        public static Map darkMap = new HashMap();
        public static Map hulkMap = new HashMap();

        @Override
public void init(CombatEngineAPI engine) {
this.engine = engine;
                this.height = engine.getMapHeight() / 2f;
                this.width = engine.getMapWidth() / 2f;
                this.wait = 0;
                sunLight = null;
}

        @Override
public void advance(float amount, List events)
{
            if (engine.isPaused()) return;
            wait += 1;
            if(wait > 1000){
                wait = 50;
            }
            //sunInterval.advance(amount);
            //if(sunInterval.intervalElapsed()){
                //StandardLight
                //Create the new light
            if(wait == 20){
                sunLight = new StandardLight();
                sunLight.setColor(255,255,255);
                sunLight.setType(3);
                Vector3f dir = new Vector3f(0.57735f, 0.57735f, 0.57735f);
                //sunLight.setLifetime(15f);
                sunLight.makePermanent();
                sunLight.setDirection(dir);
                sunLight.setIntensity(50.0f);
                sunLight.setSpecularIntensity(50.0f);
                LightShader.addLight(sunLight);
            }
           
            //Gets all ships;
            for (ShipAPI ship : engine.getShips()){
                if(!darkMap.containsKey(ship)){
                    ship.getSpriteAPI().setColor(new Color(32,32,32,255));
                    for(WeaponAPI weapon : ship.getAllWeapons()){
                        if(!weapon.getSlot().isHardpoint() && !weapon.getSlot().isDecorative() && !weapon.getSlot().isSystemSlot()){
                            weapon.getSprite().setColor(new Color(32,32,32,255));
                        }
                    }
                    darkMap.put(ship,ship);
                }
               
                if(ship.isHulk() && !hulkMap.containsKey(ship)){
                    ship.getSpriteAPI().setColor(new Color(32,32,32,255));
                    for(WeaponAPI weapon : ship.getAllWeapons()){
                        if(!weapon.getSlot().isHardpoint() && !weapon.getSlot().isDecorative() && !weapon.getSlot().isSystemSlot()){
                            weapon.getSprite().setColor(new Color(32,32,32,255));
                        }
                    }
                    hulkMap.put(ship,ship);                   
                }
               
                MutableShipStatsAPI stats = ship.getMutableStats();
                String id = ship.getFleetMemberId();
               
                if(!ship.isRetreating() && !ship.isLanding()&& !ship.isShuttlePod() && !ship.getTravelDrive().isOn() && !ship.getTravelDrive().isActive()){
                    Vector2f pos = ship.getLocation();
                    float posX = pos.getX();
                    float posY = pos.getY();

                    if(posX > 0 && posX >= width){
                        ship.getLocation().x = width;
                    } else if (posX < 0 && posX <= -width){
                        ship.getLocation().x = -width;
                    }

                    if(posY > 0 && posY >= height){
                        ship.getLocation().y = height;
                    }else if (posY < 0 && posY <= -height){
                        ship.getLocation().y = -height;
                    }               
                }
                if(ship.isHulk())
                {
                    //Makes Hulks slow down over time, instead of drifting endlessly.
                    Vector2f hulkVec = ship.getVelocity();
                    hulkVec.x *= 0.997f;
                    hulkVec.y *= 0.997f;
                    ship.setCollisionClass(CollisionClass.SHIP);
                    continue;
                }
               
                //WARNING!  THIS IS WHERE FRIGATES AND HULKS STOP BEING PROCESSED.
                if (ship.isFrigate() && !ship.isHulk())
                {
                    if (ship.getPhaseCloak() == null)
                    {
                        ship.setCollisionClass(CollisionClass.FIGHTER);
                        continue;
                    }
                }
               
                //Check for Stations.  If present, reduce their velocity to nearly zero every frame.     
                ShipHullSpecAPI shipHull = ship.getHullSpec();
                String hullName = shipHull.getHullId();
                if(hullName.contains("neutral_marlene_station") || hullName.contains("neutral_jean_station"))
                {
                    Vector2f stationVec = ship.getVelocity();
                    stationVec.x *= 0f;
                    stationVec.y *= 0f;
                    stats.getMaxSpeed().modifyMult(id, 0.000001f);
                    stats.getAcceleration().modifyMult(id, 0.000001f);
                    stats.getMaxTurnRate().modifyMult(id,0.000001f);
                    stats.getTurnAcceleration().modifyMult(id,0.000001f);
                    continue;
                }
               
                //Don't do any of this stuff if not a Destroyer+
                if (ship.isFighter() || ship.isShuttlePod() || ship.isFrigate() || ship.isDrone() || ship.isHulk())  continue;
               
                float penalty = 12.5f;
                if(ship.isCruiser()) penalty = 25f;
                if(ship.isCapital()) penalty = 50f;
               
                //Gets the ship's velocity, expressed as a vector.
                Vector2f shipVec = ship.getVelocity();
                float shipSpeed = (float) Math.sqrt(Math.abs(shipVec.getX() * shipVec.getX()) + Math.abs(shipVec.getY() * shipVec.getY()));
                float maxSpeed = (float) stats.getMaxSpeed().getBaseValue();
                float speedPenalty = Math.min(Math.max(0.0f,(shipSpeed / maxSpeed) * 100.0f),penalty);
                stats.getMaxTurnRate().unmodify(id);
                stats.getTurnAcceleration().unmodify(id);
                stats.getMaxTurnRate().modifyPercent(id,-speedPenalty);
                stats.getTurnAcceleration().modifyPercent(id,-speedPenalty);
               
               
               
                //public MutableStat getMaxTurnRate();
                //public MutableStat getTurnAcceleration();
               
                //Converts the player's heading (in degrees) back to unit vectors.
                Vector2f rotVec = new Vector2f ((float) Math.cos(ship.getFacing() * 3.14159f / 180f), (float) Math.sin(ship.getFacing() * 3.14159f / 180f));
                //Gets the "right" vector, i.e. perpendicular to the forward axis
                Vector2f rightVec = new Vector2f(rotVec.getY() * -1.0f,rotVec.getX());
                //Dot products of the two vectors
                float dotForward = Vector2f.dot(shipVec, rotVec);
                float dotRight = Vector2f.dot(shipVec, rightVec);
                //Gives us the forward and rightward vectors of current velocity
                Vector2f forwardVelocity = new Vector2f(rotVec.getX() * dotForward, rotVec.getY() * dotForward);
                Vector2f rightVelocity = new Vector2f(rightVec.getX() * dotRight, rightVec.getY() * dotRight);
                //Final conversion, drops the rightward component's magnitude while preserving the forward component.
                //The multiplier 0.02f is our tuning variable; try different amounts to play with the "friction".
                Vector2f.add(shipVec,new Vector2f(rightVelocity.getX() * -0.02f, rightVelocity.getY() * -0.02f),shipVec);
               
                //This is an alternative behavior; it keeps forward velocity (towards the forward vector) constant but lowers...
                //"right" velocity, resulting in a ship with an "inertialess" drive.  It might be useful for various behaviors.
                //Commented out, because the above behavior is closer to classic land / sea movement.
                //shipVec = shipVec.add(forwardVelocity,new Vector2f(rightVelocity.getX() * -0.02f, rightVelocity.getY() * -0.02f),shipVec);
            }
}
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on July 26, 2014, 02:20:22 PM
EveryFrameCombatPlugins are only initialized once in any instance of Starsector; this is a bug in Starsector that is being fixed later.

Basically, assume all variables to be static.  This means you'll have to add an engine-change check at the start of the advance block to reset the state variables.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 26, 2014, 05:49:27 PM
That's a thought; I'll check it out.  In the meantime, I got it working via code changes elsewhere, although there are a lot of little wrinkles that need to be dealt with first :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on July 27, 2014, 02:04:42 PM
For your problem, I think you just missed to add the 1 sec of burst size (witch for beam mean time at full power) so you need a 80 frames animation.

I had some trouble with animations too: using the "base animate on fire effect" script, if you continuously press the firing button, the animation play only once, but the gun keep firing. I'd be VERY interested in a solution for that. There is also the problem with guns chargeup that play their animations even when they don't have enough flux room to actually fire, but this one seems more difficult to solve exept if we someday get the possibility to add several layers of animation on the same weapon...

Thanks, the problem was of course fixed by adding 1s of animation, I'm dumb as a rock ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on July 27, 2014, 07:13:44 PM
Is there any easy way to "hide" a .java script from Starsector so that it ignores it completely (aside from just removing the file)?

I just want to temporarily disable WIP scripts so that I can play the game to test other things in the meantime.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on July 27, 2014, 08:05:13 PM
I just put my work in progress files in separate subfolders, otherwise I'm not really sure what else you need.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on July 27, 2014, 08:07:00 PM
Oh, and while we're at it, how do you find the target ship and impact point for the weapon from an OnHitEffectPlugin?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 28, 2014, 12:50:23 AM
Is there any easy way to "hide" a .java script from Starsector so that it ignores it completely (aside from just removing the file)?
I generaly change the extention to  "MyScript.java.WIP" (caps to keep it visible) that way I don't mess my hierarchy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on July 28, 2014, 01:02:01 AM
Oh, and while we're at it, how do you find the target ship and impact point for the weapon from an OnHitEffectPlugin?

public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine)

The Vector2f point parameter is the impact point
the CombatEntityAPI target is the ...target entity. The API for the CombatEntity will not give you the API methods for the ship directly. This is because there may be instances where your projectile hit, say, another missile, or an asteroid etc.

So what you should be doing then is check if it is an instance of a ShipAPI, then if it is a ShipAPI we can cast it as a ship or create an reference to the ShipAPI interface of the object, then do something like check if it's a frigate.

We'll then say, if it is a frigate, apply some damage to that point.
Code: java
example 1
if (target instanceof ShipAPI) {
    impactedShip = (ShipAPI)target;
    boolean checkFrigate = impactedShip.isFrigate();
          if (checkFrigate){
       engine.applyDamage(target, point, projectile.getDamageAmount(), projectile.getDamageType(), projectile.getEmpAmount(), false, true, projectile.getSource())
        {
}

example 2
if (target instanceof ShipAPI) {
    boolean checkFrigate = ((ShipAPI)target).isFrigate();
          if (checkFrigate){
       engine.applyDamage(target, point, projectile.getDamageAmount(), projectile.getDamageType(), projectile.getEmpAmount(), false, true, projectile.getSource())
        {
}

Or at least something like that. There is a lot of coding examples around, that's just off the top of my head.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on July 28, 2014, 06:11:04 AM
Ok, before I slap an query on the API request thread. Is there anywhere in the API that allows you to spawn the debris particles? I speak of the armour/shrapnel debris sprites under \starsector-core\graphics\debris.

At the moment I have created a projectile launcher for the sprites. As projectiles I have to put up with a stupid bullet trail, and as a rocket it shows up with the little diamond warnings. Either way not really happy with it.

Is there a way of spawning the debris particles without it looking rubbish?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on July 28, 2014, 08:10:00 AM
Thanks Debido, that's what I was looking for!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JDCollie on August 01, 2014, 02:57:12 PM
Just out of curiousity, how difficult would it be to create a "persistence" mod, which keeps track of ships you've lost, and the number of ships (by class) that ships in your fleet have killed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on August 01, 2014, 08:39:26 PM
Just out of curiousity, how difficult would it be to create a "persistence" mod, which keeps track of ships you've lost, and the number of ships (by class) that ships in your fleet have killed?

The difficulty would depend on how important playing nicely with other mods is to you.

You can track all of that fairly easily by creating a custom fleet interaction dialog and processing the results of backFromEngagement(), a method that provides a neat list of disabled/destroyed fleet members per side after each battle. However, this wouldn't work alongside mods that use their own custom encounter dialogs.

You could also write a combat plugin that keeps track of deaths in campaign battles and stores it in sector data. That'd be slightly more involved as you'd need to perform all the death checks yourself, but it should work universally.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on August 01, 2014, 09:31:45 PM
You could also write a combat plugin that keeps track of deaths in campaign battles and stores it in sector data. That'd be slightly more involved as you'd need to perform all the death checks yourself, but it should work universally.

Make sure that, if you do this, you check to make sure the ship has a corresponding fleet member (check this when it enters combat as this is much harder when it's a hulk already).  Some mods add ships mid-combat, such as the Interstellar Imperium's TITAN.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on August 02, 2014, 05:33:08 AM
Yes, I'd definitely say you would want to wait for .6.5a's new CombatFleetManagerAPI.getDeployedFleetMemberEvenIfDisabled() before implementing such a system. It will save you so many headaches. I believe you can then just check if getFleetMember() is null to see if it's spawned through code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on August 03, 2014, 12:30:50 PM
Guys, how does the maneuvering jets system work? I want to make several specific engines on my custom ship work only when the system is active, but they are operational always. I looked at Eagle and other ships featuring this system and searched system scripts, but found no clue of how to specify which engines are affected. Could anyone reveal the secret please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on August 03, 2014, 01:33:09 PM
Contrail size = -128 flags the engine as system-activated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JDCollie on August 03, 2014, 01:58:05 PM
Yes, I'd definitely say you would want to wait for .6.5a's new CombatFleetManagerAPI.getDeployedFleetMemberEvenIfDisabled() before implementing such a system. It will save you so many headaches. I believe you can then just check if getFleetMember() is null to see if it's spawned through code.

Hmm, k. Thanks Lazy and Dark :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on August 03, 2014, 02:16:51 PM
Thanks, Dark.Revenant! Didn't think that this was working as a flag for something. But actually not -128, but +128.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lakis on August 03, 2014, 06:50:21 PM
How would one start DevMode in Starsector?

I'm looking to test a couple ships and their new stats but I don't  want to spend the first hour or two building up the money required....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on August 03, 2014, 07:24:13 PM
Starsector/starsector-core/data/config/settings.json

change this line

Code


##############################################################
# These settings CAN NOT be changed by mods.
# You can still change them yourself, though.
##############################################################

"vsync":true,
"fps":60, # fps only used if vsync is false
"devMode":false,    <=========================================================  to true to enable devmode.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lakis on August 03, 2014, 08:59:05 PM
Thank you Flash, I was waiting before I headed towards the actually debugging for an answer.

Spoiler
Tried to start, fixed a myriad of issues due to first time testing things out. mostly captializations and stuff. as soon as I hit my modplugin though is has this issue, spoilered to reduce size.


Spoiler
Code
9655 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.RuntimeException: Error compiling [data.scripts.world.msincModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.world.msincModPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: data.scripts.world.msincModPlugin
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:165)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more

This is the modplugin that it is referring to.
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

import data.scripts.world.msincSpawnPoint;
//import data.scripts.omnifac.AddOmniFac;

public class msincModPlugin extends BaseModPlugin
{
    private static void initmsinc()
    {
        try
         {
            Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.ExerelinGen");
            return;// Exerelin mod found so skip generation
       }
        catch (ClassNotFoundException ex)
       {
         // Exerelin mod not found so continue and run normal generation code
            new msincSectorGen().generate(Global.getSector());
    }

    @Override
    public void onNewGame()
    {
        // Calling a separate method avoids duplicate code with onEnabled()
        initmsinc();
    }
}
[close]

Trying to figure it out at the moment, but any input would be appreciated.
[close]

Figured out the problem, though after that there are more problems to solve... yay!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 07, 2014, 05:58:05 PM
Is there currently any way to get shield upkeep?

I tried using Global.getSettings().loadCSV("data/hulls/ship_data.csv"); but it only gave me information about the ships in my mod. I'm assuming I can't access other info with it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 07, 2014, 06:40:30 PM
Hmm. Can you try SettingsAPI.getMergedSpreadhsheetDataForMod() and pass in "starsector-core" for the masterMod parameter? I *think* that should work. It's not actually strictly intended to, but.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on August 07, 2014, 07:33:06 PM
Alright a few things:

Item 1: I need to reduce text clutter in a faction home system. How do I name a planet/moon so that it's name does not show up on the map, but otherwise displayed when clicked on, hovered over etc. If I give a moon a name of 'Null' it's name is no longer on the map, reducing clutter. However when clicking on, or hovering over it's name is of course null.

Item 2: Fighter death detection

Here is the excerpt for the death detection:

Code: java
           if (ship.isHulk() == true && ship.isFighter() && !ship.isDrone() && !ship.isShuttlePod()) {
                ShipAPI randShip = engine.getShips().get(0);
                for (Object wing : spawnedWings) {
                    if (wing == ship.getWingToken()) {
                        FighterWingAPI FW2 = ship.getWing();
                        List<ShipAPI> wMembers = FW2.getWingMembers();
                        isSpawnedWing = true;
                    }
                }

                if (isSpawnedWing) {
                    //engine.applyDamage(ship, ship.getLocation(), 1000000f, DamageType.ENERGY, 0f, true, true, randShip);
                    //alliedFighter++;
                    continue;
                }

                float wingCR = ship.getWingCRAtDeployment();
                float wingRemainingCR = ship.getRemainingWingCR();
                FighterWingAPI FW = ship.getWing();

                boolean isAlive = true;
                //using a try/catch in case the wing name is not the id+wing which will cause an NPE
                try {
                    List<ShipAPI> wMembers = FW.getWingMembers();
                    int j = 0;
                    for (ShipAPI w : wMembers) {
                        if (w.isAlive() || w.isLanding()) {
                            j++;
                        }

                    }
                    //if there is a carrier, there are no alive ships, no CR and the members list is empty (could be simplified)
                    if (isCarrierAvailable && j == 0 && wingRemainingCR < 0.000001f) {
                        spawnedWings.add(ship.getWingToken());
                        alliedFighterWing++;
                        String wingName = ship.getHullSpec().getHullId();
                        wingName += "_wing";
                        engine.getFleetManager(FleetSide.PLAYER).spawnShipOrWing(wingName, getSafeSpawn(0), 90f, CrewXPLevel.REGULAR, 3f);

                        //if there is not a carrier, and there are no other members in the wing
                    } else if (!isCarrierAvailable && (j == 0 || wMembers.isEmpty())) {
                        spawnedWings.add(ship.getWingToken());
                        alliedFighterWing++;
                        String wingName = ship.getHullSpec().getHullId();
                        wingName += "_wing";
                        engine.getFleetManager(FleetSide.PLAYER).spawnShipOrWing(wingName, getSafeSpawn(0), 90f, CrewXPLevel.REGULAR, 3f);
                    }
                } catch (NullPointerException e) {
                    String error = "Nope";
                }
                //alliedFighter++;
                //engine.applyDamage(ship, ship.getLocation(), 1000000f, DamageType.ENERGY, 0f, true, true, randShip);

            }

This code works brilliantly when there are no carriers, but as soon as carriers are on the playing field...weird things happen, and eventually I run out of fighter wings. Any help in better fighter death detection would be greatly appreciated.

If you want to see Fighter Wing bugs caused by carriers this will crop them up after about 15-20 respawns. Sometimes they even leave vector markers on the combat map.

The code works almost all the time, but I am unaware of any other variables effecting fighter death.

Here is the whole code WIP

http://pastebin.com/4vTsRDpq

I have about 4-5 modders who are wanting to see reliable fighter wing death so Fighter-Wings-As-A-Hullmod can be achieved, so it's fairly high priority.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 07, 2014, 09:01:48 PM
Thanks once again Alex. That seems to have worked swimmingly :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on August 08, 2014, 08:00:45 AM
Hmm. Can you try SettingsAPI.getMergedSpreadhsheetDataForMod() and pass in "starsector-core" for the masterMod parameter? I *think* that should work. It's not actually strictly intended to, but.

Would there be any reason this wouldn't work with skill/aptitude data? I've tried this before and it just caused a crash.

Here's the code I used:
Code
    static void reloadCSVData() throws JSONException, IOException
    {
        APTITUDE_IDS.clear();
        SKILL_IDS.clear();

        Global.getLogger(Respec.class).log(Level.DEBUG,
                "Loading aptitudes...");
        JSONArray aptitudeData = Global.getSettings().getMergedSpreadsheetDataForMod( // <---- Crashes here
                "id", "data/characters/skills/aptitude_data.csv", "starsector-core");
        for (int x = 0; x < aptitudeData.length(); x++)
        {
            JSONObject tmp = aptitudeData.getJSONObject(x);
            String id = tmp.getString("id");
            String source = filterModPath(tmp.optString("fs_rowSource", null));
            if (id.isEmpty())
            {
                Global.getLogger(Respec.class).log(Level.DEBUG,
                        "Ignoring empty CSV row");
            }
            else
            {
                Global.getLogger(Respec.class).log(Level.DEBUG,
                        "Found aptitude \"" + id + "\" from mod " + source);
                APTITUDE_IDS.add(id);
            }
        }

        Global.getLogger(Respec.class).log(Level.DEBUG,
                "Loading skills...");
        JSONArray skillData = Global.getSettings().getMergedSpreadsheetDataForMod(
                "id", "data/characters/skills/skill_data.csv", "starsector-core");
        for (int x = 0; x < skillData.length(); x++)
        {
            JSONObject tmp = skillData.getJSONObject(x);
            String id = tmp.getString("id");
            String source = filterModPath(tmp.optString("fs_rowSource", null));
            if (id.isEmpty())
            {
                Global.getLogger(Respec.class).log(Level.DEBUG,
                        "Ignoring empty CSV row");
            }
            else
            {
                Global.getLogger(Respec.class).log(Level.DEBUG,
                        "Found skill \"" + id + "\" from mod " + source);
                SKILL_IDS.add(id);
            }
        }

        Global.getLogger(Respec.class).log(Level.INFO,
                "Found " + APTITUDE_IDS.size() + " aptitudes and "
                + SKILL_IDS.size() + " skills");
    }

And the crash:
Spoiler
Quote
35813 [Thread-5] DEBUG org.lazywizard.respec.Respec  - Loading aptitudes...
35891 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.NullPointerException
java.lang.NullPointerException
        at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
        at com.fs.starfarer.settings.StarfarerSettings$1.getMergedSpreadsheetDataForMod(Unknown Source)
        at org.lazywizard.respec.Respec.reloadCSVData(Respec.java:39)
        at org.lazywizard.respec.RespecModPlugin.onApplicationLoad(RespecModPlugin.java:13)
        at com.fs.starfarer.loading.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
        at com.fs.oOOO.A.?00000(Unknown Source)
        at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
        at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 08, 2014, 12:34:38 PM
Hmm. Can you try SettingsAPI.getMergedSpreadhsheetDataForMod() and pass in "starsector-core" for the masterMod parameter? I *think* that should work. It's not actually strictly intended to, but.

Would there be any reason this wouldn't work with skill/aptitude data? I've tried this before and it just caused a crash.

Seems to work for me, including a test w/ a mod that actually had a file to merge with one from the core. It's possible that you brought this up before and I'd fixed the crash since then, though. That kind of rings a bell.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on August 09, 2014, 03:47:34 AM
I keep getting the following error on compile:
Expression "List < ShipEngineControllerAPI.ShipEngineAPI > engines_list" is not an lvalue

Here is the offending line (Netbeans says it's fine for whatever reason):
List<ShipEngineControllerAPI.ShipEngineAPI> engines_list = player.getEngineController().getShipEngines();

I just want to make a List<ShipEngineControllerAPI.ShipEngineAPI> so I can iterate through all the player's engines and check isDisabled()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on August 09, 2014, 04:11:54 AM
I assume you've done something like, I don't know what interface you're using, but let's be generic.
Code: java
        CombatEngineAPI engine = Global.getCombatEngine();
        ShipAPI player = engine.getPlayerShip();
        List<ShipEngineControllerAPI.ShipEngineAPI> engines_list = player.getEngineController().getShipEngines();

That's valid code for me. It might be best to pastebin the entire code so we have a better idea of what's happening.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on August 09, 2014, 08:10:31 AM
I keep getting the following error on compile:
Expression "List < ShipEngineControllerAPI.ShipEngineAPI > engines_list" is not an lvalue

Here is the offending line (Netbeans says it's fine for whatever reason):
List<ShipEngineControllerAPI.ShipEngineAPI> engines_list = player.getEngineController().getShipEngines();

I just want to make a List<ShipEngineControllerAPI.ShipEngineAPI> so I can iterate through all the player's engines and check isDisabled()

Is this a loose script? Janino doesn't support generics; you'll need to use a jar if you want to include them, same with for-each loops. So basically anything that makes iteration compact and easy to read. ;)

If you want to keep it as a loose script, here's how you'd iterate over the engines without using generics:
Code: java
        for (Iterator engines = player.getEngineController().getShipEngines().iterator(); engines.hasNext(); )
        {
            ShipEngineControllerAPI.ShipEngineAPI engine
                    = (ShipEngineControllerAPI.ShipEngineAPI) engines.next();
            
            if (engine.isDisabled())
            {
                // Do stuff here
            }
        }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on August 09, 2014, 09:06:58 AM
Gaps in orbital rings. How do I go about fixing this? I haven't had this probelm with the Zorg mod's rings, and I've used the same method for both PB and TuP. Yet I keep getting these gaps with PB and TuP, no matter what I do. I've tried everything, from reducing or increasing the width of band within the texture, width of band in the game, to altering the actual image and the location of the rings therein. Changing the orbit, etc., of the ring doesn't do anything either. The larger the orbit, the more artifacts show up, but always with the same gaps (equal in size to the actual artifact).

Example:
Spoiler
(http://i.imgur.com/mvU8rtI.png)
[close]

Any ideas? I just want these rings to be completely interconnected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 09, 2014, 10:38:42 AM
Are the width/height of the ring texture a power of two? If that's not it, I'd start with the vanilla ring texture and go from there to see where what you're doing deviates...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on August 09, 2014, 10:45:09 AM
Are the width/height of the ring texture a power of two? If that's not it, I'd start with the vanilla ring texture and go from there to see where what you're doing deviates...

Yes, they are a power of two. And I've based the ring texture on vanilla. Well, I based the Zorg rings on vanilla, and based the newer rings off the Zorg rings. I am so lost as to why it is generating these gaps. But, I will start some rings from scratch and see if I can't crack this nut. Thanks for the reply.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 09, 2014, 11:12:08 AM
Hmm, weird. Not seeing anything that would cause this just from looking at the code; hope you can narrow it down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on August 09, 2014, 12:05:54 PM
Hmm, weird. Not seeing anything that would cause this just from looking at the code; hope you can narrow it down.

Well, at first I thought it was just because I added the rings to a station, instead of a planet. So I wasn't too alarmed. But in the image above, I put the rings around that planet, and the problem still persists. Anyway, I'll let you know what causes it, once I figure it out for myself.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on August 09, 2014, 12:44:24 PM
I keep getting the following error on compile:
Expression "List < ShipEngineControllerAPI.ShipEngineAPI > engines_list" is not an lvalue

Here is the offending line (Netbeans says it's fine for whatever reason):
List<ShipEngineControllerAPI.ShipEngineAPI> engines_list = player.getEngineController().getShipEngines();

I just want to make a List<ShipEngineControllerAPI.ShipEngineAPI> so I can iterate through all the player's engines and check isDisabled()

Is this a loose script? Janino doesn't support generics; you'll need to use a jar if you want to include them, same with for-each loops. So basically anything that makes iteration compact and easy to read. ;)

If you want to keep it as a loose script, here's how you'd iterate over the engines without using generics:
Code: java
        for (Iterator engines = player.getEngineController().getShipEngines().iterator(); engines.hasNext(); )
        {
            ShipEngineControllerAPI.ShipEngineAPI engine
                    = (ShipEngineControllerAPI.ShipEngineAPI) engines.next();
            
            if (engine.isDisabled())
            {
                // Do stuff here
            }
        }

Thanks, that appears to have solved the issue- script works like a charm now! Using generics was causing the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on August 09, 2014, 07:18:44 PM
Kazi - I'd suggest you start compiling your code one day soon, it's going to make aspects of programming development better.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on August 10, 2014, 04:02:34 AM
Alex, I think I figured out what caused the problem I was having with the rings. And as usual it is something ridiculously silly. The newer rings I made were 2 pixels too high.  ::)

I can't believe I missed that!

Spoiler
(http://i.imgur.com/WBKvHxk.png)
[close]
Aye, it is working now.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on August 16, 2014, 01:54:00 AM
Is there a list of arguments for collisionClass? It affects the sound on projectile collision right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on August 16, 2014, 02:10:51 AM
Is there a list of arguments for collisionClass? It affects the sound on projectile collision right?

List of Arguments?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on August 17, 2014, 01:32:49 AM
Is it possible to get the id of ship system for FleetMemberAPI? I searched the docs, but neither ShipVariantAPI nor ShipHullSpecAPI give this information. Which is strange, since it is directly linked with ship hull data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 28, 2014, 06:54:06 PM
Sorry I didn't notice your question earlier celestis. I don't know of any clean-cut way to get the system id of a ship from a FleetMemberAPI instance, but you could use the trick Alex taught me on the previous page. Like so:
Spoiler
Code: java
public class MyUtils
{
    static Map<String, String> SystemIDs;
       
    public static String getSystemID(String hullID) {
        if(SystemIDs == null) {
            SystemIDs  = new HashMap();
           
            try {
                JSONArray j = Global.getSettings().getMergedSpreadsheetDataForMod(
                        "id", "data/hulls/ship_data.csv", "starsector-core");
                for(int i = 0; i < j.length(); ++i) {
                    JSONObject s = j.getJSONObject(i);
                    String id = s.getString("id");

                    if(id.equals("")) continue;

                    String systemID = s.getString("system id");
                    SystemIDs.put(id, systemID);
                }
            } catch(IOException e) {
                // Insert your prefered method of reporting exceptions
            } catch(JSONException e) {
                // Insert your prefered method of reporting exceptions
            }
        }
       
        return SystemIDs.get(hullID);
    }
}
.
[close]

Question:
Are there any decent methods of determining or estimating where a (default AI controlled) ship wants to go and what direction it wants to be facing? I'm willing to get pretty messy to get (or even reliably guess) that information.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on August 29, 2014, 12:08:31 AM
"Sound file must be *mono* for it to be properly played within the engine."

Just noticed that little suggestion buried EXTREMELY deeply in the Javadocs. Does it really make that big of a difference?

Also, whenever I implement an interface, Netbeans started red-flagging them all as duplicated classes. This has no effect on compiling or anything else, but is really annoying. Anyone know what's causing it/a way to get rid of it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 29, 2014, 12:47:50 PM
Looks like that may be due to a netbeans bug (source (https://netbeans.org/bugzilla/show_bug.cgi?id=226360)). It might help to update and/or clear the cache.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on August 30, 2014, 01:09:28 AM
Sundog, thanks a lot! This doesn't look like a convenient solution, but still it works. Hope that appropriate methods will be added in next releases.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 11, 2014, 02:50:01 PM
Glad I could help :)

So, what's the best way to force the default AI to use autofire with certain weapons? I've been giving them 'PD' as a hint, but that's shoddy and unreliable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on September 11, 2014, 03:44:10 PM
Glad I could help :)

So, what's the best way to force the default AI to use autofire with certain weapons? I've been giving them 'PD' as a hint, but that's shoddy and unreliable.

Currently it is impossible to do it "correctly" but perhaps soon that will be possible within the API.

But I have been using the PD hint trick on rocket, missile, and flare custom autofire AI weapons and it works flawlessly?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 12, 2014, 06:50:28 PM
Hrm. That's too bad.
Yeah, using the PD hint has worked just fine for me up until this point, but I recently found out that the AI will select PD weapon groups if all other weapon groups are also PD. Unfortunately that overrides AutofireAIPlugin implementations*  :(

*Doesn't seem to be true. Sorry for the false alarm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on September 12, 2014, 07:32:43 PM
Oof, I did not realize it would foul up in that situation, thank you for the heads up Sundog.

Anyways I talked to Alex about this recently and the API addition for this problem is on his list :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 12, 2014, 08:18:04 PM
Oh, cool. Looks like the priority for that should be kept low, however, as I was completely wrong about AutofireAIPlugins being overridden...
Excuse: I'm pretty sure I accidentally removed a change to one of my AutofireAIPlugins when I backdated to a previous version of my mod. The change made the weapon stop firing at shields. When the weapon started shooting shields under AI control I naturally assumed it was Alex's fault instead of mine. Shame  :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xlandar on September 19, 2014, 12:31:55 AM
I just put together my first ship using trylobot's ship editor. How can i easily add it and test it in-game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 19, 2014, 04:40:12 PM
If you want to add the ship to a campaign save, I'd recommend LazyWizard's excellent Console Commands mod (http://fractalsoftworks.com/forum/index.php?topic=4106.0)

If you plan on doing a lot of testing with one or more ships, however, I'd suggest setting up a mission that includes all the ships you want to test. That way you won't have to reload a save every time you want to test a change. You can also add your ship to the simulator opponents.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 19, 2014, 06:06:44 PM

Is there a collision class that acts like a normal projectile or beam but ignores fighters? Or can I make one?

I thought the reaper torpedo did... but after some testing its collsion specs still hit fighters when used with other projectiles
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2014, 06:20:32 PM
HITS_SHIPS_AND_ASTEROIDS might work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 19, 2014, 06:41:25 PM
HITS_SHIPS_AND_ASTEROIDS might work.

Nope, tried it. It actually hits your own ship/shields since it includes ALL ships... even your own  ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2014, 06:44:10 PM
Ah, ouch. Don't think there's anything else, then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 19, 2014, 06:45:53 PM
 :'( well shoot. Its actually pretty important for my mod. Time for a suggestions post!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on September 19, 2014, 08:38:08 PM
Is it possible to render a missile below its weapon sprite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on September 19, 2014, 08:55:00 PM
Is there a collision class that acts like a normal projectile or beam but ignores fighters? Or can I make one?

I thought the reaper torpedo did... but after some testing its collsion specs still hit fighters when used with other projectiles

It can be done by scripting the projectile in its entirety, although that is not an ideal solution.


Is it possible to render a missile below its weapon sprite?

No, but you could get the same effect by animating the weapon frame by frame.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xlandar on September 19, 2014, 10:39:45 PM
I worded my original post badly, I don't actually know how to create the mod itself (i can make the ships with trylobots ship editor). I haven't found a proper tutorial on how to format it.

EDIT: i got it to work!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ORMtnMan on September 19, 2014, 10:45:44 PM
Do a code peek into another persons mod, that is how I learned coding... also get the program notepad+ if you don't have it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on September 20, 2014, 05:07:05 AM
I worded my original post badly, I don't actually know how to create the mod itself (i can make the ships with trylobots ship editor). I haven't found a proper tutorial on how to format it.

EDIT: i got it to work!

Well after you've made your ship files, next step is to make variant files, again this can be done with the ship editor.

Next step is mission testing usually. Have a look at the files and directories under data/missions and create a mission of your own. The Java file is fairly straight forward for a mission file.

After you've play tested a mission or two you'll want to start adding your faction into the campaign. This bit can be a little daunting, but after reading enough of the faction files and world generation scripts you can create your own star system with a generous amount of copy and paste.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on September 20, 2014, 01:34:11 PM

Is it possible to render a missile below its weapon sprite?

No, but you could get the same effect by animating the weapon frame by frame.

As also want to make a fancy missile rendered below the mount, what exactly do you mean animating the weapon frame by frame? Adding an animation to the launcher, to the missile? Adding some line of code?

Would really like a more detailed explaination of this, or even better, if you could point me in the direction of an example :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on September 20, 2014, 02:03:54 PM
Check how I did the Manticore missile weapons.
Short version: you animate a weapon with a missille loaded as first frame, and no missile as second. Then you animate it onFire, and hold the second frame as long as you need to to mach the weapon delay between shots. This doesn't work with missiles racks though, only one shot missile or pods because you need to launch all ordinances in the animation or it doesn't loop.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on September 21, 2014, 01:11:05 PM
I never really managed to make it exactly like I originally planned, but thanks to your tips I managed to make a fabulus ship that poops explosive probes ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xlandar on September 21, 2014, 09:35:37 PM
I never really managed to make it exactly like I originally planned, but thanks to your tips I managed to make a fabulus ship that poops explosive probes ;D
:o I gotta see this!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on September 23, 2014, 02:48:45 PM
I never really managed to make it exactly like I originally planned, but thanks to your tips I managed to make a fabulus ship that poops explosive probes ;D
:o I gotta see this!

I'm sorry for getting your hopes up, it's probably not as fancy as my comment would suggest.

(http://i.imgur.com/KhzbB2v.gif)

I honestly love the little *** bumble that the missiles/explosive probes does when shot out from the butt :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lakis on September 27, 2014, 02:44:54 PM
Figured out previous question, now I've got to figure out why the fighters won't separate and form a claw or box like they should...

That's not happening during travel or in combat...

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Brainbread on September 30, 2014, 10:15:16 AM
So, this might be silly, but I've been updating the Lotus Conglomerate mod, and I'm trying to figure out how to increase the number of replacement chassis fighters have. As it stands, the fighters are capping out at having replacements equal to the number of ships in the wing. Which, as you can guess, its incredibly ineffective. I did a search on the forum, and I haven't seen anything in particular for this, so any help would be nice!

E: 1 minute later, found out that the ships didn't have a CR to deploy value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 30, 2014, 05:11:09 PM
Figured out previous question, now I've got to figure out why the fighters won't separate and form a claw or box like they should...

That's not happening during travel or in combat...

If memory serves, this came up for me briefly when I was first implementing fighters into SHI.  They would consistently overlap one spot and split only under duress.  The problem turned out that their collision radius was null or infinitesimally small, so you might want to adjust that and see if that helps.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lakis on September 30, 2014, 09:59:02 PM
Was tinkering with adding ships to the Simulator and I've run into this odd Null pointer exception.

Spoiler
Code
202140 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.ai.FighterAI.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.void.super.float$super(Unknown Source)
at com.fs.A.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
[close]

It happens when ever I try to get the fighters for our faction to come out and fight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SlimPickens on October 01, 2014, 06:22:13 PM
Trying out this whole modding thing after having not looked at java in nearly a decade, so there's a good chance I'm going to have a bunch of terrible questions to go along with my terrible ideas. Thus far I made a ship. Made a gun for it. Got it to load without the game crashing.

Made a mission to test it, and the game is apparently looking for the descriptor.json (and probably the rest of the mission) in the starsector-core/mods/mymod/etc instead of just mods/mymod/etc where it lives. No idea why it would be doing that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Auraknight on October 01, 2014, 08:55:57 PM
So i've hit a slight snag in my modding, got the error I was gitting all fixed up nice and neatly tanks to the awesome people of this fourm, but my mod has assassult chainguns fireing extreemely rapidly. To the point where the game lags down to about 15 frames a second. This in and of itself isn't so uch of a problem, as the side effect of it eventuailly makeing no more bullets spawn from the gun itself, while the ammo count still drops, and flux is still being used.
(Also, what would be the minimum # for damage to consistantly deal 1 damage per shot? I have it at 1 atm, but that seems to only hit for .5 on shields, and random, sometimes seemingly inconsequential amounts (Like 0) on armour.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on October 03, 2014, 12:21:32 AM
Armor shows 0 damage because it negates something like 80% of the damage. Rounds down after 0.499999999 as far as I know. As for the shields, they have an efficiency. 1.0 efficiency will convert 100 percent of the damage into flux. A 0.5 efficiency will convert 0.5 of the flux into flux.

Good luck :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 04, 2014, 02:21:19 AM
Guys, is there any information about when Global.getFactory() returns null? I tried to get it at the moment of mission generation, but it seems not to be initialized yet. And there is nothing in docs to get to know when it becomes available.
Thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 04, 2014, 10:21:41 AM
Hmm. I'm using Global.getFactory() in a MissionDefinitionPlugin without any issues. Are you certain it's Global.getFactory() returning null and not something else on the same line? If so, the only thing I can think of to try would be calling api.initFleet() and api.setFleetTagline() before Global.getFactory().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2014, 10:37:42 AM
Global.getFactory() is only meant to be used in the campaign.

(It may work in a mission if you've loaded a campaign game in the same session, but that's not something to be relied on, perhaps obviously...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 04, 2014, 11:46:17 AM
Oh, I see. That's sad, I was relying on some of factory functionality to generate fleet members. Well, seems I have to find other way. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 04, 2014, 10:00:37 PM
Global.getFactory() is only meant to be used in the campaign.

(It may work in a mission if you've loaded a campaign game in the same session, but that's not something to be relied on, perhaps obviously...)
Hmm. Well, for some reason it seems to work for me even if a campaign game hasn't been loaded. Perhaps the factory is instantiated prematurely in 0.6.2a?
Exibit A:
Spoiler
(please excuse the atrocious code)
(http://i.imgur.com/wu67CtP.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 05, 2014, 01:07:09 AM
Sundog, our use-cases seem to be almost equal (random fleet initialization), but I'm sure that factory is null here :)
Here's my stacktrace:
Code
java.lang.ExceptionInInitializerError
at data.missions.eve_mission_test.MissionDefinition.defineMission(MissionDefinition.java:44)
...................
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Global.getFactory returned null: can't init fleet factory
at data.scripts.plugins.EveFleetFactory.<clinit>(EveFleetFactory.java:365)
As you see, my check fails while being called from the same defineMission() method. I'm puzzled) I'm using 0.6.2a RC3 - the latest version ATM. ???

Edit:
Just for test I also added some code to the mission definition itself (outside JAR):
Code
		Object a = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "eve_g_bs_megathron_brawl");
And also get NullPointerException on this line. Somehow you seem to have forced the factory to instantiate earlier...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 05, 2014, 01:28:12 AM
I think you should be using spawnShipOrWing() http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/CombatFleetManagerAPI.html

That's if you're adding ships after combat has started. Are you adding the ships in combat or in the mission definition?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 05, 2014, 01:34:58 AM
Debido, for adding ships I add standard
Code
MissionDefinitionAPI.addToFleet()
But for some internal mod logic I need to know some things, which can only be acquired after creating a fleet member. So I preload all such information in my fleet factory, which can be then used for picking random variant IDs with some parameters (ship role, for example).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 05, 2014, 11:23:12 AM
Somehow you seem to have forced the factory to instantiate earlier...

Yeah, that's what it looks like. The only thing I can think of that might be forcing the engine to instantiate the factory in my mod is the call to Global.getSettings().

I'm not familiar with ExceptionInInitializerError, but it doesn't seem to me like that would be caused by getFactory returning null. That would be a NullPointerException like you got in your uncompiled test. Maybe I misunderstood something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 05, 2014, 11:41:22 AM
Well what information do you need to get? That's the solution you're looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 05, 2014, 12:30:18 PM
Perhaps the factory is instantiated prematurely in 0.6.2a?

It's possible, could have had something to do with the memory leak cleanup - the class implementing FactoryAPI is the actual campaign engine. Hm, this is odd that you two are getting different results, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 05, 2014, 12:53:06 PM
Sundog, no, getting settings didn't help. ExceptionInInitializerError is actually not related to the problem - it is that because I initialize my stuff in static class constructor.
Debido, I need to define, what hull mods and weapons are loaded on variant and number of flight decks. I need that to "classify" ships automatically for later use in random picking. I can easily get all that after creating a fleet member. Anyway, if Alex says that it is not supposed to work, I'd rather not try further. I implemented it less "beautifully" via manually parsing the variant/hull files.
Thanks all for help

P.S.
By the way, it would be great to have more detailed metadata in API: i mean, loaded hulls/variants/weapons/..., their attributes (which are often present in CSVs, but not in API classes) - I guess this information is explicitly stored inside the engine, why isn't it made public? It would make many things like this much simpler.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 05, 2014, 01:28:06 PM
Fair enough, you could pre-create the data you want in a CSV or JSON file and have that loaded. Then manipulate it that way.

Otherwise Alex would need to expose an API for that somewhere, so you can parse interrogate the information. Wouldn't surprise me if it's all in JSONArrays though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ORMtnMan on October 06, 2014, 05:58:20 AM
Okay, so,
I made a copy (basically) of SHI engine stopper ship system. (with Shadow's permission). while making the following changes:

Changed the names off all the scripts and parts
Changed sounds and sprite pointers to non SHI assets,
Changed it to a missile weapon with limited ammo instead of a recharging beam.
Created a new JAR to house the engine kill effect and the system usage AI.

I am now getting this error in my log:
Spoiler
12635 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.RuntimeException: Error compiling [data.shipsystems.scripts.ac_EASAI]
java.lang.RuntimeException: Error compiling [data.shipsystems.scripts.ac_EASAI]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.shipsystems.scripts.ac_EASAI
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:165)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]

I can't for the life of me figure out what is going wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on October 06, 2014, 06:16:09 AM
Not sure if it's that but by default IDEs now comes with Java8, but the game is in Java7. You need to download the previous SDK and select it in your compiler.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 06, 2014, 06:26:09 AM
The issue root cause has been identified. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ORMtnMan on October 06, 2014, 06:32:23 AM
The issue root cause has been identified. :)
Yep, thanks to David. I now know to make references to my Jar files in the Mod info file >.<
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: stormbringer951 on October 06, 2014, 08:11:02 AM
Hi, I posted a topic about this in the subforum earlier but it doesn't seem to have gotten any traction :( .

Does anyone know if it's possible to modify the chase/ignore/flee logic of fleets? For example, would it be possible to have a situation where large enemy fleets with equal fleet points would avoid each other but small fleets would fight each other? My guess is no, but maybe I'm looking in the wrong part of the javadocs.

Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SlimPickens on October 06, 2014, 03:31:30 PM
Code
ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.RuntimeException: Error compiling [data.scripts.DGYModPlugin]
..........words.........
Caused by: org.codehaus.commons.compiler.CompileException: Source file "data/scripts/world/DGYGen.java" does not declare class "data.scripts.world.DGYGen"
at org.codehaus.janino.JavaSourceIClassLoader.findIClass

Not sure what this is specifically trying to tell me is wrong, everything is looking pretty good and declared to me. Obviously missing something though...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on October 06, 2014, 03:34:58 PM
Code
ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.RuntimeException: Error compiling [data.scripts.DGYModPlugin]
..........words.........
Caused by: org.codehaus.commons.compiler.CompileException: Source file "data/scripts/world/DGYGen.java" does not declare class "data.scripts.world.DGYGen"
at org.codehaus.janino.JavaSourceIClassLoader.findIClass

Not sure what this is specifically trying to tell me is wrong, everything is looking pretty good and declared to me. Obviously missing something though...

Java packaging requires the folder structure match the specified package for a class (I believe).

Your code file data/scripts/world/DGYGen.java likely has an incorrect package of data.scripts.

Set package at top of code file (DGYGen.java) like:
Code
package data.scripts.world;

Hopefully that fixes it :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on October 06, 2014, 03:37:18 PM
Hi, I posted a topic about this in the subforum earlier but it doesn't seem to have gotten any traction :( .

Does anyone know if it's possible to modify the chase/ignore/flee logic of fleets? For example, would it be possible to have a situation where large enemy fleets with equal fleet points would avoid each other but small fleets would fight each other? My guess is no, but maybe I'm looking in the wrong part of the javadocs.

Thanks :)

I don't think you can change this manually. There are a couple of the fleet behaviors that ignore other fleets, and although that means they won't chase other fleets, they also won't run from other fleets. I think "DELIVER_RESOURCES" or whichever is like this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SlimPickens on October 06, 2014, 03:40:38 PM
Set package at top of code file (DGYGen.java) like:
Code
package data.scripts.world;

Hopefully that fixes it :)

It's already in there
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on October 06, 2014, 03:49:57 PM
Set package at top of code file (DGYGen.java) like:
Code
package data.scripts.world;

Hopefully that fixes it :)

It's already in there

OK well is DGYGen.java in the data/scripts/world folder? Basically the folder needs to match the package definition (I believe, Java is certainly not my strong point :) )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SlimPickens on October 06, 2014, 04:02:22 PM
OK well is DGYGen.java in the data/scripts/world folder? Basically the folder needs to match the package definition (I believe, Java is certainly not my strong point :) )

Yeah it is. I wish it were that straightforward (it probably still is and I'm just blind, it's been awhile since I played with java)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on October 06, 2014, 06:15:24 PM
OK well is DGYGen.java in the data/scripts/world folder? Basically the folder needs to match the package definition (I believe, Java is certainly not my strong point :) )

Yeah it is. I wish it were that straightforward (it probably still is and I'm just blind, it's been awhile since I played with java)

Hmmm maybe attach the file? Bit hard to tell otherwise :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SlimPickens on October 11, 2014, 04:46:49 PM
Zaphide is a scholar and gentleman (or woman)

Edit: found it


On a side note, in my gen file I went and made the star system's coordinates randomized. Nothing else changed, and now it creates two identical star systems. I'm inclined to just call it a feature but haven't the faintest idea why it's happening.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rushyo on October 20, 2014, 07:18:32 AM
How can you get rid of the traditional starting systems?

e.g. Remove Corvin and all the ships and assorted flotsam that would otherwise spawn there.

It's for a total conversion. Currently the alpha build still has those systems there, but they serve no functional purpose and only serve to demolish suspension of disbelief. I've had a few clumsy attempts to do this using the API and it always ends in a great big mess.

Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on October 21, 2014, 06:44:42 PM
Ahhh, market woes.

Specifically, I've got SHI set up now so that Anar is spawning... not correctly, (the stations are orbiting the wrong bodies, the one supposed to be around Euripides is orbiting Theramin, and Theramins station is orbiting in approximately the center of the local star) but it's spawning.  But the economy in the system is not starting for reasons that are rather unclear.  It's not giving any errors that I can find in the log; will a json for the economy not work if it's a mod?  If so that would seem quite strange.

Also, where are the definition for specific market conditions? I haven't been able to suss them out.

E: Didn't have time earlier, but here's the source for the system generation.

Spoiler
SHIGen.java
Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl;
import com.fs.starfarer.api.impl.campaign.CoreScript;
import com.fs.starfarer.api.impl.campaign.events.CoreEventProbabilityManager;
import com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager;
import com.fs.starfarer.api.impl.campaign.ids.Factions;

import data.scripts.world.anar.Anar;

public class SHIGen implements SectorGeneratorPlugin {

    @Override
    public void generate(SectorAPI sector) {
        initFactionRelationships(sector);
       
        new Anar().generate(sector);
       
        sector.registerPlugin(new CoreCampaignPluginImpl());
sector.addScript(new CoreScript());
sector.addScript(new CoreEventProbabilityManager());
sector.addScript(new EconomyFleetManager());
    }
   
    public static void initFactionRelationships(SectorAPI sector) {
        FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
FactionAPI pirates = sector.getFaction(Factions.PIRATES);
FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
FactionAPI kol = sector.getFaction(Factions.KOL);
FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);
FactionAPI player = sector.getFaction(Factions.PLAYER);
FactionAPI diktat = sector.getFaction(Factions.DIKTAT);
        FactionAPI shadow = sector.getFaction("shadow_industry");
       
        player.setRelationship(shadow.getId(), 0);
       
        shadow.setRelationship(path.getId(), RepLevel.VENGEFUL);
       
        shadow.setRelationship(hegemony.getId(), RepLevel.HOSTILE);
        shadow.setRelationship(pirates.getId(), RepLevel.HOSTILE);
        shadow.setRelationship(diktat.getId(), RepLevel.HOSTILE);
        shadow.setRelationship(church.getId(), RepLevel.INHOSPITABLE);
        shadow.setRelationship(kol.getId(), RepLevel.SUSPICIOUS);
       
        shadow.setRelationship(tritachyon.getId(), RepLevel.NEUTRAL);
       
        shadow.setRelationship(independent.getId(), RepLevel.FAVORABLE);
    }
}

And Anar.java.
Code
package data.scripts.world.anar;

import com.fs.starfarer.api.Global;
//import com.fs.starfarer.api.InteractionDialogImageVisual;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
//import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
//import data.scripts.world.FleetManager;
import java.awt.Color;
//import com.fs.starfarer.api.impl.campaign.ids.Conditions;
//import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
//import com.fs.starfarer.api.impl.campaign.submarkets.StoragePlugin;

public class Anar {

    public void generate(SectorAPI sector) {
       
        StarSystemAPI system = sector.createStarSystem("Anar");
        system.getLocation().set(-6000, 7500);
        LocationAPI hyper = Global.getSector().getHyperspace();
       
        PlanetAPI anar = system.initStar("anar", "star_yellow", 600f);

        PlanetAPI anar1 = system.addPlanet("lumen", anar, "Lumen", "barren", 155, 55, 1000, 53);
        //anar1.setCustomDescriptionId("planet_lumen");
        //SectorEntityToken shadowPower = system.addOrbitalStation("lumen_solar", system.getEntityById("Lumen"), 155, 200, 53, "Lumen Solar Plant", "neutral");
       
        PlanetAPI anar2 = system.addPlanet("wallow", anar, "Wallow", "toxic", 20, 180, 2250, 222);
       
        PlanetAPI anar3 = system.addPlanet("euripides", anar, "Euripides", "planet_euripides", 245, 160, 3750, 381);
        PlanetAPI anar3A = system.addPlanet(null, anar3, "Aeschylus", "cryovolcanic", 235, 40, 500, 62);
        system.addRingBand(anar3, "misc", "rings1", 128f, 2, Color.white, 128f, 550, 40f);
        system.addRingBand(anar3, "misc", "rings1", 128f, 4, Color.white, 128f, 650, 60f);
        system.addRingBand(anar3, "misc", "rings1", 256f, 6, Color.white, 256f, 700, 80f);
        anar3.setCustomDescriptionId("planet_euripides");
        //anar3.setInteractionImage("illustrations", "nanshe_desert");
       
        SectorEntityToken shadowShipyards = system.addCustomEntity("prana_vayu", "Prana Vayu Shipyards", "station_side02", "shadow_industry");
        shadowShipyards.setCircularOrbitPointingDown(system.getEntityById("euripides"), 45, 400, 50);
        //shadowShipyards.setCustomDescriptionId("station_Prana");
       
        SectorEntityToken relay = system.addCustomEntity("anar_relay", // unique id
"Anar Relay", // name - if null, defaultName from custom_entities.json will be used
"comm_relay", // type of object, defined in custom_entities.json
"shadow_industry"); // faction
// synced orbit w/ Euripides
relay.setCircularOrbit( system.getEntityById("anar"), 240, 3650, 381);
       
        PlanetAPI anar4 = system.addPlanet("calleach", anar, "Calleach", "ice_giant", 235, 300, 8000, 766);
        system.addRingBand(anar4, "misc", "rings1", 256f, 3, Color.white, 256f, 1450, 40f);
        system.addRingBand(anar4, "misc", "rings1", 128f, 4, Color.white, 128f, 1550, 60f);
        system.addRingBand(anar4, "misc", "rings1", 128f, 2, Color.white, 128f, 1550, 80f);
        system.addRingBand(anar4, "misc", "rings1", 128f, 1, Color.white, 128f, 1600, 120f);
        PlanetAPI anar4a = system.addPlanet(null, anar4, "Cinderbox", "lava", 300, 60, 800, 88);
        PlanetAPI anar4b = system.addPlanet("theramin", anar4, "Theramin", "terran", 240, 120, 1200, 246);
        PlanetAPI anar4c = system.addPlanet("melancholia", anar4, "Melancholia", "cryovolcanic", 200, 80, 1500, 492);
       
        SectorEntityToken shadowResearchBase = system.addCustomEntity("gravitas", "Gravitas Research Post", "station_side03", "shadow_industry");
        shadowShipyards.setCircularOrbitPointingDown(system.getEntityById("theramin"), 45, 300, 50);
       
        system.addAsteroidBelt(anar, 600, 10000, 1400, 600, 400);
       
        //initShadowShipyardsCargo(shadowShipyards);
        //initResearchBaseCargo(shadowResearchBase);

        SectorEntityToken a3 = system.getEntityById("euripides");
JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("euripides_gate", "Euripides Gate");
OrbitAPI orbit = Global.getFactory().createCircularOrbit(a3, 0, 500, 30);
jumpPoint.setOrbit(orbit);
jumpPoint.setRelatedPlanet(a3);
       
        jumpPoint.setStandardWormholeToHyperspaceVisual();
        system.addEntity(jumpPoint);

        system.autogenerateHyperspaceJumpPoints(true, true);

        /*
        SHISpawnPoint shiSpawn = new SHISpawnPoint(sector, system, 5, 5, system.getEntityById("Euripides"));
        system.addSpawnPoint(shiSpawn);
        for (int i = 0; i < 3; i++) {
            shiSpawn.spawnFleet();
        }

        SectorEntityToken sdftoken = system.createToken(5, 5);
        ShadowyardsSDFSpawnPoint shisdfSpawn = new ShadowyardsSDFSpawnPoint(sector, system, 30, 1, sdftoken, shadowShipyards);
        system.addSpawnPoint(shisdfSpawn);
        spawnSHIDF(sector, system, shadowShipyards);

        StarSystemAPI corvus = Global.getSector().getStarSystem("Corvus");

        SectorEntityToken hegemonyStation = corvus.getEntityById("Orbital Station");
        AnarHegemonyPatrolSpawnPoint anarPatrolSpawn = new AnarHegemonyPatrolSpawnPoint(sector, corvus, 10, 5, hegemonyStation);
        corvus.addSpawnPoint(anarPatrolSpawn);
        for (int i = 0; i < 5; i++) {
            anarPatrolSpawn.spawnFleet();
        }

        AnarIndieSpawnPoint independentSpawn = new AnarIndieSpawnPoint(sector, system, 10, 15, shadowShipyards);
        system.addSpawnPoint(independentSpawn);
        for (int i = 0; i < 2; i++) {
            independentSpawn.spawnFleet();
        }

        system.addSpawnPoint(new SHIConvoySpawnPoint(sector, hyper, 12, 1, hyper.createToken(-5000, 7000), shadowShipyards));
        */
}

    /*private void spawnSHIDF(SectorAPI sector, StarSystemAPI system, SectorEntityToken location) {
        CampaignFleetAPI fleet = sector.createFleet("shadow_industry", "securityDetachment");
        try {
            FleetManager.createFleet(fleet, "SHI_securityDetachment");
        } catch (NoClassDefFoundError ex) {
            SHIVariantSelector.randomizeFleet(fleet);
        }
        system.spawnFleet(location, 400, 300, fleet);

        fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, location, 1000000);
        fleet.setPreferredResupplyLocation(location);
    }*/   
}
[close]

Alright, I might have gotten by the above on my own; problem unrelated to the system gen.  It seems to have been confined to the economy jsons.

Of course, now I have a new problem.

Edit: nevermind, I'm an idiot and failed to notice a typo.  Seems to be working now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on October 21, 2014, 09:04:21 PM
Also, where are the definition for specific market conditions? I haven't been able to suss them out.

If you're still looking for them, the market conditions definitions are in /data/campaign/market_conditions.csv

The actual scripts are in com.fs.starfarer.api.impl.campaign.econ (haven't looked at them, but I feel like the .csv gives you a pretty easy idea of what each one does in the meantime)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on October 21, 2014, 09:43:09 PM
Actually, I've already checked the API.  The market details are not actually there.  I even looked into the jar just to see if they were present in there, but they do not appear to be.  The data is obviously coming from somewhere but it seems to be a complete mystery as to where that actually is.

Also, you misunderstand, my interest in the market details isn't to get more precise info on the market info, but to make custom market conditions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on October 21, 2014, 11:49:52 PM
Hmmm... interesting. I was going to try that too at some point, I'll let you know if I make any progress in that direction.

Anyone else been getting this crash?

Code
5165 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at sound.K.<init>(Unknown Source)
at sound.public.<init>(Unknown Source)
at sound.OooO.super(Unknown Source)
at sound.OooO.super(Unknown Source)
at com.fs.starfarer.loading.OO0O.?0000(Unknown Source)
at com.fs.starfarer.loading.OO0O.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.do(Unknown Source)
at com.fs.starfarer.loading.SpecStore.if(Unknown Source)
at com.fs.starfarer.loading.void.o00000(Unknown Source)
at com.fs.super.A.?0000(Unknown Source)
at com.fs.starfarer.combat.D.super(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 22, 2014, 12:52:04 AM
@Kazi: That's a very generic error, it can happen, for instance if there are blank lines in your
sim_opponents.csv
title_screen_variants.csv

or http://fractalsoftworks.com/forum/index.php?topic=8219.0

Where you have a copy of the mission java definition file in your game data folder as well as your JAR compiled.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on October 22, 2014, 01:05:12 AM
@Kazi: That's a very generic error, it can happen, for instance if there are blank lines in your
sim_opponents.csv
title_screen_variants.csv

or http://fractalsoftworks.com/forum/index.php?topic=8219.0

Where you have a copy of the mission java definition file in your game data folder as well as your JAR compiled.
hmmmm.... from the error mine appears to have something to do with sound. Although I'm not sure what, as I've literally changed almost nothing in that file...

Is there any way to tell where the error is coming from?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: silentstormpt on October 22, 2014, 01:11:38 AM
Sound is a json file, so,

check if theres an object {} that right now is an array [] for some reason.

NOTE: Just do a quick read here (http://json.org/) if you dont understand what i mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 22, 2014, 01:27:04 AM
oh and Kazi, I think sometimes a missing comma at the end of a jason element can also cause this error. As for where it comes from, usually I look at the log file and look at the last files the game was loading before the crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on October 22, 2014, 02:38:50 AM
Okay Joao solved the problem over Skype. Turns out the JSON interpeter has gotten much, much stricter.

I can get into combat now, and the campaign is throwing traceable errors again (that I can actually fix!). Thanks for all your help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on October 22, 2014, 03:02:44 AM
Anyone know how to replace a ship with a skin to the new game creation? Like having an option that gives you a degraded lasher instead of a normal one?
Mainly what I want to know is how to word it in the rules.csv so it picks the skin
Edit: Here is what the info looks like:
Spoiler
$career = "trader"
NGCAddShip "cerberus_Starting"
AddText "Added Cerberus-class frigate" textFriendColor
NGCAddCargo RESOURCES regular_crew 30
NGCAddCargo RESOURCES supplies 20
AddText "Added 30 crew" textFriendColor
AddText "Added 20 supplies" textFriendColor
NGCAddCargo RESOURCES fuel 20
AddText "Added 20 fuel" textFriendColor
FireBest NGCStep2
[close]
Edit 2: Never mind, I figured it out
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 22, 2014, 11:28:47 AM
Just to spread the word, documentation on rule scripting:
http://fractalsoftworks.com/forum/index.php?topic=8355.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on October 22, 2014, 11:51:44 PM
okay, here's another one:

Code
32125 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.campaign.events.CampaignEventTarget.<init>(CampaignEventTarget.java:16)
at com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl.onNewGameAfterTimePass(CoreLifecyclePluginImpl.java:37)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)

It looks like I'm getting through the economy generation, then Starsector tries to start a bounty on Jangala and that fails somehow.

It should do this:
Code
109785 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.events.SystemBountyEvent  - Starting bounty at market [Jangala], 2500 credits per frigate

No idea whats throwing the error though, it's as if Jangala doesn't exist.

*EDIT:
Turns out economy.json does not merge with a "mod-specific" one. You'll need a new economy.json with all of the stuff included in it.

Like this one:
Code
{
"version":2.0,

"initialStepsToRun":500,
"maxExoticUtilityAtRange":14000,
"defaultConnectionMult":1,
"defaultConnectionFlat":1,
"defaultTariff":0.3,

"starSystems":[
"rasht.json",
"askonia.json",
"corvus.json",
"valhalla.json",
"arcadia.json",
"magec.json",
"eos.json"
],

"map":"../starmap.json"
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 24, 2014, 09:16:54 PM
For purposes of role assignment, should a Capital ship with one flight deck be considered a small, medium, or large carrier?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on October 25, 2014, 03:35:48 AM
When I was trying to add one of my favorite ships to the game i noticed something I haven't seen before in the ship_data.csv

Fields called

"c"
"c/fp"
"c/l"

Does anybody know what these are?

If it helps make sense of it, heres a comparision between the onslaught and paragon

Onslaught
c: 6000
c/fp: 214
c/l: 400

Paragon
c: 10000
c/fp: 333
c/l: 500

For purposes of role assignment, should a Capital ship with one flight deck be considered a small, medium, or large carrier?

Not sure, it's small in the sense that it has a small capacity, but large in the sense that it is a big ship with presumably lots of weapons. maybe a new designation is in order? Combat carrier?
 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 25, 2014, 04:05:10 AM
They are some calculated fields that Alex left in their, the game does not use them. Putting values in here will do nothing, this is the same case with the 8/6/4/2 thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on October 25, 2014, 05:39:41 AM
They are some calculated fields that Alex left in their, the game does not use them. Putting values in here will do nothing, this is the same case with the 8/6/4/2 thing.

Ah, ok, Sweet Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CopperCoyote on October 25, 2014, 08:55:50 AM
Would it be possible to mod the ability go give commands while paused back in?

I'm having tons of difficulty toggling autofire, active venting, and toggling hold fire now that i can't do that while paused. Partially because i'm very clumsy so i flat out miss the keys sometime, but also because my computer is old and it misses the input about 10% of the time (worse in nebulas when my framerate is in the teens).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 25, 2014, 10:37:18 AM
Added "allowShipControlWhilePaused" to settings.json. Just know you're technically cheating!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 25, 2014, 12:38:58 PM
Both excited and worried by the new character creation stuff. I'm unsure whether the new scripting language in rules.csv is capable of doing all the things CharacterCreationPlugin can do (mostly basic arithmetic!) and also how you'd go about over-riding just the creation rules (for a total conversion) and not the others. If either of those aren't possible, it would be nice to be able to fall back to the old plugins.

Both should be just fine. What you'll want to do is add new "commands" (that can be called from rules.csv); the commands are written in Java and so can do anything. As far as overriding, it's the same as usual - you can provide a file with a partial set of things, and it'll add to/override core stuff as needed. A more detailed discussion of this doesn't belong in this thread, though.
It seems like Starsector knows where to find commands automagically. I might have simply missed it, but I didn't see anything about how to add commands in the rule scripting documentation. Can we put them anywhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 25, 2014, 12:43:37 PM
Has to be in the com.fs.starfarer.api.impl.campaign.rulecmd package. I know, I know...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 25, 2014, 10:37:59 PM
Trying to make a market via API rather than JSON files...because...

Anyway

Here is an example method usage.

Code: java
        PlanetAPI rocky2 = system.addPlanet("uaf_shizuka", star, "Shizuka", "rocky_unstable", 175, 60, 3432, 125);
        PlanetAPI rocky2moon1 = system.addPlanet("uaf_shizuka_kai", rocky2, "Shizuka Kai", "rocky_metallic", 305, 10, 100, 3);

        addPlanetEconomy("uaf_d",
                rocky1,
                new ArrayList<>(Arrays.asList((SectorEntityToken) rocky2moon1)),
                "Ryoko Mining Facility",
                3,
                new ArrayList<>(Arrays.asList(Conditions.ARID, Conditions.ORE_COMPLEX, Conditions.OUTPOST, Conditions.FRONTIER, Conditions.STEALTH_MINEFIELDS, Conditions.POPULATION_3)));

And this is fine, and this works

Then here is the actual implementation:

Code: java
    private void addPlanetEconomy(String factionID, SectorEntityToken primaryEntity, ArrayList<SectorEntityToken> connectedEntities, String name, int size, ArrayList<String> marketConditions) {
        EconomyAPI globalEconomy = Global.getSector().getEconomy();
       
        String planetID = primaryEntity.getId();
        String marketID = planetID + "_market";

        MarketAPI newMarket = Global.getFactory().createMarket(marketID, name, size);

        newMarket.setFactionId(factionID);

        for (String condition : marketConditions) {
            newMarket.addCondition(condition);
        }

        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                newMarket.getConnectedEntities().add(entity);
            }
        }

        globalEconomy.addMarket(newMarket);
    }

However for some reason, it appears to cause this issue just after creating the system and is creating patrols...

Code
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.CoreScript.assignPatrolSpawningScripts(CoreScript.java:112)
at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:51)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.oO0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.if.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.i.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 25, 2014, 10:52:02 PM
Just a guess. I think you need to call:
 newMarket.setPrimaryEntity(primaryEntity);

Pretty sure you'll need to manually set up submarkets as well:
 newMarket.addSubmarket("open_market");
 newMarket.addSubmarket("generic_military");
 newMarket.addSubmarket("black_market");
 newMarket.addSubmarket("storage");

Edit: Also, at one point I had to add primaryEntity.setMarket(newMarket) to prevent a crash, but that might have only been necessary because I was trying to attach a market to a fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 25, 2014, 11:14:35 PM
Thank sundog, yeah I just found the same thing that I needed newMarket.setPrimaryEntity, I derped a bit there. Now I'm getting another error which I'm hunting down.

Code
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.events.BaseEventPlugin.getDefaultPriority(BaseEventPlugin.java:325)
at com.fs.starfarer.api.impl.campaign.events.TradeDisruptionAndSmugglingEvent.init(TradeDisruptionAndSmugglingEvent.java:70)
at com.fs.starfarer.loading.specs.c.o00000(Unknown Source)
at com.fs.starfarer.campaign.events.EventProbability.<init>(Unknown Source)
at com.fs.starfarer.campaign.events.CampaignEventManager.getProbability(Unknown Source)
at com.fs.starfarer.campaign.events.CampaignEventManager.startEvent(Unknown Source)
at com.fs.starfarer.api.util.Misc.startEvent(Misc.java:369)
at com.fs.starfarer.api.impl.campaign.events.CoreEventProbabilityManager.startTradeDisruptionEventsIfNeeded(CoreEventProbabilityManager.java:337)
at com.fs.starfarer.api.impl.campaign.events.CoreEventProbabilityManager.advance(CoreEventProbabilityManager.java:83)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.oO0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.if.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.i.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.i.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.ifnew.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.ifnew.processInputImpl(Unknown Source)
at com.fs.starfarer.coreui.O0oO.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.ifnew.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.ifnew.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.D.I.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.ifnew.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.ifnew.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.oO0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInputImpl(Unknown Source)
at com.fs.starfarer.campaign.save.J.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.ifnew.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.ifnew.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.title.B.super(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.A.new(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 25, 2014, 11:17:28 PM
It's dying on the third line here...alright, I'll set the size again using the API. The size is also set in the factory instancing line oddly.
Code: java
	protected MessagePriority getDefaultPriority() {
MessagePriority priority = MessagePriority.SECTOR;
switch (market.getSize()) {
case 1:
case 2:
case 3:
priority = MessagePriority.SYSTEM;
break;
case 4:
case 5:
case 6:
priority = MessagePriority.CLUSTER;
break;
case 7:
case 8:
case 9:
priority = MessagePriority.SECTOR;
break;
}
return priority;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CopperCoyote on October 25, 2014, 11:23:24 PM
Added "allowShipControlWhilePaused" to settings.json. Just know you're technically cheating!

Thanks.
I don't particularly mind cheating. Especially not in this case. Imagine if 10 to 20% of the time the game ignores the first 100 to 500 ms of a keypress. It's aggravating, and makes the game luck based instead of skill based.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 25, 2014, 11:32:26 PM
Ok for whatever reason the market associated with the CampaignPlanet is...null.

So on line 3 when it does the market.getSize(), it is not the size that is null, but the whole market is missing!

Ah, ok. So Sundog it appears that I will need to use the primaryEntity.setMarket(newMarket); to associate the market back to the planet in the first place. You would think setting the primary entity would do it both ways...ah well. Let's give it a shot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 25, 2014, 11:41:25 PM
Success!

Well still need to get connected entities working though

Code: java
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                newMarket.getConnectedEntities().add(entity);
            }
        }

Doesn't appear to be working
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 25, 2014, 11:45:37 PM
fixed:

Code: java
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
            }
        }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 25, 2014, 11:50:26 PM
Ah, ok. So Sundog it appears that I will need to use the primaryEntity.setMarket(newMarket); to associate the market back to the planet in the first place. You would think setting the primary entity would do it both ways...ah well. Let's give it a shot.
Ah, you didn't catch my edit. I should have made a new reply to make sure you noticed :(

My dynamically generated market still isn't working right either. Are you getting stacks of 50 supplies and fuel in your black market that sell for 1 credit each? That's the most obvious symptom of my current problem. It seems like my market isn't connected to the rest of the economy at all even when I connect it to every other market  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 25, 2014, 11:53:21 PM
fixed:

Code: java
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
            }
        }
That's a strange fix. I don't get it, but I'll try it!  :)

Edit: Oh, I see now. We were just trying to do different things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 26, 2014, 12:34:13 AM
Hm, no, can't say I'm getting the same issue with supplies/fuel worth 1 supply, let me post my whole code once I figure out why I'm not seeing tarrifs on this market...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 26, 2014, 12:49:56 AM
Ok fixed that tarrif issue.

Here is the current code:

Code: java
private void addMarketplace(String factionID, SectorEntityToken primaryEntity, ArrayList<SectorEntityToken> connectedEntities, String name, int size, ArrayList<String> marketConditions, ArrayList<String> submarkets, float tarrif) {
        EconomyAPI globalEconomy = Global.getSector().getEconomy();

        String planetID = primaryEntity.getId();
       
        //generate the market ID
        String marketID = planetID + "_market";
       
        //generate the market
        MarketAPI newMarket = Global.getFactory().createMarket(marketID, name, size);
       
        //set the faction associated with the market
        newMarket.setFactionId(factionID);
       
        //set the primary entity related to the market
        newMarket.setPrimaryEntity(primaryEntity);
       
        //set the base smuggling value (starting value)
        newMarket.setBaseSmugglingStabilityValue(0);
       
        //set the starting tarrif, could also make this value an input
        newMarket.getTariff().modifyFlat("generator", tarrif);
       
        //add each sub-market types to the mark
        if (null != submarkets){
            for (String market: submarkets){
                newMarket.addSubmarket(market);
            }
        }
       
        //add each market conditions
        for (String condition : marketConditions) {
            newMarket.addCondition(condition);
        }
       
        //add all connected entities to this marketplace, moons/stations etc.
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                newMarket.getConnectedEntities().add(entity);
            }
        }
       
        //add the market to the global market place
        globalEconomy.addMarket(newMarket);
       
        //get the primary entity and associate it back to the market that we've created
        primaryEntity.setMarket(newMarket);
       
        //get all associated entities and associate it back to the market we've created
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
            }
        }
    }

Here is an example usage of the method

Code: java
        PlanetAPI rocky2 = system.addPlanet("uaf_shizuka", star, "Shizuka", "rocky_unstable", 175, 60, 3432, 125);
        PlanetAPI rocky2moon1 = system.addPlanet("uaf_shizuka_kai", rocky2, "Shizuka Kai", "rocky_metallic", 305, 10, 100, 3);

        addMarketplace("uaf_d",
                rocky2,
                new ArrayList<>(Arrays.asList((SectorEntityToken) rocky2moon1)),
                "Ryoko Mining Facility",
                3,
                new ArrayList<>(Arrays.asList(Conditions.ARID, Conditions.ORE_COMPLEX, Conditions.OUTPOST, Conditions.FRONTIER, Conditions.STEALTH_MINEFIELDS, Conditions.POPULATION_3)),
                new ArrayList<>(Arrays.asList(Submarkets.SUBMARKET_STORAGE, Submarkets.SUBMARKET_BLACK, Submarkets.SUBMARKET_OPEN)),
                0.3f
        );
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 26, 2014, 08:38:49 AM
Turns out my market was having issues not because it's attached to fleet, but because it was created after the economy was initialized.

A few questions regarding market connections:
 - Should connections be created based on proximity?
 - Are there other factors we should take into consideration when deciding whether or not to create a connection?
 - For example, should hostile markets be connected to each other?
 - Do they change over time, or are they static?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 26, 2014, 08:45:10 AM
 - Should connections be created based on proximity? - Yes
 - Are there other factors we should take into consideration when deciding whether or not to create a connection? Nope, but if you liked you could tied say...10 planets in a star system together as a 'single market' if you really wanted to. In the vanilla game, the connected entities aren't quite what you think maybe? Connected entities are for example the Jangala planet and it's station. They are connected entities as far as the market is concerned, so if you click on either you get the same market dialog screen
 - For example, should hostile markets be connected to each other? No, see above explanation
 - Do they change over time, or are they static? Nope, it just ties together one or more entities so that the market dialog presented is the exact same.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 26, 2014, 10:14:43 AM
Ok. I thought you had misunderstood my question at first, but it turns out that I was under the false assumption that connected markets were other markets that your market could trade with rather than markets that are connected the way Jangala and it's station share a market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2014, 01:31:42 PM
About the fuel/supplies on black market: it's an issue in vanilla as well, the reason is the black market adds some fuel/supplies regardless of there being any supply/demand for it locally. If there isn't, the prices kind of break. Going to fix it for vanilla one way or another - maybe by adding some low-level fuel/supplies demand to every market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 26, 2014, 01:38:36 PM
I don't know if this is the case all the time, but in one instance I waited about two months after dynamically creating a station to see if the prices would adjust after a while, and they did. So at least the issue is temporary  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on October 26, 2014, 03:04:40 PM
Is it possible for ship skins to have different engine types, like lowtech to hightech? I didn't see any in vanilla, but just wanted to double check if it was possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2014, 10:12:40 PM
I don't know if this is the case all the time, but in one instance I waited about two months after dynamically creating a station to see if the prices would adjust after a while, and they did. So at least the issue is temporary  :)

Yeah, if you're adding markets dynamically, it'll take a while for the simulation to catch up and stabilize. If you're just adding them on game start, what you want to do is add the markets in ModPlugin.onNewGame(). This is called before the economy is loaded, so any markets you configure there will run for initialStepsToRun (from economy.json) and thus will be stabilized by the time the game starts.

Is it possible for ship skins to have different engine types, like lowtech to hightech? I didn't see any in vanilla, but just wanted to double check if it was possible.

It's not, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on October 26, 2014, 10:35:25 PM
Alright, having a problem with getting some market conditions to behave properly.  The following scripts do compile in Netbeans, and the game will load up to the menu properly with them in the jar.

However, if this set of market data is called in a systems economy it crashes when starting a campaign; the code snippets should look familiar to Alex, they're basically cribbed from what I believe are the standard WorldFarming.java:

Spoiler
Code: java
package data.scripts.campaign.econ;

import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.econ.BaseMarketConditionPlugin;

public class ms_worldFarming extends BaseMarketConditionPlugin {
    
    private final float foodMult, machineryMult, maxFood;
    
    public ms_worldFarming(float foodMult, float machineryMult) {
        this.foodMult = foodMult;
this.machineryMult = machineryMult;
this.maxFood = Float.MAX_VALUE;
    }
    
    public ms_worldFarming(float foodMult, float machineryMult, float maxFood) {
        this.foodMult = foodMult;
this.machineryMult = machineryMult;
this.maxFood = maxFood;
    }
    
    @Override
    public void apply(String id) {
float pop = getPopulation(market);
float foodProduced = pop * foodMult;
if (foodProduced > maxFood) foodProduced = maxFood;
float organicsProduced = foodProduced * ms_conditionData.FARMING_ORGANICS_FRACTION;
float machineryNeeded = pop * machineryMult;

market.getCommodityData(Commodities.ORGANICS).getSupply().modifyFlat(id, Math.max(1, organicsProduced));
market.getCommodityData(Commodities.FOOD).getSupply().modifyFlat(id, Math.max(1, foodProduced));
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().modifyFlat(id, Math.max(1, machineryNeeded));
    }

    @Override
    public void unapply(String id) {
market.getCommodityData(Commodities.ORGANICS).getSupply().unmodify(id);
market.getCommodityData(Commodities.FOOD).getSupply().unmodify(id);
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().unmodify(id);
    }
}
[close]

And one of the world specific ones:

Spoiler
Code: java
package data.scripts.campaign.econ;

class ms_worldSemiArid extends ms_worldFarming {
    
    public ms_worldSemiArid() {
        super(ms_conditionData.MS_WORLD_SEMI_ARID_FARMING_MULT, ms_conditionData.MS_WORLD_SEMI_ARID_MACHINERY_MULT);
    }

}
[close]

Which gives this... helpful error message:

Spoiler
Code: java
27329 [Thread-5] ERROR com.fs.starfarer.combat.String  - java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.OOO0.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncherjava.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.loading.scripts.ScriptStore.Ó00000(Unknown Source)
at com.fs.starfarer.loading.M.String(Unknown Source)
at com.fs.starfarer.campaign.econ.MarketCondition.<init>(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
... 13 more
Caused by: java.lang.IllegalAccessException: Class com.fs.starfarer.loading.scripts.ScriptStore can not access a member of class data.scripts.campaign.econ.ms_worldSemiArid with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
at java.lang.Class.newInstance(Class.java:373)
... 22 more
[close]

Alternatively I tried dumping the script directly into the world specific java and ignoring the idea of a seperate core file to call the planet specific details from; this is from before I set up a market condition file:

Spoiler
Code: java
package data.scripts.campaign.econ;

import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.econ.BaseMarketConditionPlugin;

class ms_worldSemiArid extends BaseMarketConditionPlugin {
    
    @Override
    public void apply(String id) {
float pop = getPopulation(market);
float foodProduced = pop * 0.15f;
//if (foodProduced > maxFood) foodProduced = maxFood;
float organicsProduced = foodProduced * 0.05;
float machineryNeeded = pop * 0.0008f;

market.getCommodityData(Commodities.ORGANICS).getSupply().modifyFlat(id, Math.max(1, organicsProduced));
market.getCommodityData(Commodities.FOOD).getSupply().modifyFlat(id, Math.max(1, foodProduced));
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().modifyFlat(id, Math.max(1, machineryNeeded));
    }

    @Override
    public void unapply(String id) {
market.getCommodityData(Commodities.ORGANICS).getSupply().unmodify(id);
market.getCommodityData(Commodities.FOOD).getSupply().unmodify(id);
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().unmodify(id);
    }

}
[close]

This results in the following error:

Spoiler
Code: java
32498 [Thread-5] ERROR com.fs.starfarer.combat.String  - java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.OOO0.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncherjava.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.loading.scripts.ScriptStore.Ó00000(Unknown Source)
at com.fs.starfarer.loading.M.String(Unknown Source)
at com.fs.starfarer.campaign.econ.MarketCondition.<init>(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
... 13 more
Caused by: java.lang.InstantiationException: data.scripts.campaign.econ.ms_worldSemiArid
at java.lang.Class.newInstance(Class.java:364)
... 22 more
[close]

In both instances the super function seems to play a role, but the why escapes me.

For now, that's all; thanks for any help you can offer.

(Edited to add code=java for readability -Alex)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2014, 10:41:06 PM
Can you try putting your stuff in a package other than data.scripts? I have a feeling that's messing with things. Not entirely sure though, this is just a first-order shot at a "hopefully easy fix".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on October 27, 2014, 02:03:01 AM
Is it okay if the shield radius is larger than the center of mass radius? (or should i post this question in the ship editor thread?)

Also another question, can the "SYSTEM" weapon slot be used to define the take off location for ship system drones?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 27, 2014, 02:14:49 AM
It should be fine
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on October 27, 2014, 03:22:59 AM
Is it okay if the shield radius is larger than the center of mass radius? (or should i post this question in the ship editor thread?)

Also another question, can the "SYSTEM" weapon slot be used to define the take off location for ship system drones?

Collision radius should always be inside the shield radius, and yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 27, 2014, 03:57:14 AM
I cannot seem to figure out how to make a custom event after looking at the code for like an hour or two. I just can't see how I can add my own CampaignEventPlugin to the engine with a unique ID.

So from what I can tell you do something like this:
SectorGeneratorPlugin addScript(new EventProbabilityManager extends BaseCampaignEventListener implements EveryFrameScript)

EventProbabilityManager
CampaignEventManagerAPI eventManager.startEvent(null, "my_even_id", null)

However I cannot see how I 'add' to the sector/game engine my own unique BaseEventPlugin? Do I add it as a listener? I just cannot figure this one out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 27, 2014, 09:13:45 AM
I got an event working by doing this:
Code: java
        Global.getSector().getEventManager().startEvent(
                new CampaignEventTarget(fleet), "sun_ice_exodus", null);
However, my event isn't plugged into the rest of the sector's event probability calculations as you seem to need to do. No idea how to do that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 27, 2014, 09:23:21 AM
Hmm. Actually, after re-reading your question, Debido, I realize you might already be doing what I suggested. Let me just copy the rest of my current event implementation here.

Spoiler
events.json
Quote
{
   "sun_ice_exodus":{
      "script":"data.campaign.events.ExodusEvent",
      "image":"graphics/icons/intel/news.png",
   },
}

reports.csv
Quote
event_type,event_stage,p,target_rel,channels,subject,summary,assessment,image,icon,tags,sound_id,implementation notes
# exodus events,,,,,,,,,,,,
sun_ice_exodus,start,,,news,Exiled Idoneus Colonists seek refuge in $refugeSystem,"A large colony fleet has been driven from Idoneus Citadel, and is seeking refuge in $refugeSystem.","A nomadic population of this size will disrupt trade wherever it goes, and is likely to bring conflict to otherwise peaceful star systems.",,,,,
sun_ice_exodus,arrive,,,news,Exiled Idoneus Colonists arrive in $refugeSystem,The colony fleet carrying thousands of exiles from Idoneus Citadel has arrived in $refugeSystem.,The political and economic climate of $refugeSystem is likely to change drastically in the wake of the fleet's arrival.,,,,,
sun_ice_exodus,move,,,news,Idoneus Exiles leaving $previousSystem for $refugeSystem,"After $timeFrame in $previousSystem the Idoneus Citadel Exiles have entered hyperspace once again, seemingly en-route to $refugeSystem.","With luck things should return to normal in $previousSystem, but those with investments in $refugeSystem are advised to plan with the eminent arrival of the exiles in mind.",,,,,
sun_ice_exodus,destroyed,,,news,Colony ship of the Idoneus Exiles destroyed,The colony ship of the exiled Idoneus Citadel dwellers has been destroyed in a recent battle.,"With no colony ship to sustain their previous nomadism, the Idoneus Citadel Exiles are likely to disperse and integrate with the colonies of $refugeSystem.",,,,,
sun_ice_exodus,tradeOffer,,,news,Exiled Idoneus Colony Fleet offers trade,The Exiled Idoneus Colony Fleet in $refugeSystem has offered to trade with any available fleets in the area.,"Due to the infrastructure and high capacity for population and storage of the colony ship, the exiled fleet can sustain a sizable market of it's own.",,,,,               


BaseEventPlugin
Code: java
package data.campaign.events;

import com.fs.starfarer.api.Global;
import static com.fs.starfarer.api.Global.getSector;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.comm.MessagePriority;
import com.fs.starfarer.api.campaign.events.CampaignEventTarget;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.events.BaseEventPlugin;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class ExodusEvent extends BaseEventPlugin {
    static final float DAYS_BETWEEN_TRADE_OFFERS = 1f;
    static final float DAYS_BEFORE_INITIAL_TRADE_OFFERS = 2f;
   
    public static boolean NoMoreTradeOffers = false;
   
    float elapsedDays = 0f;
    float dayOfNextTradeOffer = DAYS_BEFORE_INITIAL_TRADE_OFFERS;
    boolean ended = false;
    boolean traveling = true;
    boolean hasEnteredHyperspace = false;
    String previousSystem = "another System";
    String timeFrame = "months";
    CampaignFleetAPI exiles;
    StarSystemAPI destination;
    SectorAPI sector;

    public void init(String type, CampaignEventTarget eventTarget) {
        super.init(type, eventTarget);
       
        sector = Global.getSector();
        exiles = (CampaignFleetAPI)eventTarget.getEntity();
        chooseNewHome();
       
        report("start");
    }

    public void startEvent() {
        super.startEvent();
    }

    public void advance(float amount) {
        if (!isEventStarted()) { return; }
        if (isDone()) { return; }

        float days = sector.getClock().convertToDays(amount);
        elapsedDays += days;
       
        if(theColonyShipDied()) {
            report("destroyed");
            endEvent();
        } else if(traveling && hasEnteredHyperspace &&
                exiles.getContainingLocation() == destination) {
            report("arrive");
            hasEnteredHyperspace = traveling = false;
            elapsedDays = 0;
            dayOfNextTradeOffer = DAYS_BEFORE_INITIAL_TRADE_OFFERS;
        } else if(!traveling && elapsedDays > 7) {
            previousSystem = destination.getBaseName();
            chooseNewHome();
            report("move");
            traveling = true;
        } else if(!NoMoreTradeOffers && !traveling && elapsedDays >= dayOfNextTradeOffer
                && !sector.getCurrentLocation().isHyperspace()
                && sector.getFaction("sun_ice").getRelationshipLevel("player").isAtWorst(RepLevel.SUSPICIOUS)) {
            report("tradeOffer");
            dayOfNextTradeOffer = elapsedDays + DAYS_BETWEEN_TRADE_OFFERS;
        }
       
        if(exiles.isInHyperspace()) hasEnteredHyperspace = true;
    }

    private void endEvent() {
        ended = true;
    }

    public boolean isDone() {
        return ended;
    }

    public String getEventName() {
        return "Colony Fleet Exiled from Idoneus Citadel";
    }

    @Override
    public Map<String, String> getTokenReplacements() {
Map<String, String> map = super.getTokenReplacements();
        map.put("$refugeSystem", destination.getBaseName());
        map.put("$previousSystem", previousSystem);
        map.put("$timeFrame", timeFrame);
        return map;
    }
   
    void chooseNewHome() {
        List systems = new ArrayList(sector.getStarSystems());
        systems.remove(sector.getStarSystem("Ulterius"));
        destination = (StarSystemAPI) systems.get(new Random().nextInt(systems.size()));

        exiles.clearAssignments();
        exiles.addAssignment(FleetAssignment.GO_TO_LOCATION, destination.getStar(), 100000);
        exiles.addAssignment(FleetAssignment.RAID_SYSTEM, destination.getStar(), 100000);
    }
    void report(String stage) {
        sector.reportEventStage(this, stage,
                Global.getSector().getEntityById("sun_ice_idoneus_citadel"),
                MessagePriority.SECTOR);
    }
    boolean theColonyShipDied() {
        for(FleetMemberAPI m : exiles.getFleetData().getMembersListCopy()) {
            if(m.getHullId().equals("sun_ice_shalom")) return false;
        }
       
        return true;
    }
}


Pretty sure that's it, but I might have missed something.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 27, 2014, 09:29:44 AM
Ohhhhh, events.json and reports.csv....can't believe I didn't see that until now. Derp. Thanks Sundog! I was looking at everything java, and didn't look at the other files. Yep, it's coming together now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2014, 09:33:05 AM
Right, you guys are on exactly the right track. A note about CoreEventProbabilityManager: it's just a script. Basically, something needs to increase the probabilities of events now and again. That can be kicked off by other things happening, but sometimes it's also useful to do it periodically, which is what CoreEventProbabilityManager does. If your mod needs to periodically adjust event probability, then what you want to do is add your own script that does that. There's nothing special about CEPM, it's just the core implementation of that idea.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 27, 2014, 09:41:50 AM
@Alex: Good to know. Thanks!

@Debido: Glad I could help  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 27, 2014, 10:06:18 AM
Does anyone know of a good way to create demand for modded commodities?

I tried doing this:
Code: java
        for(MarketAPI copy : Global.getSector().getEconomy().getMarketsCopy()) {
            MarketAPI real = Global.getSector().getEconomy().getMarket(copy.getId());
            float demand = real.hasSubmarket("generic_military") ? 2000 : 500;
            real.getDemand("sun_ice_tech").getDemand().modifyFlat("sun_ice_base_idoneus_tech_demand", demand);
        }
But it doesn't seem to change anything.
(That code is so funky because I was worried getMarketsCopy was returning a deep copy)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on October 27, 2014, 10:33:24 AM
Do you have no demand at all?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on October 27, 2014, 11:12:42 AM
Can you try putting your stuff in a package other than data.scripts? I have a feeling that's messing with things. Not entirely sure though, this is just a first-order shot at a "hopefully easy fix".

Alright, problem solved. As it turned out, the problem emerged because I didn't have a "public" in front of "class ms_worldSemiArid."  Herpa derp.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2014, 11:43:31 AM
getMarketsCopy() is a shallow copy, as are all the ***Copy() methods.

As for modifying demand, your code looks right. How exactly are you testing to see if there's demand or not?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 27, 2014, 12:55:15 PM
Basically I've just been running around in-game checking to see if the commodity is in demand anywhere based on market info (which I've never seen). I created two markets that produce the commodity, and it shows up under market info in those places. It also shows one or two exports when you check the commodity details in those places, so it's probably working as intended, especially if that code looks like it should work. However, those two exporting markets have huge stockpiles in proportion to their exports, and it seems to me like an exclusive, in-demand commodity would get a lot more traffic than what I'm seeing. The buy/sell prices are also pretty wonky.

I'll admit to having a very shaky understanding of the economy simulator. Any idea what I'm doing wrong? I never tried simply pumping up demand. Think that would solve it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2014, 08:05:28 PM
Are you adding supply/demand in onNewGame? That'd be the first thing to make sure of, that it works when you put it in early enough for the simulation stabilizing steps to have run. Otherwise, depending on various factors, it might take a while for the stockpiles to normalize/for it to be available where it should/etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 27, 2014, 10:37:38 PM
Yeah, the demand generation code was being run during onNewGame. I decided to put off the custom commodity thing until after I've released a playable version of my mod, but I can give it another shot if you think this might be a symptom of an actual issue. Hmm... actually I think you might be too polite to ask me to do that, so I'll just go ahead and figure out what I was doing wrong. I probably just overlooked something, but if a legitimate bug was giving me trouble I want it to die before the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on October 28, 2014, 03:03:37 PM
In FoodShortageEvent.java, when creating small traders and smugglers, there's a line
Code: java
CampaignFleetAPI f;
Later on after f has been possibly maybe assigned as various different types of smuggler or trader fleet, there's this:
Code: java
final CampaignFleetAPI trader = f;
Can anyone tell me why final is used there please or why/if it's important?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 28, 2014, 05:15:17 PM
@Dorloth: Are you asking what the final keyword does or why Alex bothered to use it there?

Are you adding supply/demand in onNewGame? That'd be the first thing to make sure of, that it works when you put it in early enough for the simulation stabilizing steps to have run. Otherwise, depending on various factors, it might take a while for the stockpiles to normalize/for it to be available where it should/etc.
So it looks like onNewGame is actually too early. The reason my loop wasn't applying the demand modification was because it was iterating over a collection of zero markets. I overrode onNewGameAfterEconomyLoad and moved the loop into it, and everything seems to be peachy  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 30, 2014, 12:21:58 AM
Hello! I've got trouble with total conversion mod with 0.65. After introduction of ship skins the loader tries to load skins for ships not present in the mod due to overriding ship_data. So it looks for buffalo_d, but no buffalo itself exists, resulting in crash. How can I fix this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 30, 2014, 09:30:19 PM
@Sundog: cool, glad you worked it out :) You could also add that demand via a new market condition, which you could then specify as being added to existing markets via the star system json files. Except for the part where you'd have to wait for the bugfix release for those files to be properly merged on load, that is.

Hello! I've got trouble with total conversion mod with 0.65. After introduction of ship skins the loader tries to load skins for ships not present in the mod due to overriding ship_data. So it looks for buffalo_d, but no buffalo itself exists, resulting in crash. How can I fix this?

Right, known issue - will fix for the bugfix release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on October 31, 2014, 12:56:25 AM
Quote from: celestis on October 30, 2014, 12:21:58 AM

Quote
Hello! I've got trouble with total conversion mod with 0.65. After introduction of ship skins the loader tries to load skins for ships not present in the mod due to overriding ship_data. So it looks for buffalo_d, but no buffalo itself exists, resulting in crash. How can I fix this?

Right now you can overcome this by modifying each and every vanilla skin to be a variation of one of your ships. You can even clone their contents, but you must retain the original skin IDs. This is the only way to launch a TC in current build.

I use this generic file for each of the skins present in the vanilla:

Spoiler
{
   "baseHullId":"rockfly",
   "skinHullId":"buffalo_d",
   "hullName":"Dummy Hull",
   "descriptionId":"non-used-hull",  # optional
   "descriptionPrefix":"This is a dummy hull used to allow my cool TC mod to launch properly",
   "spriteName":"graphics/ships/rockfly.png",
   "baseValue":10000,
   "removeWeaponSlots":[],       # ids
   "removeEngineSlots":[],       # indices, as engine slots have no id in the .ship file
   "removeBuiltInMods":[],       # hullmod ids
   "removeBuiltInWeapons":[],       # weapon slot ids
   "builtInMods":[],
   "builtInWeapons":{
    },
}
[close]

And this is a little extra for you to save your time. Add this to your modinfo.json file under 'replace':

Spoiler
"data/hulls/skins/buffalo_d.skin",
"data/hulls/skins/buffalo_hegemony.skin",
"data/hulls/skins/buffalo_luddic_church.skin",
"data/hulls/skins/buffalo_pirates.skin",
"data/hulls/skins/buffalo_tritachyon.skin",
"data/hulls/skins/cerberus_d.skin",
"data/hulls/skins/cerberus_d_pirates.skin",
"data/hulls/skins/dominator_d.skin",
"data/hulls/skins/eagle_d.skin",
"data/hulls/skins/enforcer_d.skin",
"data/hulls/skins/enforcer_d_pirates.skin",
"data/hulls/skins/falcon_d.skin",
"data/hulls/skins/hammerhead_d.skin",
"data/hulls/skins/hermes_d.skin",
"data/hulls/skins/hound_d.skin",
"data/hulls/skins/hound_d_pirates.skin",
"data/hulls/skins/hound_hegemony.skin",
"data/hulls/skins/hound_luddic_church.skin",
"data/hulls/skins/lasher_d.skin",
"data/hulls/skins/mercury_d.skin",
"data/hulls/skins/mule_d.skin",
"data/hulls/skins/mule_d_pirates.skin",
"data/hulls/skins/tarsus_d.skin",
"data/hulls/skins/wolf_d.skin",
"data/hulls/skins/wolf_d_pirates.skin",
"data/hulls/skins/wolf_hegemony.skin",
[close]

I haven`t tested this deep enough, but at least it allows me to launch the TC mod I have.

EDITED: duh.. forgot to tell about the variants... Well, you`ll have to adjust each and EVERY variant files that are based on these skins. Just copy all the variants and remove any references to non-TC weapons and mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 31, 2014, 02:19:01 AM
Okim, thanks for a very detailed answer, but it looks so much like a cludge (and pretty much work to be done), that I'd rather wait for the official fix. Alex, is there any estimate for the next bugfix release date?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on October 31, 2014, 05:14:55 AM
@Darloth: Are you asking what the final keyword does or why Alex bothered to use it there?

I'm asking specifically why it was used there.

I understand (or thought I understood) what the final keyword does in Java in this context - it makes it a final local variable, which means once set it can never be changed.  As far as I can see this isn't particularly important because it's just referenced a few times and then passed out of the method.

Is it just for safety in case you forget you're not supposed to change it?
Does it stop it being changed once it's been returned?
Does it get passed by-reference to something that might otherwise change it?

Basically I can't figure out why it was important enough to devote an entirely new line to rather than just using the t instance, and when I see something like that it makes me worried that I don't understand the language as well as I thought I did.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 31, 2014, 07:32:00 AM
Darloth, it is final because it is used inside an anonymous class here:
Code
			trader.addAssignment(FleetAssignment.ORBIT_PASSIVE, from.getPrimaryEntity(), 1,
"loading food from " + from.getName(), new Script() {
public void run() {
trader.getCargo().addItems(CargoItemType.RESOURCES, Commodities.FOOD, trader.getCargo().getMaxCapacity() * (1f - FleetFactory.SUPPLIES_FRACTION));
}
});
I mean, inside new Script.run method. Any variable from outer scope must be made final to be referenced like this.
Though, in new Java 8 this is not needed.

Technically, this is because it tells compiler that it is not needed to generate special wrapping/binding code to track the changes of this variable (which is relevant only if the variable changes while the outer method executes). So if it is final in outer method scope, then it will definitely not change for anonymous class too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on October 31, 2014, 07:52:34 AM
Aha!

Thankyou, that clears everything up.  I had a) missed that there was an anonymous method being used as the script's run method (though I have no excuse, I did read the comment by Alex when he actually implemented arbitrary scripts, so I should have known they could be anonymous like this) and then b) wasn't aware of the special case usage of final to safely/efficiently pass variables into their scope.

Thanks a lot, I understand it now.  Much obliged!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on October 31, 2014, 08:15:47 AM
Is it possible to modify the behaviors of ships in combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 31, 2014, 11:54:51 AM
Alex, is there any estimate for the next bugfix release date?

Sooner rather than later. I'd like to fix maybe 5-6 more specific issues and then get it out - so, probably sometime within the next 2-3 days, but please don't hold me to it :) Basically, this estimate should hold unless 1) something in RL comes up or 2) one of those issues turns out way more involved that I'd expect.


Is it possible to modify the behaviors of ships in combat?

You can write your own AI. Replacing behaviors piecemeal isn't going to work, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 01, 2014, 04:08:46 AM
I just got this NPE for the second time while looking at my modded event reports in the intel screen. The first time was about a week ago, so this looks like one of those horrible rare bugs that's hard to reproduce. Any idea what I could be doing wrong?

Spoiler
Quote
java.lang.NullPointerException
   at com.fs.starfarer.campaign.comms.F.super(Unknown Source)
   at com.fs.starfarer.campaign.comms.F.??00(Unknown Source)
   at com.fs.starfarer.campaign.comms.F.super.while$super(Unknown Source)
   at com.fs.starfarer.campaign.comms.F.sizeChanged(Unknown Source)
   at com.fs.starfarer.ui.K.setSize(Unknown Source)
   at com.fs.starfarer.ui.interface.setSize(Unknown Source)
   at com.fs.starfarer.ui.O0OO.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO$7.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.O0OO.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.setCurrentTab(Unknown Source)
   at com.fs.starfarer.campaign.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.showCoreUITab(Unknown Source)
   at com.fs.starfarer.campaign.comms.Object.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.i.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.i.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.processInput(Unknown Source)
   at com.fs.starfarer.ui.ifnew.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.ifnew.processInputImpl(Unknown Source)
   at com.fs.starfarer.campaign.comms.B.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.processInput(Unknown Source)
   at com.fs.starfarer.ui.ifnew.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.ifnew.processInputImpl(Unknown Source)
   at com.fs.starfarer.campaign.comms.Object.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.processInput(Unknown Source)
   at com.fs.starfarer.ui.ifnew.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.ifnew.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.processInput(Unknown Source)
   at com.fs.starfarer.campaign.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.B.void.class$super(Unknown Source)
   at com.fs.A.A.new(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2014, 01:43:52 PM
Do you have any star systems not connected to hyperspace? There's a (fixed) bug where opening the intel tab in such a system will NPE, and the stack trace roughly matches it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on November 01, 2014, 01:48:32 PM
Had this intel problem Alex is talking about. Fixed by putting jump point auto-generator in EVERY system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 01, 2014, 02:37:42 PM
My mod adds one system that is connected to hyperspace and does have a comm relay, but it is located at (-161380, -249730)*, making it inaccessible, so that may be related. The more I think about it the more I suspect (and hope) that this crash only happens after I've linked Starsector to altered code while debugging. That gives me random ClassNotFoundExceptions all the time, and no one has mentioned the crash on the ICE thread yet, so for now I'm going to optimistically assume it's a non-issue until it happens in a normal runtime environment.

*The star system is only there to hide the colony fleet's market in while it's not in play. If the market doesn't have a valid entity to attach to I get exceptions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on November 01, 2014, 04:59:37 PM
Is it possible for a missile to use "behaviorSpec":{"behavior":"PROXIMITY_FUSE", ... } like the flak cannon? I haven't been able to get it to work, but I might just be missing something. Is there an example somewhere?

I don't think this ever got answered.  Any help with this one?

EDIT: Changing "missileType" to "PHASE_CHARGE" fixed this, though it'd be nice if proxy fuses worked with every type.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on November 01, 2014, 06:17:32 PM
You could probably get around this by using a MIRV that spawns a bomb/phase_charge.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 01, 2014, 11:09:53 PM
Alex, is there any estimate for the next bugfix release date?

Sooner rather than later. I'd like to fix maybe 5-6 more specific issues and then get it out - so, probably sometime within the next 2-3 days, but please don't hold me to it :) Basically, this estimate should hold unless 1) something in RL comes up or 2) one of those issues turns out way more involved that I'd expect.


Is it possible to modify the behaviors of ships in combat?

You can write your own AI. Replacing behaviors piecemeal isn't going to work, though.

Hmm, but how do you implement the AI? Is it through the "hints" in ship_data.csv?
If so what are the available ship hints in the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 01, 2014, 11:17:33 PM
No, not hints. Top to bottom replacement is done with your BaseModPlugin method:
pickMissileAI(MissileAPI missile, ShipAPI launchingShip)

here is an example from Vacuum:

Code: java
    public static final String HARPOON_MISSILE_ID = "harpoon_missile";  //name of the missile that will use that AI   
    public static final String GLAUG_CLUSTER_MISSILE_ID = "glaug_cluster_missile";  //name of the missile that will use that AI 
    public static final String SWARMER_MISSILE_ID = "type_1_srm2";
    public static final String PILUM_MISSILE_ID = "pilum_missile";
    public static final String HURRICANE_MISSILE_ID = "hurricane_missile";
    public static final String HURRICANE_MIRV_ID = "hurricane_missile_stage2";
    public static final String ANROC_ID = "anroc_stage_one";
    public static final String SABOT_ID = "sabot_srm2";
    public static final String ATROPOS_ID = "atropos_torp2";
    public static final String REAPER_ID = "reaper_torp2";
    public static final String PHASE_SHOT_ID = "phase_shot";
    @Override
    public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile,ShipAPI launchingShip) 
    { 
        if (HARPOON_MISSILE_ID.equals(missile.getProjectileSpecId()) || SABOT_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_NoDrones(missile,0.01f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        } 
        if (PILUM_MISSILE_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_NoDrones(missile,1.5f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        } 
        if (REAPER_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_Strike(missile,0.25f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        } 
        if (ATROPOS_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_NoDrones(missile,0.5f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        }           
        if (ANROC_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_NoDrones(missile,1.5f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        }         
         if (HURRICANE_MISSILE_ID.equals(missile.getProjectileSpecId()) || HURRICANE_MIRV_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_NoDrones(missile,0.5f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        }
          if (PHASE_SHOT_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_NoDrones(missile,0.01f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        }       
        if (GLAUG_CLUSTER_MISSILE_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_SmartPD(missile,0.75f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        }         
        if (SWARMER_MISSILE_ID.equals(missile.getProjectileSpecId()))     //missile 
        { 
            //Uses this AI
            return new PluginPick(new GuidedMissileAI_SmartPD(missile,0.5f), CampaignPlugin.PickPriority.MOD_SPECIFIC);
        }         
        return null; 
    }

and here is an actually Missile AI, again another example from Vacuum

Code: java
package data.scripts.weapons.missileai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipCommand;
import com.fs.starfarer.api.util.IntervalUtil;
import data.scripts.plugins.ShipThreatPlugin;
import java.util.List;

import org.lazywizard.lazylib.VectorUtils;

import org.lwjgl.util.vector.Vector2f;

//GuidedMissileAI_NoDrones script
//A low-latency guided missile AI with an example of sorting out non-drone targets
//Based on Dmaiski's work on LRPD AI
public class GuidedMissileAI_Strike implements MissileAIPlugin
{
    // Our missile object
    private final MissileAPI missile;
    private float waitTime = 0f;

    // Our current target (can be null)
    private ShipAPI target = null;
   
    //Booleans set current control state, updated every tick
    private boolean isAccelerating = false;
    private boolean turnRight = false;
    private boolean turnLeft = false;
    private boolean strafeRight = false;
    private boolean strafeLeft = false;
   
    private final IntervalUtil checkInterval = new IntervalUtil(0.05f, 0.1f);   
               
    //Initial setup.  If waitTime = 0f, the guidance begins one frame after launch. 
    //Otherwise, drifts until waitTime = 0f (useful for anime-style launch systems)
    public GuidedMissileAI_Strike (MissileAPI missile, float waitTime)
    {
        this.missile = missile;
        this.waitTime = waitTime;
       
        //This line can be enabled to give missile targetting data even while drifting.
        //target = findBestTarget(missile);
    }
   
    //This is our sorter, that finds the closest ShipAPI that is not a Drone.
    public static ShipAPI findBestTarget(MissileAPI missile)
    {
        ShipAPI source = missile.getSource();
        if(source != null){
            ShipAPI manTarget = source.getShipTarget();
            if(manTarget != null && !manTarget.isHulk() &&  !(missile.getOwner() == manTarget.getOwner())        // friendly
                && Global.getCombatEngine().isEntityInPlay(manTarget))
            {
                return manTarget;
            }
        }
        //this is where your missile is
        Vector2f loc = missile.getLocation();
       
        //Get all enemies within range.
        if(source == null) return null;
        List<ShipAPI> nearbyEnemies = ShipThreatPlugin.getThreats(source);
        if(nearbyEnemies == null || nearbyEnemies.isEmpty()) return null;

        //If we don't have a manual target, then the missile looks for the closest one in the forward arc.
        float searchArc = 45f;
        for (ShipAPI enemy : nearbyEnemies) {
            if (!enemy.isDrone() && !enemy.isFrigate() && !enemy.isFighter())
            {
                Vector2f TLoc = enemy.getLocation();
                float MFace = missile.getFacing();
               
                //main aiming (to find angle you are off target by)
                float AngleToEnemy = VectorUtils.getAngle(loc, TLoc);
                //Gets the difference in the angle to the enemy vs. the missile's current angle
                float angleToTarget = getAngleDifference(MFace, AngleToEnemy);
                float AbsAngD = Math.abs(angleToTarget); 
                if(AbsAngD < searchArc){
                    if(enemy.getPhaseCloak() != null){
                        if(!enemy.getPhaseCloak().isOn() || !enemy.getPhaseCloak().isActive()){
                            return enemy;
                        }
                    } else {
                        return enemy;
                    }
                }
            }
        }
        for (ShipAPI enemy : nearbyEnemies) {
            if(!enemy.isDrone() && !enemy.isFighter() && !enemy.isFrigate() && !enemy.isHulk() && Global.getCombatEngine().isEntityInPlay(enemy)){
                if(enemy.getPhaseCloak() != null){
                    if(!enemy.getPhaseCloak().isOn() || !enemy.getPhaseCloak().isActive()){
                        return enemy;
                    }
                } else {
                    return enemy;
                }
            }
        }       
        for (ShipAPI enemy : nearbyEnemies) {
            if(!enemy.isDrone() && !enemy.isFighter() && !enemy.isHulk() && Global.getCombatEngine().isEntityInPlay(enemy)){
                return enemy;
            }           
        }

        return null;
    }

    //Main logic
    @Override
    public void advance(float amount)
    {   
        //LOGIC CHECKS
        // If fading or fizzling, don't bother with updates.
        if (missile.isFading() || missile.isFizzling())
        {
            return;
        }
       
        //Do nothing while waitTime > 0
        if(waitTime > 0f){
            waitTime -= 0.16f;
            return;
        }
       
        //If neither of the above are true, go ahead and increment our checkInterval
        checkInterval.advance(amount);
       
        //UPDATE TARGETS
        //If we don't have a target, find one.   
        //If our target is dead, removed from the sim or has switched sides, find a new target.
        if (target == null // unset
                || target.isHulk()
                ||  (missile.getOwner() == target.getOwner())        // friendly
                ||  !Global.getCombatEngine().isEntityInPlay(target) ) // completely removed
        {
            target = findBestTarget(missile);
            return;
        }     
       
        //CONTINUAL CONTROL STATES
        //Checks booleans and gives continual commands here.
        //Done here so that we can use IntervalUtil to save CPU later
        if(isAccelerating){
            missile.giveCommand(ShipCommand.ACCELERATE);
        }else{
            missile.giveCommand(ShipCommand.DECELERATE);
        }
       
        if(turnRight){
            missile.giveCommand(ShipCommand.TURN_RIGHT);
        }
        if (turnLeft){
            missile.giveCommand(ShipCommand.TURN_LEFT);
        }
        if(strafeRight){
            missile.giveCommand(ShipCommand.STRAFE_RIGHT);
        }
        if(strafeLeft){
            missile.giveCommand(ShipCommand.STRAFE_LEFT);
        }

        //MAIN AI LOGIC
        //This code governs the missile's behavior and outputs boolean states that...
        //...are used in the continual control state code.
        //By using an IntervalUtil here, we can do practical load-balancing at the cost of accuracy.
        if (target!=null && checkInterval.intervalElapsed()) //if you have a target
        {
            //Reset all of the continuous control states here.
            isAccelerating = false;
            turnRight = false;
            turnLeft = false;
            strafeRight = false;
            strafeLeft = false;
            //aming
            //1step calculations of various stats
            Vector2f MVel = missile.getVelocity();
            Vector2f MLoc = missile.getLocation();
            Vector2f TVel = target.getVelocity();
            Vector2f TLoc = target.getLocation();
            float MFace = missile.getFacing();

            //Testing InterceptPoint, tests for slow-moving things now
            Vector2f TLead;
            if(TVel.length() < 100f){
                TLead = TLoc;
            } else {
                float TCol = target.getCollisionRadius();
                Vector2f TVelShort = VectorDirection(TVel, TCol);
                TLead = new Vector2f(TLoc.getX() + TVelShort.getX(),TLoc.getY() + TVelShort.getY());
            }

            //Main aiming logic
            float AngleToEnemy = VectorUtils.getAngle(MLoc, TLead);
            float angleToTarget = getAngleDifference(  //how far off target you are
                    MFace, AngleToEnemy);         //where missile pointing, where target is in relation

            float AbsAngD = Math.abs(angleToTarget);

            //////////////////////////////////////////////////////////////////////////////////////////////

            if (AbsAngD < 5)
            {
                //course correct for missile velocity vector (some bugs when severly off target)
                float MFlightAng = VectorUtils.getAngle(new Vector2f(0, 0), MVel);
                float MFlightCC = getAngleDifference(MFace, MFlightAng);
                if (Math.abs(MFlightCC)>20)
                {
                    if(MFlightCC < 0){
                        strafeLeft = true;
                    } else {
                        strafeRight = true;
                    }
                }
            }
           
            //point towards target
            if (AbsAngD >= 0.5)
            {
                if(angleToTarget > 0){
                    turnLeft = true;
                }else{
                    turnRight = true;
                }
            }
           
            //Damp angular velocity if we're getting close to the target angle
            if(AbsAngD < Math.abs(missile.getAngularVelocity())){
                if(angleToTarget > 0){
                    missile.setAngularVelocity(AbsAngD);
                }else if (angleToTarget < 0){
                    missile.setAngularVelocity(-AbsAngD);
                }               
            }

            //acceleration code
            if (AbsAngD < 20)
            {
                isAccelerating = true;
            }
        }
    }
   
    //Returns a new vector with original direction but new length
    public static Vector2f VectorDirection(Vector2f vec, float size)
    {
        float x = vec.getX();
        float y = vec.getY();

        float lenght =(float) Math.hypot(x, y);
        return new Vector2f(x*size/lenght, y*size/lenght);
    }           

    // Will be in next LazyLib version
    public static float getAngleDifference(float angle1, float angle2)
    {
        float distance = (angle2 - angle1) + 180f;
        distance = (distance / 360.0f);
        distance = ((distance - (float) Math.floor(distance)) * 360f) - 180f;
        return distance;
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 01, 2014, 11:37:16 PM
Thanks, now off to learn some java coding....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jocan2003 on November 02, 2014, 12:04:59 AM
Im having a little problem, there is a mod i really love the ships from so i told myself hey why not just take his ship and since he dont have the background, economy etc sorted out, just get the ship in another released faction.

Well that ws a good and bad idea i believe. First i found out some call he used with lazylib was not supported anymore everycombatframe? and some other, anyway i didnt really care so i pruned eveything i didnt care loosing, wich was extra hull mods and some weapons special effect. Anyway, i got it in game, everything is laoding fine, i go in the campaign and the faction doesnt sell these ship even tho i went and added cargo.addMothballedShip(FleetMemberType.SHIP, "valk_radiance_Hull", null); ( and the other hulls too).

I am a little clueless on what is going on..... When the game loads i see the valkyrian ships in the background fight with their weapons and all but once in the campaign well they are hiding somewhere. I correctly merged the ship_data, wings_data, weapon_data, went in citadel.java and added the ships to the station yet nothing. Also second question, will market pick up random ship from the ship_data and wing_data file to put up for sale or is there an array i have to add possible ship choice for sale?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 02, 2014, 12:13:17 AM
A few things

LazyLib is still very much supported and up to date in 0.65, though a few methods may have been deprecated in lieu of features provided by game utilties themselves

http://fractalsoftworks.com/forum/index.php?topic=5444.0

Next: the EveryFrameCombatPlugin is also very much supported. You no longer 'implement' the EveryFrameCombatPlugin, but extend the BaseEveryFrameCombatPlugin in the class declaration - just a small difference to allow the extra rendering methods for ShaderLib mainly.

Now before I go any further, did you get permission from ValkyriaL to modify and re-release?

Anyway nevermind that, if ValkyriaL finishes the faction file this weekend the Valkyrie faction will be released in the next couple of days, I currently need that input for the update to 0.65 as well as the new flag asset from Ryxsen. So stay tuned.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jocan2003 on November 02, 2014, 12:29:43 AM
Oh i am not releasing it, im using it for myself, im just too impatient to wait hehe. Im just hacking my way in to get these ship to spawn so i can have a little fun with them hehe. I am in no way a good modder and 95% of what is required to properly update it is totally lost to me
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Venatos on November 02, 2014, 01:15:35 AM
as i understand it, the market gets semi randomly stocked with ships that are spezified as a certain role in: \starsector-core\data\world\factions.
just open the faction file and add: "valk_radiance_Hull":10,   (other ships dont have the _Hull in these files, maybe just valk_radiance?)       to a few of the classes, your ship should automaticly spawn on the markets of the faction.
i did something similar with the Gemini freighter, i like to use it because it doubles as carrier in my fleet and it was way to hard to come by, so i added it to medium freighters of all the factions and now i see it more often. ;)
but be aware that this is a hack! and also be aware that i just startet looking into java and starsector modding yesterday.
so i might be wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 02, 2014, 09:32:00 PM
Just found out about ShipAPI.setJitter, which is awesome  :D

Two questions:

Is this the best way to shut down jitter?
myShip.setJitter(Color.WHITE, 0, 0, 0);

When the 'Transfer Command' option is used, is there currently any way to find out what ship command is being transferred to, if any?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 02, 2014, 10:21:09 PM
Is this the best way to shut down jitter?
myShip.setJitter(Color.WHITE, 0, 0, 0);

Left alone, jitter will shut itself down - and fade out gracefully - after 0.1 seconds. But if you want it shut down immediately, yeah, what you're doing is probably best.

When the 'Transfer Command' option is used, is there currently any way to find out what ship command is being transferred to, if any?

Don't think so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 02, 2014, 11:39:15 PM
Ah, ok. I assumed jitter would perpetuate if left unchecked. Thanks Alex  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on November 03, 2014, 12:19:06 PM
Is there a way to get a sound to play fully even if the source has stopped functioning?

i.e. A burst PD style laser whose bursts are very short.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on November 05, 2014, 08:24:26 AM
I`m currently working on a translation mod and quite sure some of the files containing in-game descriptions will be changed in following updates(such as minor balance tweak, etc). I don`t want to move all the translated lines into a new file every time a new version is up, nor look for all the changes in the new one and edit them.
Is there a way to overwrite only certain value in .csv or .json files without overriding the entire files? Would simply leaving places for data I don`t want to change blank work?

Edit: Also I am quite sure that I did not found all of the files with in-game descriptions. Can anyone list it please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 05, 2014, 09:55:29 PM
Hi!
Could anyone please tell if it is possible to override ship system in a skin file?
There are some values from CSV, that are overridden in vanilla, like "fleetPoints" and "baseValue", but I didn't manage to guess the word for a ship system: tried "systemId", "system", "shipSystem", "shipSystemId", but the system didn't change. Is it possible at all?
Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on November 06, 2014, 09:36:45 AM
in BAPI (or a copy thereof) winner.getFleet().getCargo() seems to be returning a cargo with a maximum size of 1000 units, 50 of which are used, but with no stacks in it. (500 fuel capacity, 750 crew capacity)

The fleet in question is two hounds and a talon.

Should I just enumerate the fleet and query all their cargo sizes to find the true maximum? Also, what's the 50 used space going on, anyone know please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2014, 09:54:38 AM
I`m currently working on a translation mod and quite sure some of the files containing in-game descriptions will be changed in following updates(such as minor balance tweak, etc). I don`t want to move all the translated lines into a new file every time a new version is up, nor look for all the changes in the new one and edit them.
Is there a way to overwrite only certain value in .csv or .json files without overriding the entire files? Would simply leaving places for data I don`t want to change blank work?

Edit: Also I am quite sure that I did not found all of the files with in-game descriptions. Can anyone list it please?

Hi - no, that won't work. Entire rows get replaced; partial replacement isn't supported.

As far as the files, you're going to run into trouble since some of the text (such as, say, the labels in ship tooltips) are directly in code and not in any text file.


Hi!
Could anyone please tell if it is possible to override ship system in a skin file?
There are some values from CSV, that are overridden in vanilla, like "fleetPoints" and "baseValue", but I didn't manage to guess the word for a ship system: tried "systemId", "system", "shipSystem", "shipSystemId", but the system didn't change. Is it possible at all?
Thanks

No, it's not possible. One of the issues is that ship systems often need hidden "system" type slots to function, although I suppose that's not universally true, so maybe allowing that option wouldn't be a bad idea... hmm. Yeah, let me add this to the list.

in BAPI (or a copy thereof) winner.getFleet().getCargo() seems to be returning a cargo with a maximum size of 1000 units, 50 of which are used, but with no stacks in it. (500 fuel capacity, 750 crew capacity)

The fleet in question is two hounds and a talon.

Should I just enumerate the fleet and query all their cargo sizes to find the true maximum? Also, what's the 50 used space going on, anyone know please?

The 50 space is a bug, it's never properly updating the cargo carried. It should be 0 unless it's a trade fleet, or a pirate fleet with loot, etc, provided that the fleet has aiMode set to true, which it should.

I'm not sure about the maximum, though. 1000 is the default value it's inited to (like 50 for the space used), but I'm not seeing it - seems to be updated properly for me. I ran this: winner.fleet.getCargo().getMaxCapacity() from line 419 in BAPI and it seems to return the correct value.

As a last resort, you can call fleet.forceSync() - after that, the values should be in good shape. Except for the space used; there was a bug where that wasn't being updated in forceSync(). As a workaround, you might add and then remove 1 unit of supplies - that should trigger a recompute.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on November 06, 2014, 10:21:14 AM
Thanks - I have a little more data.

Some fleets have 1000, 500 and 750 in their capacities, and other fleets don't.

I suspect what's happening is that it's being initialized to that but never properly synced.  Interestingly enough, the CargoData in the Logistics section IS always correct (at least as far as I've seen poking around with a debugger).  Sorry I don't have enough good data to give you a proper bug report on this, and I'll go ahead and try forceSync() some more.

Is there any way to tell how many simulated supplies an AI fleet has?  If not I will just fudge it :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2014, 01:30:35 PM
Is there any way to tell how many simulated supplies an AI fleet has?  If not I will just fudge it :)

"As many as it needs to complete its mission successfully." :) Fudge away!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Darloth on November 06, 2014, 01:58:07 PM
forceSync and the +/-1 supplies trick seems to have sorted that out very nicely.

My next question (sorry, I have a lot tonight!) is: Is there a way to get custom entity icons defined in custom_entities.json to scale on the map like fleets do? I tried scaleNameWithZoom but somewhat predictably it doesn't work on the icon.  Is there a definition of this structure I've missed somewhere so I could see whether there was a scaleIconWithZoom?   (I tried that specific one anyway, but it did nothing)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2014, 02:23:28 PM
No, in fact, that reminds me - I really need to add that. It's causing some problems with station icons in vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 08, 2014, 01:45:25 AM
So what does the default_ship_roles.json in the starsector3\starsector-core\data\world\factions do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 08, 2014, 08:52:32 AM
My guess is that default_ship_roles.json is used to pick a variant for a role when a faction file fails to specify a way to do so. Just a guess though.

Question: What's the best way to force an event to end instantly? Simply using Global.getSector().getEventManager().endEvent(myEvent) seems to make events hang around forever in intel. I've resorted to using myEvent.advance() to force them to expire, but that feels dirty.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 08, 2014, 09:15:40 AM
My guess is that default_ship_roles.json is used to pick a variant for a role when a faction file fails to specify a way to do so. Just a guess though.

Correct.

Question: What's the best way to force an event to end instantly? Simply using Global.getSector().getEventManager().endEvent(myEvent) seems to make events hang around forever in intel. I've resorted to using myEvent.advance() to force them to expire, but that feels dirty.

Hmm. Not at the dev computer now, but this sounds like an issue with endEvent()... will take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on November 08, 2014, 06:00:34 PM
Putting this here since search has failed me but I'm sure it's been asked before; is Starsector's AI code somewhere?  I'd like to make my own AI but without the base AI to work off of I have no idea where to start.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on November 08, 2014, 06:55:51 PM
Putting this here since search has failed me but I'm sure it's been asked before; is Starsector's AI code somewhere?  I'd like to make my own AI but without the base AI to work off of I have no idea where to start.

The vanilla AI is not available to us at all.

And about making your own AI, I strongly advise such a venture. It is literally is the hardest thing to do in the world of modding this game. And no matter how much time you spend on it, nothing you make will ever hold a candle to the vanilla AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 08, 2014, 07:30:34 PM
The Meso speaks truth. However, if you're determined to create a custom AI, your best bet is probably to start from one of xenoarph's AI implementations from Vacuum.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on November 08, 2014, 07:38:06 PM
NikolaiLev, I should have asked this earlier but. Why do you desire custom AI?

In some cases it is possible to add certain kinds of behaviors but you cannot remove any.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 08, 2014, 08:17:21 PM
All this time i've only been spriting and never code. What code lies beneath the .jar in mods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on November 09, 2014, 02:34:46 AM
NikolaiLev, I should have asked this earlier but. Why do you desire custom AI?

In some cases it is possible to add certain kinds of behaviors but you cannot remove any.

Basically, I want fighters that lack lateral/reverse thrusters, and operate more like modern-day fighter planes.  Thus, they rely more on "zoom & boom" tactics, and the end result is fighters that are unique to play against, and resemble traditional "Star Wars style" dogfights.

I've tried using ship systems that disable lateral motion (like the in-game Travel Drive/Full Burn system) but fighters don't obey those restrictions.  And even if they did, the AI wouldn't necessarily know how to fight competently given the lack of lateral motion.

From what I can see, the .6a patch introduced the ability to write an entirely new AI which would allow me to make what I want.  The problem is doing so would be extremely time-consuming, especially for someone with so little experience with java as I.  It'd be one thing if I could take the default fighter AI, clip out the strafing/reversing logic and introduce some new operations for passes (or just make interceptors/fighters/etc.. behave more like bombers without them being subject to bomber fleet assignment), but having to write it from the ground up is likely too much for me to handle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 09, 2014, 05:16:21 AM
How is BeamEffectPlugin instantiated and what is its lifespan?
I added logging in constructor and here is the stack trace when it is created during battle (one more is created during load):
Code
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.fs.starfarer.loading.scripts.ScriptStore.?00000(Unknown Source)
com.fs.starfarer.loading.specs.new.getBeamEffect(Unknown Source)
com.fs.starfarer.combat.entities.BeamWeaponRay.<init>(Unknown Source)
com.fs.starfarer.combat.entities.ship.A.G.?O0000(Unknown Source)
com.fs.starfarer.combat.entities.ship.A.G.createBeam(Unknown Source)
com.fs.starfarer.combat.entities.ship.trackers.class.o00000(Unknown Source)
com.fs.starfarer.combat.entities.ship.trackers.O0OO.o00000(Unknown Source)
com.fs.starfarer.combat.entities.ship.trackers.O0OO.o00000(Unknown Source)
com.fs.starfarer.combat.entities.ship.trackers.class.o00000(Unknown Source)
com.fs.starfarer.combat.entities.ship.A.G.advance(Unknown Source)
com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
com.fs.starfarer.combat.entities.Ship.super(Unknown Source)
com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
Well, I suppose, that this is ran once for each beam, so if I shoot twice I get 2 plugins, correct?

If so, then how can I detect when the beam is removed? Plugin has only "advance" method and I guess it will not be executed after beam is removed. Or will it run also when the beam has zero brightness and then dispose?
Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on November 09, 2014, 04:11:27 PM
First, I want to apologize, I'm going to be asking a lot of low level questions. When I kinda petered away from working my mods for Starfarer, jars and general java stuff was only just coming into play for mods, so I never learned anything about that.

Now I'm building my mod again, basically from scratch, and uh... well I'm going with the tried and true method of learning modding by making a carbon copy of another mod and tweaking the crap out of it until I'm competent (in this case, SCY).

First problem! I've taken a look at the .jars and apparently Notepad++ isn't the tool I need here? I've opened several jar files from various mods and I get nasty strings like this...

Quote
PKETX EOT
NUL NUL BS NUL NUL-_heNUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL     NUL EOT NULMETAINF/

...and so on, lots of gibberish, lots of null entries. So what tool are you guys using?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 09, 2014, 04:33:16 PM
I use netbean to compile my java files into a jar (that allow the use of more functions in the scripts, debugging and in general is super useful). If you want to take a look at my files, they all are located in jar/src/data. But as you can guess, if you want to use them you will neet to compile your mod. There is a pair of very useful tutorials here (http://fractalsoftworks.com/forum/index.php?topic=3173.0) and here (http://fractalsoftworks.com/forum/index.php?topic=7957.0) to get you started. the only thing not precised when setting up netbean (probably because it's old) is to make sure you download java 7 SDK and set this one in your project.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 09, 2014, 04:36:52 PM
@Lcu and Austupaio:
Jars contain the same code you find in mods that don't have jars, but the code is already compiled (http://en.wikipedia.org/wiki/Compiler). You can extract jars with 7zip to see what's inside them.
More about jars (http://en.wikipedia.org/wiki/JAR_(file_format))

If so, then how can I detect when the beam is removed?
I've run into this issue as well. I don't know of a proper way to do it, there might not be one. In fact, it might warrant an API suggestion. The best solution I can think of is to use an EveryFrameWeaponEffectPlugin and iterate over engine.getBeams() to find the one belonging to your weapon as soon as weapon.isFiring()
Not exactly elegant...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on November 09, 2014, 04:41:25 PM
Argh, now that I'm starting to recall, I started falling off modding because it became so Java intensive. I don't really have time to learn all that and my limited Lua knowledge isn't carrying me.

Oh well, I'll see what I can do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 09, 2014, 04:50:45 PM
btw, if you want a clean mod to copy carbon over, I'd suggest taking Shadowyards... I have olds files all over the place and even a few mistakes. (but you can check the scripts all you want, I tried to comment most of them)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on November 09, 2014, 04:54:58 PM
Actually checking out both, haha.

So for my own purposes at the moment, is a jar compilation strictly necessary or just better than loose files?

Edit; :o I have missed a lot, ships have normal maps now? :D Alright, I'm no stranger to those, but what are the material and surface graphics, they're clearly not intended to be the diffuse or specular maps?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 09, 2014, 05:23:23 PM
Actually checking out both, haha.

So for my own purposes at the moment, is a jar compilation strictly necessary or just better than loose files?

Edit; :o I have missed a lot, ships have normal maps now? :D Alright, I'm no stranger to those, but what are the material and surface graphics, they're clearly not intended to be the diffuse or specular maps?

Jar compilation isn't strictly necessary, but it allows you to get around Janino's lack of generics. Generics are again not strictly necessary, but makes working with the various map/list/container objects in java much easier. If you are using an IDE (I use Netbeans) then making a jar is worthwhile because its so easy to do, but helps to catch errors.

Ships don't need to have normal maps etc. I for one am sad that so many mods are moving to ShaderLib, because my POS computer cannot run it at high enough setting for it to look any good. So I'm watching my mods drop off one by one :P.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on November 09, 2014, 05:25:53 PM
Quote
to get around Janino's lack of generics. Generics are again not strictly necessary, but makes working with the various map/list/container objects in java much easier.
I absolutely know what you're talking about, yep. Quite right. That's the ticket. In any case, I'll keep it separate until I have a better understand of all this and then worry about compiling.

Quote
Ships don't need to have normal maps etc. I for one am sad that so many mods are moving to ShaderLib, because my POS computer cannot run it at high enough setting for it to look any good. So I'm watching my mods drop off one by one.
Yeah, I'm seeing that's a ShaderLib thing and so far not standard throughout mods... I think for now I'm going to skip on the side of things to save myself time and since apparently it is a concern for some people that it lowers performance.

Bleh, I wish modding APIs were more consistent with language use, I have to use lua for this game, CC/Python for that game, Java for this game. It just means that I can't keep any of it current in my head. :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 09, 2014, 05:30:20 PM
The reason most modders have gone down the path of using compiled JAR format is to get around the restrictions of Janino. With version of Janino shipped with SS you are not allowed to use generics (another topic), this makes programming for loose files a little more difficult.

Because it is precompiled the game loads faster as well, as Janino does not have to compile it on game load.

But despite all that more serious modders use netbeans/eclipse IDEs as an environment to code because it just makes coding easier, and finds mistakes that you make before you compile them. Precompiling it also means that any compile errors Janino would have found are discovered as well, this means you aren't changing your code, starting the game, and checking if Janino throws an error, modifying your code then needing to repeat that until it works.

So a compiled JAR format has advantages is also adding speed and quality to your coding development.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 09, 2014, 05:38:21 PM
I wouldn't put off setting up an IDE and compiling for too long, Austupaio. It might take a while to set up and learn, but once you do you'll be able to code and troubleshoot two or three times faster. (i.e. What Debido just said)

I for one am sad that so many mods are moving to ShaderLib, because my POS computer cannot run it at high enough setting for it to look any good. So I'm watching my mods drop off one by one :P.
Have you tried setting "enableShaders":false in mods/ShaderLib/shaderSettings.json? Pretty sure that disables all of ShaderLib's features while still allowing you to keep SaderLib (and ShaderLib requiring mods) active.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on November 09, 2014, 05:40:01 PM
Well, I've got to put it off for a little while because I don't even recall what IDE stands for. :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on November 09, 2014, 06:00:43 PM
I for one am sad that so many mods are moving to ShaderLib, because my POS computer cannot run it at high enough setting for it to look any good. So I'm watching my mods drop off one by one :P.

I think for now I'm going to skip on the side of things to save myself time and since apparently it is a concern for some people that it lowers performance.

If your computer cannot handle the system requirements of ShaderLib or you dislike the aesthetic, open the shaderSettings.json in the ShaderLib mod folder and disable or adjust the options.

Then mods that need ShaderLib keep running and it has zero performance impact or visual changes at all!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on November 09, 2014, 06:04:10 PM
Integrated Development Environment: the thing that newfangled programmers use these days to increase productivity in their first few decades of programming, and an useful tool besides for large-scale projects and learning new languages.  It's not strictly necessary but all but the most veteran (like 40+ years) programmers would be slowed down considerably without it.  For something like this, it's indispensable.

ShaderLib has no performance impact whatsoever (memory, CPU, GPU, etc), if you set enableShaders to false.

Material Maps are a legacy term for the first type of user-defined auxiliary textures I added.  Basically, they control the reflective color of the sprite.  I believe the proper term for this is actually a surface map, which is confusing considering I use that term for something else.

Normal Maps are obvious.

Surface Maps are sort of combination specular maps and glow maps.  The red channel influences the sprite's ambient brightness.  Because Starsector uses built-in ambient brightness, this channel is basically never used unless you need it for a TC.  I might change it to something else later down the line if I need an extra map.  The green channel is specular intensity and the blue channel is specular hardness.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on November 09, 2014, 06:10:49 PM
Thanks for the explanations, I'll keep that in mind for when I work on adding those features. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 10, 2014, 03:07:25 AM
I took a look inside a mod's jar, most of the files are .class type files. These are just the same as the scripts in .java files right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 10, 2014, 03:21:51 AM
The .class files are pre-compiled 'bytecode'
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on November 10, 2014, 07:31:48 PM
I'm probably being daft, but forum searches aren't turning anything useful up for campaign career choice integration.  I'd like to allow the player to choose to start with a mod ship, allied with the mod faction, and starting in the planet, but without overriding existing vanilla choices.  Right now I've put the options in rules.csv but these override vanilla choices, leaving only mod choices to choose.

Is it possible to use rules.csv to add new game career choices or must I use a java script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 10, 2014, 09:23:27 PM
You should be able to add new choices through rules.csv, though depending on what you want to do as a result of those being chosen, you might need to add some java code to make it happen.

As to what's going wrong, it's hard to say w/o seeing your rules.csv. Have you read the documentation on rule scripting?http://fractalsoftworks.com/forum/index.php?topic=8355.0

I'd say it's pretty much required reading if you're going to mess with it in any significant way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Aklyon on November 12, 2014, 11:54:53 AM
So, I think I've been overthinking things too much since I can't find the latter anywhere, but I thought I'd ask my dumb question here anyway.
Do people make new weapons by modifying .wpn files they've copied from starsector-core, or is there a reference I'm missing that describes how to make one without duplicating other weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on November 13, 2014, 08:16:13 AM
So, I think I've been overthinking things too much since I can't find the latter anywhere, but I thought I'd ask my dumb question here anyway.
Do people make new weapons by modifying .wpn files they've copied from starsector-core, or is there a reference I'm missing that describes how to make one without duplicating other weapons?

Personally, i copy .wpn files and modify them to my needs. You could write a .txt file and give it the .wpn filetype, but i dont see why you would.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 13, 2014, 11:05:00 PM
In my mod I have a concept of having neutral stations, that do not spawn any fleets - they just serve as exchange points for all other factions. But with 0.65 stations automatically spawn a ton of fleets. How can I avoid it without overriding impl scripts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on November 13, 2014, 11:53:55 PM
Try setting their faction to neutral as abandoned station is right now. Not sure if they wont spawn fleets, but as long as they have no conditions with supplies - they should not spawn freighter fleets. Can`t say if they will attract any faction fleets though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 14, 2014, 12:27:52 AM
Try setting their faction to neutral as abandoned station is right now. Not sure if they wont spawn fleets, but as long as they have no conditions with supplies - they should not spawn freighter fleets. Can`t say if they will attract any faction fleets though.
Then they spawn no fleets alright, but nobody will visit them either. You can probably add the market to the SharedData lists:
SharedData.getData().getMarketsWithoutTradeFleetSpawn()
Also remove it from the market that spawn relief fleets maybe, I'm not sure this one disable that too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on November 14, 2014, 07:22:39 AM
Quote
As far as the files, you're going to run into trouble since some of the text (such as, say, the labels in ship tooltips) are directly in code and not in any text file.
Does that include $ShiporFleet thing? It messes up a lot of battle report messages and other things.
We're doing this translation project anyway, though :P
Having fun translating the codex.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 14, 2014, 09:23:17 AM
In my mod I have a concept of having neutral stations, that do not spawn any fleets - they just serve as exchange points for all other factions. But with 0.65 stations automatically spawn a ton of fleets. How can I avoid it without overriding impl scripts?

Take a look at com.fs.starfarer.api.impl.campaign.shared.SharedData

In particular:
private Set<String> marketsWithoutTradeFleetSpawn = new HashSet<String>();
private Set<String> marketsWithoutPatrolSpawn = new HashSet<String>();

Adding your market ids to those should cover all the spawns ("patrol" covers both mercs/pirates and regular patrols, iirc).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 14, 2014, 10:43:41 AM
I got it, thanks for the replies! But could you tell also when am I supposed to call this? I tried adding this right after creating the station, but its market was null. I suppose that I need to pass market id there, so I need to call it at at moment when it is already created, but not after the game started running (or even simulating economy).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 14, 2014, 10:53:48 AM
I figured it out on my own. Seems that BaseModPlugin.onNewGameAfterTimePass() is a suitable place to do this. Again, thanks for your help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 14, 2014, 10:39:06 PM
Trying out generating some systems with this code (all i did was make sections of the code comments, and change the values)
Code
package data.scripts.world.renisim_systems;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

public class Lorenais {

public void generate(SectorAPI sector) {
StarSystemAPI system = sector.createStarSystem("Lorenais");
LocationAPI hyper = Global.getSector().getHyperspace();

        system.getLocation().set(1500,2500);
system.setBackgroundTextureFilename("graphics/backgrounds/background4.jpg");

// create the star and generate the hyperspace anchor for this system
PlanetAPI star = system.initStar("lorenais", // unique id for this star
"star_yellow", // id in planets.json
1000f); // radius (in pixels at default zoom)

system.setLightColor(new Color(244, 255, 75)); // light color in entire system, affects all entities


/*
* addPlanet() parameters:
* 1. Unique id for this planet (or null to have it be autogenerated)
* 2. What the planet orbits (orbit is always circular)
* 3. Name
* 4. Planet type id in planets.json
* 5. Starting angle in orbit, i.e. 0 = to the right of the star
* 6. Planet radius, pixels at default zoom
* 7. Orbit radius, pixels at default zoom
* 8. Days it takes to complete an orbit. 1 day = 10 seconds.
*/
PlanetAPI lorenais1 = system.addPlanet("poliensar", star, "Poliensar", "gas_giant", 36, 450, 1500, 30);
lorenais1.getSpec().setPlanetColor(new Color(75,165,255,255));
lorenais1.getSpec().setAtmosphereColor(new Color(150,150,150,150));
lorenais1.getSpec().setCloudColor(new Color(150,50,255,200));
lorenais1.getSpec().setIconColor(new Color(120,130,100,255));
lorenais1.applySpecChanges();
   //magec1.setCustomDescriptionId("planet_chaxiraxi");

PlanetAPI lorenais2 = system.addPlanet("hexis", star, "Hexis", "desert", 0, 150, 1000, 50);
//lorenais2.setCustomDescriptionId("planet_maxios");
//lorenais2.getSpec().setGlowTexture(Global.getSettings().getSpriteName("hab_glows", "asharu"));
lorenais2.getSpec().setGlowColor(new Color(255,222,51,155));
//lorenais2.getSpec().setUseReverseLightForGlow(true);
lorenais2.applySpecChanges();

SectorEntityToken relay = system.addCustomEntity("lorenais_relay", // unique id
"Lorenais Relay", // name - if null, defaultName from custom_entities.json will be used
"comm_relay", // type of object, defined in custom_entities.json
"renis_imperium"); // faction
relay.setCircularOrbit(star,0, 850, 30);

/* Where are these from? Oh-- a huge csv file. Um. Will let Alex figure that one out.
m1.setCustomDescriptionId("planet_magec_i");
m2.setCustomDescriptionId("planet_magec_ii");
m3.setCustomDescriptionId("planet_achaman"); Not a planet btw.
m31.setCustomDescriptionId("planet_achaman_i");
*/

// Make Magec I proper
/* TODO test via "star_blue" settings in planets.json
magec1.getSpec().setPlanetColor(new Color(200,225,255,255));
magec1.getSpec().setAtmosphereColor(new Color(140,160,225,140));
magec1.getSpec().setCloudColor(new Color(120,140,220,200));
magec1.getSpec().setTilt(36);
magec1.applySpecChanges(); */

/*
* addAsteroidBelt() parameters:
* 1. What the belt orbits
* 2. Number of asteroids
* 3. Orbit radius
* 4. Belt width
* 6/7. Range of days to complete one orbit. Value picked randomly for each asteroid.
*/
// TODO replace these with a better dust cloud system
/*
*system.addAsteroidBelt(star, 100, 3300, 256, 150, 250);
*system.addAsteroidBelt(star, 100, 3700, 256, 150, 250);
        *
*system.addAsteroidBelt(star, 100, 4150, 128, 200, 300);
*system.addAsteroidBelt(star, 100, 4450, 188, 200, 300);
*system.addAsteroidBelt(star, 100, 4675, 256, 200, 300);
        */

/*
* addRingBand() parameters:
* 1. What it orbits
* 2. Category under "graphics" in settings.json
* 3. Key in category
* 4. Width of band within the texture
* 5. Index of band
* 6. Color to apply to band
* 7. Width of band (in the game)
* 8. Orbit radius (of the middle of the band)
* 9. Orbital period, in days
*/

// system.addRingBand(star, "misc", "rings1", 256f, 2, Color.white, 256f, 3200, 80f);
// system.addRingBand(star, "misc", "rings1", 256f, 3, Color.white, 256f, 3400, 100f);
// system.addRingBand(star, "misc", "rings1", 256f, 2, Color.white, 256f, 3600, 130f);
// system.addRingBand(star, "misc", "rings1", 256f, 3, Color.white, 256f, 3800, 80f);

// system.addRingBand(star, "misc", "rings1", 256f, 2, Color.white, 256f, 4000, 80f);
// system.addRingBand(star, "misc", "rings1", 256f, 3, Color.white, 256f, 4100, 120f);
// system.addRingBand(star, "misc", "rings1", 256f, 2, Color.white, 256f, 4200, 160f);

// system.addRingBand(a2, "misc", "rings1", 256f, 0, Color.white, 256f, 1700, 50f);
// system.addRingBand(a2, "misc", "rings1", 256f, 0, Color.white, 256f, 1700, 70f);
// system.addRingBand(a2, "misc", "rings1", 256f, 1, Color.white, 256f, 1700, 90f);
// system.addRingBand(a2, "misc", "rings1", 256f, 1, Color.white, 256f, 1700, 110f);

// system.addRingBand(star, "misc", "rings1", 256f, 3, Color.white, 256f, 4300, 140f);
// system.addRingBand(star, "misc", "rings1", 256f, 3, Color.white, 256f, 4400, 180f);
// system.addRingBand(star, "misc", "rings1", 256f, 3, Color.white, 256f, 4500, 220f);

// system.addRingBand(star, "misc", "rings1", 256f, 0, Color.white, 256f, 4500, 100f);
// system.addRingBand(star, "misc", "rings1", 256f, 0, Color.white, 256f, 4600, 140f);
// system.addRingBand(star, "misc", "rings1", 256f, 0, Color.white, 256f, 4700, 160f);
// system.addRingBand(star, "misc", "rings1", 256f, 1, Color.white, 256f, 4800, 180f);

// SectorEntityToken civilianStation = system.addOrbitalStation("new_maxios", star, 0, 3900, 80, "New Maxios", "independent");
// initCivilianStationCargo(civilianStation);
// civilianStation.setCustomDescriptionId("station_new_maxios");

// rumoured to have the finest cocktail lounge in the entire Sector
// SectorEntityToken tritachStation = system.addOrbitalStation("port_tse", star, 120, 4750, 175, "Port Tse Franchise Station #3", "tritachyon");
// initTritachStationCargo(tritachStation);
// tritachStation.setCustomDescriptionId("station_tse_enterprise");
// tritachStation.setInteractionImage("illustrations", "space_bar");

// SectorEntityToken pirateStation = system.addOrbitalStation("kantas_den", star, 240, 4250, 150, "Kanta's Den", "pirates");
// initPirateStationCargo(pirateStation);
// pirateStation.setCustomDescriptionId("station_kantas_den");
// pirateStation.setInteractionImage("illustrations", "pirate_station");

JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("hexis_jump_point", "Hexis Jump Point");
OrbitAPI orbit = Global.getFactory().createCircularOrbit(lorenais2, 0, 500, 30);
jumpPoint.setOrbit(orbit);
jumpPoint.setRelatedPlanet(lorenais2);
jumpPoint.setStandardWormholeToHyperspaceVisual();
system.addEntity(jumpPoint);

// example of using custom visuals below
// a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
// jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
// station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));

// generates hyperspace destinations for in-system jump points
system.autogenerateHyperspaceJumpPoints(true, true);

/*
DiktatPatrolSpawnPoint patrolSpawn = new DiktatPatrolSpawnPoint(sector, system, 5, 3, a1);
system.addScript(patrolSpawn);
for (int i = 0; i < 5; i++)
patrolSpawn.spawnFleet();

DiktatGarrisonSpawnPoint garrisonSpawn = new DiktatGarrisonSpawnPoint(sector, system, 30, 1, a1, a1);
system.addScript(garrisonSpawn);
garrisonSpawn.spawnFleet();
*/

//system.addScript(new IndependentTraderSpawnPoint(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), station));
}
    /*
private void initCivilianStationCargo(SectorEntityToken station) {
CargoAPI cargo = station.getCargo();
addRandomWeapons(cargo, 5);

cargo.addCrew(CrewXPLevel.VETERAN, 10);
cargo.addCrew(CrewXPLevel.REGULAR, 100);
cargo.addMarines(20);
cargo.addSupplies(500);
cargo.addFuel(100);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "mercury_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "hermes_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "gemini_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "buffalo_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "mining_drone_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "mining_drone_wing"));
}

private void initTritachStationCargo(SectorEntityToken station) {
CargoAPI cargo = station.getCargo();
addRandomWeapons(cargo, 5);

cargo.addCrew(CrewXPLevel.VETERAN, 10);
cargo.addCrew(CrewXPLevel.REGULAR, 100);
cargo.addMarines(20);
cargo.addSupplies(500);
cargo.addFuel(100);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "mercury_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "hermes_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "gemini_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "buffalo_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "mining_drone_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "mining_drone_wing"));
}

private void initPirateStationCargo(SectorEntityToken station) {
CargoAPI cargo = station.getCargo();
addRandomWeapons(cargo, 5);

cargo.addCrew(CrewXPLevel.VETERAN, 10);
cargo.addCrew(CrewXPLevel.REGULAR, 100);
cargo.addMarines(20);
cargo.addSupplies(500);
cargo.addFuel(100);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "mercury_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "hermes_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "gemini_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "buffalo_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "mining_drone_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "mining_drone_wing"));
}


private void initStationCargo(SectorEntityToken station) {
CargoAPI cargo = station.getCargo();
addRandomWeapons(cargo, 5);

cargo.addCrew(CrewXPLevel.VETERAN, 20);
cargo.addCrew(CrewXPLevel.REGULAR, 500);
cargo.addMarines(200);
cargo.addSupplies(1000);
cargo.addFuel(500);

cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
}

private void addRandomWeapons(CargoAPI cargo, int count) {
List weaponIds = Global.getSector().getAllWeaponIds();
for (int i = 0; i < count; i++) {
String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
int quantity = (int)(Math.random() * 4f + 2f);
cargo.addWeapons(weaponId, quantity);
}
}
    */
}
Made this crash happen :
Code
java.lang.RuntimeException: Error compiling [data.scripts.world.renis_lorenais]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit "com.fs.starfarer.loading.A$1@168fb7"
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:180)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:158)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:199)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:164)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Source file "data/scripts/world/renis_lorenais.java" does not declare class "data.scripts.world.renis_lorenais"
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:165)
... 7 more
I am a noob coder, what is wrong with the script above?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 14, 2014, 10:56:43 PM
First of all

declaration should probably be

public class Lorenais implements SectorGeneratorPlugin

After removing the commented stuff so I could actually see what was actually there:

Code
package data.scripts.world.renisim_systems;

import java.awt.Color;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;

public class Lorenais implements SectorGeneratorPlugin {

    public void generate(SectorAPI sector) {
        StarSystemAPI system = sector.createStarSystem("Lorenais");
        LocationAPI hyper = Global.getSector().getHyperspace();

        system.getLocation().set(1500, 2500);
        system.setBackgroundTextureFilename("graphics/backgrounds/background4.jpg");

        // create the star and generate the hyperspace anchor for this system
        PlanetAPI star = system.initStar("lorenais", // unique id for this star
                "star_yellow", // id in planets.json
                1000f); // radius (in pixels at default zoom)

        system.setLightColor(new Color(244, 255, 75)); // light color in entire system, affects all entities

        PlanetAPI lorenais1 = system.addPlanet("poliensar", star, "Poliensar", "gas_giant", 36, 450, 1500, 30);
        lorenais1.getSpec().setPlanetColor(new Color(75, 165, 255, 255));
        lorenais1.getSpec().setAtmosphereColor(new Color(150, 150, 150, 150));
        lorenais1.getSpec().setCloudColor(new Color(150, 50, 255, 200));
        lorenais1.getSpec().setIconColor(new Color(120, 130, 100, 255));
        lorenais1.applySpecChanges();
        //magec1.setCustomDescriptionId("planet_chaxiraxi");

        PlanetAPI lorenais2 = system.addPlanet("hexis", star, "Hexis", "desert", 0, 150, 1000, 50);
//lorenais2.setCustomDescriptionId("planet_maxios");
        //lorenais2.getSpec().setGlowTexture(Global.getSettings().getSpriteName("hab_glows", "asharu"));
        lorenais2.getSpec().setGlowColor(new Color(255, 222, 51, 155));
        //lorenais2.getSpec().setUseReverseLightForGlow(true);
        lorenais2.applySpecChanges();

        SectorEntityToken relay = system.addCustomEntity("lorenais_relay", // unique id
                "Lorenais Relay", // name - if null, defaultName from custom_entities.json will be used
                "comm_relay", // type of object, defined in custom_entities.json
                "renis_imperium"); // faction
        relay.setCircularOrbit(star, 0, 850, 30);

        JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("hexis_jump_point", "Hexis Jump Point");
        OrbitAPI orbit = Global.getFactory().createCircularOrbit(lorenais2, 0, 500, 30);
        jumpPoint.setOrbit(orbit);
        jumpPoint.setRelatedPlanet(lorenais2);
        jumpPoint.setStandardWormholeToHyperspaceVisual();
        system.addEntity(jumpPoint);

        system.autogenerateHyperspaceJumpPoints(true, true);

    }

}


This appears correct in the IDE
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 14, 2014, 11:20:05 PM
Hmm, still generates the same crash, but thanks, because that declaration error will cause another crash in the future.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on November 15, 2014, 10:51:44 AM
Putting this here since search has failed me but I'm sure it's been asked before; is Starsector's AI code somewhere?  I'd like to make my own AI but without the base AI to work off of I have no idea where to start.

So, I know what vanilla AI is obfuscated.  Is there any chance of either 1) Unobfuscating it or 2) Allowing custom AI to callback to default AI behaviors?  That would allow modders to implement custom AI without building it from scratch.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 15, 2014, 10:58:36 AM
So, I know what vanilla AI is obfuscated.  Is there any chance of either 1) Unobfuscating it or 2) Allowing custom AI to callback to default AI behaviors?  That would allow modders to implement custom AI without building it from scratch.

1) No, because it's an internal part of the game and is not in any shape suitable to being exposed. If I were to code it *now*, I'd probably put the code in .api.impl, but that's not how it worked out, and exposing it would be extremely time-consuming.

2) No, because the AI is not structured in a way that makes this possible, because it wasn't designed for that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on November 15, 2014, 11:01:00 AM
Putting this here since search has failed me but I'm sure it's been asked before; is Starsector's AI code somewhere?  I'd like to make my own AI but without the base AI to work off of I have no idea where to start.

So, I know what vanilla AI is obfuscated.  Is there any chance of either 1) Unobfuscating it or 2) Allowing custom AI to callback to default AI behaviors?  That would allow modders to implement custom AI without building it from scratch.

There are complete AIs from scratch that are functional and very well made, check out xenoargh mod. You can ask permission and use it, I'm sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 16, 2014, 08:09:21 PM
Is there any way to turn off the energy damage boost with flux? I'm just playing around with things and wondering. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2014, 08:21:27 PM
No, there isn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on November 16, 2014, 08:58:17 PM
No, there isn't.
You can probably work around this with an every frame combat plugin that adjusts energy weapon damage inversely.  Might take a bit of work to make it function properly, and there might be some corner cases with high flux-per-shot weapons like the antimatter blaster...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 16, 2014, 09:00:07 PM
Not directly...buuuuuut.

blah extends BaseHullMod

    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {

FluxTrackerAPI ft = ship.getFluxTracker();
float fluxPercent = ft.getCurrFlux() / ft.getMaxFlux();

ship.getMutableStats().getEnergyWeaponDamageMult().modifyPercent("my_hullmod", -1f * (fluxPercent * 50f));

}

Something like anyway, I've just highlighted the multiply by a negative as it means you're taking away flux damage, not adding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2014, 09:17:41 PM
Oh, hm. Yeah, that seems like it would work :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 16, 2014, 09:23:03 PM
Thanks everyone!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Erick Doe on November 17, 2014, 05:54:32 AM
I know how to get things working if I create my own system and add my own entities.

But for now I'd just like to add quick compatibility with [0.65.1a] for Tore Up Plenty.

However, I am currently confused as to why the following isn't working:

Code
package data.scripts.world;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.InteractionDialogImageVisual;
import com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

import data.scripts.world.corvus.Corvus;

@SuppressWarnings( "unchecked" )
public class TUPGen implements SectorGeneratorPlugin {

public void generate( SectorAPI sector ) {

sector.registerPlugin(new CoreCampaignPluginImpl());

    StarSystemAPI system = sector.getStarSystem("Corvus");

SectorEntityToken sol = system.createToken(0, 0);
    SectorEntityToken token = system.createToken(2500, 15000);
SectorEntityToken TUPstation = system.addOrbitalStation(sol, 300, 5500, 100, "Scrapyard", "scavengers");

It lists the following error:
Quote
caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/world/TUPGen.java, Line 32, Column 59: No applicable constructor/method found for actual parameters "com.fs.starfarer.api.campaign.SectorEntityToken, int, int, int, java.lang.String, java.lang.String"; candidates are: "public abstract com.fs.starfarer.api.campaign.SectorEntityToken com.fs.starfarer.api.campaign.LocationAPI.addOrbitalStation(java.lang.String, com.fs.starfarer.api.campaign.SectorEntityToken, java.lang.String, java.lang.String, float, float, float, float, java.lang.String, java.lang.String)", "public abstract com.fs.starfarer.api.campaign.SectorEntityToken com.fs.starfarer.api.campaign.LocationAPI.addOrbitalStation(java.lang.String, com.fs.starfarer.api.campaign.SectorEntityToken, float, float, float, java.lang.String, java.lang.String)"

Why can't I add an orbital station using the SectorEntityToken anymore?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 17, 2014, 06:55:58 AM
theyre not used any more, see the sector gen for Corvus for custom entities as stations to which you add markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 17, 2014, 08:29:52 AM
I thought this code for the gen file have no syntax error, right?
Code
//*snip*
player.setRelationship(renisim.getId(), 0);
diktat.setRelationship(renisim.getId(), RepLevel.HOSTILE);
independent.setRelationship(renisim.getId(), RepLevel.WELCOMING);
pirates.setRelationship(renisim.getId(), RepLevel.HOSTILE);
//*snip*
After testing it, it caused this crash :
Code
java.lang.RuntimeException: Error compiling [data.scripts.world.renisim_gen]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit "com.fs.starfarer.loading.A$1@1f417ca"
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:180)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:158)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:199)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:164)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File data/scripts/world/renisim_gen.java, Line 50, Column 15: ';' expected instead of 'player'
at org.codehaus.janino.Parser.compileException(Parser.java:2635)
at org.codehaus.janino.Parser.read(Parser.java:2370)
at org.codehaus.janino.Parser.parseBlockStatement(Parser.java:1017)
at org.codehaus.janino.Parser.parseBlockStatements(Parser.java:938)
at org.codehaus.janino.Parser.parseMethodDeclarationRest(Parser.java:804)
at org.codehaus.janino.Parser.parseClassBodyDeclaration(Parser.java:442)
at org.codehaus.janino.Parser.parseClassBody(Parser.java:393)
at org.codehaus.janino.Parser.parseClassDeclarationRest(Parser.java:372)
at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:251)
at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:153)
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:150)
... 7 more
According to the crash log, the player in player.setRelationship(renisim.getId(), 0); is considered by the engine as a syntax error.
Is the code above in a correct syntax?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 17, 2014, 08:43:24 AM
Here's mine, it also set relations to modded factions if they are present, and add named bounties:
Code: java
public static void initFactionRelationships(SectorAPI sector) {

        FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
        FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
        FactionAPI pirates = sector.getFaction(Factions.PIRATES);
        FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
        FactionAPI kol = sector.getFaction(Factions.KOL);
        FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
        FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);
        FactionAPI player = sector.getFaction(Factions.PLAYER);
        FactionAPI diktat = sector.getFaction(Factions.DIKTAT);

        FactionAPI scy = sector.getFaction("SCY");

        player.setRelationship(scy.getId(), RepLevel.SUSPICIOUS);
        scy.setRelationship(player.getId(), RepLevel.SUSPICIOUS);
        scy.setRelationship(path.getId(), RepLevel.HOSTILE);
        scy.setRelationship(hegemony.getId(), RepLevel.INHOSPITABLE);
        scy.setRelationship(pirates.getId(), RepLevel.HOSTILE);
        scy.setRelationship(diktat.getId(), RepLevel.INHOSPITABLE);
        scy.setRelationship(church.getId(), RepLevel.HOSTILE);
        scy.setRelationship(kol.getId(), RepLevel.SUSPICIOUS);
        scy.setRelationship(tritachyon.getId(), RepLevel.INHOSPITABLE);
        scy.setRelationship(independent.getId(), RepLevel.FRIENDLY);

        //modded factions
        FactionAPI sra = sector.getFaction("shadow_industry");
        FactionAPI pirateAnar = sector.getFaction("pirateAnar");
        FactionAPI mayorate = sector.getFaction("mayorate");
        FactionAPI ice = sector.getFaction("sun_ice");
        FactionAPI ici = sector.getFaction("sun_ici");
        FactionAPI citadel = sector.getFaction("citadeldefenders");
FactionAPI II = sector.getFaction("interstellarimperium");

        if (sra != null) {
            scy.setRelationship(sra.getId(), RepLevel.WELCOMING);
        }
        if (pirateAnar != null) {
            scy.setRelationship(pirateAnar.getId(), RepLevel.HOSTILE);
        }
        if (mayorate != null) {
            scy.setRelationship(mayorate.getId(), RepLevel.SUSPICIOUS);
        }
        if (ice != null) {
            scy.setRelationship(ice.getId(), RepLevel.NEUTRAL);
        }
        if (ici != null) {
            scy.setRelationship(ici.getId(), RepLevel.HOSTILE);
        }
        if (citadel != null) {
            scy.setRelationship(citadel.getId(), RepLevel.FAVORABLE);
        }
       
        if (II != null) {
            scy.setRelationship(uglystals.getId(), RepLevel.INHOSPITABLE);
        }
//named bounties
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("SCY");
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 18, 2014, 12:24:18 AM
Thanks, but how about neutral relations to a faction? You don't have to define it right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 18, 2014, 12:43:06 AM
Neutral is the default relationship, you still can set it explicitly if you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 18, 2014, 01:40:58 AM
I am sorry for asking too much questions, but somehow i am still unable to set up my faction's system. I have set up the faction file, gen file, and the system file itself (in .java).
Faction file :
Code
{
id:"renis_imperium",
"color":[224,213,37,255],
"baseUIColor":[59,76,90,255],
"darkUIColor":[39,56,70,175],
"gridUIColor":[65,82,96,75],

#"darkUIColor":[100,100,100,175],
#"gridUIColor":[120,120,120,75],

#"color":[170,0,110,255],
"displayName":"Renis Imperium",
"logo":"graphics/renis/factions/renis_imperium.png",
"displayNameWithArticle":"the Renis Imperium",
"shipNamePrefix":"RIS",
"shipNameSources":{
"BRITISH_NAVY":1,
"ROMAN":1,
"GREEK":1,
},
"names":{
"old english":1,
},
"illegalCommodities":[
"drugs",
"organs",
],
"internalComms":"renis_imperium_internal",
"portraits":{
"standard_male":[
"graphics/portraits/portrait_hegemony01.png",
"graphics/portraits/portrait_hegemony02.png",
"graphics/portraits/portrait_hegemony05.png",
"graphics/portraits/portrait_mercenary01.png",
"graphics/portraits/portrait_mercenary03.png",
"graphics/portraits/portrait13.png",
"graphics/portraits/portrait15.png",
],
"standard_female":[
"graphics/portraits/portrait_hegemony03.png",
"graphics/portraits/portrait_hegemony04.png",
"graphics/portraits/portrait_mercenary02.png",
"graphics/portraits/portrait16.png",
],
},
"shipRoles":{
"interceptor":{
"r_seberat_wing":10,
"thunder_wing":10,
"fallback":{"fighter":1},
},
"fighter":{
"r_seberat_wing":10,
"fallback":{"interceptor":1},
},
"bomber":{
"piranha_wing":10,
},

"fastAttack":{
"r_enim_support":10,
"r_enim_assault":10,
"r_fasustport_assault":2,
"fallback":{"combatSmall":1},
},

"escortSmall":{
"r_enim_support":10,
"r_dreneder_balanced":1,
"r_enim_assault":10,
"fallback":{"combatSmall":1},
},
"escortMedium":{
"r_arloneria_balanced":10,
"r_arloneria_flas":10,
"r_fasustport_elite":10,
"r_fasustport_assault":10,
"fallback":{"combatMedium":1},
},

"combatSmall":{
"r_enim_assault":10,
"r_enim_support":10,
"r_dreneder_balanced":10,
"fallback":{"escortSmall":1},
},
"combatMedium":{
"r_fasustport_assault":10,
"r_fasustport_elite":10,
"r_fasustport_support":10,
"r_arloneria_balanced":10,
"r_arloneria_flas":10,
"sunder_CS":10,
"sunder_Assault":10,
"fallback":{"combatSmall":2},
},
"combatLarge":{
"r_minet_balanced":10,
"fallback":{"combatMedium":2},
},
"combatCapital":{
"r_ultima_balanced":10,
"fallback":{"combatLarge":2},
},


# hybrid ships with good combat and cargo capacity
"combatFreighterSmall":{
"fallback":{"freighterSmall":1},
},
"combatFreighterMedium":{
"fallback":{"combatFreighterSmall":2},
},
"combatFreighterLarge":{
"fallback":{"combatFreighterMedium":2},
},

"civilianRandom":{
"mercury_Standard":10,
"hermes_Standard":10,
"fallback":{"freighterSmall":1},
},

# carriers
"carrierSmall":{
"r_cafarrstier_support":10,
"fallback":{"carrierMedium":1},
},
"carrierMedium":{
"fallback":{"carrierSmall":2},
},
"carrierLarge":{
"fallback":{"carrierMedium":2},
},

# freighters and such
"freighterSmall":{
"hermes_Standard":10,
"fallback":{"freighterMedium":1},
},
"freighterMedium":{
"buffalo_Standard":10,
"fallback":{"freighterSmall":2},
},
"freighterLarge":{
"atlas_Standard":10,
"fallback":{"freighterMedium":2},
},

"tankerSmall":{
"dram_Light":10,
"fallback":{"tankerMedium":1},
},
"tankerMedium":{
"phaeton_Standard":10,
"fallback":{"tankerSmall":2},
},
"tankerLarge":{
"prometheus_Super":10,
"fallback":{"tankerMedium":2},
},

"personnelSmall":{
"mercury_Standard":10,
"fallback":{"personnelMedium":1},
},
"personnelMedium":{
"valkyrie_Elite":10,
"fallback":{"personnelSmall":2},
},
"personnelLarge":{
"fallback":{"personnelMedium":2},
},

# utility ships
"tug":{
"ox_Standard":10,
"fallback":{"utility":1},
},
"crig":{
"crig_Standard":10,
"fallback":{"utility":1},
},
"utility":{
"crig_Standard":10,
"ox_Standard":10,
},
},
"traits":{
"admiral":{
},
"captain":{
"cowardly":1,
"cautious":1,
"steady":1,
"aggressive":1,
"suicidal":1,
"fearless":1,
},
},
"dialogue":{
"greetingFriendly":"RIIC received. Friendly status confirmed. Good to see you.",
"greetingNeutral":"You have been scanned and identified. Communique on protocol Nu established. Over.",
"greetingHostileAggressive":"For violation of Rule 98 of the , power down your vessel and surrender. Over.",
"greetingHostileTimid":"For violation of Rule 56 of the , nearby patrol fleets has already been dispatched to intercept your fleet. You are advised to power down weapon systems and surrender. Over.",
}
},

Gen file :
Code
package data.scripts.world;

import java.awt.Color;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl;
import com.fs.starfarer.api.impl.campaign.CoreScript;
import com.fs.starfarer.api.impl.campaign.events.CoreEventProbabilityManager;
import com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager;
import com.fs.starfarer.api.impl.campaign.ids.Factions;

import data.scripts.world.renisimsystems.Lorenais;

public class renisim_gen implements SectorGeneratorPlugin {

    public void generate(SectorAPI sector) {

        initFactionRelationships(sector);
        new Lorenais().generate(sector);


// }
    }

    public static void initFactionRelationships(SectorAPI sector) {

        FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
        FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
        FactionAPI pirates = sector.getFaction(Factions.PIRATES);
        FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
        FactionAPI kol = sector.getFaction(Factions.KOL);
        FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
        FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);
        FactionAPI player = sector.getFaction(Factions.PLAYER);
        FactionAPI diktat = sector.getFaction(Factions.DIKTAT);

        FactionAPI ren = sector.getFaction("renis_imperium");

        player.setRelationship(ren.getId(), RepLevel.NEUTRAL);
        ren.setRelationship(player.getId(), RepLevel.NEUTRAL);
        ren.setRelationship(path.getId(), RepLevel.SUSPICIOUS);
        ren.setRelationship(hegemony.getId(), RepLevel.NEUTRAL);
        ren.setRelationship(pirates.getId(), RepLevel.HOSTILE);
        ren.setRelationship(diktat.getId(), RepLevel.HOSTILE);
        ren.setRelationship(church.getId(), RepLevel.SUSPICIOUS);
        ren.setRelationship(kol.getId(), RepLevel.SUSPICIOUS);
        ren.setRelationship(tritachyon.getId(), RepLevel.INHOSPITABLE);
        ren.setRelationship(independent.getId(), RepLevel.WELCOMING);

        //modded factions 
/*
        FactionAPI sra = sector.getFaction("shadow_industry"); 
        FactionAPI pirateAnar = sector.getFaction("pirateAnar"); 
        FactionAPI mayorate = sector.getFaction("mayorate"); 
        FactionAPI ice = sector.getFaction("sun_ice"); 
        FactionAPI ici = sector.getFaction("sun_ici"); 
        FactionAPI citadel = sector.getFaction("citadeldefenders"); 
   FactionAPI II = sector.getFaction("interstellarimperium"); 
 
        if (sra != null) { 
            ren.setRelationship(sra.getId(), RepLevel.WELCOMING); 
        } 
        if (pirateAnar != null) { 
            ren.setRelationship(pirateAnar.getId(), RepLevel.HOSTILE); 
        } 
        if (mayorate != null) { 
            ren.setRelationship(mayorate.getId(), RepLevel.SUSPICIOUS); 
        } 
        if (ice != null) { 
            ren.setRelationship(ice.getId(), RepLevel.NEUTRAL); 
        } 
        if (ici != null) { 
            ren.setRelationship(ici.getId(), RepLevel.HOSTILE); 
        } 
        if (citadel != null) { 
            ren.setRelationship(citadel.getId(), RepLevel.FAVORABLE); 
        } 
         
        if (II != null) { 
            ren.setRelationship(uglystals.getId(), RepLevel.INHOSPITABLE); 
        } 
*/
        //named bounties
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("renis_imperium");
    }
}

System file :
Code
package data.scripts.world.renisimsystems;

import com.fs.starfarer.api.Global;
//import com.fs.starfarer.api.InteractionDialogImageVisual;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import java.awt.Color;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import java.util.ArrayList;
import java.util.Arrays;

public class Lorenais {

    public void generate(SectorAPI sector) {

        StarSystemAPI system = sector.createStarSystem("Lorenais");
        system.getLocation().set(8500, -8500);
        LocationAPI hyper = Global.getSector().getHyperspace();

        system.setBackgroundTextureFilename("graphics/backgrounds/background4.jpg");

        PlanetAPI lorenais = system.initStar("lorenais", "star_yellow", 800f);

        PlanetAPI lore1 = system.addPlanet("hexis", lorenais, "Hexis", "barren", 36, 80, 1000, 64);
        lore1.setFaction("renis_imperium");

        PlanetAPI lore2 = system.addPlanet("poliensar", lorenais, "Poliensar", "gas_giant", 196, 180, 2250, 179);
        PlanetAPI lore3 = system.addPlanet(null, lore2, "Crelanom", "cryovolcanic", 50, 50, 600, 40);

        system.addRingBand(lore2, "misc", "rings1", 128f, 2, Color.white, 128f, 550, 40f);

        SectorEntityToken relay = system.addCustomEntity("lorenais_relay", // unique id
                "Lorenais Relay", // name - if null, defaultName from custom_entities.json will be used
                "comm_relay", // type of object, defined in custom_entities.json
                "renis_imperium"); // faction
        relay.setCircularOrbit( system.getEntityById("lorenais"), 279, 2000, 485);

        SectorEntityToken l1 = system.getEntityById("hexis");
        JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("hexis_gate", "Hexis Gate");
        OrbitAPI orbit = Global.getFactory().createCircularOrbit(l1, 0, 550, 30);
        jumpPoint.setOrbit(orbit);
        jumpPoint.setRelatedPlanet(l1);

        jumpPoint.setStandardWormholeToHyperspaceVisual();
        system.addEntity(jumpPoint);

        system.autogenerateHyperspaceJumpPoints(true, true);

 
    }
}
Looking into other mod's files, i assume the three files above are the only files necessary to set up a system. But still, it only shows the faction in the intel screen without any known enemies nor allies (even if it has been defined in the gen class) and the systems i am trying to set up are missing. Am i missing something? Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 18, 2014, 02:42:12 AM
Yeah,

You'll need to have a line in your BaseModPlugin file

something like:

Code: java
public class My_modPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        initMyFaction();
}

    private static void initMyFaction() {
        try {
            Global.getSettings().getScriptClassLoader().loadClass("data.scripts.world.ExerelinGen");
            //Got Exerelin, so just Exerelin
        } catch (ClassNotFoundException ex) {
            new MyFaction_gen().generate(Global.getSector());
        }
    }

}


Then in your mod_info.json file ensure you have the following:
Code
  "modPlugin":"data.scripts.My_modPlugin",


So what's happening is

Game engine -> mod_info.json -> modPlugin element (telling it where the modPlugin file is)

modPlugin on New Game -> Init faction -> Sector Generator Plugin --> System File

Not exactly straight forward is it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 18, 2014, 04:38:03 AM
Actually it seems straightforward to me, but i just don't know which files to fiddle with.
Thank you very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on November 21, 2014, 10:04:25 AM
I apologize in advance if the answer to my question was already in this thread.
Why in the files of many mods is a file BaseSpawnPoint.java? Usually it is in the directory "\data\scripts\world".
How it affects the appearance of the faction fleets in the latest version of the game (0.65.1)?
Do the old methods of creating fleets through Spawn Points files works or now they depend only on the properties of the markets?
Thanks in advance for your answers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 21, 2014, 11:56:26 AM
Forget all about the base spawn point, just let market auto generation do its thing. Otherwise the fleet factory in the API is another place to look,  or extending / implementing your own fleet factory.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on November 21, 2014, 11:42:51 PM
Is there any way to check and see all of the possible actions (scripts) you can do in rules.csv? Alex listed "Etc" in the documentation, so I was wondering if there was an easy way to check and see all of the options.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 22, 2014, 06:33:42 AM
So i managed to generate a star system. I defined the location in the .java file for the star system, but when i changed it, it still stays on the same location in a new game. Why can't it change the positions?

(Tested with .jars as well, didn't work as well).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on November 22, 2014, 06:37:39 AM
Do you have a starmap.json in your campaign folder? Maybe that is overriding it?

I cannot immediately think of any other reason...usually it just works. Can you paste your system gen on paste bin? or paste it here. But be sure to use the code=java tag if you do paste it here, helps format it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on November 22, 2014, 12:04:42 PM
Thank you for your answer to my previous question. Sorry for so many questions. Here are some more:
How market properties affect to the fact how often and what fraction fleets appear? Is the number of appearing fleets depends on how the market is filled? Or certain market conditions affect the composition of the fleet? In the end, what are the conditions for planet I have to give to round it was a lot of fleets of certain fraction?
Thanks in advance for your answers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arumac on November 26, 2014, 05:08:01 PM
Hi all, Im making an onhit script for a projectile. Basically, I want it to deal additional damage. I had it working well for awhile, until I realized that it was still dealing the same amount of damage across the board vs shields, armor, AND fortress shields. So I figured I could do something like a target.getShieldAbsorptionMult() to not have it basically ignore defenses. However I figured it wouldn't work, and it doesn't. I'm not aware of any way to modify damage dealt based on a target's shield defense and armor defense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 28, 2014, 02:08:54 AM
Looking into the starfarer api, and i found :
com.fs.starfarer.api.impl.campaign.fleets.FleetFactory

Looks like a great way to add custom fleets,
Also does classes in the .impl package need to be implemented?

EDIT : Nevermind, already tried it myself and it worked.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 29, 2014, 02:51:48 AM
Stupid question - where the hell are systems/planets defined?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on November 29, 2014, 03:13:48 AM
Stupid question - where the hell are systems/planets defined?
In data/scripts/world. These scripts are the ones that define the systems.

Now my question :
In the ship_data.csv there are 3 new values, c, c/fp, and c/l.
What does these do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 29, 2014, 03:32:58 AM
Stupid question - where the hell are systems/planets defined?
data/config/planet.json for the planets

Now my question :
In the ship_data.csv there are 3 new values, c, c/fp, and c/l.
What does these do?
Nothing. Like the 8/6/5/4% column they are derived data that Alex use for balancing (and are automatically calculated with his tools).

Mine  now:
I'm trying to create custom shields using
ship.getShield().setRadius(200, "ART_innerShield", "ART_outerShield");

the API says:
Code
setRadius

void setRadius(float radius,
               java.lang.String textureInner,
               java.lang.String textureRing)

    Textures should be already loaded (i.e. via settings.json).
So I created this in my settings:
   "graphics":{   
      "shields":{
         "ART_outerShield":"graphics/SCY/vectorCruiser/ART_outerShield.png",
         "ART_innerShield":"graphics/SCY/vectorCruiser/ART_innerShield.png",
      },
         },

But I keep getting NPE because the game can't find the texture...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2014, 10:47:29 AM
I'm trying to create custom shields using
ship.getShield().setRadius(200, "ART_innerShield", "ART_outerShield");

the API says:
Code
setRadius

void setRadius(float radius,
               java.lang.String textureInner,
               java.lang.String textureRing)

    Textures should be already loaded (i.e. via settings.json).
So I created this in my settings:
   "graphics":{   
      "shields":{
         "ART_outerShield":"graphics/SCY/vectorCruiser/ART_outerShield.png",
         "ART_innerShield":"graphics/SCY/vectorCruiser/ART_innerShield.png",
      },
         },

But I keep getting NPE because the game can't find the texture...


You need to pass in "graphics/SCY/vectorCruiser/ART_outerShield.png","graphics/SCY/vectorCruiser/ART_innerShield.png".

The way you know which one the game expects is 1) the argument naming convention of category/key, and 2) the fact that here it's only taking a single parameter for each texture. If it was using the category/key form, there'd be 4 parameters - i.e. "shields","ART_outerShield","shields","ART_innerShield".

You still need to have the lines you added to settings.json, though, since that does get the game to load the texture.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 29, 2014, 01:01:26 PM
Mhh, after some trial and errors, I think
void setRadius(float radius,
               java.lang.String textureInner,
               java.lang.String textureRing)

act in fact like:
void setRadius(float radius,
               java.lang.String textureInnerMask,
               java.lang.String textureInner)

because no matter what I put in the second texture, I always have the vanilla ring visible. And the first isn't visible at all but seems to act as a mask for the second texture...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2014, 05:44:18 PM
Ugh, there was a bug where the "ring" parameter was getting assigned to and overwriting the "inner" parameter. Now fixed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on December 05, 2014, 08:31:50 PM
Is there anywhere I can figure out all the possible options for a .system file?  I don't think it's in the API since it's not java.

There's a "weaponTypes": with possible options like BALLISTIC, but there doesn't seem to be a "weaponSizes": value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2014, 08:39:38 PM
There isn't a "weaponSizes", no.

The best way to see what all the possible values are would be to collate the data from vanilla systems. I think that'd about cover it, except for a couple of mod-requested enhancements.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikolaiLev on December 05, 2014, 08:59:33 PM
There isn't a "weaponSizes", no.

The best way to see what all the possible values are would be to collate the data from vanilla systems. I think that'd about cover it, except for a couple of mod-requested enhancements.

Yeah, I did that already.

I'm assuming it's possible to limit what the system applies to through the Stats script?  Or am I unable to make a system that affects only a specific size of weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: carmey on December 08, 2014, 04:26:20 PM
I just can't get to the root of this problem:
I want a beam weapon to play one sound effect when the beam starts charging, and another sound whilst firing. as far as I know, it can be done quite simply in the *.wpn file like this:

Code
	
"fireSoundOne":"file-one",
"fireSoundTwo":"file-two"

But it just won't work, it instead plays both sounds whilst the beam is firing, and nothing during the charge-up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 08, 2014, 04:34:55 PM
nope, it can't. The sounds are played when the beam is created. You'll have to add a script to the weapon to play the charge sound.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: carmey on December 08, 2014, 04:38:37 PM
That's something I'd already considered, and I spent quite a while looking through YOUR scripts to work it out, but I couldn't find anything!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Leith on December 08, 2014, 05:37:27 PM
Hello, gentlemen! I am very interested in modding this wonderful game and I have two questions:

1- I want to create ships for the Sindrian faction. How do I enable the player to access those ships only when he has sufficient influence with the faction, just like the Hegemony? What do I need to add/change? I suspect it has to do with files located in \starsector-core\data\scripts\world.

2- How do I influence the chances of a certain ship(s) being available at a certain station?

I would appreciate a detailed answer for the first question since I'm just learning the ropes here. Thank you for reading this!  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: carmey on December 08, 2014, 08:22:26 PM
nope, it can't. The sounds are played when the beam is created. You'll have to add a script to the weapon to play the charge sound.
Still can't find the weapon script you used in your mod, apparently it just works by magic. can you point me in the right direction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 09, 2014, 01:38:09 AM
Still can't find the weapon script you used in your mod, apparently it just works by magic. can you point me in the right direction?
I don't have any charging sound like that... Well, not in Scy anyway. But it quite simple to make:
Code: Java
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;

public class yourWeapon_chargeEffect implements EveryFrameWeaponEffectPlugin {

    private boolean SOUNDPLAYED = false;
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
       
        //disable the script if the game is paused
        if (engine.isPaused()) {
            return;
        }
        //detect charging
        float wPow = weapon.getChargeLevel();
        if (wPow>0) {
            if (!SOUNDPLAYED) {
                Global.getSoundPlayer().playSound("yourWeapon_chargeSound", 1f, 1f, weapon.getLocation(), weapon.getShip().getVelocity());
                //only play the sound once per charge
                SOUNDPLAYED=true;
            }           
        }
        //reinitialize the script once the weapon has completed a firing cycle
        if (wPow == 0) {           
            SOUNDPLAYED=false;
        }
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: carmey on December 09, 2014, 09:17:28 AM
I don't have any charging sound like that...

actually you do, the SCY_superfocusbeam works perfectly

...

It works! thanks a million, I'd never have managed that on my own
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 09, 2014, 03:02:53 PM
actually you do, the SCY_superfocusbeam works perfectly
Err, no? The super focus beam only have a normal firing sound and loop. It does however have a charge visual effect, but that's it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on December 10, 2014, 07:33:14 AM
Tried modding a ship in, experiencing somewhat distracting graphical glitch.
Spoiler
(http://i.imgur.com/AbMZB8L.jpg)(http://i.imgur.com/urOH4r6.jpg)
[close]
Deploying and recalling drone causes this glitch. What have I done wrong? Vanilla drone ships works just fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 10, 2014, 07:49:27 AM
I'm not sure but I think this is the bug you get if your collision radius is too small: it mustn't intersect your sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on December 10, 2014, 07:55:55 AM
Oh... I didn`t knew that. Fixed. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: isaacssv552 on December 10, 2014, 08:30:09 AM
Is it possible to make a hull mod that decreases the OP costs of weapons for only the ship it is installed on? I was thinking of making a hull mod that trades mount durability and turn speed, armor, OP, and maybe flux vents/capacitors for (significantly?) reduced weapon OP costs but if I use the weaponOP methods in the character API it would reduce the OP cost for all weapons (I think).

Edit:
Also, is it possible to make a hull mod that can be added to a ship multiple times? I think I would have to have multiple different hullmods with the same name (but different IDs) that didn't become available until the previous one had been added. Is there a way to hide and unhide hullmods? (not counting the in game only show available)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 10, 2014, 10:07:38 AM
Is it possible to make a hull mod that decreases the OP costs of weapons for only the ship it is installed on? I was thinking of making a hull mod that trades mount durability and turn speed, armor, OP, and maybe flux vents/capacitors for (significantly?) reduced weapon OP costs but if I use the weaponOP methods in the character API it would reduce the OP cost for all weapons (I think).
The CharacterOP method should work if its tied to a hullmod, otherwise I don't think there is an easy method to do that. The closest thing I can think of is a hullmod that replace the vents and capacitors: the OP unused for them could be used for the weapons. This hull mod could calculate how much you would have left. Not really practical but doable.

Also, is it possible to make a hull mod that can be added to a ship multiple times? I think I would have to have multiple different hullmods with the same name (but different IDs) that didn't become available until the previous one had been added. Is there a way to hide and unhide hullmods? (not counting the in game only show available)
There isn't a way to make a hullmod invisible, but you certainly can make them available only if the previous one is installed using public boolean isApplicableToShip(ShipAPI ship)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: isaacssv552 on December 10, 2014, 10:59:23 AM
Is it possible to make a hull mod that decreases the OP costs of weapons for only the ship it is installed on? I was thinking of making a hull mod that trades mount durability and turn speed, armor, OP, and maybe flux vents/capacitors for (significantly?) reduced weapon OP costs but if I use the weaponOP methods in the character API it would reduce the OP cost for all weapons (I think).
The CharacterOP method should work if its tied to a hullmod, otherwise I don't think there is an easy method to do that. The closest thing I can think of is a hullmod that replace the vents and capacitors: the OP unused for them could be used for the weapons. This hull mod could calculate how much you would have left. Not really practical but doable.

When I said flux vents/capacitors I meant the base dissipation/capacity. So the methods from the character API would only effect one ship if they were tied to a hull mod?

Also, is it possible to make a hull mod that can be added to a ship multiple times? I think I would have to have multiple different hullmods with the same name (but different IDs) that didn't become available until the previous one had been added. Is there a way to hide and unhide hullmods? (not counting the in game only show available)
There isn't a way to make a hullmod invisible, but you certainly can make them available only if the previous one is installed using public boolean isApplicableToShip(ShipAPI ship)

I know how to use isApplicableToShip, I'm not sure how to prevent hullmods from showing up in the selection menu when isApplicableToShip is false. Are you saying its impossible to prevent it from showing up in the selection screen? Would it be possible to make a script that adds and removes hullmods from the list of hullmods you have the right skill levels for? For example, a hull mod requires 5 in flux dynamics but if isApplicableToShip is false it acts as if you don't have a high enough flux dynamics skill for it even if you do. (without affecting other hullmods)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 10, 2014, 11:10:53 AM
When I said flux vents/capacitors I meant the base dissipation/capacity. So the methods from the character API would only effect one ship if they were tied to a hull mod?
Dunno, probably? That's something you'll have to try out. I'd be interested in hearing the result though.

Are you saying its impossible to prevent it from showing up in the selection screen?
That's exactly what I'm saying, there are many mods out there with built-in hullmods that keep cluttering the list, and not aware of anyone managing to find a workaround yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2014, 11:59:33 AM
(Added "Add method to prevent hullmods from showing up in selection dialog" to my list.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 10, 2014, 12:02:53 PM
Now that's a good news, it will go a long way in uncluttering the mission's hullmods screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2014, 12:05:29 PM
Yeah, helps there's a good use case for it in vanilla, with all those built-in hullmods floating around :)

Edit: added "hidden" column to hull_mods.csv. If set to true, the hullmod will never show up in the mod picker dialog in the refit screen, regardless of all other considerations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: isaacssv552 on December 10, 2014, 06:10:00 PM
Quote
added "hidden" column to hull_mods.csv. If set to true, the hullmod will never show up in the mod picker dialog in the refit screen, regardless of all other considerations.
Yay! Thanks for adding that in.

(Still working on testing out the lower weapon OP thing)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on December 11, 2014, 06:14:09 AM
Is 1 SU in Starsector (i don't know if its a real measurement system) 1 meters?

EDIT : Another yet more important question
Is it possible to make certain hulls act similar to missiles (explode on contact)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 12, 2014, 12:19:11 PM
Yeah, helps there's a good use case for it in vanilla, with all those built-in hullmods floating around :)

Edit: added "hidden" column to hull_mods.csv. If set to true, the hullmod will never show up in the mod picker dialog in the refit screen, regardless of all other considerations.
Useful, but also arg - I really wanted that to be something set via a java method so you could do basic things like "Dedicated Targeting Core simply doesn't show up for destroyer / frigate hulls".  Don't get me wrong, I'll definitely have use for it for built-ins, but I was hoping for a more flexible approach.

As an aside, don't have the API in front of me, is there any sort of "onRemove" callback for hull mods?  Trying to work out if I can add hull mods that let you trade cargo space for ordnance points (or vice versa), and need a way to make sure the player can't add such a mod, use the extra ordnance points, and then remove the mod, gaining the benefit without the cost.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2014, 12:27:29 PM
Useful, but also arg - I really wanted that to be something set via a java method so you could do basic things like "Dedicated Targeting Core simply doesn't show up for destroyer / frigate hulls".  Don't get me wrong, I'll definitely have use for it for built-ins, but I was hoping for a more flexible approach.

I was thinking about that, but there's currently a checkbox that hides stuff that can't be installed, so making that flexible via code seems like it would be stepping on its toes a little bit. It's not exactly the same, since it also hides anything you can't afford OP-wise... hm.


As an aside, don't have the API in front of me, is there any sort of "onRemove" callback for hull mods?  Trying to work out if I can add hull mods that let you trade cargo space for ordnance points (or vice versa), and need a way to make sure the player can't add such a mod, use the extra ordnance points, and then remove the mod, gaining the benefit without the cost.

There isn't, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 12, 2014, 12:39:06 PM
Useful, but also arg - I really wanted that to be something set via a java method so you could do basic things like "Dedicated Targeting Core simply doesn't show up for destroyer / frigate hulls".  Don't get me wrong, I'll definitely have use for it for built-ins, but I was hoping for a more flexible approach.

I was thinking about that, but there's currently a checkbox that hides stuff that can't be installed, so making that flexible via code seems like it would be stepping on its toes a little bit. It's not exactly the same, since it also hides anything you can't afford OP-wise... hm.
At least for my playstyle, that's not at all the same - there's a big difference between hiding hull mods that you can't install, ever, and hiding hull mods that you totally could install if you were willing to drop one or two flux capacitors.  The former is useful to me, the latter, not so much; as such, I've never found that checkbox to be worth clicking on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2014, 12:49:17 PM
Come to think of it, that matches my (non)use of that button. Changed so that it only hides mods that 1) aren't applicable or 2) are already installed on the ship. Seem reasonable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 12, 2014, 12:59:22 PM
Come to think of it, that matches my (non)use of that button. Changed so that it only hides mods that 1) aren't applicable or 2) are already installed on the ship. Seem reasonable?
Sounds good to me - I'll actually play with that checked, now.  That also removes any need for making hiding hull mods programmable.  Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2014, 01:02:46 PM
Cool, glad you brought it up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 15, 2014, 12:19:59 AM
Some questions..I'm looking into making specific weapons:

1) A VLMS (side of top mounted) I figure making the turret base a single pixel and the barrels the missile boxes, setting the turret to not rotate and the missile to tracking should work? The missiles will fire regardless of turret facing?

2) Freepsace style beam cannon.
(http://upload.wikimedia.org/wikipedia/en/5/53/FreeSpace_2_Beam-Combat-Anim.gif)
I don't know how to do this. The weapon should have a 90° fire angle, but the turret itself shouldn't move. The beam emitter is static.
I could make everything hidden, but the weapon should be destructable... ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 15, 2014, 01:09:15 AM
1) You have a DO_NOT_AIM flag for weapons, and it works fine (see the Erymanthian Boar built-in missile launcher in Scy)

2) You can simply assign no sprite to the weapon like this
   "turretSprite":"",
   "hardpointSprite":"",
(those line need to be present event if they are empty) and then you can add a under sprite. The under sprite won't move, but will hide the mount if you want that weapon to be modular.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 15, 2014, 05:51:21 AM
Under sprite?
First time I hear about it. How does one add/define it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on December 15, 2014, 06:37:26 AM
Look a Mjolnir cannon in vanilla. There is a undersprite in there.

However, IIRC undersprite rotates with the turret, so this will be a problem in your case and i really don`t thing that the game will accept "" for sprite routes. I guess this will result in a crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 15, 2014, 06:59:34 AM
However, IIRC undersprite rotates with the turret, so this will be a problem in your case and i really don`t thing that the game will accept "" for sprite routes. I guess this will result in a crash.
Under sprites don't turn, that's their whole point, and the game accept "" for a sprite all right. You have to put that line in the weapon file or the game crash, but it can be empty.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 15, 2014, 10:13:23 AM
Code
393482 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Picking market updates
393483 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Adding Ship Components(Visis)
393483 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Adding Hand Weapons(Visis)
393484 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Adding Electronics(Visis)
393542 [Thread-5] WARN  com.fs.starfarer.campaign.rules.super  - Problem with command of class com.fs.starfarer.api.impl.campaign.rulecmd.OpenCoreTab: null
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.getWeaponsOnRolePick(BaseSubmarketPlugin.java:352)
at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.addWeaponsForRolePicks(BaseSubmarketPlugin.java:314)
at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.addWeaponsBasedOnMarketSize(BaseSubmarketPlugin.java:272)
at com.fs.starfarer.api.impl.campaign.submarkets.OpenMarketPlugin.updateCargoPrePlayerInteraction(OpenMarketPlugin.java:53)
at com.fs.starfarer.campaign.ui.T.<init>(Unknown Source)
at com.fs.starfarer.coreui.OO0o.<init>(Unknown Source)
at com.fs.starfarer.coreui.OO0o.<init>(Unknown Source)
at com.fs.starfarer.ui.String.int$5.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.String.int.setCurrentTab(Unknown Source)
at com.fs.starfarer.ui.String.int.setCurrentTab(Unknown Source)
at com.fs.starfarer.ui.String.P.showCoreInternal(Unknown Source)
at com.fs.starfarer.ui.String.P.showCore(Unknown Source)
at com.fs.starfarer.api.impl.campaign.rulecmd.OpenCoreTab.execute(OpenCoreTab.java:39)
at com.fs.starfarer.campaign.rules.super.execute(Unknown Source)
at com.fs.starfarer.campaign.rules.D.runScript(Unknown Source)
at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.applyRule(FireBest.java:96)
at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.execute(FireBest.java:46)
at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.fire(FireBest.java:52)
at com.fs.starfarer.api.impl.campaign.RuleBasedInteractionDialogPluginImpl.fireBest(RuleBasedInteractionDialogPluginImpl.java:110)
at com.fs.starfarer.api.impl.campaign.RuleBasedInteractionDialogPluginImpl.optionSelected(RuleBasedInteractionDialogPluginImpl.java:139)
at com.fs.starfarer.ui.String.P$1.o00000(Unknown Source)
at com.fs.starfarer.ui.String.A.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.thisnew.super(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
398299 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.getWeaponsOnRolePick(BaseSubmarketPlugin.java:352)
at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.addWeaponsForRolePicks(BaseSubmarketPlugin.java:314)
at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.addWeaponsBasedOnMarketSize(BaseSubmarketPlugin.java:272)
at com.fs.starfarer.api.impl.campaign.submarkets.MilitarySubmarketPlugin.updateCargoPrePlayerInteraction(MilitarySubmarketPlugin.java:59)
at com.fs.starfarer.coreui.f.<init>(Unknown Source)
at com.fs.starfarer.ui.String.int$3.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.thisnew.super(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Can anyone figure out this?
Happens when I want to trade/buy ships in my own system
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on December 15, 2014, 05:10:04 PM
Is there anyway to force a ship to vent?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 16, 2014, 12:32:34 AM
Code: Java
ship.giveCommand(ShipCommand.VENT_FLUX, null, 0);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 16, 2014, 08:05:42 AM
Can someone tell me how markets are populated?
In the old version there was a file with weapons and ships that belonged to a faction
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 16, 2014, 09:24:11 AM
That's automatic: it now mostly depend on the faction ships variants, the market size and modifiers, plus some random variables.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on December 19, 2014, 09:15:52 PM
Is there a guide for how to use the shipcommands? I'm trying to force a ship to accelerate backwards when using a shipsystem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 20, 2014, 12:42:28 AM
http://www.fractalsoftworks.com/starfarer.api/index.html?overview-summary.html (http://www.fractalsoftworks.com/starfarer.api/index.html?overview-summary.html)
Look for "shipCommand" in the index.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on December 22, 2014, 10:44:47 AM
Is it somehow possible to render something (sprite) at some specific "level" (Z/depth order)? More specifically, is it possible to render something on the level where ships are, but below, for example, projectiles? I didn't find any way to do this via EveryFrameCombatPlugin: everything rendered in renderInWorldCoords appears on top of everything in game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on December 29, 2014, 12:07:11 PM
For some reason this line:

stats.getBeamWeaponFluxCostMult().modifyMult(id, effectLevel * 1.2f);

Doesn't seem to do anything in game. Am I doing anything wrong, or is it just the method?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 29, 2014, 03:45:47 PM
What's making you think it's not working? A 20% increase in beam flux use might not be trivial to verify, especially if it's all dissipated anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on December 29, 2014, 04:14:05 PM
I made a system that increases beam flux when used, and I have a ship with an built-in phase beam. The ship I made has a dissipation of 180. The beam has a flux/second of 160 that should increase to 192 when the system is used, but seems to stay at 160.

Spoiler
(http://i.imgur.com/EOLZDjd.png)
The ship and the beam.

(http://i.imgur.com/BtAmLjl.png)
Flux level stays at 0 with the system off.

(http://i.imgur.com/kGsspHl.png)
Flux level stays at 0 with the system on.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 29, 2014, 04:19:55 PM
Ah - the weapon tooltip only shows base weapon stats. Even if it didn't, it *still* wouldn't show system-modified stats :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on December 29, 2014, 04:43:45 PM
I meant that the ships flux stays at zero when the system is on and off, even though the phase beam should be generating 192 flux when the system is active.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 29, 2014, 05:15:51 PM
... my bad, I didn't see the other 2 screenshots - they were off-screen and then I closed the spoiler after looking at the top one :)

Looking at it more closely, the problem is twofold:
1) You want 1f + (0.2f * effectLevel) for the multiplier, and, rather more importantly
2) The whole stat is completely ignored

(Well, not completely - it's applied to another variable where it ultimately doesn't matter at all. Fixed that up; thanks for bringing it up!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on December 29, 2014, 05:23:07 PM
Thanks for the help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 01, 2015, 03:24:31 PM
How do I add a fleet to a planet?

Yeah, I know, with a code like:
Code
    public static void vnsmain_spawner()
    {


        int vns_mainfleet = getSector().getEntitiesWithTag("vns_mainfleet").size();


if (vnsmainfleet < 1)
{

                CampaignFleetAPI fleet = FleetFactory.createGenericFleet("VNS", "Patrol", 200, 0);
                home_name = "avalon";

                SectorEntityToken home = getSector().getEntityById(home_name);

                fleet_filler("VNS", fleet);
                fleet.addTag("vns_mainfleet");

                fleet.getFleetData().sort();
                FleetFactory.finishAndSync(fleet);

                fleet.setName("System Defence Fleet");

                home.getContainingLocation().addEntity(fleet);
                fleet.setLocation(home.getLocation().x + 0, home.getLocation().y + 0);
                fleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, home, 3, "preparing for duty");
                fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, home, 14, "patrolling around "+home.getName());
                fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, home, 3, "standing down from duty");
                fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, home, 1000, "returning to "+home.getName());
                fleet.setPreferredResupplyLocation(home);

}

BUT, how do I a create a specific fleet?
I want very specific ships in that fleet.
1X, 2 of Y and 4 Z escorts

getSector().getFaction(faction).pickShipAndAddToFleet(ShipRoles.FREIGHTER_SMALL, qf, fleet);

adds a ship based on role...
Is is possible to specify a variant?





Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 01, 2015, 05:52:27 PM
How do I add a fleet to a planet?

Yeah, I know, with a code like:
Code
    public static void vnsmain_spawner()
    {


        int vns_mainfleet = getSector().getEntitiesWithTag("vns_mainfleet").size();


if (vnsmainfleet < 1)
{

                CampaignFleetAPI fleet = FleetFactory.createGenericFleet("VNS", "Patrol", 200, 0);
                home_name = "avalon";

                SectorEntityToken home = getSector().getEntityById(home_name);

                fleet_filler("VNS", fleet);
                fleet.addTag("vns_mainfleet");

                fleet.getFleetData().sort();
                FleetFactory.finishAndSync(fleet);

                fleet.setName("System Defence Fleet");

                home.getContainingLocation().addEntity(fleet);
                fleet.setLocation(home.getLocation().x + 0, home.getLocation().y + 0);
                fleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, home, 3, "preparing for duty");
                fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, home, 14, "patrolling around "+home.getName());
                fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, home, 3, "standing down from duty");
                fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, home, 1000, "returning to "+home.getName());
                fleet.setPreferredResupplyLocation(home);

}

BUT, how do I a create a specific fleet?
I want very specific ships in that fleet.
1X, 2 of Y and 4 Z escorts

getSector().getFaction(faction).pickShipAndAddToFleet(ShipRoles.FREIGHTER_SMALL, qf, fleet);

adds a ship based on role...
Is is possible to specify a variant?

Take a look at the CustomFleets class in the com.fs.starfarer.api.impl.campaign.fleets . (I don't know if i wrote that right.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 02, 2015, 02:08:35 AM
Where can I find it?

In what file? Or do I have to uncompile java to find it?

EDIT: NEvermind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 02, 2015, 03:28:17 AM
So..if I got this right:

Code
package com.fs.starfarer.api.impl.campaign.fleets;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.FleetDataAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.ids.Factions;

public class CustomFleets {

/**
* To add a new fleet:
* 1) Make a copy of this method
* 2) Call it from spawn()
*/
private void spawnVNSFleet() {
CampaignFleetAPI fleet = Global.getFactory().createEmptyFleet(Factions.VNS, "1st Fleet", true);

FleetDataAPI data = fleet.getFleetData();
FleetMemberAPI member = null;

// add a fleet member with a custom name
member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "archangel_standard");
member.setShipName("VNS Archangel");
data.addFleetMember(member);

// add a ship and a fighter
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_avenger_mk2_strikeE"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_prometheus_standard"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_dedalus_standard"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_fury_std"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_cobra2_assault2"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_cobra2_assault2"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "ASF14_wing"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "ASF14_wing"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "PhnI_Spec_wing"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "PhnI_Spec_wing"));
data.addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "Armageddon_wing"));



// makes fleet not need supplies or fuel or crew
FleetFactory.finishAndSync(fleet);

// add fleet to a star system and set its location
LocationAPI location = Global.getSector().getStarSystem("vanyar");
location.addEntity(fleet);

SectorEntityToken planet = location.getEntityById("avalon");
fleet.setLocation(planet.getLocation().x, planet.getLocation().y - 500);

// give the fleet an assignment (1000000f days ~= forever)
// the fleet tooltip will show it as "<relationship level>, doing something" - i.e. "Neutral, doing something"
fleet.getAI().addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, planet, 1000000f, "defending Avalon", null);
}


/**
* This is called from CoreCampaignPluginImpl.onNewGameAfterTimePass().
*/
public void spawn() {
spawnVNSFleet();
}
}

Do I even need a public CustomFleet class OR all the imports?
My programing days are a fleeting memory, but IIRC; I only need:

import com.fs.starfarer.api.impl.campaign.fleets;



right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sabotsas on January 06, 2015, 04:06:14 PM
Hello Starsector-Community,

I am currently playing SS (without mods) and reached a point where enemy fleets are no threat any more.
I wanted to change a few things:

1) Increase bounties and make their fleets bigger (and increase % of capital ships), increase loot.
2) Make System Defense Fleets bigger (and increase % of capital ships), increase loot.
3) Create a late game faction with no diplomatic ties to the other ones (for the sake of reputation) with very big System Defense Fleets /w commanders (like bounty-captains)


I had a look at all (easily) accessible SS files but AFAIK the last update changed the way how fleets are generated.
I also did a brief search within these forums but I didn't find an answer to my questions.
Is there any way for me to accomplish some or all of the goals above without much trouble?
I have not much experience in coding but I can edit txt files ...

Any help highly appreciated!

Kind Regards
Sabotsas
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 10, 2015, 05:00:45 AM
Would like to ask something.
In the .proj files there are parameters named :
Code
"collisionClass":"PROJECTILE_FF",
"collisionClassByFighter":"PROJECTILE_FIGHTER",
What does these two parameters do? Is it possible to use these so that beams miss fighters

EDIT : Could anyone please list the collision classes, if there are one?

EDIT 2 : What does this error mean ?
Code
4774 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.remove(Unknown Source)
at com.fs.starfarer.loading.specs.P.addTurretAngleOffset(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.new(Unknown Source)
at com.fs.starfarer.loading.SpecStore.ö00000(Unknown Source)
at com.fs.starfarer.loading.void.super(Unknown Source)
at com.fs.A.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 11, 2015, 05:42:14 PM
If you want beams to miss fighters, use HITS_SHIPS_AND_ASTEROIDS

The error probably means that you've got a mismatch between the number of turretOffsets and turretAngleOffsets (or same for hardpoints). The former should be 2x the number of the latter, as the former are coordinate pairs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 12, 2015, 01:04:38 AM
Hello Starsector-Community,

I am currently playing SS (without mods) and reached a point where enemy fleets are no threat any more.
I wanted to change a few things:

1) Increase bounties and make their fleets bigger (and increase % of capital ships), increase loot.
2) Make System Defense Fleets bigger (and increase % of capital ships), increase loot.
3) Create a late game faction with no diplomatic ties to the other ones (for the sake of reputation) with very big System Defense Fleets /w commanders (like bounty-captains)


I had a look at all (easily) accessible SS files but AFAIK the last update changed the way how fleets are generated.
I also did a brief search within these forums but I didn't find an answer to my questions.
Is there any way for me to accomplish some or all of the goals above without much trouble?
I have not much experience in coding but I can edit txt files ...

Any help highly appreciated!

Kind Regards
Sabotsas

For the 1 and 2 there is an easy way to achieve what you wish by copy/pasting capital ships from CAPITAL ship role to any other (in that faction`s file in data/world/factions). This will make capitals more frequent, but may lead to smaller fleets becoming more dangerous. For the loot part you can easily edit the settings file in data/config. There is a loot value somewhere in it that you can adjust. Not that this will result only in supplies/fuel/metals, not the odds to salvage guns IIRC. This should cover both SDF and bounty fleets.

Making fleets bigger is a tricky part because it requires you to edit the corresponding fleet generation files that are in a jar (and thus are not that easily modified). You can, however, reduce the fleet points of all the ships in the game (data/hulls). This will increase the total amount of the ships, but will lead to some of them being available for much lower relationship level that original.

The faction part is also quite easy to do - just create a new faction (by copy/pasting any existing one and renaming all their stuff except for the ships) and giving them at least one planet some where in the already existing systems (this is done in economy folder - just pick any existing markets and edit owner faction).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 12, 2015, 01:48:36 AM
If you want beams to miss fighters, use HITS_SHIPS_AND_ASTEROIDS

The error probably means that you've got a mismatch between the number of turretOffsets and turretAngleOffsets (or same for hardpoints). The former should be 2x the number of the latter, as the former are coordinate pairs.
Thanks Alex, but i have another question, if you want to classify a weapon as PD and target missiles, how do you do it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on January 12, 2015, 01:57:02 AM
Should be in the weapon hints column in the weapon CSV, use a hint like PD,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 12, 2015, 04:42:09 AM
Wait, hints could work? I never knew  ???. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 13, 2015, 01:19:57 AM
I already know you can make a hullmod that repairs hull in battle (already have it)

BUT.

Is it possible to repair ARMOR?

I kinda want a self-repairing armor upgrade, but all I can get so far is hull repair. Which is not the same thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on January 16, 2015, 11:01:10 PM
I already know you can make a hullmod that repairs hull in battle (already have it)

BUT.

Is it possible to repair ARMOR?

I kinda want a self-repairing armor upgrade, but all I can get so far is hull repair. Which is not the same thing.

Sundog had already made a armor repair shipsystem in ICE Faction
http://fractalsoftworks.com/forum/index.php?topic=7625.0

and...well, i think you should check you add-on's integrality before releasing by install it and test it.
i mean form a mod-free Starsector copy, and the latest version of Ironclads.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on January 18, 2015, 07:16:13 AM
How to simply disable a song change when docking? I prefer how it was prior to 65.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 18, 2015, 11:21:35 PM
I already know you can make a hullmod that repairs hull in battle (already have it)

BUT.

Is it possible to repair ARMOR?

I kinda want a self-repairing armor upgrade, but all I can get so far is hull repair. Which is not the same thing.

Sundog had already made a armor repair shipsystem in ICE Faction
http://fractalsoftworks.com/forum/index.php?topic=7625.0

and...well, i think you should check you add-on's integrality before releasing by install it and test it.
i mean form a mod-free Starsector copy, and the latest version of Ironclads.

Oh yes, just what daddy wanted.

Hmm..packed ina .jar file. I have a program that lets me look into java files. I can certanly copy-paste the code from the .class file, but I do wonder if it would work as a .java file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 19, 2015, 12:35:12 PM
Spoiler
I already know you can make a hullmod that repairs hull in battle (already have it)

BUT.

Is it possible to repair ARMOR?

I kinda want a self-repairing armor upgrade, but all I can get so far is hull repair. Which is not the same thing.
Sundog had already made a armor repair shipsystem in ICE Faction
http://fractalsoftworks.com/forum/index.php?topic=7625.0

and...well, i think you should check you add-on's integrality before releasing by install it and test it.
i mean form a mod-free Starsector copy, and the latest version of Ironclads.
[close]

Oh yes, just what daddy wanted.

Hmm..packed ina .jar file. I have a program that lets me look into java files. I can certanly copy-paste the code from the .class file, but I do wonder if it would work as a .java file.

ICE's code is also available online in Sundog's Bitbucket repository (https://bitbucket.org/Nate_NBJ/ice/src/). Here's the code he uses for armor repairing. (https://bitbucket.org/Nate_NBJ/ice/src/f95f4c8ed2622e325059443b3cf55bbd9e8b16a3/src/data/ai/drone/MxDroneAI.java?at=default#cl-256)

If you just want all armor on your ship to repair at a constant rate, that's actually fairly simple. Here's an example:
Code
package data.hullmods;

import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;

public class ExampleArmorRepairHullMod extends BaseHullMod
{
    private static final float ARMOR_REPAIRED_PER_SECOND = 5f;

    @Override
    public void advanceInCombat(ShipAPI ship, float amount)
    {
        // Grab the ship's armor grid and raw armor values
        final ArmorGridAPI armor = ship.getArmorGrid();
        final float[][] grid = armor.getGrid();

        // Calculate how much armor to repair per cell this frame
        // Armor per cell is NOT the same as the listed armor rating, so we have
        // to compensate by dividing max armor per cell by the 'actual' rating
        // This means 5 armor per second might only be ~0.3 armor per cell
        final float maxArmor = armor.getMaxArmorInCell(),
                toHeal = ARMOR_REPAIRED_PER_SECOND * amount
                * (maxArmor / armor.getArmorRating());

        // Iterate over all armor cells and add repairs to their current value
        for (int x = 0; x < grid.length; x++)
        {
            for (int y = 0; y < grid[0].length; y++)
            {
                armor.setArmorValue(x, y, Math.min(grid[x][y] + toHeal, maxArmor));
            }
        }
    }
}

If you want to repair a percentage of total armor per second instead, just change toHeal's value to toHeal = maxArmor * (ARMOR_REPAIRED_PER_SECOND / 100f) * amount.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 21, 2015, 10:54:40 PM
Does anyone know what does
Code
	"quality":0.25,
line means in variant files? What is influenced by this value?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 21, 2015, 11:59:28 PM
It's exactly what it say, it is the quality of the variant: low stability worlds can't spawn high quality variants.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 22, 2015, 12:20:07 AM
Aha, I see. Thanks for explanation!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: orost on January 23, 2015, 08:31:15 PM
Is there a way to print out arbitrary values for debugging purposes? On screen in the game or to the console, either way is fine.  I tried a couple standard things like System.out, but they're either not there or give me security exceptions.

This is my first time doing anything in Java, so apologies if I said something stupid.

edit: ah, never mind, System.out.println is there. I was trying to use out.format() and out.printf() because the value I wanted was a float, but I guess I can work with just println().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: orost on January 23, 2015, 11:42:10 PM
Is there a way to add my own indicator to the bar on the left in combat? The one that indicates things like "zero flux engine boost", shows CR, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 24, 2015, 02:09:17 AM
Check out the Common Radar (http://fractalsoftworks.com/forum/index.php?topic=7526.0) mod for how Lazy Wizzard managed it, but be warned, it's really not simple to do that!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: orost on January 24, 2015, 02:26:31 AM
So I'd have to draw my own directly? I know OpengGL, so I guess I could, but trying to make its look fit with vanilla indicators would be a huge pain. I think I'm going to pass and hope we get an API for it at some point. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on January 24, 2015, 02:40:10 AM
NVM, uomoz is stoopid
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 24, 2015, 08:12:00 AM
I think orost meant is the status indicators such as when the Burn Drive is activated, it shows the player a text that says the weapon systems are disabled.

Taken from data.shipsystems.scripts.ManeuveringJetsStats.java

Code: Java
//snip

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("improved maneuverability", false);
} else if (index == 1) {
return new StatusData("+50 top speed", false);
}
return null;
}
}
I think you can use those to get the results you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: orost on January 24, 2015, 09:46:36 AM
That's what I meant, but I think this is only usable from within a ship system script. I'd like to display a status when a hull mod I added activates itself, and the hullmod class doesn't have getStatusData() or equivalent. I guess it's because hullmods are only supposed to be passive stat bonuses. I'll consider requesting an API addition, but I have to think whether it makes sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on January 26, 2015, 08:45:05 AM
All the documentation I'm finding on Missions is old and seems to predate the campaign, I don't want to make a new thread for this single question so I'll ask it here:

How do you give levels/skills to mission fleets? I've only found ways to give them Elite Crew members but not on how to give either fleet character skills.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 26, 2015, 09:00:15 AM
I believe you can't  :( I stand corrected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2015, 10:21:33 AM
Fairly sure you can do it - there's a FleetMemberAPI.setCaptain(PersonAPI), and you can use SettingsAPI.getFactory().createPerson() to create a person.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on January 26, 2015, 10:42:24 AM
Fairly sure you can do it - there's a FleetMemberAPI.setCaptain(PersonAPI), and you can use SettingsAPI.getFactory().createPerson() to create a person.

Would it be too much to ask for an example? I don't do much modding, normally I just modify work done by others so I can do my own private things. If anyone else ever used these for your mission please share your code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2015, 10:59:03 AM
Something like:

Code: java
FleetMemberAPI fleetMember;
fleetMember = api.addToFleet(FleetSide.PLAYER, "venture_Balanced", FleetMemberType.SHIP, "ISS Hamatsu", false);
fleetMember.getCaptain().getStats().setAptitudeLevel("combat", 10);
fleetMember.getCaptain().getStats().setSkillLevel("helmsmanship", 10);

Haven't tested this, but it ought to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on January 27, 2015, 09:21:53 AM
Thanks Alex, best of luck with the next version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Beobachter on January 27, 2015, 02:44:02 PM
I am attempting to modify the spawn rates of NPC fleets in a couple mods (less draining on the laptop and gives a better feeling of empty 'space'). Is there a particular line in a file I can change or does this require dissecting some jar files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 27, 2015, 02:58:07 PM
You can change the "# start economy fleet spawning configuration" in the starsector-core\data\config\settings.json file
Also if you are using SS+, it override some of those so change the values in the mod's config file too
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on January 29, 2015, 03:56:47 AM
Is it possible to have engine flames only appear when they are used (moving)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 29, 2015, 04:03:57 AM
Mmh, not sure, maybe you can create a hullmod that makes them transparent when not accelerating? Otherwise you can always make completely custom engines, but be warned, it's a pain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on January 30, 2015, 09:44:38 PM
Would someone kindly tell me how to generate a system for a faction?

The tutorial given in the Resources are currently outdated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 31, 2015, 12:04:59 AM
If your aren't compiling your mod, check the vanilla systems files in data/scripts/world/systems (don't use Corvus as a bases, it's quite messy since it has been modified many times each new version of SS)
If you are compiling, check some clean mod systems like Mayorate's Rasht in the jars/src/... folder
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on January 31, 2015, 05:22:55 AM
If your aren't compiling your mod, check the vanilla systems files in data/scripts/world/systems (don't use Corvus as a bases, it's quite messy since it has been modified many times each new version of SS)
If you are compiling, check some clean mod systems like Mayorate's Rasht in the jars/src/... folder

I had created a Plug-in, a (Faction)Gen, and said system file using Vanilla as reference, but when I started the campaign and went out of the Corvus Star System into Hyperspace, I don't see my Star Systems appearing (which are about at -2500, 4000 and -12000, 3000). I even wrote them down on both Starmap.json and the system references.

Is there anything else I didn't miss? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on February 01, 2015, 01:08:28 PM
just wondering is it possible to change the colour of a projectile. i saw a weapon i wanted to use with a different coloured projectile but i werent sure how to change it. its a energy weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 01, 2015, 07:28:01 PM
Some mission-making questions:

1) Is there a way to spawn ship wrecks at a specified location in the battle? Preferably in a way that doesn't have the "ship disabled" message.

2) I'm running a plugin that creates a new FleetMemberAPI and spawns it for one side part way through the battle. But I can't add it to the list of ships with status (deployed, disabled, destroyed, retreated, in reserve) on each side that gets displayed after the battle. I tried
Code
engine.getFleetManager(FleetSide.PLAYER).addToReserves(member);
but no luck. Is there a way to do this?

Alternatively, can I set the name of a ship that gets spawned with engine.getFleetManager(#).spawnShipOrWing(), since that doesn't have this problem?

3) Can I add a jump point as a background planet in vanilla?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 01, 2015, 11:40:18 PM
1 you can spawn a ship, move it to a certain location then kill it. It will gives the message, but it's the only way I'm aware of.

2 SS+ does it in the arcade and the benchmark mission, I believe DarkRevenant is using
Code: Java
api.addToFleet(side, id, FleetMemberType.SHIP,"nameOfTheShip", false);

3 You can't but you may have noticed a "fake" wormhole in some Scy missions or the battles near wormhole in recent SS+ versions. It's a group of planets with a sorta wormhole texture on top of each other. Check SCY mission 1 "Trail" to see how it's done as I didn't compiled it. Since the planet textures are quite heavy in RAM, I suggest you use the same path and name for them. That way they will override themselves if multiple mods use them and not take the space multiple time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 03, 2015, 12:06:06 AM
Thanks, Tartiflette!

Spoiler
2) That code is something from default missions, isn't it? Arcade doesn't use it outside MissionDefiniton.java for the two initial Oxen. Anyway, it requires the MissionDefinitionAPI, and I don't know if there's a way to access it from mission every-frame plugins.
I didn't check the benchmark mission, but in Arcade only bosses (and fighter wings) appear in the results screen.

3) Are the Scy wormhole textures and planet definitions open for others to use? (Though I'm not sure if I want to bother with such a seemingly hacky solution regardless >_>)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 03, 2015, 01:18:55 AM
3) They are, they already are used in SS+ too. That's why I suggested you to keep the hierarchy, to avoid duplicating the same texture across multiple mods, unless you are planning a TC that is. And it's not hackish, it's clever (if I dare say so myself!  ;D), it require no scripts or anything and is quite simple even.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on February 03, 2015, 04:09:40 AM
How do you use LazyLib? I understand what it is and what it's used for, but I don't know how to access the LazyLib... thigamajiggies. Does the LazyLib jar have to be in the jars folder(for whatever mod you're working on) and THEN you can import things?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 03, 2015, 04:28:03 AM
You need to use an IDE and import it as a library just like LazyLib
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on February 04, 2015, 03:03:10 AM
I had created a Plug-in, a (Faction)Gen, and said system file using Vanilla as reference, but when I started the campaign and went out of the Corvus Star System into Hyperspace, I don't see my Star Systems appearing (which are about at -2500, 4000 and -12000, 3000). I even wrote them down on both Starmap.json and the system references.

Is there anything else I didn't miss? :)

No one has answered me yet.

Did I missed anything? I tried starting the campaign for more than 5 times now and my star systems didn't appear yet. :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 04, 2015, 03:38:23 AM
No.

Okay to be more helpful, did you tried to save the game, open that save and look if the system is spawned or not at all? Maybe you made a mistake like not spawning any wormholes. Otherwise, you'll have to check everything again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on February 04, 2015, 07:19:35 PM
I did wrote down the wormhole codes accordingly.

Quote

      JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("nemvis_gate", "Nemvis Gate");
      OrbitAPI orbit = Global.getFactory().createCircularOrbit(star, 0, 5600, 365);
      jumpPoint.setOrbit(orbit);
      jumpPoint.setStandardWormholeToHyperspaceVisual();
      system.addEntity(jumpPoint);
      
      system.autogenerateHyperspaceJumpPoints(true, true);

But I'm not sure if it is enough.



On the side note:
Spoiler
Also, I'm sorry if you guys feel bad against me, detailing the info is much needed to get some necessary answers unlike from other players I've heard of did not provide from other forums.

Spoiler
I don't know if there is any conflict happening right now, I just assumed there is a system where you don't provide the tutorials in the mods anymore due to others simply overwriting info much faster than creating it.
[close]

I also know much of the forum options here, not because I did exist in this very forum here before, it's because I used to be on several forums beforehand.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 06, 2015, 02:45:50 AM
System.out.println() doesn't seem to write anything to log file on Windows 7. Is there anything I have to do to get it to work, or some other way to debug?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on February 06, 2015, 05:10:01 AM
Is there any way to make a missile do piercing damage. I wanted to make a drone weapon out of Stargate so it could pierce a enemy ships 2-3 times. Haven't found anything in missile settings though
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Spoorthuzad on February 10, 2015, 06:32:06 AM
I had created a Plug-in, a (Faction)Gen, and said system file using Vanilla as reference, but when I started the campaign and went out of the Corvus Star System into Hyperspace, I don't see my Star Systems appearing (which are about at -2500, 4000 and -12000, 3000). I even wrote them down on both Starmap.json and the system references.

Is there anything else I didn't miss? :)

No one has answered me yet.

Did I missed anything? I tried starting the campaign for more than 5 times now and my star systems didn't appear yet. :(
I have the same problem for a while now and i really want to add my own system
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 10, 2015, 06:35:59 AM
You're probably better off copying the custom system spawning code from another mod (any of the ones in SS+ should be good).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Spoorthuzad on February 10, 2015, 06:40:48 AM
You're probably better off copying the custom system spawning code from another mod (any of the ones in SS+ should be good).
Hm okay I will try that
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 14, 2015, 04:13:23 AM
My tokens are broken (in Exerelin) and I canna figure out what could possibly causing them. Halp!

Spoiler
(http://i.imgur.com/x7yLdK7.jpg?1)
[close]

Annoyingly it does manage to substitute things like $relayName as "NEUTRALayname" ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 14, 2015, 12:22:15 PM
The missing tokens come from CoreRuleTokenReplacementPlugin, which is registered like so:

Code: java
@Override
public void onGameLoad() {
// the token replacement generators don't get saved
// add them on every game load
Global.getSector().getRules().addTokenReplacementGenerator(new CoreRuleTokenReplacementGeneratorImpl());
}

In CoreLifecyclePluginImpl. That, in turn, is registered through settings.json:
Code
"plugins":{
# core equivalent of ModPlugin (must implement the ModPlugin interface)
"coreLifecyclePlugin":"com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl",
}

So, my guess would be that Exerelin provides a different implementation of coreLifecyclePlugin that doesn't add the core token replacement generator.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 16, 2015, 08:26:31 PM
Hey! Is there any simple way to remove the economy stuff (markets etc.) from the game for TC mods?

I did implement my own sectorgen without

//      sector.addScript(new CoreScript());
//      sector.addScript(new CoreEventProbabilityManager());
//      sector.addScript(new EconomyFleetManager());

but the game crashes in absence of an economy.json with a correct starmap.json and at last 1 market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 16, 2015, 08:31:21 PM
What's the crash stack trace?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 16, 2015, 08:40:40 PM
Without any economy.json:

Code
17438 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/backgrounds/background4.jpg] as texture with id [graphics/backgrounds/background4.jpg]
25346 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/economy.json)]
25346 [Thread-5] INFO  com.fs.starfarer.campaign.econ.B  - Loading economy data from data/campaign/econ/economy.json
25346 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data\campaign\econ/../starmap.json)]
25346 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\SectorQuest (data\campaign\econ/../starmap.json)]
25347 [Thread-5] INFO  com.fs.starfarer.campaign.econ.B  - Loading star system: askonia.json
25347 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data\campaign\econ/askonia.json)]
25428 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
java.lang.RuntimeException: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.thisnew.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.new.?o000(Unknown Source)
at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?0000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
... 13 more

Without any "starsyStems" inside the economy.json:

Code
18406 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/backgrounds/background4.jpg] as texture with id [graphics/backgrounds/background4.jpg]
29649 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\SectorQuest (data/campaign/econ/economy.json)]
29649 [Thread-5] INFO  com.fs.starfarer.campaign.econ.B  - Loading economy data from data/campaign/econ/economy.json
29649 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data\campaign\econ/../starmap.json)]
29649 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\SectorQuest (data\campaign\econ/../starmap.json)]
29723 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.thisnew.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.new.?o000(Unknown Source)
at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?0000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.campaign.econ.EconomyStepTracker.??00(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.advance(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.nextStep(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
... 13 more

Without any "markets" inside the system.json of an existing system:

Code
23424 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\SectorQuest (data/campaign/econ/economy.json)]
23425 [Thread-5] INFO  com.fs.starfarer.campaign.econ.B  - Loading economy data from data/campaign/econ/economy.json
23425 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data\campaign\econ/../starmap.json)]
23425 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\SectorQuest (data\campaign\econ/../starmap.json)]
23425 [Thread-5] INFO  com.fs.starfarer.campaign.econ.B  - Loading star system: yolo.json
23426 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\SectorQuest (data\campaign\econ/yolo.json)]
23491 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.thisnew.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.new.?o000(Unknown Source)
at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?0000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.campaign.econ.EconomyStepTracker.??00(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.advance(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.nextStep(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
... 13 more

Sorry if I made some noobish mistakes in trying this out :)

EDIT:

I also added this to the mod_info for this tests:

"replace":
   [
   "data/campaign/starmap.json",
   "data/campaign/rules.csv",
   "data/campaign/econ/economy.json",
   "data/missions/mission_list.csv",
   ],

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 16, 2015, 08:50:58 PM
Thanks for posting these - fixed so that it shouldn't crash in the last two cases.

For now, I'd suggest having an economy file with one star system with one market. Might be able to put it on a placeholder planet and then remove it, or some such.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uomoz on February 16, 2015, 08:53:57 PM
Thanks for posting these - fixed so that it shouldn't crash in the last two cases.

For now, I'd suggest having an economy file with one star system with one market. Might be able to put it on a placeholder planet and then remove it, or some such.

that's exactly the hack I made ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 17, 2015, 04:25:02 AM
Thanks, Alex!

Now, what's a good way to store variables that will persist through savegames? I used to do it using a non-expiring variable in the memory map. Then I tried using sector.getPersistentData()
Code: java
package exerelin.campaign;

import com.fs.starfarer.api.Global;
import java.util.Map;
import org.apache.log4j.Logger;

public class PlayerFactionStore {
    private static final String PLAYER_FACTION_ID_KEY = "exerelin_playerFactionId";
   
    private static String factionId = "independent";
   
    public static Logger log = Global.getLogger(PlayerFactionStore.class);
   
    public static void setPlayerFactionId(String newFactionId)
    {
        factionId = newFactionId;
        Map<String, Object> data = Global.getSector().getPersistentData();
        data.put(PLAYER_FACTION_ID_KEY, factionId);
        log.info("Stored player ID as " + factionId);
        Object storedId = data.get(PLAYER_FACTION_ID_KEY);
        if (storedId != null)
        {
            log.info("Found stored player ID " + storedId);
        }
    }
   
    public static String getPlayerFactionId()
    {
        Map<String, Object> data = Global.getSector().getPersistentData();
        Object storedId = data.get(PLAYER_FACTION_ID_KEY);
        if (storedId != null)
        {
            log.info("Found stored player ID " + storedId);
            factionId = (String)storedId;
            return (String)storedId;
        }
        return factionId;
    }
}
But I can't actually fetch the data once I put it in (I can't even tell if it actually gets added or not). Am I doing something wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 18, 2015, 05:57:32 AM
Figured out that I shouldn't try to save persistent data from character creation.

Okay, new question: I don't suppose there a way to get a ship's fuel/cargo/crew capacity given the variant name? This would save me the trouble of having to manually specify how much of these to add when giving the player ships during NGC.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 18, 2015, 12:49:00 PM
Figured out that I shouldn't try to save persistent data from character creation.

Right, IIRC that's why there's a memory that gets passed around there. Well, that and the fact that it's needed as context for the dialog to work.

Okay, new question: I don't suppose there a way to get a ship's fuel/cargo/crew capacity given the variant name? This would save me the trouble of having to manually specify how much of these to add when giving the player ships during NGC.

Don't believe so - you really need a FleetMemberAPI for that. ... actually, you could create one using FactoryAPI.createFleetMember(). Yeah, I think that'd work - fairly sure you don't need to be in the campaign to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 19, 2015, 06:02:10 PM
How can we get the groupNumber of a WeaponGroupAPI group, so that we can send a Command?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 19, 2015, 08:54:33 PM
Something like ShipAPI.getWeaponGroupsCopy().indexOf(group).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 19, 2015, 09:36:50 PM
Something like ShipAPI.getWeaponGroupsCopy().indexOf(group).

Yeah, I ended up solving it this way:

Code: java
        List<WeaponGroupAPI> weaponGroups = ship.getWeaponGroupsCopy();
        ListIterator<WeaponGroupAPI> groupsIter = weaponGroups.listIterator();
        while (groupsIter.hasNext()){
            WeaponGroupAPI thisGroup = (WeaponGroupAPI) groupsIter.next();
            
            //DO STUFF
        }

Twas a little messy, though, because once again, I ran into the problem of not being be able to use ship.giveCommand() commands multiple times in a single frame for Weapons Groups.  Got it nailed down, though :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 19, 2015, 11:12:45 PM
Hi!
What should I do to make a faction trade with player even if hostile? I have a pirate faction in my mod which is working okay. It has -0.65 standing with player and       "willTradeWhenHostile":true in faction file. And I've got another one, just with the same parameters, which is NOT willing to trade with me. What's wrong? Is there anything else needed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 19, 2015, 11:20:18 PM
Hmm. Looking into it, that's not enough - willTradeWhenHostile actually only allows you to gain reputation from trading with that faction when you're hostile, so that's rather misleadingly named. My apologies!

The actual "will it trade" logic is in rules.csv. There was a thread about it somewhere else, but I can't find it for some reason. What you want to do is search for marketPostOpenPiratesHostile, and add a similar line to your mod's rules.csv, but with your faction id instead of "pirates", and with a different rule id, of course. I think that's all that's necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 19, 2015, 11:46:46 PM
Yeah, willTradeWhenHostile was really misleading) Thanks for explanation, I'll try to find that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 20, 2015, 02:51:57 AM
Hello,

I am trying my luck at modding and I thought I'd start by trying to convert the Hiigaran Descendants to 0.65.2a. Gotcha said on his forum we'd be free to try and update the mod if we'd like since he can't do it at the moment, so I'd thought like to give it a bash.
I not really familiar with the starsector api, lazylib, shaderlib etc, but I do have experience in programming, only just not in Java.
I've already identified most of what I need to change within the source files, how I will go about doing that...well I'm gonna need a bit help.
First things first upon booting up the game with Hiigaran only I get this nifty little error in the starsector log:

3695 [Thread-5] INFO  com.fs.starfarer.loading.SpecStore  - Loading hiigaran_descendants faction
3728 [Thread-5] ERROR com.fs.starfarer.combat.D  - org.json.JSONException: JSONObject["logo"] not found.
org.json.JSONException: JSONObject["logo"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.SpecStore.this.super(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ö00000(Unknown Source)
   at com.fs.starfarer.loading.G.super(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

I'm not quite sure what to make of this, from what I can gather an object named "logo" can't be found. Any suggestions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 20, 2015, 04:18:04 AM
Each faction file should have a "logo" entry with a path to icon image. Perhaps the mod was designed at the times when this didn't exist yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 20, 2015, 04:50:54 AM
Yes it was back in 0.62, added the missing information into the faction.json.
Now I'm tackling sector generation, this part I have to rebuild mostly from scratch from what I see here, is there a list of planet types, star types and other such entities anywhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 20, 2015, 06:41:52 AM
Yep, this stuff is in planets.json in vanilla data/config fodler.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 20, 2015, 06:50:10 AM
Hmm Null pointer exceptions when trying to start a new campaign...
57534 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.ui.trade.CargoItemStack.readResolve(Unknown Source)
   at com.fs.starfarer.campaign.ui.trade.CargoItemStack.<init>(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CargoData.addItems(Unknown Source)
   at data.scripts.world.HiiPolarisGen.initStationCargo$(HiiPolarisGen.java:206)
   at data.scripts.world.HiiPolarisGen.generate(HiiPolarisGen.java:104)
   at data.scripts.world.HiiModPlugin.initHiigaranDescendants(HiiModPlugin.java:19)
   at data.scripts.world.HiiModPlugin.onNewGame(HiiModPlugin.java:28)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)

Problem seems to be from me trying to add items to the stations, how do you add markets to planets and link them up with the stations? And setup item availability and such?

Also where can I find fleet types and define my own fleet types?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 20, 2015, 08:34:18 AM
You'd better take a more close look at how these things are done in vanilla. Browse the data folders (vanilla and other mods) to find something looking similar to what you are trying to do, and you won't need to post every question here)
You need to look at data/campaign/starmap.json, data/campaign/econ/*. AFAIK since economy was added items are no longer added via java scripts - you just specify the market conditions in this folder, all the rest is done when running simuation before game start. This will require some tweaking to be stable though, search the forum for problems with balancing markets.
I'm not very sure about fleets, but I guess people will correct me if i'm wrong: fleets are defined in vanilla core scripts, and are not that easy to modify (especially if you are just starting with modding). Some use their own fleet composing scripts, like in Uomoz Sector. What is easy to define is the ship roles. They can be found in data/world/factions folder in special file and in faction files (overrides). This describes the roles and particular variants that can be chosen by generator for that role. In most cases this will do the trick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 20, 2015, 09:35:56 AM
For star system/planet/station/market creation, check some of the code-based examples in any of the updated mods (Shadowyards has a runtime compile version, and Blackrock has source code included in the jar folder). The current preference is to avoid using starmap.json and economy.json AFAIK.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 20, 2015, 09:44:30 AM
Didn't hear about that. Is something wrong with economy files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 20, 2015, 09:54:39 AM
The way Hiigaran Descendants fleet spawning is set up won't work anymore from the looks of it so I need to figure out how the fleet/ship system works now.
Do you need to do anything special to add interaction with spawned stations? I'vé managed to spawn my system and create planets and stations but I can't interact with them.

The fleet generation is very confusing  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 20, 2015, 03:07:30 PM
Didn't hear about that. Is something wrong with economy files?

There was an issue where this wasn't being merged properly by the base game, and so each mod had to provide a full economy.json, which naturally made mods incompatible where otherwise they wouldn't be.

As far as I know, this is fixed now and economy.json should be fine to use, but there could be other reasons I'm not aware of.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vaio on February 20, 2015, 11:21:24 PM
I want to ask about support user-made ships
In front page fractalsoftworks.com is written:
Mod support for user-made factions, missions, ships, and weapons
Custom weapons add-on good work with original games command AddRandomWeapon to market,
and may hunt for rare custom weapons  :)
But user-made ships not added to market, they can be added to the game only with
Console Commands AddShip (but it is not interesting in game and good only for edit and test ships)
Maybe make some way to add custom ships to black market with high price, or some scripts for not factions mods,
 only with custom ships?
(PS:Custom ships in custom missions I think not interesting)
Sorry, for my bad Google english.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 21, 2015, 01:26:18 AM
As far as I know, this is fixed now and economy.json should be fine to use, but there could be other reasons I'm not aware of.
The reasons we keep creating the markets in the system.java is because it's easier to maintain (we don't have to worry about the starmap.json and the economy.json) and using an IDE hotfix function we can tune the markets conditions without having to relaunch the game (creating a new campaign is all that's needed, witch is definitively nice when the mods make the initial launch quite long).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 21, 2015, 01:37:57 AM
Could someone please explain the structure of Ships roles and how to use these to spawn ships? I've been poking around in the various script files but for some like Blackrock I didn't find any specific script that handles fleet generation.

For example I've been looking into the vanilla files and found a structure like this.

"shipRoles":{
      "interceptor":{
         "talon_wing":10,
         "thunder_wing":10,
         "fallback":{"fighter":1},
      },
      "fighter":{
         "broadsword_wing":10,
         "gladius_wing":10,
         "warthog_wing":10,
         "fallback":{"interceptor":1},
      },
      "bomber":{
         "piranha_wing":10,
      },
      
      "fastAttack":{
         "lasher_Standard":10,
         "hound_luddic_church_Standard":10,
         "wolf_Assault":2,
         "fallback":{"combatSmall":1},
      },
   
      "escortSmall":{
         "lasher_CS":10,
         "lasher_PD":10,
         "monitor_Escort":2,
         "wolf_PD":10,
         "vigilance_FS":10,
         "fallback":{"combatSmall":1},
      },
Some of these are variants that can be found in the variants folder, but others like "talon_wing" there are no variant files, only talon.variant. Also I don't quite understand what the :number is supposed to specify.
What does fallback acomplish?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 21, 2015, 01:46:23 AM
Vanilla handle the fleet spawning: You define role, it pick the right ship to the right fleet. And fighters always have been spawned in wings defined in the wings_data.csv next to the ship_data.csv. The number is (obviously) the probability of this or this variant to be picked up. "Fallback" is the fallback  ??? Pretty self explanatory...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 21, 2015, 01:54:00 AM
Vanilla handle the fleet spawning: You define role, it pick the right ship to the right fleet. And fighters always have been spawned in wings defined in the wings_data.csv next to the ship_data.csv. The number is (obviously) the probability of this or this variant to be picked up. "Fallback" is the fallback  ??? Pretty self explanatory...

When is fallback triggered?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 21, 2015, 02:36:43 AM
Randomly? and probably when the market is too poor to afford a better variant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 21, 2015, 04:31:31 AM
Alright fair enough, how do you set planet ownerships and station markets?

In the weapons.csv what is hints and number used for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 21, 2015, 05:46:36 AM
hints: AI behaviour
number: nothing
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 21, 2015, 06:39:10 AM
Hmm, is there a way to, after character creation, set the star system and position where the player spawns (or to move the player fleet there once it does spawn?)

and using an IDE hotfix function we can tune the markets conditions without having to relaunch the game (creating a new campaign is all that's needed, witch is definitively nice when the mods make the initial launch quite long).
Woah, really? I must know the secret to this sorcery, it would save me so much time!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 21, 2015, 08:11:43 AM
My custom description won't load, am I forgetting anything?

PlanetAPI hii1 = system.addPlanet("newhiigara", star, "New Hiigara", "newhiigara", 235, 175, 8000, 250);
        hii1.setCustomDescriptionId("newhiigara");

description.csv contains a line with id: newhiigara and some flavor text.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 21, 2015, 08:17:08 AM
Woah, really? I must know the secret to this sorcery, it would save me so much time!
Debido made some tutos some time ago:
http://fractalsoftworks.com/forum/index.php?topic=7957.0
http://fractalsoftworks.com/forum/index.php?topic=7956.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 21, 2015, 08:51:31 AM
Quote
description.csv contains a line with id: newhiigara and some flavor text.
What is the type column's value?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 21, 2015, 09:12:25 AM
Fixed it, changed the tag from PLANET to custom.

So I created a json file for economy and added: sector.addScript(new EconomyFleetManager()); into the generator for my systems, however the planets are still without a faction and no fleets spawn. (I've created shiproles in the faction file).

Code
{
"starSystem":"polaris",
"markets":[
{
"entities":["newhiigara", "new_hiigara_station"],
"faction":"hiigaran_descendants",
"size":8,
"startingConditions":[
"urbanized_polity",
"headquarters",
"military_base",
"orbital_station",
"ore_complex",
"ore_complex",
"ore_refining_complex",
"ore_refining_complex",
"ore_refining_complex",
"ore_refining_complex",
"ore_refining_complex",
"ore_refining_complex",
"water",
"aquaculture",
"antimatter_fuel_production",
"large_refugee_population",
"uninhabitable",
"population_8",
],
},
{
"entities":["hiigara_security_station"],
"faction":"hiigaran_descendants",
"size":6,
"startingConditions":[
"urbanized_polity",
"aquaculture",
"volturnian_lobster_pens",
"heavy_industrial_complex",
"large_refugee_population",
"organized_crime",
"water",
"population_6",
],
},
{
"entities":["maal","hiigara_graveyard"],
"faction":"independant",
"size":3,
"startingConditions":[
"ore_complex",
"vice_demand",
"shipbreaking_center",
"ore_refining_complex",
"ore_refining_complex",
"outpost",
"uninhabitable",
"population_3",
],
},
{
"entities":["kohntala"],
"faction":"pirates",
"size":4,
"startingConditions":[
"military_base",
"headquarters",
"volatiles_complex",
"ore_complex",
"dissident",
"uninhabitable",
"population_3",
],
},
],


}

Polaris system file:

Code
public class HiiPolarisGen
{
    public void generate(SectorAPI sector)
    {
        
        StarSystemAPI system = sector.createStarSystem("Polaris");
        LocationAPI hyper = Global.getSector().getHyperspace();
        system.setBackgroundTextureFilename("graphics/backgrounds/hii_background.jpg");
        
        sector.setRespawnLocation(system);
        sector.getRespawnCoordinates().set(-2500, -3500);
        
        PlanetAPI star = system.initStar("polaris", "hii_star", 600f);
        star.setCustomDescriptionId("hii_star");
        
        PlanetAPI hii1 = system.addPlanet("newhiigara", star, "New Hiigara", "newhiigara", 235, 175, 8000, 250);
        hii1.setCustomDescriptionId("newhiigara");
        
        PlanetAPI hii2 = system.addPlanet("jakuul", star, "Jakuul", "hii_gas_giant", 275, 255, 13000, 350);
        hii2.setCustomDescriptionId("hii_gas_giant");
        
        PlanetAPI hii3 = system.addPlanet("koya", hii2, "Koya", "hii_moon", 135, 50, 500, 30);
        hii3.setCustomDescriptionId("hii_moon");
        
        PlanetAPI hii4 = system.addPlanet("daiamid", star, "Daiamid", "hii_ocean", 75, 150, 6000, 150);
        hii4.setCustomDescriptionId("hii_ocean");
        
        PlanetAPI hii5 = system.addPlanet("maal", star, "Maal", "hii_volcanic", 0, 125, 3000, 100);
        hii5.setCustomDescriptionId("hii_volacani");
        
        PlanetAPI hii6 = system.addPlanet("kohntala",star, "Kohntala", "hii_frozen", 200, 200, 16000, 350);
        hii6.setCustomDescriptionId("hii_frozen");
        
        SectorEntityToken relay = system.addCustomEntity("polaris_relay", "New Hiigara Relay", "comm_relay", "hiigaran_descendants");
        relay.setCircularOrbit(system.getEntityById("newhiigara"), 90, 650, 275);

        SectorEntityToken jmp1 = system.getEntityById("newhiigara");        
        JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("jump_point_alpha", "Jump Point Alpha");
        OrbitAPI orbit = Global.getFactory().createCircularOrbit(hii5, 0, 500, 30);
        jumpPoint.setOrbit(orbit);
        jumpPoint.setRelatedPlanet(hii1);
        jumpPoint.setStandardWormholeToHyperspaceVisual();
        system.addEntity(jumpPoint);
/*
        SectorEntityToken NewHiigaraStation = system.addOrbitalStation(hii1, 45, 400, 50, "'Angel Moon' Station", "hiigaran_descendants");
        SectorEntityToken NewHiigaraSecurityStation = system.addOrbitalStation(hii5, 45, 300, 50, "Security Station", "hiigaran_descendants");
        SectorEntityToken NewHiigaraGraveyard = system.addOrbitalStation(hii1, 245, 600, 50, "Ship Graveyard", "neutral");
*/
        SectorEntityToken NewHiigaraStation = system.addCustomEntity("new_hiigara_station", "'Angel Moon' Station", "new_hiigara_type", "hiigaran_descendants");
        NewHiigaraStation.setCircularOrbitPointingDown(system.getEntityById("newhiigara"), 45, 400, 50);
        
        SectorEntityToken NewHiigaraSecurityStation = system.addCustomEntity("hiigara_security_station", "'Guard House' Station", "hiigara_security_type", "hiigaran_descendants");
        NewHiigaraSecurityStation.setCircularOrbitPointingDown(system.getEntityById("koya"), 45, 300, 50);
                
        SectorEntityToken NewHiigaraGraveyard = system.addCustomEntity("hiigara_graveyard", "Junkyard Station", "new_hiigara_type", "neutral");
        NewHiigaraGraveyard.setCircularOrbitPointingDown(system.getEntityById("maal"), 45, 600, 50);
        
        //Asteroids
        system.addAsteroidBelt(hii2, 25, 800, 128, 40, 80);
        system.addAsteroidBelt(star, 1000, 10000, 200, 40, 80);
        system.addAsteroidBelt(star, 1000, 10000, 200, 40, 80);

        system.addRingBand(hii1, "misc", "hii_rings", 256f, 3, Color.white, 256f, 250, 40f);
        system.addRingBand(hii1, "misc", "hii_rings", 256f, 2, Color.white, 256f, 250, 20f);
        system.addRingBand(hii1, "misc", "hii_rings", 256f, 1, Color.white, 256f, 250, 10f);
        system.addRingBand(hii5, "misc", "hii_rings", 256f, 0, Color.white, 256f, 190, 10f);
        system.addRingBand(hii4, "misc", "rings1", 256f, 2, Color.white, 256f, 400, 30f);
        system.addRingBand(hii4, "misc", "rings1", 256f, 3, Color.white, 256f, 400, 40f);
        system.addRingBand(hii4, "misc", "rings1", 256f, 2, Color.white, 256f, 600, 40f);
        system.addRingBand(hii6, "misc", "rings1", 256f, 1, Color.white, 256f, 400, 40f);
        system.addRingBand(hii6, "misc", "rings1", 256f, 0, Color.white, 256f, 600, 60f);
        system.addRingBand(hii6, "misc", "rings1", 256f, 2, Color.white, 256f, 1000, 80f);
        
        
        //initStationCargo(NewHiigaraStation);
        //initSecurityStationCargo(NewHiigaraSecurityStation);

        system.autogenerateHyperspaceJumpPoints(true, true);
        sector.addScript(new EconomyFleetManager());
    }

  
}

What am I missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 21, 2015, 09:48:42 AM
Code
hii1.setFaction("yourFactionIdHere");
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on February 21, 2015, 11:22:55 AM
When is fallback triggered?

The fallback is for when no specified ships can be found in the market that the fleet is spawning from, it's a general bracket of ships that allows things to be taken from the open market (though I don't think things are taken from the black market) and is what leads to Tri-Tach fleets fielding reappropriated SHI ships or the Hegemony fielding II ships.

In the weapons.csv what is hints and number used for?

Hints provide focus for the weapon. DO_NOT_AIM allows the AI to fire the weapon without first pointing it at a target. Vanilla examples include Pila and Hurricanes which can quickly correct their own trajectories. STRIKE tells the AI to refrain from using the weapon all willy-nilly and prefer to use it to push a target over the edge. AM Blasters and most, if not all torpedoes are treated with this in vanilla. USE_VS_FRIGATES, found on the AM Blaster, means that it's fine to use the weapon on a frigate. Without that hint, the AI would not waste AM rounds on a frigate because it's a strike weapon. ANTI_FTR prioritizes fighters over other targets, I believe. PD will target missiles. Putting PD or ANTI_FTR before the other will prioritize that aspect of point defense. If you put ANTI_FTR first, the weapon will focus down any fighters first, then missiles, then ships. SYSTEM makes the weapon unable to drop as loot and is typically used on things like flares or decor but you can use it to make weapons on a ship unlootable regardless. SHOW_IN_CODEX is pretty self explanatory, if the weapon is usually just a built-in weapon, this makes sure it still appears in the codex for study. GUIDED_POOR allows for some leeway in aiming, a sort of closeenough.jpg approach.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on February 21, 2015, 11:30:44 AM
When is fallback triggered?

The fallback is for when no specified ships can be found in the market that the fleet is spawning from, it's a general bracket of ships that allows things to be taken from the open market (though I don't think things are taken from the black market) and is what leads to Tri-Tach fleets fielding reappropriated SHI ships or the Hegemony fielding II ships.

No, fallback is used when market stability is too low/high to support the variant quality factor of the variants in the list.  Hegemony using II ships and such is actually unrelated to this; it's a SS+ feature to increase fleet variety.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on February 21, 2015, 11:55:06 AM
Variant quality factor?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 21, 2015, 12:25:47 PM
How does starsector load up the econ files? for example corvus.json. Are they loaded automatically?

Progress, managed to spawn fleets and generate markets. :) Have a little problem , how do i control item availability? The current setup gives some Hiigaran ships but no hiigaran weapons.
Is there a list where I can find what those market conditions mean? Do they influence availability of weapons, ships and their tier?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2015, 01:11:42 PM
As far as I know, this is fixed now and economy.json should be fine to use, but there could be other reasons I'm not aware of.
The reasons we keep creating the markets in the system.java is because it's easier to maintain (we don't have to worry about the starmap.json and the economy.json) and using an IDE hotfix function we can tune the markets conditions without having to relaunch the game (creating a new campaign is all that's needed, witch is definitively nice when the mods make the initial launch quite long).

Ah, thanks for explaining. Yeah, that makes good sense.


Variant quality factor?

It's a value in the .variant file. Higher stability markets tend to spawn fleets with higher quality variants.



I want to ask about support user-made ships
In front page fractalsoftworks.com is written:
Mod support for user-made factions, missions, ships, and weapons
Custom weapons add-on good work with original games command AddRandomWeapon to market,
and may hunt for rare custom weapons  :)
But user-made ships not added to market, they can be added to the game only with
Console Commands AddShip (but it is not interesting in game and good only for edit and test ships)
Maybe make some way to add custom ships to black market with high price, or some scripts for not factions mods,
 only with custom ships?
(PS:Custom ships in custom missions I think not interesting)
Sorry, for my bad Google english.

You have to add your new ships to the fleet compositions of a faction if you want it to show up in the campaign - take a look at the various .faction files.

Or you can create your own faction, but that's more involved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on February 21, 2015, 01:17:31 PM
Quote
How does starsector load up the econ files? for example corvus.json. Are they loaded automatically?
Did you even look at the folder with those files? There is an economy.json file, which is pretty self-explanatory.
Quote
Is there a list where I can find what those market conditions mean? Do they influence availability of weapons, ships and their tier?
Code for all these things are in api zip (if the description isn't enough). starsector-core folder has starfarer.api.zip containing all sorts of stuff used by game. Unzip it and browse com\fs\starfarer\api\impl\campaign\econ folder: there you'll find all market condition plugins. AFAIK none of them influences availability of ships/weapons. "Tier" is regulated by market stability, as already stated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on February 21, 2015, 02:19:20 PM
Variant quality factor?
It's a value in the .variant file. Higher stability markets tend to spawn fleets with higher quality variants.

Hrm. I was working under this impression (http://puu.sh/g6JKQ/5cd3064607.png) and that there wasn't any other factors in it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 21, 2015, 03:01:21 PM
Quote
Is there a list where I can find what those market conditions mean? Do they influence availability of weapons, ships and their tier?
*sigh*
http://fractalsoftworks.com/forum/index.php?topic=8493.0
Please use the search button before asking basic questions that have been answered a gazillion times before...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2015, 03:34:44 PM
Variant quality factor?
It's a value in the .variant file. Higher stability markets tend to spawn fleets with higher quality variants.

Hrm. I was working under this impression (http://puu.sh/g6JKQ/5cd3064607.png) and that there wasn't any other factors in it.

That's true as far as it goes, but stability and variant quality act as multipliers for the weights.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on February 21, 2015, 03:39:44 PM
It seems that when I try to get a value from a WeightedRandomPicker or use an enum in a switch I get an error that says it 'Assignment conversion not possible from Object to enum' or 'Assignment conversion not possible from enum to int', even though these worked last patch. Any reason why this could happen (i'm using eclipse btw).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2015, 03:51:25 PM
Are you compiling to a jar or is the game compiling your code on startup?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on February 21, 2015, 03:54:28 PM
Found the problem! I put the wrong folder to look for the jar in in mod_info. :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 22, 2015, 04:01:38 AM
When is fallback triggered?

The fallback is for when no specified ships can be found in the market that the fleet is spawning from, it's a general bracket of ships that allows things to be taken from the open market (though I don't think things are taken from the black market) and is what leads to Tri-Tach fleets fielding reappropriated SHI ships or the Hegemony fielding II ships.

In the weapons.csv what is hints and number used for?


Hints provide focus for the weapon. DO_NOT_AIM allows the AI to fire the weapon without first pointing it at a target. Vanilla examples include Pila and Hurricanes which can quickly correct their own trajectories. STRIKE tells the AI to refrain from using the weapon all willy-nilly and prefer to use it to push a target over the edge. AM Blasters and most, if not all torpedoes are treated with this in vanilla. USE_VS_FRIGATES, found on the AM Blaster, means that it's fine to use the weapon on a frigate. Without that hint, the AI would not waste AM rounds on a frigate because it's a strike weapon. ANTI_FTR prioritizes fighters over other targets, I believe. PD will target missiles. Putting PD or ANTI_FTR before the other will prioritize that aspect of point defense. If you put ANTI_FTR first, the weapon will focus down any fighters first, then missiles, then ships. SYSTEM makes the weapon unable to drop as loot and is typically used on things like flares or decor but you can use it to make weapons on a ship unlootable regardless. SHOW_IN_CODEX is pretty self explanatory, if the weapon is usually just a built-in weapon, this makes sure it still appears in the codex for study. GUIDED_POOR allows for some leeway in aiming, a sort of closeenough.jpg approach.

Thank you for the explanation :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 22, 2015, 07:59:16 AM
I'm getting some rather weird fleet compositions, 5 freighters or more and a few frigates.
How do I balance fleet compositions properly?

Also how does one add custom planet interaction images?
Using SetInteractionImage("illustrations" , "my_image"), doesn't seem to do the trick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 22, 2015, 10:05:47 PM
I'm getting some rather weird fleet compositions, 5 freighters or more and a few frigates.
How do I balance fleet compositions properly?

Also how does one add custom planet interaction images?
Using SetInteractionImage("illustrations" , "my_image"), doesn't seem to do the trick.

Fleet composition is automatic/dynamically adjusted on the fly based upon market conditions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 23, 2015, 12:25:04 AM
I see, so I need to tinker with my market conditions. Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 23, 2015, 01:38:02 AM
Yes and...no

If there are more pirates attacking a market, the market will generate more war vessels proportional to the pirate fleet size.

If you use lazy libs console, and give yourself a big fleet, just go around smashing into all ships generated by your faction, you will see in a few minutes a proportional response generated.

Here is some additional info.

http://fractalsoftworks.com/2014/07/24/fleet-creation/#more-2146
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on February 23, 2015, 05:51:04 AM
Quote
Is there a list where I can find what those market conditions mean? Do they influence availability of weapons, ships and their tier?
*sigh*
http://fractalsoftworks.com/forum/index.php?topic=8493.0
Please use the search button before asking basic questions that have been answered a gazillion times before...

I'd say such a tone is unwarranted and unneeded. Your thread has all of two replies in it and you could have posted your findings into a code window for all to see at a glance instead of needing to download a file. A cursory search of "economy" doesn't even put your thread on the first page of results. He's a dude asking for help in a general modding help thread, you don't need to be telling him to go away, look for it himself and come back when he has real questions. All modding questions are valid here whether answered or not. If answered, a link, brief rundown and "here you go, bud" is all that's needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 23, 2015, 05:58:45 AM
Yes and...no

If there are more pirates attacking a market, the market will generate more war vessels proportional to the pirate fleet size.

If you use lazy libs console, and give yourself a big fleet, just go around smashing into all ships generated by your faction, you will see in a few minutes a proportional response generated.

Here is some additional info.

http://fractalsoftworks.com/2014/07/24/fleet-creation/#more-2146
Useful stuff, thanks  :)

I have some ideas about making the big Skaal laser systems a bit more...epic when they fire. Is there a way to generate and manipulate particles?
The effect I have in mind is a small plume of particles start to form at the muzzle point in a specific fashion/pattern during the weapon charge-up. I've already played around with Shaderlibs lights and got some interesting results but I'm curious if I can add some particle effects to it as well.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on February 23, 2015, 06:11:36 AM
Yeah, people use a few different tricks to achieve particle generation. Using EveryFrameCombat or OnHit or BeamEffectPlugin scripts or whatever is applicable to your weapon or scenario/context for the particle generation. Find a weapon you like the particle effects of, and then look through the code, then use that as an example for your own.

There is a "Radioactive Code Dump" of various scripts, some of them are a little outdated and need updating, but check out:

http://fractalsoftworks.com/forum/index.php?topic=6452.0

There is a whole lot of code, some of it overpowered or just very very cool.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 23, 2015, 06:19:57 AM
Awesome  :) Here is an idea of what type of particle effect I'm trying to implement.

http://youtu.be/5NkHjKPdDsw?t=49s (http://youtu.be/5NkHjKPdDsw?t=49s)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 23, 2015, 06:33:30 AM
stuff
Sorry, there has been a long streak of obvious questions recently and well, at some point it does get old when they have been answered many times before. But what can I do? Leave the question unanswered? Don't seems like a good idea either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silver Silence on February 23, 2015, 09:50:03 AM
Sorry, there has been a long streak of obvious questions recently and well, at some point it does get old when they have been answered many times before. But what can I do? Leave the question unanswered? Don't seems like a good idea either.
All modding questions are valid here whether answered or not. If answered, a link, brief rundown and "here you go, bud" is all that's needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 23, 2015, 10:36:47 AM
I don't see the connection there. I did provide said answer, with a (slightly acid) advise to search the forum first next time since it was the 10th or so basic question that day (and it was more a general advise than a personal attack). Isn't that better than not answering the question at all? And before you say "someone else will answer that if it bother you", sometimes there isn't anybody else and the thread get bumped again and again with "please gimme some answer"...

I don't deny it sounded a bit aggressive, but the advise itself is valid and help keeping this thread useful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 23, 2015, 02:00:39 PM
Do I need to restart the game everytime I change some data in the .csv files? I'm tinkering with the lights and weapons stats but reloading the game everytimes take quite a while.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 23, 2015, 03:08:31 PM
If you have devmode enabled (either by setting "devMode" to true in starsector-core/data/config/settings.json, or by using the console mod's DevMode command), you can hit F8 to reload all scripts and data files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 23, 2015, 03:23:58 PM
If you have devmode enabled (either by setting "devMode" to true in starsector-core/data/config/settings.json, or by using the console mod's DevMode command), you can hit F8 to reload all scripts and data files.

Thank you, you've just saved me of having to wait 2 minutes every time I change a color !  :D
Is there any visual indication that the scripts/data has been reloaded, I doesn't seem to work.

Where can I find    a list of the valid config elements? Like this "statsScript":"data.shipsystems.scripts.FortressShieldStats", I have an idea involving the ShieldAPI as a ship system but I'm unsure of how to link to link it in a shipsystem file.
I want to create a shipsystem called Multispectral Shields, it will act kinda like a fortshield but the shield color will change randomly. Poking around the API I've found functions that do this in the ShieldAPI but my concern is if they are actually supported or not?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 24, 2015, 04:07:25 AM
Suppose I have an invasion fleet of Faction A in orbit around a hostile market of Faction B. At the end of a three-day period, the fleet is likely to capture the market for its own faction, so it's in B's interest to throw everything at the fleet to try to kill it, even using fleets that are individually much weaker.

How do I make the Faction B fleets do this? I tried
Code: java
BroadcastPlayerAction.broadcast(ActionType.HOSTILE, 750, "$exerelinRespondingToInvasion", myInvasionFleet, marketPrimaryEntity);
but no dice, the defender fleets still won't attack if they don't have a significant advantage :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 24, 2015, 04:29:18 AM
Would it be possible to merge them before attacking?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on February 24, 2015, 06:15:10 PM
So, is there a way to get custom fleets to spawn in the game?

I could use some in order to prevent top ships from being sold to the market. Especially Red's.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on February 26, 2015, 11:41:52 AM
Anyone got an arching laser? So basically, It's just an EMP Arc Emitter, Not a laser that emits an arc on the enemy ship when it hits :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on February 27, 2015, 07:08:50 AM
Anyone know how I could interface with ShieldAPI and change shield color?

Is there a way I could add particle effects OnHit? Like creating two plumes of particles while a laser beam cuts into the hull of a ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on February 27, 2015, 08:26:14 AM
Anyone know how I could interface with ShieldAPI and change shield color?

You can get the Hull Styles from "\starsector-core\data\config", the file itself does changes to the color of the conditions of your ship, including shields. You can also change the sounds of your ships for your liking.

Just make your own name for the Hull Style of your choosing and slap the new one with each Hull of your faction, once your done tinkering the colors.


Is there a way I could add particle effects OnHit? Like creating two plumes of particles while a laser beam cuts into the hull of a ship.

So far, as I can tell that ShaderLib is only responisble for the OnHit particle effects. Although the Hull Style can have you configure explosion color of your ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sirboomalot on February 27, 2015, 08:37:52 PM
Well I'm not exactly a modder, but I figured the question I've run into could technically fit into the parameters of this thread.

Basically, I've just downloaded and installed the latest starsector version and am being silly and trying to get as many mods running at the same time as possible, because more in my mind is more. I have also frankensteined an april-fools polka mod and ye 'ol galatia complete music-pack into starsector+'s musiclib. The complete list of mods, as it stands, is spoiler'd below:

Spoiler
Starsector+ V. 2.6.7
Blackrock Driveyards V. 0.7.3
Citadel 0.7.6a
Diable Avionics 1.05
Exigency Incorporated 0.7
Interstellar Imperium 1.7.2
Junk pirates/ASP/Pack 2.36
Lazylib 2.0b
Ori 0.2.1
Patrian Principate 2.2a
Scy 0.8.9
The Crystantite Coalition 1.2
Knights templar 0.9.4
Mayorate 0.8.1
Twiglib 0.6.5p
Musiclib 2.6.7+
Shaderlib Beta 1.05
[close]

I am fully capable of starting a new game, getting myself blown up in a battle, visiting a wormhole and station, saving my game, and doing just about everything else with the game but just one thing. Even the music works properly.

My question?

Why on earth is the load button of all things broken?! I get a CTD every time I hit the button, from the main-menu or from in-game, with the following showing up in my .log file:

Spoiler
365954 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.save.LoadGameDialog.super(Unknown Source)
   at com.fs.starfarer.campaign.save.LoadGameDialog$1.o00000(Unknown Source)
   at com.fs.starfarer.campaign.save.LoadGameDialog$1.compare(Unknown Source)
   at java.util.Arrays.mergeSort(Unknown Source)
   at java.util.Arrays.legacyMergeSort(Unknown Source)
   at java.util.Arrays.sort(Unknown Source)
   at java.util.ArrayList.sort(Unknown Source)
   at java.util.Collections.sort(Unknown Source)
   at com.fs.starfarer.campaign.save.LoadGameDialog.<init>(Unknown Source)
   at com.fs.starfarer.campaign.ooOO.ôøo000(Unknown Source)
   at com.fs.starfarer.campaign.save.oOOO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Any information on which mod I need to cut from the list to make things work would also be appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on February 27, 2015, 08:50:30 PM
You have to delete your old saves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on February 27, 2015, 09:17:58 PM
If you want to spare your previous Save, get the Save Transfer Mod (http://fractalsoftworks.com/forum/index.php?topic=8950.0) and its requirements and follow its instructions.

In my case, this happens:
Quote
1. Load up the original mods (before patches) and then load save.
2. "Copysave" in the Console during transit within the game. (Copies data to the Clipboard, so don't copy anything else with Ctrl+C)
3. (Optional) Paste to a notepad to use for later.
4. Place new patches for respective mods and load the game.
5. Start a new game.
6. "Loadsave" in the Console during transit within the game. (Uses the data from the Clipboard, and hopefully still has your "Copysave" data)
7. Celebrate your success of transferring necessary game data from the previous saves.

Save Transfer Mod, although, cannot guarantee all your items will be spared on the trip, since it has something to do with the New items existing or Items getting new id's from the new mod patches.

Normally new updates causes your saves to corrupt, since there are changes within the data where it normally shouldn't be anymore, such as new ships, new weapons and new scripts in the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sirboomalot on February 28, 2015, 08:03:32 AM
I knew that saves in old versions of the game wouldn't work, but I hadn't realized they could entirely crash the game. Thanks for the aid, folks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on February 28, 2015, 09:26:53 PM
I'm using the json method of generating markets, but for some reason when the new game is loading it goes Spec of class with id [test] not found. Any reason why it's not finding the planet? (I have the planet in the gen file and the id's are the same).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on March 01, 2015, 01:15:23 AM
Make sure the object follows the AddPlanet ID and not the API ID, I got this mistake at first, having my planet virtually market-less upon start-up.

From a World file.
Code
PlanetAPI nemv2 = system.addPlanet("mytoselle", star, "Mytoselle", "terran", 0, 400, 7000, 365);

Then an Economy file.
Code
{
"starSystem":"Nemvis",
"markets":[
{
"entities":["mytoselle"],
"faction":"PTech",
"size":7,
"startingConditions":[
"terran",
"headquarters",
"military_base",
"military_base",
"population_6",
"organics_complex",
"organics_complex",
"aquaculture",
"aquaculture",
"ore_complex",
"ore_complex",
"ore_complex",
"ore_complex",
"ore_complex",
"ore_refining_complex",
"ore_refining_complex",
"ore_refining_complex",
"ore_refining_complex",
"ore_refining_complex",
"volturnian_lobster_pens",
"light_industrial_complex",
"light_industrial_complex",
"light_industrial_complex",
"light_industrial_complex",
"autofac_heavy_industry",
"autofac_heavy_industry",
"autofac_heavy_industry",
"autofac_heavy_industry",
"cottage_industry",
"shipbreaking_center",
"free_market",
],
},
],
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 01, 2015, 05:22:51 AM
Anyone know how I could interface with ShieldAPI and change shield color?

Is there a way I could add particle effects OnHit? Like creating two plumes of particles while a laser beam cuts into the hull of a ship.

A) ShipAPI > getShield()
ShieldAPI > setInnerColor
ShieldAPI > setRingColor

B) Plumes over time require a EveryFrameCombatPlugin in addition to your OnHit. The onHit registers the location of the hit with the EveryFrameCOmbatPlugin and the Every Frame handles the creation, flow, color, and removal of the particle plume.

Mind you laser beams are something different to laser beams, but could be used similarly. See BeamEffectPlugin.

Here is an example of my over penetration script

Code: java
/*Armour Penetration / Shield Ricochet script by Xangle13, updated by Debido
 * This script allows a missile/projectile to simulate certain behaviors
 * 1. Successfully hitting projectiles will pass through and exit the opposite side of a ship if the armour is low enough
 * 2. The projectile will bounce off the enemies shield if it hits at an oblique enough angle
 */

/*
 This is the instant pass through variant, projectile(s) will only 'pass through' if the exit side has armour that is compromised.
 Dev version, includes pop up text.
 */
package data.scripts.weapons;

import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import java.awt.Color;
import org.lazywizard.lazylib.CollisionUtils;
import org.lazywizard.lazylib.FastTrig;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.DefenseUtils;
import org.lwjgl.util.vector.Vector2f;

public class diableavionics_ShapedCharge_b implements OnHitEffectPlugin {

    private Vector2f particleVelocity1;
    private Vector2f particleVelocity2;
    private static final Color particleColor = new Color(245, 48, 58, 225);
    private static final float particleSize = 2.5f;
    private static final float particleBrightness = 1.28f;
    private static final float particleDuration = 1.45f;
    private static final float explosionSize = 120f;
    private static final float explosionSize2 = 60f;
    private static final float explosionDuration = 0.33f;
    private static final float explosionDuration2 = 0.9f;
    private static final boolean dealsSoftFlux = false;

    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
        float ENTER_FACTOR = 0.1f;
        float EXIT_FACTOR = 0.2f;
        //if the target is a ship, that is to say it will not work on asteroids
        if (target instanceof ShipAPI) {
            ShipAPI sourceShip = projectile.getSource();

            //check the source ship is not a null entity
            if (sourceShip != null) {

                //get the weapon that fired the projectile
                WeaponAPI weaponFrom = projectile.getWeapon();

                //if the weapon that fired the projectile is not null
                if (weaponFrom != null) {

                    //get the projectile location and velocity. Location currently not used
                    Vector2f projectileVelocity = projectile.getVelocity();
                    //get the angle at which the projectile is hitting the ship
                    float fromAngle = projectile.getFacing();
                    //get the damage amount
                    float damageAmount = projectile.getDamageAmount();

                    //get the emp amount
                    float empAmount = projectile.getEmpAmount();

                    //get the damage type
                    DamageType damageType = projectile.getDamageType();

                    if (shieldHit) {

                        engine.applyDamage(target, point, damageAmount * (float) (Math.random() * 0.25 + 0.25), damageType, empAmount, false, false, null);

                    } else {
                        // get the targets armor grid
                        ArmorGridAPI targetArmorGrid = ((ShipAPI) target).getArmorGrid();

                        //get the armor rating
                        float targetArmorRating = targetArmorGrid.getArmorRating();

                        //get the armor level of the cell where the projectile is hitting
                        float targetArmorLevel = DefenseUtils.getArmorLevel((ShipAPI) target, point) * (targetArmorRating / 15);

                        //calculate the penetration value against the current armor level at the hit point using 0.1f as a fudge factor.
                        float penetrateValue = (damageAmount * ENTER_FACTOR) - targetArmorLevel;

                        if ((penetrateValue > 0) && (targetArmorLevel >= 0) && ((float) Math.random() <= (penetrateValue / targetArmorLevel))) {
                            Vector2f penetrateVelocity = new Vector2f(projectileVelocity.getX(), projectileVelocity.getY());
                            penetrateVelocity = penetrateVelocity.normalise(penetrateVelocity);
                            Vector2f penetrateLocation = new Vector2f(point.getX() + penetrateVelocity.getX() * 50f, point.getY() + penetrateVelocity.getY() * 50f);

                            //project the pentration vector through the ship to an imaginary point beyond the ship on the opposite side
                            float projectedLocationX = (float) (1200f * FastTrig.cos(Math.toRadians(projectile.getFacing())) + penetrateLocation.x);
                            float projectedLocationY = (float) (1200f * FastTrig.sin(Math.toRadians(projectile.getFacing())) + penetrateLocation.y);

                            //location as vector2f
                            Vector2f projectedLocation = new Vector2f(projectedLocationX, projectedLocationY);

                            //derive exit location with Lazylib collision utils. This basically uses the imaginary point and the hit point, then checks every segment of the hit boundary segments for an intersect then return the Vector2f value of the closest point where the the two line and the boundary segment meet
                            //using this vector direction it will use the farthest point on the ship for the exit
                            //this method will consistently get the outside boundary
                            //Vector2f exitLocation = CollisionUtils.getCollisionPoint(projectedLocation, penetrateLocation, target);
                           
                            //use this vector direction to determine if it should exit at the nearest point
                            //this method does not consistently get the nearest point due to issues probably with other authors ship boundaries.
                            Vector2f exitLocation = CollisionUtils.getCollisionPoint(penetrateLocation, projectedLocation, target);

                            if (null != exitLocation) {
                                float passThroughShipDistance = MathUtils.getDistance(point, exitLocation);

                                //So let's check IF the imaginary projectile can get 'through' the full distance of internal hull, let's use a value of 1000px, a very very big ship! ie. Zorg
                                if (passThroughShipDistance > 1000f) {
                                    //apply bonus RNG damage to entry point.
                                    engine.applyDamage(target, point, damageAmount, DamageType.HIGH_EXPLOSIVE, empAmount, false, dealsSoftFlux, projectile.getSource());
                                    //we're done, no exit
                                    return;
                                }
                                //Now let's check how strong the armor is on the exit location, and can we penetrate the otherside
                                float targetArmorExitLevel = DefenseUtils.getArmorLevel((ShipAPI) target, exitLocation) * (targetArmorRating / 15);

                                float penetrateExitValue = (damageAmount * EXIT_FACTOR) - targetArmorExitLevel;

                                if ((penetrateExitValue > 0) && (targetArmorExitLevel >= 0) && ((float) Math.random() <= (penetrateExitValue / targetArmorExitLevel))) {

                                    //let's do a simple test if the distance through the ship, we have two versions
                                    // if (passThroughShipDistance > projectile.getVelocity().length() || (passThroughShipDistance - projectile.getVelocity().length()) < 100f){
//                                        float newHull = ((ShipAPI)target).getHitpoints() - projectile.getDamageAmount() * 0.5f;
//                                        ((ShipAPI)target).setHitpoints(newHull);
//                                        return;
//                                    }
                                    float passThroughShipTime = passThroughShipDistance / projectile.getVelocity().length();

                                    APDebrisPlugin.startFire(
                                            target,
                                            exitLocation,
                                            projectile.getDamageAmount() * 0.1f,
                                            5f,
                                            projectile.getSource(),
                                            fromAngle,
                                            passThroughShipTime,
                                            projectile
                                    );

                                    APDelayedProjectilePlugin.startFire(
                                            target,
                                            exitLocation,
                                            projectile.getDamageAmount(),
                                            projectile.getSource(),
                                            fromAngle, passThroughShipTime,
                                            projectile.getWeapon().getId(),
                                            projectile.getVelocity().length(),
                                            projectile
                                    );

                                    //engine.applyDamage(target, point, damageAmount * (float) (Math.random() * 1 + 1), damageType, empAmount, true, true, null);
                                    engine.addFloatingText(penetrateLocation, "Penetrated", 30, new Color(255, 0, 0, 255), target, 1f, 2f);

                                    damageAmount += (50f * Math.random());
                                    engine.applyDamage(target, point, damageAmount, DamageType.HIGH_EXPLOSIVE, empAmount, false, dealsSoftFlux, projectile.getSource());

                                } else {
                                    // So if the shaped charge cannot penetrate all the way through, it will start causing damage on the opposite side of the ship.
                                    damageAmount += (50f * Math.random());
                                    engine.applyDamage(target, exitLocation, damageAmount, DamageType.HIGH_EXPLOSIVE, empAmount, true, dealsSoftFlux, projectile.getSource());
                                }
                                //There are some strange cases where where the algorithm to find the exit location will not return one, this else statement captures that
                            } else {

                                engine.spawnExplosion(penetrateLocation, new Vector2f(penetrateVelocity.getX() * 250f, penetrateVelocity.getY() * 250f), new Color(225, 200, 50, 200), damageAmount / 70f, 0.5f);

                                //
                                for (int i = 0; i < (int) (damageAmount / 5); i++) {
                                    engine.addHitParticle(penetrateLocation, new Vector2f(penetrateVelocity.getX() * 300f + (float) (Math.random() * 100 - 30), penetrateVelocity.getY() * 500f + (float) (Math.random() * 100 - 30)), damageAmount / 50, 0.5f, 3f, new Color(225, 200, 50, 170));//Color(225,200,50,200)
                                }

                                //spawn exit projectile(s) this will spawn 10 projectiles, there is not need for a loop if you just want to spawn one projectile
                                for (int i = 0; i < 3; i++) {

                                    CombatEntityAPI projectileSpawned = engine.spawnProjectile(null, null, "diableavionics_thunderboltcharge", penetrateLocation, fromAngle + ((float) Math.random() * 20f - 7f), null);
                                    ((DamagingProjectileAPI) projectileSpawned).setSource((ShipAPI) target);
                                }

                                //engine.applyDamage(target, point, damageAmount * (float) (Math.random() * 1 + 1), damageType, empAmount, true, true, null);
                                engine.addFloatingText(penetrateLocation, "Bypass", 30, new Color(255, 0, 0, 255), target, 1f, 2f);
                            }

                        }
                    }
                }
            }
        }
    }
}

The important part here is the call here

Code: java
                                    APDebrisPlugin.startFire(
                                            target,
                                            exitLocation,
                                            projectile.getDamageAmount() * 0.1f,
                                            5f,
                                            projectile.getSource(),
                                            fromAngle,
                                            passThroughShipTime,
                                            projectile
                                    );

This passes through the target, and location where it hit and so on. Then this is handled by the EveryFrame

Code: java
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.lazywizard.lazylib.FastTrig;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.entities.AnchoredEntity;
import org.lwjgl.util.vector.Vector2f;

// TODO: Check for nearby debriss and merge them for better performance
public class APDebrisPlugin implements EveryFrameCombatPlugin {

    // How long between damage/particle effect ticks
    private static final float TIME_BETWEEN_DAMAGE_TICKS = .2f;
    private static final float TIME_BETWEEN_PARTICLE_TICKS = .33f;
    // Stores the currently DEBRIS_MAP debriss
    // Having the Set backed by a WeakHashMap helps prevent memory leaks
    private static final List<DebrisData> DEBRIS_MAP = new ArrayList<>();
    private CombatEngineAPI engine;
    private float lastDamage, lastParticle;

    @Override
    public void advance(float amount, List events) {

        if (engine != Global.getCombatEngine()) {
            this.engine = Global.getCombatEngine();
        }

        if (engine.isPaused() || DEBRIS_MAP.isEmpty()) {
            return;
        }

        lastDamage += amount;
        lastParticle += amount;

        float damageMod = lastDamage;

        boolean dealDamage = false;
        if (lastDamage >= TIME_BETWEEN_DAMAGE_TICKS) {
            lastDamage -= TIME_BETWEEN_DAMAGE_TICKS;
            dealDamage = true;
        }

        boolean showParticle = false;
        if (lastParticle >= TIME_BETWEEN_PARTICLE_TICKS) {
            lastParticle -= TIME_BETWEEN_PARTICLE_TICKS;
            showParticle = true;
        }

        // Deal debris damage for all actively DEBRIS_MAP projectiles
        for (Iterator iter = DEBRIS_MAP.iterator(); iter.hasNext();) {
            DebrisData debris = (DebrisData) iter.next();

            // Check if the debris has gone out
            if (engine.getTotalElapsedTime(false) >= debris.expiration
                    || !engine.isEntityInPlay(debris.getAnchor())) {
                iter.remove();
            } else if (engine.getTotalElapsedTime(false) < debris.start) {
                continue;
            } else {
                if (dealDamage) {
                    engine.applyDamage(debris.getAnchor(), debris.getLocation(),
                            debris.dps * damageMod, DamageType.FRAGMENTATION,
                            debris.dps * damageMod, true, true, debris.source);
                }

                // Draw smoke effect to show where the debris is DEBRIS_MAP
                float intensity = debris.getRemainingDuration() / debris.getDuration();
                float intensity2 = debris.getRemainingDuration() / (debris.getDuration() * debris.getDuration());

                if (showParticle) {
                    Vector2f particleVelocity = new Vector2f(intensity2 * (debris.getDebrisVector().x),
                            //* 5f
                            //* debris.dps
                            //* debris.getRemainingDuration()
                            //add the x velocity of the host ship
                            //+ debris.getAnchor().getVelocity().x
                            //add some randomness
                            //+ MathUtils.getRandomNumberInRange(-25f, 25f)),
                            intensity2 * (debris.getDebrisVector().y)
                            //* 5f
                            //* debris.dps
                            //* debris.getRemainingDuration()
                            //add the y velocity of the host ship
                            //+ debris.getAnchor().getVelocity().y
                            ////add some randomness
                           // + MathUtils.getRandomNumberInRange(-25f, 25f))
                    );

                    engine.addSmokeParticle(debris.getLocation(), // Location
                            particleVelocity, // Velocity
                            MathUtils.getRandomNumberInRange(20f, 40f), // Size
                            MathUtils.getRandomNumberInRange(.05f, .15f), // Brightness
                            2.2f, Color.DARK_GRAY); // Duration, color

//                    engine.spawnExplosion(debris.getLocation(), //location
//                            particleVelocity,//velocity
//                            Color.yellow, //colour
//                            MathUtils.getRandomNumberInRange(2f, 5f), //size
//                            MathUtils.getRandomNumberInRange(.01f, .05f)); //duration
                }
                //spawn debris from exit hole
                for (int i = 0; i < 2; i++) {
                    Vector2f debrisVelocity = new Vector2f(1200f * intensity2 * debris.getDebrisVector().x
                            //* 5f
                            //* debris.dps
                            //* debris.getRemainingDuration()
                            //add the x velocity of the host ship
                            + debris.getAnchor().getVelocity().x,
                            //add some randomness
                            //+ MathUtils.getRandomNumberInRange(intensity * -15f, intensity * 15f),
                            1200f * intensity2 * debris.getDebrisVector().y
                            //* 5f
                            //* debris.dps
                            //* debris.getRemainingDuration()
                            //add the y velocity of the host ship
                            + debris.getAnchor().getVelocity().y
                    ////add some randomness
                    //+ MathUtils.getRandomNumberInRange(intensity * -15f, intensity * 15f)
                    );

                    float tempKelvin = intensity * 4800f;
                    Color debrisColor = KelvinCalc.getRGB(tempKelvin);

                    engine.addHitParticle(
                            debris.getLocation(), //location,
                            debrisVelocity, //velocity
                            MathUtils.getRandomNumberInRange(1f, 4f) * debris.getRemainingDuration(), //size
                            intensity, debris.getRemainingDuration() * 0.11f, //, new Color(225, 200, 50, 200)
                            debrisColor
                    );

                }

            }
        }
    }

    public static void startFire(CombatEntityAPI target,
            Vector2f hitLoc,
            float totalDamage,
            float burnDuration,
            CombatEntityAPI source,
            float debrisAngle,
            float delay,
            DamagingProjectileAPI projectile
    ) {
        // TODO: merge with nearby debriss on the same target
        DEBRIS_MAP.add(new DebrisData(target, hitLoc, totalDamage, burnDuration, source, debrisAngle, delay, projectile));
    }

    @Override
    public void init(CombatEngineAPI engine) {
    }

    private static class DebrisData {

        private final AnchoredEntity hitLoc;
        private final CombatEntityAPI source;
        private final float dps, expiration, duration, start;
        private final float shipStartFacing, deltaAngle;
        private final DamagingProjectileAPI damagingProjectile;

        public DebrisData(CombatEntityAPI target,
                Vector2f hitLoc,
                float totalDamage,
                float burnDuration,
                CombatEntityAPI source,
                float debrisAngle,
                float delay,
                DamagingProjectileAPI projectile
        ) {
            this.hitLoc = new AnchoredEntity(target, hitLoc);
            this.source = source;
            this.deltaAngle = debrisAngle;
            this.duration = burnDuration;
            this.shipStartFacing = source.getFacing();
            dps = totalDamage / burnDuration;
            expiration = Global.getCombatEngine().getTotalElapsedTime(false)
                    + burnDuration;
            start = Global.getCombatEngine().getTotalElapsedTime(false)
                    + delay;
            this.damagingProjectile = projectile;
        }

        public Vector2f getLocation() {
            return hitLoc.getLocation();
        }

        public CombatEntityAPI getAnchor() {
            return hitLoc.getAnchor();
        }

        private float getDebrisAngle() {
            return deltaAngle + (shipStartFacing - source.getFacing());
        }

        public float getRemainingDuration() {
            return expiration - Global.getCombatEngine().getTotalElapsedTime(false);
        }

        public float getDuration() {
            return duration;
        }

        public Vector2f getDebrisVector() {
            Vector2f debVector = new Vector2f();
            damagingProjectile.getVelocity().normalise(debVector);
            return debVector;
        }
    }

    private static class KelvinCalc {

        //Code adapted from http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
        static Color getRGB(float tmpKelvin) {

            double tmpCalc = tmpKelvin; //Temperature must fall between 1000 and 40000 degrees
            double r, g, b = 0f;

            if (tmpKelvin < 1000) {
                tmpKelvin = 1000;
            }
            if (tmpKelvin > 40000) {
                tmpKelvin = 40000;
            } //All calculations require tmpKelvin \ 100, so only do the conversion once
            tmpKelvin /= 100;

            //Calculate each color in turn
            //First: red
            if (tmpKelvin <= 66) {
                r = 255;
            } else {//Note: the R-squared value for this approximation is .988
                tmpCalc = tmpKelvin - 60;
                tmpCalc = 329.698727446d * (Math.pow((double) tmpCalc, -0.1332047592d));
                r = tmpCalc;
                if (r < 0) {
                    r = 0;
                }

                if (r > 255) {
                    r = 255;
                }

            }
            if (tmpKelvin <= 66) {
                tmpCalc = tmpKelvin;
                tmpCalc = 99.4708025861d * Math.log(tmpCalc) - 161.1195681661d;
                g = tmpCalc;

                if (g < 0) {
                    g = 0;
                }

                if (g > 255) {
                    g = 255;
                }

            } else {//Note: the R-squared value for this approximation is .987
                tmpCalc = tmpKelvin - 60;

                tmpCalc = 288.1221695283d * (Math.pow(tmpCalc, -0.0755148492d));
                g = tmpCalc;
                if (g < 0) {
                    g = 0;
                    if (g > 255) {
                        g = 255;
                    }
                }

            }

            //blue
            if (tmpKelvin >= 66) {
                b = 255;
            } else {
                if (tmpKelvin <= 19) {
                    b = 0;
                } else {
                    tmpCalc = tmpKelvin - 10;
                    tmpCalc = 138.5177312231d * Math.log(tmpCalc) - 305.0447927307;

                    b = tmpCalc;
                    if (b < 0) {
                        b = 0;
                    }

                    if (b > 255) {
                        b = 255;
                    }

                }
            }

            return new Color((int) r, (int) g, (int) b, 240);
        }
    }
}

If you have a look through the radioactive code dump, you can probably find a simpler example than the one provided for an onHit. Have a look for some BeamEffectPlugin scripts as well which may do what you want. The example provided is specific for the purposes of over penetration and has a whole lot of math that you probably don't require for your script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on March 01, 2015, 07:24:21 AM
I changed it to use the planet id, but it still says that it can't find the spec of class with the planets id. I have the same id in the system file, and in the generator.

EDIT: nvm, found out what was wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 02, 2015, 04:44:20 AM
Is there a way to designate a commodity type as personnel, so it takes up crew space (and doesn't get lost when you lose ships and have to retreat)?

Would it be possible to merge them before attacking?
Thing is, there may not be anyone available to merge with.

(It's still worthwhile to try and attack, because the invasion fleet may decide to retreat, and because its FP count towards invasion strength)

EDIT: More important question, how do I override a vanilla class? (I tried putting the same class name in the same package earlier for a market condition, but that didn't seem to work.) I need to modify the loot the player gets after a battle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on March 02, 2015, 10:54:38 AM
So, noone has a decent EMP arc emitting weapon? :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on March 02, 2015, 11:50:42 AM
I seem to recall a mod faction having a missile that splits into two projectiles which emit EMP fields in between them. It was really neat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 02, 2015, 02:09:17 PM
I seem to recall a mod faction having a missile that splits into two projectiles which emit EMP fields in between them. It was really neat.

SCY
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on March 03, 2015, 06:03:46 AM
How do I add custom interaction images for space stations/planets?

Also how do I restrict or control the appearance of certain ships/weapons in the market place?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 03, 2015, 12:27:38 PM
EDIT: More important question, how do I override a vanilla class? (I tried putting the same class name in the same package earlier for a market condition, but that didn't seem to work.) I need to modify the loot the player gets after a battle.

You can't override an API class, but you can override the condition itself to the same effect. Just add a row to your mod's market_conditions.csv with the same id as the condition you want to override and point 'script' at your replacement script.

As for modifying loot, you can add a campaign listener with a reportEncounterLootGenerated() implementation, and modify the loot cargo in there.


How do I add custom interaction images for space stations/planets?
There are two ways. First is to implement it as a custom entity - see starsector-core/data/config/custom_entities.json for examples. You also have to edit your system generation script to add the station using addCustomEntity() instead of addOrbitalStation().

The other way is to just call setInteractionImage() in the code where you spawn it. This is far less work, but the custom entity route also allows you to customize other aspects of your stations in a central, easy to edit location.


Quote
Also how do I restrict or control the appearance of certain ships/weapons in the market place?

What ships and weapons appear is (I believe) based on what's used in your market's faction's fleets. The tier column in ship_data.csv and weapon_data.csv controls the minimum reputation necessary with the faction before you can buy them. Anything else would require a custom submarket plugin, which isn't a trivial task.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on March 03, 2015, 12:33:55 PM
EDIT: More important question, how do I override a vanilla class? (I tried putting the same class name in the same package earlier for a market condition, but that didn't seem to work.) I need to modify the loot the player gets after a battle.

You can't override an API class, but you can override the condition itself to the same effect. Just add a row to your mod's market_conditions.csv with the same id as the condition you want to override and point 'script' at your replacement script.

As for modifying loot, you can add a campaign listener with a reportEncounterLootGenerated() implementation, and modify the loot cargo in there.


How do I add custom interaction images for space stations/planets?
There are two ways. First is to implement it as a custom entity - see starsector-core/data/config/custom_entites.json for examples. You also have to edit your system generation script to add the station using addCustomEntity() instead of addOrbitalStation().

The other way is to just call setInteractionImage() in the code where you spawn it. This is far less work, but the custom entity route also allows you to customize other aspects of your stations in a central, easy to edit location.


Quote
Also how do I restrict or control the appearance of certain ships/weapons in the market place?

What ships and weapons appear is (I believe) based on what's used in your market's faction's fleets. The tier column in ship_data.csv and weapon_data.csv controls the minimum reputation necessary with the faction before you can buy them. Anything else would require a custom submarket plugin, which isn't a trivial task.

 SetInteractionImage() I've tried using this but I get errors that it can't find the illustration i'm pointing it at for some reason. This happens for planets, I use custom entities for the stations.

As for the market, I've added some new pirate ships into the pirate fleets and apparently that cause said ships to appear in multiple numbers in the black market section on multiple systems. So i need a way to reduce that occurance some way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 03, 2015, 01:03:10 PM
SetInteractionImage() I've tried using this but I get errors that it can't find the illustration i'm pointing it at for some reason.

You need to register the image in the "graphics" section of data/config/settings.json so Starsector knows to load it when the game starts.


Quote
As for the market, I've added some new pirate ships into the pirate fleets and apparently that cause said ships to appear in multiple numbers in the black market section on multiple systems. So i need a way to reduce that occurance some way.

If they are extremely common in markets they might be too common in your fleets. You can try reducing their spawn probability to see if the problem goes away.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on March 03, 2015, 01:15:02 PM
SetInteractionImage() I've tried using this but I get errors that it can't find the illustration i'm pointing it at for some reason.

You need to register the image in the "graphics" section of data/config/settings.json so Starsector knows to load it when the game starts.


Quote
As for the market, I've added some new pirate ships into the pirate fleets and apparently that cause said ships to appear in multiple numbers in the black market section on multiple systems. So i need a way to reduce that occurance some way.

If they are extremely common in markets they might be too common in your fleets. You can try reducing their spawn probability to see if the problem goes away.

So basically something like this:

Code
"graphics":{
"illustrations":{
"hii_homeworld":"graphics/HD/planets/hii_homeworld.png"
},
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 03, 2015, 01:26:05 PM
Yep, then you should be able to just call setInteractionImage("illustrations", "hii_homeworld"). :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on March 04, 2015, 12:09:19 AM
How to prevent a ship ues system to enemy drone?

Coded a ship system AI and already set

if (target.isDrone()){return;}

but it dosen't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 04, 2015, 03:23:48 AM
Thanks LazyWizard!

As for the market, I've added some new pirate ships into the pirate fleets and apparently that cause said ships to appear in multiple numbers in the black market section on multiple systems. So i need a way to reduce that occurance some way.
Don't know if you already noticed this and tried to fix it that way, but: As Toxicity pointed out (http://fractalsoftworks.com/forum/index.php?topic=6347.msg155188#msg155188), you have the Goliath categorised in the pirate faction file as a medium carrier and a medium combat, which is going to make it pretty common. It logically should be listed only as a large carrier, but that'll probably make it just not appear anywhere short of a really large military market, which may be undesirable. Reducing the chance number might do the trick, though.

(also why is the Black Swan considered a large carrier?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on March 04, 2015, 04:26:40 AM
Thanks LazyWizard!

As for the market, I've added some new pirate ships into the pirate fleets and apparently that cause said ships to appear in multiple numbers in the black market section on multiple systems. So i need a way to reduce that occurance some way.
Don't know if you already noticed this and tried to fix it that way, but: As Toxicity pointed out (http://fractalsoftworks.com/forum/index.php?topic=6347.msg155188#msg155188), you have the Goliath categorised in the pirate faction file as a medium carrier and a medium combat, which is going to make it pretty common. It logically should be listed only as a large carrier, but that'll probably make it just not appear anywhere short of a really large military market, which may be undesirable. Reducing the chance number might do the trick, though.

(also why is the Black Swan considered a large carrier?)

Because it has 2 flight decks and is mostly a capital ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cathair on March 04, 2015, 11:35:41 AM
Is it possible to alter how many equipped weapons are dropped by destroyed player ships? How about the number of crew salvaged from life pods?

This seems pretty basic, so if it's a stupid question that should be self-evident, just point me at where I should be looking and I'll figure it out. I've done a few searches and poked around in the game data, but I can't find anything explicitly referencing what I'm looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on March 04, 2015, 11:40:44 AM
Is it possible to alter how many equipped weapons are dropped by destroyed player ships? How about the number of crew salvaged from life pods?

This seems pretty basic, so if it's a stupid question that should be self-evident, just point me at where I should be looking and I'll figure it out. I've done a few searches and poked around in the game data, but I can't find anything explicitly referencing what I'm looking for.

As far as I know you can only restrict them from not dropping at all by setting them as system weapons, as in built in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on March 04, 2015, 03:31:33 PM
I'm having a difficult time balancing out the market prices. I've managed to get Bushi up and running but that sent the market out of balance again, supplies costing 200-300 creds on average.
Bushi fleets seem to spawn quite small in scale and get stomped by the pirate fleets.

How can I better balance the market conditions?

In the factions file if I add for a example a ship variant in all of the ship roles will that make more of that variant or will it simply be more common in fleet compositions?
How can I beef up the fleets up a bit because as it stands these are quite weak?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cathair on March 05, 2015, 04:16:33 PM
Is it possible to alter how many equipped weapons are dropped by destroyed player ships? How about the number of crew salvaged from life pods?

This seems pretty basic, so if it's a stupid question that should be self-evident, just point me at where I should be looking and I'll figure it out. I've done a few searches and poked around in the game data, but I can't find anything explicitly referencing what I'm looking for.

As far as I know you can only restrict them from not dropping at all by setting them as system weapons, as in built in.

Oh well. Thanks for the info!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: EI on March 05, 2015, 06:33:12 PM
How do you compile Java scripts in a single RAR file like every mod I see?

Current threads that have are somewhat outdated for the current version of the game. @-@


So I can at least use two of my Market Conditions to replace the large compiled ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 05, 2015, 10:21:41 PM
How do you compile Java scripts in a single RAR file like every mod I see?

Current threads that have are somewhat outdated for the current version of the game. @-@


So I can at least use two of my Market Conditions to replace the large compiled ones.

(http://vignette4.wikia.nocookie.net/tumblrroleplay/images/0/05/Magic_meme.gif/revision/latest?cb=20130810063248)

Eh, no actually most of us use NetBeans or some other IDE which allows us to compile our code. The compiled code is published to a JAR file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 05, 2015, 10:27:27 PM
Addendum: Check out lazy's thread on setting up netbeans if you're interested

http://fractalsoftworks.com/forum/index.php?topic=3173.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 05, 2015, 11:25:42 PM
Is it possible to have a decorative weapon (i forgot what is it called in this game's modding) to cover ships engine flames?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on March 05, 2015, 11:35:51 PM
Is it possible to have a decorative weapon (i forgot what is it called in this game's modding) to cover ships engine flames?

Yes :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nomadic_leader on March 06, 2015, 06:08:54 AM
Hello, I'm not familiar with java or anything but even the basic concepts of computer science, so this will be uphill battle:

Loading values for system.addPlanet() from Tab seperated value files (TSV)

Let's say I'm making a bunch of planets using system.addPlanet()

But then what if I playtest it and they feel too far apart, or too close together or something, and I want to change all of them, say multiply all the orbit radii by 0.8 or something. Going through every file and every system.addPlanet() and doing this would be really tiresome.

It seems like it would be much easier to load all the fields of a TSV into an array and then refer to those in the system.addPlanet(). Then I could quickly alter all the TSV values in excel and so forth all at once were it necessary. Unless loading an array of tsv values is going to do something bad to memory or performance, I really know nothing of such matters.

Does the java starsector uses have a tsv parsing function or library or whatnot? If someone has a link to where i can read about it I'm willing to go try and read it myself, rather than forcing you to spoonfeed me here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 06, 2015, 08:00:00 AM
Is it possible to have a decorative weapon (i forgot what is it called in this game's modding) to cover ships engine flames?

Yes :)

Okay, what are the steps to do it? Or is the sprite drawn after the flames?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pushover on March 06, 2015, 08:20:22 AM
Hello, I'm not familiar with java or anything but even the basic concepts of computer science, so this will be uphill battle:

Loading values for system.addPlanet() from Tab seperated value files (TSV)

Let's say I'm making a bunch of planets using system.addPlanet()

But then what if I playtest it and they feel too far apart, or too close together or something, and I want to change all of them, say multiply all the orbit radii by 0.8 or something. Going through every file and every system.addPlanet() and doing this would be really tiresome.

It seems like it would be much easier to load all the fields of a TSV into an array and then refer to those in the system.addPlanet(). Then I could quickly alter all the TSV values in excel and so forth all at once were it necessary. Unless loading an array of tsv values is going to do something bad to memory or performance, I really know nothing of such matters.

Does the java starsector uses have a tsv parsing function or library or whatnot? If someone has a link to where i can read about it I'm willing to go try and read it myself, rather than forcing you to spoonfeed me here.
You could probably just use Scanner (http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html), something like
Code
float[] x = new float[10]; //10 systems, pick the correct number. You could also use an arrayList if you don't want to have to figure out how many systems
float[] y = new float[10];
String[] names = new String[10];
int i = 0;
try {
   File file = new File("file.tsv");
   Scanner s = new Scanner(file);
   while (s.hasNext()){
      //read all the values with s.nextInt(), s.next(), s.nextFloat() or one of those methods. For example:
      names[i] = s.next(); //pulls a string from the file
      x[i] = s.nextFloat(); //pulls a float, this line could technically cause an error if the file was not formatted properly
      y[i] = s.nextFloat();
      i++;
   }
}catch(IOException e){
   //log the error here, either file not found or trying to read past the end of the file are the most likely errors
}

No idea if this code actually compiles, but should be a rough example of what you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 06, 2015, 10:04:49 AM
How do you make a script run whenever a ship is destroyed? I'm trying to make a mod that adds sparks when ships blow up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 06, 2015, 11:55:26 AM
How do you make a script run whenever a ship is destroyed? I'm trying to make a mod that adds sparks when ships blow up.

An everyframe combat plugin that checks the state of ships each frame, if it's dead, then do desired effects.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 06, 2015, 12:05:01 PM
Hello, I'm not familiar with java or anything but even the basic concepts of computer science, so this will be uphill battle:

Loading values for system.addPlanet() from Tab seperated value files (TSV)

Let's say I'm making a bunch of planets using system.addPlanet()

But then what if I playtest it and they feel too far apart, or too close together or something, and I want to change all of them, say multiply all the orbit radii by 0.8 or something. Going through every file and every system.addPlanet() and doing this would be really tiresome.

It seems like it would be much easier to load all the fields of a TSV into an array and then refer to those in the system.addPlanet(). Then I could quickly alter all the TSV values in excel and so forth all at once were it necessary. Unless loading an array of tsv values is going to do something bad to memory or performance, I really know nothing of such matters.

Does the java starsector uses have a tsv parsing function or library or whatnot? If someone has a link to where i can read about it I'm willing to go try and read it myself, rather than forcing you to spoonfeed me here.
You could probably just use Scanner (http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html), something like
Code
float[] x = new float[10]; //10 systems, pick the correct number. You could also use an arrayList if you don't want to have to figure out how many systems
float[] y = new float[10];
String[] names = new String[10];
int i = 0;
try {
   File file = new File("file.tsv");
   Scanner s = new Scanner(file);
   while (s.hasNext()){
      //read all the values with s.nextInt(), s.next(), s.nextFloat() or one of those methods. For example:
      names[i] = s.next(); //pulls a string from the file
      x[i] = s.nextFloat(); //pulls a float, this line could technically cause an error if the file was not formatted properly
      y[i] = s.nextFloat();
      i++;
   }
}catch(IOException e){
   //log the error here, either file not found or trying to read past the end of the file are the most likely errors
}

No idea if this code actually compiles, but should be a rough example of what you want.

Won't work with that file load, but you may kinda be on the rightish sort of track if you're using a CSV file with the SettingsAPI.loadCSV which will give you a Json array.

Alternatively you could have a static map inside the Java class that generates your system, and use an IDE code hot update function to update the values before re-instancing a new game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 06, 2015, 12:19:02 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on March 06, 2015, 02:15:53 PM
Is it possible to have a decorative weapon (i forgot what is it called in this game's modding) to cover ships engine flames?

Yes :)

Okay, what are the steps to do it? Or is the sprite drawn after the flames?

Nothing special about it, engine effects are always rendered under weapons so just rig it up and it is good to go.
Deco weapons are all sorts of fun!

(http://i.imgur.com/eH0zjvk.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nomadic_leader on March 07, 2015, 09:32:05 AM
Thanks for the advice about tsv/csv.

Another question, which I couldn't find in the forums:

Why does pressing the forward engine key in devmode (OSX) always cause you to go to "full burn" mode? Is there a way to disable this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on March 08, 2015, 06:26:03 AM
To ensure compatibility with Mac and Linux, my mod file names and pathing all needs to be lowercase, right?

If that's the case, I've got some tedious work to do, but I wanted to check first. Also, is there anything else along those lines I should look into to clean up my mod/ensure compatibility?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 08, 2015, 06:50:08 AM
It only need to match. Windows don't care about case, so it's easy to make mistakes in the names or path, and Linux will throw an error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on March 08, 2015, 07:01:25 AM
Ah, okay. Just matching is easier because I'm fairly certain all of my cases match anyway. I'm actually glad to hear that because having some capitalization instead of all lower case is just easier for me to read.

Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 08, 2015, 04:55:09 PM
I now know how to tell when a ship is destroyed. However, I don't know how to add sparks. I had planned to spawn several projectiles when a ship was destroyed, but after looking through the Starsector documentation I only found one function to do this--spawnProjectile() in CombatEngineAPI(). This function requires a weapon object that the projectile was launched from, but I don't have a weapon to shoot them from. This makes me think that it isn't a good idea to use projectiles, but I can't think of any other way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 08, 2015, 05:06:08 PM
Why does pressing the forward engine key in devmode (OSX) always cause you to go to "full burn" mode? Is there a way to disable this?

Do you happen to have your "forward engine" key bound to P? That's hardcoded to full burn in devmode.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on March 08, 2015, 08:08:57 PM
For some reason when the SectorGen file loads for a TC it calls on the default vanilla SectorGen instead. This results in a crash when a new game loads. Any reason this could be happening?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 08, 2015, 08:48:58 PM
Does your TC's settings.json have this?
"plugins":{
   "newGameCreationEntryPoint":"data.scripts.world.SectorGen",
},

Pointing to your SectorGen, that is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nomadic_leader on March 09, 2015, 10:36:45 AM
Why does pressing the forward engine key in devmode (OSX) always cause you to go to "full burn" mode? Is there a way to disable this?

Do you happen to have your "forward engine" key bound to P? That's hardcoded to full burn in devmode.

Ah. It's a hard life for left handed people.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 09, 2015, 09:25:26 PM
Soooo...

Let's say that I'm writing a custom FleetInteractionDialogPlugin, and it's based on code that worked back before Markets became a thing.

It's working fine... well, except that Bounties and the Patrol stuff isn't working.  I think that these are two different issues, but at this point I'm extremely confused: it's completely unclear how FleetInteractionDialogPlugin talks to EventManager and says, "yeah, that Bounty fleet?  Player just nailed it.".  The player can defeat the fleets, and other old code that still works adjusts the relationships with the factions... but he / she doesn't get paid for it by the Markets :P

So:

1.  How (i.e., by what code) is it determined that the fleet that the Player has defeated is effected by a Bounty, whether System or Person?  It's totally unclear to me atm, unfortunately.  I thought it was somewhere in FleetEncounterContext, because there is a lot of stuff there that suggests that the game's been informed that the Player has engaged and defeated another fleet... but no.
2.  How, once the fleet is a Bounty fleet, is the Bounty end-event triggered?  I can't seem to find that one either.
3.  If it's a Patrol, how is that determined?

I get that all of this probably tied into the Rules and Market code in some fashion, but I'm completely confused at this point, tbh; it's very hard to see how the parts are meshing from here, let alone get the Dialog to play nice with Vanilla again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2015, 09:34:19 PM
1. Yeah, it's from FleetEncounterContext, specifically this line:
Global.getSector().reportBattleOccurred(winner, loser);

SystemBountyEvent has a callback that's called by reportBattleOccurred, since it's registered as a CampaignListener (all events are, if they derive from BaseEventPlugin)

2. Take a look at SystemBountyEvent, specifically where it calls its own endEvent() method. Specifically, it gets ended either in:
void reportBattleOccurred(CampaignFleetAPI winner, CampaignFleetAPI loser) or in
void reportFleetDespawned(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param)

3. Do you mean, how does the game know to spawn another patrol? IIRC the PatrolFleetManager takes care of it in similar callbacks to #2. I think it's also got some failsafe where it iterates through existing patrols to make sure they didn't magically disappear without a reportXXX method being called. It's not strictly necessary but I'm paranoid.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 09, 2015, 09:44:02 PM
Huh.  I put Global.getSector().reportBattleOccurred(winner, loser); in at one point, but nothing happened.  Will take another look at this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 09, 2015, 10:02:36 PM
Tested, still not having any luck:

In my FleetInteractionDialog, when we're back from combat, BattleEffects() gets called, like so:

Code: java
    @Override
    public void backFromEngagement(EngagementResultAPI result) {
        if(didFightBattle)
        {
            BattleEffects bEffect = new BattleEffects();
            bEffect.getResult(result,playerFleet,otherFleet,marines, marinesStart);
        }
    }

In BattleEffects():
Code: java
    public void getResult(EngagementResultAPI result, CampaignFleetAPI playerFleet, CampaignFleetAPI otherFleet, int marines, int marinesStart){       
        Global.getSector().reportBattleOccurred(playerFleet, otherFleet);
        }

I see the Bounty end, on the next Market updates... but the player never gets the credit, or the Credits.  There is clearly something else I need to do to trigger this properly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2015, 10:09:32 PM
Ahh - yes, there's one more bit. The bounty is based on which ships got destroyed, but that information isn't tracked automatically in the fleet.

If you look at FIDPI.init(), you'll see:
playerFleet.getFleetData().takeSnapshot();
otherFleet.getFleetData().takeSnapshot();

Which saves the current list of fleet members into a snapshot (a list, really) which can then be compared against after the battle to find out what was lost, which is what the SystemBountyEvent does.

(Ideally, perhaps reportBattleOccurred() would take more parameters that include an accounting of the losses, but there was some reason I didn't do it that way. Might have been simple convenience, really don't recall.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 09, 2015, 10:13:20 PM
Ahhh.  I was wondering what the heck that was for. 

Sooo... Patrol.  The issue is that I am fine writing up a Dialog extorting the player's hard-earned credits collecting the tolls, but...

1.  How do I distinguish that this Fleet I'm talking to is a Customs Patrol?
2.  How do I message the Event system after I pay up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 09, 2015, 10:20:18 PM
And rats.  That still doesn't do it, for getting the Bounty.  Do I need to take another snapshot after the fight?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2015, 10:21:35 PM
1. It has a MemFlags.MEMORY_KEY_PATROL_FLEET and MemFlags.MEMORY_KEY_CUSTOMS_INSPECTOR both set to true in its memory.

2. Check out CustomsInspectionEvent - it communicates by checking flags in various memory objects.

(Incidentally, I'm adding a bit of code now that allows for direct callbacks to events from rules, as that's convenient/required sometimes.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2015, 10:22:50 PM
And rats.  That still doesn't do it, for getting the Bounty.  Do I need to take another snapshot after the fight?

No, if you take another snapshot, you'll obliterate the first one.

I'd suggest breakpointing either:
Global.getSector().reportBattleOccurred(playerFleet, otherFleet); 
Or:
SystemBountyEvent.reportBattleOccurred()

And stepping through it to see what's going wrong for you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 10, 2015, 12:46:50 PM
Hrmm.  I put a breakpoint on that code where it's called, with it set to halt all threads, and the application doesn't halt there. 

I've tried selecting the application via PID and by name; nothing happens and I don't hit a breakpoint.  I know that subsequent code is running, because if anything halted that thread it would screw up other things in the Dialog at the very least.

Am I doing it wrong?  I haven't ever made much use of breakpoints, so probably yes.  Is there any other way to reach in and test for what's happening under the hood, event-wise, that's causing the Player's involvement in the battle to get lost (since that appears to be the issue here)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 10, 2015, 12:50:21 PM
Oh, and while I'm at it- could this be happening because currently:

Code: java
    @Override
    public Map<String, MemoryAPI> getMemoryMap() {
        return null;
    }
I'm not really sure what this is for atm, so I have it return null until I know what it's doing and whether I want to do that?


[EDIT]So that's for firing up the rules-based conversation system.  I was kind of hoping that I could avoid that; the old rules I had worked just fine.  But I'm not seeing the effects otherwise.  Maybe I need to read the rules and see if it's calling anything else?  I can't see anything else happening here that would cause it to basically "see" that the Player has killed a Person Bounty fleet or a fleet affected by a System Bounty but not credit the player with the kill. 

It's too bad that there doesn't appear to be a way to pull a list of the current Events and find a match.[/EDIT]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2015, 01:33:46 PM
Hrmm.  I put a breakpoint on that code where it's called, with it set to halt all threads, and the application doesn't halt there. 

I've tried selecting the application via PID and by name; nothing happens and I don't hit a breakpoint.  I know that subsequent code is running, because if anything halted that thread it would screw up other things in the Dialog at the very least.

Am I doing it wrong?  I haven't ever made much use of breakpoints, so probably yes.  Is there any other way to reach in and test for what's happening under the hood, event-wise, that's causing the Player's involvement in the battle to get lost (since that appears to be the issue here)?

Not entirely sure, as I pretty much always set breakpoints and run the game through an IDE. You can attach to a running process, though, but IIRC you have to add some parameters when you start the process being debugged (something like: "-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n passed" in to java).


I was kind of hoping that I could avoid that; the old rules I had worked just fine.

The new stuff is entirely optional; if you have something that's already working, it should continue working. Well, it might break, but not for "not using rules" reasons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 10, 2015, 03:23:44 PM
Oh, right; I didn't put in any debug parameters when starting the JVM.  I'll try that and see if I can get any farther in terms of understanding why it's not doing what I'm expecting.  Sorry this is so involved; I figured I was just missing something really straightforward here (and frankly, I probably am, I just don't know what it is yet).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 10, 2015, 09:02:39 PM
OK, I got the breakpoint to work... but I don't see anything obvious over here.  It just calls to internal Stuff; I'm not really getting anything out of it.  It's not like it's crashing or anything, it just fails to do anything.  I can see how PersonBountyEvent should get invoked by this:

Code
Global.getSector().reportBattleOccurred(winnerFleet,loserFleet);

...but something is obviously not right there.  Given that winnerFleet and loserFleet must be valid CampaignFleetAPI objects, and the Player Fleet is clearly defined, and the winnerFleet should be the correct winner based on the result... I'm really confused now.  Perhaps I should throw an exception if neither fleet is actually the player fleet or if the player counts as the "loser" even though I won the battle, since that's about the only way I can see this happening?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2015, 09:11:45 PM
I'd put the breakpoint in PersonBountyEvent.reportBattleOccurred - that way you can make sure it's being called, and if it is (which it kind of has to be, unless the event is no longer active - SectorAPI.reportBattleOccurred literally just iterates over all campaign listeners and calls that method on them) then you could see where it's bailing out/why it's not deciding to apply the bounty.

Note that for a person bounty, you have to disable/destroy the flagship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 10, 2015, 09:16:38 PM
Ah, OK, so just throw that into campaign/events/ then breakpoint it?

KK, I'll give that a go when I can spare some more time this weekend and try and puzzle this out :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2015, 09:21:09 PM
Ah, OK, so just throw that into campaign/events/ then breakpoint it?

That *might* work, but the proper way to do it would be to point your IDE to the source for starfarer.api, and then you can open the api source from the IDE, put breakpoints in it, and it'll work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 12, 2015, 07:49:23 AM
Is there a way for me to make a weapon that has an effect other than shooting? For example, would it be possible to make an armor "weapon" that increases the ship's armor?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on March 12, 2015, 08:51:06 AM
Yes. For beam weapons you can use custom BeamEffectPlugin for a weapon. In advance method you then can use beam.getDamageTarget(), cast it to ShipAPI (this will be the target ship) and use setHitpoints to increase hull level (or whatever other way you would prefer). Vanilla tachyon lance has the example of attaching BeamEffectPlugin , AFAIK.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 12, 2015, 10:24:56 AM
Thanks. I'll see if I can figure it out.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 12, 2015, 11:57:17 AM
Yes. For beam weapons you can use custom BeamEffectPlugin for a weapon. In advance method you then can use beam.getDamageTarget(), cast it to ShipAPI (this will be the target ship) and use setHitpoints to increase hull level (or whatever other way you would prefer). Vanilla tachyon lance has the example of attaching BeamEffectPlugin , AFAIK.

That'd apply to the target ship, btw - I suspect Xanderzoo meant for the mounting ship. In which case it'd be something like weapon.getShip(), iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 12, 2015, 04:19:03 PM
OK, I've breakpointed in the IDE; when I hit PersonBountyEvent.reportBattleOccurred(winner, loser) the winner is being reported, correctly, as the Player's fleet, so far as I can determine, same with the loser's fleet.

So, huh.  The only way that it appears that this should fail is if this isn't considered to be the Player Fleet?

I'll put in more breakpoints and see what I'm getting at each stage.  Getting closer to some sort of resolution, but I'm still pretty confused about where it's losing the plot :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 13, 2015, 06:06:09 AM
How does an EveryFrame plugin work? And how do you implement it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 14, 2015, 12:52:51 AM
How does an EveryFrame plugin work? And how do you implement it?

The answer to that is a bit complicated. :)

If you're referring to combat plugins (EveryFrameCombatPlugin):
Spoiler
Combat plugins just run every frame of every combat by default. There's nothing really special about them. Just make a script extending BaseEveryFrameCombatPlugin and override its advance() and init() methods (the other methods in this class aren't necessary 99.9% of the time). init() is called once before the battle begins, and advance() is called every frame. I'd recommend looking at examples from other mods if you're lost.

How you actually get the combat plugin working in-game depends on whether your mod uses loose scripts or a compiled jar. If it's loose scripts, just put your script's .java file in data/scripts/plugins and Starsector will automatically add it to every combat instance. It's that simple.

If it's jarred the script can be in any package, but you'll need to register it in the "plugins" section of data/config/settings.json for Starsector to know it exists. Example:
Quote
   "plugins":
    {
        "CombatRadarPlugin":"org.lazywizard.radar.CombatRadarPlugin"
    },

[close]

If you're referring to campaign plugins (EveryFrameScript):
Spoiler
Campaign plugins are significantly more complicated, but we can break them down to global scripts vs local scripts, and transient vs regular scripts. I should point out that all of these are EveryFrameScripts, the only difference is where and how they are registered.

Global scripts are added to the sector itself (SectorAPI.addScript()), and run every frame regardless of where the player is. Local scripts are added to a system/hyperspace (LocationAPI.addScript()), and run every frame when the player is in that location, or once every several frames if the player is outside of it. Local scripts are useful for fleet spawners or any other type of script where only running a few times a second won't matter when the player isn't around. Global scripts are used for overarching campaign logic like AI or event systems. Both global and local scripts will only run until their isDone() method returns true, after which they are removed from the game.

As for transient vs regular scripts, the only differences are that transient scripts must be registered globally and aren't retained in the savefile. This means they can't store any data and must be re-added every time the player loads a save. Transient scripts are used almost exclusively by utility mods, so I'd say forget they exist and just use regular scripts.

For regular scripts, the best place to add them is in your mod plugin, either in the onNewGame() method or onEnabled() (if wasEnabledBefore is false). I'd recommend using onEnabled() as that allows your mod to be added to an existing save. Example:
Code: java
    @Override
    public void onEnabled(boolean wasEnabledBefore)
    {
        if (!wasEnabledBefore)
        {
            Global.getSector().addScript(new ITBMaster());
        }
    }

For transient scripts, as stated before they aren't saved and must be re-added every time the game is reloaded. Therefore you'd be using ModPlugin's onGameLoad() method. Example:
Code: java
    @Override
    public void onGameLoad()
    {
        Global.getSector().addTransientScript(new CampaignRadarPlugin());
    }
[close]


If you find any of that confusing let me know and I'll attempt to clarify it. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 14, 2015, 02:51:02 AM
Thank you very much! I am trying to make a hidden weapon slot that is actually a regular slot, thus it could be disabled (Tartiflette told me this is possible).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 14, 2015, 11:31:13 PM
Is there a way to texture shields? Specifically, I want to give shields a hexagonal texture.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 12:19:47 AM
Yes there is, check out the Shield API, it covers changing the texture and inner/outer colour.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 08:18:35 AM
Okay, I found a function called setRadius in ShieldAPI that looks like it will work. Where should I call this function?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 09:21:13 PM
Either a EveryFrameCombatPlugin or a EveryFrameWeaponEffectPlugin on a hidden/invisible/deco weapon will do the trick, both will suit your purpose. I'd probably prefer the EveryFrameWeaponEffectPlugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 09:36:34 PM
I decided to try an EveryFrameCombatPlugin first. Unfortunately, I'm running into this error. I don't know much about java, so I don't know how to fix it.

Spoiler
Error:
Fatal: Error compiling[data.scripts.plugins.ShieldEffect]
Cause: File 'data/scripts/plugins/ShieldEffect.java' Line 25, Column 10:
Assignment conversion not possible from type "java.lang.Object" to type
"com.fs.starfarer.api.combat.ShipAPI"
Check starsector.log for more info.
[close]

End of starsector.log:
Spoiler
java.lang.RuntimeException: Error compiling [data.scripts.plugins.ShieldEffect]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/plugins/ShieldEffect.java', Line 25, Column 10: Assignment conversion not possible from type "java.lang.Object" to type "com.fs.starfarer.api.combat.ShipAPI"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/plugins/ShieldEffect.java', Line 25, Column 10: Assignment conversion not possible from type "java.lang.Object" to type "com.fs.starfarer.api.combat.ShipAPI"
   at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
   at org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:9071)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2669)
   at org.codehaus.janino.UnitCompiler.access$4500(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$7.visitAssignment(UnitCompiler.java:2619)
   at org.codehaus.janino.Java$Assignment.accept(Java.java:3405)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2654)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1643)
   at org.codehaus.janino.UnitCompiler.access$1100(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java:936)
   at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:2097)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:993)
   at org.codehaus.janino.UnitCompiler.access$1000(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitBlock(UnitCompiler.java:935)
   at org.codehaus.janino.Java$Block.accept(Java.java:2012)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1088)
   at org.codehaus.janino.UnitCompiler.access$1300(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitForStatement(UnitCompiler.java:938)
   at org.codehaus.janino.Java$ForStatement.accept(Java.java:2196)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
   at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
   at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
   at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
   ... 5 more
[close]

My code:

Spoiler
Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import java.util.List;

public class ShieldEffect extends BaseEveryFrameCombatPlugin {

private CombatEngineAPI engine;

private List<ShipAPI> ships;

    @Override
    public void advance(float amount) {
List<ShipAPI> ships = engine.getShips();
int numShips = ships.size();
ShipAPI ship = null;
int radius = 0;
ShieldAPI shield = null;
for (int i = 0; i < numShips; i++)
{
ship = ships.get(i);


shield = ship.getShield();

radius = shield.getRadius();
shield.setRadius(radius, "shieldTexture", "shieldTexture");


}
    }

    @Override
    public void init(CombatEngineAPI engine) {
this.engine = engine;

    }

}
[close]

Thanks for all your help so far.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lunisolar on March 15, 2015, 09:52:56 PM
Hi. How can I get the source weapon of a MIRV warhead? I need to find out the range of the weapon that fired the MIRV missile. But projectile.getWeapon() seems return null in my case.

public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
   WeaponAPI sourceWeapon = projectile.getWeapon();
...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 09:54:56 PM
Spoiler
Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import java.util.List;

public class ShieldEffect extends BaseEveryFrameCombatPlugin {

    public void advance(float amount) {
        List<ShipAPI> ships = Global.getCombatEngine().getShips();
        for (ShipAPI ship : ships) {
            ShieldAPI shield = ship.getShield();

            float radius = shield.getRadius();
            shield.setRadius(radius, "shieldTexture", "shieldTexture");

        }

    }

}

[close]

That looks a bit more correct to me...sort of, I'd probably do it a bit differently overall. I'd suggest using an IDE to compile your code, I'm not sure what the status of generics is with the latest Janino 2.7.8 in the latest SS. I stopped using loose scripts and using the default janino compiler as it is a complete pain in the ass.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 09:58:27 PM
Hi. How can I get the source weapon of a MIRV warhead? I need to find out the range of the weapon that fired the MIRV missile. But projectile.getWeapon() seems return null in my case.

public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
   WeaponAPI sourceWeapon = projectile.getWeapon();
...

Good question, MIRVs have behaved like that since I can remember.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 10:06:55 PM
The errors are gone, but the shields don't have a texture. I want to tell if the script is not running, or if there is a different problem. Is there a way to output text to the console? System.out.println didn't work for me.  :(

Edit: Never mind, made a stupid mistake. System.out.println is working, and it looks like my script isn't running. I'll try to figure out why.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 10:12:04 PM
In order to get an EveryFrameCombatPlugin to run, do I need to do anything other than add it to my settings.json file under "plugins"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 10:22:01 PM
pretty sure you can put it in the magical

[mod]\data\scripts\plugins

folder and it should work like a charm

oh wait, i see what you did there...

Spoiler
Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.input.InputEventAPI;
import java.util.List;

public class ShieldEffect extends BaseEveryFrameCombatPlugin {

    @Override
    public void advance(float amount, List<InputEventAPI> events) {
        List<ShipAPI> ships = Global.getCombatEngine().getShips();
        int numShips = ships.size();
        ShipAPI ship = null;
        float radius = 0;
        ShieldAPI shield = null;
        for (int i = 0; i < numShips; i++) {
            ship = ships.get(i);

            shield = ship.getShield();

            radius = shield.getRadius();
            shield.setRadius(radius, "shieldTexture", "shieldTexture");

        }
    }

}

[close]

You had the wrong signature for the advance method. Use an IDE, it will pick up on things like that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 10:27:36 PM
What's a signature?  :-[

Edit:

And yeah, sometime I'll need to set up an IDE. The reason I haven't already is I've already tried installing Netbeans. It tried to sneak some junkware past me, and when I disabled the junkware the installer decided to crash. Now I have little fragments of Netbeans on my computer that I'll have to clean out before I can install it for real.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 10:31:19 PM
you had

 public void advance(float amount)

you needed

 public void advance(float amount, List<InputEventAPI> events)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 10:35:31 PM
Unfortunately, I now get a "Fatal: null" error when I click on the missions button.

The end of the starsector.log file:

Spoiler
10875 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at data.scripts.plugins.ShieldEffect.advance(ShieldEffect.java:17)
   at com.fs.starfarer.title.ooOO.K$Oo.o00000(Unknown Source)
   at com.fs.starfarer.combat.super.new.super(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 10:49:34 PM
ok, first, a bit of a correction, I paste the old code and added the correct signature, this what I meant to paste:

Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.input.InputEventAPI;
import java.util.List;

public class ShieldEffect extends BaseEveryFrameCombatPlugin {

   @Override
   public void advance(float amount, List<InputEventAPI> events) {
        List<ShipAPI> ships = Global.getCombatEngine().getShips();
        for (ShipAPI ship : ships) {
            ShieldAPI shield = ship.getShield();

            float radius = shield.getRadius();
            shield.setRadius(radius, "shieldTexture", "shieldTexture");

        }

    }

}

However in regards to your other problem with the clicking of the missions button, my best guess would be it is loading/previewing the ship in the mission menu - this is an *actual* ship IIRC and causes various other things to load, but it isn't a *complete* ship when inside the menu. For this reason you need to add some conditional logic so it doesn't run inside the menus. You could do a null check for the shield as an example.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 10:53:06 PM
All right, now it doesn't give the null error until I try to raise shields in battle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 10:55:34 PM
End of .log file:
java.lang.NullPointerException
   at com.fs.starfarer.combat.systems.H.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.BaseEntity.render(Unknown Source)
   at com.fs.graphics.LayeredRenderer.Õ00000(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.render(Unknown Source)
   at com.fs.starfarer.combat.G.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 15, 2015, 11:01:16 PM
Yeah, fair enough. Look I would never use a EveryFrameCombatPlugin for this type of script, you're going to need to track the individual ships for your faction for which you have changed the shield. It is better to use an EveryFrameWeaponEffectPlugin so you have a per-ship script instance you can work with. You don't need to do list retrieval with a EveryFrameWeaponEffectPlugin as you're always in the context of the ship.

I haven't implemented a shield changing code before, not sure what bugs there are and I'd have to spend a whole bunch of time debugging and investigating the various states of values to determine what is and is not working.

Again I'd suggest getting an IDE so you can debug and get a deeper understanding of what is going on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 11:45:40 PM
Okay, thanks for your help.  :) The reason I don't want to use an EveryFrameWeaponEffectPlugin is that I don't want the textured shields for my specific faction--I want them for all ships. I'll do some experimentation to see if I can get it to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 15, 2015, 11:52:40 PM
I'm actually starting to suspect that there's a problem with the setRadius function, as it works perfectly (Except for texturing the shields, of course) if I leave out the textures.

Edit:

If anyone has successfully given shields a texture, I would love to hear how you did it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 16, 2015, 12:48:45 AM
Okay, thanks for your help.  :) The reason I don't want to use an EveryFrameWeaponEffectPlugin is that I don't want the textured shields for my specific faction--I want them for all ships. I'll do some experimentation to see if I can get it to work.

For all ships?

Well that makes it a LOT easier, and requires 0 coding IIRC.

You only need to have your own copy of the following files in the following folder in your mod:
[mod]\graphics\fx\
shields64
shields64ring
shields128
shields128ringc
shields256
shields256ring
shields256ringb
shields256ringc
shields256ringd

You can then change the colour of shields via the hull_styles if the colour is static. For dynamic shield colouring that is another thing...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 16, 2015, 07:58:24 AM
Oh. Wow. I wish I'd mentioned that before, it's a lot simpler. Thanks!  :)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 16, 2015, 08:10:56 AM
Well, I did what you suggested and the shields still aren't textured. I'll do some experimentation to see if I can get it to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on March 18, 2015, 03:52:18 AM
Is there somewhere a setting for default sight radius? I mean, the radius affected by MutableShipStatsAPI.getSightRadiusMod().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2015, 11:59:32 AM
Is there somewhere a setting for default sight radius? I mean, the radius affected by MutableShipStatsAPI.getSightRadiusMod().

No - it's hardcoded to 3000.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Serenitis on March 18, 2015, 12:25:25 PM
Hopefully a simple one.

For a given ship, where is the data for the turn rate and engine output stored?
I've been looking in the \hulls\*.ship files but I can't see anything that's marked for either, its all just postioning data for the various components and overlays so it probably isn't even in there.
But I can't see anywhere else where this data could be.

Anyone care to point me in the right direction here....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 18, 2015, 12:27:26 PM
It's in starsector-core/data/hulls/ship_data.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on March 19, 2015, 09:27:31 AM
Is there somewhere a setting for default sight radius? I mean, the radius affected by MutableShipStatsAPI.getSightRadiusMod().

No - it's hardcoded to 3000.
Oh, I see... Can I suggest moving this value to settings.json?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Serenitis on March 19, 2015, 11:44:43 AM
It's in starsector-core/data/hulls/ship_data.csv.
Thank you  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 19, 2015, 11:48:39 AM
No problem... I remember having to figure that out myself.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 19, 2015, 02:53:34 PM
Is there a way for the enemy to lose a mission when a certain ship of there's dies? I tried api.defeatOnShipLoss(), but it didn't seem to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: orost on March 19, 2015, 03:09:01 PM
I create a FleetMember, put in the player's fleet, add crew (before that there is none) and then try to bring it to max CR by calling RepairTrackerAPI.setCR(RepairTrackerAPI.getMaxCR())... but it sets to 10%, while the real max CR is 70-something. I assume that something doesn't get updated and it still thinks it has 0 crew - how do I get around that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on March 21, 2015, 12:21:01 PM
I create a FleetMember, put in the player's fleet, add crew (before that there is none) and then try to bring it to max CR by calling RepairTrackerAPI.setCR(RepairTrackerAPI.getMaxCR())... but it sets to 10%, while the real max CR is 70-something. I assume that something doesn't get updated and it still thinks it has 0 crew - how do I get around that?
why not just set it to '100'%?

Could anyone help me with a problem of my own? When trying to edit ship_data.csv and make certain ships faster or slower or cheaper, it saves but doesn't update in-game. How do I make it update?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: orost on March 21, 2015, 12:56:53 PM
...because I need to set it to current max CR, and not 100%?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 21, 2015, 06:52:49 PM
Could anyone help me with a problem of my own? When trying to edit ship_data.csv and make certain ships faster or slower or cheaper, it saves but doesn't update in-game. How do I make it update?

If you enable dev mode (in data/config/settings.json, or by using the console mod) you can press F8 in combat to reload all scripts and CSVs.


I create a FleetMember, put in the player's fleet, add crew (before that there is none) and then try to bring it to max CR by calling RepairTrackerAPI.setCR(RepairTrackerAPI.getMaxCR())... but it sets to 10%, while the real max CR is 70-something. I assume that something doesn't get updated and it still thinks it has 0 crew - how do I get around that?

I remember having problems with this in the past. I don't remember exactly what fixed it, but here's the code I use:
Code: java
    private static FleetMemberAPI addShipToFleet(String id, FleetMemberType type,
            CrewXPLevel level, CampaignFleetAPI fleet)
    {
        FleetMemberAPI ship = Global.getFactory().createFleetMember(type, id);
        fleet.getFleetData().addFleetMember(ship);

        fleet.getCargo().addCrew(level, (int) ship.getNeededCrew());
        ship.getStatus().repairFully();
        ship.getRepairTracker().setCR(ship.getRepairTracker().getMaxCR());
        ship.setStatUpdateNeeded(true);

        return ship;
    }

    // Elsewhere, after fleet is set up
    fleet.getCargo().addSupplies(fleet.getCargo().getSpaceLeft());
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2015, 11:18:59 PM
(Side note: CampaignFleetAPI.setAIMode(true) will turn off crew requirements, supply use, etc. You can still set crew level, though.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on March 22, 2015, 06:06:10 AM
Is it possible to add unremovable hull mods to a ship via script, or would that have to be done via making a new variant and setting them as built-in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 22, 2015, 10:37:29 AM
Anyone know where I can find the most likely cause of the following error? I'm trying to make my mod work with the new market system and I'm rebuilding it based on mendocas Junkpirate mod, I assume I messed up with the labeling somewhere but I'm not too sure of where to look.

Code
15590 [Thread-11] INFO  sound.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - Playing music with id [music-miscallenous_main_menu.ogg]
15674 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/backgrounds/background4.jpg] as texture with id [graphics/backgrounds/background4.jpg]
25560 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.terrain.Planet.setSpec(Unknown Source)
at com.fs.starfarer.campaign.CampaignPlanet.applySpecChanges(Unknown Source)
at data.scripts.world.systems.tolp.generate(tolp.java:100)
at data.scripts.world.pnGen.generate(pnGen.java:30)
at data.scripts.pnModPlugin.initpn(pnModPlugin.java:19)
at data.scripts.pnModPlugin.onNewGame(pnModPlugin.java:28)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.thisnew.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.new.Òôo000(Unknown Source)
at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
25591 [Thread-11] INFO  sound.O  - Creating streaming player for music with id [music-miscallenous_main_menu.ogg]
25591 [Thread-11] INFO  sound.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - Playing music with id [music-miscallenous_main_menu.ogg]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 22, 2015, 02:35:26 PM
Is it possible to add unremovable hull mods to a ship via script, or would that have to be done via making a new variant and setting them as built-in?

IICR you'd have to create a new hull (not a variant) to get built-in hullmods. It's not dynamic, though it probably could/should be.


@Zudgemund: Most likely, you're calling applySpecChanges() on a planet without having called getSpec().setXXXXX to actually init and make any changes to the planet spec.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 22, 2015, 03:05:40 PM
@Zudgemund: Most likely, you're calling applySpecChanges() on a planet without having called getSpec().setXXXXX to actually init and make any changes to the planet spec.

I *** love you!

(it worked)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Talkie Toaster on March 22, 2015, 03:53:34 PM
IICR you'd have to create a new hull (not a variant) to get built-in hullmods. It's not dynamic, though it probably could/should be.
Ah, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 22, 2015, 07:07:26 PM
I was reminiscing my first time playing, when I using that Gratuitous Space Pirates mod (I always loved the federation ships in that game!). I said to myself, "man it would be cool to incorporate those ships with the default pirate faction". So here I am, utterly confuzzled as to how I change pirate fleet composition. I mean, it looks like it should be easy to figure out just by poking around in the core files, but I'm still very unsure. It looks like it's all in "pirates.faction", in the "shipRoles" section. The fleets compositions as shown in several tutorials are not in that file.

Help? :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 22, 2015, 07:10:31 PM
Is there a way for the enemy to lose a mission when a certain ship of there's dies? I tried api.defeatOnShipLoss(), but it didn't seem to work.

I don't want to bug people, but I really need this answered.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 22, 2015, 07:22:06 PM
Is there a way for the enemy to lose a mission when a certain ship of there's dies? I tried api.defeatOnShipLoss(), but it didn't seem to work.

I don't want to bug people, but I really need this answered.

The way you're doing it should work. It requires the actual name of the ship (i.e. "ISS Unlikely to Survive"), and, looking at the code, should work for both sides.

Failing that, you can also add an every frame script to that mission and call CombatEngineAPI.endCombat(0f, FleetSide.PLAYER).


I was reminiscing my first time playing, when I using that Gratuitous Space Pirates mod (I always loved the federation ships in that game!). I said to myself, "man it would be cool to incorporate those ships with the default pirate faction". So here I am, utterly confuzzled as to how I change pirate fleet composition. I mean, it looks like it should be easy to figure out just by poking around in the core files, but I'm still very unsure. It looks like it's all in "pirates.faction", in the "shipRoles" section. The fleets compositions as shown in several tutorials are not in that file.

Help? :(

Yeah, it's the shipRoles section you want to change. The number is the weight - i.e. the higher it is, the more likely the ship is to show up in that faction's fleets. The fleet compositions you're probably talking about are outdated as of 0.65a.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 22, 2015, 07:26:07 PM
All right, I'll try it again. Thanks.  :)

Edit: So... Yeah, I had an extra space. Yeah.  :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 22, 2015, 09:24:12 PM
Yeah, it's the shipRoles section you want to change. The number is the weight - i.e. the higher it is, the more likely the ship is to show up in that faction's fleets. The fleet compositions you're probably talking about are outdated as of 0.65a.

That's wicked! So many to choose from. Thanks, chief!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Az the Squishy on March 23, 2015, 11:13:45 PM
Hey, as some of you may know I'm working on a mod called Metelson Industries. It's meant to add more mining pods an such. And basically be my own attempt at making ships I'd like to see flying around an the like.

One of the features for the Vanilla campaign is that there's a small station orbiting around Corvus.
I've been trying to figure out a way to do this and one of the ways I thought of, was copying the corvus system-code and simply having it add in a station around Asharu- it needs some lovin', it's one of the first things anyone sees and it's nearly-always battered by pirates or some other bully :P -rather than duplicating it entirely.

But i'm wondering if there's another way of doing this. I'm working on the code and getting the files in the right places as well as makin' the ship files over the next few days. But I'm a bit at a loss of where to go and how to do some things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 24, 2015, 04:05:47 AM
Is there any way to continuously remove the visual damage that accumulates on a ship when you get hit during combat? Alternatively is there a way to not get this visual combat damage at all? The only way to do this that I could think of myself is to make a decorative sprite that basically covers the ship, though I'm not sure any mounted guns would be visible through that sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 24, 2015, 06:43:42 AM
You can define custom damage decals in the hull_styles, just point to a blank image.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 24, 2015, 06:59:17 AM
You can define custom damage decals in the hull_styles, just point to a blank image.

Thanks, I'll try that this evening! Just for curiosity's sake, is there a way to make it fade during combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on March 24, 2015, 04:25:15 PM
Is there any way to render a weapon under the engines?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on March 24, 2015, 04:58:59 PM
No.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on March 25, 2015, 02:21:34 AM
So i am trying to set up an animated weapon, but this crash happens :
Code
41118 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/weapons/pd_laser_turret_glow.png] as texture with id [graphics/weapons/pd_laser_turret_glow.png]
41119 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loaded 179,19 MB of texture data so far
41119 [Thread-5] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/weapons/pd_laser_turret_glow.png (using cast)
41120 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png] as texture with id [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png]
41122 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loaded 179,21 MB of texture data so far
41122 [Thread-5] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png (using cast)
41123 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png] as texture with id [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png]
41123 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png01.png] as texture with id [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png01.png]
41471 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Error loading [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png01.png] resource, not found in [C:\Users\USER\Desktop\Ristyo\starsector3\starsector-core\..\mods\Cronus Initiative,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/cronus/weapons/levianGunAnim/crn_leviananim01.png01.png] resource, not found in [C:\Users\USER\Desktop\Ristyo\starsector3\starsector-core\..\mods\Cronus Initiative,../starfarer.res/res,CLASSPATH]
at com.fs.util.Object.Object(Unknown Source)
at com.fs.util.Object.Ô00000(Unknown Source)
at com.fs.graphics.TextureLoader.Ò00000(Unknown Source)
at com.fs.graphics.TextureLoader.o00000(Unknown Source)
at com.fs.graphics.TextureLoader.o00000(Unknown Source)
at com.fs.graphics.TextureLoader.o00000(Unknown Source)
at com.fs.graphics.H.o00000(Unknown Source)
at com.fs.starfarer.loading.G.super(Unknown Source)
at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I named the first frame crn_leviananim01.png, but it keeps searching for crn_leviananim01.png01.png, why does this happen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 25, 2015, 12:19:38 PM
@Lcu: the first sprite name in the animation *has* to end with 00.png.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 25, 2015, 10:04:00 PM
OK, I got the breakpoint to work... but I don't see anything obvious over here.  It just calls to internal Stuff; I'm not really getting anything out of it.  It's not like it's crashing or anything, it just fails to do anything.  I can see how PersonBountyEvent should get invoked by this:

Code
Global.getSector().reportBattleOccurred(winnerFleet,loserFleet);

...but something is obviously not right there.  Given that winnerFleet and loserFleet must be valid CampaignFleetAPI objects, and the Player Fleet is clearly defined, and the winnerFleet should be the correct winner based on the result... I'm really confused now.  Perhaps I should throw an exception if neither fleet is actually the player fleet or if the player counts as the "loser" even though I won the battle, since that's about the only way I can see this happening?
OK, I finally had enough time to really sort this out tonight with breakpoints to see where it halted... and I've solved this bug with the Fleet Dialogs and Bounty Events are now registering properly, yay!

Here's what was up, just in case it's useful for others trying to modify Dialogs. 

Basically, I was calling reportPlayerEngagement() and reportBattleOccurred() before removeFleetMemberWithDestructionFlash() events.

So that's what was up; the enemy Fleet still had its ships because the events of result hadn't been applied to the CampaignFleetAPI, just to the Deployed members, because the Event system isn't reading result, it's dealing with the CampaignFleetAPI object.  Which also brings up another point, which is that messing with PersonAPIs in Dialogs is probably pretty tricky to avoid recursive problems with... but that's a problem for another day.

So basically it ended up being a cut-pasta fix, after a few hours of figuring out why it was broke, lol.  Thanks again Alex; this was a really weird issue and I don't think I'd have puzzled it out without breakpointing it to death.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 25, 2015, 10:26:28 PM
Glad you got it! Yeah, that kind of thing can be evil - trying to trace out why something isn't working right when your code plugs into random places in somebody else's code that you're not 100% sure about what it's doing and when.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 25, 2015, 10:47:43 PM
Yeah, sorry it took so long to get to this at all; IRL has been extraordinarily busy lately :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 25, 2015, 10:55:34 PM
Is there a way to create a weapon with a black fringe and a white core? I want fringeColor to be [0, 0, 0, 255], but when I set it to that the fringe of the beam is invisible. I suspect this is because beams are drawn additively. Is there a way to tell Starsector not to use additive blending for the fringe?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 26, 2015, 08:52:04 PM
@Xanderzoo:  nope, beams aren't accessible via SpriteAPI atm, so the blending mode can't be set.



Alex (because, well, I don't think anybody else knows about how to do this yet)... uh...  how do I create an in-game Comm Message that:

1.  Has an icon for a Faction?
2.  Has a specific string that I can custom-build?

I have looked at the stuff internally for quite a bit today, and I am really confused about the process, to the point where I'm just using  Global.getSector().getCampaignUI().addMessage right now. 

What I get is that what's happening here (from PersonBountyEvent.java) is both triggering an Event ending that then cascades into one or more Comm Messages:

Code: java
			Global.getSector().reportEventStage(this, "bounty_payment_end", market.getPrimaryEntity(),
MessagePriority.ENSURE_DELIVERY,
new BaseOnMessageDeliveryScript() {
public void beforeDelivery(CommMessageAPI message) {
CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
playerFleet.getCargo().getCredits().add(payment);
Global.getSector().adjustPlayerReputation(
new RepActionEnvelope(RepActions.PERSON_BOUNTY_REWARD, null, message, true),
faction.getId());
}
});

But past that, I'm utterly confused; how this works internally is kind of hard to decypher. 

beforeDelivery() wants a CommMessageAPI message there, but I don't see it defined anywhere in the chain.  What I want is to do something simple like:

Code: java
                    FactionAPI enemyFaction = otherFleet.getFaction();
                    float adjustment = -0.2f;
                    if(enemyFaction.getRelationship("player") > 0f) adjustment = -0.7f;
                    enemyFaction.adjustRelationship("player",adjustment);
                    Global.getSector().reportPlayerReputationChange(enemyFaction.getId(), adjustment);
                    //CREATE COMM MESSAGE HERE, SAYING REP WAS X, NOW IS Y

So how do I create a valid Comm Message with the proper icon for the Faction and deliver it to PlayerFleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 26, 2015, 09:56:24 PM
OK, I got this specific thing:

Code
Global.getSector().adjustPlayerReputation(RepActions.COMBAT_NORMAL, otherFleet.getFaction().getId());

That does it.  However, it's not going to let me use a custom value for the reputation change there. 

So I need to look at what RepActions.COMBAT_NORMAL is, I guess.  Otherwise, good to go.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 26, 2015, 10:09:36 PM
For reputation stuff, you might want to create your own version of the CoreReputationPlugin. If you want to do something simple like reducing/increasing the reputation by a fixed amount, that's not nearly as complicated as the core version.

You'd probably want to copy/paste the append-stuff-to-message code that's there, though. Hmm. I might need to tweak this a bit to make it easier to expand.


The "beforeDelivery" method is called by core right before the message is delivered to the player, with the message as the parameter. That way the rep change happens when the player gets the message, rather than when the thing happens.

Basically, this whole bit of code:
 new BaseOnMessageDeliveryScript() { 
            public void beforeDelivery(CommMessageAPI message) { 
               CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet(); 
               playerFleet.getCargo().getCredits().add(payment); 
               Global.getSector().adjustPlayerReputation( 
                     new RepActionEnvelope(RepActions.PERSON_BOUNTY_REWARD, null, message, true),   
                     faction.getId()); 
            } 

Creates a new instance of an anonymous inner class with a custom implementation of the beforeDelivery method. This instance is passed in to reportEventStage, stored, and at some point down the line - right before the message is delivered to the player - something calls the beforeDelivery method. I hope that makes some kind of sense; it's a fairly common Java thing.


Global.getSector().adjustPlayerReputation() method, you might want to check out the javadoc to see how it functions - the actual behavior is possible to override by supplying a different plugin, like I'm talking about at the start.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 26, 2015, 10:30:42 PM
KK.

I ran into problems right away with this when I wanted to apply it to other stuff; when I use COMBAT_WITH_ENEMY, for example, I got a crash, because param is apparently null and that's hosing CoreReputationPlugin's adjustPlayerReputation(). 

I will look at implementing a new plugin real quick-like and see if I can make this work properly this weekend :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 26, 2015, 10:49:52 PM
I'll take a look at making this easier for the next release - maybe a special value you can pass in to the core rep plugin, with a param that specs out the details of the change.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 26, 2015, 11:33:11 PM
Is there a way to make a projectile that doesn't hit anything? I want it to pass over all ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 27, 2015, 12:09:54 AM
Is there a way to make a projectile that doesn't hit anything? I want it to pass over all ships.

Have a look at the projectile collision class in the proj file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 27, 2015, 08:45:50 AM
I thought of that, but what should I set it too? An empty string?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2015, 11:14:59 AM
Off the top of my head, I think "NONE" would work. Take a look at CollisionClass in the API, the enum names from that are the valid values for that field.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 27, 2015, 11:37:53 AM
Thank you, it works.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 27, 2015, 06:01:13 PM
Quote
I'll take a look at making this easier for the next release - maybe a special value you can pass in to the core rep plugin, with a param that specs out the details of the change.
Just a thought:  PostPlayerMessage(String message, RepEvent event, string factionID) or something like would be very nice, especially if we could extend it.

I figured out implementing the CoreReputationPlugin and it appears to work as desired now, but I'm still a bit at sea about how I'd go about a new custom message; it's a lot more complicated under the hood than I was anticipating :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2015, 06:27:50 PM
Not sure what you mean by "new custom message". Is it the kind that shows up in the intel tab? Then you need to add an entry to reports.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on March 28, 2015, 12:06:30 PM
This part not so important right now: (Hi, I really like fighters and would like to mod my game to have a ton of fighter spam, how would I increase the amount of fighters in a V wing? I thought someone said it was hard coded and couldn't be changed, but it would be nice to have it be like 100 fighters in a wing.)

Please help: (read update 1st)

I tried turning on devmode, and succeeded in doing that, and then tried to press f8, but in battle the game just crashed.
when I am fighting like a hound, it'll say, ship variant hull_hound not found!
If I am fighting a lasher, it'll say hull_lasher not found! and just crash. idk what to do. When fighting pirates in battle with nexerelin and pressing f8 it crashes.

when in the refit screen and I simulate fight fighters and press f8 it waits a second, then continues like normal, but nothing changed. Sometimes it'll randomly crash, but always from a hull not found error.

UPDATE: lol, it worked. I didnt realize SS+ mod also had a wing_Data.csv, i changed the values there and it worked...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on March 28, 2015, 01:20:20 PM
Is there anyway for you to change the arc of a weaponslot, and make the weapons able to go past their original arcs?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on March 28, 2015, 07:32:34 PM
Ships possess the weapon arcs for the mounts, not the weapons themselves.

You can edit the ships with the help of Trylobot's Ship Editor (http://fractalsoftworks.com/forum/index.php?topic=375.0).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on March 28, 2015, 07:43:30 PM
I meant mid-battle, sorry I didn't make that clear.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on March 28, 2015, 07:46:47 PM
Ah.

No, I don't think there is a convenient way of configuring weapon arcs in mid-battle other than mess around with the javascript coding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 28, 2015, 08:43:32 PM
In a projectile class, when you are creating a missile, how do you make the engine use particles instead of a quad strip? Obviously you change QUAD_STRIP to PARTICLES, but a comment says that I need to change the other values that I passed in? What should I change them to?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 29, 2015, 08:03:50 AM
I encounter this error when opening the military market of my own faction. I was told it might be something wrong with the ship variants, or ship hulls, but I honestly cant find anything odd in them. Anyone know more specifically what is wrong and where I should look to correct it?

Code
759538 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] with id [] not found
java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] with id [] not found
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOO.J.<init>(Unknown Source)
at com.fs.starfarer.loading.specs.intsuper.o00000(Unknown Source)
at com.fs.starfarer.loading.specs.intsuper.o00000(Unknown Source)
at com.fs.starfarer.title.ooOO.L.Ò00000(Unknown Source)
at com.fs.starfarer.title.ooOO.L.super(Unknown Source)
at com.fs.starfarer.coreui.T.o00000(Unknown Source)
at com.fs.starfarer.ui.thisnew.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.campaign.ui.fleet.FleetMemberView.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.coreui.dosuper.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.d$Oo.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.ui.d.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.coreui.oOOO.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.coreui.oo0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.ui.D.String.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.ui.do.renderImpl(Unknown Source)
at com.fs.starfarer.ui.D.I.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.ui.do.renderImpl(Unknown Source)
at com.fs.starfarer.ui.D.J.renderImpl(Unknown Source)
at com.fs.starfarer.ui.D.O00O.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.ui.O0o0.renderImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.render(Unknown Source)
at com.fs.starfarer.campaign.ooOO.do.class(Unknown Source)
at com.fs.starfarer.new.Òôo000(Unknown Source)
at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2015, 09:47:34 AM
@Zudgemud: looks like a non-beam weapon with an empty sound id for one of its sounds, I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on March 29, 2015, 11:06:37 AM
Actually so I figured out how to change values yay! But I would like to create fighter wings with 20 - 100 fighters per wing. Imagine hundreds of talons versus an onslaught!
But where is the AI for fighter wings located in the folders? I don't know where to look.

I'm getting fatals!

I fixed the first problem, but it seems everything is corrupted!!! Notice that it says "planeets" not planets, and .png when most images are .jpg

15043 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Error loading [graphics/planeets/atmosphere2.png] resource, not found in [C:\Games\Starsector\starsector-core\..\mods\Starsector Plus,C:\Games\Starsector\starsector-core\..\mods\LazyLib,C:\Games\Starsector\starsector-core\..\mods\Histidine-exerelin-c3823efb1e46,C:\Games\Starsector\starsector-core\..\mods\ShaderLib,../starfarer.res/res,CLASSPATH]
java.lang.RuntimeException: Error loading [graphics/planeets/atmosphere2.png] resource, not found in [C:\Games\Starsector\starsector-core\..\mods\Starsector Plus,C:\Games\Starsector\starsector-core\..\mods\LazyLib,C:\Games\Starsector\starsector-core\..\mods\Histidine-exerelin-c3823efb1e46,C:\Games\Starsector\starsector-core\..\mods\ShaderLib,../starfarer.res/res,CLASSPATH]
   at com.fs.util.Object.Object(Unknown Source)
   at com.fs.util.Object.Ô00000(Unknown Source)
   at com.fs.graphics.TextureLoader.Ò00000(Unknown Source)
   at com.fs.graphics.TextureLoader.o00000(Unknown Source)
   at com.fs.graphics.TextureLoader.o00000(Unknown Source)
   at com.fs.graphics.TextureLoader.o00000(Unknown Source)
   at com.fs.graphics.H.o00000(Unknown Source)
   at com.fs.starfarer.loading.G.super(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 29, 2015, 11:16:04 AM
You can't have more than six fighters in a wing. It is possible to work around this using drones, but I've never tried it and I've heard it's quite messy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 29, 2015, 12:12:59 PM
Quote
I would like to create fighter wings with 20 - 100 fighters per wing
Then you need to implement a custom ship AI, and spawn a fighter that creates the clones for the formation when it's initialized in a battle as a one-time event. 

Basically, Vanilla isn't set up for more than 6 fighters, period, and I don't think you can get around that even with a custom AI, because the issue is related to whatever engine-side code handles the formations at spawn.  At best, you can get around it in the sense of spawning lots of ships via script and then using a custom AI to regulate their behaviors.

That said... what you're going to hit, right away, is performance problems.  Vanilla's not really designed for hundreds of ships and performance isn't all that great.  You'll need to address a lot of things; for example, Vanilla's engines are pretty CPU-heavy.

In Vacuum, after cutting out a lot of the stuff from Vanilla that made it hard to have really large-scale fights, I had about a hundred fighters in a battle in late-game fights (and hundreds of missiles, dozens of other ships, maybe 500 auto-fire weapons operating at once, etc.), and it took quite a lot of optimization to deal with the loads.  I'm about done developing a new AI framework that robustly supports Vanilla gameplay concepts, and it eats more CPU than the Vacuum implementation did but it's still considerably faster than Vanilla's AI, and fairly easy to extend.  When I feel like it's reasonably polished, I will probably release it as a project for everybody to make use of and customize :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on March 29, 2015, 12:26:01 PM
@Zudgemud: looks like a non-beam weapon with an empty sound id for one of its sounds, I think.

It was something with the sound yes, I fixed it by changing some gun sounds from vanilla IDs to custom IDs and suddenly it started working, so thanks a lot!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2015, 01:47:31 PM
I'll take a look at making this easier for the next release - maybe a special value you can pass in to the core rep plugin, with a param that specs out the details of the change.

A bit off topic, but I made some improvements here for the next release:

Code: java
CustomRepImpact impact = new CustomRepImpact();
impact.delta = 0.01f;
impact.limit = RepLevel.WELCOMING;
impact.requireAtWorst = RepLevel.SUSPICIOUS;
Global.getSector().adjustPlayerReputation(new RepActionEnvelope(RepActions.CUSTOM, impact, message, true), factionId);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 29, 2015, 03:15:22 PM
Yay :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 30, 2015, 03:56:24 PM
I keep getting, "Ship Hull variant [gsp_centaur_Standard] not found". Everything looks correct in "ship_data.csv", "gsp_centaur_Standard.variant", and "gsp_centaur.ship". Specifically, the game is calling for a variant I have in place of a starter variant. Could it be related to why some Starsector core file variants are loose and others have their own folder?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2015, 05:16:50 PM
Check the log to see if your .variant file is being loaded - you should see something like this:

Loading variant [C:\workspace\starfarer\..\starfarer.res\res\data\variants\afflictor_Strike.variant]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 30, 2015, 06:21:46 PM
It gets loaded early on, but the error occurs anyway when I choose to start as a pirate (Nexelerin feature). I simply replaced the start ship of that faction with my variant, "gsp_centaur_standard" in rules.csv. Could that be the problem?
Code
Loading variant [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Starfarcraft\data\variants\gsp_centaur_standard.variant]
125479 [Thread-5] WARN  com.fs.starfarer.campaign.rules.oOOO  - Problem with command of class com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddShipAndComplement: Ship hull variant [gsp_centaur_standard] not found!
java.lang.RuntimeException: Ship hull variant [gsp_centaur_standard] not found!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2015, 07:27:13 PM
"Standard" or "standard"? Capitalization of the id matters. Beyond that, I'd make really, really doubly sure there's no typo in the id, either in the .variant or where you're using it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 30, 2015, 11:50:53 PM
Well, the formatting all appears OK and I've checked it against other working mods. I've never had the greatest luck with modding this game. Everything I've done, other than spreadsheet edits, weapon & ship edits, SFX additions, extra campaign music, results in inexplicable errors.

New errors (which all go away if I remove my custom ships):
Code
7317 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at com.fs.starfarer.campaign.FactionManager.readResolve(Unknown Source)
at com.fs.starfarer.campaign.FactionManager.<init>(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.<init>(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.getInstance(Unknown Source)
at com.fs.starfarer.loading.P.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.oOOo$Oo.<init>(Unknown Source)
at com.fs.starfarer.loading.oOOo.<init>(Unknown Source)
at com.fs.starfarer.loading.SpecStore.this.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.ö00000(Unknown Source)
at com.fs.starfarer.loading.G.super(Unknown Source)
at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.H] with id [neutral] not found
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.campaign.Faction.readResolve(Unknown Source)
at com.fs.starfarer.campaign.Faction.<init>(Unknown Source)
at com.fs.starfarer.campaign.Faction.<clinit>(Unknown Source)
... 15 more
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on March 31, 2015, 12:45:55 AM
Sorry if this has already been asked, but is it possible to detect impacts in a EveryFrameWeaponScript? With impacts i refer to any form of projectile hitting the ship and dealing damage.

If yes, would it be possible to generate a vector from the impact location and/or access the amount of damage said projectile caused?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on March 31, 2015, 02:23:52 AM
Not that I'm aware of, it's more popular to have a script attached to the impact, and the impact passes off the vector data (and other stuff) to an EveryFrameCombat plugin
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 31, 2015, 11:50:16 AM
Quote
is it possible to detect impacts in a EveryFrameWeaponScript?
Yes... but like Debido said, it's better to use a projectile script instead.  Detecting impacts means doing quite a lot of math; since the game already does that under the hood, it's best to deal with it there. 

The only exception I can think of is dealing with weapons that don't detect impacts otherwise, because they're using collision mask NONE; those can be done at a reasonable cost, because you're not duplicating work. 

Basically you'd just sort out ships < possible collision distance and check for circle-point collisions to detect a valid impact.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on March 31, 2015, 12:10:57 PM
Sorry for being unclear; i do not wish to make a projectile with a specific behavior. I wish to make a ship which triggers a special behavior every time it is hit.

Though judging from your comments this is impossible. Do you have any other suggestions for making something which triggers when hit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 31, 2015, 12:18:49 PM
You can do that, and fairly cheaply.  Simply write an EveryFrameCombatPlugin that looks for instances of <ship>. 

Then iterate through all of the projectiles, sorting out the ones that haven't done damage this frame. 

Then cross-check the projectiles with the ship by getDamageTarget().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 31, 2015, 01:04:56 PM
I ended up sorting everything out by starting from scratch with the ship implementation. Eeeeeh... not sure what I did differently. Anyways, I now have lovely Gratuitous Space Pirate ships in the campaign ;D ;D ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SexPanther on March 31, 2015, 02:23:55 PM
Okay this seems like a fitting thread. I've never really tried to mod anything before, really, but I know a bit of Java and pixel animation so I figured I would give it a shot. Ideally I would like to make a total conversion mod with around 15-25 ships based on my own balancing scheme (and if the time I would like to code in some new game mechanics as well) BUT.... I figured a good starting point would be to just get ONE SHIP into the game, so... after a bit of time I've managed to get a custom ship into the vanilla game, with all the stats and the whole thing, only one little part is missing, the image. For some reason, the PNG file won't load into the game, it's always just shown as blank.

For some context, my mod currently consists of 4 files:
mod_info.json
purple_ship.png (just the name of the ship image file due to it's purple nature)
ship_data.csv
purple_ship.ship

And for the life of me I can't figure out what the problem is. Yes, all the files are in the proper associated folders. I started off use templates, and Trylobot's ship editor, but it gave me this issue, so I also tried manually creating a .ship and ship_data.csv files from scratch just to see if it would help, but it doesn't. The "spriteName" part of the .ship file does indeed link to the correct file in the correct mod directory as far as I can tell... I just don't know what's wrong. Can someone think of what the problem might be? Much appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 31, 2015, 02:31:07 PM
If the name in spriteName is correct (it is case-sensitive) then at a guess, maybe you're not using a 24-bit PNG?  8-bit doesn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SexPanther on March 31, 2015, 05:35:07 PM
If the name in spriteName is correct (it is case-sensitive) then at a guess, maybe you're not using a 24-bit PNG?  8-bit doesn't work.

Wow... yep... that was it. It was an 8-bit PNG. I would have literally never figured that out, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on March 31, 2015, 07:29:48 PM
I'm trying to add my faction to the campaign using this (http://fractalsoftworks.com/forum/index.php?topic=1282.0) tutorial. I'm having some issues. I followed the instructions in the tutorial, but then I had an error: BaseSpawnPoint.java didn't exist. I copied it over from the starsector-core/data/scripts/world, and then that fixed one problem. Then I had to copy SectorGen.java. At this point I realized that SectorGen.java has an error when it's copied into my mod. I looked, and it seemed like it was because it was initiating things like Corvus and Askonia. I tried copying the corvus and systems folders into my mod, but for some reason it didn't recognize them. I deleted these, along with the troublesome code, and it compiled fine. The problem arose when I tried starting a new game. I got the following error:

Fatal: null
Check starsector.log for more info.

I obeyed the error message and checked starsector.log:

Spoiler
java.lang.NullPointerException
   at data.scripts.world.HutharGen.generate(HutharGen.java:30)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

It said the problem was where I was setting the faction relations. This was odd, because it had been copied directly from the tutorial, but I commented it out just to see what would happen.

This:
Spoiler
31064 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
java.lang.RuntimeException: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   ... 13 more
[close]

So I assumed that this was because I had deleted the imports for Corvus, Askonia, etc. Just to see what would happen, I deleted the entire contents of SectorGen.java's two functions. All it was left with was a class with two empty functions.

I was rewarded with this fun little error:

Spoiler
java.lang.NullPointerException
   at data.scripts.world.HutharGen.generate(HutharGen.java:24)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

[close]

I have no idea what I'm doing wrong. I followed the tutorial exactly, but things didn't work... I hope someone can help me.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: orost on March 31, 2015, 11:31:49 PM
Is there a way to apply a blanket adjustment to stats? Say I wanted to double flux dissipation of all ships in the game or something, is there a better way to do it than just changing every flux disspation value in the .csv files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 01, 2015, 04:19:57 AM
@Xanderzoo
This tutorial is so outdated it hurts. You should just take one of the clean mods as a template like Mayorate, Shadowyard or Junk Pirates.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 01, 2015, 07:14:16 AM
Ah. That would explain a lot. Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 01, 2015, 08:16:23 AM
I'm basing my mod around a mixture of Junk Pirates, Shadowyards and Vanilla, but I'm still getting an error:

Fatal: null
Check starsector.log for more info.

Starsector.log
Spoiler
30147 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.fleet.CargoData.initMothballedShips(Unknown Source)
   at com.fs.starfarer.campaign.CustomCampaignEntity.<init>(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
   at data.scripts.world.systems.Quavar.generate(Quavar.java:52)
   at data.scripts.world.HutharGen.generate(HutharGen.java:32)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Quavar.java (The name of the system I'm trying to add):

Spoiler
package data.scripts.world.systems;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

public class Quavar {

   public void generate(SectorAPI sector) {
      
      StarSystemAPI system = sector.createStarSystem("Quavar");
      LocationAPI hyper = Global.getSector().getHyperspace();
      
      system.setBackgroundTextureFilename("graphics/backgrounds/background1.jpg");
      
      // create the star and generate the hyperspace anchor for this system
      PlanetAPI star = system.initStar("quavar", // unique id for this star
                               "star_red", // id in planets.json
                               600f);       // radius (in pixels at default zoom)
      
      system.setLightColor(new Color(255, 220, 180)); // light color in entire system, affects all entities
      
      /*
       * addPlanet() parameters:
       * 1. Unique id for this planet (or null to have it be autogenerated)
       * 2. What the planet orbits (orbit is always circular)
       * 3. Name
       * 4. Planet type id in planets.json
       * 5. Starting angle in orbit, i.e. 0 = to the right of the star
       * 6. Planet radius, pixels at default zoom
       * 7. Orbit radius, pixels at default zoom
       * 8. Days it takes to complete an orbit. 1 day = 10 seconds.
       */
      
      
      


      PlanetAPI quavar1 = system.addPlanet("ninsun", star, "Ninsun", "rocky_metallic", 100, 120, 1500, 60);

      SectorEntityToken hutharStation = system.addCustomEntity("ninsun_orbital", "Ninsun Orbital", "station_side02", "huthar");
      hutharStation.setCircularOrbitPointingDown(system.getEntityById("ninsun"), 90, 450, 45);      



      SectorEntityToken relay = system.addCustomEntity("huthar_relay", // unique id
             "Graymore Relay", // name - if null, defaultName from custom_entities.json will be used
             "comm_relay", // type of object, defined in custom_entities.json
             "huthar"); // faction
      relay.setCircularOrbit( system.getEntityById("graymore"), 150, 1200, 100);

      JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("ninsun_gate", "Ninsune Jump-Point");
      OrbitAPI orbit = Global.getFactory().createCircularOrbit(quavar1, 0, 500, 30);
      jumpPoint.setOrbit(orbit);
      jumpPoint.setRelatedPlanet(quavar1);
      jumpPoint.setStandardWormholeToHyperspaceVisual();
      system.addEntity(jumpPoint);
      

      //initStationCargo(station);
      
      //SectorEntityToken station = system.addCustomEntity("diktat_cnc", "Command & Control", "station_side02", "sindrian_diktat");
      //station.setCircularOrbitPointingDown(system.getEntityById("sindria"), 45, 300, 50);      
//      station.setCustomDescriptionId("station_ragnar");
      
      // example of using custom visuals below
//      a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
//      jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
//      station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));
      
      // generates hyperspace destinations for in-system jump points
      system.autogenerateHyperspaceJumpPoints(true, true);
      
      
      /*
      DiktatPatrolSpawnPoint patrolSpawn = new DiktatPatrolSpawnPoint(sector, system, 5, 3, a1);
      system.addScript(patrolSpawn);
      for (int i = 0; i < 5; i++)
         patrolSpawn.spawnFleet();

      DiktatGarrisonSpawnPoint garrisonSpawn = new DiktatGarrisonSpawnPoint(sector, system, 30, 1, a1, a1);
      system.addScript(garrisonSpawn);
      garrisonSpawn.spawnFleet();
      
      
      system.addScript(new IndependentTraderSpawnPoint(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), station));
      */
   }
   
   
   private void initStationCargo(SectorEntityToken station) {
      CargoAPI cargo = station.getCargo();
      addRandomWeapons(cargo, 5);
      
      cargo.addCrew(CrewXPLevel.VETERAN, 20);
      cargo.addCrew(CrewXPLevel.REGULAR, 500);
      cargo.addMarines(200);
      cargo.addSupplies(1000);
      cargo.addFuel(500);
      
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "heron_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "heron_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "shepherd_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "shepherd_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "monitor_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "monitor_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
   }
   
   private void addRandomWeapons(CargoAPI cargo, int count) {
      List weaponIds = Global.getSector().getAllWeaponIds();
      for (int i = 0; i < count; i++) {
         String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
         int quantity = (int)(Math.random() * 4f + 2f);
         cargo.addWeapons(weaponId, quantity);
      }
   }
   
}

[close]

HutharGen.java

Spoiler
package data.scripts.world;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.econ.EconomyAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import java.util.ArrayList;
//import com.fs.starfarer.api.InteractionDialogImageVisual;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import java.awt.Color;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

import data.scripts.world.systems.Quavar;

public class HutharGen implements SectorGeneratorPlugin{

   public void generate(SectorAPI sector) {

        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("huthar"); 
       
      new Quavar().generate(sector);

      initFactionRelationships(sector);
   }

   
    public static void initFactionRelationships(SectorAPI sector) {
        FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
        FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
        FactionAPI pirates = sector.getFaction(Factions.PIRATES);
        FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
        FactionAPI kol = sector.getFaction(Factions.KOL);
        FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
        FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);
        FactionAPI player = sector.getFaction(Factions.PLAYER);
        FactionAPI diktat = sector.getFaction(Factions.DIKTAT);
        FactionAPI huthar = sector.getFaction("huthar");
       
        //modded factions 
        FactionAPI sra = sector.getFaction("shadow_industry"); 
        FactionAPI pirateAnar = sector.getFaction("pirateAnar"); 
        FactionAPI mayorate = sector.getFaction("mayorate"); 
        FactionAPI ice = sector.getFaction("sun_ice"); 
        FactionAPI ici = sector.getFaction("sun_ici"); 
        FactionAPI citadel = sector.getFaction("citadeldefenders"); 
        FactionAPI II = sector.getFaction("interstellarimperium");
        FactionAPI exi = sector.getFaction("exigency");
        FactionAPI brdy = sector.getFaction("blackrock_driveyards");
        FactionAPI lions = sector.getFaction("lions_guard");
        FactionAPI ahr = sector.getFaction("exipirated");
 
        if (sra != null) { 
            huthar.setRelationship(sra.getId(), RepLevel.HOSTILE);
        } 
        if (pirateAnar != null) { 
            huthar.setRelationship(pirateAnar.getId(), RepLevel.HOSTILE);
        } 
        if (mayorate != null) { 
            huthar.setRelationship(mayorate.getId(), RepLevel.NEUTRAL);
        } 
        if (ice != null) { 
            huthar.setRelationship(ice.getId(), RepLevel.VENGEFUL);
        } 
        if (ici != null) { 
            huthar.setRelationship(ici.getId(), RepLevel.VENGEFUL);
        } 
        if (citadel != null) { 
            huthar.setRelationship(citadel.getId(), RepLevel.WELCOMING);
        } 
         
        if (II != null) { 
            huthar.setRelationship(II.getId(), RepLevel.HOSTILE);
        } 
       
        if (ahr != null) { 
            huthar.setRelationship(ahr.getId(), RepLevel.INHOSPITABLE);
        }
       
        if (exi != null) { 
            huthar.setRelationship(exi.getId(), RepLevel.NEUTRAL);
        }
       
        player.setRelationship(huthar.getId(), 0);
       
        huthar.setRelationship(hegemony.getId(), RepLevel.FAVORABLE);
        huthar.setRelationship(path.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(church.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(pirates.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(diktat.getId(), RepLevel.FRIENDLY);
        huthar.setRelationship(tritachyon.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(independent.getId(), RepLevel.SUSPICIOUS);
       
        tritachyon.setRelationship(huthar.getId(), RepLevel.VENGEFUL);
        hegemony.setRelationship(huthar.getId(), RepLevel.FAVORABLE);
        pirates.setRelationship(huthar.getId(), RepLevel.VENGEFUL);
        kol.setRelationship(huthar.getId(), RepLevel.HOSTILE);

       

    }
}

[close]

I think the problem is happening when I add a space station, but I don't know what's causing it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on April 01, 2015, 09:58:46 AM
I'm basing my mod around a mixture of Junk Pirates, Shadowyards and Vanilla, but I'm still getting an error:

Fatal: null
Check starsector.log for more info.

Starsector.log
Spoiler
30147 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.fleet.CargoData.initMothballedShips(Unknown Source)
   at com.fs.starfarer.campaign.CustomCampaignEntity.<init>(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
   at data.scripts.world.systems.Quavar.generate(Quavar.java:52)
   at data.scripts.world.HutharGen.generate(HutharGen.java:32)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Quavar.java (The name of the system I'm trying to add):

Spoiler
package data.scripts.world.systems;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetMemberType;

public class Quavar {

   public void generate(SectorAPI sector) {
      
      StarSystemAPI system = sector.createStarSystem("Quavar");
      LocationAPI hyper = Global.getSector().getHyperspace();
      
      system.setBackgroundTextureFilename("graphics/backgrounds/background1.jpg");
      
      // create the star and generate the hyperspace anchor for this system
      PlanetAPI star = system.initStar("quavar", // unique id for this star
                               "star_red", // id in planets.json
                               600f);       // radius (in pixels at default zoom)
      
      system.setLightColor(new Color(255, 220, 180)); // light color in entire system, affects all entities
      
      /*
       * addPlanet() parameters:
       * 1. Unique id for this planet (or null to have it be autogenerated)
       * 2. What the planet orbits (orbit is always circular)
       * 3. Name
       * 4. Planet type id in planets.json
       * 5. Starting angle in orbit, i.e. 0 = to the right of the star
       * 6. Planet radius, pixels at default zoom
       * 7. Orbit radius, pixels at default zoom
       * 8. Days it takes to complete an orbit. 1 day = 10 seconds.
       */
      
      
      


      PlanetAPI quavar1 = system.addPlanet("ninsun", star, "Ninsun", "rocky_metallic", 100, 120, 1500, 60);

      SectorEntityToken hutharStation = system.addCustomEntity("ninsun_orbital", "Ninsun Orbital", "station_side02", "huthar");
      hutharStation.setCircularOrbitPointingDown(system.getEntityById("ninsun"), 90, 450, 45);      



      SectorEntityToken relay = system.addCustomEntity("huthar_relay", // unique id
             "Graymore Relay", // name - if null, defaultName from custom_entities.json will be used
             "comm_relay", // type of object, defined in custom_entities.json
             "huthar"); // faction
      relay.setCircularOrbit( system.getEntityById("graymore"), 150, 1200, 100);

      JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("ninsun_gate", "Ninsune Jump-Point");
      OrbitAPI orbit = Global.getFactory().createCircularOrbit(quavar1, 0, 500, 30);
      jumpPoint.setOrbit(orbit);
      jumpPoint.setRelatedPlanet(quavar1);
      jumpPoint.setStandardWormholeToHyperspaceVisual();
      system.addEntity(jumpPoint);
      

      //initStationCargo(station);
      
      //SectorEntityToken station = system.addCustomEntity("diktat_cnc", "Command & Control", "station_side02", "sindrian_diktat");
      //station.setCircularOrbitPointingDown(system.getEntityById("sindria"), 45, 300, 50);      
//      station.setCustomDescriptionId("station_ragnar");
      
      // example of using custom visuals below
//      a1.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "hull_breach", 800, 800));
//      jumpPoint.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "space_wreckage", 1200, 1200));
//      station.setCustomInteractionDialogImageVisual(new InteractionDialogImageVisual("illustrations", "cargo_loading", 1200, 1200));
      
      // generates hyperspace destinations for in-system jump points
      system.autogenerateHyperspaceJumpPoints(true, true);
      
      
      /*
      DiktatPatrolSpawnPoint patrolSpawn = new DiktatPatrolSpawnPoint(sector, system, 5, 3, a1);
      system.addScript(patrolSpawn);
      for (int i = 0; i < 5; i++)
         patrolSpawn.spawnFleet();

      DiktatGarrisonSpawnPoint garrisonSpawn = new DiktatGarrisonSpawnPoint(sector, system, 30, 1, a1, a1);
      system.addScript(garrisonSpawn);
      garrisonSpawn.spawnFleet();
      
      
      system.addScript(new IndependentTraderSpawnPoint(sector, hyper, 1, 10, hyper.createToken(-6000, 2000), station));
      */
   }
   
   
   private void initStationCargo(SectorEntityToken station) {
      CargoAPI cargo = station.getCargo();
      addRandomWeapons(cargo, 5);
      
      cargo.addCrew(CrewXPLevel.VETERAN, 20);
      cargo.addCrew(CrewXPLevel.REGULAR, 500);
      cargo.addMarines(200);
      cargo.addSupplies(1000);
      cargo.addFuel(500);
      
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "conquest_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "heron_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "heron_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "shepherd_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "shepherd_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "crig_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "ox_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "monitor_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, "monitor_Hull"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
      cargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gladius_wing"));
   }
   
   private void addRandomWeapons(CargoAPI cargo, int count) {
      List weaponIds = Global.getSector().getAllWeaponIds();
      for (int i = 0; i < count; i++) {
         String weaponId = (String) weaponIds.get((int) (weaponIds.size() * Math.random()));
         int quantity = (int)(Math.random() * 4f + 2f);
         cargo.addWeapons(weaponId, quantity);
      }
   }
   
}

[close]

HutharGen.java

Spoiler
package data.scripts.world;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.econ.EconomyAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import java.util.ArrayList;
//import com.fs.starfarer.api.InteractionDialogImageVisual;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import java.awt.Color;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

import data.scripts.world.systems.Quavar;

public class HutharGen implements SectorGeneratorPlugin{

   public void generate(SectorAPI sector) {

        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("huthar"); 
       
      new Quavar().generate(sector);

      initFactionRelationships(sector);
   }

   
    public static void initFactionRelationships(SectorAPI sector) {
        FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
        FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
        FactionAPI pirates = sector.getFaction(Factions.PIRATES);
        FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
        FactionAPI kol = sector.getFaction(Factions.KOL);
        FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
        FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);
        FactionAPI player = sector.getFaction(Factions.PLAYER);
        FactionAPI diktat = sector.getFaction(Factions.DIKTAT);
        FactionAPI huthar = sector.getFaction("huthar");
       
        //modded factions 
        FactionAPI sra = sector.getFaction("shadow_industry"); 
        FactionAPI pirateAnar = sector.getFaction("pirateAnar"); 
        FactionAPI mayorate = sector.getFaction("mayorate"); 
        FactionAPI ice = sector.getFaction("sun_ice"); 
        FactionAPI ici = sector.getFaction("sun_ici"); 
        FactionAPI citadel = sector.getFaction("citadeldefenders"); 
        FactionAPI II = sector.getFaction("interstellarimperium");
        FactionAPI exi = sector.getFaction("exigency");
        FactionAPI brdy = sector.getFaction("blackrock_driveyards");
        FactionAPI lions = sector.getFaction("lions_guard");
        FactionAPI ahr = sector.getFaction("exipirated");
 
        if (sra != null) { 
            huthar.setRelationship(sra.getId(), RepLevel.HOSTILE);
        } 
        if (pirateAnar != null) { 
            huthar.setRelationship(pirateAnar.getId(), RepLevel.HOSTILE);
        } 
        if (mayorate != null) { 
            huthar.setRelationship(mayorate.getId(), RepLevel.NEUTRAL);
        } 
        if (ice != null) { 
            huthar.setRelationship(ice.getId(), RepLevel.VENGEFUL);
        } 
        if (ici != null) { 
            huthar.setRelationship(ici.getId(), RepLevel.VENGEFUL);
        } 
        if (citadel != null) { 
            huthar.setRelationship(citadel.getId(), RepLevel.WELCOMING);
        } 
         
        if (II != null) { 
            huthar.setRelationship(II.getId(), RepLevel.HOSTILE);
        } 
       
        if (ahr != null) { 
            huthar.setRelationship(ahr.getId(), RepLevel.INHOSPITABLE);
        }
       
        if (exi != null) { 
            huthar.setRelationship(exi.getId(), RepLevel.NEUTRAL);
        }
       
        player.setRelationship(huthar.getId(), 0);
       
        huthar.setRelationship(hegemony.getId(), RepLevel.FAVORABLE);
        huthar.setRelationship(path.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(church.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(pirates.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(diktat.getId(), RepLevel.FRIENDLY);
        huthar.setRelationship(tritachyon.getId(), RepLevel.VENGEFUL);
        huthar.setRelationship(independent.getId(), RepLevel.SUSPICIOUS);
       
        tritachyon.setRelationship(huthar.getId(), RepLevel.VENGEFUL);
        hegemony.setRelationship(huthar.getId(), RepLevel.FAVORABLE);
        pirates.setRelationship(huthar.getId(), RepLevel.VENGEFUL);
        kol.setRelationship(huthar.getId(), RepLevel.HOSTILE);

       

    }
}

[close]

I think the problem is happening when I add a space station, but I don't know what's causing it.

        FactionAPI brdy = sector.getFaction("blackrock_driveyards");
        FactionAPI lions = sector.getFaction("lions_guard");

these two lines in HutharGen.java needs a null check as others mod factions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 01, 2015, 09:59:36 AM
Ah, thank you. I'm trying it now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 01, 2015, 10:03:11 AM
Unfortunately, I'm still getting the same error as before.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on April 01, 2015, 12:37:33 PM
I'm getting an annoying error with system gen that I simply cannot fix, no matter what I do. The error is in the spoiler below.

Spoiler
57178 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files\Fractal Softworks\Starsector 0.65.2\starsector-core\..\mods\CoFS (data\campaign\econ/bastion.json)]
57557 [Thread-11] INFO  sound.O  - Creating streaming player for music with id [music-miscallenous_main_menu.ogg]
57558 [Thread-11] INFO  sound.OooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOO  - Playing music with id [music-miscallenous_main_menu.ogg]
58330 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.lang.RuntimeException: Market in bastion system refers to invalid entity citadel
java.lang.RuntimeException: java.lang.RuntimeException: Market in bastion system refers to invalid entity citadel
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.thisnew.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
   at com.fs.starfarer.coreui.if.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.I.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.do.processInputImpl(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Market in bastion system refers to invalid entity citadel
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   ... 32 more
[close]

The download to the files are below. If anyone could tell me what I've screwed up, that would be great.

https://mega.co.nz/#!4kxnnCpQ!_p-HvsKlSuiuknYoSmz2VZzkV3inuDoAThXvXpZvK64 (https://mega.co.nz/#!4kxnnCpQ!_p-HvsKlSuiuknYoSmz2VZzkV3inuDoAThXvXpZvK64)

Luna out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 01, 2015, 12:49:33 PM
Quote
Market in bastion system refers to invalid entity citadel
Might be a clue :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2015, 12:55:30 PM
@Xanderzoo:

The stack trace from the log has this line in it
 at data.scripts.world.systems.Quavar.generate(Quavar.java:52)

This means that the error happens in something triggered further down by the call on line 52. Unless I'm mistaken (didn't line-count exactly, please double check), that line is:
SectorEntityToken hutharStation = system.addCustomEntity("ninsun_orbital", "Ninsun Orbital", "station_side02", "huthar");

I think it's an issue with the faction id not pointing to a valid faction. Perhaps there's a typo (either there or in the .faction file), or perhaps you didn't add your .faction file to factions.csv.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 01, 2015, 03:38:34 PM
I had incorrectly set up factions.csv. I fixed that, and now I have a new error:

39308 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.CircularOrbit.advance(Unknown Source)
   at com.fs.starfarer.campaign.StarSystem.autogenerateHyperspaceJumpPoints(Unknown Source)
   at data.scripts.world.systems.Quavar.generate(Quavar.java:83)
   at data.scripts.world.HutharGen.generate(HutharGen.java:32)
   at data.scripts.HModPlugin.initHuthar(HModPlugin.java:21)
   at data.scripts.HModPlugin.onNewGame(HModPlugin.java:30)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

This time the line in question is
Code
system.autogenerateHyperspaceJumpPoints(true, true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2015, 03:46:06 PM
It's probably due to this:
relay.setCircularOrbit( system.getEntityById("graymore"), 150, 1200, 100);

You end up with an orbit around a non-existent entity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 01, 2015, 03:53:38 PM
Thank you. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 01, 2015, 03:56:56 PM
That fixed one error, but now I'm getting this.

39638 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/economy.json)]
39638 [Thread-5] INFO  com.fs.starfarer.campaign.econ.B  - Loading economy data from data/campaign/econ/economy.json
39639 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data\campaign\econ/../starmap.json)]
39639 [Thread-5] INFO  com.fs.starfarer.campaign.econ.B  - Loading star system: askonia.json
39639 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data\campaign\econ/askonia.json)]
39695 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
java.lang.RuntimeException: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.O0oO.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.H.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Market in askonia system refers to invalid entity sindria
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
   ... 13 more


It has something to do with the Askonia system, but I'm not modifying it in my mod...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on April 01, 2015, 05:27:08 PM
Quote
Market in bastion system refers to invalid entity citadel
Might be a clue :)

I know it's a clue. I tried playing with the economy.json, the file that generates Bastion, but nothing works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on April 02, 2015, 01:04:48 PM
So, after adding my ships to the campaign (via a faction file), the market is completely screwed up. While it was certainly a nice surprise to see the new ships in the market, the traditional "rarity-based" market stocking is gone. I can find stacks of 4 HILs in just about every market. This is a familiar side-effect that I remember reading complaints about in the past. I can't remember why it happens or if there was a solution (not sure what to search for). I guess my question would be: can this be fixed on my end?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on April 05, 2015, 07:11:55 AM
Alright, I fixed the bug I had previously(somehow), but now I have another problem with the Bastion system not generating at all. Getting a system in place and setting up fleet compositions is really all I need to do before I can properly release the mod for you all to enjoy(blowing up everything before a balance patch is out). Please tell me what I've screwed up in a simple enough matter that even I can fix it.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 05, 2015, 10:11:16 AM
So, after adding my ships to the campaign (via a faction file), the market is completely screwed up. While it was certainly a nice surprise to see the new ships in the market, the traditional "rarity-based" market stocking is gone. I can find stacks of 4 HILs in just about every market. This is a familiar side-effect that I remember reading complaints about in the past. I can't remember why it happens or if there was a solution (not sure what to search for). I guess my question would be: can this be fixed on my end?

The weapons you see in the markets are based on what's mounted on that faction's ships. The rarity of a weapon for a given faction, then, is based on how much it's used in its loadouts.

You shouldn't be seeing something like the HIL on the open market, though, as that submarket is restricted to tier 0 weapons, and the HIL is tier 1.


Alright, I fixed the bug I had previously(somehow), but now I have another problem with the Bastion system not generating at all. Getting a system in place and setting up fleet compositions is really all I need to do before I can properly release the mod for you all to enjoy(blowing up everything before a balance patch is out). Please tell me what I've screwed up in a simple enough matter that even I can fix it.  :P

Are you calling the system-generation code from your ModPlugin's onNewGame() method?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 05, 2015, 12:45:23 PM
LunaIsBestPony: Can you tell me how you fixed your problem? I seem to have a similar bug.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on April 05, 2015, 02:49:17 PM
I don't know what I'm doing wrong. Here, just have my src file. It's below.

As for you, Xanderzoo, I have no idea how I fixed it. Sorry.

"My code doesn't work! I don't know why."

"My code works!... I still don't know why."


[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 05, 2015, 03:00:50 PM
Oh well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 05, 2015, 03:03:51 PM
I don't know what I'm doing wrong. Here, just have my src file. It's below.

After a very cursory look, things seem right. Is it possible you're simply not pointing to your ModPlugin from your mod_info.json?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on April 05, 2015, 03:25:22 PM
I actually did have the wrong thing in the ModPlugin field, but that didn't do it. Here's the entire current CoFS folder, in case I screwed something up elsewhere and someone more experienced then I can spot the error.

https://mega.co.nz/#!JkoSxAJJ!PSaYloE5y3-x9RGtT6DxucS-wPsU3zqtji0MoYgx8us (https://mega.co.nz/#!JkoSxAJJ!PSaYloE5y3-x9RGtT6DxucS-wPsU3zqtji0MoYgx8us)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on April 05, 2015, 03:37:29 PM
In case someone's feeling altruistic and wants to help me fix my bug, this is my mod:

Buggy mod (https://www.dropbox.com/s/u79gpq7lfpsgbgp/Hu%27thar.zip?dl=0)

Thanks. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on April 07, 2015, 03:22:21 PM
Can someone help me with the mod I dun stupided with? There's something wrong with the system gen, as in the system my mod adds doesn't generate. As of right now, that's the only error. Can someone please tell me what I did wrong?

Link!
https://www.dropbox.com/s/70s88dbksx64tal/CoFSdev4.zip?dl=0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nanao-kun on April 09, 2015, 04:49:47 PM
Will changing the "maxFXsources" setting above the default 64 cause any problems?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on April 09, 2015, 11:39:22 PM
Can someone help me with the mod I dun stupided with? There's something wrong with the system gen, as in the system my mod adds doesn't generate. As of right now, that's the only error. Can someone please tell me what I did wrong?

Link!
https://www.dropbox.com/s/70s88dbksx64tal/CoFSdev4.zip?dl=0

I got this one done. Check your PM.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 09, 2015, 11:57:24 PM
Will changing the "maxFXsources" setting above the default 64 cause any problems?
No, but you have to leave some room for the music tracks as the maximum amount of sources is 256. My settings are:
Code
	# OpenAL-related
"maxFXSources":220,
"maxUISources":10,

With these I never got a crash, and I very rarely get weapon sounds that clip each other.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nanao-kun on April 10, 2015, 09:17:13 AM
Will changing the "maxFXsources" setting above the default 64 cause any problems?
No, but you have to leave some room for the music tracks as the maximum amount of sources is 256. My settings are:
Code
	# OpenAL-related
"maxFXSources":220,
"maxUISources":10,

With these I never got a crash, and I very rarely get weapon sounds that clip each other.
Alright, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Merlin on April 10, 2015, 01:43:31 PM
Just changed the NOFIRING attribution of the phasecloak to "FALSE" in the CSV file,
then I found that in the P-space weapons still cannot fire...
except beam weapons. :-\
Wonder why and how to make other kinds of weapons be able to fire in the P-space?
My game version is 0.651a.
Thanks in advance. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on April 20, 2015, 11:40:24 PM
How do I add ships to the player fleet?

This doesn't seem to work:
Code
Global.getSector().getPlayerFleet().getCargo().addMothballedShip(type, ship, ship);
type = FleetMemberType.SHIP
ship = just a standard String variant ID
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 21, 2015, 12:18:59 AM
I think you'll need something more like:
Code: Java
FleetMemberAPI newMember = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "variantID");
Global.getSector().getPlayerFleet().getFleetData().addFleetMember(newMember);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on April 21, 2015, 08:05:01 PM
I think you'll need something more like:
Code: Java
FleetMemberAPI newMember = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "variantID");
Global.getSector().getPlayerFleet().getFleetData().addFleetMember(newMember);

That works. You rock!

Guess I somehow never found that method even after an hour or two of paging through the APIs. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Az the Squishy on May 10, 2015, 04:26:30 PM
Right... I need some help. How do you get your system to actually spawn?
I made a system based on the Arcadia Vinallia system and it simply will not spawn the stupid system i've named, Rock! ... yeah lame i know.
Anyway, It doesn't crash but, whenever I run the game it simply doesn't spawn the system.
No idea what to do and I've been scratching at my head for a few hours now!

Here is a fresh log of the game being started if that's any help. Ant the mod in a working state that DOES NOT. Have my flimsy attempts of fixxing the damn thing.


Spoiler
Code
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Starting Starsector 0.65.2a-RC2 launcher
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Running in /home/peter/Documents/linuxgames/Stragey/ssdev
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - OS: Linux 3.13.0-37-generic
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Java version: 1.8.0_45 (64-bit)

...

21756 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loaded 200.23 MB of texture data so far
21756 [Thread-5] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/particlealpha32sq.png (using cast)
21840 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/backgrounds/background4.jpg] as texture with id [graphics/backgrounds/background4.jpg]
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/economy.json)]
37993 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading economy data from data/campaign/econ/economy.json
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/../starmap.json)]
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: /home/peter/Documents/linuxgames/Stragey/ssdev/./mods/mi (data/campaign/econ/../starmap.json)]
37993 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: askonia.json
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/askonia.json)]
37996 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: corvus.json
37996 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/corvus.json)]
37998 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: valhalla.json
37998 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/valhalla.json)]
38002 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: arcadia.json
38002 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/arcadia.json)]
38004 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: magec.json
38004 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/magec.json)]
38008 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: eos.json
38008 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/eos.json)]
38824 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Tartessus]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Tartessus]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Nomios]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Nomios]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Baetis]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Baetis]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Skathi]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Skathi]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Sindria]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Sindria]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Citadel Arcadia]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Citadel Arcadia]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Volturn]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Volturn]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Raesvelg]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Raesvelg]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Asharu]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Asharu]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Cruor]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Cruor]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Mimir Siphon Platform]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Mimir Siphon Platform]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Ragnar Complex]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Ragnar Complex]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Agreus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Agreus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Jangala]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Jangala]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Ceyx]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Ceyx]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Ratatosk]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Ratatosk]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Hesperus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Hesperus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [New Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [New Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Tibicena]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Tibicena]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Port Tse Franchise Station #3]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Port Tse Franchise Station #3]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Glasnir]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Glasnir]
38833 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  -
38834 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  - Checking whether to spawn trade fleet
38834 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  - 0 out of a maximum 100 trade fleets in play

.... ....

48154 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  - Spawned 8 point trade fleet from [Nomios] to [Hesperus]
51256 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving to ./saves/save_asdasdasdasd_7181433286896150291...
51881 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Finished saving

[close]

Looking at my own log it looks like the system isn't even loading!!! What the heck'm I doing wrong here? xD It doesn't crash the game which is nice, but ai can't see my copy-cat systeme dang it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on May 10, 2015, 06:47:38 PM
Right... I need some help. How do you get your system to actually spawn?
I made a system based on the Arcadia Vinallia system and it simply will not spawn the stupid system i've named, Rock! ... yeah lame i know.
Anyway, It doesn't crash but, whenever I run the game it simply doesn't spawn the system.
No idea what to do and I've been scratching at my head for a few hours now!

Here is a fresh log of the game being started if that's any help. Ant the mod in a working state that DOES NOT. Have my flimsy attempts of fixxing the damn thing.


Spoiler
Code
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Starting Starsector 0.65.2a-RC2 launcher
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Running in /home/peter/Documents/linuxgames/Stragey/ssdev
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - OS: Linux 3.13.0-37-generic
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Java version: 1.8.0_45 (64-bit)

...

21756 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loaded 200.23 MB of texture data so far
21756 [Thread-5] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/particlealpha32sq.png (using cast)
21840 [Thread-5] DEBUG com.fs.graphics.TextureLoader  - Loading [graphics/backgrounds/background4.jpg] as texture with id [graphics/backgrounds/background4.jpg]
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/economy.json)]
37993 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading economy data from data/campaign/econ/economy.json
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/../starmap.json)]
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: /home/peter/Documents/linuxgames/Stragey/ssdev/./mods/mi (data/campaign/econ/../starmap.json)]
37993 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: askonia.json
37993 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/askonia.json)]
37996 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: corvus.json
37996 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/corvus.json)]
37998 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: valhalla.json
37998 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/valhalla.json)]
38002 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: arcadia.json
38002 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/arcadia.json)]
38004 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: magec.json
38004 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/magec.json)]
38008 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: eos.json
38008 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/eos.json)]
38824 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Tartessus]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Tartessus]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Nomios]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Nomios]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Baetis]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Baetis]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Skathi]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Skathi]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Sindria]
38825 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Sindria]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Citadel Arcadia]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Citadel Arcadia]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Volturn]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Volturn]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Raesvelg]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Raesvelg]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Asharu]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Asharu]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Cruor]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Cruor]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Mimir Siphon Platform]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Mimir Siphon Platform]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Ragnar Complex]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Ragnar Complex]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Agreus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Agreus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Jangala]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Jangala]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Ceyx]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Ceyx]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Ratatosk]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Ratatosk]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Hesperus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Hesperus]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [New Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [New Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Tibicena]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Tibicena]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Port Tse Franchise Station #3]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Port Tse Franchise Station #3]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Maxios]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added patrol fleet spawning script to market [Glasnir]
38826 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.CoreScript  - Added pirate fleet spawning script to market [Glasnir]
38833 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  -
38834 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  - Checking whether to spawn trade fleet
38834 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  - 0 out of a maximum 100 trade fleets in play

.... ....

48154 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetManager  - Spawned 8 point trade fleet from [Nomios] to [Hesperus]
51256 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving to ./saves/save_asdasdasdasd_7181433286896150291...
51881 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Finished saving

[close]

Looking at my own log it looks like the system isn't even loading!!! What the heck'm I doing wrong here? xD It doesn't crash the game which is nice, but ai can't see my copy-cat systeme dang it!

Remember what I have done to the mod_info.json ? Revoke it。
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Az the Squishy on May 10, 2015, 09:11:58 PM
... if that works. hooray. and deathfly. I friggin' love your help.

It worked, then burned. So, it seems i may've done things... incorrectly. I'll update after mussing around to see if i can't fix it myself somehow.

edit edit: So, after having gone through all the files cleaned up an old system that FAILED uttlery, I've gotten it to the point where it recgonized the system, now it's coming up with a friggin' NULL error however coming from the related eco rock.json file that's to be with the system.


here's the borked mod if anyone wants to take a look, and the resulting log segment at error.
https://www.dropbox.com/s/h3u23c6njq0qdax/miBORK.zip?dl=0


Code
14550 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: valhalla.json
14550 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/valhalla.json)]
14553 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: arcadia.json
14553 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/arcadia.json)]
14555 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: magec.json
14555 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/magec.json)]
14558 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: eos.json
14558 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/campaign/econ/eos.json)]
14561 [Thread-5] INFO  com.fs.starfarer.campaign.econ.OoOO  - Loading star system: rock.json
14561 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: /home/peter/Documents/linuxgames/Stragey/ssdev/./mods/mi (data/campaign/econ/rock.json)]
14596 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.B.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.oO0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.O0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.OOO0.o00000(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.OOO0.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.s.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.s.processInputImpl(Unknown Source)
at com.fs.starfarer.coreui.J.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.s.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.s.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.O0OO.I.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.s.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.s.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.oO0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInputImpl(Unknown Source)
at com.fs.starfarer.campaign.save.J.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.s.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.s.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.title.B.o00000(Unknown Source)
at com.fs.starfarer.B.null.class$super(Unknown Source)
at com.fs.super.oOOO.Ò00000(Unknown Source)
at com.fs.starfarer.combat.D.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.fs.starfarer.campaign.econ.OoOO.super(Unknown Source)
at com.fs.starfarer.campaign.econ.OoOO.super(Unknown Source)
at com.fs.starfarer.campaign.econ.OoOO.super(Unknown Source)
... 32 more

At least it recgonizes the system, even if borked.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on May 10, 2015, 10:14:15 PM
... if that works. hooray. and deathfly. I friggin' love your help.

It worked, then burned. So, it seems i may've done things... incorrectly. I'll update after mussing around to see if i can't fix it myself somehow.


yeah, there are a lot of things need to be done correctly after that...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on May 11, 2015, 06:51:52 AM
here's the borked mod if anyone wants to take a look, and the resulting log segment at error.
https://www.dropbox.com/s/h3u23c6njq0qdax/miBORK.zip?dl=0

Got that one fixed. Check your PM.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on May 11, 2015, 10:56:24 AM
Quick question, Max number of fighters in a wing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ryxsen1421 on May 11, 2015, 11:26:28 AM
Quick question, Max number of fighters in a wing?

5 or 6.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 11, 2015, 11:44:55 AM
6.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sproginator on May 11, 2015, 11:47:43 AM
Good to know, thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 13, 2015, 09:16:57 PM
So I made the terrible mistake of doing a bunch of description work... And when I saved the spreadsheet and launched the mod it gives me FATAL:JSONObject ["Id"] not found. Does that mean that the spreadsheet format was somehow messed up and it no longer can find any of the ids or does that mean one id in particular?

Edit: actually I think I've found a bug. There isn't a comma in notepad between "notes" and the first id of the first description with the base file. If you press enter there it will literally break the whole file and there is nothing you can do that I have found to fix it other than redownload the game. You can't just press backspace to remove it and save the file and make it go back to normal. It still gives the same error message. It looks like something is screwy there from the last update. I will experiment more and post in the appropriate forum.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on May 13, 2015, 11:26:18 PM
Nerve EVER use Notepad or Wordpad to edit game files, for exactly that reason. You should get Notepad+ that is meant for that exact task.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on May 14, 2015, 08:55:49 AM
For the csv files it is safe (and convenient!) to use a spreadsheet editor like excel or its open office, as long as you save it in "csv" format.

Be careful of putting non-Ascii characters in the descriptions (I have no idea if SS is set up to parse them or not). The various word products are horrible about converting ascii to non that looks 'better' (I got tripped up with another project because I put "1/2" into a description. Excel converted it into a fancy looking fraction which was non ascii and my parser wasn't set up to read it).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pushover on May 15, 2015, 01:48:11 PM
For the csv files it is safe (and convenient!) to use a spreadsheet editor like excel or its open office, as long as you save it in "csv" format.

Be careful of putting non-Ascii characters in the descriptions (I have no idea if SS is set up to parse them or not). The various word products are horrible about converting ascii to non that looks 'better' (I got tripped up with another project because I put "1/2" into a description. Excel converted it into a fancy looking fraction which was non ascii and my parser wasn't set up to read it).
I have an old version of excel (2003), and any time I modify rules.csv where there are multiple lines, it breaks. I'm not convinced that it's safe.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on May 15, 2015, 06:52:53 PM
If you save csv in UTF-8 without BOM, it is save. To do this, you needs notepad++.
UTF-8 with BOM will leaves some invisible characters at the head of file and this will break it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on May 18, 2015, 12:47:55 AM
Having trouble spawning emp arcs.

When I do this, I get no arc:
Code: Java
engine.spawnEmpArc(projectile.getSource(), projectile.getLocation(), new SimpleEntity(projectile.getLocation()), new SimpleEntity(loc), //owner, location, anchor, target
                            DamageType.ENERGY, 0f, 0f, //damage stats
                            1000f, null, 12f, EMP_FRINGE_COLOR, EMP_CORE_COLOR); //maxrange, sfx, width, fringe, core

But when I do this:
Code: Java
engine.spawnEmpArc(projectile.getSource(), projectile.getLocation(), null, new SimpleEntity(loc), //owner, location, anchor, target
                            DamageType.ENERGY, 0f, 0f, //damage stats
                            1000f, null, 12f, EMP_FRINGE_COLOR, EMP_CORE_COLOR); //maxrange, sfx, width, fringe, core

I get...
Spoiler
SUPER ANAMORPHIC FLARE EXTREME!!!!!
(http://i.imgur.com/hHjfbP6.png)
[close]

I just want to spawn some emp arcs along a projectile's path... how do I do that? I've got the locations to spawn between, just how do I use them to make an actual EMP arc. It seems like I'm doing everything correctly :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on May 18, 2015, 02:45:18 AM
Having trouble spawning emp arcs.

When I do this, I get no arc:
Code: Java
engine.spawnEmpArc(projectile.getSource(), projectile.getLocation(), new SimpleEntity(projectile.getLocation()), new SimpleEntity(loc), //owner, location, anchor, target
                            DamageType.ENERGY, 0f, 0f, //damage stats
                            1000f, null, 12f, EMP_FRINGE_COLOR, EMP_CORE_COLOR); //maxrange, sfx, width, fringe, core

But when I do this:
Code: Java
engine.spawnEmpArc(projectile.getSource(), projectile.getLocation(), null, new SimpleEntity(loc), //owner, location, anchor, target
                            DamageType.ENERGY, 0f, 0f, //damage stats
                            1000f, null, 12f, EMP_FRINGE_COLOR, EMP_CORE_COLOR); //maxrange, sfx, width, fringe, core

I get...
Spoiler
SUPER ANAMORPHIC FLARE EXTREME!!!!!
(http://i.imgur.com/hHjfbP6.png)
[close]

I just want to spawn some emp arcs along a projectile's path... how do I do that? I've got the locations to spawn between, just how do I use them to make an actual EMP arc. It seems like I'm doing everything correctly :P


LOL, I got this too. And I use this as a new VFX for Adv. photon.

Any way, you can change "SimpleEntity(loc)" into an "AnchoredEntity(loc, projectile)" and leave an about 5 to 10 space between the arcFormLoc and arcToLoc(I use MathUtils.getRandomPointOnCircumference(loc, 5) for the accFormLoc). You may still got some unexpected ANAMORPHIC FLARE but at least the arc will spawn.

EDIT: Or you can spawn arcs beteewn two SimpleEntitis, and this will leave some arcs in path but...well, they may not looks good in this way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on May 31, 2015, 07:57:27 AM
Having issues with the newest version of the Crystanite; i do not know how, but when i started the game to test it a final time before releasing(i did not change anything that i know of), i am greeted by this:

Spoiler
21611 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.system.B.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Can anyone tell me whats wrong, looking at this message? I really want the next update up and running as fast as possible.

EDIT: Solved!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on May 31, 2015, 08:04:09 AM
Nevermind. It seems as though i missed a comma.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on June 01, 2015, 07:00:08 AM
Nevermind again, the comma only solved part of the problem. Now i triggered the same issue again, with the following errorcode:

Spoiler
19750 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.system.B.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

And now i get it at every startup, when i could use practically everything just fine before. Help?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on June 01, 2015, 07:18:50 AM
Nevermind again, the comma only solved part of the problem. Now i triggered the same issue again, with the following errorcode:

Spoiler
19750 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.system.B.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.title.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.new.Òôo000(Unknown Source)
   at com.fs.oOOO.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.D.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

And now i get it at every startup, when i could use practically everything just fine before. Help?

Many many many places you can get the null pointer, makes copies/versions of your files often so you can track what you've changed where. I always ask what were the last files I touched and go back from there and if necessary start disabling/moving code, features, weapons, ships etc. until the bug goes away.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on June 01, 2015, 07:21:14 AM
Problem is, the code seems to be "self sustaining"; once it triggers, i cant get my game working in the first place. Will slowly move through my files now. See you in like, um, a month?

I made a backup, but i think it has been corrupted as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on June 01, 2015, 09:04:07 AM
Found the corrupting factor; the AI somehow screwed up when attempting to use a specific ship system. Changing its AI-type solved the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 06, 2015, 11:20:42 PM
Thought I saw this a while back but is it possible to mod the amount of dissipation each vent gives when equipped?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Debido on June 06, 2015, 11:57:20 PM
Thought I saw this a while back but is it possible to mod the amount of dissipation each vent gives when equipped?

Yes, please read the bible here http://fractalsoftworks.com/starfarer.api/ And have a look at com.fs.starfarer.api.combat
Interface MutableShipStatsAPI

Specifically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on June 07, 2015, 12:37:27 AM
How do I manually start an encounter/battle between two fleets? Specifically, I want to start an engagement with the player and a fleet I just spawned on top of the player, but the hostile fleet seems to have to wait a few seconds before it starts the fight. This unfortunately gives the player a chance to run for their life. I'd like to eliminate that option so the player gets forced into combat immediately and probably dies horribly. ;)

If it helps, I am currently starting the engagement while interacting with a market.

Here's what I'm using now (has the delay that I want to get rid of):
Code: Java
        // allow immediate attack
        player.setNoEngaging(0f);      
        fleet.setNoEngaging(0f);
        
        // make the other fleet want your blood
        MemoryAPI mem = fleet.getMemoryWithoutUpdate();
        mem.set(MemFlags.MEMORY_KEY_MAKE_HOSTILE, true);
        mem.set(MemFlags.MEMORY_KEY_MAKE_AGGRESSIVE, true);
        fleet.addAssignment(FleetAssignment.INTERCEPT, player, 10f);
        
        // start the fireworks        
        dialog.dismiss();
        Global.getSector().setPaused(false);

This also doesn't work (the engagement starts exactly like I want it to, but then has zero impact on anything... all the destroyed ships come back to life and you reenter the previous dialog like nothing ever happened):
Code: Java
dialog.startBattle(new BattleCreationContext(player, FleetGoal.ATTACK, fleet, FleetGoal.ATTACK));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 08, 2015, 01:53:40 PM
I think the issue with the first case is that setNoEngaging(0f) gets overridden when the dialog is dismissed - the standard "no engaging" timer gets set then. If you add a script and set it from there as soon as the game unpauses (i.e., after the dialog is dismissed), then it should work.

The 2nd case, I don't know - this is the method the standard fleet interaction dialog uses, so it definitely works in *some* cases, and the code you're showing doesn't have any obvious issues that I can see. Must be something going on elsewhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on June 08, 2015, 07:24:10 PM
Just tested out moving the aggression/allow immediate attack code to after the dialog is dismissed/game unpaused and also to a separate script. Unfortunately, neither of those works.  :P

Is there any way to manually force an dialog interaction between two SectorEntityTokens (a player + something else)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 08, 2015, 08:08:59 PM
Try this: setNoEngaging(0f), for both fleets, in a script, after a tenth of a second has elapsed.

Also fleet.setInteractionTarget(player).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on June 10, 2015, 02:05:46 PM
Thanks, I'll give that a try as soon as I get some free time again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on June 10, 2015, 10:47:18 PM
While changing a few things here and there, I decided that the engagement time thing isn't as big of a problem as I thought. The way I'm intending to use this script, having a small delay makes more sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ahne on June 14, 2015, 02:27:10 PM
have an error on starting starsector, i wanted to test some self created weapon in a mission, without the weapons in the mod folder evrything works

http://pastebin.com/CK0YCYQB

JSONArray[1] not found

someone got an idea?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 15, 2015, 11:39:05 AM
Might be a mismatch in the number of barrels - i.e. if you've got X angle offsets and *not* X times 2 coordinates, you might see this kind of error. (Or it might be backwards - I don't remember offhand which of the two it reads first...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ahne on June 15, 2015, 01:54:26 PM
@alex, thanks!

is it possible to change the files to get plus 1 to the basic available logistic points when leveling up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ahne on June 28, 2015, 12:57:10 PM
another question, how do i get my 2 burst sized missile launcher to render it's loaded missiles again, i use
   
   "hardpointOffsets":[14, -11, 14, 11, 14, -11, 14, 11],
   "turretOffsets":[14, -11, 14, 11, 14, -11, 14, 11],
   "hardpointAngleOffsets":[0, 0, 0, 0],
   "turretAngleOffsets":[0, 0, 0, 0],
   "barrelMode":"ALTERNATING",
   "animationType":"SMOKE",
   "renderHints":[RENDER_LOADED_MISSILES],
   "interruptibleBurst":true,

in the weapon_data file i use ammo 2, ammo/reload per sec 0.1 and burst size 2 with burst delay 0.8.

If the fight starts both missiles are loaded and visible, when i have shot them they don't render again at the "barrels" but they are visible when i shot them.

What to do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 28, 2015, 01:46:11 PM
IIRC there's a (fixed in dev) bug where ammo regen, missiles, and rendering loaded missiles like that doesn't work well together for small numbers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ahne on June 28, 2015, 02:10:12 PM
wow thank you Alex for the reply and good to know, also i got it to work but not 100%, the fight begins both missiles loaded/rendered, i shot one missile and wait for ammo reloading, missiles gets replaced and rendered same with the other mounted missile BUT when i fire both then the rendering didn't functure for every reloaded ammo (i can still shot the "invisible" loaded missile in this time and it get visible once shot), if i wait until ammunition is reloaded for both mounted missiles then they get rendered again, after that aplies the same behavior as it had at the beginning of the match.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dd_dent on July 02, 2015, 02:02:06 PM
How can I meddle with in-combat commands?
Specifically add, remove or change how existing commands behave?
Also note, this doesn't have to be something the other (AI/ENEMY) side can use during combat.
Haven't seeing anything like it in the javadoc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on July 11, 2015, 07:51:34 AM
It has probably been discussed already, but I didn't manage to find what I need to know:
How do fighter config values like refit and carrier decks work? For a long time I thought that 'refit' is number of 'backup' fighters that will launch if one of the original wing members gets destroyed. But I've just made a fighter wing with num=2 and refit=2. I tested it in a mission with a carrier (2 large launch bays). I had to kill 14 (!) these fighters before the it was stated that 'XXX wing has no more replacement craft available'. How does that work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 13, 2015, 07:50:55 AM
It has probably been discussed already, but I didn't manage to find what I need to know:
How do fighter config values like refit and carrier decks work? For a long time I thought that 'refit' is number of 'backup' fighters that will launch if one of the original wing members gets destroyed. But I've just made a fighter wing with num=2 and refit=2. I tested it in a mission with a carrier (2 large launch bays). I had to kill 14 (!) these fighters before the it was stated that 'XXX wing has no more replacement craft available'. How does that work?
I'm guessing "refit" is the base amount of time it takes for a carrier to rearm/repair or replace a fighter.

Number of replacement fighters is controlled entirely by Combat Readiness; specifically, each fighter (including replacements spawned in combat) deducts CR to deploy (as specified in ship_data.csv) from the wing's current CR.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on July 13, 2015, 11:33:10 AM
Ah, I see now. I've been oblivious to that for so long =)
Now everything makes sense, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 18, 2015, 09:24:59 AM
Suppose I wanted to make certain modifications patrol fleet behavior (e.g. making fleet size and/or spawn frequency dependent on economic characteristics of the origin market). What would be a good way to go about doing this? (Is overriding CoreScript a good idea?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DinoZavarski on July 28, 2015, 06:59:26 AM
There are two ship upgrades i want to implement in a mod:

Spoiler

High-tech Systems
Thanks to the newest achievements in miniaturization and automation this ship gains small boost to all stats, has more space for other upgrades and lower maintenance cost, but in case of damage it's systems are easier to replace than to repair. Latest smart management and optimization subroutines decrease skeleton crew requirements and allow the ship to be operated effectively by staff with only basic training. The designed lack of flexibility however, combined with numerous documentation and DRM related issues results in serious performance decrease with experienced crew. Also safety protocol enforcement policies, while successful in protecting lives, prevent various dangerous overrides, that generally increase ship survivability in combat.

Stats:
-5/-10/-15/-20 space
+3% to all main specs
-5% maintenance cost
+10% Repair time
-10% minimum crew
10% less fatalities
+10/+10/-10/-30 to crew CR bonus
5% more damage taken
-10% Chance to recover if disabled

[close]

Spoiler

Lo-tech Systems
Using only well known designs, that proved their effectiveness with ages of fateful service this ship's systems are somehow bulky, slightly less effective and harder to maintain. Inexperienced crew is often clueless facing them and tends to greatly underestimate their usability. In hands of a pro however such systems are easily tuned, achieving performance that goes above and beyond the boundaries of their specs. There are various popular safety overrides, known to improve survivability of ships with such systems in combat, trough if things turn bad some of them may be deadly for crew members that implement them. Lo-tech systems are also easy to repair and there are quite a few cases where seemingly destroyed ships had their basic functionality field-restored 'with just copper wire and plastic band' as techs love to say.

Stats:
5/10/15/20 space
-3% to all main specs
+10% maintenance cost
-10% Repair time
+5% minimum crew
5% more fatalities
-20/-10/+10/+10 to crew CR bonus
5% less damage taken
+10% Chance to recover if disabled

[close]

Stats are not final and may change for balance purposes trough they look to me quite realistic (from today's point of view at least).

My question:

Is it possible to manipulate crew type CR bonuses and disabled ship post-combat recovery chance with a subsystem, on per ship basis. If there it is - how?

Without at least CR manipulation both systems are meaningless.

Be aware, i have no Java programming experience. In many cases i can figure the logic in existing code and make modifications in it, but am far from being able to write one on my own.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on August 07, 2015, 03:42:45 AM
What are the quality and hyperdrive entry in the wing_data.csv for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on August 07, 2015, 04:02:49 AM
Hyperdrive is unused and is safe to leave blank.

Quality I also believe is unused and is simply a quick reference that Alex added that is matched to the actual fighter variant quality in the .variant file. Just to be safe I would do the same :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on August 07, 2015, 04:10:04 AM
Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on August 09, 2015, 06:18:57 PM
I'm spawning a whole bunch of fighter wings and then killing them instantly.

Is there a way to suppress the "Incoming vessels: ..." and "... Wing has no more combat-capable craft remaining" messages, and keep them from appearing?


Nevermind that, using a different method now. But while we're at it, how do you add ship status messages like "SHIELDS DISABLED" to the players display (like from a system)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on August 21, 2015, 10:34:02 AM
How would I go about making a hullmod that doubles shield efficiency but causes hull damage when the shield takes a hit? Is this sort of thing even possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on August 21, 2015, 10:56:01 AM
That's rather easy with a small twist: the only way to gain hard flux is to take damage on the shield. Then it's a piece of cake to translate that to a hull reduction. Soft flux damage however would be more difficult to asses.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on August 21, 2015, 01:29:28 PM
Thanks for the help. I'll have to think about how to get beams working though...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xanderzoo on August 21, 2015, 02:27:24 PM
I just realized I don't know how to apply hull damage. Everything else is working, but I can't find any way to apply hull damage.  :-\

EDIT: Never mind, I figured it out. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 24, 2015, 07:14:22 AM
I know you can remove mounts with ship skins, but can you add them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on August 24, 2015, 07:25:47 AM
simple: you can't. Skins really are not that usefull, you can't do much modification, and the variants aren't compatibles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 24, 2015, 07:34:28 AM
Alright, that's what I thought. Maybe someday.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lcu on August 24, 2015, 07:48:01 AM
In my opinion it would be easier if you made a different hull.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 24, 2015, 07:56:15 AM
That's what I did before I asked. ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on August 25, 2015, 03:10:29 AM
You can create all slots in base hull and make unused hidden. Then make a variant and change slot type, that should work (for custom hulls of course).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on September 01, 2015, 12:48:18 AM
Running into an error with my new mod, i have been searching for a couple of hours but i am coming up empty. Does someone know what i am doing wrong?

Spoiler
20139 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Error compiling [data.scripts.VortexModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.VortexModPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.VortexModPlugin
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]

VortexModPlugin compiles properly in IDEA. I really do not know what i have managed to break this time. I am attaching the src folder.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on September 01, 2015, 08:51:15 AM
Running into an error with my new mod, i have been searching for a couple of hours but i am coming up empty. Does someone know what i am doing wrong?

Spoiler
20139 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Error compiling [data.scripts.VortexModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.VortexModPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.VortexModPlugin
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]

VortexModPlugin compiles properly in IDEA. I really do not know what i have managed to break this time. I am attaching the src folder.

Hard to say without seeing any code, though if I had to guess I'd say your class isn't packaged correctly. (Its file path doesn't match its expected package)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on September 01, 2015, 10:01:23 AM
Running into an error with my new mod, i have been searching for a couple of hours but i am coming up empty. Does someone know what i am doing wrong?

Spoiler
20139 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.RuntimeException: Error compiling [data.scripts.VortexModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.VortexModPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.VortexModPlugin
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]

VortexModPlugin compiles properly in IDEA. I really do not know what i have managed to break this time. I am attaching the src folder.

Hard to say without seeing any code, though if I had to guess I'd say your class isn't packaged correctly. (Its file path doesn't match its expected package)

The code is packaged in the .zip i sent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on September 01, 2015, 10:26:31 AM
I'm guessing you haven't told starsector about the plugin in settings.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jay2Jay on September 20, 2015, 12:57:13 PM
Is it possible (aka how) to make it so that you must buy hullmods in order to unlock them, or that when you gain a ship you gain the use of the hullmods that it has attached to it without relying on unlocking them from the exp tree? Also if you want to use the same hullmod on a different ship, you must buy/aquire another instance of that hullmod.

This is so I can put flat out "upgrade" hullmods into the game while still having some semblance of balance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on September 20, 2015, 01:56:41 PM
Is it possible (aka how) to make it so that you must buy hullmods in order to unlock them, or that when you gain a ship you gain the use of the hullmods that it has attached to it without relying on unlocking them from the exp tree? Also if you want to use the same hullmod on a different ship, you must buy/aquire another instance of that hullmod.

This is so I can put flat out "upgrade" hullmods into the game while still having some semblance of balance.

Yes, it's possible. Here's an example from the ancient CAELUS mod (I cleaned up the code a bit, but it might still need tweaking):

Code: java
package data.hullmods;

import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.fleet.FleetMemberAPI;

public class EliteTweak extends BaseHullMod
{
    // The ID of the persistent data for unlocked hulls in the current campaign
    private static final String UNLOCKED_DATA_ID = "elite_tweak_unlocked_hulls";
    private static final Map<HullSize, String> REQUIRED_CARGO = new HashMap();

    static
    {
        // These are all items defined in data/campaign/resources.csv
        // A separate item for each hullsize allows different pricing tiers
        REQUIRED_CARGO.put(HullSize.FRIGATE, "shipmanual_frigate");
        REQUIRED_CARGO.put(HullSize.DESTROYER, "shipmanual_destroyer");
        REQUIRED_CARGO.put(HullSize.CRUISER, "shipmanual_cruiser");
        REQUIRED_CARGO.put(HullSize.CAPITAL_SHIP, "shipmanual_capital");
    }

    private static boolean inCampaign()
    {
        // There's probably a better way of doing this these days, but meh, lazy
        return (Global.getSector() != null
                && Global.getSector().getPersistentData() != null);
    }

    public static List<String> getUnlockedHulls()
    {
        // This should never trip, but just in case...
        if (!inCampaign())
        {
            return new ArrayList();
        }

        final Map<String, Object> persistentData = Global.getSector().getPersistentData();
        List<String> hulls = (List<String>) persistentData.get(UNLOCKED_DATA_ID);

        // Persistent data for hullmod unlocks not found? Create it!
        if (hulls == null)
        {
            hulls = new ArrayList<>();
            persistentData.put(UNLOCKED_DATA_ID, hulls);
        }

        return hulls;
    }

    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id)
    {
        // < INSERT HULLMOD EFFECT CODE HERE >
        

        // If we're in a mission, our job is done
        // The rest of this method just checks if we should remove the unlock item
        if (!inCampaign())
        {
            return;
        }

        // Already unlocked for this hull? Don't remove any more unlocking items
        final String hullId = ship.getHullSpec().getBaseHullId();
        if (getUnlockedHulls().contains(hullId))
        {
            return;
        }

        // Is this ship in an NPC fleet? NPCs get it for free ;)
        final CampaignFleetAPI player = Global.getSector().getPlayerFleet();
        boolean inPlayerFleet = false;
        for (FleetMemberAPI member : player.getFleetData().getMembersListCopy())
        {
            if (member.getId().equals(ship.getFleetMemberId()))
            {
                inPlayerFleet = true;
                break;
            }
        }
        if (!inPlayerFleet)
        {
            return;
        }

        // Otherwise, remove the unlocking item...
        String requiredCargo = (String) REQUIRED_CARGO.get(ship.getHullSize());
        Global.getSector().getPlayerFleet().getCargo().removeItems(
                CargoItemType.RESOURCES, requiredCargo, 1f);

        // .. and permanently unlock this hullmod for this hull type
        getUnlockedHulls().add(hullId);
        Global.getSector().getCampaignUI().addMessage(
                "Elite Tweak hullmod unlocked for all ships of class "
                + ship.getHullSpec().getHullName() + ".", Color.GREEN);
    }

    @Override
    public boolean isApplicableToShip(ShipAPI ship)
    {
        // In a mission? Return true
        if (!inCampaign())
        {
            return true;
        }

        // In campaign and hullmod is already unlocked? Return true
        if (getUnlockedHulls().contains(ship.getHullSpec().getHullId()))
        {
            return true;
        }

        // In campaign, locked, and we have the proper unlock item? Return true
        final String requiredCargo = REQUIRED_CARGO.get(ship.getHullSize());
        return (Global.getSector().getPlayerFleet().getCargo()
                .getQuantity(CargoItemType.RESOURCES, requiredCargo) >= 1f);
    }
}


That unlocks based on the base hull ID so it's permanently unlocked for a hull plus all its skins with one item, but you could trivially change it to unlock per hull size, or even only unlock a single ship by using ship.getFleetMemberId().

That code should also unlock the hullmod if you obtain a ship with it already installed, but I can see a minor bug where it will still remove the unlocking item if you have one in the inventory.

This script used the old resource system. I'm not sure how well an item-based unlock will work post-market update, so if you need to unlock it through a script you can call getUnlockedHulls() (or equivalent) and modify that directly, or add methods to do it properly. You know, if you're not lazy like myself. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jay2Jay on September 21, 2015, 07:47:50 AM

Yes, it's possible. Here's an example from the ancient CAELUS mod (I cleaned up the code a bit, but it might still need tweaking):


Thank you sir.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on September 26, 2015, 02:08:38 PM
Is there a way to fix the angles that MIRV submunitions emerge from their parent projectile at? Nothing fancy, and no particular reason, I'd just like to have them evenly-spaced.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 28, 2015, 01:16:49 PM
Is there any way (hacky or not) to force pursuers in an escape mission to only appear behind the player's ships? I'm using a narrow map so if ships appear on the sides in front of the escaping ship it looks weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2015, 08:36:24 PM
Is there a way to fix the angles that MIRV submunitions emerge from their parent projectile at? Nothing fancy, and no particular reason, I'd just like to have them evenly-spaced.

Pretty sure there isn't, beyond doing some custom scripting. There's an:
"evenSpread":true,
Which does what you want but I'm fairly certain it's not in the currently-released version.

Is there any way (hacky or not) to force pursuers in an escape mission to only appear behind the player's ships? I'm using a narrow map so if ships appear on the sides in front of the escaping ship it looks weird.

BattleCreationContext.setFlankDeploymentDistance(1000) should make it so that stuff that's deployed from the side is deployed near the bottom of the map. So: hacky, but would probably at least improve the situation in your case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 29, 2015, 09:20:24 AM
I tried setFlankDeploymentDistance using the format of the mission "Dire Straights", but it didn't do anything. -1000, 0, 1000, 5000, etc. all got the same result as not having the function call at all.
Code: java
BattleCreationContext context = new BattleCreationContext(null, null, null, null);
context.setFlankDeploymentDistance(1000);
api.addPlugin(new EscapeRevealPlugin(context));

I also messed with these functions - they didn't seem to do anything either.
setInitialEscapeRange
setInitialDeploymentBurnDuration
setEscapeDeploymentBurnDuration
setPursuitRangeModifier
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2015, 10:49:42 AM
Right, what's happening there is the context is a dummy context just to make the EscapeRevealPlugin work; it's not the actual context used by the engine. Also known as "a hack". The reason it's doing that is during mission definition, the engine hasn't been created yet, and the real context doesn't exist. During battle creation in the campaign, which is what EscapeRevealPlugin was originally written for, you get a context passed in that's the "real" one, but MissionDefinition doesn't use that, being older code.

So, what you want to do is run setFlankDeploymentDistance on the real context, before any stuff has been deployed. I think something like this should work:

Code: java
api.addPlugin(new BaseEveryFrameCombatPlugin() {
@Override
public void advance(float amount, List events) {
Global.getCombatEngine().getContext().setFlankDeploymentDistance(1000);
}
});

That way you'll run setFlankDeploymentDistance when the context actually exists, when the engine is initializing the combat plugins.

Just doing:
Code: java
Global.getCombatEngine().getContext().setFlankDeploymentDistance(1000);
from the MissionDefinition wouldn't work because at that point the context (or the engine) doesn't exist. You'd, iirc, just get a benign dummy version of the engine so it probably wouldn't crash, but it wouldn't do anything either. But wrapping it in a plugin ensures it's called at the right time.

(Sorry, I was sort of assuming you were doing this in a campaign battle and not a mission, or I'd have mentioned this earlier. You did say "mission", but it just didn't register.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DeathRay on September 29, 2015, 11:04:40 AM
I'm currently thinking about making my own mod and wanted to ask in advance,
if it is possible to decrease CR and/or peakperformance in combat by using a shipsystem?

(Currrently hoping for increasing CR deterationrate?? and decreasing maximum Peakperformance,
while keeping the ratio of maxpeak to remainingpeak, by "simply" ::) multiplying by a factor, as long as the shipsystem is active.)

PS:
Sorry for the grammar.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 29, 2015, 11:40:42 AM
That code doesn't work since it can't find "Global". :-\ Importing com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin doesn't change anything.

That's about all I can figure out. Only barely have a clue what I'm doing with Java.

Edit: To clarify - the game crashes when the loading bar fills before the main menu appears.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2015, 12:08:32 PM
That code doesn't work since it can't find "Global". :-\ Importing com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin doesn't change anything.

That's about all I can figure out. Only barely have a clue what I'm doing with Java.

Edit: To clarify - the game crashes when the loading bar fills before the main menu appears.

Right, you need to import EveryFrameCombatPlugin, so that's good. You also need to import Global; see here for what package it's in:
http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html
http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/Global.html


I'm currently thinking about making my own mod and wanted to ask in advance,
if it is possible to decrease CR and/or peakperformance in combat by using a shipsystem?

(Currrently hoping for increasing CR deterationrate?? and decreasing maximum Peakperformance,
while keeping the ratio of maxpeak to remainingpeak, by "simply" ::) multiplying by a factor, as long as the shipsystem is active.)

PS:
Sorry for the grammar.



Should be doable, I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on September 29, 2015, 12:10:09 PM
I'm currently thinking about making my own mod and wanted to ask in advance,
if it is possible to decrease CR and/or peakperformance in combat by using a shipsystem?
You can modify the timer via the Mutable Stats, and CR directly in the shipAPI.

Is there any way (hacky or not) to force pursuers in an escape mission to only appear behind the player's ships? I'm using a narrow map so if ships appear on the sides in front of the escaping ship it looks weird.
This is a script I took from DR to force the deployment of the enemy force on the top of the map, but should work to force the deployment to the bottom in a pursuit scenario. Though I believe it require compiling.
Code: Java
    private static final class Plugin extends BaseEveryFrameCombatPlugin {

        private boolean done = false;
        private final float mapX;
        private final float mapY;
        private float timer = 5f;

        private Plugin(float mapX, float mapY) {
            this.mapX = mapX;
            this.mapY = mapY;
        }

        @Override
        public void advance(float amount, List<InputEventAPI> events) {
            if (done || Global.getCombatEngine() == null || Global.getCombatEngine().isPaused()) {
                return;
            }

            timer -= amount;
            if (timer <= 0f) {
                for (FleetMemberAPI member : Global.getCombatEngine().getFleetManager(FleetSide.ENEMY).getReservesCopy()) {
                    if (!Global.getCombatEngine().getFleetManager(FleetSide.ENEMY).getDeployedCopy().contains(member)) {
                        Global.getCombatEngine().getFleetManager(FleetSide.ENEMY).spawnFleetMember(member, getSafeSpawn(FleetSide.ENEMY, mapX, mapY), 270f, 1f);
                    }
                }
                done = true;
            }
        }

        @Override
        public void init(CombatEngineAPI engine) {
            }

                private static Vector2f getSafeSpawn(FleetSide side, float mapX, float mapY) {
            Vector2f spawnLocation = new Vector2f();

            spawnLocation.x = MathUtils.getRandomNumberInRange(-mapX / 2, mapX / 2);
            if (side == FleetSide.PLAYER) {
                spawnLocation.y = (-mapY / 2f);

            } else {
                spawnLocation.y = mapY / 2;
            }

            return spawnLocation;
        }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DeathRay on September 29, 2015, 01:30:55 PM
Thanks for the answers
and help :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 29, 2015, 04:15:08 PM
Thanks Alex! That got it working.

This is a script I took from DR to force the deployment of the enemy force on the top of the map, but should work to force the deployment to the bottom in a pursuit scenario. Though I believe it require compiling.

While that probably does exactly what I'd like, I have no idea how to implement it. ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 03, 2015, 04:39:27 AM
Does anyone know what "viewOffset" value in hull json stands for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 05, 2015, 07:16:22 AM
Does the event manager cache primary entities by market?

The exile colony fleet in the ICE mod has a market (temporarily attached to a hidden star when the fleet loses its colony ship, moved back when a new fleet is spawned). I've noticed that the event manager will add food shortages to the now-marketless fleet (I can tell because the event reports are missing the market-related tokens), which causes a crash when the shortage ends and it tries to cause recent unrest.
This happens even though the market condition ends up in the market as it should, and CoreEventProbabilityManager checks and increments probability by market rather than entity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on October 05, 2015, 08:02:40 AM
Food shortages have a gestation period, taking some time to start after being first initialized.  In theory, this will cause their entity to be set well before the actual event reaches the start stage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 05, 2015, 10:13:12 AM
Does anyone know what "viewOffset" value in hull json stands for?

It's not used anywhere for anything, iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 06, 2015, 08:11:10 AM
Does anyone know what "viewOffset" value in hull json stands for?

It's not used anywhere for anything, iirc.
Thanks for info, I was suspecting that it is not really used)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: D00D on October 11, 2015, 10:30:06 PM
Cross posting from the sprite art thread:

Is it possible to use a gif as a ship spite so that you can make transforming ships with a changing hitbox? Weapon mounts isn't a issue since I intend to hide it under the ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on October 14, 2015, 08:46:31 PM
So, it's been a long time (a REALLY long time, more than two years since I last made a mod.info file) since I last actually modded the game - the people who made these wonderful mods have just outstripped me with their pretty in-depth code and jumble that I don't understand yet.  But, I'm getting curious again, so I've dipped my toe back in.

So, what I'm about to ask is so unbelievably simple that it pales in comparison to the rest of the stuff here, but how the hell do you take advantage of the (relatively) new MIRV capabilities?  More specifically, how to make it spawn projectiles instead of regular missiles like the Hurricane MIRV or SABOT.  Now, I know that the Scy mod has a Laser Torpedo, but I looked into it for some inspiration and found that it uses it's own code to spawn that stuff.  Which I have no intentions of learning right now after two years of absence.  Just the simple stuff with the terrible vanilla MIRV AI - how do you spawn projectiles?
(by the way - yes, that functionality was supposedly added in the 0.65a update, but I've never seen an example of it)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 14, 2015, 10:27:49 PM
Check out hurricane.wpn - you'll see a line that says:
"projectileSpecId":"type_1_mirv",

Open up type_1_mirv.proj to see how that's all set up. There's a:
"behaviorSpec":{"behavior":"MIRV",
With all the details. It involves yet another .proj file for the actual warhead.

There's no scripting involved here, it's all done through the .wpn and the .proj files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on October 15, 2015, 07:38:47 AM
@Alex
Yes, I understand the part with the details of a regular MIRV warhead - I haven't forgotten quite everything. ;) But the details of MIRV to let a projectile instead of a missile or rocket to function is the bit I can't get right.  Things like the hitpoints of the MIRV warhead won't be used with a projectile, and there needs to be a defined range for it (which I've seen in the SABOT warhead, but commented out).  I've tried it with the health on, without the health, with the projectileRange on and off, and a combination of all 4 and it's not working (I'm using heavymg_shot as the test projectile for reference).  Is there something I'm missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 15, 2015, 10:51:35 AM
Hmm. Just did this in type_1_mirv.proj:

#"projectileSpec":"mirv_warhead",
"projectileSpec":"heavyac_shot",

And it seems to work. Might be due to changes in the dev version, though, so not 100% sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on October 15, 2015, 12:00:11 PM
So, making the Hurricane MIRV shoot Light Autocannon bullets worked fine on my end.  But it's not working in a mod.

Probably something in my mod structure.  Urg, it's been way too long....

EDIT:
So, turns out using OpenOffice to save a .csv file screws up the format.  I did everything perfectly fine, except the format of the .csv was screwed up.  Got it working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on October 15, 2015, 03:10:22 PM
(http://i.imgur.com/sE0SzBw.png)

Useful reference for others that are new to OpenOffice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on October 15, 2015, 03:18:19 PM
So, making the Hurricane MIRV shoot Light Autocannon bullets worked fine on my end.  But it's not working in a mod.

Probably something in my mod structure.  Urg, it's been way too long....

EDIT:
So, turns out using OpenOffice to save a .csv file screws up the format.  I did everything perfectly fine, except the format of the .csv was screwed up.  Got it working.

When making weapons (especially complicated stuff like MIRVs), it's useful to start off with a vanilla weapon as a template. Source: am dirty MIRV lover.

And you need to make sure that your .csv editor is exporting things in a "UTF-8 without BOM" encoding... I've had issues with other character encodings not working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on October 15, 2015, 03:22:59 PM
When making weapons (especially complicated stuff like MIRVs), it's useful to start off with a vanilla weapon as a template. Source: am dirty MIRV lover.
Dude, I haven't forgotten everything about modding. xD That's probably the first thing anyone does.  That kind of advice pretty much pertains to everything coding and modding related, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: D00D on October 18, 2015, 07:18:27 AM
Hi, is there a way to create your own hull mod? I seen many people asking about how to create weapons (I would like to know too) but how for the moment I would like to make faction hull mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on October 19, 2015, 11:50:41 AM
Hi, is there a way to create your own hull mod? I seen many people asking about how to create weapons (I would like to know too) but how for the moment I would like to make faction hull mods.
Sure there is. You should make an entry in your hull_mods.csv file, fields there should be self-explanatory. For 'script' field you should supply a class that looks approximately like this:
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class AcceleratedShieldEmitter extends BaseHullMod {

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
//apply your stat changes here
}

public String getDescriptionParam(int index, HullSize hullSize) {
//here return values for substitution in hullmod description depending on their index
}

public boolean isApplicableToShip(ShipAPI ship) {
//return some condition if you want (or just true)
}
}
Class should be either in JAR or in java file in hullmods folder
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Draba on October 19, 2015, 05:45:09 PM
Does anyone know about an easy way to disable the degraded stats on boarded ships?
Config would be nice but I didn't find anything at a glance so I'm ok with doing minor code changes, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 19, 2015, 05:52:31 PM
Boarded ships don't have degraded stats in vanilla. Two options - 1) you're playing with a mod that does this, or 2) you've boarded a (D) variant of a ship that had permanently degraded stats to begin with.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 19, 2015, 06:51:01 PM
In the "hulls" folder there is a "skins" folder. If you open the "_d" .ship files in there you can delete the built-in negative hull-mods. A couple ships like the Wolf have removed weapon mounts; it's in the same file so you shouldn't miss it. I recommend creating a backup of the folder before you do anything, or better yet do the modifications as a mod in the "mods" folder.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Draba on October 20, 2015, 04:26:41 AM
Boarded ships don't have degraded stats in vanilla. Two options - 1) you're playing with a mod that does this, or 2) you've boarded a (D) variant of a ship that had permanently degraded stats to begin with.

Yep, first run with SS+/all the factions. To be sure I've started a vanilla game and scummed a boarding, it's
3) Didn't notice that the boarded ships are shot to hell and have the low combat readiness penalty applied to them in the display.
Thought it's a new feature, my bad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 20, 2015, 07:51:24 PM
Is it possible to detect when damage is coming from a collision, like with an asteroid, and reduce it with a hullmod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2015, 08:09:06 PM
Is it possible to detect when damage is coming from a collision, like with an asteroid, and reduce it with a hullmod?

I don't believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on October 20, 2015, 08:39:38 PM
Is it possible to do the weapon glow (like the one done in AmmoFeed) via script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2015, 08:46:21 PM
No, but it turned out trivial to expose. Added:
ShipAPI.setWeaponGlow(float glow, Color color, EnumSet<WeaponType> types)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 20, 2015, 09:40:10 PM
I'm trying to play around with KineticDamageTakenMult, but I can't seem to get it to work.

Code: java
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;

public class AdvancedAsteroidAvoidance extends BaseHullMod {

private static final float DAMAGE_REDUCTION = 50f;

public void applyEffectsBeforeShipCreation(MutableShipStatsAPI stats, String id) {

stats.getKineticDamageTakenMult().modifyMult(id, 1f - DAMAGE_REDUCTION * 0.01f);
}

}

I just have it as a .java file sitting in data/hullmods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2015, 09:49:42 PM
"Can't get it to work" is awfully vague. The code for the hullmod looks right, though.

Assuming you've got a hullmod pointing to this .java file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 20, 2015, 09:52:45 PM
Yeah, I do. What I mean is I'm not noticing any effect on kinetic damage to hull or armor no matter how extreme of values I put it in there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2015, 09:55:26 PM
Oh, hey: the method signature should be
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)

That's probably it. Unless this is a 0.7a thing? I don't remember changing it but it's possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2015, 09:57:17 PM
Also: this wouldn't apply to shields. There's getKineticShieldDamageTakenMult() for that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 20, 2015, 10:04:01 PM
Blargleflargle, I took out the hullsize stuff since I wasn't using it. Put it back in and tested with DAMAGE_REDUCTION = 5000f. Kinetic damage did nothing! :P ;D

Thanks Alex!

Also: this wouldn't apply to shields. There's getKineticShieldDamageTakenMult() for that.

Saw that when I was looking through initially, but I just wanted hull/armor. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2015, 10:07:15 PM
Cool. Yeah, you can't just take parameters out if you're not using them, that doesn't work :)

If you're wondering why it didn't error out: it was calling the applyEffectsBeforeShipCreation from the BaseHullMod class instead. Basically, your code added a *new* method (which nobody at all was calling), as opposed to overriding a method from the base class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on October 21, 2015, 07:37:41 AM
Is there a certain way getDamageAmount() in DamagingProjectileAPI needs to be used? I'm using it in a OnHitEffectPlugin and it seems to only return 0.

EDIT: nevermind, found out the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MasterEthereal on October 22, 2015, 07:43:35 PM
I am currently working with the commodities Exel sheet to add several additional crew types to the game. I am having problems finding the script file that runs this Exel sheet though.

Can anyone help me find this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on October 26, 2015, 08:58:20 AM
I was wondering two things:
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2015, 11:00:00 AM
I am currently working with the commodities Exel sheet to add several additional crew types to the game. I am having problems finding the script file that runs this Exel sheet though.

Can anyone help me find this?

I don't know exactly what you're trying to do, but it seems like it might work in general - the crew types are specified in the commodities spreadsheet, yes, but how they're used/crew assignment/etc is handled in the core code and these 4 crew types are hardcoded there.


I was wondering two things:
  • Does getCurrFlux() include Hard Flux?
  • Is there a way to stop a ship from getting the 0 flux boost besides constantly giving it a small amount of flux?

1) Yes.
2) setting MutableShipStatsAPI.getZeroFluxMinimumFluxLevel() to something below zero should do it. e.g.
getZeroFluxMinimumFluxLevel().modifyFlat(id, -1000);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Luna on October 26, 2015, 02:47:01 PM
Welp. I've finally been motivated to get back to work on The Confederacy of Free Stars after many many months. Yay, procrastination! w00t

Alrighty. So all the code's there. Everything I need to be making a .jar is there, and I have been making jars. Thing is, they're not compiling correctly. I've been using IntelliJ IDEA to compile it with, but once I slap the .jar file into the mod's folder and boot the game up, I get highly disappointed after a full loading bar with the error message:

Fatal: Error compiling [data.scripts.CoFSModPlugin]
Cause: Invalid signature file digest for Manifest main attributes
Check starsector.log for more info.

And that's what I did. Completely incomprehensible to me, probably because I'm quite inexperienced with coding.

So, if anyone could be nice enough to tell me what exactly it is I'm doing wrong? I made a promise to InfinitySquared a while ago that I would fix his mod, and I think I've killed enough time.

Anyways, the .jar and starsector.log are below.

Downloaderooni! (https://www.dropbox.com/s/5wc9hohmutbxd6x/Borken%20CoFS.zip?dl=0)

(https://i.imgflip.com/fmohn.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on October 30, 2015, 02:16:42 PM
What's the best way to detect the complete destruction of the player's fleet?

CampaignEventListener's reportPlayerEngagement() won't catch death spirals from accidents, and reportFleetDespawned() doesn't seem to trip for the player fleet. Is an EveryFrameScript occasionally checking if the fleet ID has changed the way to go, then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 30, 2015, 04:50:27 PM
Just checked and reportFleetDespawned() seems to be called for the player fleet in 0.7a. That aside, yeah, checking if the fleet id changed would definitely work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on October 31, 2015, 06:43:04 AM
I am trying to modify some of the vanilla weapons for my mod and wanted to use the IR pulse laser, how can I set it to be a point defence. And are there any 3 barrel vanilla weapons that I can modify(if not can anyone tell me how to make a triple barrel turret, I have the sprite but not sure on the data files)

Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 31, 2015, 07:36:01 AM
You can tell the AI a weapon is PD in the weapons.csv file. The second to last column is labeled "hints"; just put "PD" on the appropriate row for your weapon.

The Heavy Autocannon is a triple barrel weapon. The way it works is it has 3 pairs of offsets coordinates in its .wpn file instead of 1 like a single barreled weapon. A weapon with multiple offsets will fire multiple shots at full damage for the flux of one shot, so make sure to compensate for that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on October 31, 2015, 07:41:39 AM
Ah thanks a lot Hartlord. I'll get round to doing that later and trying it out.    :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on October 31, 2015, 02:22:22 PM
Hello!

I was making my fighter/carrier mod and was wondering how to initiate devmode from a mission so u can control+click on a fighter and use it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on October 31, 2015, 03:10:52 PM
Have you tried the console commands mod, that has a devmode command but I've never used it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on October 31, 2015, 04:14:48 PM
Have you tried the console commands mod, that has a devmode command but I've never used it.

I mean an automatic change, not something that you would have to type in at the beginning of a battle.

So you can play without devmode, click on the mission, and for its duration, you will be playing in devmode.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 31, 2015, 07:49:56 PM
Hello!

I was making my fighter/carrier mod and was wondering how to initiate devmode from a mission so u can control+click on a fighter and use it?
Global.getSettings().setDevMode(true);

(but I haven't found an "easy" way to turn it back off afterwards)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 01, 2015, 04:50:12 AM
@LunaIsBestPony: Can't say what the exact cause of the error is, but your .jar seems to have all kinds of weird junk in it:

Spoiler
(http://i.imgur.com/Pxt46iG.png)
[close]

Check your IDE build/compile settings maybe?
(unfortunately I use Netbeans so I can't really help you here, try poking around in your settings and Google for help)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 01, 2015, 09:02:15 AM
Hello!

I was making my fighter/carrier mod and was wondering how to initiate devmode from a mission so u can control+click on a fighter and use it?
Global.getSettings().setDevMode(true);

(but I haven't found an "easy" way to turn it back off afterwards)

Maybe restarting SS immediately afterward?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2015, 10:18:10 AM
Global.getSettings().setDevMode(true);
(but I haven't found an "easy" way to turn it back off afterwards)

Alright, let's go for the obvious - have you tried:
Global.getSettings().setDevMode(false);
?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 01, 2015, 01:38:17 PM
Global.getSettings().setDevMode(true);
(but I haven't found an "easy" way to turn it back off afterwards)

Alright, let's go for the obvious - have you tried:
Global.getSettings().setDevMode(false);
?

Well,
    public void defineMission(MissionDefinitionAPI api) {

this only defines a mission.
So It would be nice to have a method called onCombatEnd() where you can tell it to turn off dev Mode for missions only
otherwise when you set devmode false, it never actually becomes on during the mission, as they're in the same method.


ALSO, how can you force the enemy fleet to deploy a buffalo to combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2015, 02:32:52 PM
Ah, gotcha.

For deploying stuff, you can try using the CombatFleetManagerAPI.spawnFleetMember() in a script - afaik, that should work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 01, 2015, 03:18:50 PM
Ah, gotcha.

For deploying stuff, you can try using the CombatFleetManagerAPI.spawnFleetMember() in a script - afaik, that should work.

umm, yeah, I'm kinda new to coding... could you please explain what the parameters want?

spawnShipOrWing(java.lang.String specId, Vector2f location, float facing)
          Deploy a ship/fighter wing with the given spec or variant id.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2015, 03:38:32 PM
(Side question: are you using some kind of IDE? If not, you're *really* making life difficult for yourself in the long run. Going to assume you're aware of the
javadoc (http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html), since it looks like you pasted from it.)

Basically, what you want to do is:
1) Get a hold of the player-side CombatFleetManagerAPI, using Global.getCombatEngine().getPlayerFleetManager().
2) Figure out which fleet member from the reserves you want to deploy, using the CombatFleetManagerAPI (iirc, there's a getReserves() method there)
3) Deploy it using the spawnShipOrWing method. The first parameter is the variant id, which you can get using FleetMemberAPI.getId(). The other two are a location and a facing for the new ship, which is what their names are, so I'm not sure I'm being entirely helpful with those two :)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 01, 2015, 04:02:27 PM
Yeah I'm gonna stick with notepad.

I'll keep working on it and maybe I'll get it to work in a couple days. THANKS!!!

EDIT:


The wing is a custom buffalo wing with 5 buffalo's as bombers. Unfortunately, the enemy AI doesn't want to deploy them.
My new code gives fatal errors when clicking on the mission, but compiles.

import org.lwjgl.util.vector.Vector2f;
...(code)
Global.getCombatEngine().getFleetManager(FleetSide.ENEMY).spawnShipOrWing("buffalo_wing",new Vector2f(0,0), 90f);



BTW when I mean I'm gonna do it in a couple days, I mean I'm not going to sleep till I get it to work...

17592 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.movement.maneuvers.for.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.movement.maneuvers.OooO$o.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.movement.maneuvers.OooO.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2015, 04:31:21 PM
Yeah I'm gonna stick with notepad.

Fair enough :)

I'll keep working on it and maybe I'll get it to work in a couple days. THANKS!!!

Good luck!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 09, 2015, 12:34:14 PM
OK.

Well, I got nowhere, but am now using NetBeans. My code compile, but crashes when you click on the mission. Do you know what is wrong with it?


CombatFleetManagerAPI engine = Global.getCombatEngine().getFleetManager(FleetSide.ENEMY);

engine.spawnShipOrWing("buffalo_wing",new Vector2f(0,0), 90f);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on November 10, 2015, 07:51:17 PM
Yeah I'm gonna stick with notepad.

I read that and died a little inside. Use Intellij IDEA- it's pretty fabulous.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 10, 2015, 09:23:56 PM
OK.

Well, I got nowhere, but am now using NetBeans. My code compile, but crashes when you click on the mission. Do you know what is wrong with it?


CombatFleetManagerAPI engine = Global.getCombatEngine().getFleetManager(FleetSide.ENEMY);

engine.spawnShipOrWing("buffalo_wing",new Vector2f(0,0), 90f);
It is not very helpful to see only the code, we need the error itself too to advise something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 11, 2015, 07:26:51 AM
OK.

Well, I got nowhere, but am now using NetBeans. My code compile, but crashes when you click on the mission. Do you know what is wrong with it?


CombatFleetManagerAPI engine = Global.getCombatEngine().getFleetManager(FleetSide.ENEMY);

engine.spawnShipOrWing("buffalo_wing",new Vector2f(0,0), 90f);
It is not very helpful to see only the code, we need the error itself too to advise something.



Here is the error, something to do with .advance, as I have seen other mods using some kind of "advance" function but didn't know what it did:

17592 [Thread-5] ERROR com.fs.starfarer.combat.D  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.movement.maneuvers.for.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.movement.maneuvers.OooO$o.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.movement.maneuvers.OooO.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 11, 2015, 03:24:36 PM
GREAT SUCCESS!!!!!!!!


api.addPlugin(new BaseEveryFrameCombatPlugin() {

   public void advance(float amount, List events) {
   }

   public void init(CombatFleetManagerAPI engine) {
      engine.spawnShipOrWing("buffalo_wing",new Vector2f(0,0), 90f);
   }

});            

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2015, 04:04:48 PM
Try spawning a ship rather than a wing; I suspect something might be mucked up in your fighter wing config. (Do you have a wing_data.csv entry etc?)

Ships are slightly easier so I'd get that working first.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mangalore on November 16, 2015, 02:57:54 PM
I'm trying to add two ships to my game.

Added .ship files, added sprites, added them into CSV. Game loads without a problem.

Now my question is: How do I find them in a game?

Simple question: Is there a cheat code? Mainly want to check if the weapon configuration seems okay.
Bigger question: How do I add them to markets/factions?

Do I need variants for that?

THX!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on November 16, 2015, 10:40:43 PM
You will need at least one .variant, in order to be able to call it in to the game.

I test things by using a 'test' mission, and adding the variant to the list of ships on your side - you can then refit / simulate etc. to your hearts content, test out different variants etc.

To have it spawn generally in the campaign, the variant should appear (by function e.g. CombatLarge, FreighterMedium etc.) in the relevant .faction file, located in /modname/data/world/factions/.

There is a .variant type called shipname_Hull which is self generated by the game, and has no weapons/hullmods etc. but whether it is spawned for sale is dependent on both the relative frequency of it appearing in the .faction list (and by type, to suit different markets e.g. Civilian/Military) and the variant quality factor (high quality only in stable markets)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mangalore on November 17, 2015, 09:55:59 AM
You will need at least one .variant, in order to be able to call it in to the game.

I test things by using a 'test' mission, and adding the variant to the list of ships on your side - you can then refit / simulate etc. to your hearts content, test out different variants etc.

To have it spawn generally in the campaign, the variant should appear (by function e.g. CombatLarge, FreighterMedium etc.) in the relevant .faction file, located in /modname/data/world/factions/.

There is a .variant type called shipname_Hull which is self generated by the game, and has no weapons/hullmods etc. but whether it is spawned for sale is dependent on both the relative frequency of it appearing in the .faction list (and by type, to suit different markets e.g. Civilian/Military) and the variant quality factor (high quality only in stable markets)

Ah, okay. Had a small hen egg issues concerning variants as I had no clue how to do them and if my design basically works. I edited my save file to have two hulls in my vicinity changed into the new hulls. Worked quite nicely, the bloody faction even didn't want to sell it to me because it is bigger military  tech.

Will check variants out now then. Is there still a Variant editing tool around? Or does one has to crosscheck between game, files and the variant JSON?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on November 17, 2015, 04:04:28 PM
Is not being able to shoot when phased hard coded? I deleted the TRUE value for notFiring and it still won't let me fire when phased.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 17, 2015, 04:25:00 PM
Looking at it just now: yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 18, 2015, 05:25:23 AM
Is there still a Variant editing tool around? Or does one has to crosscheck between game, files and the variant JSON?
Trylobot's ship editor (http://fractalsoftworks.com/forum/index.php?topic=375.0) should mostly work. You can also use the devmode editor, or save a variant from a mission and get the file from the mission saves folder.

Looking at it just now: yes.
Alex, if you happen to get around to changing it: Could you also add support for phase cloak not actually making the unit phase out, and a working aiScript tag for phase cloak shipsystems? Would be useful for mods that want to use right-click shipsystems (notably Exigency and Templars).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 20, 2015, 10:00:15 PM
What does this error mean?

Code
758052 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
 at com.fs.starfarer.campaign.ai.TacticalModule.advance(Unknown Source)
 at com.fs.starfarer.campaign.ai.ModularFleetAI.advance(Unknown Source)
 at com.fs.starfarer.campaign.fleet.CampaignFleet.advance(Unknown Source)
 at com.fs.starfarer.campaign.BaseLocation.advance(Unknown Source)
 at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
 at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
 at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
 at com.fs.state.AppDriver.begin(Unknown Source)
 at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
 at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2015, 10:09:05 PM
The AI crashes (which is fairly clear from the trace, so I'm probably not telling you anything new), but why? There's not enough information there to say. Anything in particular that you were adding to the game that made it crash like this? If you have a save where this is reproducible (and can send me whatever mods are needed), I can take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 20, 2015, 11:48:00 PM
Anything in particular that you were adding to the game that made it crash like this? If you have a save where this is reproducible (and can send me whatever mods are needed), I can take a look.
Okay, here's the stuff:
AI War mod for 0.7 (https://bitbucket.org/Histidine/ai-war-ss/downloads/AI%20War%200.3_alpha1.zip) (requires LazyLib and ShaderLib)
Save game (https://www.dropbox.com/s/x9uz6ow01h6q6wk/save_WhyDontItwork_5125669165461508853.zip?dl=0)
To reproduce: Load, go into hyperspace, and just fly around for a bit (a couple of ingame days should suffice).

Since it doesn't happen in vanilla and none of the other modders have apparently seen something like this, I'm suspecting it has something to do with the "vengeance" fleets in AI War.
Fleet generation (https://bitbucket.org/Histidine/ai-war-ss/src/dc76f523da17f64d0052fa1d202a9bab68216ffb/jars/src/data/scripts/world/AIW_VengeanceGeneratorManager.java?at=master&fileviewer=file-view-default#AIW_VengeanceGeneratorManager.java-167)
Fleet EveryFrameScript (https://bitbucket.org/Histidine/ai-war-ss/src/dc76f523da17f64d0052fa1d202a9bab68216ffb/jars/src/data/scripts/world/AIW_VengeanceFleetAI.java?at=master&fileviewer=file-view-default)

By the way, is there a way to make gaps in the hyperspace terrain once it's created? I'm hoping to use the vanilla hyperspace map with randomly generated star systems, without having said systems be covered up by the hyper clouds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 21, 2015, 10:22:29 AM
Hi!
It seems that in 0.7 StarSystemAPI.getAsteroids() will return empty list immediately after successfully executing addAsteroidBelt().
Is that a bug or expected behavior? Possible workarounds?
Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 21, 2015, 10:28:25 AM
I think asteroids are spawned on the fly when you enter the system, or when the game actually start, not when it's generated. (to avoid having them stored in savegames)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 21, 2015, 10:45:28 AM
I think asteroids are spawned on the fly when you enter the system, or when the game actually start, not when it's generated. (to avoid having them stored in savegames)
Perhaps. Though, as I said, this changed only in the last version. If this was intentional, then I will rewrite related code. If not, I'd rather wait for a fix.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2015, 10:53:25 AM
Hi!
It seems that in 0.7 StarSystemAPI.getAsteroids() will return empty list immediately after successfully executing addAsteroidBelt().
Is that a bug or expected behavior? Possible workarounds?
Thanks

It adds them when it next advances. To work around, something like:
((CampaignTerrainAPI)belt).getPlugin().advance(0);
Where "belt" is the SectorEntityToken retured by addAsteroidBelt() should work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2015, 11:09:23 AM
Save game (https://www.dropbox.com/s/x9uz6ow01h6q6wk/save_WhyDontItwork_5125669165461508853.zip?dl=0)

Could you email me the file? Dropbox seems borked at the moment.
Edit: never mind, works now.

By the way, is there a way to make gaps in the hyperspace terrain once it's created? I'm hoping to use the vanilla hyperspace map with randomly generated star systems, without having said systems be covered up by the hyper clouds.

Yeah. Something like:
Code: java
for (CampaignTerrainAPI curr : Global.getSector().getHyperspace().getTerrainCopy()) {
if (curr.getPlugin() instanceof HyperspaceTerrainPlugin) {
HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) curr.getPlugin();
plugin.getTiles()[0][0] = -1;
break;
}
}

The above would ensure the bottom-left (I think) corner of hyperspace is clear.


I think asteroids are spawned on the fly when you enter the system, or when the game actually start, not when it's generated. (to avoid having them stored in savegames)

(They're cleaned up on save and regenerated after the save completes, in case this is relevant for any future things.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2015, 11:23:13 AM
To reproduce: Load, go into hyperspace, and just fly around for a bit (a couple of ingame days should suffice).

Since it doesn't happen in vanilla and none of the other modders have apparently seen something like this, I'm suspecting it has something to do with the "vengeance" fleets in AI War.

Thanks for providing the save etc! Fixed. Issue was with a fleet ("Dark Spire vengeance fleet") lacking a sourceMarket. In theory, every fleet should have one; still shouldn't crash if one doesn't, though.


Side note: hope you all are using ctrl-click (in campaign/campaign map) to move about more quickly now. Just want to make sure that dev-feature didn't slip through the cracks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on November 21, 2015, 12:18:29 PM
Hi!
It seems that in 0.7 StarSystemAPI.getAsteroids() will return empty list immediately after successfully executing addAsteroidBelt().
Is that a bug or expected behavior? Possible workarounds?
Thanks

It adds them when it next advances. To work around, something like:
((CampaignTerrainAPI)belt).getPlugin().advance(0);
Where "belt" is the SectorEntityToken retured by addAsteroidBelt() should work.
Thanks for a quick reply, Alex, but addAsteroidBelt() is void, there's no return value. Anyway, I'd rather rewrite the code instead of adding a kludge like that, since this is really working as intended.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2015, 12:31:31 PM
Oh, oops - my bad.

You could still do this if you replaced the addAsteroidBelt() call with this:
Code: java
SectorEntityToken belt = addTerrain(Terrain.ASTEROID_BELT,
new AsteroidBeltParams(
numAsteroids,
orbitRadius,
width,
minOrbitDays,
maxOrbitDays,
4f,
16f,
optionalName));
belt.setCircularOrbit(focus, 0, 0, 100);
((CampaignTerrainAPI)belt).getPlugin().advance(0);

But changing the code, as you say, might be less kludgy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on November 21, 2015, 12:39:35 PM
Side note: hope you all are using ctrl-click (in campaign/campaign map) to move about more quickly now. Just want to make sure that dev-feature didn't slip through the cracks :)

Oh boy!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2015, 02:13:04 PM
Oh, also! Ctrl-D to toggle sensors on and off.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on November 21, 2015, 03:40:39 PM
Side note: hope you all are using ctrl-click (in campaign/campaign map) to move about more quickly now. Just want to make sure that dev-feature didn't slip through the cracks :)
Oh, also! Ctrl-D to toggle sensors on and off.
We REALLY need a list of all the dev commands...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 21, 2015, 08:05:14 PM
Is there anything special you need to do in order to get missions integrated, or, if not, would an override of some sort be feasible?

I've been unable to figure this out for the past couple of days, but none of the ports of call in the two systems I've added, regardless of prosperity or affiliation, seem to be generating missions for some reason.  Unfortunately, the reason behind this obstinate refusal to post missions is pretty opaque; I'm not even sure what (if anything) is wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 21, 2015, 08:12:02 PM
To reproduce: Load, go into hyperspace, and just fly around for a bit (a couple of ingame days should suffice).

Since it doesn't happen in vanilla and none of the other modders have apparently seen something like this, I'm suspecting it has something to do with the "vengeance" fleets in AI War.

Thanks for providing the save etc! Fixed. Issue was with a fleet ("Dark Spire vengeance fleet") lacking a sourceMarket. In theory, every fleet should have one; still shouldn't crash if one doesn't, though.
Thanks Alex!

I tried using fleet.setMarket(fakeMarket) to resolve the issue, but it still crashes (and so far as I can tell, FleetFactoryV2 should have already set the market). Am I missing something?

Spoiler
Code: java
        fakeMarket = Global.getFactory().createMarket("spire_vengeance_fakeMarket", "Fake Vengeance Market", 6);
        fakeMarket.setFactionId("darkspire");

Code: java
        FleetParams fleetParams = new FleetParams(spawner.getLocationInHyperspace(), fakeMarket, "darkspire", null, "spireVengeanceFleet", 
                fp*0.75f, // combat
                fp*0.25f, // freighters
                0,        // tankers
                0,        // personnel transports
                0,        // liners
                0,        // civilian
                0,    // utility
                0f, qf, 2f, levelBonus);    // quality bonus, quality override, officer num mult, officer level bonus
        
        CampaignFleetAPI fleet = FleetFactoryV2.createFleet(fleetParams);
        //CampaignFleetAPI fleet = FleetFactory.createGenericFleet("darkspire", name, qf, (int)fp);
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_FLEET_TYPE, "spireVengeanceFleet");
        fleet.setName(name);
        fleet.setAIMode(true);
        fleet.setMarket(fakeMarket); // try this?
        
        loc.addEntity(fleet);
        
        fleet.setLocation(spawner.getLocation().x, spawner.getLocation().y);
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2015, 09:01:13 PM
Is there anything special you need to do in order to get missions integrated, or, if not, would an override of some sort be feasible?

I've been unable to figure this out for the past couple of days, but none of the ports of call in the two systems I've added, regardless of prosperity or affiliation, seem to be generating missions for some reason.  Unfortunately, the reason behind this obstinate refusal to post missions is pretty opaque; I'm not even sure what (if anything) is wrong.

There shouldn't be anything special. One thing is if your two systems have everything available, it's not going to create procurement missions with those markets as destinations - it picks markets that don't have that commodity available nearby. They should still get procurement missions from other markets that aren't too far away if they're not hostile to everybody, though.

Take a look at:
com.fs.starfarer.api.impl.campaign.missions.MarketProcurementMissionCreator
That's the script that creates and posts procurement missions. Something there might tip you off as to why your markets aren't participating.


To reproduce: Load, go into hyperspace, and just fly around for a bit (a couple of ingame days should suffice).

Since it doesn't happen in vanilla and none of the other modders have apparently seen something like this, I'm suspecting it has something to do with the "vengeance" fleets in AI War.

Thanks for providing the save etc! Fixed. Issue was with a fleet ("Dark Spire vengeance fleet") lacking a sourceMarket. In theory, every fleet should have one; still shouldn't crash if one doesn't, though.
Thanks Alex!

I tried using fleet.setMarket(fakeMarket) to resolve the issue, but it still crashes (and so far as I can tell, FleetFactoryV2 should have already set the market). Am I missing something?

Spoiler
Code: java
        fakeMarket = Global.getFactory().createMarket("spire_vengeance_fakeMarket", "Fake Vengeance Market", 6);
        fakeMarket.setFactionId("darkspire");

Code: java
        FleetParams fleetParams = new FleetParams(spawner.getLocationInHyperspace(), fakeMarket, "darkspire", null, "spireVengeanceFleet", 
                fp*0.75f, // combat
                fp*0.25f, // freighters
                0,        // tankers
                0,        // personnel transports
                0,        // liners
                0,        // civilian
                0,    // utility
                0f, qf, 2f, levelBonus);    // quality bonus, quality override, officer num mult, officer level bonus
       
        CampaignFleetAPI fleet = FleetFactoryV2.createFleet(fleetParams);
        //CampaignFleetAPI fleet = FleetFactory.createGenericFleet("darkspire", name, qf, (int)fp);
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_FLEET_TYPE, "spireVengeanceFleet");
        fleet.setName(name);
        fleet.setAIMode(true);
        fleet.setMarket(fakeMarket); // try this?
       
        loc.addEntity(fleet);
       
        fleet.setLocation(spawner.getLocation().x, spawner.getLocation().y);
[close]

Hm, yes, FleetFactoryV2 should have already set it. In fact, it seems impossible for it not to have set it - it'd fail to create the fleet and return null if there was no suitable market to pick as a source.

As far as setting the market, btw: you do NOT want to setMarket() on the fleet. That's adding an actual market to the fleet. What you want is to set a $sourceMarket in the fleet's memory, like so (which is what FFV2 does):

fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_SOURCE_MARKET, market.getId());

... ahh, this makes sense. You're using a fakeMarket to spawn the fleet, but that market isn't part of the economy, so when the fleet AI tries to retrieve that market based on the id, it can't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on November 22, 2015, 10:33:13 AM
Never modded starsector before.

Also, I hate Java (but I use it on my day work sometimes).

Still, what files I need to edit to change the market and economy? I am REALLY bothered the trading ins't more fun and want to meddle with it.

It is the only reason why I don't play this game more (the combat is awesome, in fact for now the strongest selling point, but for combat there is also lots of other interesting games, right now Mechwarrior Online that is grabbing my attention with slow action + editing your vehicle, thus trading, that I really love, would be the "dealbreaker").
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nimaniel on November 22, 2015, 01:11:08 PM
Does the vanilla game generate the faction-relation restricted ships available for purchase based on the faction files in \starsector-core\data\world\factions ? (These files seem to be mainly for the faction fleet composition, but I haven't found what I'm looking for anywhere else.)

(I know this is not strictly speaking a mod-question, but if anyone knows the answer, it's you guys :)

I wanted to compile a short overview of ships that are faction "unique" (ignoring the fact that some of these can also appear on "independent" and "black" markets).

For example:

TT:
Medusa
Shade
Omen
etc.

But what I really want to figure out is how a set of available ships are generated at a given faction station.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2015, 01:26:00 PM
Yeah, that's how they're generated; same process as picking a ship for a faction fleet. Weapons are generated the same way - it picks ships then strips them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on November 22, 2015, 02:23:07 PM
How I mod the economy and markets? What files I should look into?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2015, 03:45:33 PM
Take a look here for a start:
http://fractalsoftworks.com/forum/index.php?topic=9689.0

Then there's data/campaign/econ/economy.json and the files referenced from it.

It's involved and not really suited for this thread as a general discussion of "how to mod the economy". Specific questions re: modding a specific thing would be a good fit, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 25, 2015, 05:34:25 AM
How do I make a fleet not chase enemies around? MemFlags.MEMORY_KEY_TRADE_FLEET didn't seem to be sufficient.

(It was quite funny to see two mining fleets running down a pirate fleet, but also quite disconcerting)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 25, 2015, 12:10:13 PM
How do I make a fleet not chase enemies around? MemFlags.MEMORY_KEY_TRADE_FLEET didn't seem to be sufficient.

(It was quite funny to see two mining fleets running down a pirate fleet, but also quite disconcerting)

It should do the job, mostly. But if the pirates attack them/cross their path, then they may give chase.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 25, 2015, 12:23:09 PM
How do I make a fleet not chase enemies around? MemFlags.MEMORY_KEY_TRADE_FLEET didn't seem to be sufficient.

(It was quite funny to see two mining fleets running down a pirate fleet, but also quite disconcerting)

It should do the job, mostly. But if the pirates attack them/cross their path, then they may give chase.

I saw a TT Relief fleet attack a Hegemony Mercantile fleet in vanilla, which was also a bit disconcerting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 25, 2015, 12:35:59 PM
Is it possible to direct the production from a Market Condition into a specific sub-market?

I have some "Intelligence Data Chips" in demand throughout the sector but I want to make them available only in a couple of sub-markets that require a high standing with the corresponding factions. Problem is, market conditions only dump them in all the sub-markets but the one I created for this. And when I tried to generate them by hand, they don't participate in the economy. I tried to remove them from all the other sub-markets in the "updateCargoPrePlayerInteraction()" but that made the whole market unavailable for some reason. I tried to do the same in the market condition but it didn't do anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 25, 2015, 12:48:09 PM
I tried to remove them from all the other sub-markets in the "updateCargoPrePlayerInteraction()" but that made the whole market unavailable for some reason.

That's the right way to go, yeah - that method decides what to take from the economy and put into the actual player-accessible submarket cargo. Don't know why it'd make the submarket unavailable, but I'd imagine some sort of bug in your code :)

Well, and I wouldn't *remove* them from other submarkets in that method - rather, it should only add them in it for the markets you want.

I should probably add a "do not auto-put this into tradeable cargo" tag to commodities to make this sort of thing easier...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 25, 2015, 01:17:50 PM
Well at first I did this:

Code: Java
    @Override
    public void updateCargoPrePlayerInteraction() {

        if (!okToUpdateCargo()) return;        
        CargoAPI cargo = getCargo();        
        cargo.addCommodity("SCY_intelChip", sinceLastCargoUpdate*Global.getSector().getAllFactions().size()*MAX_INTEL_PER_FACTION*(market.getStabilityValue()/20));
        sinceLastCargoUpdate = 0f;
   }

But while it generated the items in the submarket, they did not appear in the market info and neither seemed to participate in the economy.

That's why I created the Condition for this :

Code: java
    @Override
    public void apply(String id) {   
            market.getDemand(Commodities.REGULAR_CREW).getDemand().modifyFlat(id, SCY_spyGuild_crew);
            market.getDemand(Commodities.REGULAR_CREW).getNonConsumingDemand().modifyFlat(id, SCY_spyGuild_crew * ConditionData.CREW_MARINES_NON_CONSUMING_FRACTION);
            float crewDemandMet = market.getDemand(Commodities.REGULAR_CREW).getClampedAverageFractionMet();

            market.getDemand(Commodities.HAND_WEAPONS).getDemand().modifyFlat(id, SCY_spyGuild_weapons * crewDemandMet);
            market.getDemand(Commodities.SUPPLIES).getDemand().modifyFlat(id, SCY_spyGuild_suplies * crewDemandMet);

            float stability = market.getStabilityValue()/10;
            float factions = Global.getSector().getAllFactions().size()/6;
            market.getCommodityData("SCY_intelChip").getSupply().modifyFlat(id,
                            SCY_spyGuild_intel
                            * crewDemandMet
                            * stability
                            * factions
            );  
   }

With the sub market update looking like this to avoid spilling the chips everywhere:

Code: java
    @Override
    public void updateCargoPrePlayerInteraction() {
        if (!okToUpdateCargo()) return;
        
        CargoAPI cargo = getCargo();    
        
        float chips=0;
        for (SubmarketAPI sm : market.getSubmarketsCopy()){
            if (sm != submarket){
                List<CargoStackAPI> stacks = sm.getCargo().getStacksCopy();
                for (CargoStackAPI s : stacks){
                    if (s.getCommodityId().equals("SCY_intelChip")){
                        chips += s.getSize();
                        sm.getCargo().removeItems(s.getType(), s.getData(), s.getSize());
                        break;
                    }                    
                }                
                sm.getCargo().removeEmptyStacks();
            }
        }
        
        cargo.addCommodity("SCY_intelChip", chips);        
        
        cargo.sort();
        cargo.removeEmptyStacks();  
        
        sinceLastCargoUpdate = 0f;
   }

But this gives me an empty screen when I try to get to the market (nothing on the screen but the interaction image and the menus to the bottom)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 25, 2015, 01:49:52 PM
But this gives me an empty screen when I try to get to the market (nothing on the screen but the interaction image and the menus to the bottom)

Real quick: this means there's an exception, probably during running one of the rule commands, and a stack trace should be in the log.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 25, 2015, 02:26:00 PM
mmmh, it hang at
Code: java
                    if (s.getCommodityId().equals("SCY_intelChip")){      
 

in
Code: java
float chips=0;
        for (SubmarketAPI sm : market.getSubmarketsCopy()){
            if (sm != submarket){
                List<CargoStackAPI> stacks = sm.getCargo().getStacksCopy();
                if (!stacks.isEmpty()){
                    for (CargoStackAPI s : stacks){
                        if (s.getCommodityId().equals("SCY_intelChip")){
                            chips += s.getSize();
                            sm.getCargo().removeItems(s.getType(), s.getData(), s.getSize());
                            break;
                        }                    
                    }      
                }
                sm.getCargo().removeEmptyStacks();
            }
        }

Spoiler
Code
java.lang.NullPointerException
at data.scripts.campaign.submarkets.SCY_intelligenceMarket.updateCargoPrePlayerInteraction(SCY_intelligenceMarket.java:57)
at com.fs.starfarer.campaign.ui.T.<init>(Unknown Source)
at com.fs.starfarer.coreui.f.<init>(Unknown Source)
at com.fs.starfarer.coreui.f.<init>(Unknown Source)
at com.fs.starfarer.ui.newui.J$5.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newui.J.setCurrentTab(Unknown Source)
at com.fs.starfarer.ui.newui.J.setCurrentTab(Unknown Source)
at com.fs.starfarer.ui.newui.T.showCoreInternal(Unknown Source)
at com.fs.starfarer.ui.newui.T.showCore(Unknown Source)
at com.fs.starfarer.api.impl.campaign.rulecmd.OpenCoreTab.execute(OpenCoreTab.java:39)
at com.fs.starfarer.campaign.rules.super.execute(Unknown Source)
at com.fs.starfarer.campaign.rules.ooOO.runScript(Unknown Source)
at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.applyRule(FireBest.java:97)
at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.execute(FireBest.java:47)
at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.fire(FireBest.java:53)
at com.fs.starfarer.api.impl.campaign.RuleBasedInteractionDialogPluginImpl.fireBest(RuleBasedInteractionDialogPluginImpl.java:176)
at com.fs.starfarer.api.impl.campaign.RuleBasedInteractionDialogPluginImpl.optionSelected(RuleBasedInteractionDialogPluginImpl.java:208)
at com.fs.starfarer.ui.newui.T$1.o00000(Unknown Source)
at com.fs.starfarer.ui.newui.super.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.h.o00000(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.U.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

[EDIT] LazyWizzard solved this for me, I had to check is s was a commodity stack.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 26, 2015, 07:39:28 PM
So I really can't figure out where I went wrong. Can anyone help?

ship hull spec not found
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 28, 2015, 11:49:40 AM
can anyone help me please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 28, 2015, 11:57:12 AM
What's the error? I vaguely remember seeing a more detailed question in this thread but I can't spot it now.

Do you have an entry for your new ship in ship_data.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 28, 2015, 12:16:37 PM
2070 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull spec [engager] not found!
java.lang.RuntimeException: Ship hull spec [engager] not found!
   at com.fs.starfarer.loading.L.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.loading.specs.HullVariantSpec.<init>(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


yes, it is a wing, it has a variant called enforcer_variant.variant with enforcer_wing as id
and in wing_data.csv it has enforcer_wing
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on November 29, 2015, 11:39:33 AM
Is there a way to get the full damage a missile can do (the total damage from projectiles/missiles spawned by the missile).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on November 29, 2015, 03:34:50 PM
2070 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull spec [engager] not found!
java.lang.RuntimeException: Ship hull spec [engager] not found!
   at com.fs.starfarer.loading.L.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.loading.specs.HullVariantSpec.<init>(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


yes, it is a wing, it has a variant called enforcer_variant.variant with enforcer_wing as id
and in wing_data.csv it has enforcer_wing

So, you have a wing_data.csv with an entry for 'enforcer_wing', that specifies it is a wing of 'enforcer_variant' variants?

And then you have a enforcer_variant.variant file (with variantId 'enforcer_variant', which specifies the hull of the variant is of hullId 'engager')?

And then you have a 'engager.ship' file that specifies the hullId as 'engager'?

And then you have an entry in ship_data.csv for 'engager'?

(It's been a while but I think that is what you need. I suspect you either don't have one of those things or the names/locations of files are incorrect)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 30, 2015, 03:57:57 AM
In reportEncounterLootGenerated(), I need to know what proportion of the total loot the player should get. Is performPostVictoryRecovery(EngagementResultAPI result) what I want to use?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on November 30, 2015, 08:59:37 AM
In reportEncounterLootGenerated(), I need to know what proportion of the total loot the player should get. Is performPostVictoryRecovery(EngagementResultAPI result) what I want to use?

The first one is the one you want.  It gives you the encounter plugin, which should let you implement whichever part of FleetEncounterContext.generatePlayerLoot() you want to use.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 30, 2015, 09:47:02 AM
Added FleetEncounterContextPlugin.computePlayerContribFraction().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on November 30, 2015, 01:01:55 PM
I'm looking to start up work on a Freespace 2 mod (I have standing permission from the FSOpen team to use their assets, with credit provided). The idea would be to have 3 main factions, each with its own home system (Terran, Vasudan, Shivan). There would be an additional set of 2 pirate factions in two of those systems (for Terran and Vasudan, respectively), using similar ship assets.

I don't want to make this a total conversion, so that people can use it with other faction mods, Nexelerin, SS+, etc.

How should I go about ensuring compatibility? I've never modded Starsector before (I have a lot of experience in modding other games, though), so I want to ensure I'm thinking about this correctly from a high level before I dig in.

Any other "things I wish I would have known" that you all want to impart before I kick this off?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on November 30, 2015, 03:11:27 PM
Well the easiest way would be to download an existing "simple" faction mod and match their structure and files. I'd suggest taking a look at Shadowyards or Diable Avionics: while they are compiled they do not try too many fancy things and are relatively simple to understand. Unless you try modify a core file you'd have to do something really bad to make mods mutually incompatible.
(btw Nexerelin actually require some work to be compatible with, but it's explained in the first post)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on November 30, 2015, 07:45:20 PM
Sorry to ask again, but is there a way to get the full damage for a missile that splits into sub munitions? For example the hurricane MIRV returns 500 damage when getting it from both DerivedStats() and DamageAPI(), instead of the possible 5000.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on November 30, 2015, 08:07:17 PM
@ Toxicity - I'd assume you'd have to add up all of the submunitions damage.

How do I get the mission boards to auto-populate themselves? All of my markets are showing up as blank and have no missions after market creation. Do I have to make a script to manually populate the Sector's MissionBoardAPI for my system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 30, 2015, 08:11:31 PM
Sorry to ask again, but is there a way to get the full damage for a missile that splits into sub munitions? For example the hurricane MIRV returns 500 damage when getting it from both DerivedStats() and DamageAPI(), instead of the possible 5000.

I don't think there's an easy way to get all the relevant data. The only thing you could really do is load the .proj file and parse out the MIRV spec. At least, nothing else comes to mind - the relevant functionality (i.e. what the weapon tooltip uses) isn't currently exposed.

How do I get the mission boards to auto-populate themselves? All of my markets are showing up as blank and have no missions after market creation. Do I have to make a script to manually populate the Sector's MissionBoardAPI for my system?

If you add markets before the initial time pass, they should automatically get missions in them. There's a bug where it was using the market ID instead of the entity ID for this, though, so if yours don't match, it won't work until 0.7.1a. In vanilla, they do (mostly) match, so I didn't notice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on November 30, 2015, 08:30:24 PM
Hmmm... that would explain things. All of my markets had IDs of the form "<parent>_market", whereas the actual entities are just "<parent>". I'll test that out later tonight (with identical IDs).

The "(mostly)" bit you mentioned might also explain why some of the vanilla markets were just randomly blank as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 30, 2015, 08:32:15 PM
Yeah, those are stations around a primary planet - again, same issue with the ID mismatch.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on December 01, 2015, 02:05:09 AM
Looks like changing the market names to the ID of their parent entities fixed the issue for the primary market (secondary stations are still blank).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 01, 2015, 07:01:50 AM
Hi, none idea if my search is bad, but i have not found a answer for my problem. Oh, also, i am french, so this is maybe the reason.

I have this problem:
Quote
2737 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Looters (data/world/factions/Looters.faction)]
2755 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.missions.thelasthurrah.MissionDefinition] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
2758 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: A JSONObject text must end with '}' at 2902 [character 3 line 106]
org.json.JSONException: A JSONObject text must end with '}' at 2902 [character 3 line 106]
   at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
   at org.json.JSONObject.<init>(JSONObject.java:190)
   at org.json.JSONObject.<init>(JSONObject.java:311)
   at com.fs.starfarer.loading.LoadingUtils.int(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ØO0000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

So, i search error with my last }(this is my character 3, line 106), but i have not found:
Spoiler
{
        id:"Looters",
        "color":[180,255,128,128],
        "displayName":"Looters",
        "displayNameWithArticle":"the looters",
        "displayNameLong":"Looters",
        "displayNameLongWithArticle":"the looters",
        "logo":"graphics/factions/Looters.png",
        "shipNamePrefix":"Lt",
        "shipNameSources":{
                "PIRATES":1,
                "SPACE":1,
        },
        "description":"Your money and your lives but also your soul",
        "names":{
                "modern":1,
                "world":1,
                "future":1,
        },
        "illegalCommodities":[
        ],
   "internalComms":"Looters_internal",
   "music":{
      "theme":"music_pirates_market_neutral",
      "market_neutral":"music_pirates_market_neutral",
      "market_hostile":"music_pirates_market_hostile",
      "market_friendly":"music_pirates_market_friendly",
      "encounter_neutral":"music_pirates_encounter_neutral",
      "encounter_hostile":"music_pirates_encounter_hostile",
      "encounter_friendly":"music_pirates_encounter_friendly",
   },
   "portraits":{
      "standard_male":[
         "graphics/portraits/portrait_generic.png",

      ],
      "standard_female":[
         "graphics/portraits/portrait_generic.png",
      ],
   },
   "ranks":{
      "ranks":{
         "spaceCommander":{"name":"Captain"},
      },
      "posts":{
         "patrolCommander":{"name":"Captain"},
         "fleetCommander":{"name":"Warlord"},
         "baseCommander":{"name":"Captain"},
      },
   "custom":{
      "investigatesPlayerForGoodRepWithOtherFactions":false,
      "worthInvestigatingPlayerForGoodRepWith":false,
      "ignoreTradeWithEnemiesForReputation":true,
   },   
   "shipRoles":{
      "carrierMedium":{
         "logpir":10,
         "fallback":{"carrierSmall":2},
      },
      "freighterMedium":{
         "logpir":10,
         "fallback":{"freighterSmall":2},
      },
   },
   "fleetTypeNames":{
      "trade":"Convoy",
      "tradeLiner":"Convoy",
      "mercScout":"Scout",
      "mercBountyHunter":"Raiders",
      "mercPrivateer":"Raiders",
      "mercPatrol":"Attack Fleet",
      "mercArmada":"Armada",
   },
   "traits":{
      "admiral":{
      },
      "captain":{
         "timid":0,
         "cautious":0,
         "steady":0,
         "aggressive":15,
      },
   },
        "doctrine":{
                "interceptors":0,
                "fighters":0,
                "bombers":0,
                "small":0,
                "fast":0,
                "medium":10,
                "large":0,
                "capital":0,
                "escortSmallFraction":0.8,
                "escortMediumFraction":0.8,
                "combatFreighterProbability":0.25,
                "minPointsForCombatCapital":24,
                "minPointsForLargeCarrier":30,
                "smallCarrierProbability":0.30,
                "mediumCarrierProbability":0.30,
                "largeCarrierProbability":0.30,
                "officersPerPoint":0.35,
                "officerLevelPerPoint":0.15,
                "officerLevelBase":3,
                "officerLevelVariance":0.5,
        },
},      
[close]
PS: i have use a other mod for help me, so many useless things. (And, i have only a ship, actually, for test.)

Thank for your help.

PS2: When i delete "," , new error because i have not last }.
PS3: yes, this spoiler is useless, because i can found alone, but i want know why and where. Thank.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 01, 2015, 07:14:00 AM
Your ranks table is missing the closing brace }

(also, don't use portrait_generic.png) (http://fractalsoftworks.com/forum/index.php?topic=9834.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 01, 2015, 07:26:21 AM
Thank, i have verificate 2 times, but, i am so blind.

Edit: I have other error after fix my problem, but it is better.
Spoiler
Now, i need just find Fatal: JSONObject["type"] not found. Yes, google, i come. (Or search, also)
PS: (I use pad for .txt, but i go also for .csv, i have see same problem with excel)
[close]
Also thank for portrait generic.



EDIT: where are i can post a mini subject for a mission who test my ship and where he can say why my ship is bad or other?  download (http://http://www.mediafire.com/download/jyr4kkmel4sugh3/Lootersmission.rar) <(my mission, if subjet do not exist)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on December 01, 2015, 12:51:55 PM
You can use http://jsonlint.com/ (http://jsonlint.com/), to verify that your JSONs are properly formatted. Note that it does not allow the "#" comment character- Alex's JSON parser is quite lenient and forgiving of extra ","s.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 01, 2015, 09:57:49 PM
Ok, thank, for this moment, i have not problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 02, 2015, 06:39:03 AM
Hey guys, Java is my hobby in free-time so I decided that modding in SC will be a nice learn-on thing.
My plan is to create my own faction (Private Military Company), nothing fancy to start off - few ships with weapons.  I used ship editor - great stuff and easy to use, but I understand nothing except sprite and ship file creation.  
So my questions are, were can I find tutorials for ship and weapon modding? Just a direction like "this goes here and you will need that out here". As modding wiki is dead (or is it just link) I have difficulties finding this things out.
Also:
1. Is it possible to make turret weapon without sprite for turret itself? Are turret(weapon) and projectile different things or are they are in one file?
2. Is it possible for proximity detonation of projectile with some randomness, like when projectile can explode before and after passing the target?
3. Is it possible for projectile to release few other projectiles around it self during detonation?
4. Is it possible to make laser-warhead missile? Like sabot-missile from vanilla but with beam instead of projectile?
5. Is it possible to put weapons below some layers of ship-sprite? So that we can see just part of turret.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 02, 2015, 06:57:36 AM
Hey guys, Java is my hobby in free-time so I decided that modding in SC will be a nice learn-on thing.
My plan is to create my own faction (Private Military Company), nothing fancy to start off - few ships with weapons.  I used ship editor - great stuff and easy to use, but I understand nothing except sprite and ship file creation.  
So my questions are, were can I find tutorials for ship and weapon modding? Just a direction like "this goes here and you will need that out here". As modding wiki is dead (or is it just link) I have difficulties finding this things out.
Also:
1. Is it possible to make turret weapon without sprite for turret itself? Are turret(weapon) and projectile different things or are they are in one file?
2. Is it possible for proximity detonation of projectile with some randomness, like when projectile can explode before and after passing the target?
3. Is it possible for projectile to release few other projectiles around it self during detonation?
4. Is it possible to make laser-warhead missile? Like sabot-missile from vanilla but with beam instead of projectile?
5. Is it possible to put weapons below some layers of ship-sprite? So that we can see just part of turret.

Thanks!
There are a few old tutorial on setting up ships and weapons (including the one on the wiki), while some fields changed it's still the same idea.

1. Check any .weapon file: you'll see the path for the turret and the hardpoint sprites. leave the path empty to have a weapon without sprite.

2. You'll have to write a plugin that catch all projectiles every frames then sort out yours, then check for the distance to the nearest enemy then add some randomness. Nothing complicated, there are a few scripts like that in several mods (including my Scy Nation mod, look for SCY_projectilesEffect.java) But it could become quite CPU intensive if you intend to have a lot of these projectiles.

3. Of course, check SCY_ketoMainGunEffect.java in Scy.

4. That one is quite tricky. You can't spawn beam in the game engine, but you can display a beam like sprite and apply some damage at an arbitrary location. Me, Deathfly, 19_30 and Kazi wrote some variation around a "fake beam" plugin to do that:
http://fractalsoftworks.com/forum/index.php?topic=6452.msg161937#msg161937
and the following posts. You can check the SCY_laserTorpedoAI.java to see how I implemented it.

5. You have to cheat it by using a decorative weapon on top that look like the hull. One Exigency fighter does that (as well as some other mods but unreleased yet so I can't point you to them)...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 02, 2015, 07:15:01 AM

2. You'll have to write a plugin that catch all projectiles every frames then sort out yours, then check for the distance to the nearest enemy then add some randomness. Nothing complicated, there are a few scripts like that in several mods (including my Scy Nation mod, look for SCY_projectilesEffect.java) But it could become quite CPU intensive if you intend to have a lot of these projectiles.

3. Of course, check SCY_ketoMainGunEffect.java in Scy.



Thanks a lot for answering!
As for point 2 and 3, I want to recreate effect of Venator flak-cannon from SW movie, you can see how it is implemented in this HW mod (https://www.youtube.com/watch?feature=player_detailpage&v=u5yZbJSp7FE).
But I dont want this flak cannon to be present on ship itself as visible weapon.
So:
1. Is there a way to add it as hull-modification maybe?
2. Can I make it to fire at and damage ONLY missiles? (and maybe fighters?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 02, 2015, 07:34:45 AM
1. that's what built-in weapons are for. With no sprite, or hidden though I would advice against that (cause other issues).

2. PD flag in the weapon_data.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on December 02, 2015, 08:00:11 AM
There is a PD_ONLY tag if you really want it to only attack missiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 02, 2015, 09:09:42 AM
If my mod is currently just one ship, is there anything else I need to do to get it selectable/playable other than creating the graphics, .ship file, and csv entry?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 02, 2015, 09:35:17 AM
Depends, if you want to add it to your fleet via command you only need to add a mod_info.json. But if you want it to spawn in markets, you'll need at least a variant and to add it to one of the faction's ship selection.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 02, 2015, 11:46:17 AM
Many questions:

-What this:
    {
        "major":1,
        "minor":9,
        "patch":0
    },
In namemod.version?

-Where find ThreadId (of same namemod.version) not indented , same thing for numero of ships ?

-It is possible, create a IA for a unique ship?(Like wing with support,interceptor,assault)

Thank!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 02, 2015, 02:59:28 PM
Hi, new question, in hullmod:

Spoiler
       private static final float SUPPLY_USE_MULT = 0.9f;
   
   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
      stats.getSuppliesPerMonth().modifyMult(id, SUPPLY_USE_MULT);
   }
   
        public String getDescriptionParam(int index, HullSize hullSize) {
      if (index == 0) return "" + (int)(SUPPLY_USE_MULT * 1f);
      return null;
   }
[close]
I need insert what so that reduce maintenance at 10% in all ships? (We can cumulate effect with? Not error? This is possible?)
(and i suppose also that void applyEffectsBeforeShipCreation is not good. I need use AfterShipCreation for better performances?)
Please. Thank you.(I know coding only python for the time.)

EDIT: I have find  Javadoc for this, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 03, 2015, 06:02:36 AM
When using CombatEngineAPI.getCombatUI().addMessage():
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 03, 2015, 09:18:14 AM
  • Is there a way to automatically write the shipName (shipClass-class) string (preferably with the color already set)?
Not automatically, no.

  • Aside from the above case, is it possible to only colorize part of the message?
Yes - just provide multiple colors as parameters, e.g: color1, text, color2, more text. The default text color is standardTextColor from settings.json.


How do I add custom station in the current version?
I managed to spawn it, but when I arrive, I do not see any dialogue - only "Leave" option.

I spawn station with:
Code
SectorEntityToken station = system.addCustomEntity("StationTest", "StationTest", "station_pirate_type", "myfaction");
station.setCircularOrbitPointingDown(point, 360, 2048, 240);
station.setInteractionImage("illustrations", "orbital");

What do I do wrong and what can I do to make station dialogue like default pirate station has?

Probably need a market configured for it in the economy. Station interaction dialog is actually market interaction.

Also, is it possible to make unique officers and if possible - how?

Depends on what you mean by unique; there's code creating officers in com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent, so I'd take a look there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 03, 2015, 01:17:04 PM
Hi, again, for two news questions:

I am french, so i do not understand this: (And 0 tutorials... ( except very old tutorials..)

What is this fallback,and what represent value 1?   
      "interceptor":{
         "fallback":{"fighter":1},
      },


Thank you .

Other question:
Spoiler
-What this:
    {
        "major":1,
        "minor":9,
        "patch":0
    },
In namemod.version?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on December 03, 2015, 06:27:19 PM
Hi, again, for two news questions:

I am french, so i do not understand this: (And 0 tutorials... ( except very old tutorials..)

What is this fallback,and what represent value 1?   
      "interceptor":{
         "fallback":{"fighter":1},
      },


Thank you .

I believe that means that if the fleet builder can't pick a ship from that category, it will pick 1 entry from the "fighter" category instead.

Quote
Other question:
Spoiler
-What this:
    {
        "major":1,
        "minor":9,
        "patch":0
    },
In namemod.version?
[close]

That's not required for your mod to function. It's to support the mod Version Checker (http://fractalsoftworks.com/forum/index.php?topic=8181.0), which just informs users when a new version of a mod is available and lets them open the mod's forum thread from within the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 04, 2015, 09:32:21 AM
Alex I found out that most of the game economy is hardcoded and not easily modable, including many decisions I disagree with (like the existance of the "greed factor" as a hack to keep prices working)

Is it possible to disable the economy entirely, and plug in my own? I can't find where the game calls the "Economy" class for example...

Note that I only want to meddle with the economy calculations itself, the conditions for example is something I like, and would leave them as is, what I don't like is the stock and price formulas.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 04, 2015, 09:33:40 AM
Hey guys, please help.
Created my first ship, added it to simulator, but when I select it as my opponent i have CTD with next error in log:

Spoiler
30654 [Thread-11] INFO  sound.H  - Playing music with id [battle_ambience_01.ogg]
33192 [Thread-9] INFO  sound.OOoO  - Cleaned buffer for sound music (using cast)
33581 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.Oo0O] with id [pmc_haeg] not found
java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.Oo0O] with id [pmc_haeg] not found
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.<init>(Unknown Source)
   at com.fs.starfarer.loading.specs.forsuper.o00000(Unknown Source)
   at com.fs.starfarer.title.C.L.new(Unknown Source)
   at com.fs.starfarer.title.C.L.o00000(Unknown Source)
   at com.fs.starfarer.coreui.oOoo.super(Unknown Source)
   at com.fs.starfarer.ui.h.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.ui.ifnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.ui.ifnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.ui.ifnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
33655 [Thread-11] INFO  sound.O  - Creating streaming player for music with id [battle_ambience_01.ogg]
33655 [Thread-11] INFO  sound.H  - Playing music with id [battle_ambience_01.ogg]
[close]

Edit: just found that it crashed due to in ship.cvs i have pmc_haeg as "system". Can anyone explain me what "system" stands for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: murumuru on December 04, 2015, 10:54:04 AM
Is it possible to create unique officers available for hire?
By unique I mean officer that uses custom portrait, name, level, traits and abilities and make it available on a station.
I took a look into com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent, but it did not help me much.
Basically, I want to create some predefined officers (name, level, traits, etc) and place them on stations available for hire.
How can I do it?
If possible, a little code example would be of a great help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 04, 2015, 10:55:29 AM
Hey guys, please help.
Created my first ship, added it to simulator, but when I select it as my opponent i have CTD with next error in log:

Spoiler
30654 [Thread-11] INFO  sound.H  - Playing music with id [battle_ambience_01.ogg]
33192 [Thread-9] INFO  sound.OOoO  - Cleaned buffer for sound music (using cast)
33581 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.Oo0O] with id [pmc_haeg] not found
java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.Oo0O] with id [pmc_haeg] not found
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.<init>(Unknown Source)
   at com.fs.starfarer.loading.specs.forsuper.o00000(Unknown Source)
   at com.fs.starfarer.title.C.L.new(Unknown Source)
   at com.fs.starfarer.title.C.L.o00000(Unknown Source)
   at com.fs.starfarer.coreui.oOoo.super(Unknown Source)
   at com.fs.starfarer.ui.h.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.ui.ifnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.ui.ifnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.ui.ifnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.private.render(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
33655 [Thread-11] INFO  sound.O  - Creating streaming player for music with id [battle_ambience_01.ogg]
33655 [Thread-11] INFO  sound.H  - Playing music with id [battle_ambience_01.ogg]
[close]

Edit: just found that it crashed due to in ship.cvs i have pmc_haeg as "system". Can anyone explain me what "system" stands for?

system is for example is: maneuveringjets . This is "shipsystem", simple, no? ^^. (You can find shipsystem in:Starsector/starsector-core/data/shipsystems.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 04, 2015, 09:10:00 PM
How I check if a market has a condition?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on December 04, 2015, 10:11:26 PM
How I check if a market has a condition?

Code: Java
// MarketAPI market = whatever marketAPI you're checking for conditions

String toCheckFor = "exampleMarketConditionID"
for (MarketConditionAPI condition : market.getConditions()) {
     if (toCheckFor.equals(condition.getId())) {
                //do something
     }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 04, 2015, 10:26:51 PM
Code: java
    if (market.hasCondition(toCheckFor) {
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 04, 2015, 10:43:42 PM
Code: java
    if (market.hasCondition(toCheckFor) {
    }

Thanks, that worked great!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 05, 2015, 11:34:55 AM
I have been looking all over for an answer to this, and haven't found anything.

Is there a checklist anywhere of what needs to be present in order for a mod to actually work? Is there a baseline version of a set of java files that you need for a mod? This is my first time through, and I don't want to miss anything (especially since troubleshooting could take forever at my current level of knowledge).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 05, 2015, 11:49:56 AM
I have been looking all over for an answer to this, and haven't found anything.

Is there a checklist anywhere of what needs to be present in order for a mod to actually work? Is there a baseline version of a set of java files that you need for a mod? This is my first time through, and I don't want to miss anything (especially since troubleshooting could take forever at my current level of knowledge).

I am also making my first mod, and didn't found that either...

But someone helped me with this in another thread.

http://fractalsoftworks.com/forum/index.php?topic=10114.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 05, 2015, 02:42:13 PM
So, i have this problem:

Like, i have ship without shield, i take very good damage in hull, so i need more repair, so i put less supply/rec.
BUT, now, deployement cost in battle is cost  just very too low.( Imagine a battlecruiser who need just 10 points, with 6 others battlecruiser.... )

So, i search a script for put in my mod who decuple/triple/up  deployement cost for my faction only.

Possible ?

Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2015, 03:01:59 PM
You could probably do it by having a higher supply/rec and then have a script restore CR based on hull damage taken.

Low supply/rec could be a problem in general - it may encourage deploying more of these ships vs weak enemy forces so they take no hull damage and remain cheap to deploy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 05, 2015, 03:14:30 PM
I wanted so much a ship who need so many fleets points for deployement and low supply/rec...

I cannot have big supply/rec  and then, for  calcul for "fleet repair" in campaign and decreases price with my faction?

If we can give salary per month with Nexerelin, i need search if i cannot reduce price of maintenance '.'

Quote
Low supply/rec could be a problem in general - it may encourage deploying more of these ships vs weak enemy forces so they take no hull damage and remain cheap to deploy.
If i up cost CR,  it will compensate,no?

...

Yeah, i think  your idea is better. I need just find this script who restore CR based on hull damage taken. Pirate are always happy after have win loot. (Like i want just use less supplies with my faction because 30 supplies per day just for one destroyer...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on December 05, 2015, 04:43:13 PM
How do I start a system bounty at a specific target?

Right now I'm trying to use:

Code
sector.getEventManager().startEvent(new CampaignEventTarget(ilk1.getMarket()), "system_bounty", null);

but have no idea what to put in the "param" argument (since it's just "java.lang.object param" in the documentation).

*edit - nvm got it, was being dumb with when I was spawning the event (the sector hadn't been created yet).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 06, 2015, 06:05:53 AM
Hey guys, trying to make a script for gun to apply extra damage when only shield is hit, but it is not working. help?
Spoiler
@Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {

        if (shieldHit = true) {              // Apply extra kintetic damage
            engine.applyDamage(
                    target,
                    point,
                    projectile.getWeapon().getDamage().getDamage(),
                    DamageType.KINETIC,
                    1000f,
                    false,
                    false,
                    projectile.getSource()
            );


        }
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 06, 2015, 07:14:34 AM
Three things:
if(shieldHit) is enough to check if a boolean is true. And for example if(!shieldHit) check if it's false.

Emp damage does nothing to shields, you can remove it.

And finally you should use projectile.getDamageAmount() to get the damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 06, 2015, 07:48:07 AM
I have this, no problem, functionnal hullmod who give 3 food per day(  Eh, Supplies is not only food.)
Code
package data.hullmods;  
 
import com.fs.starfarer.api.Global; 
import com.fs.starfarer.api.combat.BaseHullMod; 
import com.fs.starfarer.api.fleet.FleetMemberAPI; 
import com.fs.starfarer.api.impl.campaign.ids.Commodities; 
import com.fs.starfarer.api.util.IntervalUtil;
public class Lt_PortableFarm extends BaseHullMod { 


   protected IntervalUtil interval = new IntervalUtil(1,1); 
     
   @Override 
   public void advanceInCampaign(FleetMemberAPI member, float amount) { 
      float days = Global.getSector().getClock().convertToDays(amount); 
      interval.advance(days); 
      if (interval.intervalElapsed()) 
      { 
        float food = 3;
        member.getFleetData().getFleet().getCargo().addCommodity(Commodities.FOOD, food);     
      }
   } 

But: I want a hullmod as this who give depending on the size of the vessel for just do not create a hullmod for each hullsize.
Code
package data.hullmods;  
 
import com.fs.starfarer.api.Global; 
import com.fs.starfarer.api.combat.BaseHullMod; 
import com.fs.starfarer.api.fleet.FleetMemberAPI; 
import com.fs.starfarer.api.impl.campaign.ids.Commodities; 
import com.fs.starfarer.api.util.IntervalUtil; 
 
public class Lt_PortableFarm extends BaseHullMod { 
     
   public static final float FOOD_FRIGATE = 1; 
   public static final float FOOD_DESTROYER = 2; 
   public static final float FOOD_CRUISER = 4; 
   public static final float FOOD_CAPITAL = 8; 
     
   protected IntervalUtil interval = new IntervalUtil(1,1); 
     
   @Override 
   public void advanceInCampaign(FleetMemberAPI member, float amount) { 
      float days = Global.getSector().getClock().convertToDays(amount); 
      interval.advance(days); 
      if (interval.intervalElapsed()) 
      { 
         float food = 0; 
         switch (member.getHullSpec().getHullSize()) { 
            case FRIGATE:
               food = FOOD_FRIGATE; 
               break; 
            case FIGHTER: 
               food = FOOD_FRIGATE; 
               break; 
            case DESTROYER: 
               food = FOOD_DESTROYER; 
               break; 
            case CRUISER: 
               food = FOOD_CRUISER; 
               break; 
            case CAPITAL_SHIP: 
               food = FOOD_CAPITAL; 
               break; 
         } 
         member.getFleetData().getFleet().getCargo().addCommodity(Commodities.FOOD, food); 
      } 
   } 

But, i have this error: Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/LT_PortableFarm.java', Line 25, Column 16: Assignment conversion not possible from type "com.fs.starfarer.api.combat.ShipAPI$HullSize" to type "int"


PS: this hullmod was created by Histidine and I asked him too.

Why i have this error, so? Thank '.'
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 06, 2015, 07:57:38 AM
Three things:
if(shieldHit) is enough to check if a boolean is true. And for example if(!shieldHit) check if it's false.

Emp damage does nothing to shields, you can remove it.

And finally you should use projectile.getDamageAmount() to get the damage.

thanks!
But were did you see EMP damage in my example?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 06, 2015, 08:12:25 AM
            engine.applyDamage(
                    target,
                    point,
                    projectile.getWeapon().getDamage().getDamage(),
                    DamageType.KINETIC,
                    1000f,
                    false,
                    false,
                    projectile.getSource()
            );
This is EMP damage. I cannot recomend enough using an IDE. It can display help popups and check you code for obvious mistakes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on December 06, 2015, 08:47:12 AM

/snip

But, i have this error: Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/LT_PortableFarm.java', Line 25, Column 16: Assignment conversion not possible from type "com.fs.starfarer.api.combat.ShipAPI$HullSize" to type "int"

That's an error coming from the Janino compiler.
Something about the enum switch it doesn't like.
Perhaps a bug in Janino, as it's supposed to support Java 1.5 enum switches.

Though you appear to have a filename case mismatch too, which might be contributing to the problem.
The class "Lt_PortableFarm" is defined in the file "LT_PortableFarm.java". (Note "Lt_" vs "LT_".)
The Java class file format & compiler require the two to be identical. (it's possible Janino doesn't explicitly check for this, and consequently fails at a later unrelated compilation step).

If correcting that mismatch doesn't fix it, I'd try tweaking the code to see if it's a bug in Janino's compiler that can be avoided.
e.g.
1) Try re-ordering the case statements.
2) Try adding the missing "case DEFAULT:" and/or add a "default:" case too.
3) Try assigning the hullsize to a local variable & switching on that instead.

Worst case scenario; avoid using the Janino compiler completely by compiling the class yourself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 06, 2015, 09:34:29 AM

This is EMP damage. I cannot recomend enough using an IDE. It can display help popups and check you code for obvious mistakes.

But Im using IntellijIDEA, not really experienced user, is there a way to set-up help popups?
Spoiler
(https://photos-3.dropbox.com/t/2/AADWDAwAZI6iCmTTQb_w4vMgo-fvWjEIWVoUoHAUrPjeeA/12/192898178/jpeg/32x32/3/1449439200/0/2/screenshot.jpg/EOzLrZIBGLwHIAIoAg/i9wkG0zd05SCpgakzi9p0miVncD8ndp-PYKn9B2k4u4?size_mode=3&size=1280x960)
[close]

EDIT: ok, it seems I didn't get it. Isn't it says damage.KINETIC? how can I change emp damage to kinetic then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 06, 2015, 09:49:32 AM
Ok TJJ. Not a error of LT/Lt (I have copy a old error).

Not a error a case DEFAULT, i have test.
After, i can always create juste X hullmod for all, ah ah.

Thank.

EDIT: Fine now '.' .
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 07, 2015, 05:12:14 AM
Im not sure on this one:

do scripts work if you place them in mod folder as .java?
Or they has to be compiled into jre?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 07, 2015, 06:35:50 AM
Im not sure on this one:

do scripts work if you place them in mod folder as .java?
Or they has to be compiled into jre?

A question I can answer! :D

They work as *.java. They have to be under data/scripts in the appropriate folder (if applicable).

Compiling into a *.jar should be done for release, but doesn't have to be if you're just doing development.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 07, 2015, 07:02:46 AM
Not exactly. .java files are compiled by the game's compiler Janino. That's quite enough for most cases. However there a some Java functions that Janino doesn't support, then you have to pre-compile your code in a jar to bypass janino. That also decrease the loading time since the game doens't have to do that. There are also some useful functions that comes with compiling, like modifying your code while the game is running.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 07, 2015, 07:58:41 AM
There are also some useful functions that comes with compiling, like modifying your code while the game is running.

Wat????
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 07, 2015, 02:50:19 PM
Hey, i have question: Why i need so many supplies with my faction?
Spoiler
(http://img15.hostingpics.net/pics/693538screenshot015.png) (http://www.hostingpics.net/viewer.php?id=693538screenshot015.png)
[close]

51 supplies per day for just a capital_ship? (It is correct value?)


I need less supply per day, if i give less hull and more armor, no?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 08, 2015, 04:49:19 AM
Hey, i have question: Why i need so many supplies with my faction?
Spoiler
(http://img15.hostingpics.net/pics/693538screenshot015.png) (http://www.hostingpics.net/viewer.php?id=693538screenshot015.png)
[close]

51 supplies per day for just a capital_ship? (It is correct value?)


I need less supply per day, if i give less hull and more armor, no?
The ship is still recovering CR, so it uses supplies/day calculated from the supplies/deploy, CR/deployment and CR recovery/day values. Hull and armor shouldn't affect anything.


Now for a design decision question: Is there a particular reason the new fleet spawning methods use hull size instead of FP now? This messes up the fleet strength of faction mods with qualitatively weak or strong ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 08, 2015, 06:22:11 AM
51 supplies per day for just CR recovery is not just too big? Use 52 supplies just for recovery 3% CR, when i have 0% CR, i need 51 * 20 supplies for regen my capital_ship, is not very too?

EDIT: What is "doctrine" in file.faction , i have never understand '.'.

EDIT2: I have test with my frigate, i have three times more egals with a same frigate in other mod.
I have not CR/deployment, so i have hight cost for compensate.(Yes, fail.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 08, 2015, 07:48:49 AM
What's the secret to getting a JAR to compile? Right now I just have one *.java file, and IntelliJ will not compile it, despite me setting IntelliJ up via the guides here on the forum (and troubleshooting guides elsewhere). IntelliJ just says "files updated" whenever I try to build. Here's my FreespaceModPlugin.java, in case it's an issue with the file:

Spoiler
https://github.com/mechwars/Freespace/blob/master/data/scripts/FreespaceModPlugin.java
[close]

Thoughts? I have "package data.scripts" at the top of the file, so theoretically it should just compile when I build?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 08, 2015, 09:06:12 AM
What's the secret to getting a JAR to compile? Right now I just have one *.java file, and IntelliJ will not compile it, despite me setting IntelliJ up via the guides here on the forum (and troubleshooting guides elsewhere). IntelliJ just says "files updated" whenever I try to build. Here's my FreespaceModPlugin.java, in case it's an issue with the file:

Spoiler
https://github.com/mechwars/Freespace/blob/master/data/scripts/FreespaceModPlugin.java
[close]

Thoughts? I have "package data.scripts" at the top of the file, so theoretically it should just compile when I build?

I found iti s better to move to a folder that is NOT data.scripts

It maybe conflicts with starsector (starsector use data.scripts to store he .java files that are compiled by janino when it launches).

The other thing is pay attention to your mod_info.json, when my mod refused to work, I tought intellij wasn't compiling, and even learned how to use the "jar" commandline command to check my jar file, and later learned there was a typo in my mod_info.json (in the line that defines the mod plugin).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 08, 2015, 09:14:22 AM
What's the secret to getting a JAR to compile? Right now I just have one *.java file, and IntelliJ will not compile it, despite me setting IntelliJ up via the guides here on the forum (and troubleshooting guides elsewhere). IntelliJ just says "files updated" whenever I try to build. Here's my FreespaceModPlugin.java, in case it's an issue with the file:

Spoiler
https://github.com/mechwars/Freespace/blob/master/data/scripts/FreespaceModPlugin.java
[close]

Thoughts? I have "package data.scripts" at the top of the file, so theoretically it should just compile when I build?

I found iti s better to move to a folder that is NOT data.scripts

It maybe conflicts with starsector (starsector use data.scripts to store he .java files that are compiled by janino when it launches).

The other thing is pay attention to your mod_info.json, when my mod refused to work, I tought intellij wasn't compiling, and even learned how to use the "jar" commandline command to check my jar file, and later learned there was a typo in my mod_info.json (in the line that defines the mod plugin).

Thanks. The mod launches and works just fine with the current mod_info.json and *.java files I have, I just can't get IntelliJ to actually create a compiled *.jar file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 08, 2015, 09:42:23 AM
go in the artifacts screen, create an empty jar artifact, and add the compiled output (just double click on it on the right side of the screen).

if that STILL don't work, it means IntelliJ don't think your java files are in a source folder.

Source folders in intellij display blue (only the top folder, not all of them), thus look in your project view to see if your java files are inside a blue folder.

If not, in the project settings screen thre is also a screen to setup this.

My own project (that I also created initially as data/scritps and later found out this woulnd't work) I did this:

my proejct folder has inside it a folder named "sources", this folder is blue.

Inside "sources" there is a folder named CSE, this folder shows yellow with a blue dot.

Inside CSE folder there is my plugin java file, this file has on top of it package "CSE"

EDIT:

(http://snag.gy/yjFs0.jpg)

(http://snag.gy/FZX5c.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 08, 2015, 09:58:05 AM
Thanks! I'll try that out this evening.

EDIT: It worked perfectly! I just had to change my JAR output directory to a folder that wasn't a parent of my source folder, and then IntelliJ stopped auto-excluding my source folder from being considered for compiling.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 09, 2015, 04:23:59 AM
I don't suppose there's any way to discern anything useful from this crash log? (SS+, Nexerelin, Tiandong, Common Radar, and their required utility mods)

Code
1280353 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.M.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.int.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.interfacesuper.o00000(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.U.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 09, 2015, 04:52:18 AM
What would be the most accurate way to determine when a beam weapon has started charging up? I want to trigger a sound at the start of charging, and have it play through the charging sequence. There's no isCharging, so I'm guessing I'll need to rely on getChargeLevel and check if it's non-zero? I feel like there should be another qualifier to prevent the sound from being restarted every time the above check is true.

Unless I just set a "charging" variable to true when the sound starts, check that as part of my if condition, and don't set that variable to false again until isFiring is true?

Thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on December 09, 2015, 05:12:18 AM
How to use the plugins section of config>settings to replace vanilla plugins?

Quote
"officerLevelUp":"data.scripts.plugins.OfficerLevelupPluginImpl",
worked for a custom officer level up plugin, but that was in config settings to start with and all I did was alter the file path. Now I'm trying to do something similar with nav buoys, with the line
Quote
"navBuoyEffect":"data.scripts.plugins.NavBuoyEffect",

which seems to have no effect. help?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 09, 2015, 08:16:50 AM
When the player buy, or sell a commodity to a market, it affects the market internal stocks? Or only the submarket cargo?

suppose a market has 400 lobsters with "GetRollingStockpileAfterDemand", 20 of these are on BlackMarket, 10 on OpenMarket

If you buy all 30, you will get with the GetRollingStockpileAfterDemand 370 lobsters, 380 lobsters, or 400 lobsters?

I DID noticed that when the game generates the cargo it does NOT affect the stockpile, thus why I am wondering if the playertransaction tracker or something like that does this work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rushyo on December 09, 2015, 10:49:19 AM
How do I determine the earliest point I can bring up an interaction dialog without a nullpointerexception?

The initial EveryFrame is too early.

onNewGame(), onNewGameAfterEconomyLoad(), onNewGameAfterTimePass(), onGameLoad() are too early.

I've tried putting loads of defensive conditional checks (Global.getSector() != null && Global.getSector().getCampaignUI() != null && playerFleet != null, etc) but that doesn't help much. Either the dialog doesn't load at all, or it loads and still fails on a nullpointerexception before executing any code in my dialog plugin class  :-\

Been beating my head over this for inumerable hours. I've just tied it to an ability the alpha tester is told to select at the game start for the time being.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 09, 2015, 12:15:17 PM
I don't suppose there's any way to discern anything useful from this crash log? (SS+, Nexerelin, Tiandong, Common Radar, and their required utility mods)

Code
1280353 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.M.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.int.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.interfacesuper.o00000(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.U.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Looks like it happens when loading a game, right? Beyond that, there's nothing useful in this stack trace.

What would be the most accurate way to determine when a beam weapon has started charging up? I want to trigger a sound at the start of charging, and have it play through the charging sequence. There's no isCharging, so I'm guessing I'll need to rely on getChargeLevel and check if it's non-zero? I feel like there should be another qualifier to prevent the sound from being restarted every time the above check is true.

Unless I just set a "charging" variable to true when the sound starts, check that as part of my if condition, and don't set that variable to false again until isFiring is true?

Thoughts?

What you're saying should work, except for beams like the High Intensity Laser, which have beamFireOnlyOnFullCharge:true set.

How to use the plugins section of config>settings to replace vanilla plugins?

Quote
"officerLevelUp":"data.scripts.plugins.OfficerLevelupPluginImpl",
worked for a custom officer level up plugin, but that was in config settings to start with and all I did was alter the file path. Now I'm trying to do something similar with nav buoys, with the line
Quote
"navBuoyEffect":"data.scripts.plugins.NavBuoyEffect",

which seems to have no effect. help?

Generally speaking, unless it's an already-existing key, stuff you put in that section isn't going to do anything. For battle objectives, see data/config/battle_objectives.json.


When the player buy, or sell a commodity to a market, it affects the market internal stocks? Or only the submarket cargo?

suppose a market has 400 lobsters with "GetRollingStockpileAfterDemand", 20 of these are on BlackMarket, 10 on OpenMarket

If you buy all 30, you will get with the GetRollingStockpileAfterDemand 370 lobsters, 380 lobsters, or 400 lobsters?

I DID noticed that when the game generates the cargo it does NOT affect the stockpile, thus why I am wondering if the playertransaction tracker or something like that does this work.

It affects the internal stocks at 10x the normal rate (meaning, buying 10 of something will reduce the *average* stockpile by 10, rather than eventually reducing by 1/10th of the amount.

See: BaseSubmarketPlugin.reportPlayerMarketTransaction()


How do I determine the earliest point I can bring up an interaction dialog without a nullpointerexception?

The initial EveryFrame is too early.

onNewGame(), onNewGameAfterEconomyLoad(), onNewGameAfterTimePass(), onGameLoad() are too early.

I've tried putting loads of defensive conditional checks (Global.getSector() != null && Global.getSector().getCampaignUI() != null && playerFleet != null, etc) but that doesn't help much. Either the dialog doesn't load at all, or it loads and still fails on a nullpointerexception before executing any code in my dialog plugin class  :-\

Been beating my head over this for inumerable hours. I've just tied it to an ability the alpha tester is told to select at the game start for the time being.

A stack trace would help here; I've no idea why it's crashing for you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rushyo on December 09, 2015, 03:10:57 PM

A stack trace would help here; I've no idea why it's crashing for you.

Spoiler
Code
35444 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.CampaignState.showInteractionDialog(Unknown Source)
at data.scripts.BattlestarModPlugin.onGameLoad(BattlestarModPlugin.java:44)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.M.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.int.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.interfacesuper.o00000(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.interfacesuper.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.O00O.processInput(Unknown Source)
at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
at com.fs.starfarer.coreui.intsuper.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.O00O.processInput(Unknown Source)
at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.O00O.processInput(Unknown Source)
at com.fs.starfarer.O0OO.int.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.O00O.processInput(Unknown Source)
at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.M.processInputImpl(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.O00O.processInput(Unknown Source)
at com.fs.starfarer.ui.O0o0.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.O0o0.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.O00O.processInput(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.processInput(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

Ta :)

EDIT: Based on the stack trace, this looks to be very similar to the issue Histidine is encountering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 09, 2015, 03:56:16 PM
Thanks - that's a bit different, if it was the same it'd fail a couple of levels deeper than it does.

After a bit of tinkering, this works:

Code: java
public void onGameLoad(boolean newGame) {
Global.getSector().addTransientScript(new EveryFrameScript() {
private boolean shown = false;
private boolean firstFrame = true;
public boolean runWhilePaused() {
return true;
}
public boolean isDone() {
return false;
}
public void advance(float amount) {
if (firstFrame) {
firstFrame = false;
return;
}
if (!shown) {
Global.getSector().getCampaignUI().showInteractionDialog(Global.getSector().getEntityById("jangala"));
shown = true;
}
}
});
}

Hope the whole "anonymous class" thing makes sense to you; basically just creating an implementation of EveryFrameScript on the fly to avoid having an extra .java file etc.

The thing this does differently from your code is skipping one frame; for reasons I can't recall the game-load code has to advance() the engine once right after loading but before the UI is initialized.

Checking to see if amount > 0 would probably do the job too, since those "from game load" advance() calls pass in 0 for amount.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rushyo on December 09, 2015, 04:01:39 PM
Hope the whole "anonymous class" thing makes sense to you; basically just creating an implementation of EveryFrameScript on the fly to avoid having an extra .java file etc.

The thing this does differently from your code is skipping one frame; for reasons I can't recall the game-load code has to advance() the engine once right after loading but before the UI is initialized.

Checking to see if amount > 0 would probably do the job too, since those "from game load" advance() calls pass in 0 for amount.

Sweet. Yeah, that all makes sense. I'll give it a whirl now.

EDIT: Worked perfectly. Huzzah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 09, 2015, 04:52:27 PM
What would be the most accurate way to determine when a beam weapon has started charging up? I want to trigger a sound at the start of charging, and have it play through the charging sequence. There's no isCharging, so I'm guessing I'll need to rely on getChargeLevel and check if it's non-zero? I feel like there should be another qualifier to prevent the sound from being restarted every time the above check is true.

Unless I just set a "charging" variable to true when the sound starts, check that as part of my if condition, and don't set that variable to false again until isFiring is true?

Thoughts?

What you're saying should work, except for beams like the High Intensity Laser, which have beamFireOnlyOnFullCharge:true set.

Why would that setting not work for beamFireOnlyOnFullCharge:true? Doesn't the weapon just wait to actually fire till the charge = 1 then? How does it work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 09, 2015, 04:54:43 PM
Why would that setting not work for beamFireOnlyOnFullCharge:true? Doesn't the weapon just wait to actually fire till the charge = 1 then? How does it work?

Exactly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Twogs on December 10, 2015, 09:54:23 AM
Is it possible for the same ship system to spawn to different kind of Drones? I really want to design a drone ship, which would be much cooler with 2 kind of drones instead of one
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2015, 12:10:43 PM
Not as such. You could give the drones drone systems that spawn other drones, or manage it directly with some fairly heavy scripting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Twogs on December 10, 2015, 12:26:46 PM
Tought so, ok then I will probably just have just one kind of drone
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 10, 2015, 12:38:38 PM
Alex what is the numbers that show on conditions tooltips? (like AutoFactory (3) )

I assumed it was the "level" of the condition, but reading a condition source it has nothing like that...

so what is it?

And what controls it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2015, 12:55:11 PM
It's the number of those conditions at a market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 10, 2015, 02:02:23 PM
It's the number of those conditions at a market.

How you place multiple conditions on a market?

Also if you did that, how you track what condition is witch?

Also, where this is managed on vanilla? (what file has something that says that jengala has x of y condition?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pushover on December 10, 2015, 08:19:14 PM
See starsector-core/data/campaign/econ/

Conditions are in com/fs/starfarer/impl/campaign/econ/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: StarSchulz on December 10, 2015, 08:33:49 PM
Can fighters be given abilities like ship systems? i wanted to see if i could figure out how to make a custom fighter wing that could phase or teleport.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pushover on December 10, 2015, 08:39:45 PM
Some fighters in Ironclads have Burn Drive, although they can get locked into strange orientations when burning.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: StarSchulz on December 11, 2015, 12:00:35 AM
Ha, i kinda remember something like that when i had ironclads installed. I wonder if the AI can handle individual fighters phase teleporting or moving quickly to the side to avoid missiles and heavy weapons fire.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 11, 2015, 03:07:37 AM
If classB extends/implements classA, and I call entity.removeScriptsOfClass(classA.class), will instances of classB also be removed?

In combat, is there a way to tell if/when a FleetMemberAPI is disabled/destroyed or has retreated? Is there a way to get a list of all such fleet members for a given fleet (i.e. not deployed, not in reserve)?

How you place multiple conditions on a market?

Also if you did that, how you track what condition is witch?
Call market.addCondition(condition) with the same arg multiple times.

Market conditions of the same type are functionally identical so you shouldn't need to tell them apart, but if you do there's market.getSpecificCondition(String id), market.getConditions(String typeId), condition.getId().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 11, 2015, 03:15:46 AM
Question with Netbeans:

You create, so, a project extern to your mod, then, you take all lib that you need. After a create a script, you compile this, then you build?
But , how run with Netbeans? I have always main class not found.

And also, when you have build, after, you need just put file.jar created with others files(so i put all file ...). But not success and Starsector ignore my jar...

I do not understand... and tutorial do not explain this...

Thank
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 11, 2015, 04:42:34 AM
I'm trying to get my head around if this is possible. I have a beam-type weapon that should:


I don't see a way to actually put the weapon on cooldown for a set period of time. I would be happy to script it in if I knew which stat I needed to set when the beam is done firing.

Unless I'm misunderstanding how these weapon stats are supposed to work, which is entirely possible ;)

EDIT: Tested this a bit...

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 11, 2015, 09:02:16 AM
Can I add information to conditions tooltips? (like the stability tooltip, that show what is affecting stability... I wanted to add to conditions tooltips warnings about what is blocking production, like missing resources/crew or excess goods stored)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 11, 2015, 11:21:18 AM
If classB extends/implements classA, and I call entity.removeScriptsOfClass(classA.class), will instances of classB also be removed?

They won't. If checks whether script.getClass() == parameterClass.

In combat, is there a way to tell if/when a FleetMemberAPI is disabled/destroyed or has retreated? Is there a way to get a list of all such fleet members for a given fleet (i.e. not deployed, not in reserve)?

There isn't. Added:
CombatFleetManagerAPI
   List<FleetMemberAPI> getDisabledCopy();
   List<FleetMemberAPI> getDestroyedCopy();
   List<FleetMemberAPI> getRetreatedCopy();

Was a bit of an oversight these methods weren't in the interface to begin with. For now, you might take a snapshot of the reserves at battle start and try to work from that. Distinguishing "retreated" and "destroyed/disabled" might be tricky, though.

  • Charge up for 3 seconds (chargeup)
  • Fire at full power for 4 seconds (number of bursts and burst delay??)
  • Charge down for 1.5 seconds (chargedown? Add to cooldown?)
  • Be on cooldown for 25 seconds until it can be charged again and fired (?)

Take a look at the Tachyon Lance or Phase Lance stats in weapon_data, both of these do what you're trying to do, I think. If you don't want them to fire while charging up, add "beamFireOnlyOnFullCharge":true to the .wpn file.


Can I add information to conditions tooltips? (like the stability tooltip, that show what is affecting stability... I wanted to add to conditions tooltips warnings about what is blocking production, like missing resources/crew or excess goods stored)

Yes, see: MarketConditionPlugin interface.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 12, 2015, 09:06:49 AM
Can I add a new commodity that has the demand class "REGULAR_CREW" but does NOT count as crew inside your ship? (ie: passengers, the intention is to allow trading of workers between stations without consuming your supplies in the process... it would be nice if it still used crew space though, to justify using the transport shuttles, and because putting people in cargo holds is weird).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rushyo on December 12, 2015, 09:19:08 PM
I can write a custom UI in a small panel in an interaction dialog by implementing CustomUIPanelPlugin. I can render custom UI in combat by implementing renderInUICoords() in interface EveryFrameCombatPlugin.

Is it possible for me to render a full screen custom UI in the campaign interface, similar to existing fleet or map UIs? I'd like to add a new basic interface that focuses on 'important people'. If so, are there any existing examples, particularly some which would demonstrate the basic window elements (like the pretty borders, tab interface, text rendering, etc)? Doesn't need to be in-depth; I should be able to work out the niceties (I'm comfortable with OpenGL).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on December 12, 2015, 09:25:20 PM
How do I override tips(shown in main screen and under loading bar) with a mod?
I tried creating strings\tips.json in the mod category, but seems it is adding new tips instead of overwriting them...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rushyo on December 12, 2015, 09:50:07 PM
How do I override tips(shown in main screen and under loading bar) with a mod?
I tried creating strings\tips.json in the mod category, but seems it is adding new tips instead of overwriting them...

You need to add "data/strings/tips.json" to your mod_info.json's "replace" section.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on December 12, 2015, 10:07:52 PM
How do I override tips(shown in main screen and under loading bar) with a mod?
I tried creating strings\tips.json in the mod category, but seems it is adding new tips instead of overwriting them...

You need to add "data/strings/tips.json" to your mod_info.json's "replace" section.
Is the format "replace":["data/strings/tips.json","",...] ?
I still haven't figured out the full functionalities of mod_info.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ChaseBears on December 12, 2015, 10:21:35 PM
Hello,

I'm trying to figure out how subfactions are defined. Namely, despite looking through what feels like every file in the starsector-core directory, I can't find how the Lion's Guard are defined as related to the Sindrian Diktat other than their comms channel.  Can anyone point me to the right file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rushyo on December 12, 2015, 10:34:08 PM
Is the format "replace":["data/strings/tips.json","",...] ?
I still haven't figured out the full functionalities of mod_info.json.

Yup, that's it  :) Gimme a PM if you have any trouble. I'm around for a bit...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ChaseBears on December 13, 2015, 03:56:15 AM
Another Q.  Is there any way for auto-named ships in missions (as in, not in the campaign) to draw from a name list?

I have a bunch of prime numbers for machine ships in my ship name list, but having random human ships pull from that is annoying.

I looked through the API documentation but it looked like the only thing you could define for a side was its ship prefix, and I quickly got lost in the weeds when digging through the campaign fleet spawning API.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 13, 2015, 04:55:43 AM
You can set the names manually, from a list in the mission definition file if necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ChaseBears on December 13, 2015, 09:20:36 AM
Yeah thats what i ended up doing. My Java ended up being incredibly ugly but it seems to work alright.  Used Excel to make up a big list quickly. 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on December 15, 2015, 06:02:44 AM
What should I know if I want to create - or edit - custom fonts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: murumuru on December 16, 2015, 01:29:11 AM
I made faction and made a description in .faction file, however I still get "No description yet..." description ingame. What am I doing wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on December 16, 2015, 02:01:18 AM
You need a description in a csv with a FACTION type. Take a look at strings/ folder in game data (as far as I remember the file is named descriptions.csv, but I'm just not sure enough).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 16, 2015, 03:07:04 AM
You can look also others  mods for this.(Because, less thing, so more readable.)

For my description factions, i have put here:
Namemod/data/strings/descriptions.csv:
Quote
id,type,"text1","text2","text3","notes"
idship,SHIP,"text",,,
idfaction,FACTION,"Text",,,

(id faction in your file.faction)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: murumuru on December 16, 2015, 03:10:24 AM
Now I have another question. I compiled .jar file, I created mod_info.json and referred to .jar file and modPlugin. However, when I try to start a new game I get "Fatal: null" error.

Log:
Spoiler
Code
216919 [Thread-5] INFO  data.scripts.world.MyModPlugin  - MyModPlugin Started
219412 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.fleet.CargoData.initMothballedShips(Unknown Source)
at com.fs.starfarer.campaign.CustomCampaignEntity.<init>(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
at data.scripts.world.MyStationSpawn.generate(MyStationSpawn.java:26)
at data.scripts.world.MyGen.generate(MyGen.java:23)
at data.scripts.world.MyModPlugin.onNewGame(MyModPlugin.java:43)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.M.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.int.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.interfacesuper.o00000(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.U.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

And I cannot figure out what is wrong here, because it works without compilation.

@celestis,
@Snrasha,
Thank you, what is that description line in .faction file for then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 16, 2015, 03:19:17 AM
Quote
Thank you, what is that description line in .faction file for then?

None idea, ah ah, sorry, this answer is useless. (But, i have put a short description of my faction in case.)

For compiled, i cannot help you, my mod have not jar.(Yes, very simply mod)

I have question, same, again(because i have not find):
Where i find a link for create a .jar with class  as all others mods? Because, when i compile with Netbeans, i have jar, class, but game does not seem to read? (I search a tutorial '.' )

Thank.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: murumuru on December 16, 2015, 03:39:59 AM
@Snrasha,
I use IntelliJ IDEA 15.0.1 to compile .jar file.
In short:
1. Import Project -> From sources -> [Select mod folder]
2. File -> Project Structure -> Libraries -> Add Libraries -> [Add all available files from starsector-core (and other libs if any)]
3. File -> Project Structure -> Artifacts -> Module [Your Module], Jar files from libraries: extract to the target JAR -> OK -> Remove everything from the left panel, except [Your Module] compile output.
3a. Output directory can be changed as well.
4. Then .jar can be generated by: Build -> Make Project, it will be generated in the output directory.

5. Append following lines to the mod_info.json:
Code
	"jars":[PATH_TO_YOUR_JAR_FILE],
"modPlugin":PATH_TO_YOUR_MODPLUGIN_CLASS,
, where
PATH_TO_YOUR_JAR_FILE - path to your .jar file, i.e. "jars/MyJarFile.jar" (Quotes are necessary);
PATH_TO_YOUR_MODPLUGIN_CLASS - path to your ModPlugin class file (as far as I understand it should be init file of your mod), i.e. "data.scripts.world.MyModPlugin" (Quotes are necessary).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 16, 2015, 05:50:48 AM
Ah yes, i have forgot this thing in mod_info.json , ever since. Ah ah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 16, 2015, 06:25:29 AM
QUESTIONS:


1) I'm using a bit of code to add specific ship and spawning a specific fleet

Code
	public static void vnsmain_spawner()
    {
        int vns_mainfleet = getSector().getEntitiesWithTag("vns_mainfleet").size();
        if (vns_mainfleet < 1)
        {
 
            String dest_name = "vaynar";
            String home_name = "avalon";
            SectorEntityToken home = getSector().getEntityById(home_name);
            SectorEntityToken dest = getSector().getEntityById(dest_name);

            home = getSector().getEntityById("avalon");
            log.info("Spawning VNS main fleet in Vaynar.");


            CampaignFleetAPI vns_firstfleet = FleetFactory.createGenericFleet("VNS", "1st Fleet", 1, 200);
                vns_firstfleet.addTag("vns_mainfleet");

            getSector().getFaction("VNS").pickShipAndAddToFleet(ShipRoles.FREIGHTER_MEDIUM, 1, vns_firstfleet);
            getSector().getFaction("VNS").pickShipAndAddToFleet(ShipRoles.TANKER_MEDIUM, 1, vns_firstfleet);


            FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_archangel_standard");
member.setShipName("VNS Archangel");
member.setFlagship(true);
vns_firstfleet.getFleetData().addFleetMember(member);

            FleetMemberAPI member2 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_cobra2_assault2");
member2.setShipName("VNS Venom");
vns_firstfleet.getFleetData().addFleetMember(member2);    
            FleetMemberAPI member3 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_cobrax_advanced");
member3.setShipName("VNS Deimos");
vns_firstfleet.getFleetData().addFleetMember(member3);
            FleetMemberAPI member4 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_cobrax_advanced");
member4.setShipName("VNS Phobos");
vns_firstfleet.getFleetData().addFleetMember(member4);
            FleetMemberAPI member5 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_dedalus_elite");
member5.setShipName("VNS Dedalus");
vns_firstfleet.getFleetData().addFleetMember(member5);
            FleetMemberAPI member6 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_prometheus_elite");
member6.setShipName("VNS Caldabolg");
vns_firstfleet.getFleetData().addFleetMember(member6);
            FleetMemberAPI member7 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_avenger_mk1_elite");
member7.setShipName("VNS Gae bolg");
vns_firstfleet.getFleetData().addFleetMember(member7);
            FleetMemberAPI member8 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_paladin_elite");
member8.setShipName("VNS Ascension");
vns_firstfleet.getFleetData().addFleetMember(member8);
            FleetMemberAPI member9 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_paladin_elite");
member9.setShipName("VNS Tempestus Irae");
vns_firstfleet.getFleetData().addFleetMember(member9);

            FleetMemberAPI member10 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_perserverance_elite");
member10.setShipName("VNS Eternity");
vns_firstfleet.getFleetData().addFleetMember(member10);
            FleetMemberAPI member11 = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "vns_avenger_mk2_elite");
member11.setShipName("VNS Radiance");
vns_firstfleet.getFleetData().addFleetMember(member11);



            FleetMemberAPI member12 = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "ASF14_wing");
vns_firstfleet.getFleetData().addFleetMember(member12);
            FleetMemberAPI member13 = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "PhnI_Spec_wing");
vns_firstfleet.getFleetData().addFleetMember(member13);
            FleetMemberAPI member14 = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "Armageddon_T_wing");
vns_firstfleet.getFleetData().addFleetMember(member14);
            FleetMemberAPI member15 = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "ASF14E_wing");
vns_firstfleet.getFleetData().addFleetMember(member15);


            vns_firstfleet.getCargo().addCrew(CargoAPI.CrewXPLevel.ELITE, (int)(vns_firstfleet.getCargo().getMaxPersonnel()));
            vns_firstfleet.getCargo().addSupplies(vns_firstfleet.getCargo().getMaxCapacity()/3);
            vns_firstfleet.getCargo().addFuel(vns_firstfleet.getCargo().getMaxFuel());

            vns_firstfleet.getFleetData().sort();
            FleetFactory.finishAndSync(vns_firstfleet);


            home.getContainingLocation().addEntity(vns_firstfleet);
            vns_firstfleet.setLocation(home.getLocation().x + 0, home.getLocation().y + 0);
            vns_firstfleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, home, 3, "preparing for duty");
            vns_firstfleet.addAssignment(FleetAssignment.DEFEND_LOCATION, home, 21, "patrolling around "+home.getName());
            vns_firstfleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, home, 3, "standing down from duty");
            vns_firstfleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, home, 1000, "returning to "+home.getName());
            vns_firstfleet.setPreferredResupplyLocation(home);


            log.info("Spawned VNS main fleet in Vaynar");
        }
    }

Can I also specifiy the portrait, name and personality of the admiral in charge?



2) I want to create a beam canon with a fixed beam duration and re-charge time (regardless of low flux). So even if you had zero flux, the beam would fire for 5 seconds and then re-charge for 5-10 seconds.
Can it be done in a simple way?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on December 16, 2015, 06:29:24 AM
2) I believe Phase Lance, Tachyon Lance, Burst PD Laser, Heavy Burst Laser, Guardian PD System do that(With latter three having capacitor for rapid successive firing). Might worth looking into.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 16, 2015, 02:00:05 PM
Hi, i do not understand how change color bullet:

I have :

   "fringeColor":[255,200,70,225],
   "coreColor":[255,200,200,180],   

But, where find value for this list [,,,] and why when i change value in this list, i have never  color in game who change ? Thank you.

EDIT: i have find, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 16, 2015, 02:38:17 PM
Code
3376195 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.events.InvestigationEventGoodRepWithOther.pickMarket(InvestigationEventGoodRepWithOther.java:346)
at com.fs.starfarer.api.impl.campaign.events.InvestigationEventGoodRepWithOther.startEvent(InvestigationEventGoodRepWithOther.java:126)
at com.fs.starfarer.campaign.events.CampaignEventManager.processNextEventCheck(Unknown Source)
at com.fs.starfarer.campaign.events.CampaignEventManager.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Market invastigation?
What kind of error am I look at here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 17, 2015, 03:37:29 AM
Now I have another question. I compiled .jar file, I created mod_info.json and referred to .jar file and modPlugin. However, when I try to start a new game I get "Fatal: null" error.

Log:
Spoiler
Code
216919 [Thread-5] INFO  data.scripts.world.MyModPlugin  - MyModPlugin Started
219412 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.fleet.CargoData.initMothballedShips(Unknown Source)
at com.fs.starfarer.campaign.CustomCampaignEntity.<init>(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
at data.scripts.world.MyStationSpawn.generate(MyStationSpawn.java:26)
at data.scripts.world.MyGen.generate(MyGen.java:23)
at data.scripts.world.MyModPlugin.onNewGame(MyModPlugin.java:43)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.M.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.int.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.interfacesuper.o00000(Unknown Source)
at com.fs.starfarer.ui.null.processInput(Unknown Source)
at com.fs.starfarer.ui.U.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

And I cannot figure out what is wrong here, because it works without compilation.

@celestis,
@Snrasha,
Thank you, what is that description line in .faction file for then?
1) Paste the code.

2) I'd presume unused legacy stuff.

Code
3376195 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.events.InvestigationEventGoodRepWithOther.pickMarket(InvestigationEventGoodRepWithOther.java:346)
at com.fs.starfarer.api.impl.campaign.events.InvestigationEventGoodRepWithOther.startEvent(InvestigationEventGoodRepWithOther.java:126)
at com.fs.starfarer.campaign.events.CampaignEventManager.processNextEventCheck(Unknown Source)
at com.fs.starfarer.campaign.events.CampaignEventManager.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Market invastigation?
What kind of error am I look at here?
Likely an out-of-date version of Starsector (the good rep investigations were removed in 0.7.1) or one of its mods (likely SS+ or Nexerelin).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 17, 2015, 11:32:43 AM
I have put in my faction:
      "willTradeWhenHostile":true,
But, when i am hostile with my faction, i cannot trade in their market.

Why? >.<


Thank.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2015, 12:03:43 PM
Apparently, that's a holdover from the past and doesn't actually do anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on December 18, 2015, 11:50:46 AM
Hey guys, a little help needed.Moved to IDE but it does not want to import dependencies, even if libraries are set correctly, any solution?



[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on December 18, 2015, 03:24:49 PM
Does anyone know where in starfarer.api.zip is:

1. AI for patrol fleets to attack hostile fleets
2. AI for trade fleets to evade pursuing fleets
3. requirements for joining a battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nuclear_ash on December 18, 2015, 11:45:29 PM
What magic is behind the tug ship? Why there's always only 1 ship of that type even in the mods? And where to look for tug cable buff code? Say if I want to change it from +1 burn to +2 burn.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 19, 2015, 12:14:45 PM
How I add some initial stock of stuff before the "economy stabilization" so that after it finishes markets already have industrial goods for sale (instead of still picking up to speed with the initial raw material production) ?

I tried adding a market

Code
@Override
    public void onNewGame()
    {
        super.onNewGame();
        initialStockMarket = Global.getFactory().createMarket("initial_stock", "initial stock", 9);
        initialStockMarket.getCommodityData(Commodities.HEAVY_MACHINERY).setAverageStockpile(1000000000000f);
        initialStockMarket.setFactionId(Factions.INDEPENDENT);
        Global.getSector().getEconomy().addMarket(initialStockMarket);
    }

But it didn't worked, seemly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: murumuru on December 19, 2015, 04:47:28 PM
I am creating generic fleets using FleetFactoryv2, thus using FleetParams.
What do following parameters do and mean?
Code
java.lang.String fleetType
float qualityBonus
float qualityOverride
float officerNumMult
int levelLimit
I did not find the descriptions in the docs, if I missed them then I would be grateful for a link.

Next are the questions about FleetAssignment.
Can I send the fleet into another system just by something like
Code
fleet.addAssignment(FleetAssignment.RAID_SYSTEM, randomSectorEntityToken, days);
, if I can do so, then is time to travel included into days or they start counting only when fleet arrives into target system?
Will it look around the system for targets or will stay near the randomSectorEntityToken?
If fleet will not travel to the system due to some reason, will it just abandon the task and start next one?
Will FleetAssignment.GO_TO_LOCATION_AND_DESPAWN despawn fleet if the fleet will not be able to reach the location before the end of the days allocated for the assignment?
Is it even possible to send fleet to entity in another system, if yes, then how?

And at last, is there a description of .faction file structure?
In particular, I am interested in "custom" section: what is available and still works there and "shipRoles".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: StarSchulz on December 19, 2015, 09:28:56 PM
Can anyone point me in the right direction on starting a faction mod? there has got to be some kind of tips page around here somewhere! x.x I finally think i have a reasonable idea on where i want to go with it, but i don't know how to code it all unless i spend a week tearing apart and reverse engineering an existing faction mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 19, 2015, 10:15:04 PM
What magic is behind the tug ship? Why there's always only 1 ship of that type even in the mods?
Not sure what you mean. Are you saying there aren't enough tugs in the store? That's controlled by the submarket plugin for each submarket type.
And where to look for tug cable buff code? Say if I want to change it from +1 burn to +2 burn.
com/fs/starfarer/api/impl/campaign/TowCable.java
(make a modified version of this Java class and make the tow_cable entry (or your own hullmod) in hull_mods.csv point to your class)

How I add some initial stock of stuff before the "economy stabilization" so that after it finishes markets already have industrial goods for sale (instead of still picking up to speed with the initial raw material production) ?

I tried adding a market

Code
@Override
    public void onNewGame()
    {
        super.onNewGame();
        initialStockMarket = Global.getFactory().createMarket("initial_stock", "initial stock", 9);
        initialStockMarket.getCommodityData(Commodities.HEAVY_MACHINERY).setAverageStockpile(1000000000000f);
        initialStockMarket.setFactionId(Factions.INDEPENDENT);
        Global.getSector().getEconomy().addMarket(initialStockMarket);
    }

But it didn't worked, seemly.
Try setting the (non-average) stockpile as well.
Or if you need stuff added to cargo, there's this (though I have no idea if it's actually necessary or even does anything):
Code: java
        if (market.getFactionId().equals("templars"))
        {
            CargoAPI cargoTemplars = market.getSubmarket("tem_templarmarket").getCargo();
            cargoTemplars.addCommodity(commodityID, amountToAdd * 0.2f);
            return;
        }
        if (market.getSubmarket(Submarkets.SUBMARKET_OPEN) == null)    // some weirdo mod
        {
            return;
        }
       
        CargoAPI cargoOpen = market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo();
        CargoAPI cargoBlack = cargoOpen;
        if (market.hasSubmarket(Submarkets.SUBMARKET_BLACK))
            cargoBlack = market.getSubmarket(Submarkets.SUBMARKET_BLACK).getCargo();
        CargoAPI cargoMilitary = null;
        if (market.hasSubmarket(Submarkets.GENERIC_MILITARY))
            cargoMilitary = market.getSubmarket(Submarkets.GENERIC_MILITARY).getCargo();
       
        if (commodityID.equals("agent") || commodityID.equals("saboteur"))
        {
            if (cargoMilitary != null)
            {
                cargoOpen.addCommodity(commodityID, amountToAdd * 0.02f);
                cargoMilitary.addCommodity(commodityID, amountToAdd * 0.11f);
                cargoBlack.addCommodity(commodityID, amountToAdd * 0.02f);
            }
            else
            {
                cargoOpen.addCommodity(commodityID, amountToAdd * 0.04f);
                cargoBlack.addCommodity(commodityID, amountToAdd * 0.11f);
            }
        }
        else if(!market.isIllegal(commodity))
            cargoOpen.addCommodity(commodityID, amountToAdd * 0.15f);
        else if (commodityID.equals("hand_weapons") && cargoMilitary != null)
        {
            cargoMilitary.addCommodity(commodityID, amountToAdd * 0.1f);
            cargoBlack.addCommodity(commodityID, amountToAdd * 0.05f);
        }
        else
            cargoBlack.addCommodity(commodityID, amountToAdd * 0.1f);

I am creating generic fleets using FleetFactoryv2, thus using FleetParams.
What do following parameters do and mean?
Code
java.lang.String fleetType
float qualityBonus
float qualityOverride
float officerNumMult
int levelLimit
I did not find the descriptions in the docs, if I missed them then I would be grateful for a link.
qualityBonus adds to the market's stability for determining the allowed variants (like how fleets from badly destabilized markets have more (D) ships).
qualityOverride ignores the stability value completely and just uses the specified quality threshold (0.0 - 1.0).
officerNumMult allows more officers in the fleet, of course (still limited to 10).
levelLimit caps the level of officers in the fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: murumuru on December 20, 2015, 01:31:48 AM
qualityOverride ignores the stability value completely and just uses the specified quality threshold (0.0 - 1.0).
What do I use to avoid the override, just zero?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 20, 2015, 12:47:38 PM
My game keeps hard crashing Java SE with no error on new campaign start, whenever it tries to spawn a patrol for one of my new planets:

44185 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.fleets.PatrolFleetManager  - 0 out of a maximum 4 patrols in play for market [Shivan Origin]

Right after that, the game hard crashes. Anyone have any ideas?

EDIT1: Commenting out the sector file in question allows the new game to be created. What could be wrong with my sector java file? I made it based on other ones I made that actually work. Here it is: https://github.com/mechwars/Freespace/blob/initial-version/sources/data/scripts/world/freespace/Cocytus.java

EDIT2: I just tried copying an existing system that worked and just changed the faction. Crash. Could the faction file be the issue? I'm boggled here without an error message to work with.

EDIT3: Redid the faciton file and I'm still getting the crash. Changed the system to use a different faction, and it loads fine. I have no idea why the faction is crashing on load with no error.

SOLVED: You can't have 0 probability for smalls ships in your faction file. Your faction must have some chance for small ships, or a new game will just crash on load. Not sure if this is a bug or not, but it was the one key difference between the faction that crashed and the ones that didn't.

This faction doesn't have carriers, so I'm just having it fall back to combat ships if it picks one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 20, 2015, 08:16:01 PM
qualityOverride ignores the stability value completely and just uses the specified quality threshold (0.0 - 1.0).
What do I use to avoid the override, just zero?
-1
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 21, 2015, 03:32:59 AM
I'm having trouble getting my beam cannons to look right.

Do these lines:
   "fringeColor":[250,250,220,255],
   "coreColor":[5,255,10,155],
   "glowColor":[0,255,10,255],
   "width":10.0,

Even do anything?
Also, is it R,G,B, luminosity? Or is the other different.

Currently, my beams are far too wide and far too white.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stalker on December 21, 2015, 04:20:37 AM
I'm having trouble getting my beam cannons to look right.

Do these lines:
   "fringeColor":[250,250,220,255],
   "coreColor":[5,255,10,155],
   "glowColor":[0,255,10,255],
   "width":10.0,

Even do anything?
Also, is it R,G,B, luminosity? Or is the other different.

Currently, my beams are far too wide and far too white.

It's RGB+Luminosity. You have that right.

I believe the order in-game goes core -> fringe -> glow. So right now, your almost-white glow has a whole lot more luminosity than your core, which is probably contributing to the all white issue.

I'm not sure why your beam is wide. 10f is not a very wide beam.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 21, 2015, 04:07:19 PM
Can you make an animated turret base?

I basically wanted to make an animated Vertical Launch Missile System:
Here's part of the code

Code
{
"id":"vns_mis_cruise1",
"specClass":"projectile",
"type":"MISSILE",
"size":"LARGE",
"turretUnderSprite":"graphics/weapons/animated/vmls/vmls00.png",
"turretSprite":"",
"hardpointSprite":"",

"numFrames":5,
"frameRate":30,

The graphiccs are there, but any time I try to start the game it complains that it cannot load image [01]
 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 22, 2015, 09:49:00 AM
What is the game engine encoding?

ie: What is the encoding on strings on the source, on csv files, and on json files?

here csv files keep breaking, I am suspecting it is a encoding issue (because I am in Brazil, thus many of my apps use Windows-1252 encoding... also my Windows itself is set to use japanese encoding because of japanese games I have here).

Also if I ever wanted to write stuff in my own language (Brazillian portuguese), knowing the encoding is needed too (the Ç character byte for example, change a lot between each possible encoding)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 22, 2015, 10:11:58 AM
Hi, i search script who change parameter according to difficulty. But, i have just find in CharacterCreationData : setdifficulty and getdifficulty, but i do not find parameter. (Less salvage, for example, with easy difficult)


Thank you.

update: I have see in rule.csv:
Quote
ngcDifficultyOptions,NGCStep3,,"SetTooltip ngcEasy ""- Reduces damage taken by 50%\n- Increases damage dealt by 50%\n- Increases sensor range by 500 units\n- Increases salvage by 50%\n- Reduces level of enemy officers by 50%\n- Extra 10,000 credits\n- Extra starting ship & officer""

SetTooltipHighlightColors ngcEasy hColor hColor hColor hColor hColor hColor

SetTooltipHighlights ngcEasy ""50%"" ""50%"" ""500"" ""50%"" ""50%"" ""10,000""
[...]
ngcEasyOption,NewGameOptionSelected,$option == ngcEasy,"AddText ""- Reducing damage taken by 50%\n- Increasing damage dealt by 50%\n- Increasing sensor range by 500 units\n- Increasing salvage by 50%\n- Reducing level of enemy officers by 50%"" textFriendColor
But...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 22, 2015, 03:29:27 PM
How I get all commodities on the market of a certain demand type? (example: Lobster and Luxury goods at the same time, or all types of crew at the same time)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 23, 2015, 08:13:16 AM
In commodities.csv, does a larger number in the decay column mean the commodity decays faster or slower?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on December 23, 2015, 08:27:56 AM
In commodities.csv, does a larger number in the decay column mean the commodity decays faster or slower?

Decay formula:

usefulStock = max(supply*utility, demand)

if(usefulStock  <= 0) usefulStock = 1

toDecay = max(stockpile - usefulStock, 0) * min(0.5, decay * DECAY_MULT)

stockpile = stockpile - toDecay


DECAY_MULT is the "economyDecayMult" number in the settings.json, default is 1

So, decay on the commodity, has no effect below 0.5, and it dictates the percentage of the "useless" stockpile that decays.

So at a decay 1, with vanilla economy settings, the market will always have the stockpile cut to the demand, or supply amount of the month.

At decay 0.1 (most of vanilla defaults) means every month 10% of the excess goods are lost.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 23, 2015, 12:59:23 PM
What the hell am I looking at here?


IndexOutOfBoundsException: Index: 1, Size: 1

Code
8951 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [G:\Minigames\Starsector\starsector-core\..\mods\ironclads2\data\weapons\vns_lrg_mis_micro.wpn]
8951 [Thread-5] INFO  com.fs.starfarer.loading.WeaponSpecLoader  - Loading weapon [G:\Minigames\Starsector\starsector-core\..\mods\ironclads2\data\weapons\vns_med_bal1b.wpn]
8952 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [G:\Minigames\Starsector\starsector-core\..\mods\ironclads2\data\weapons\vns_med_bal1b.wpn]
9067 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.scripts.world.FleetSpawner] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9351 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.scripts.world.SectorGen] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9357 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.world.TimeManager]
9388 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.world.BaseSpawnPoint]
9389 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.scripts.world.SectorGen] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9490 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [com.fs.starfarer.api.impl.combat.CRPluginImpl] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9491 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.scripts.world.SectorGen] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9493 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9493 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [com.fs.starfarer.api.impl.campaign.OfficerLevelupPluginImpl] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9494 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [com.fs.starfarer.api.impl.campaign.NewGameDialogPluginImpl] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9520 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.missions.ironcladsRSF.MissionDefinition] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
9531 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.remove(Unknown Source)
at com.fs.starfarer.loading.specs.S.addTurretAngleOffset(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.float(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


I can't find anything wrong
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pushover on December 23, 2015, 04:55:08 PM
That error means that somewhere something is trying to access index 1 (the second element) of an array that has 1 element. Something to do with the starting angle of a weapon? Is there a ship with 1 weapon that should start at an offset?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on December 25, 2015, 07:37:47 AM
Hello everyone.

When I try to create my own market condition I ran into a problem. Why in the code of file "my_mod\data\campaign\econ\my_new_market_condition" the following code works with custom commodity "my_commodity":

Code
market.getCommodityData("my_commodity").getSupply().modifyFlat(id, my_commodity_supply * crewDemandMet);

Where "my_commodity" - are id of my new commodity and "my_commodity_supply" - private static final float indicating the amount of supply.


But the following code almost same essentially unfortunately for some reason it does not work:

Code
market.getCommodityData("my_commodity").getDemand().modifyFlat(id, my_commodity_demand);

Please help to understand what is the problem.

And what are the best ways to set the amount of demand of new custom commodity in market condition file?

Thanks in advance for your help.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DinoZavarski on December 27, 2015, 04:26:22 AM
Is it possible to modify crew experience bonuses with a hullmod? Like increasing bonuses for green to regular crew. decreased for veteran and penalty instead of bonus for elite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 27, 2015, 04:31:09 AM
Yes, you have a skill for this, so you can go look this skill and transform this thing for a hullmod. This is possible, i have a hullmod who give a supply per day, why not this thing?
Spoiler
Quote
package data.characters.skills.scripts;

import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;

public class CommandExperienceEffect1 implements CharacterStatsSkillEffect {

   public void apply(MutableCharacterStatsAPI stats, String id, float level) {
      stats.getCrewXPGainMult().modifyPercent(id, SkillData.COMMAND_EXPERIENCE_CREW_XP_BONUS * level);
   }

   public void unapply(MutableCharacterStatsAPI stats, String id) {
      stats.getCrewXPGainMult().unmodify(id);
   }
   
   public String getEffectDescription(float level) {
      return "+" + (int) (SkillData.COMMAND_EXPERIENCE_CREW_XP_BONUS * level) + "% crew experience gained";
   }
   
   public String getEffectPerLevelDescription() {
      return "" + (int) SkillData.COMMAND_EXPERIENCE_CREW_XP_BONUS + "%";
   }

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

}

[close]
After, for penalty for elite, i need research
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on December 27, 2015, 08:13:21 PM
So what's the difference between a dev mod and a stable mod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 28, 2015, 02:06:00 AM
For me:

A dev mod: You can have very bug (very long to repair)(so instable version), not balanced value( X50 extra salvage, because you want test)
And, can have very many update fastly , maybe...


A stable mod: A mod who can launch without problem if all conditions are made.(This mod is not compatible with SS+, per example) And have balanced value with this mod and starsector (Ex: Templars is a overpower faction, so it is normal, EX2: A frigate(Of your mod) who kill a Templar cruiser, it is not normal, except if you play very good))
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: StarSchulz on December 30, 2015, 12:39:06 PM
How do the luddic path fleets spawn? they have no station or market anywhere that i can see. [ i want to replicate this sort of behavior in my own mod if at all possible ]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nuclear_ash on December 30, 2015, 01:49:25 PM
Where is the code for fleet deployment window? Is it obfuscated? I'm trying to make a skill which decreases ship deployment cost.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Caricature on December 30, 2015, 02:30:27 PM
How do the luddic path fleets spawn? they have no station or market anywhere that i can see. [ i want to replicate this sort of behavior in my own mod if at all possible ]

Luddic Path fleets have their source market chosen from Luddic Church markets. LuddicPathFleetManager calls up FleetFactoryV2 to make the fleets, and one of the parameters determines the faction to choose the source market from (apparently). More relevant to your question, the code calls CampaignFleetAPI.setLocation to choose where the fleet actually gets spawned in at. (If the player is closer to the market the fleet is targeting, it gets spawned near the player instead of at its home base.) The Misc class has a couple of methods for getting locations near to the player. Hope this helps.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jay2Jay on December 30, 2015, 11:23:28 PM
Query: Would it be possible to make a ship that has all built in weapons but can use a hullmod to convert it to using all weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on December 31, 2015, 08:58:29 AM
is there a mod that increases the number/amount in stock at an open market, including ships?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lucian Greymark on January 01, 2016, 12:33:31 AM
Hi, while working on my mod I set up a (pretty standard) burst pd laser. The only problem is that it refuses to target missiles and fighters, even when I add the 'hints' it still focuses fire on whatever my target is, or even just the biggest threat (as I imagine most weapons do)

I'll post the data line here in case I've made some massive *** up but I have no idea where to look at this.

Panacles BPD,scion_panacles,1,0,500,300,,,1,90,6,20,2,,ENERGY,,40,,0.1,0.1,,,,,,10000,,,,,,"PD,ANTI_FTR",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 01, 2016, 01:00:51 AM
I'm trying to make a skill which decreases ship deployment cost.
The deploy cost as seen in the deploy window (and which the battle size setting restricts) is the same as the ship's supplies/deploy value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on January 01, 2016, 01:20:42 AM
Hi, while working on my mod I set up a (pretty standard) burst pd laser. The only problem is that it refuses to target missiles and fighters, even when I add the 'hints' it still focuses fire on whatever my target is, or even just the biggest threat (as I imagine most weapons do)

I'll post the data line here in case I've made some massive *** up but I have no idea where to look at this.

Panacles BPD,scion_panacles,1,0,500,300,,,1,90,6,20,2,,ENERGY,,40,,0.1,0.1,,,,,,10000,,,,,,"PD,ANTI_FTR",

Disruptor,neutrino_disruptor,0,600,600,50,,50,2.5,90,6,,,,ENERGY,,200,0.1,0.1,0.6,0.7,,,,,10000,,,,,"PD,PD_ONLY,ANTI_FTR",89712
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lucian Greymark on January 01, 2016, 01:29:28 AM
No change, it's like it's ignoring the hints ;.;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 01, 2016, 02:04:52 AM
Artefact light PD(B),Noir_ABS1,1,200,300,,20,,5,90,3,20,2,,FRAGMENTATION,5,,0,2,10,0.05,0,50,10,1,,300,0,4,10,"PD",3007

Hum, you have not too many "," ? Between projectile speed(10 000 , i suppose for a burst PD) and your "PD"?

Me, i have a PD missiles and my missiles focus missiles, so it is not bugged, ah ah :p

You have test with this?
Panacles BPD,scion_panacles,1,0,500,300,,,1,90,6,20,2,,ENERGY,,40,,0.1,0.1,,,,,,10000,,,,"PD,ANTI_FTR",hints
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on January 01, 2016, 04:37:52 AM
PD,PD_ONLY,ANTI_FTR

All you need is put these 3 hints togeter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lucian Greymark on January 01, 2016, 05:18:06 AM
idk what the problem was but I just redid the whole weapon and it's working perfectly now. If I can figure out what was causing the trouble I'll post my findings here but honestly I'm still stumped
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 01, 2016, 11:36:01 AM
Question, i train with IA missiles(so i have paste IA of many mod for understand), so i want build a full missile who focus missile. Not problem here because missile focus only missile and ignore ship. But:

What is this: missile.getDamageTarget() ?    (MissileAPI)  I am not english, so i do not understand this get... who seem just return null for me.

Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on January 01, 2016, 03:00:27 PM
can someone make a mod that increases the number of things sold on all markets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 02, 2016, 04:16:42 PM
I'm trying to modify the damage of a seeking weapon based on the time its been in existence. Here is my code. The console messages show that the math is right but its still doing full damage. I'm assuming the onHitEffectPlugin is called before damage is assigned but maybe I'm wrong.

edit: I added a check for didDamage() and it looks like the projectile has already done its full damage before the onHit gets called. So, what method should I be implementing to change the damage BEFORE it does its full damage?

edit2: I found a workaround. I define the weapon as having 1 damage in the csv and then assign all the damage through the script. It's not ideal but it works for now. I'm still hoping that there is some method that can affect a shot's damage before it assigns it to its target.

Code
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.SoundAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.FluxTrackerAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import data.scripts.util.TEM_Twig;
import java.awt.Color;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.entities.SimpleEntity;
import org.lwjgl.util.vector.ReadableVector2f;
import org.lwjgl.util.vector.Vector2f;
import org.lazywizard.console.Console;

public class SFB_PlasmaROnHitEffect implements OnHitEffectPlugin {

private static final float PlasmaRMaxFlightTime = 10.0f;

    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
        if (target == null || point == null) {
            return;
        }
Console.showMessage("In onHit method");

        if (target instanceof ShipAPI)
{

            ShipAPI ship = (ShipAPI)target;
float flightTime = projectile.getElapsed();
float damagedecay = Math.min(1.0f, (flightTime/PlasmaRMaxFlightTime));
projectile.setDamageAmount(projectile.getDamageAmount()* ( 1.0f - damagedecay ));
Console.showMessage("Damage " + projectile.getDamageAmount());

        }
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on January 03, 2016, 02:40:20 AM
Is there a way to work out whether a ship is currently repairing fighters?

I can't seem to find a way to work out whether flight decks are in use... or even get at the flight decks for a ship in any form via the API.

I can work out (I think) if a fighter wing is attempting to go to a flight deck (via ShipAPI.isLanding() and ShipAPI.IsFinishedLanding()) but is that the best I can get at the moment?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 04, 2016, 05:39:05 PM
Is there a way to tell how much damage has been done to a projectile by point defenses and other sources? The game must keep track because it knows when to destroy the projectile.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 04, 2016, 05:54:33 PM
Is there a way to tell how much damage has been done to a projectile by point defenses and other sources? The game must keep track because it knows when to destroy the projectile.

CombatEntityAPI.getHitpoints() and CombatEntityAPI.getMaxHitpoints()


Is there a way to work out whether a ship is currently repairing fighters?

I can't seem to find a way to work out whether flight decks are in use... or even get at the flight decks for a ship in any form via the API.

I can work out (I think) if a fighter wing is attempting to go to a flight deck (via ShipAPI.isLanding() and ShipAPI.IsFinishedLanding()) but is that the best I can get at the moment?

I don't think there's a way. Added a FighterLaunchBayAPI.openForLanding() method...


edit2: I found a workaround. I define the weapon as having 1 damage in the csv and then assign all the damage through the script. It's not ideal but it works for now. I'm still hoping that there is some method that can affect a shot's damage before it assigns it to its target.

There isn't, unfortunately. May end up adding that at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 04, 2016, 07:35:41 PM
Is there a way to tell how much damage has been done to a projectile by point defenses and other sources? The game must keep track because it knows when to destroy the projectile.

CombatEntityAPI.getHitpoints() and CombatEntityAPI.getMaxHitpoints()


Is there a way to work out whether a ship is currently repairing fighters?

I can't seem to find a way to work out whether flight decks are in use... or even get at the flight decks for a ship in any form via the API.

I can work out (I think) if a fighter wing is attempting to go to a flight deck (via ShipAPI.isLanding() and ShipAPI.IsFinishedLanding()) but is that the best I can get at the moment?

I don't think there's a way. Added a FighterLaunchBayAPI.openForLanding() method...


edit2: I found a workaround. I define the weapon as having 1 damage in the csv and then assign all the damage through the script. It's not ideal but it works for now. I'm still hoping that there is some method that can affect a shot's damage before it assigns it to its target.

There isn't, unfortunately. May end up adding that at some point.

Thank you for the answers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on January 05, 2016, 09:44:50 PM
Is there a way to work out whether a ship is currently repairing fighters?

I can't seem to find a way to work out whether flight decks are in use... or even get at the flight decks for a ship in any form via the API.

I can work out (I think) if a fighter wing is attempting to go to a flight deck (via ShipAPI.isLanding() and ShipAPI.IsFinishedLanding()) but is that the best I can get at the moment?

I don't think there's a way. Added a FighterLaunchBayAPI.openForLanding() method...


Thank you! And is it currently possible to get a list of FighterLaunchBayAPI from a ShipAPI?

You can go the other way with FighterLaunchBayAPI.getShip() but I can't see a way to get from Ship -> FighterLaunchBay(s).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fgdfgfthgr on January 05, 2016, 11:13:51 PM
I had write a missile ai, but what should I do if I what to use it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 06, 2016, 03:06:40 AM
I had write a missile ai, but what should I do if I what to use it?

Look modplugin of my mod Artefact/Noir , or templar. Look customAI missile.


I have a problem of null pointer exception: But, i do not find my error ><
Quote
    private final Map<ShipAPI, IntervalUtil> timersdebuff = new HashMap<>();
Spoiler
Quote
List<BeamAPI> activebeam = engine.getBeams();
        int beamSize = activebeam.size();
        for (int i = 0; i < beamSize; i++) {
            BeamAPI beamm = activebeam.get(i);
            if (beamm.didDamageThisFrame() || !beamm.getWeapon().isFiring()) {
                continue;
               
            }
        if (beamm.getWeapon().getId().equals("Noir_slow")) {
            //ShipAPI shipdamaged = null;
            if (beamm.getWeapon().isFiring()){   
                if (beamm.getDamageTarget() != null) {
                    if (beamm.getDamageTarget().getCollisionClass().equals(CollisionClass.SHIP)){
                        ShipAPI shipdamaged = (ShipAPI) beamm.getDamageTarget();
                        if (timersdebuff.containsKey(shipdamaged)){
                            this.timersdebuff.remove(shipdamaged, new IntervalUtil(0.1f,2f)); 
                        }
                        this.timersdebuff.put(shipdamaged, new IntervalUtil(0.1f,2f));
                        [Add a clock each time when you touch a ship]
                        }
                    }
                }         
            }           
        }   [ I have a null pointer exception here.]
        if (!timersdebuff.isEmpty()){
            Iterator<Map.Entry<ShipAPI, IntervalUtil>> iter = timersdebuff.entrySet().iterator();
            while (iter.hasNext()) {
                Map.Entry<ShipAPI, IntervalUtil> entry = iter.next();
                ShipAPI shipclear= entry.getKey();
                IntervalUtil interval = this.timersdebuff.get(shipclear);
                interval.advance(amount);
                if (interval.intervalElapsed()) {
                    //timersdebuff.remove(shipclear, new IntervalUtil(0.1f,2f));
                    iter.remove();   
                }
               
        }}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lucian Greymark on January 06, 2016, 03:20:20 AM
Hi there, at the moment I'm having a problem with a custom torpedo. After firing a couple of things happen, either it functions as intended, hitting a target and exploding. Sometimes it passes straight through targets and flies of into the distance. If it doesn't hit anything (glitched or otherwise) it reaches the end of it's flight time and then sits there, the projectile becomes inert but it doesn't disappear either.

I'll post the relevant code in spoilers so if I've royally screwed something up you lads can spot it. I'm about at the end of my tether trying to fix this.

And yes, in advance I'll confirm that it is supposed to have absurd emp damage.


Projectile
Spoiler
{
   "id":"estoc_rpg",
   "specClass":"missile",
   "missileType":"ROCKET",
   #"sprite":"graphics/missiles/missile_torpedo.png",
   #"size":[16,28],   
   #"center":[8,14],
   "sprite":"graphics/missiles/scion_estocrpg.png",
   "size":[14,23],   
   "center":[7,11],
   "collisionRadius":20,
   "collisionClass":"PROJECTILE_FF",
   "collisionClassByFighter":"PROJECTILE_FIGHTER",
   "explosionColor":[255,100,100,255],  # purely visual, will get a white additively blended core on top of this color
   "explosionRadius":350, # purely visual
   "explosionSpec":{"duration":0.1f, # not visual
                "radius":175,
                "coreRadius":75, # full damage within core radius
                "collisionClass":HITS_SHIPS_AND_ASTEROIDS,
                "collisionClassByFighter":HITS_SHIPS_AND_ASTEROIDS,
                "particleSizeMin":5.0,
                "particleSizeRange":3.0,
                "particleDuration":1,
                "particleCount":200,
                "particleColor":[170,70,230,255]},
   "flameoutTime":3, # total time from flameout to full fadeout
   "noEngineGlowTime":0.5, # time spent without the engine glow being rendered
   "fadeTime":0.5, # fadeout duration               
   "engineSpec":{"turnAcc":0,
              "turnRate":0,
              #"acc":35,
              "acc":500,
              "dec":0},
   "engineSlots":[{"id":"ES1",
               "loc":[-11, 0],
               #"loc":[-14, 0],
                #"style":"TORPEDO",
                "style":"CUSTOM",
               "styleSpec":{
                  "mode":"QUAD_STRIP", # PARTICLES or QUAD_STRIP, determines which params are used
                  "engineColor":[170,70,230,255],
                  "contrailDuration":2,
                  "contrailWidthMult":1.5,
                  "contrailWidthAddedFractionAtEnd":1,  # can be negative. makes trail spread out/narrow at the end
                  "contrailMinSeg":5, # min segment length, in pixels
                  "contrailMaxSpeedMult":0f,
                  "contrailAngularVelocityMult":0.5f,
                  "contrailSpawnDistMult":0f, # how far away from engine it starts
                  "contrailColor":[170,70,230,50],
                  "glowSizeMult":2.5,
                  "glowAlternateColor":[170,70,230,255],
                  "type":"GLOW" # GLOW or SMOKE; additive or regular blend mode
               },
                "width":10.0,
                "length":80.0,
                "angle":180.0}]
}
         
[close]

Weapon
Spoiler
{
   "id":"scion_estoc",
   "specClass":"projectile",
   "type":"BALLISTIC",
   "size":"MEDIUM",
   "turretSprite":"graphics/weapons/scion_estoc.png",
   "hardpointSprite":"graphics/weapons/scion_estoc.png",
   "hardpointOffsets":[10, 0],
   "turretOffsets":[7, 0],
   "hardpointAngleOffsets":[0],
   "turretAngleOffsets":[0],
   "barrelMode":"ALTERNATING",
   "animationType":"SMOKE",
   "renderHints":[],
   "interruptibleBurst":false,
   "displayArcRadius":1000,
   #"smokeSpec":{"particleSizeMin":20.0,
   #          "particleSizeRange":20.0,
   #          "cloudParticleCount":3,
   #          "cloudDuration":1.0,
   #          "cloudRadius":10.0,
   #          "blowbackParticleCount":3,
   #          "blowbackDuration":2.0,
   #          "blowbackLength":30.0,
   #          "blowbackSpread":10.0,
   #          "particleColor":[100,100,100,200]},
   "smokeSpec":{"particleSizeMin":16.0,
             "particleSizeRange":18.0,
             "cloudParticleCount":8,
             "cloudDuration":1.5,
             "cloudRadius":10.0,
             "blowbackParticleCount":4,
             "blowbackDuration":2.0,
             "blowbackLength":22.0,
             "blowbackSpread":15.0,
             "particleColor":[125,15,25,105]},
   "autocharge":true,
   "requiresFullCharge":true,            
   "projectileSpecId":"estoc_rpg",
   "fireSoundOne":"high_intensity_laser_loop",
   "fireSoundTwo":"hypervel_driver_fire",
}
}
[close]

csv line
Spoiler
Estoc,scion_estoc,2,0,1500,,5000,100000,150,30,14,3,0.05,3,ENERGY,,,3,10,1,,,0,0,0,0,,3000,1.0,200,STRIKE,,
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ChaseBears on January 06, 2016, 03:27:36 AM
first pass thoughts: you have it classed as BALLISTIC.  Intentional?

also the spoiler'd stuff is nigh-unreadable, think its messing up the code-box.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 06, 2016, 03:49:00 AM
For my bug, same bug with others, i think.

shipdamaged.getMutableStats().getMaxSpeed().modifyMult(shipdamaged.getFleetMemberId(), 0.1f);

Crash me. ah ah

when i unmodify, he unmodify all and crash my game, i suppose.
Fun:
Spoiler
(http://i.imgur.com/VdbfkZF.gif)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lucian Greymark on January 06, 2016, 06:24:39 AM
first pass thoughts: you have it classed as BALLISTIC.  Intentional?

also the spoiler'd stuff is nigh-unreadable, think its messing up the code-box.



Okay I took the code tags out and it didn't completely break my post so that's a good start. As for the ballistic thing, yes it is intentional, and no it doesn't affect it, I've tried it with all three weapon types, same problems. I'm guessing it probably has something to do with the projectile itself but Idk what
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on January 06, 2016, 07:21:57 AM
I was wondering two things:
  • Does getCurrFlux() include Hard Flux?
  • Is there a way to stop a ship from getting the 0 flux boost besides constantly giving it a small amount of flux?

1) Yes.
2) setting MutableShipStatsAPI.getZeroFluxMinimumFluxLevel() to something below zero should do it. e.g.
getZeroFluxMinimumFluxLevel().modifyFlat(id, -1000);

I know I should of followed up on this sooner, but using stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, -1000); doesn't seem to do anything, when used in a ShipSystemStatsScript.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 06, 2016, 08:07:10 AM
Does anyone have an idea about the cause of this error?
Code
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Spec of class [com.fs.starfarer.rpg.super] with id [suicidal] not found
It is related to migrating a mod 0.65->0.7, the fleet factory fails to add an officer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on January 06, 2016, 08:34:07 AM
Does anyone have an idea about the cause of this error?
Code
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Spec of class [com.fs.starfarer.rpg.super] with id [suicidal] not found
It is related to migrating a mod 0.65->0.7, the fleet factory fails to add an officer.

Presumably, the relevant .faction file lists Officer personality option as 'Suicidal' - and this personality type is no longer in the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 06, 2016, 08:39:15 AM
Thanks a lot)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fgdfgfthgr on January 06, 2016, 12:59:19 PM
That is my Mod Plugin:
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import data.scripts.weapons.Mine_AI;
import data.scripts.world.fleadenModGen;
import org.dark.shaders.light.LightData;
import org.dark.shaders.util.ShaderLib;

public class FleadenModPlugin extends BaseModPlugin
{
public static final String MINE_MISSILEID = "mine_mirv";
    private void initFleaden() {
    new fleadenModGen().generate(Global.getSector());
    }
    @Override
    public void onApplicationLoad() throws ClassNotFoundException{ 
        try { 
            Global.getSettings().getScriptClassLoader().loadClass("org.dark.shaders.util.ShaderLib"); 
        } catch (ClassNotFoundException ex) { 
            return;
        } 
        ShaderLib.init(); 
        LightData.readLightDataCSV("data/lights/FD_light_data.csv"); 
    } 

    public void onNewGame()
    {
        // Calling a separate method avoids duplicate code with onEnabled()
        initFleaden();
    }
public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        switch (missile.getProjectileSpecId()) {
            case MINE_MISSILEID:
                return new PluginPick<MissileAIPlugin>(new Mine_AI(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SPECIFIC);
            default:
        }
        return null;
    }
}
But I get that:
Code
157897 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.FleadenModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.FleadenModPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/FleadenModPlugin.java', Line 20, Column 22: Cannot determine simple type name "fleadenModGen"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/FleadenModPlugin.java', Line 20, Column 22: Cannot determine simple type name "fleadenModGen"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5398)
at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5207)
at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5188)
at org.codehaus.janino.UnitCompiler.access$12600(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$16.visitReferenceType(UnitCompiler.java:5119)
at org.codehaus.janino.Java$ReferenceType.accept(Java.java:2880)
at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5675)
at org.codehaus.janino.UnitCompiler.access$15000(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$16.visitNewClassInstance(UnitCompiler.java:5144)
at org.codehaus.janino.Java$NewClassInstance.accept(Java.java:4082)
at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7333)
at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3873)
at org.codehaus.janino.UnitCompiler.access$6900(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:3263)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:3290)
at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:4368)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2662)
at org.codehaus.janino.UnitCompiler.access$4400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$7.visitMethodInvocation(UnitCompiler.java:2627)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2654)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1643)
at org.codehaus.janino.UnitCompiler.access$1100(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java:936)
at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:2097)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
... 5 more
If I don't add the part of missile ai, it would not make this error.
 ??? ??? ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 06, 2016, 01:15:32 PM
Quote
   @Override
    public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        switch (missile.getProjectileSpecId()) {
            case IDARS:
               return new PluginPick<MissileAIPlugin>(new CustomARS(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            case IDARN:
                return new PluginPick<MissileAIPlugin>(new CustomARS(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            case IDABS:
               return new PluginPick<MissileAIPlugin>(new CustomABS(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            default:
                return null;
        }
My plugin pick, why mod_specific? And you have very bad placement of your return null, also xD


Mine_MIRV, you copy my idea of mine missile? :D (But, yes, i have not create a mine AI, just a Mine plugin)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fgdfgfthgr on January 06, 2016, 08:45:24 PM
Quote
   @Override
    public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        switch (missile.getProjectileSpecId()) {
            case IDARS:
               return new PluginPick<MissileAIPlugin>(new CustomARS(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            case IDARN:
                return new PluginPick<MissileAIPlugin>(new CustomARS(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            case IDABS:
               return new PluginPick<MissileAIPlugin>(new CustomABS(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            default:
                return null;
        }
My plugin pick, why mod_specific? And you have very bad placement of your return null, also xD


Mine_MIRV, you copy my idea of mine missile? :D (But, yes, i have not create a mine AI, just a Mine plugin)

......
Error again, and that is a Incomprehensible error?
Code
66367 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.FleadenModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.FleadenModPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/FleadenModPlugin.java', Line 29, Column 19: Unknown variable or type "ShaderLib"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/FleadenModPlugin.java', Line 29, Column 19: Unknown variable or type "ShaderLib"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5424)
at org.codehaus.janino.UnitCompiler.access$12300(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$16.visitPackage(UnitCompiler.java:5115)
at org.codehaus.janino.Java$Package.accept(Java.java:3164)
at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5419)
at org.codehaus.janino.UnitCompiler.access$15400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$16.visitAmbiguousName(UnitCompiler.java:5149)
at org.codehaus.janino.Java$AmbiguousName.accept(Java.java:3135)
at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7333)
at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3873)
at org.codehaus.janino.UnitCompiler.access$6900(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:3263)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:3290)
at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:4368)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2662)
at org.codehaus.janino.UnitCompiler.access$4400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$7.visitMethodInvocation(UnitCompiler.java:2627)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2654)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1643)
at org.codehaus.janino.UnitCompiler.access$1100(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java:936)
at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:2097)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
... 5 more
I am very sure I enable the ShaderLib.
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.SectorAPI;
import data.scripts.world.fleadenModGen;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import data.scripts.weapons.Mine_AI;
import org.dark.shaders.light.LightData;
import org.dark.shaders.util.ShaderLib;

public class FleadenModPlugin extends BaseModPlugin
{
public static final String MINE_ID = "mine_mirv";
    private void initFleaden() {
    new fleadenModGen().generate(Global.getSector());
    }
    @Override
    public void onApplicationLoad() throws ClassNotFoundException{ 
        try { 
            Global.getSettings().getScriptClassLoader().loadClass("org.dark.shaders.util.ShaderLib"); 
        } catch (ClassNotFoundException ex) { 
            return;
        } 
        ShaderLib.init(); 
        LightData.readLightDataCSV("data/lights/FD_light_data.csv"); 
    } 

    public void onNewGame()
    {
        // Calling a separate method avoids duplicate code with onEnabled()
        initFleaden();
    }
   @Override
    public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        switch (missile.getProjectileSpecId()) {
            case MINE_ID:
               return new PluginPick<MissileAIPlugin>(new Mine_AI(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            default:
                return null;
        }
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 06, 2016, 09:11:01 PM
Quote
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/FleadenModPlugin.java', Line 29, Column 19: Unknown variable or type "ShaderLib"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)

Global.getSettings().getScriptClassLoader().loadClass("org.dark.shaders.util.ShaderLib");
Maybe=>
Class<?> def = Global.getSettings().getScriptClassLoader().loadClass("exerelin.campaign.SectorManager"); 

Delete maybe also import org.dark.shaders.util.ShaderLib;   because you import in this line, maybe?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fgdfgfthgr on January 07, 2016, 12:44:54 PM
Quote
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/FleadenModPlugin.java', Line 29, Column 19: Unknown variable or type "ShaderLib"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)

Global.getSettings().getScriptClassLoader().loadClass("org.dark.shaders.util.ShaderLib");
Maybe=>
Class<?> def = Global.getSettings().getScriptClassLoader().loadClass("exerelin.campaign.SectorManager"); 

Delete maybe also import org.dark.shaders.util.ShaderLib;   because you import in this line, maybe?
What a wonderful nice error :o :
Code
78714 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.FleadenModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.FleadenModPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/FleadenModPlugin.java', Line 28, Column 15: Assignment conversion not possible from type "java.lang.String" to type "int"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/FleadenModPlugin.java', Line 28, Column 15: Assignment conversion not possible from type "java.lang.String" to type "int"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
at org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:9071)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1344)
at org.codehaus.janino.UnitCompiler.access$1700(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$4.visitSwitchStatement(UnitCompiler.java:942)
at org.codehaus.janino.Java$SwitchStatement.accept(Java.java:2402)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
... 5 more
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.SectorAPI;
import data.scripts.world.fleadenModGen;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import data.scripts.weapons.Mine_AI;

public class FleadenModPlugin extends BaseModPlugin
{
public static final String MINE_ID = "mine_mirv";
    private void initFleaden() {
    new fleadenModGen().generate(Global.getSector());
    }

    public void onNewGame()
    {
        // Calling a separate method avoids duplicate code with onEnabled()
        initFleaden();
    }
   @Override
    public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        switch (missile.getProjectileSpecId()) {
            case MINE_ID:
               return new PluginPick<MissileAIPlugin>(new Mine_AI(missile, launchingShip), CampaignPlugin.PickPriority.MOD_SET);
            default:
                return null;
        }
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 07, 2016, 12:55:28 PM
You have not forgot compiled your code?

at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)

Because, if you use janino, you cannot maybe compile this script who need be compiled. You can send my your file, i compile a jar and test, if you want( If you do not compile)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fgdfgfthgr on January 07, 2016, 03:31:36 PM
You have not forgot compiled your code?

at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)

Because, if you use janino, you cannot maybe compile this script who need be compiled. You can send my your file, i compile a jar and test, if you want( If you do not compile)
http://www.mediafire.com/download/nc2r5rr1qrrk4c7/Fleaden_en.rar
...here it is, after compile can you tell me how to compile? ??? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 07, 2016, 04:33:45 PM
1: You have fail your class Mine_AI, ( java editor see this error),  one reason why your game crash.
2: This Mine_AI is on weapons, but your mine_AI package on missileAI....
3: It is also a problem of compilation : Install netbeans or Intel ( You have tutorial in modding ressources)

4: For unknow reason, i have lost your mod in my list of mod. I do not understand why, ah ah.  But, after delete modinfo and reset, it is fine, now.

Warning, i link your your file compiled, but after you cannot change a file.java with just a notebloc, he read compiled file in priority.
I link a file who have all lib (shaderlib and lady, so you do not need active theses mod, ah ah, yes 10 Mo your mod if you do not clean, you can rego 6Mo, if you clean, but you need know how run a compiled java, i think.

After, also, i have modified mod_info, i have not idea why, but this file is corrupted, so, yes,  you need put description, again, ah ah. I need go sleep, sorry ><.

http://www.mediafire.com/download/xj1zdag5bxwxc6j/Fleaden_en.rar

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fgdfgfthgr on January 07, 2016, 05:24:48 PM
1: You have fail your class Mine_AI, ( java editor see this error),  one reason why your game crash.
2: This Mine_AI is on weapons, but your mine_AI package on missileAI....
3: It is also a problem of compilation : Install netbeans or Intel ( You have tutorial in modding ressources)

4: For unknow reason, i have lost your mod in my list of mod. I do not understand why, ah ah.  But, after delete modinfo and reset, it is fine, now.

Warning, i link your your file compiled, but after you cannot change a file.java with just a notebloc, he read compiled file in priority.
I link a file who have all lib (shaderlib and lady, so you do not need active theses mod, ah ah, yes 10 Mo your mod if you do not clean, you can rego 6Mo, if you clean, but you need know how run a compiled java, i think.

After, also, i have modified mod_info, i have not idea why, but this file is corrupted, so, yes,  you need put description, again, ah ah. I need go sleep, sorry ><.

http://www.mediafire.com/download/xj1zdag5bxwxc6j/Fleaden_en.rar


Thank you so much! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 08, 2016, 02:11:45 PM
Who have a better effect weapon lightning emp without too lag?
I have this that, but maybe too to lag. (Hum, i put this weapon  in large mount after, for limited, ah ah.)
Spoiler
Video: 2x speed
(http://i.imgur.com/sDq8Ud4.gif)
[close]

And why we have so many emp arc on my ship?  (You can look, a effect , when you look down GIF)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 15, 2016, 09:52:55 PM
How can I determine that a fighter has just spawned from carrier bay/is currently launching from the bay?
API has methods isLanding, isFinishedLanding, but they seem to indicate only the landing TO carrier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 17, 2016, 02:51:33 AM
And another question: is ShipAPI.setShield() actually working?
I called it on a shield-less ship, but it didn't raise shield ever. I tried dev mode and transmitted command to that ship and wasn't able to do it manually too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 17, 2016, 11:30:59 AM
And another question: is ShipAPI.setShield() actually working?
I called it on a shield-less ship, but it didn't raise shield ever. I tried dev mode and transmitted command to that ship and wasn't able to do it manually too.

It should work - just tried it and it does. Two issues: one, the AI won't become aware of having a shield if you add it to a ship mid-fight, and 2) the ship needs to have a shield radius and center set up in the .ship file. Which it also needs for the shield-adding hullmods to work, so specifying those is a requirement even for shieldless ships. I'm guessing the latter is the issue here - it's probably raising the shield, but it's just radius 0.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 17, 2016, 09:43:37 PM
And another question: is ShipAPI.setShield() actually working?
I called it on a shield-less ship, but it didn't raise shield ever. I tried dev mode and transmitted command to that ship and wasn't able to do it manually too.

It should work - just tried it and it does. Two issues: one, the AI won't become aware of having a shield if you add it to a ship mid-fight, and 2) the ship needs to have a shield radius and center set up in the .ship file. Which it also needs for the shield-adding hullmods to work, so specifying those is a requirement even for shieldless ships. I'm guessing the latter is the issue here - it's probably raising the shield, but it's just radius 0.

Thanks for the reply, Alex. Unfortunately this isn't a hullmod - it is a script adding a temporary shield in combat. I guess there is no way to reassing the ship AI to "shielded" after the effect took place (and back to shieldless after shield is removed)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 17, 2016, 10:28:30 PM
Thanks for the reply, Alex. Unfortunately this isn't a hullmod - it is a script adding a temporary shield in combat. I guess there is no way to reassing the ship AI to "shielded" after the effect took place (and back to shieldless after shield is removed)?

ShipAPI.resetDefaultAI() should do it. Will make the AI forget what it was thinking, but shouldn't be a huge deal.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefiasOne on January 18, 2016, 08:06:11 AM
I've added some new logos to the mods i'm working on but i've hit this frustrating little problem. I keep getting resource not found when the game loads.

Code
"insurgency_net":{
"name":"Insurgency Intelligence",
"logo":" graphics/khs_graphics/factions/logo_insurgency.png",
"icon":" graphics/khs_graphics/factions/logo_insurgency.png",
"image":"graphics/khs_graphics/factions/logo_insurgency.png",
"sound":"ui_channel_comm_secure",
"faction":"insurgency",
"type":"Intelligence Report",
"shortType":"Intel",
},

I've commented the code just to bypass this problem but I don't understand what I'm missing here. The game won't find that file at the specified location.


Also I would like to replace this piece of code for an AI script.

CombatUtils.getCombatEngine().getShips().iterator() - it no longer exists

Thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 19, 2016, 01:32:07 AM
Thanks for the reply, Alex. Unfortunately this isn't a hullmod - it is a script adding a temporary shield in combat. I guess there is no way to reassing the ship AI to "shielded" after the effect took place (and back to shieldless after shield is removed)?

ShipAPI.resetDefaultAI() should do it. Will make the AI forget what it was thinking, but shouldn't be a huge deal.
Thanks a lot, I'll try that!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 22, 2016, 03:19:18 AM
ShieldAPI void setRadius(float radius, String textureInner, String textureRing);
What does these texture look like?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 22, 2016, 07:07:46 AM
ShieldAPI void setRadius(float radius, String textureInner, String textureRing);
What does these texture look like?
I believe they are in the FX folder (some square 128 or 256 tga with a ring in it)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on January 23, 2016, 05:12:22 AM
Question about ShipSystemAIScript.
If I want to activate the system I can just write ship.useSystem() in advance() method.
But what should I do to deactivate it (for toggle-mode systems)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2016, 10:16:24 AM
IIRC just useSystem() again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 23, 2016, 10:19:41 AM
To get a $global.memoryValue from Java code, I use Global.getSector().getMemoryWithoutUpdate().
To get a $faction.value it's factionAPI.getMemoryWithoutUpdate().
But how do I get a $player.value?

(Also, what's the difference between getMemory() and getMemoryWithoutUpdate()?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on January 23, 2016, 11:01:06 AM
I believe you can use something like Global.getSector().getPlayerFleet().getCommanderStats() to get at some of the player memory data. The problem with the player memory is it's in a whole bunch of different places, which means you often have to go digging through several different parts of the API to get player-related information.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2016, 07:02:52 PM
To get a $global.memoryValue from Java code, I use Global.getSector().getMemoryWithoutUpdate().
To get a $faction.value it's factionAPI.getMemoryWithoutUpdate().
But how do I get a $player.value?

Global.getSector().getCharacterData().getMemory()

(Also, what's the difference between getMemory() and getMemoryWithoutUpdate()?)

getMemory() calls the various updateXXXFacts() methods, whichever are applicable for that memory. A lot of the memory data has an expiration of 0 and so is recomputed on a getMemory() call instead of being saved/kept around all the time.

See: the CoreCampaignPluginImpl.updateXXXFacts() methods; these and any mod-provided ones will be called.

So, generally, if you're only going to write to the memory, you should call getMemoryWithoutUpdate(). If you're going to read from it, it depends on what you want to read, i.e. whether it's something you know sticks around or if it's something recomputed. Also, generally, if you *do* call getMemory(), you want to store the return value in a variable to avoid calling the method multiple times.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on January 23, 2016, 08:47:48 PM
So, generally, if you're only going to write to the memory, you should call getMemoryWithoutUpdate(). If you're going to read from it, it depends on what you want to read, i.e. whether it's something you know sticks around or if it's something recomputed. Also, generally, if you *do* call getMemory(), you want to store the return value in a variable to avoid calling the method multiple times.

Interesting, it was never quite clear to me what the difference actually was.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2016, 10:16:15 PM
(A corollary to the above: calling getMemory() outside the context of a UI interaction is likely a bad idea, while getMemoryWithoutUpdate() is ok.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LB on January 25, 2016, 04:21:46 PM
Is it possible to lock a weapon to a specific angle, aside from issuing a setCurrAngle() every frame? Is it possible to restrict the firing arc of weapons dynamically?

Are there any foreseeable issues with doing either of the above from a ship system, rather than a EveryFrameWeaponEffectPlugin?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 27, 2016, 01:36:23 PM
It's not, aside from what you're saying (which, IIRC, would still restrict it to the weapon's normal arc).

Are there any foreseeable issues with doing either of the above from a ship system, rather than a EveryFrameWeaponEffectPlugin?

Should be fine either way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on February 01, 2016, 04:09:49 PM
Is there a way to tell if combat is ending?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 05, 2016, 09:50:44 AM
Hi question, a mean for put a decorative weapon like a sprite of ship?

Hum, look this gif and you can understand easy my problem : (Look just engine)

Spoiler
(http://i.imgur.com/dLyz22h.gif)
[close]

"renderHints":["RENDER_ADDITIVE"]   is good for that, but he change also color of my object (this thing blu and red)... and i have not find where is list of RENDER...   ( Base of my object  is light green if i put that ><) .
Spoiler
Semi transparent or if i put under a sprite of this object: I have always a green too green.
(http://i.imgur.com/XRooeit.png)
[close]

Thank you '.'

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2016, 08:58:00 AM
Is there a way to tell if combat is ending?

Hmm, don't think so, at least not super easily. You could check things like "nothing on the field for one side, and no reserves or is in full retreat", and that'd probably do it, though.


@Snarsha: I'm sorry, I don't understand what you're asking. Could you try explaining in a different way?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 06, 2016, 09:56:13 AM
Hum, sorry, i have think a other means.

But small question: If i have a weapon who boost stats, but, if i put more weapon, i do not have more boost, just one.

Spoiler
Quote
        @Override
   public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
               
      if (engine.isPaused()) return;
               
                ShipAPI ship = weapon.getShip();


                if(weapon.isDisabled()){
                        ship.getMutableStats().getFluxDissipation().unmodifyMult(weapon.getId());
                } else{
                        ship.getMutableStats().getFluxDissipation().modifyMult(weapon.getId(), BOOSTFLUX);
                }
[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 06, 2016, 10:03:55 AM
That's because all your "boost" weapons have the same ID. Try to set a unique ID per weapon script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2016, 10:04:24 AM
Right - the weapon id is the id from the spreadsheet, so for multiple copies of the same weapon you get the same id. You probably want to generate a unique id in the constructor for your script and then use that as they modifier key.

(Ninja'ed!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 06, 2016, 10:34:10 AM
Else, a means for create a hybrid/universal weapon who is not effect (Because this is a type)so per  boost ballistic,missile and energy?


Thank Alex-Admin-God and Tartiflette
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on February 10, 2016, 08:41:29 PM
Can anyone point me to a good tutorial on how to compile the .java files to .class files that Starsector will read?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 10, 2016, 11:23:03 PM
Two methods:
You  can use your shell, i have already use that, but boring. (Ok no, but when you have second method, hum..)

You can use eclipse,netbeans, intelUp. Two lasts have tutoriel in this forum. After, open your project, you can compile your file java in class, this three environment for development java can build also  file.jar (who is read per Starsector, if you put in mod_info.json).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on February 11, 2016, 11:15:54 AM
Well I tried following this one (http://fractalsoftworks.com/forum/index.php?topic=4344.msg67576) but I didn't manage to compile anything and the code I had presented a bunch of errors (even though it was pretty much a carbon copy of something I know it worked), probably because I might have messed up when adding libraries of stuff like LazyLib and the sort, I'm not really certain how to do these things. And updated tutorial would be nice if there is one around.

Unrelated but can anyone tell if the number of ships the AI deploys is dependent on the total FP of your fleet or is it dependent on the total FP that you deploy?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 11, 2016, 12:56:47 PM
None idea for your second question.( Because i am french so i do not understand this sense)

For first, i can help you, same if i use Netbeans, not Eclispe. (But Eclispe is the best, i suppose...) Or not.


So for all eclipse,netbeans(where i know button for that) and etc:
You need so create a new project who follow your mod. (Do not forgot take only java with a thing **/*.java, not reason)
Then, you need go your library and import :
Default:
- starfarer.api.jar
- starfarer.api.zip  (and if possible, you redirect starfarer.api.jar in this source)
- lwjgl.jar
- lwjgl_util.jar
Extra:
-Shaderlib
-Lazylib
For others:
- Others, but this is not for now.

After that, you can build and clean your project(who compile all), after  you need just put your .jar in your mod and redirect mod_info in that.

For your error, send me per private message, i can maybe help you.




Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaphide on February 11, 2016, 01:52:53 PM
Can anyone point me to a good tutorial on how to compile the .java files to .class files that Starsector will read?

Are you sure you actually need to (pre)compile them? StarSector will auto-compile any .java files (I think if they are under <yourModDirectory>/data/...) for you using Janino.

It is only necessary to pre-compile your .java files if you are using Java features that are not supported by Janino.

If you do need to compile your .java files, I suggest using kazi's guide here:
http://fractalsoftworks.com/forum/index.php?topic=10057.0 (http://fractalsoftworks.com/forum/index.php?topic=10057.0)

and setting your mod up like:
<yourModDirectory>/src (your .java source files go here)
e.g. <yourModDirectory>/src/data/scripts/yourModPlugin.java
<yourModDirectory>/jars (your compiled .jar [a collection of .class files] goes here)
e.g. <yourModDirectory>/jars/yourMod.jar
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 15, 2016, 07:17:23 AM
I've got some weird bug where a PersonAPI object used as a key in a HashMap stored in SS's persistent data, said map being created in onNewGame(), is apparently changing its hash after save/load. Are "orphaned" PersonAPIs being recreated with same name, portrait, etc. instead of being reloaded?

Spoiler
The Rags to Riches mod (http://fractalsoftworks.com/forum/index.php?topic=10205.msg182056#msg182056) creates two PersonAPIs on a new game, stores them in a BaseCampaignEventListener/EveryFrameScript, and saves them to persistent data with the PersonAPI as key and a predefined string as value. (source (https://bitbucket.org/Histidine/rags-to-riches/src/5cf1a7b6cf996324ae3b5f732b7c1d7339f17905/jars/src/data/scripts/campaign/R2R_CampaignManager.java?at=master&fileviewer=file-view-default#R2R_CampaignManager.java-61))
It later adds the objects stored in the BaseCampaignEventListener/EveryFrameScript as officers to the player fleet, once some early game stuff (an informal starter "quest") is done. (source (https://bitbucket.org/Histidine/rags-to-riches/src/5cf1a7b6cf996324ae3b5f732b7c1d7339f17905/jars/src/com/fs/starfarer/api/impl/campaign/rulecmd/R2R_CompleteEscape1.java?at=master&fileviewer=file-view-default#R2R_CompleteEscape1.java-35))

I went through the process to get the officers and used a debug command (not in release version):

541772 [Thread-5] INFO  org.lazywizard.console.Console  - Running command "printchatterchars"
541773 [Thread-5] INFO  org.lazywizard.console.Console  - Saved officers:    // this is from persistent data created at start
541774 [Thread-5] INFO  org.lazywizard.console.Console  - Erin Zuma (com.fs.starfarer.rpg.Person@1553854): sunrider_asaga
541774 [Thread-5] INFO  org.lazywizard.console.Console  - Zoltan Andreyev (com.fs.starfarer.rpg.Person@1e1d0c5): default
541774 [Thread-5] INFO  org.lazywizard.console.Console  - Current officers:    // this is what is currently in the playerfleet; added with fleet.getFleetData().addOfficer()
541775 [Thread-5] INFO  org.lazywizard.console.Console  - Zoltan Andreyev (com.fs.starfarer.rpg.Person@1e1d0c5)
541775 [Thread-5] INFO  org.lazywizard.console.Console  - Erin Zuma (com.fs.starfarer.rpg.Person@1553854)


Hashes match.

Quit to main menu, reloaded the after-pregame-time-pass save, repeated the process:

577187 [Thread-5] INFO  org.lazywizard.console.Console  - Running command "printchatterchars"
577188 [Thread-5] INFO  org.lazywizard.console.Console  - Saved officers:
577189 [Thread-5] INFO  org.lazywizard.console.Console  - Zoltan Andreyev (com.fs.starfarer.rpg.Person@187edd1): default
577189 [Thread-5] INFO  org.lazywizard.console.Console  - Erin Zuma (com.fs.starfarer.rpg.Person@10c2827): sunrider_asaga
577189 [Thread-5] INFO  org.lazywizard.console.Console  - Current officers:
577190 [Thread-5] INFO  org.lazywizard.console.Console  - Zoltan Andreyev (com.fs.starfarer.rpg.Person@1e1d0c5)
577190 [Thread-5] INFO  org.lazywizard.console.Console  - Erin Zuma (com.fs.starfarer.rpg.Person@1553854)


Now the hash of the map key PersonAPI no longer matches that of the one stored in the BaseCampaignEventListener.

Is there an explanation for this?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on February 15, 2016, 10:38:43 AM
You, uh, probably shouldn't use them as a key.  If you're trying to store something, the value is what you're actually trying to store.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 15, 2016, 10:57:59 AM
(Side note: hashCode() isn't guaranteed to be unique in the first place, and isn't guaranteed to remain the same across invocations of the jvm, per the javadoc (https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html).)

A class used as a key in a map etc should generally have suitable hashCode() and equals() methods defined, as the default implementation inherited from Object is likely to produce undesired results. I mean, you can generally put a bunch of <whatever> into a set and rely on that working, but not if you start changing the objects in the set in the meantime.

I'd suggest using person.getId() as the key - that id is generated using UUID and is unique, and is a String and so can safely be used as a key.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Very Good on February 15, 2016, 02:09:30 PM
How i get more deployment points/make battle bigger?I tried setting it in the setting.json but got Nothing in game:

"minBattleSize":1500, # in supplies-to-recover. min value for settings slider
   "defaultBattleSize":2500, # in supplies-to-recover. starting tvalue for settings slider
   "maxBattleSize":5000, # in supplies-to-recover. max value for settings slider

also if i want to make my officer/npc officer have a higher level cap i need to only change this value?:"officerMaxLevel":200, -EDIT-made the game unstable for me.

also changing this will allow me to hire 200 officer while having a max of 100 in my fleet?

   "officerMaxHireable":200,
   "officerPlayerMax":100,


edit:oh and how i make Bounty last longer?

EDIT 2:ACTUALY EDITING setting.json do not affect my game,why?Oh,i have starsector and nexerlin btw.

EDIT 3:okay,i had to edit starsector one.

edit 4: starsector have proceduraly generated NPC ship layout,how i could allow the NPC to have more ordonance points(and bigger layout,weapons,more mod)?

edit 5:I boosted the deployment points,but i am getting this crash when i try to fight a templar fleet(the crash happen during the battle):


165259 [Thread-11] INFO  sound.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOO  - Creating streaming player for music with id [faction_generic_market_01_hostile_var01.ogg]
165259 [Thread-11] INFO  sound.H  - Playing music with id [faction_generic_market_01_hostile_var01.ogg]
165273 [Thread-9] INFO  sound.F  - Creating music buffer #2
169531 [Thread-5] INFO  com.fs.starfarer.combat.CombatEngine  - FP1: 857, FP2: 211, maxFP1: 3000, maxFP2: 2000
169778 [Thread-5] INFO  org.histidine.chatter.combat.ChatterCombatPlugin  - Chatter plugin initialized
169779 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading CSV data from [DIRECTORY: F:\A Starsector\starsector-core\..\mods\AI War]
169780 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading CSV data from [DIRECTORY: F:\A Starsector\starsector-core\..\mods\AI War]
169780 [Thread-5] INFO  data.scripts.plugins.AIW_ForcefieldPlugin  - Forcefield plugin initialized
169780 [Thread-5] INFO  data.scripts.plugins.AIW_GravityDrainPlugin  - Gravity drain plugin initialized
171263 [Thread-11] INFO  sound.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOO  - Creating streaming player for music with id [TheFlagship.ogg]
171264 [Thread-11] INFO  sound.H  - Playing music with id [TheFlagship.ogg]
241035 [Thread-5] INFO  org.histidine.chatter.combat.ChatterCombatPlugin  - Time elapsed: 0.4363334
307770 [Thread-5] INFO  org.histidine.chatter.combat.ChatterCombatPlugin  - Time elapsed: 64.89503
323855 [Thread-11] INFO  sound.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOO  - Creating streaming player for music with id [Relics.ogg]
323867 [Thread-11] INFO  sound.H  - Playing music with id [Relics.ogg]
324019 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at data.scripts.plugins.TEM_WeaponScriptPlugin.advance(TEM_WeaponScriptPlugin.java:201)
   at com.fs.starfarer.title.ooOO.o0oO$Oo.super(Unknown Source)
   at com.fs.starfarer.combat.oOOO.new.super(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on February 16, 2016, 07:47:13 AM
Could anyone help me set up a simple total conversion for the newest version of starsector, I have a simple add on for mission with my ships but when I try to make it work on the newest version. I am unable to. My mods version is currently 0.65a
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ahne on February 16, 2016, 03:19:38 PM
How can i let only specific ships spawn in the black markets?  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on February 17, 2016, 11:13:12 AM
Does anyone currently have a basic template for a mod. I used Rushyo's battlestar as a base to get my ships into the game but I can't get it to work with 0.7.1 so if anyone has a basic setup I could use, I would appreciate it. I'm sure there's a few other people wanting to mod that would like it too. Do we need JAR and VERSION files for the 0.7.1 update?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on February 17, 2016, 01:28:33 PM
Also does anyone know if it's possible to edit the accelerated shields hullmod so they are raised instantly??
Thinking of trying it for my Stargate ships if it's possible to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on February 18, 2016, 08:17:37 AM
Hello everyone.

Can you advise me, how can I make a hullmods which would have produced fuel over time? And that while the number of produced fuel would depend on the distance to the nearest star, the closer to the star, the more fuel is produced.

If you already have mod which such already is realized, please show it to me as an example.

Thanks in advance for your help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wind Tempest on February 19, 2016, 11:24:36 AM
Hello everyone.

So I have started to work on my own mod and am trying to learn the code side of it.  So far I have stumbled through parts of it and gotten it to work to some degree.  I will probably post here several times as I get stuck.

So anyways to the question.
One of the things I have been trying is a mirv type missile that releases flares as a point defense system.  I have gotten the flares to release, however now the mirv missile weapon won't fire on incoming missiles or track them.  I used the data from the Hurricane MIRV and the flare system as a base and added PD into the weapon_data.csv.

Here is the line in the csv:
Ember Missile Rack,ember_rack,1,300,1000,,200,,10,5,6,30,0.2,,ENERGY,0,,0,2,1,,0,0,0,0,,900,100,6,35,"PD,DO_NOT_AIM",9

Here is the weapon I was using:
Spoiler
{
   "id":"ember_rack",
   "specClass":"projectile",
   "type":"MISSILE",
   "size":"SMALL",
   "turretUnderSprite":"graphics/weapons/cmc_s_emberrack_turret_base.png",
   "turretSprite":"graphics/weapons/cmc_s_emberrack_turret.png",
   "hardpointSprite":"graphics/weapons/cmc_s_emberrack_hardpoint.png",   
   "hardpointOffsets":[12, 0, 12, 2, 12, -2, 12, 0],
   "turretOffsets":[2, 0, 0, 2, -2, 0, 0, -2],
   "hardpointAngleOffsets":[0, 0, 0, 0],
   "turretAngleOffsets":[0, 0, 0, 0],
   "barrelMode":"ALTERNATING",
   "animationType":"SMOKE",
   #"renderHints":[RENDER_LOADED_MISSILES],
   "interruptibleBurst":false,
   "displayArcRadius":300,
   "smokeSpec":{"particleSizeMin":10.0,
             "particleSizeRange":16.0,
             "cloudParticleCount":3,
             "cloudDuration":0.9,
             "cloudRadius":8.0,
             "blowbackParticleCount":4,
             "blowbackDuration":1.1,
             "blowbackLength":20.0,
             "blowbackSpread":10.0,
             "particleColor":[170,160,150,130]},
   "projectileSpecId":"ember_shot",
   "fireSoundTwo":"harpoon_fire",
}
[close]

Here is the initial projectile:
Spoiler
{
   "id":"ember_shot",
   "specClass":"missile",   
   "missileType":"MIRV",
   "sprite":"graphics/missiles/cmc_ember.png",
   "size":[5,11],   
   "center":[3,6],
   "collisionRadius":10,
   "collisionClass":"MISSILE_NO_FF",
   "explosionColor":[255,100,10,255],  # purely visual, will get a white additively blended core on top of this color
   "explosionRadius":0, # purely visual
   "engineSpec":{"turnAcc":180,
              "turnRate":90,
              "acc":1500,
              "dec":1000},
   "engineSlots":[{"id":"ES1",
               "loc":[-13, 0],
                #"style":"MISSILE_HIGH_TECH",
                "style":"CUSTOM",
               "styleSpec":{
                  "mode":"QUAD_STRIP", # PARTICLES or QUAD_STRIP, determines which params are used
                  "engineColor":[255,150,100,255],
                  "contrailDuration":2,
                  "contrailWidthMult":1,
                  "contrailWidthAddedFractionAtEnd":2.5,  # can be negative. makes trail spread out/narrow at the end
                  "contrailMinSeg":5, # min segment length, in pixels
                  "contrailMaxSpeedMult":0.5f,
                  "contrailAngularVelocityMult":0.5f,
                  "contrailColor":[255,150,100,100],
                  "type":"GLOW" # GLOW or SMOKE; additive or regular blend mode
               },
                "width":5.0,
                "length":15.0,
                "angle":180.0}],
   "behaviorSpec":{"behavior":"MIRV",
               "splitRange":100,
               "minTimeToSplit":1,
               "numShots":4,
               "damage":10,
               "emp":100,
               "damageType":ENERGY,
               "hitpoints":1,
               "arc":270,
               "spreadSpeed":325,
               "projectileSpec":"flare_standard",
               #"emptySpec":"type_1_mirv_empty",
               "smokeSpec":{"particleSizeMin":20.0,
                         "particleSizeRange":20.0,
                         "cloudParticleCount":11,
                         "cloudDuration":1.0,
                         "cloudRadius":20.0,
                         "blowbackParticleCount":0,
                         "blowbackDuration":0,
                         "blowbackLength":0,
                         "blowbackSpread":0,
                         "particleColor":[175,100,50,200]}
               }
               
}
[close]

And I just used the flare_standard.proj as the submunition I copied from the vanilla data folder(along with the graphics needed to run it)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 19, 2016, 05:37:33 PM
How can i let only specific ships spawn in the black markets?  :-\
Might be best to make your own version of the black market submarket and spawn the special ships you want in the code.

Hello everyone.

Can you advise me, how can I make a hullmods which would have produced fuel over time? And that while the number of produced fuel would depend on the distance to the nearest star, the closer to the star, the more fuel is produced.

If you already have mod which such already is realized, please show it to me as an example.

Thanks in advance for your help.

Quickly whipped up example hullmod code, untested:

Code: java
	public static final float BASE_DISTANCE = 100;
public static final float FUEL_PER_DAY = 2;
IntervalUtil interval = new IntervalUtil(0.25f,0.25f); // probably premature optimisation but meh

@Override
public void advanceInCampaign(FleetMemberAPI member, float amount) {
float days = Global.getSector().getClock().convertToDays(amount);
interval.advance(days);
if (interval.intervalElapsed()) {
CampaignFleetAPI fleet = member.getFleetData().getFleet();
LocationAPI loc = fleet.getContainingLocation();
if (loc == Global.getSector().getHyperspace()) return;

// NOTE: uses generics, will fail if using Janino runtime compiler
List<PlanetAPI> planets = loc.getPlanets(); // TODO check if this also gets the system primary, if not use getAllEntities instead
for (PlanetAPI planet : planets) {
if (!planet.isStar()) continue;

// TODO: consider examining the star specs (size, corona size, etc.) and multiplying fuel generation accordingly
// also being in the corona or a solar storm might increase fuel production
float distance = Misc.getDistance(planet.getLocation(), fleet.getLocation());
if (distance < 10) distance = 10; // div0 protection, keeps fuel production non-ridiculous when getting _really_ close
float fuelMult = BASE_DISTANCE/distance;

// TODO: modifying output by the hull size of the ship this hullmod is installed on is left as exercise to the reader
fleet.getCargo().addCommodity(Commodities.FUEL, FUEL_PER_DAY * fuelMult * interval.getIntervalDuration());
}
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Runoved on February 27, 2016, 07:52:31 AM
Once again, hello everyone.


Firstly thank you for your help with my previous question.

And again I have to ask for advice.

When I try to move my mod on the new version of the game (0.7.2a), I found a strange problem.
When I try to run the game with my mod, the game falls with the following error:

Spoiler
Code
16766 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.scripts.ScriptStore.new(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.o00000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

[close]

But, what is the strangest thing, if I replace java folder (jre) on the one, that was used in previous versions of the game (0.7.1a), then suddenly everything starts to operate normally. I guess it has something to do with the changing Java version in the new version of the game.

For this please advise what could be the reason for this? And what part of my mod should I look for reasons to fix compatibility with the new version of the game? Perhaps someone has already faced a similar problem.

Thanks in advance for your attention.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 27, 2016, 08:00:05 AM
If you use Netbeans, eclipse or Intel..

You need just downgrade your version of Java where you compile,  Java 8 => Java 7.

Netbeans per example: Properties => Source/Binary format => JDK8 => JDK 7. Then, fix script and compile.  

That is my problem, three hours ago, ah ah.

But, why when you use
Spoiler
[close]
with
Code
i cannot see correctly text inside in the double balise....


Update: I have a very strange error who do not give me a easy error to fix: A idea? :x
Spoiler
95291 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 5
java.lang.ArrayIndexOutOfBoundsException: 5
   at com.fs.starfarer.combat.entities.ship.A.G.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.BaseEntity.render(Unknown Source)
   at com.fs.graphics.LayeredRenderer.render(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.render(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2016, 09:57:25 AM
Update: I have a very strange error who do not give me a easy error to fix: A idea? :x
Spoiler
95291 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 5
java.lang.ArrayIndexOutOfBoundsException: 5
   at com.fs.starfarer.combat.entities.ship.A.G.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.BaseEntity.render(Unknown Source)
   at com.fs.graphics.LayeredRenderer.render(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.render(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

That looks like a mismatch between the number of frames a beam weapon has and a frame it's trying to render. Basically, it's trying to render a 5th frame, and that doesn't exist. (At least, I'm about 90% sure that's the issue.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on February 27, 2016, 10:09:26 AM
Making a custom ship_roles.csv doesn't require anything special right? I can just do it by hand much like weapon_data.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2016, 10:22:43 AM
Well, there's no ship_roles.csv, for starters :)

There's a default_ship_roles.json, and then there's the "shipRoles" section in most .faction files. Those can, indeed, be edited by hand.

As can ship_data.csv, in case you were asking about that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 27, 2016, 10:26:59 AM
Update: I have a very strange error who do not give me a easy error to fix: A idea? :x
Spoiler
95291 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 5
java.lang.ArrayIndexOutOfBoundsException: 5
   at com.fs.starfarer.combat.entities.ship.A.G.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.BaseEntity.render(Unknown Source)
   at com.fs.graphics.LayeredRenderer.render(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.render(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

That looks like a mismatch between the number of frames a beam weapon has and a frame it's trying to render. Basically, it's trying to render a 5th frame, and that doesn't exist. (At least, I'm about 90% sure that's the issue.)

But, my faction have only ballistic weapon... (and it seems, before change a small thing, not problem before...). (He have also 12 system weapon and 3 booster weapon... but no problem with that, i think)
Hum, maybe in this modified script for shoot 3 proj instead of one proj.
Arbalest Autocannon(m),Lt_ab,0,800,1400,,125,,10,12,8,1,3,,KINETIC,170,,0,2,3,0.05,0,0,0,0,,1200,,,30,,3157
But this weapon have only EveryFrameEffect:
Spoiler
       
Quote
       if(currentflux/maxflux <= 0.3f){
            weapon.setMaxAmmo(1);
        }
        if(currentflux/maxflux > 0.4f){
            weapon.setMaxAmmo(3);
        }
[close]
Thank for your help.


This problem can be maybe because i have change JDK8 to JDK7 for compatibility 0.7.2 but not reasons, i use a environment...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2016, 10:39:20 AM
Do you have any decorative weapons on your ships? Because the stack trace is definitely telling me it's crashing in a beam weapon's render() method. It's possible the deobfuscator is bugged, but that hasn't happened before, so I'd consider it unlikely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 27, 2016, 10:50:29 AM
Two decoratives. Two animated with a script. (A aura and a reactor)
Problem, i can fight in battle with 20 ships who have each a reactor and a aura. before without problem(or maybe , just never luck).

Aura is a red layer with currentflux.(More flux, more red)  : 6 png.

Reactor is a just a "external" reactor always animated who have more fast animation if engine is active or shipsystem is active.(And become purple if shipsystem is active) : 20 png.(10 for blu, 10 for red)     Red because blu+red => purple
Reactor:
Spoiler
Quote
{
   "id":"Lt_Sreactor",  
   "specClass":"beam",
   "type":"DECORATIVE",
   "size":"SMALL",
   "everyFrameEffect":"data.scripts.weapons.Lt_reactor",
   "showDamageWhenDecorative":true,
   "renderBelowAllWeapons":true,
   "renderHints":["RENDER_ADDITIVE"],
   "turretSprite":"graphics/weapons/Sreactor/Lt_reactor00.png",
   "hardpointSprite":"graphics/weapons/Sreactor/Lt_reactor00.png",
   "numFrames":20,
   "frameRate":20,
   "alwaysAnimate":"true",
   "turretOffsets":[0, 0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[0, 0],
   "hardpointAngleOffsets":[0],   
   "fringeColor":[255,255,255,255],
   "coreColor":[255,255,255,255],
   "glowColor":[255,255,255,255],
   "width":1,
   "textureType":ROUGH,
   "textureScrollSpeed":1.0,
   "pixelsPerTexel":1.0,   
}

(http://cdn.bulbagarden.net/upload/5/5a/Ratty_Rattata.png)

[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on February 27, 2016, 11:08:05 AM
Well, there's no ship_roles.csv, for starters :)

There's a default_ship_roles.json, and then there's the "shipRoles" section in most .faction files. Those can, indeed, be edited by hand.

As can ship_data.csv, in case you were asking about that.

Aaah, I thought shipRoles in .faction files didn't work anymore. While that was pretty convenient back in the day, adding custom ships to that also messes up the market which is why I'd rather compile my own thingy. I guess I actually don't know what that entails, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 28, 2016, 02:42:54 AM
When i desactive script of Reactor, i have a new error, ah ah:
Spoiler
Quote
[Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 4
java.lang.ArrayIndexOutOfBoundsException: 4
   at com.fs.starfarer.combat.entities.ship.A.G.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.render(Unknown Source)
   at com.fs.starfarer.combat.entities.BaseEntity.render(Unknown Source)
   at com.fs.graphics.LayeredRenderer.render(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.render(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

So i have a big problem with render...

Update: And i crash one mission sur two. (big fleet against big fleet) So this is not a easy bug when i can fix with my level ><. I hate random crash.


Update 29/02/2016: After many test missions, this is maybe:
Spoiler
Quote
public class Lt_EveryFrameEffect implements EveryFrameWeaponEffectPlugin {
    private float elapsed2=0f;
       
    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        if (engine.isPaused()) {
            return;
        }
        ShipAPI ship = weapon.getShip();
        float currenflux = ship.getFluxTracker().getCurrFlux();
        float hardflux = ship.getFluxTracker().getHardFlux();
        float currentflux = hardflux+currenflux;
        float maxflux = ship.getFluxTracker().getMaxFlux();
       
        if(currentflux/maxflux <= 0.3f){
            weapon.setMaxAmmo(1);
        }
        if(currentflux/maxflux > 0.4f){
            weapon.setMaxAmmo(3);
        }
[close]
SetMaxAmmo crash my computer, maybe...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on March 02, 2016, 03:38:09 AM
Just wondering if anyone knows how to write a hullmod that would bend a shield around the ship boundaries?
I wanted a contoured shield for my stargate mod's aurora class battleship but have no idea how to make one. I've seen hullmods that act as a shield but wondered if one could be written that would bend the shield around the ships boundaries to create a contoured shield.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: billi999 on March 02, 2016, 04:22:01 AM
If you're using ShaderLib, you might be able to use a shader to do a simple edge detect of sorts, which runs a test for each pixel of the alpha channel of your ship sprite, then Compares that with neighbouring pixels. If the sample has low alpha, and a neighbouring pixel has high alpha it's at an edge of the sprite. This would allow your shader to edge detect on any ship. For the shield effect you could have a fan of triangles starting from the ship center fading out to the edges, but you'd likely have problems with that if you have any concave parts to your sprites.
This is all in theory though as I've never used ShaderLib :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on March 02, 2016, 05:40:33 AM
How exactly does stats.getEnergyWeaponFluxCostMod().modifyFlat() work?  It only adds a small amount of flux to a Heavy Blaster, but skyrockets flux costs for the Pulse Laser and weapons like the PD laser.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 02, 2016, 01:48:55 PM
How exactly does stats.getEnergyWeaponFluxCostMod().modifyFlat() work?  It only adds a small amount of flux to a Heavy Blaster, but skyrockets flux costs for the Pulse Laser and weapons like the PD laser.

It just adds a flat amount to the flux cost. Probably not something you ever want to do, since it'll disproportionately affect weapons with a low flux cost - unless that's what you need, for some reason.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on March 02, 2016, 10:06:37 PM
In the faction files, how do the numbers next to ship variants work (e.g. "hound_Standard":10)? What I want to know is, if you add more variants but don't want to affect the overall rarity of the hull, do you use the same number as all the other variants (assuming that every variant has equal weighting of course), or do you need to reduce the number of every variant to keep the base hull's rarity the same as it was before?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on March 02, 2016, 11:46:49 PM
This is a probability for me, if i put 0.001, you can never see this ship in fleet and market. I think, this is a probability with all others ships in your faction file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on March 03, 2016, 12:29:11 AM
This is a probability for me, if i put 0.001, you can never see this ship in fleet and market. I think, this is a probability with all others ships in your faction file.

I know it's a probability, my question is does every variant entry have to compete with each other (i.e. the bigger the total number in a set, the less chance each individual variant has of getting rolled) or are they independent.

So for example, say there is a single variant "TestShip_OnlyVariant":10. If I add "TestShip_SecondVariant":10 does that double the chance of TestShip appearing (20 total, 10 each for OnlyVariant and SecondVariant), or does TestShip have the same chance of appearing (10).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wind Tempest on March 03, 2016, 10:28:54 AM
Any answer for my question about MIRV point defense missiles being possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 03, 2016, 10:50:39 AM
So for example, say there is a single variant "TestShip_OnlyVariant":10. If I add "TestShip_SecondVariant":10 does that double the chance of TestShip appearing (20 total, 10 each for OnlyVariant and SecondVariant),

This one.

Any answer for my question about MIRV point defense missiles being possible?

I'm... not sure, actually. It seems like it should work, and what you're doing looks right. Haven't had time to look into it deeper, unfortunately. Are you able to get regular, non-mirv PD missiles working?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wind Tempest on March 03, 2016, 11:29:20 AM
I'm... not sure, actually. It seems like it should work, and what you're doing looks right. Haven't had time to look into it deeper, unfortunately. Are you able to get regular, non-mirv PD missiles working?
Yeah,  I was able to get non-mirv PD missiles to fire and target enemy missiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on March 03, 2016, 11:56:00 AM
You have test install a plugin missile AI on your flare missile? (Create a new flare missile for that.)

My mirv missile weapon spawn homing missiles, so this is strange.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: billi999 on March 03, 2016, 01:12:44 PM
MIRV point defense missiles
I'm... not sure, actually. It seems like it should work

I've tried this before, it didn't work for me either, although this was several versions back. I know that might not be a helpful answer but I hope it's helpful at least as confirmation.
Edit: The first-stage warhead was able to target missiles, it was the second-stage projectiles that didn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wind Tempest on March 03, 2016, 01:26:46 PM
You have test install a plugin missile AI on your flare missile? (Create a new flare missile for that.)

My mirv missile weapon spawn homing missiles, so this is strange.
Sorry, I am not completely sure of what you are asking but here is the Dropbox link for the weapon in question:
https://www.dropbox.com/sh/ju0iiida872qijl/AACQ_z6Jf5K8nmX14xKtKnSVa?dl=0

Ideally I would like the missiles to be fired and homing on enemy inbound missiles and then when they get close release a bunch of flares.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 03, 2016, 01:41:04 PM
You have test install a plugin missile AI on your flare missile? (Create a new flare missile for that.)

My mirv missile weapon spawn homing missiles, so this is strange.
Sorry, I am not completely sure of what you are asking but here is the Dropbox link for the weapon in question:
https://www.dropbox.com/sh/ju0iiida872qijl/AACQ_z6Jf5K8nmX14xKtKnSVa?dl=0

Ideally I would like the missiles to be fired and homing on enemy inbound missiles and then when they get close release a bunch of flares.
Basically he meant that you have to write a custom missile AI and implement it to the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wind Tempest on March 03, 2016, 02:16:10 PM
Basically he meant that you have to write a custom missile AI and implement it to the game.
Ah, well that sucks since my knowledge of programming is non-existent.  I will have to try something else then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on March 03, 2016, 02:26:55 PM
You can look others mods like my mod artefact or all others mods. Ah ah. You can find this implement in ModPlugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 03, 2016, 07:31:21 PM
How do I specify that my mod event should appear under the Important tab in intel screen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 03, 2016, 07:36:08 PM
How do I specify that my mod event should appear under the Important tab in intel screen?

"important" tag in reports.csv. It's not per-event, it's per-report, so you have an event with only some messages being important.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on March 03, 2016, 09:50:27 PM
So for example, say there is a single variant "TestShip_OnlyVariant":10. If I add "TestShip_SecondVariant":10 does that double the chance of TestShip appearing (20 total, 10 each for OnlyVariant and SecondVariant),

This one.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 05, 2016, 05:52:18 PM
A question. How does addafterimage work in ShipAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2016, 05:54:06 PM
A question. How does addafterimage work in ShipAPI?

Hard to explain exactly, basically it allows you to make the ship look like it's smeared/moving fast/something like that. Can add a bunch of images of the ship sprite that move away from it in the specified direction and fade in/out over the specified duration.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 05, 2016, 07:59:34 PM
A question. How does addafterimage work in ShipAPI?

Hard to explain exactly, basically it allows you to make the ship look like it's smeared/moving fast/something like that. Can add a bunch of images of the ship sprite that move away from it in the specified direction and fade in/out over the specified duration.
So if i addafterimage at like ship.getloc.x,ship.getloc.y,ship.getVel.x(or 0),ship.getVel.y(or 0), a copy sprite will appear at that place? If not, what will happen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2016, 08:21:53 PM
So if i addafterimage at like ship.getloc.x,ship.getloc.y,ship.getVel.x(or 0),ship.getVel.y(or 0), a copy sprite will appear at that place? If not, what will happen?

Yes, exactly - but it's only of the base sprite, not the weapons, engine glows, or anything else. Not even decorative weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on March 07, 2016, 10:18:48 AM
Just wondering how can I change the amount of fleet points in a mission so I can deploy more ships. Tried opening the mission in word pad and searching for "80" because that is the current limit for the mission but can't find it.
Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on March 07, 2016, 12:52:40 PM
And can someone tell me how to make projectiles not hit missiles. Thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Divinitus Monstrum on March 07, 2016, 07:06:06 PM
Hey all, I don't post often but I am pretty stumped with this one.
I get this when loading the game with a mod I am making. I am using jdk8 as others have suggested its jdk7 that caused this issue.
Thanks in advance!
Spoiler
21160 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
   at java.util.ArrayList.rangeCheck(Unknown Source)
   at java.util.ArrayList.get(Unknown Source)
   at com.fs.starfarer.loading.scripts.ScriptStore.new(Unknown Source)
   at com.fs.starfarer.settings.StarfarerSettings.super(Unknown Source)
   at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Edit: Cant read. should have used jdk7. Thanks Snrasha!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on March 07, 2016, 09:16:29 PM
Yes, this is a problem because you compile your mod in jdk8. You can use research on this forum and found all same solution, retrograde to JDK7.

For Joe130794, i have a idea, but maybe too bad for that and this is not very usefull.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on March 08, 2016, 01:58:10 AM
Which one? The missions fleet points or Projectiles not hitting missiles. I have flak for missiles but want my main guns to not hit missiles so it actually hit's what I want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on March 08, 2016, 11:11:47 AM
Spoiler
https://www.youtube.com/watch?v=nXrlCvLzBYs&index=3&list=PLMVfAF8qxZvcWIKsCdFBfnte6LawJkHPt
[close]

Recorded some gameplay with a modified ship. I changed the autofire on some of the weapons so you can see whats shooting. I want my main gun batteries to not engage fighters because they tend to miss and I don't want the heavy gun batteries to hit and be hit by missiles if anyone can help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pax_Empyrean on March 09, 2016, 06:13:18 AM
How do I change the number of hit points that a missile has?

I kinda figured it would be under "proj hitpoints" in weapon_data.csv (since what else would that do?) but even after reducing that value to 1, missiles are still taking multiple hits from Vulcans or surviving a a second or two from a point defense beam. Other changes I've made to weapon_data.csv are working just fine, so I know the mod itself isn't broken.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 09, 2016, 06:20:19 AM
How do I change the number of hit points that a missile has?

I kinda figured it would be under "proj hitpoints" in weapon_data.csv (since what else would that do?) but even after reducing that value to 1, missiles are still taking multiple hits from Vulcans or surviving a a second or two from a point defense beam. Other changes I've made to weapon_data.csv are working just fine, so I know the mod itself isn't broken.
Are you sure there isn't something miss-aligned on that row? Or a missing comma? You can use OpenOffice to check your formatting easily.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pax_Empyrean on March 09, 2016, 06:44:59 AM
How do I change the number of hit points that a missile has?

I kinda figured it would be under "proj hitpoints" in weapon_data.csv (since what else would that do?) but even after reducing that value to 1, missiles are still taking multiple hits from Vulcans or surviving a a second or two from a point defense beam. Other changes I've made to weapon_data.csv are working just fine, so I know the mod itself isn't broken.
Are you sure there isn't something miss-aligned on that row? Or a missing comma? You can use OpenOffice to check your formatting easily.

Pretty sure. I use LibreOffice (an OpenOffice fork that's still alive) to do the editing in the first place. Never had a problem like that before. I've changed a few other things, so they are chargedown restricted rather than using ammo, but everything else is working fine. Here's the line for the Harpoon MRM; it should have two hit points, per the entry just before the AI hints:

Quote
Harpoon MRM,harpoon,0,200,2500,,375,,15,30,5,,,,HIGH_EXPLOSIVE,0,,0,5.9,2,0.1,0,0,0,,,300,100,12.5,2,"DO_NOT_AIM, DO_NOT_CONSERVE",11.5

Just making sure that there isn't a value I need to change somewhere else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deathfly on March 09, 2016, 07:26:53 AM
A quick question: what "aiHints" can we use in .system files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pax_Empyrean on March 09, 2016, 10:56:04 AM
How do I change the number of hit points that a missile has?

I kinda figured it would be under "proj hitpoints" in weapon_data.csv (since what else would that do?) but even after reducing that value to 1, missiles are still taking multiple hits from Vulcans or surviving a a second or two from a point defense beam. Other changes I've made to weapon_data.csv are working just fine, so I know the mod itself isn't broken.
Are you sure there isn't something miss-aligned on that row? Or a missing comma? You can use OpenOffice to check your formatting easily.

Okay, so I went back and copied over the stuff that I had changed, and then changed only the projectile hit points, just to make sure that I hadn't stumbled into some oddball way of breaking the file. All behavior is just the same as vanilla, including the hit points, which should have been lowered dramatically but still seem to show base values.

Has anyone successfully changed this, or are these problems a one-off thing for me?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 09, 2016, 12:01:29 PM
Harpoon MRM,harpoon,0,200,2500,,375,,15,30,5,,,,HIGH_EXPLOSIVE,0,,0,5.9,2,0.1,0,0,0,,,300,100,12.5,2,"DO_NOT_AIM, DO_NOT_CONSERVE",11.5
Works fine for me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2016, 12:06:44 PM
One shot/rack/pod missile weapons share the same projectile, so any change in the csv stats must be made for all 3 versions of the weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pax_Empyrean on March 09, 2016, 12:13:28 PM
One shot/rack/pod missile weapons share the same projectile, so any change in the csv stats must be made for all 3 versions of the weapon.
Thanks. I had changed the small versions, but not the larger ones. I'm guessing the hit points thing was just being overwritten.

Oddly enough, the damage difference went through without a hitch. Thanks for the reply, Alex.

EDIT: Just confirmed. That was the problem, and now it's working fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cordacc on March 09, 2016, 04:33:46 PM
Not sure this is the right place for this, but...
Are there any current Mods that can make a 1 system campaign map with every faction (vanilla and mod) spawning in that one system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Beobachter on March 09, 2016, 10:28:35 PM
Not sure this is the right place for this, but...
Are there any current Mods that can make a 1 system campaign map with every faction (vanilla and mod) spawning in that one system?
I believe StarSector+ has "Corvus Mode" which has that functionality.

Disregard completely, corrected by Tartiflette
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 09, 2016, 11:47:22 PM
Not sure this is the right place for this, but...
Are there any current Mods that can make a 1 system campaign map with every faction (vanilla and mod) spawning in that one system?
I believe StarSector+ has "Corvus Mode" which has that functionality.
Nexerelin has a Corvus mode and that's the opposite of what he wants. But you can create a single system in a Procedural Nexerelin. Although beware, it will be crowded with fleets and much faster paced than in used to in the pre-0.58a days.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cordacc on March 10, 2016, 02:36:00 AM
I tried making a single system in Nexerelin, and for the most part it worked well. The biggest issues being that even when I set planets and stations to max, most of the time not all factions will spaw. There's also the sort of inherent issue whereby if I want all the factions that'll only be the case for a very short period of time in Nexerelin, as factions will very quickly get knocked out. I'm actually kinda curious as to why the number of faction that spawn fluctuates between starts for no apparent reason.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 10, 2016, 02:43:08 AM
I tried making a single system in Nexerelin, and for the most part it worked well. The biggest issues being that even when I set planets and stations to max, most of the time not all factions will spaw. There's also the sort of inherent issue whereby if I want all the factions that'll only be the case for a very short period of time in Nexerelin, as factions will very quickly get knocked out. I'm actually kinda curious as to why the number of faction that spawn fluctuates between starts for no apparent reason.
You can alter the min and max stations/planets in Nexerelin's settings.json I believe.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on March 10, 2016, 01:01:40 PM
edit:

A means for create a new BoundAPI with a "false" entity?
Or where see a class who implements BoundsAPI? (For copy update method)

Update: Because i have create a class hitbox who are just a polygon with segment(a other class). But, i have not idea for facing of this polygon link with facing ship.
Edit: a gif for give my problem:
Spoiler
(http://i.imgur.com/TsB8J4b.gif)
[close]
EDIT: sorry, after 4 hours, i have found.
EDIT2: Yippie, ok, i am sad, this is not so beautiful when expected, but...
Spoiler
(http://i.imgur.com/zq04OYH.gif)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 13, 2016, 01:26:47 AM
Is $menuState used for anything? I want to know if I can set it to things that are not "main".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kevin Flemming on March 13, 2016, 05:59:59 AM
How can I alter the Officer name pool? I'm getting a bit tired of seeing Dickerson all of the time. It seems that surname appears all of the time for me, across multiple restarts. I just want to remove that particular surname from being selected.

Edit: No matter, I found how to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2016, 06:08:15 PM
Is $menuState used for anything? I want to know if I can set it to things that are not "main".

If you search through rules.csv, you can see that $menuState is used to populate the top level of the market interaction menu with options. The idea is that it might be set to something else when/if options start to have nested sub-options, as opposed to all immediately opening a dialog/screen of some sort.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: hqz on March 14, 2016, 11:47:05 AM
Is there a way to invert the side of the battle map where units have to go through when they retreat?

Basically I would like the player fleet to retreat through the top of the map, while the opposing fleet would retreat through the bottom of the map. The goal here is to force fleets to pass through each other even when one is trying to avoid the other.

I've found this: http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/CombatEngineAPI.html#setSideDeploymentOverrideSide(com.fs.starfarer.api.mission.FleetSide) (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/CombatEngineAPI.html#setSideDeploymentOverrideSide(com.fs.starfarer.api.mission.FleetSide))
But I'm not sure what this actually does.

Context: this is a follow-up on an idea suggested in http://fractalsoftworks.com/forum/index.php?topic=10834.msg184725#msg184725 (http://fractalsoftworks.com/forum/index.php?topic=10834.msg184725#msg184725)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on March 19, 2016, 04:59:49 AM
If there a relatively simple way to make a weapon firing 2 different projectiles? Maybe 2 different weapons, but one of them triggering another to fire first...?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 19, 2016, 01:22:04 PM
Quote
Is there a way to invert the side of the battle map where units have to go through when they retreat?
Pretty sure you'd have to have a new AI to handle that; the method you're talking about is mainly there to support Allied fleets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on March 21, 2016, 06:06:47 PM
Is there any way to give a personality (aggressive, steady, etc) without an officer? Or force all ships of a certain type to have that personality?

Related question: is there any way to completely remove the fighter AI's default flanking behavior without writing an entirely new AI for them? I'm guessing the answer is no.

Spoiler
I've been working on a fighter mod to make carrier fleets viable, and everything is fine except for their behavior. If they just flew directly at the enemy and shot, they would be great! As is, they just uselessly try and flank and get blown away by long range weapon without landing a single shot.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2016, 06:25:49 PM
Is there any way to give a personality (aggressive, steady, etc) without an officer? Or force all ships of a certain type to have that personality?

Was going to say yes, but it turns out PersonAPI getCaptain() isn't exposed in the ShipAPI. Added, but for now the answer is, I think, no.

Related question: is there any way to completely remove the fighter AI's default flanking behavior without writing an entirely new AI for them? I'm guessing the answer is no.

Pretty sure your guess is correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on March 23, 2016, 08:44:32 PM
For my purposes, the current code works, the AI fires the weapon as soon as it has any ammo. However it is a bit clunkier than what I would like. As it requires the weapon to be set to autofire in the ship's variant and it will still fire if under the player control (not a big issue).
Any ideas how to achieve something better, specially by not needing to set the weapon to autofire, so it is easier to use for the player's AI controlled custom variant ships.

Had to do this for long ranged ships, any carriers I equipped with this weapon refused to fire it unless the enemy was directly in front of them, combat ships use it very well without any special AI.

The weapon itself fires a fast fading projectile set to a long range, that does nothing. The weapon has an everyframe pluggin that spawns a "drone wing" whenever the coldown is 0 and it is firing, which is why I want it to just fire at the start of the combat.

Code
package data.scripts.weapons.ai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.AutofireAIPlugin;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import org.lwjgl.util.vector.Vector2f;

public class TSC_DroneBay_FireAI implements AutofireAIPlugin{

    private boolean shouldFire = false;
    private CombatEntityAPI target = null;
    private final WeaponAPI weapon;
 
    
    public TSC_DroneBay_FireAI(WeaponAPI weapon) {
        this.weapon = weapon;
    }
    
    

    @Override
    public void advance(float amount) {

        if (((weapon.getShip()) != Global.getCombatEngine().getPlayerShip()) && (weapon.getAmmo() > 0)); {
            shouldFire = true;
        }
    }

    @Override
    public void forceOff() {
        shouldFire = false;
    }

    @Override
    public Vector2f getTarget() {
        if (target == null) {
            return null;
        } else {
            return target.getLocation();
        }
    }

    @Override
    public ShipAPI getTargetShip() {
        return null;
    }

    @Override
    public WeaponAPI getWeapon() {
        return weapon;
    }

    @Override
    public boolean shouldFire() {
        return shouldFire;
    }
}

Hopefully I've been just wasting my time and there's a really dumb easy way to do this.


On an unrelated issue, does insert flash work?, all I get is a link...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on March 25, 2016, 09:17:45 PM
...And... I was wasting my time. Just adding PD to the weapon's hints solved all my issues. Meanwhile combining the hint with the script achieved just what I wanted to do, it works well enough with just the hint, only difference is that the ship will get in range first, which actually makes the weapon more useful.

The flash question still stands, and... Is there a way to make a ship's death not be reported during combat?

I kinda want to try my hand in something that would be too spamming for the interface otherwise (actually I already did and it was "unplayable" 40 individual crappy fighters getting destroyed in quick succession is not a good thing, specially when they also report they are out of replacements besides being destroyed).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 27, 2016, 03:16:19 AM
Will using this to reset a market's smuggling suspicion level work? Will it have any undesired side effects?
Code: java
	if (submarketId.equals("black_market")) {
PlayerTradeDataForSubmarket tradeData =  SharedData.getData().getPlayerActivityTracker().getPlayerTradeData(submarket);
tradeData.setTotalPlayerTradeValue(0);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2016, 10:25:42 AM
I think it'll work, but also stop any reputation loss from BM trading.

Side note: I'd suggest using Submarkets.BLACK_MARKET instead of just "black_market". Not that I'm planning on changing the id for that, but you never know, and if you use the constant, it's a bit quicker to find everywhere it's used (though that's IDE dependent, I suppose).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mr. Nobody on March 28, 2016, 08:51:43 AM
Is there any way to make a 3+ way fight?

Ie: Hegemony, Tri-tach and player all hate each other, A hegemony and a tri-tachion fleet are engaged in battle, the player comes and join the fray, cue large brawl where all parties involved want to kill the other two.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2016, 11:52:34 AM
Not possible, no.

I mean, you might be able to get close with full custom AI and heavy scripting, but the effort involved would be completely unreasonable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mr. Nobody on March 28, 2016, 12:28:18 PM
Well, there goes my idea for a mod.

Thought that since allies work as a second fleet on the player side they were effectively a 3rd party (but only 2 squads) and that adding more would be fairly simple.

Alas it is not (or at least, not on the mod side of things, Alex only knows what goes source side)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2016, 12:29:26 PM
It's still two sides under the hood, but some of the ships are flagged as "allies".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on March 29, 2016, 08:56:05 PM
Is there any way to give a personality (aggressive, steady, etc) without an officer? Or force all ships of a certain type to have that personality?

Was going to say yes, but it turns out PersonAPI getCaptain() isn't exposed in the ShipAPI. Added, but for now the answer is, I think, no.


Thanks! I was thinking of modding in unmanned "fireboats", which is to say small shield-less frigates armed with lmgs, vulcans, and mortars that charge in and die, which would need default aggressive AI.

New question:
Is there a way to change the max number of officers with a skill? I know the base setting is in settings.json, but the SettingsAPI doesn't include an entry for it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2016, 08:58:22 PM
No, though that'll almost certainly be a thing at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on March 29, 2016, 09:25:02 PM
Quick reply! :)

Yeah, officer number or max level bonus is pretty much perfect for a leadership skill or the aptitude bonus. Same thing with maximum ship number, really, and I'm guessing its also not exposed atm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2016, 09:29:13 PM
Yeah, officer number or max level bonus is pretty much perfect for a leadership skill or the aptitude bonus. Same thing with maximum ship number, really, and I'm guessing its also not exposed atm.

Huh, wasn't thinking about officer max level, but yes, that could also be a good one. Not so much with ships, though - I kind of want to sweep that under the rug rather than highlight it mechanically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on March 29, 2016, 09:45:25 PM
Yeah, officer number or max level bonus is pretty much perfect for a leadership skill or the aptitude bonus. Same thing with maximum ship number, really, and I'm guessing its also not exposed atm.

Huh, wasn't thinking about officer max level, but yes, that could also be a good one. Not so much with ships, though - I kind of want to sweep that under the rug rather than highlight it mechanically.

Ah, fair enough! Yeah I've been working on a skills overhaul for my own enjoyment - finished combat and technology and am now brainstorming the Leadership.


Slightly more complicated question:

I want to create the skill effect "Concentrated Fire" where my fleet gets a skill dependent damage bonus when ships target an enemy. (Implemented in an everyFrameCombatPlugin that sweeps through my ships and takes all of their targets with getShipTarget - all of those then take a percentage more damage via their MutableStats. So if 1 ship of mine is targeting, the target takes +x% damage; if 4 ships are targeting, then its +4x% damage.).

My question: How would I get the skill to save some data (a percentage bonus) that the everyFrameCombatPlugin could then check?

(Also, does the AI actually select targets in a big fleet brawl? I should do some check runs in the sim to see what targets it actually selects.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2016, 09:53:15 PM
My question: How would I get the skill to save some data (a percentage bonus) that the everyFrameCombatPlugin could then check?

What about having the per-skill-level bonus being a public static final in the skill class, and then having the plugin access that and multiply it by the player's skill level?

(Also, does the AI actually select targets in a big fleet brawl? I should do some check runs in the sim to see what targets it actually selects.)

It does, but it's not super-reliable about that. However, there's a ShipwideAIFlags.MANEUVER_TARGET which has a ShipAPI as its aiFlags.getCustom(). That's more reliable; I'd recommend using a combination of getTarget() and that, i.e.:

Code: java
ShipAPI target = ship.getShipTarget();
if (target == null) {
Object test = ship.getAIFlags().getCustom(AIFlags.MANEUVER_TARGET);
if (test instanceof ShipAPI) {
...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on March 29, 2016, 10:13:37 PM
That sounds like a more sensible way to do it. I can just put the per level bonus in SkillData.java and have the .skill just handle the cosmetics.

How can the plugin access the skills/skill levels? I haven't found a method in the combatEngineAPI to get that, and I'm guessing you know the easy way :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2016, 10:26:25 PM
How can the plugin access the skills/skill levels? I haven't found a method in the combatEngineAPI to get that, and I'm guessing you know the easy way :P

I was thinking something like if (Global.getCombatEngine().isInCampaign()) and then Global.getSector().getCharacterData() etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on March 31, 2016, 08:54:33 PM
How can the plugin access the skills/skill levels? I haven't found a method in the combatEngineAPI to get that, and I'm guessing you know the easy way :P

I was thinking something like if (Global.getCombatEngine().isInCampaign()) and then Global.getSector().getCharacterData() etc.

Right, Global. I totally remembered Global. *cough*

Another question: I added a sensor profile reduction to the navigation skill, but it appears to only work for the player ship. Did I do something silly, or is this actually a bug?

Effect code:
Code: java
package data.characters.skills.scripts;

import com.fs.starfarer.api.characters.ShipSkillEffect;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class NavigationEffect2 implements ShipSkillEffect {

public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
stats.getSensorProfile().modifyMult(id, (1f - SkillData.NAVIGATION_SENSOR_PROFILE_BONUS_PER_LEVEL * level * 0.01f));
}

public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
stats.getSensorProfile().unmodify(id);
}

public String getEffectDescription(float level) {

return "-" + (int)(SkillData.NAVIGATION_SENSOR_PROFILE_BONUS_PER_LEVEL * level) + "% sensor profile";
}

public String getEffectPerLevelDescription() {
return "" + (int)(SkillData.NAVIGATION_SENSOR_PROFILE_BONUS_PER_LEVEL) + "%";
}

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

}

.skill file:
Code
{
"id":"navigation",
"governingAptitude":"technology",
"effectGroups":[
{
"effects":[
{
"type":"CHARACTER_STATS",
"script":"data.characters.skills.scripts.NavigationEffect1",
},
{
"type":"SHIP",
"script":"data.characters.skills.scripts.NavigationEffect2",
},
]
},
],
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 31, 2016, 09:21:15 PM
In the .skill file, you want type:ALL_SHIPS_IN_FLEET, not SHIP. Type SHIP is for skills that only apply to a ship captained by the person with the skill. ALL_SHIPS_IN_FLEET apply to all ships in the fleet commanded by a person that has the skill.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on March 31, 2016, 09:22:37 PM
Ah, stupid mistake it was! Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liet on April 01, 2016, 01:12:12 PM
Can anybody tell me how I can get my ship into the actual game world, that is it appears in fleets, shows up in markets? Using a mod folder it's in the game (can read it in codex), but not in the world. I'm using SS+ and Nexerelin. Do I need to edit the data/world faction files in SS+ or SS-core? Thanks for any help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on April 01, 2016, 06:32:46 PM
Can anybody tell me how I can get my ship into the actual game world, that is it appears in fleets, shows up in markets? Using a mod folder it's in the game (can read it in codex), but not in the world. I'm using SS+ and Nexerelin. Do I need to edit the data/world faction files in SS+ or SS-core? Thanks for any help.

You are correct that you need to use .faction files (or rather, this is the easiest way). If I understand you correctly, you already have your own mod that contains the .ship, .variant, and appropriate csv files (and of course its own mod_info.json so that it can be turned on and off in the launcher). You can now make your own data/world/factions/<faction> files to add your ships to whatever factions you want, in whatever roles.

For examples, the following code (in my mod folder/data/world/factions/, called hegemony.faction) will add the "hyperion_Attack" variant to the "fastAttack" role of their faction. It also sets its relative weight to 100, so it should show up a lot! Remember to use variants, not ship names. If I also wanted the hyperion to appear in escorts, I need to add it to that role as well. I believe if it is showing up in fleets, it will show up in the markets (though probably in the military market at high rep only, give the Hyperion's quality :P).
Code
{
"shipRoles":{
"fastAttack":{
"hyperion_Attack":100,
},
},
},

The way json files like the .faction files work is that their contents are merged - see this page for more info: http://fractalsoftworks.com/forum/index.php?topic=5016.0

So in this case "hyperion_Attack":100 is being tacked onto the end of the fastAttack list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Polmax on April 08, 2016, 11:03:47 AM
So im kinda confused , first thing , i do not need a custom .jar file for my mod do i? i mean i can have thye .java of my scripts be compiled during execution , or am i wrong?

snd is im trying to make something really simple , use the OnHitEffect interface to just change the sound of my projectiles when they hit

--code

Code
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import org.lwjgl.util.vector.Vector2f;

public class AziimobOnHitEffect implements OnHitEffectPlugin {

private static final Vector2f ZERO = new Vector2f();

    @Override
    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {

            Global.getSoundPlayer().playSound("aziimob_impact", 1f, 1f, point, ZERO);

        }
}

now i have this file in C:\Games\Starsector\mods\Azura Fleet\jars\src\data\scripts\weapons

all the sounds are ready and everything, but everytime i execute it i get error compiling blablabla AziimobOnHitEffect, in the log i get this

Code
10217 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.weapons.AziimobOnHitEffect]
java.lang.RuntimeException: Error compiling [data.scripts.weapons.AziimobOnHitEffect]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.weapons.AziimobOnHitEffect
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

so im guessing its not find the .java  , so what am i doing wrong ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 08, 2016, 06:00:12 PM
If you want to use Janino (auto-compile Java scripts on runtime), put your script file in [MyMod]/data/scripts[/any subdirectory]. Anything else will need compiling.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Polmax on April 09, 2016, 03:24:14 AM
Thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 11, 2016, 06:40:24 AM
How does the economy handle supply/demand for different commodities with the same demand class?

Spoiler
In Nexerelin, I have "agents" and "saboteurs", which have the marines demand class, the military tag and an utility of 3. They are made only from military bases, which in Nexerelin use a modified class:

Code: java
public class ExerelinMilitaryBase extends MilitaryBase {
public static final float EXTRA_MARINES_MULT = 1.25f; // hax

public void apply(String id) {
super.apply(id);
if (this.market.getFactionId().equals("templars"))
{
market.removeSubmarket(Submarkets.GENERIC_MILITARY);
}
market.getCommodityData(Commodities.MARINES).getSupply().modifyFlat(id, ConditionData.MILITARY_BASE_MARINES_SUPPLY * EXTRA_MARINES_MULT);
market.getCommodityData("agent").getSupply().modifyFlat(id, 1);
market.getCommodityData("saboteur").getSupply().modifyFlat(id, 1);
}

public void unapply(String id) {
super.unapply(id);
market.getCommodityData("agent").getSupply().unmodify(id);
market.getCommodityData("saboteur").getSupply().unmodify(id);
}

}
ConditionData.MILITARY_BASE_MARINES_SUPPLY * EXTRA_MARINES_MULT equals 125, so I'd expect there to be tons of marines and few agents or saboteurs.

Instead I routinely see things like this:

(http://i.imgur.com/PbqkePE.png)
(agents are the blue suits, saboteurs are orange)

Are the agents and saboteurs being overproduced, and/or not being consumed? Can I fix this?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 11, 2016, 09:09:07 AM
Do you have lots of demand for marines? If you're setting that somewhere, make sure to also set the non-consuming demand for marines to a high value, so that the demand ends up generating stockpiles instead of consuming the marines entirely.

The actual consumption is based on (demand - nonConsumingDemand), and is distributed among the commodities sharing that demand class proportionally to their total stockpile utility.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 11, 2016, 02:19:11 PM
Soooo... a few AI-related questions, dealing with some final polish issues I'm having before I (finally) release a Vanilla-compliant AI project I've been gradually messing with.

1.  How is the engine spawning MIRV projectileSpecs?

Because, well, it's not doing it by spawnProjectile(), unless there is a .wpn inherent to every .proj with a specific naming convention that I don't know about, lol. 

I need a method to deal with that, because the MissileAI is supposed to handle that behavior somehow, not the .proj, apparently.  So if I want to handle that generically in an AI, I need to know how to trigger it or produce the projectiles.

2.  I have a probably-stupid one about JSON parsing and Drones in general.

How do I parse the droneBehavior to get the values out of the sub-objects, and how do I get a Drone's index number?

i.e., I want to get the Drone's index number, realize it's 0, and get the behavior per:

Spoiler
   "droneBehavior":[
      {"droneIndex":[0],
       "defaultFacing":"MATCH_SHIP_FACING",   # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
       "faceEnemy":true,
       "holdRoamRange":0,
       "freeRoamRange":150,
       "targetPriority":[FIGHTER, SHIP],
       "initialOrbitAngle":60,
       "orbitRadius":-100,             # plus ship radius
       "orbitDir":1,                # -1 or 1
       "orbitSpeed":0,             # pixels/second
      },
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2016, 02:11:06 PM
It's using spawnProjectile. The weapon passed in is the weapon that fired the original missile.



2.  I have a probably-stupid one about JSON parsing and Drones in general.

How do I parse the droneBehavior to get the values out of the sub-objects, and how do I get a Drone's index number?

i.e., I want to get the Drone's index number, realize it's 0, and get the behavior per:

Spoiler
   "droneBehavior":[
      {"droneIndex":[0],
       "defaultFacing":"MATCH_SHIP_FACING",   # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
       "faceEnemy":true,
       "holdRoamRange":0,
       "freeRoamRange":150,
       "targetPriority":[FIGHTER, SHIP],
       "initialOrbitAngle":60,
       "orbitRadius":-100,             # plus ship radius
       "orbitDir":1,                # -1 or 1
       "orbitSpeed":0,             # pixels/second
      },
[close]

No good way to get the index - added a getIndex() method to DroneLauncherShipSystemAPI. For now, your best bet would be to get the list of all drones for a given mothership, and then sort them according to their order in the list returned by CombatEngineAPI.getAllShips(). Note that the index will change as drones get destroyed.

For how to parse it, you've got the JSONObject returned by DroneLauncherShipSystemAPI.getSpecJson(), right? From there it's just using the varius getJSONArray()/getJSONObject() etc methods. Something like:

JSONArray behaviors = json.getJSONArray("droneBehavior");
for (int i = 0; i < behaviors.length(); i++) {
   JSONObject behavior = behaviors.getJSONObject(i);
   // read the details of the behavior here
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 12, 2016, 06:38:05 PM
Quote
It's using spawnProjectile. The weapon passed in is the weapon that fired the original missile.
Ah.  Will test that.  It'd be good to get that under my AI.

I'll look at the drone / JSON issue; that sounds like it might be a bit more work (and more computationally expensive) than I'd like to tackle for the first release, as it'd have to get updated quite often.  It's a minor issue anyhow; fixed-formation Drones don't get used much in Vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shuul on April 13, 2016, 01:03:56 AM
Is it possible to create fighter wing with only one fighter in it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on April 13, 2016, 01:19:51 AM
Why not? You need just put "1" in number of wings. (I have test, so this is functionnal)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 13, 2016, 04:54:46 AM
Single fighter wings didn't work until recently, and I don't know if Alex did it on purpose. They may become unsupported again in future versions and there are probably bugs with them, so I would be very wary of doing anything with them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on April 13, 2016, 05:34:25 AM
Ah ok, i learn a thing today, me. Thank.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 13, 2016, 02:27:44 PM
Quote
It's using spawnProjectile. The weapon passed in is the weapon that fired the original missile.
Tested this... and it generates infinite recursion of the original missile.  

I can't get to the sub-projectile at all this way; what you said doesn't make sense unless there's a way to spawnProjectile that allows us to call a specific projectile by name, which doesn't appear to be a thing; passing in a proj ID rather than a wpn ID results in a crash.  

What's wrong here?  Also note the isFromMissile() check, which fails when tested.
Code
			//Can we spawn missiles from this missile?  Do so now.
if(spawnCount > 0 && !missile.isFromMissile() && missile.getElapsed() > 0.5f){
if(MathUtils.getDistanceSquared(missile, target) <= (spawnDistance * spawnDistance)){
Global.getCombatEngine().applyDamage(missile, missile.getLocation(), 10000f, DamageType.HIGH_EXPLOSIVE, 0f, true, false, missile.getSource());
for(int i = 0; i < spawnCount; i++){
MissileAPI newProj = (MissileAPI) Global.getCombatEngine().spawnProjectile(
missile.getSource(),
missile.getWeapon(),
missile.getWeapon().getId(),
missile.getLocation(),
MathUtils.getRandomNumberInRange(0f, 360f),
missile.getVelocity());
newProj.setFromMissile(true);
}
return;
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2016, 02:55:31 PM
Ahh, you're right - I wasn't taking the parameters of the exposed method into account. Hmm. About the only thing you could do to work around this right now would be to create fake "weapons" for the MIRV warheads.

Added another version of the spawnProjectile method, with an extra "projSpecId" parameter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 13, 2016, 03:08:21 PM
Right on, figured it was something like that :)

I'll just leave those alone for now (because otherwise, not really universally compatible w/out kludges) but I have finished building the basic support for them later.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 15, 2016, 11:21:15 PM
@Alex: My problem is that the economy appears to be demanding/consuming many more marines than the other commodities with the same demand type (so there are often almost as many or more agents and saboteurs than marines in stores, even though there should only be 1 agent and 1 saboteur for every 125 marines based on production values). Is there a reason this would occur?

(I tried setting agent/saboteur utility to 1 from 3, but testing didn't reveal any effect at least on Jangala; there were reliably about 220 marines and one-tenth that many agents and saboteurs each in both cases)

Another question: Is there a mod plugin method or such that gets called just before/when the game reaches the main menu? I need to call Global.getSector().getAllFactions(), but it crashes if I do this in onApplicationLoad().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 16, 2016, 08:11:32 AM
@Alex: My problem is that the economy appears to be demanding/consuming many more marines than the other commodities with the same demand type (so there are often almost as many or more agents and saboteurs than marines in stores, even though there should only be 1 agent and 1 saboteur for every 125 marines based on production values). Is there a reason this would occur?

(I tried setting agent/saboteur utility to 1 from 3, but testing didn't reveal any effect at least on Jangala; there were reliably about 220 marines and one-tenth that many agents and saboteurs each in both cases)

That's because generally, most of the demand for personnel is non-consuming, so the supply needs to only exceed the consuming demand in order for all demand to be eventually filled.

For example: there's demand for 1000 crew, 10 of which is consuming. If there's a supply of 110 crew, it'll be up to 1000 crew in 10 months.

How this works is going to change, though, so may not be something worth worrying *too* much about long-term. If a quick hack would do the job, I'd go for that instead.

Another question: Is there a mod plugin method or such that gets called just before/when the game reaches the main menu? I need to call Global.getSector().getAllFactions(), but it crashes if I do this in onApplicationLoad().

Global.getSector() isn't going to work outside the campaign, since it returns the campaign engine. (I can't check to see if there are any alternatives to getAllFactions() elsewhere, not in front of the dev computer at the moment...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 24, 2016, 08:11:23 AM
Is there a way to be notified when a battle between two NPC fleets ends (i.e. one side has been destroyed or is running)? reportBattleFinished() with a check for battle.isDone() seemed like the obvious way, but it seems to always return false...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 24, 2016, 09:52:30 AM
Hmm - looking at it, jeez, that's a mess.

isDone() works right and only returns true when the battle is over, but the reportBattledFinished() doesn't get called when it should there.

Both reportBattleOccurred() and reportBattleFinished() get called twice per autoresolve round - actually scratch that. reportBattleOccurred gets called 3 times (because of a bug), while reportBattleFinished gets called once.

So, technically, the right way to do this is indeed in reportBattleFinished() and then checking isDone(), and then getting snapshots to see who participated in the battle (because by the time it's done, the battle is cleaned up aside from that). But due to bugs, you'll want to check isDone() in reportBattleOccurred, since that's what gets called instead of reportBattleFinished() when it's finished. Fairly sure that should do the job.

(Fixed on my end, but going to keep an eye on it in case this causes something to break. Also only made it call reportBattleOccured() once per auto-round, with a further reportBattleFinished when it's done.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 29, 2016, 06:11:21 AM
That worked, thanks Alex!

Now: are there any factors other than fleet size that control fleet strategic flight/fight behaviour?

Spoiler
(http://i.imgur.com/JNVdiMp.png)
[close]

Both fleets were created with 12 points (10 combat, 2 utility), and the independent fleet has qualityFactor 0.8 to the pirates' 0.35. Indies have two fighter wings with no carrier, but their other hulls are definitely higher-tier. But the independent fleet is fleeing. This seems odd.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 29, 2016, 09:52:23 AM
1) If CR is low, that affects apparent strength. Can't tell whether this is the case for one of the fleets from the screenshot.
2) The evaluation is cached for a few seconds, so if the fleets recently saw each other but changed composition since, that could affect it.
3) Officers can up to double the strength of a ship they command.
4) If the fleet commander is timid or cautious, and the fleet isn't significantly stronger (+25% or more) than the enemy, they'll run.

Probably #4 going on here.


Nearby fleets also factor in, btw - if there's enough friends or enemies nearby, that'll override the above, basically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on May 01, 2016, 05:58:00 PM
Well, kind of a strange question perhaps, but it seems a bit necessary to figure out right now; Alex what's the calculation you're using to figure out collision damage?

Currently I'm using this for the Mimir's Lock Drive AI because I like it playing fast and loose with the crashin':

Code
     float areaChange = 1f;
     float aMass = ship.getMass();
     float bMass = tmp.getMass();
     
     if (CollisionUtils.getCollides(ship.getLocation(), shipDir, bash, tmp.getCollisionRadius() * 0.5f + ship.getCollisionRadius() *
                                 0.75f * areaChange)) {
         if (tmp.getOwner() == ship.getOwner()) {
                 bashNum = mag.get(tmp.getHullSize()) * ((bMass / aMass * 900f) * 2f); //The ship values friendly ships more, so the crash value is doubled
         } else {
                 bashNum = mag.get(tmp.getHullSize()) * ((bMass / aMass * 900f) * 0.75f);
         }
     }

However, this has resulted in a propensity for banging into things, which has caused a lot people to get annoyed with the AI. A more accurate collision damage model seems like it's probably a good idea, all things considered.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 01, 2016, 07:11:41 PM
It's... complicated. Just throw in something low that's based on the total mass of the two ships, and you can't go too far wrong. As long as the numbers are sort of in line with vanilla, I don't think it's going to be noticeable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gorgonson on May 16, 2016, 05:18:09 AM
I have a question about Spread Decay interacting with Minimum / Maximum Spread.
Smartypants had the idea for a weapon that became more accurate the longer it was fired.

I wasn't sure how to set default accuracy of the weapon to a very low amount - so I figured I'd set Spread Decay to a negative value.  It worked, though the only problem was that the accuracy continually degrades, ignoring the bounds set by Maximum Spread.  Another issue arose when I set the Spread Per Shot to a negative amount.  This did successfully cause each shot to narrow the accuracy of the weapon, but this seemed to begin from an arbitrary number that I can't find.

I'll explain:  The simulation begins with perfect accuracy.  Each second, the cone widens by a few degrees.  Eventually the cone expands to a semicircle, then to a complete circle, totally ignoring the supposed bounds of the spread.  When I fire, the cone immediately snaps to around 10 degrees, then rapidly shrinks as the negative Spread Per Shot is applied from the weapon.

What can I do to fix the accuracy cone within the bounds of Maximum Spread, and why does the accuracy cone suddenly snap to around ten degrees, as opposed to slowly tightening from it's current position?

I really appreciate any advice or feedback you can provide.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on May 23, 2016, 07:17:23 PM
I haven't see much of the code on what calls for variants (or how the game spawns fleets for that matter, excuse my assumptions), but how possible would it be to control the percentages of variants?

Say a Hegemony fleet needs to low FP patrol fleet that may have Lashers. Say I have created 9 variants for the ship. Can I control the percentages right there (for example making it so 60% of it is variant 1,2,3,4,5,6, 30% is either 7,8 and 10% is 9) or would I have to create many copies of the files that are called in order to simulate a percentage? (as in having the fleet spawn code spawn one of these: Lasher A.var, Lasher A.var, Lasher A.var, Lasher B.var, Lasher B.var, Lasher C.var, in this case making Lasher A.var have 50% chance)

I know I'm being crude here, I just want to know how possible any of this is before I try jumping into the real thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on May 24, 2016, 02:21:43 PM
So, I just tested this and it's totally possible to make a weapon's type HYBRID or COMPOSITE or SYNERGY, such that it will only fit into that slot type or a Universal. Some questions:

1) Is this going to stick around? I assume this isn't A+ engine behavior from your perspective.
2) This is actually really cool for modding, because you can make funky edge-case weapons that can only be mounted in fancy slots. Another reason why fewer, more flexible slots become a viable design choice.
3a) How customizable are slot types from the modding end? If I were, say, doing a total conversion, could I rename and recolor them?
3b) How hard is it to hack in a new slot type?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on May 24, 2016, 02:54:14 PM
Slot types are hardcoded iirc, which kind of takes 3a/b out of the question unfortunately
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 28, 2016, 08:45:37 AM
how to use sprite.setBlendFunc() to make an inverse? I draw a white sprite using GL_SRC_ALPHA_SATURATE, GL_ONE_MINUS_SRC_COLOR but it seems unworkable
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 28, 2016, 09:19:12 AM
I haven't see much of the code on what calls for variants (or how the game spawns fleets for that matter, excuse my assumptions), but how possible would it be to control the percentages of variants?

Say a Hegemony fleet needs to low FP patrol fleet that may have Lashers. Say I have created 9 variants for the ship. Can I control the percentages right there (for example making it so 60% of it is variant 1,2,3,4,5,6, 30% is either 7,8 and 10% is 9) or would I have to create many copies of the files that are called in order to simulate a percentage? (as in having the fleet spawn code spawn one of these: Lasher A.var, Lasher A.var, Lasher A.var, Lasher B.var, Lasher B.var, Lasher C.var, in this case making Lasher A.var have 50% chance)

I know I'm being crude here, I just want to know how possible any of this is before I try jumping into the real thing.

You can do that, look in shipRoles in the .faction file - the number after the variant id there is a weight, which is a relative frequency compared to all other variants within that role.

1) Is this going to stick around? I assume this isn't A+ engine behavior from your perspective.

I honestly can't say. It's not a *bad* thing from my perspective, since it's not something that comes up in vanilla as a bug. However, I might make a change that would stop this from working, even entirely without realizing it, since I'm not sure what fortuitous chain of events is required to make this work out all the way through.

About the most I can say is I won't stamp it out on purpose. But if I had to knowingly break it while doing something related? Would totally do it.


how to use sprite.setBlendFunc() to make an inverse? I draw a white sprite using GL_SRC_ALPHA_SATURATE, GL_ONE_MINUS_SRC_COLOR but it seems unworkable

It really depends on what you mean by "inverse"; I'd suggest taking a look here:
https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

This talks about the possible values and what they do, a good starting point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 28, 2016, 09:33:36 AM
how to use sprite.setBlendFunc() to make an inverse? I draw a white sprite using GL_SRC_ALPHA_SATURATE, GL_ONE_MINUS_SRC_COLOR but it seems unworkable

It really depends on what you mean by "inverse"; I'd suggest taking a look here:
https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

This talks about the possible values and what they do, a good starting point.

Well I have learnt about it and actually it does no help.
Inverse i mean...like pressing ctrl+i in ps
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 28, 2016, 09:58:12 AM
Inverse i mean...like pressing ctrl+i in ps

You might try GL_ONE_MINUS_SRC_COLOR, GL_ZERO. That's not going to look the same, though - what PS does is more involved than just a straight color inversion. Not sure offhand how you'd accomplish the same thing without using shaders.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Codyrex123 on May 31, 2016, 11:12:07 AM
No. But it can now have an animated barrel, a la the Assault Chaingun or the Thumper.


What about.... a beam weapon like that except it'l have a laser for each barrel, so it does hit long the side? i mean, i don't know what'l happen when they are sitting on top of each other, maybe extra damage to the bit they are hitting?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on June 01, 2016, 03:30:29 AM
i mean, i don't know what'l happen when they are sitting on top of each other, maybe extra damage to the bit they are hitting?

Um, do you mean it's a spinning barrel weapon with beams that fires every barrel at once like a tactical laser? What's the point of the spinning barrels then?
But spinning barrels aside, there's already a vanilla weapon that does basically that-- the large burst laser is a beam array and yeah getting hit by more than three lasers from the same weapon does three times the damage. I'm not sure what your question is, specifically
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mord on June 01, 2016, 07:12:50 AM
IS there a way to increase the max fleet size limit so i wont lose cr for having a huge fleet? I tried to go around in the settings but i didnt find anything what could be used for that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on June 01, 2016, 09:30:32 AM
IS there a way to increase the max fleet size limit so i wont lose cr for having a huge fleet? I tried to go around in the settings but i didnt find anything what could be used for that.
What version of the game are you playing? There is no longer a soft cap in 0.7.2a.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mord on June 01, 2016, 01:10:03 PM
IS there a way to increase the max fleet size limit so i wont lose cr for having a huge fleet? I tried to go around in the settings but i didnt find anything what could be used for that.
What version of the game are you playing? There is no longer a soft cap in 0.7.2a.
If i remember correctly its 7.2a. I currently have 25 ships and i constantly get a message saying that my fleet is over the optional number ,uses more supplies and i get 15% cr punishment. Im maybe doing something wrong or missing something but i coulkdnt find anything useful on the net regarding this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 01, 2016, 09:18:59 PM
There's an SS+ setting that does that; it can be changed in SSP_OPTIONS.ini.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mord on June 02, 2016, 05:39:22 AM
There's an SS+ setting that does that; it can be changed in SSP_OPTIONS.ini.
Oh my god, it worked! Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on June 02, 2016, 02:02:05 PM
How do you control where ship.addAfterimage(...) spawns the afterimage? I have a system that spawns one that seems to change position each time it is used, even though the locX and locY variables are the ship locations corresponding x and y values.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2016, 02:20:33 PM
The afterimage location is relative to the center of the ship. Added a comment to that effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on June 03, 2016, 08:06:09 PM
Thanks for the answer.

I was also wondering what is with ship sprites sometimes looking a bit blurry compared to their actual sprite, when they're shown in game. Is there any reason for this, and anyway to fix it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 03, 2016, 08:31:46 PM
Consider that the pixels of the sprite virtually never exactly align with the pixels on the screen. For example, they won't even have a chance to do that if the ship's facing is not a multiple of 90, which it only ever is at the start of a battle.

Plus, iirc the view moves around by fractions of a pixel.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on June 03, 2016, 09:21:29 PM
There are techniques to reduce translation aliasing, such as forcing screen scrolling to a minimum value and otherwise clamping to an integral position when stopped, forcing integral screen positions when scrolling sufficiently quickly, etc.  Generally speaking, those are all pointless for Starsector because there are no guarantees for positional or rotational alignment for ships.

The only "fix" is to create art that isn't prone to interpolation/aliasing problems.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 03, 2016, 09:25:49 PM
There are techniques to reduce translation aliasing, such as forcing screen scrolling to a minimum value and otherwise clamping to an integral position when stopped, forcing integral screen positions when scrolling sufficiently quickly, etc.

(As a side note, actually tried that - it's surprising how un-smooth clamping to the nearest pixel feels. And if you're moving the view fast, then yeah, that might be ok, but it doesn't really matter since it *is* moving fast...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on June 03, 2016, 09:44:45 PM
It's more for changing your screen movement from "Move at X Velocity and Dampen" to "Calculate Endpoint, Round Endpoint, Use Calculus to Determine Modified Resultant Velocity, Dampen, and Force Velocity 0 and Integral Position When Below Sufficiently Low Speed".  More complicated, but avoids blurring static backgrounds.  Again, it's pointless for Starsector.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on June 04, 2016, 01:14:47 AM
How to play music (BGM) in battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on June 10, 2016, 04:42:29 PM
How do you add a market to a station?

How do you stop your faction's fleets from flying with their transponder off?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lakis on June 12, 2016, 06:56:04 PM
EDIT2: Narrowed it down to Neutrino, testing to see if there's a trigger or if it's just neutrino, even with just it's Dependencies.

Confirmed, fatal error (haphazardly coming up with blue text or not), happens even with just Neutrino's Basic Dependencies.

Edit1:Was missing Graphics lib, however new error popped up once it was installed.  Neon Blue Fatal error...

Anyone run across this using these mods together on linux?

Mod list:
Spoiler

Starsector+
Blackrock Driveyards
Combat Chatter
Common Radar
Console Commands
Diable Avionics
Interstellar Imperium
Junk Pirates/ asp / pack
lazy lib
Metelson industries
neutrino corporation
new galactic order
nexerelin
pegasus belt council
save transfer
scy nation
shadowyards
steiner foundation
kinhgts templar
the mayorate
tiandong heavy industries
twiglib
version checker
musiclib - Now known as Audio Plus.
shaderlib -Now Known as GraphicsLib

[close]

Current Error from .log (showing up in window as Neon Blue Fatal error.):
Spoiler
Code
31995 [Thread-5] INFO  org.lazywizard.lazylib.LazyLib  - Running LazyLib v2.1 for Starsector 0.7a
31995 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [lazylib_settings.json]
32079 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoSuchFieldError: o00000
java.lang.NoSuchFieldError: o00000
at data.scripts.SetUnlockBySkill.setUnlockBySkill(SetUnlockBySkill.java:36)
at data.scripts.NCModPlugin.onApplicationLoad(NCModPlugin.java:68)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)

[close]


Previous Error Below.
Spoiler
Code
89585 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at com.fs.starfarer.loading.scripts.ScriptStore.new(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.o00000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
[close]
Previous Error above.

.sh file for linux.
Spoiler
Code
java -server -XX:CompilerThreadPriority=1 -XX:+CompilerThreadHintNoPreempt -Djava.library.path=./native/linux -Xms2048m -Xmx4096m -Xss4096k 
-classpath janino.jar:commons-compiler.jar:commons-compiler-jdk.jar:starfarer.api.jar:starfarer_obf.jar:jogg-0.0.7.jar:jorbis-
0.0.15.jar:json.jar:lwjgl.jar:jinput.jar:log4j-1.2.9.jar:lwjgl_util.jar:fs.sound_obf.jar:fs.common_obf.jar:xstream-1.4.2.jar
-Dcom.fs.starfarer.settings.paths.saves=./saves -Dcom.fs.starfarer.settings.paths.screenshots=./screenshots
-Dcom.fs.starfarer.settings.paths.mods=./mods -Dcom.fs.starfarer.settings.paths.logs=. com.fs.starfarer.StarfarerLauncher

[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2016, 09:28:38 AM
How to play music (BGM) in battle?

Global.getSoundPlayer().playMusic()

The sound set id point so an entry under "music" in sounds.json.


How do you add a market to a station?

Off the top of my head, something like:

MarketAPI market = Global.getFactory.createMarket(...)
station.setMarket(market);
Global.getEconomy().addMarket(market);

The last step - adding the market to the economy - is required for the market to participate in the economy. If you don't, though, it should still work as far as being interacted with by the player.


How do you stop your faction's fleets from flying with their transponder off?

Make them patrols or traders, like so:

fleet.getMemory().set(MemFlags.MEMORY_KEY_PATROL_FLEET, true);
fleet.getMemory().set(MemFlags.MEMORY_KEY_TRADE_FLEET, true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on June 13, 2016, 03:56:33 PM
Is there a way to have a phasecloak system without having to have the "_glow1" and "_glow2" sprites?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2016, 04:40:09 PM
Unless not specifying those works, no. But they can just be a 1x1 transparent PNG.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on June 13, 2016, 05:26:48 PM
Kind of related; is there any purpose to the "phaseHighlight" and "phaseDiffuse"? It doesn't seem to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2016, 06:45:22 PM
They specify what the filename with the phase coil glow is. Is that what's not working for you?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on June 13, 2016, 06:55:00 PM
Alex the fact that this thread is 189 pages long and you're still replying is super cool of you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2016, 07:19:55 PM
I think it's more cool that most of those pages are filled with fellow modders helping each other :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on June 13, 2016, 07:21:58 PM
Yea, those two don't seem to do anything. I tried to use the same sprite for the highlight and diffuse (sprite_glow1) and it said that it required a _glow2 sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2016, 07:27:11 PM
Hm, looking at the code that seems... unlikely. It's not hardcoded anywhere and is properly getting the values from what's specified in the .system file. Are you sure it's not doing that for some other system where glow2 *is* specified? Such as say the vanilla phase cloak.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on June 13, 2016, 07:32:15 PM
I'm sure it's not the vanilla phase cloak.

Are there supposed to be full sprite names in there? Ex: "phaseHighlight":"sprite_glow1" vs. "phaseHighlight":"_glow1".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2016, 07:38:30 PM
Sample ship sprite name: doom.png
"phaseHighlight":"_glow1",

Yields the highlight sprite name of doom_glow1.png. So, the 2nd option.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on June 13, 2016, 07:57:23 PM
I'm not entirely sure what is going wrong then.  :-\

Well I got it working by using 1x1 pngs. Thanks for the help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2016, 07:59:10 PM
Weird... well, uhh. I'll just leave it at that then, would rather not experiment with it in the dev build, for fear of forgetting to revert something etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 14, 2016, 09:25:34 AM
Here's a misc mod question for Alex; did you ever play with SS+ before the content split? Specifically, did you ever toy around with the mobile HQ Castle Ship?

I haven't, actually, never got a chance to.


What are your thoughts on a largely immobile firing platform with a shipsystem that increases its weapon range way beyond its sight radius at the expense of not being able to sustain fire with its ability on without needing to eventually vent flux? I found it mesmerizing to take into combat and have an actual firing platform and it always made me salivate at the thought of space stations and firing platforms in-combat

:-X

Let's not get this thread off-topic, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on June 24, 2016, 10:42:02 PM
Currently working on a mod that adds Lion's Guard reskinned ships to the game. How do I make the Sindrians and Lion's Guard use them? I've tried working backwards from the Ship and Weapons pack, but I'm not sure exactly what file in the directory says 'use these ships'. Tried making new data/world/factions/lions_guard (OR) Sindrian_Diktat FACTION files, and still haven't seen them at all from new games.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 25, 2016, 08:37:56 AM
Seems like you're going about it the right way - you want to add a "lions_guard.faction" file, and then point to your new ships from shipRoles in that file. However, that would only add those ships to the existing configuration for the faction, not replace it entirely. To do that, you need to add the faction file to the "replace" list in your mod_info.json, like so:

"replace":["data/world/factions/lions_guard.faction", "<another file if needed>"],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on June 26, 2016, 01:48:21 AM
Thanks Alex! I think the main problem is I'm running SWP and that's 'drowning out' the modded ships.

Another quick one - I'm making a hullmod for the Sindrians that gives better ship speed etc., but at the cost of consuming more fuel. Exactly what is the name of the mutable ship stats API that affects fuel? Is it stats.getFuelPerLightYear?


Also - a general interest question. Could you make a particular ship role get a damage bonus vs. another ship role? I wouldn't mind just mucking around with the interceptor and fighter roles and giving them bonuses vs. Bombers and interceptors respectively.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Marsale on June 26, 2016, 05:30:34 AM
Hi

I'm trying to add a new ship through Trylo's ship editor. I've gone through the steps as far as I can read on the guides on the wiki, adding the center, shields, etc, edited the ships.csv file through the editor to add a new entry and also added a standard .variant file. However, Starsector crashes on startup and the .log file tells me very little or something I can't understand.

java.lang.NullPointerException
   at com.fs.starfarer.loading.specs.HullVariantSpec.setHullSpec(Unknown Source)
   at com.fs.starfarer.loading.specs.HullVariantSpec.<init>(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

I'm not sure where to begin, what did I do wrong? I don't have any other mods installed.

edit- I must have done something wrong with the hull or variant names because redoing it fixed this. Thanks anyway!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morbo513 on June 26, 2016, 11:27:29 AM
Is there a way to increase the rate at which a station/planet's shipyard will refresh its inventory? If I'm using SS+, Nexerelin and Dynasector, which of these if any will I need to make the change to?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Blaze on June 29, 2016, 04:21:35 AM
Another quick one - I'm making a hullmod for the Sindrians that gives better ship speed etc., but at the cost of consuming more fuel. Exactly what is the name of the mutable ship stats API that affects fuel? Is it stats.getFuelPerLightYear?
stats.getFuelUseMod


Quote
Also - a general interest question. Could you make a particular ship role get a damage bonus vs. another ship role? I wouldn't mind just mucking around with the interceptor and fighter roles and giving them bonuses vs. Bombers and interceptors respectively.
I'm not experienced enough to answer this, but I think you'd be better off using weapon scripts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 01, 2016, 06:21:19 PM
Thanks Blaze!

Another question - say I make the built-in speed mod, however I don't want the ship to then be able to use Augmented Engines or Unstable Injectors. How do I make this happen? Do I adjust the isApplicableToShip? Or do I need to edit the 'core' hullmods to do this like they do in StarSector Plus?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Blaze on July 01, 2016, 10:34:00 PM
Code
	@Override
public boolean isApplicableToShip(ShipAPI ship) {
return !ship.getVariant().getHullMods().contains("UnstableInjector") && !ship.getVariant().getHullMods().contains("AugmentedEngines");
}

Adding this should make it so you can't apply it if you have either hullmod and block installing those hullmods if you have your hullmod installed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 02, 2016, 12:59:58 AM
Thank you very much Blaze!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 02, 2016, 01:13:07 AM
Depending on the implementation you seek, you'll have to take some mods' hullmods into account too.
Also since it is built-in, it's the other way around: you have to remove the hullmod they just added instead, and probably something like this (http://fractalsoftworks.com/forum/index.php?topic=6452.msg172577#msg172577) to tell the players about the incompatibility.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 02, 2016, 01:33:34 AM
Question about skill_data.csv.
If i set a skill's 'combat officer' TRUE, it will appear in officers' level up skills any way?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 02, 2016, 02:39:31 AM
Depending on the implementation you seek, you'll have to take some mods' hullmods into account too.
Also since it is built-in, it's the other way around: you have to remove the hullmod they just added instead, and probably something like this (http://fractalsoftworks.com/forum/index.php?topic=6452.msg172577#msg172577) to tell the players about the incompatibility.

Giving your 'block hullmod' thing a go from that link, but I keep getting an error:

Code
81401 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.hullmods.LionsGuard]
java.lang.RuntimeException: Error compiling [data.hullmods.LionsGuard]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.LionsGuard'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/LionsGuard.java', Line 34, Column 70: Identifier expected instead of '>'
at org.codehaus.janino.Parser.compileException(Parser.java:3125)
at org.codehaus.janino.Parser.readIdentifier(Parser.java:2909)
at org.codehaus.janino.Parser.parseQualifiedIdentifier(Parser.java:245)
at org.codehaus.janino.Parser.parseReferenceType(Parser.java:1776)
at org.codehaus.janino.Parser.parseType(Parser.java:1752)
at org.codehaus.janino.Parser.parseTypeArgument(Parser.java:1856)
at org.codehaus.janino.Parser.parseTypeArgumentsOpt(Parser.java:1827)
at org.codehaus.janino.Parser.parseReferenceType(Parser.java:1776)
at org.codehaus.janino.Parser.parseType(Parser.java:1752)
at org.codehaus.janino.Parser.parsePrimary(Parser.java:2444)
at org.codehaus.janino.Parser.parseUnaryExpression(Parser.java:2252)
at org.codehaus.janino.Parser.parseMultiplicativeExpression(Parser.java:2211)
at org.codehaus.janino.Parser.parseAdditiveExpression(Parser.java:2190)
at org.codehaus.janino.Parser.parseShiftExpression(Parser.java:2169)
at org.codehaus.janino.Parser.parseRelationalExpression(Parser.java:2072)
at org.codehaus.janino.Parser.parseEqualityExpression(Parser.java:2046)
at org.codehaus.janino.Parser.parseAndExpression(Parser.java:2025)
at org.codehaus.janino.Parser.parseExclusiveOrExpression(Parser.java:2004)
at org.codehaus.janino.Parser.parseInclusiveOrExpression(Parser.java:1983)
at org.codehaus.janino.Parser.parseConditionalAndExpression(Parser.java:1962)
at org.codehaus.janino.Parser.parseConditionalOrExpression(Parser.java:1941)
at org.codehaus.janino.Parser.parseConditionalExpression(Parser.java:1922)
at org.codehaus.janino.Parser.parseAssignmentExpression(Parser.java:1901)
at org.codehaus.janino.Parser.parseExpression(Parser.java:1886)
at org.codehaus.janino.Parser.parseVariableInitializer(Parser.java:966)
at org.codehaus.janino.Parser.parseVariableDeclaratorRest(Parser.java:1230)
at org.codehaus.janino.Parser.parseFieldDeclarationRest(Parser.java:1195)
at org.codehaus.janino.Parser.parseClassBodyDeclaration(Parser.java:631)
at org.codehaus.janino.Parser.parseClassBody(Parser.java:515)
at org.codehaus.janino.Parser.parseClassDeclarationRest(Parser.java:481)
at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:269)
at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:168)
at org.codehaus.janino.JavaSourceIClassLoader.findCompilationUnit(JavaSourceIClassLoader.java:203)
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:146)
... 7 more

I've narrowed it down to this line (I think) by process of elimination (IE sticking the block hullmod in various spots in the hullmod code and comparing with the line at which the error occurs):

    private static final Set<String> BLOCKED_HULLMODS = new HashSet<>();

The error doesn't exist if you remove the 'block' hullmod section. The code SHOULD work, as I've had a peak in your own blocked hullmod section and there is barely (if any) difference to what you put in the Radioactive Code Dump. Clearly, I am doing something wrong. Any thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 02, 2016, 05:05:15 AM
It needs to be compiled though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 02, 2016, 07:19:22 AM
Question about skill_data.csv.
If i set a skill's 'combat officer' TRUE, it will appear in officers' level up skills any way?

Yes, it should show up as one of the levelup choices for the officers. Press "L" in dev mode to gain a bunch of XP to test this out more easily.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 02, 2016, 11:13:40 PM
Seems like you're going about it the right way - you want to add a "lions_guard.faction" file, and then point to your new ships from shipRoles in that file. However, that would only add those ships to the existing configuration for the faction, not replace it entirely. To do that, you need to add the faction file to the "replace" list in your mod_info.json, like so:

"replace":["data/world/factions/lions_guard.faction", "<another file if needed>"],

A follow up to this:

I've made anew Lion's Guard Faction file and used the code above in the mod_info...and it hasn't replaced it. I've seen standard vanilla brawlers in the Lion's Guard, not to mention I haven't seen any of the modded ships - at all - in either Sindrian or Lion's Guard factions. Using FindShip in console comes back 'no ships found'. So what's a more solid way of adding ships to vanilla factions? Or am I doing something completely wrong? The ships work - I've used AddShip to get them in the fleet and I've had no issue. Once I've got this one, single detail down pat then I can finally release the BETA for this mod, and start work on my own faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 02, 2016, 11:51:35 PM
There is no "more solid" way to add ships: that's the way to add ships to a faction. Are you only using your mod with vanilla to test that first? With no other mods that overwrite the fleets composition like DynaSector?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 03, 2016, 12:43:44 AM
There is no "more solid" way to add ships: that's the way to add ships to a faction. Are you only using your mod with vanilla to test that first? With no other mods that overwrite the fleets composition like DynaSector?

Just checked. Works like a charm with vanilla. The question then becomes how do you get it to work in a dynasector / starsector game, if at all? There must be a way, considering Ship and Weapons pack isn't affected, so to speak. Yet all the stuff I've looked at focuses on adding carrier fleets to the game, and making fleets from roles, and not exactly where it specifically focuses on the mod ships. Presumably it should use ships based on roles, not based on mod.

Adding onto this: Is there a tutorial on making ship systems? I've cast around and I can't seem to locate one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 03, 2016, 04:52:34 AM
Yes, it should show up as one of the levelup choices for the officers. Press "L" in dev mode to gain a bunch of XP to test this out more easily.

Alright, i know. Thx
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 06, 2016, 04:14:44 AM
Alright, I'm stuck - how do skin files work?

I've got the SKIN files pointing to the skins images, I've got the Variants pointing at the skin files, but the game keeps chucking a 'ship hull_id not found' error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 07, 2016, 07:05:18 AM
Alright, I'm stuck - how do skin files work?

I've got the SKIN files pointing to the skins images, I've got the Variants pointing at the skin files, but the game keeps chucking a 'ship hull_id not found' error.
Paste your .skin and .variant files and maybe we can see what's wrong.
(My totally random guess is an incorrect baseHullId in the skin definition)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 07, 2016, 05:45:10 PM
Here's the SKIN file:

Code
{
"baseHullId":"brawler",
"skinHullId":"lg_brawler",
"hullName":"Brawler (LG)",
"descriptionId":"brawler",
"descriptionPrefix":"One of the Lion's Guard Fleet, this ship has been modified by the best Sindrian Engineers with several minor improvements to the flux systems and increased ordinance, enabling these ships to hit well above their weight. Unfortunately these improvements, as varied and often incompatible as the best Sindrian engineers that included them, increase the deployment costs of these ships.",
"fleetPoints":5,
"ordnancePoints":50,
"baseValueMult":1.75,
"spriteName":"graphics/ships/brawler/lg_brawler.png",
"coversColor":[255,255,255,255],
"removeWeaponSlots":[], # ids
"removeEngineSlots":[], # indices, as engine slots have no id in the .ship file
"removeBuiltInMods":[], # hullmod ids
"removeBuiltInWeapons":[], # weapon slot ids
"builtInMods":["LionsGuard", "solar_shielding"],
"builtInWeapons":{
    },
}

...and the VARIANT file:

Code
{
  "displayName": "Raider",
  "fluxCapacitors": 7,
  "fluxVents": 8,
  "hullId": "lg_brawler",
  "hullMods": [],
  "quality": 0.25,
  "variantId": "lg_brawler_Raider",
  "weaponGroups": [
    {
      "autofire": false,
      "mode": "LINKED",
      "weapons": {
        "WS 001": "heavymauler",
        "WS 002": "heavyac"
      }
    },
    {
      "autofire": false,
      "mode": "ALTERNATING",
      "weapons": {
        "WS 003": "harpoon",
        "WS 004": "harpoon"
      }
    }
  ]
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 08, 2016, 08:10:56 AM
I put the variant and skin into a test mod (removing the LG hullmod and using an existing vanilla sprite for the Brawler) and I could add it to my fleet with console command, no problems.

What does starsector.log say? (Should've asked for that from the beginning...)
Maybe it's crashing on a different ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 08, 2016, 06:28:13 PM
Code
...
3129 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\data\variants\vigilance_Strike.variant]
3131 [Thread-4] INFO  com.fs.starfarer.loading.SpecStore  - Loading variant [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Lions Guard\data\variants\brawler\lg_brawler_Raider.variant]
3131 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Lions Guard\data\variants\brawler\lg_brawler_Raider.variant]
3170 [Thread-7] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.missions.coralnebula.MissionDefinition] already loaded (perhaps from jar file, or due to a reference from another class), skipping compilation.
3183 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull spec [lg_brawler] not found!
java.lang.RuntimeException: Ship hull spec [lg_brawler] not found!
at com.fs.starfarer.loading.OO0O.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.super(Unknown Source)
at com.fs.starfarer.loading.specs.HullVariantSpec.<init>(Unknown Source)
at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
...

It happens when you start up the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 08, 2016, 06:44:20 PM
Make sure you've deleted the lg_brawler entry in hull_data.csv and the lg_brawler.ship file if they're still there.

Other than that, best I can suggest at this point is to just throw up the mod zip somewhere and others can try debugging it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 08, 2016, 09:26:27 PM
But there isn't any hull.csv nor .ship files at all.

Here's the mod pack. (https://www.dropbox.com/s/oxfk1ydaeuihkj0/Lions%20Guard.rar?dl=0) Give me a yell if it's inaccessable.

I just want this freaking done already - the Sindrians NEED this!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 16, 2016, 07:59:05 AM
BALLISTIC_AS_BEAM
This type of projectile.
How to use the custom texture type?
And are there other preset texture type aside from SMOOTH and TOUGH?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 16, 2016, 08:05:48 AM
Same as beams, add something like this to the .proj file:
"textureType":["graphics/fx/emp_arcs.png","graphics/fx/emp_arcs.png"]

That should work. The first one is the fringe, the second is the core.

The preset texture types are:

SMOOTH("graphics/fx/beamfringeb.png","graphics/fx/beamcoreb.png"),
MEDIUM("graphics/fx/beamfringec.png","graphics/fx/beamcorec.png"),
ROUGH("graphics/fx/beamfringe.png","graphics/fx/beamcore.png"),
CHUNKY("graphics/fx/beam_chunky_fringe.png","graphics/fx/beam_chunky_core.png"),
ROUGH2("graphics/fx/beam_rough2_fringe.png","graphics/fx/beam_rough2_core.png"),
WEAVE("graphics/fx/beam_weave_fringe.png","graphics/fx/beam_weave_core.png"),
LASER("graphics/fx/beam_laser_fringe.png","graphics/fx/beam_laser_core.png"),

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 16, 2016, 05:15:59 PM
Same as beams, add something like this to the .proj file:
"textureType":["graphics/fx/emp_arcs.png","graphics/fx/emp_arcs.png"]

That should work. The first one is the fringe, the second is the core.

The preset texture types are:

SMOOTH("graphics/fx/beamfringeb.png","graphics/fx/beamcoreb.png"),
MEDIUM("graphics/fx/beamfringec.png","graphics/fx/beamcorec.png"),
ROUGH("graphics/fx/beamfringe.png","graphics/fx/beamcore.png"),
CHUNKY("graphics/fx/beam_chunky_fringe.png","graphics/fx/beam_chunky_core.png"),
ROUGH2("graphics/fx/beam_rough2_fringe.png","graphics/fx/beam_rough2_core.png"),
WEAVE("graphics/fx/beam_weave_fringe.png","graphics/fx/beam_weave_core.png"),
LASER("graphics/fx/beam_laser_fringe.png","graphics/fx/beam_laser_core.png"),


Thanks.
And seems like if proj's spawntype is BALLISTIC, texture type wont work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 19, 2016, 04:11:14 AM
How can i let only specific ships spawn in the black markets?  :-\
Might be best to make your own version of the black market submarket and spawn the special ships you want in the code.

Hello everyone.

Can you advise me, how can I make a hullmods which would have produced fuel over time? And that while the number of produced fuel would depend on the distance to the nearest star, the closer to the star, the more fuel is produced.

If you already have mod which such already is realized, please show it to me as an example.

Thanks in advance for your help.

Quickly whipped up example hullmod code, untested:

Code: java
	public static final float BASE_DISTANCE = 100;
public static final float FUEL_PER_DAY = 2;
IntervalUtil interval = new IntervalUtil(0.25f,0.25f); // probably premature optimisation but meh

@Override
public void advanceInCampaign(FleetMemberAPI member, float amount) {
float days = Global.getSector().getClock().convertToDays(amount);
interval.advance(days);
if (interval.intervalElapsed()) {
CampaignFleetAPI fleet = member.getFleetData().getFleet();
LocationAPI loc = fleet.getContainingLocation();
if (loc == Global.getSector().getHyperspace()) return;

// NOTE: uses generics, will fail if using Janino runtime compiler
List<PlanetAPI> planets = loc.getPlanets(); // TODO check if this also gets the system primary, if not use getAllEntities instead
for (PlanetAPI planet : planets) {
if (!planet.isStar()) continue;

// TODO: consider examining the star specs (size, corona size, etc.) and multiplying fuel generation accordingly
// also being in the corona or a solar storm might increase fuel production
float distance = Misc.getDistance(planet.getLocation(), fleet.getLocation());
if (distance < 10) distance = 10; // div0 protection, keeps fuel production non-ridiculous when getting _really_ close
float fuelMult = BASE_DISTANCE/distance;

// TODO: modifying output by the hull size of the ship this hullmod is installed on is left as exercise to the reader
fleet.getCargo().addCommodity(Commodities.FUEL, FUEL_PER_DAY * fuelMult * interval.getIntervalDuration());
}
}
}

I'm finally getting round to doing some work on my mod after a while and I was just wondering how I would actually add this into the game.
I was hoping to use it on my Destiny in my stargate mod I'm working on so it can refuel near stars.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2016, 07:59:01 AM
And seems like if proj's spawntype is BALLISTIC, texture type wont work?

Correct.


I'm finally getting round to doing some work on my mod after a while and I was just wondering how I would actually add this into the game.
I was hoping to use it on my Destiny in my stargate mod I'm working on so it can refuel near stars.

I would *strongly* recommend implementing this as an EveryFrameScript, added at Sector-level, that does this for the player fleet only - or, perhaps, an active ability that, when used, grants this fuel.

The way this is set up is it will run for every single fleet member of every single fleet in every singe location; even with the "premature optimization" that seems like it'll be super heavy performance-wise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 19, 2016, 08:03:25 AM
I was hoping to do it as a hull mod as it's only for 1 ship. I just have no idea how to add it to my mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2016, 08:13:28 AM
The advanceInCampaign method gets called for all ships, not just ones with the mod.

Actually, never mind, I'm wrong about that. Was thinking of the "void advanceInCampaign(CampaignFleetAPI fleet);" method.


Right, so: to add this a new hullmod to hull_mods.csv that points to this code, and then add the hullmod to a ship, and you should be good.

One more note: the mod effect script only gets instantiated once, meaning the "interval" data member would be shared between all ships that have this mode. That's not what you want, I'm assuming.

The way to get around that would be to use the SectorEntityToken.Map<String, Object> getCustomData() to store data specific to each fleet member. Basically, anything that you want to be a member variable would go in there instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 19, 2016, 11:31:31 AM
I tried adding it as a hullmod and set up the csv data but got this error and I'm not sure why if anyone can help.

Spoiler
31368 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.hullmods.SolarRefuelling]
java.lang.RuntimeException: Error compiling [data.hullmods.SolarRefuelling]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.SolarRefuelling'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/SolarRefuelling.java', Line 1, Column 33: One of 'class interface' expected instead of 'float'
   at org.codehaus.janino.Parser.compileException(Parser.java:3125)
   at org.codehaus.janino.Parser.read(Parser.java:2839)
   at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:266)
   at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:168)
   at org.codehaus.janino.JavaSourceIClassLoader.findCompilationUnit(JavaSourceIClassLoader.java:203)
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:146)
   ... 7 more
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2016, 11:40:14 AM
If you're looking for help with a compilation error, usually posting the full source is a good idea :)

That said: the other partial source you posted is using generics, so it's not going to work w/ Janino anyway. But that doesn't look like the error, so there's probably another issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 19, 2016, 11:43:36 AM
I thought I posted all the error parts. I don't even know what janino is.

But the code I quoted is what I tried to use.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2016, 11:47:31 AM
Ahh. From a comment in your code:
// NOTE: uses generics, will fail if using Janino runtime compiler  

I was assuming you'd written/read that.

You didn't post the full code for that file. It looks like the error is happening in a part you did not post.

(Edit: Wait. *Did* you actually post the full code for that file? If you did, there are... problems.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 19, 2016, 11:52:50 AM
Oh. It was posted ages ago when someone asked about doing it and I thought I would try it. I'm not a good coder so just tried to implement it as is. In the quote I posted I thought was the entire code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2016, 11:59:47 AM
Gotcha, fair enough. This code is just a snippet, it's missing some vital stuff like imports, the actual class definition, etc. It would also need to be either 1) pre-complied or 2) adjusted to be compilable with the Java compiler the game comes with (called "Janino").

If you want to tackle it, I'd suggest looking at the code for hullmods the game comes with as a first step, and possibly at some very basic Java tutorials just to get an understanding for what a class definition is/what it looks like.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 19, 2016, 12:07:40 PM
Will do at some point, Thanks for your help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 20, 2016, 01:55:39 PM
Can anyone tell me what this error is. I'm trying to add another weapon to my mod but seem to get this error everytime I try to start it and I can't see anything wrong with the files. it's a modified swarmer.

Spoiler
8976 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IllegalArgumentException: No enum constant com.fs.starfarer.api.combat.WeaponAPI.AIHints.50
java.lang.IllegalArgumentException: No enum constant com.fs.starfarer.api.combat.WeaponAPI.AIHints.50
   at java.lang.Enum.valueOf(Unknown Source)
   at com.fs.starfarer.loading.B.o00000(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpreadsheetLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on July 20, 2016, 03:15:56 PM
Can anyone tell me what this error is. I'm trying to add another weapon to my mod but seem to get this error everytime I try to start it and I can't see anything wrong with the files. it's a modified swarmer.

Spoiler
8976 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IllegalArgumentException: No enum constant com.fs.starfarer.api.combat.WeaponAPI.AIHints.50
java.lang.IllegalArgumentException: No enum constant com.fs.starfarer.api.combat.WeaponAPI.AIHints.50
   at java.lang.Enum.valueOf(Unknown Source)
   at com.fs.starfarer.loading.B.o00000(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpreadsheetLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ø00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Sounds like you're trying to pass an enum into a function which does not take an enum paremeter. Can you post you're code for the weapon here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 22, 2016, 02:37:50 AM
heres the weapon file
Spoiler
{
   "id":"jumperdrones",
   "specClass":"projectile",
   "type":"MISSILE",
   "size":"SMALL",
   "turretSprite":"graphics/weapons/swarmer_srm_launcher_turret_base.png",
   "hardpointSprite":"graphics/weapons/swarmer_srm_launcher_hardpoint_base.png",
   "hardpointOffsets":[15, -4, 15, -2, 15, 2, 15, 4],
   "turretOffsets":[10, -4, 10, -2, 10, 2, 10, 4],
   #"hardpointAngleOffsets":[-20, -10, 10, 20],
   #"turretAngleOffsets":[-20, -10, 10, 20],
   "hardpointAngleOffsets":[0, 0, 0, 0],
   "turretAngleOffsets":[0, 0, 0, 0],
   "barrelMode":"ALTERNATING",
   "animationType":"SMOKE",
   "interruptibleBurst":false,
   "displayArcRadius":500,
   "smokeSpec":{"particleSizeMin":10.0,
             "particleSizeRange":16.0,
             "cloudParticleCount":3,
             "cloudDuration":0.9,
             "cloudRadius":8.0,
             "blowbackParticleCount":4,
             "blowbackDuration":1.1,
             "blowbackLength":20.0,
             "blowbackSpread":10.0,
             "particleColor":[170,160,150,130]},
   "projectileSpecId":"jumperdrones",
   "fireSoundTwo":"swarmer_fire",
}
[close]

And the proj file

Spoiler
{
   "id":"jumperdrones",
   "specClass":"missile",   
   "missileType":"MISSILE",
   "sprite":"graphics/missiles/missile_SRM.png",
   "size":[3,7],   
   "center":[3,7],
   "collisionRadius":5,
   "collisionClass":"MISSILE_NO_FF",
   "explosionColor":[255,165,50,255],  # purely visual, will get a white additively blended core on top of this color
   "explosionRadius":60, # purely visual
   "fadeTime":1, # fadeout duration
   "engineSpec":{"turnAcc":1720,
              "turnRate":240,
              "acc":2500,
              "dec":800},
   #"engineSpec":{"turnAcc":240,
   #           "turnRate":120,
   #           "acc":400,
   #           "dec":400},             
   "engineSlots":[{"id":"ES1",
               "loc":[-7, 0],
                #"style":"MISSILE_MIDLINE",
                "style":"CUSTOM",
               "styleSpec":{
                  "mode":"QUAD_STRIP", # PARTICLES or QUAD_STRIP, determines which params are used
                  "engineColor":[255,145,75,255],
                  "contrailDuration":.5,
                  "contrailWidthMult":2,
                  "contrailWidthAddedFractionAtEnd":2,  # can be negative. makes trail spread out/narrow at the end
                  "contrailMinSeg":15, # min segment length, in pixels
                  "contrailMaxSpeedMult":.0f,
                  "contrailAngularVelocityMult":0.5f,
                  "contrailSpawnDistMult":.5, # how far away from engine it starts
                  "contrailColor":[100,100,100,150],
                  "type":"SMOKE" # GLOW or SMOKE; additive or regular blend mode
               },
                "width":2.0,
                "length":10.0,
                "angle":180.0}]
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 22, 2016, 07:09:00 AM
This looks like an error with weapon_data.csv, actually. Looks like a "50" snuck into the hints column.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 22, 2016, 07:25:39 AM
Ah right, This is the weapon csv data. I think I only got round to changing the name so it recognized the other files.
Spoiler
Puddle Jumper Drone Launcher,jumperdrones,1,250,1000,,175,,5,0,4,,6,0.25,HIGH_EXPLOSIVE,0,,0,4,2,0.2,0,0,0,0,,300,100,5,50,"ANTI_FTR, DO_NOT_AIM, SYSTEM,DO_NOT_CONSERVE",10
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on July 22, 2016, 03:03:00 PM
Ships in my mod are very "Cowardly." They attack at maximum weapon range, and miss a lot because of that. Is there a way to make them come closer to enemies before shooting and not running away?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 22, 2016, 08:08:43 PM
I have a question that how to get the FleetMemberAPI when a ship get captured?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on July 23, 2016, 03:08:40 AM
Hi! How to deal with suicidal ship behavior? I created a frigate with a long-range missile weapon (range=3500,DO_NOT_AIM,DO_NOT_CONSERVE) and a burst pd laser, and it always tries to fight at close range and dies. Why?! How to force it to kite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 23, 2016, 04:05:15 AM
Hi! How to deal with suicidal ship behavior? I created a frigate with a long-range missile weapon (range=3500,DO_NOT_AIM,DO_NOT_CONSERVE) and a burst pd laser, and it always tries to fight at close range and dies. Why?! How to force it to kite?
You need at least one non-missile non-PD weapon for the AI to correctly estimate the range of engagement. So a Tactical Laser maybe? Or a civilian flag.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: celestis on July 23, 2016, 04:39:55 AM
Hi! How to deal with suicidal ship behavior? I created a frigate with a long-range missile weapon (range=3500,DO_NOT_AIM,DO_NOT_CONSERVE) and a burst pd laser, and it always tries to fight at close range and dies. Why?! How to force it to kite?
You need at least one non-missile non-PD weapon for the AI to correctly estimate the range of engagement. So a Tactical Laser maybe? Or a civilian flag.
Thanks a lot, I'll try to add laser! How weird...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 23, 2016, 08:17:32 AM
Ships in my mod are very "Cowardly." They attack at maximum weapon range, and miss a lot because of that. Is there a way to make them come closer to enemies before shooting and not running away?

Do they behave like civilian ships, or do they actually try to fight, but just prefer extreme range? If it's the latter, that's not going to be easy to work around, since it's in most cases good behavior. About the only thing that comes to mind is experimenting with aggressive officers to see if that makes a difference, and possibly adding in a single low-range weapon.


I have a question that how to get the FleetMemberAPI when a ship get captured?

I'm not sure exactly what you're asking, could you be more specific about the context this is in?

If you're asking to be *notified* when a ship gets captured, there's no way other than providing an alternate implementation of the FleetInteractionDialogPluginImpl.



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 23, 2016, 05:22:34 PM
I have a question that how to get the FleetMemberAPI when a ship get captured?

I'm not sure exactly what you're asking, could you be more specific about the context this is in?

If you're asking to be *notified* when a ship gets captured, there's no way other than providing an alternate implementation of the FleetInteractionDialogPluginImpl.

Hmm, if a ship get captured, will it appear in reportBattleFinished's primary winner?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 23, 2016, 05:38:42 PM
I think it will, yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on July 23, 2016, 09:21:18 PM
I got a few questions, may sound a bit silly, so bear with me.

Q1: How do I force the phase cloak system to have a delay at the end of its phase cloak deactivation?

I've messed around with the Citadel's phase cruiser (permission asked and granted), and managed to get it to phase through things properly instead of crashing into stuff.

The only problem was that the delay is missing.

Q2: What are the significant difference in compiled and non-compiled mods?

I couldn't quite grasp the difference, aside from that the compiled mods all have the jars folder (and some src folder outside their jars).

Q3: For the starfarer.api JAR and compressed file alongside the lwjgl and lwjgl_util JAR files, do I just copy them over to the jars file in a compressed mod?

I did that with the Citadel files.

Thanks for listening.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 24, 2016, 08:55:31 AM
Q1: How do I force the phase cloak system to have a delay at the end of its phase cloak deactivation?

I've messed around with the Citadel's phase cruiser (permission asked and granted), and managed to get it to phase through things properly instead of crashing into stuff.

The only problem was that the delay is missing.

You mean the cooldown after it turns off? That's specified in the "cooldown" column in ship_systems.csv. The vanilla one has a cooldown of 2 seconds.

Q2: What are the significant difference in compiled and non-compiled mods?

I couldn't quite grasp the difference, aside from that the compiled mods all have the jars folder (and some src folder outside their jars).

Java code needs to be compiled into a form that the java virtual machine (the JVM, i.e. what actually runs the game) can run. The game comes with a third party compiler, Janino, which does this to code provided under data/scripts. However, it's got some issues - it's not aware of certain Java features like generics, and it's been known to fail to compile certain other pieces of code. It also takes time on game start, as it has to do this every time.

The benefit of that is that it's easier to mod, since you can just edit the script and the game does everything else for you, no need to set up a dev environment.

Compiled mods provide the compiled version of their code in a jar file (Java ARchive). You can actually open it upwith winzip or some such and see a bunch of .class files there; .class files are compiled versions of corresponding .java files. So, this means the modder has to compile their code into this form outside the game; I'd imagine mostly one would automate this using an IDE.

The benefits of doing it this way are faster startup time, being able to use all Java language features, and, well, using an IDE (Interactive Dev Environment), though you could also do the latter w/ the loose scripts in data/scripts.


Q3: For the starfarer.api JAR and compressed file alongside the lwjgl and lwjgl_util JAR files, do I just copy them over to the jars file in a compressed mod?

I did that with the Citadel files.

You don't need to do that, the game already comes with those so there's no point to duplicating them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on July 25, 2016, 03:03:14 AM
just wondering what would I have to edit to make it so missiles aren't rendered in the launcher?
And how can i make a weapon not a pd weapon, I modified a pdlaser and have now replaced it with a modified phase beam but its still acting as a pd laser. thanks in advance

and i figured out why I couldnt get some weapons to work. When I moved the mod to the 0.7.2a folder and it worked I didnt think i needed to change anything. BUT the weapons csv files are slightly different at the top for anyone wanting to do a mod.
Heres an example
Spoiler
name,id,tier,base value,range,damage/second,damage/shot,emp,impact,turn rate,OPs,ammo,ammo/sec,reload size,type,energy/shot,energy/second,chargeup,chargedown,burst size,burst delay,min spread,max spread,spread/shot,spread decay/sec,beam speed,proj speed,launch speed,flight time,proj hitpoints,hints,number
name,id,tier,base value,range,damage/second,damage/shot,emp,impact,turn rate,OPs,ammo,ammo/sec,type,energy/shot,energy/second,chargeup,chargedown,burst size,burst delay,min spread,max spread,spread/shot,spread decay/sec,beam speed,proj speed,launch speed,flight time,proj hitpoints,hints,number

the top line is the 0.72a csv file and the bottom is 0.65a i think.
The 0.72a updata added reload size as a option too.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on July 26, 2016, 02:28:36 AM

You mean the cooldown after it turns off? That's specified in the "cooldown" column in ship_systems.csv. The vanilla one has a cooldown of 2 seconds.


Java code needs to be compiled into a form that the java virtual machine (the JVM, i.e. what actually runs the game) can run. The game comes with a third party compiler, Janino, which does this to code provided under data/scripts. However, it's got some issues - it's not aware of certain Java features like generics, and it's been known to fail to compile certain other pieces of code. It also takes time on game start, as it has to do this every time.

The benefit of that is that it's easier to mod, since you can just edit the script and the game does everything else for you, no need to set up a dev environment.

Compiled mods provide the compiled version of their code in a jar file (Java ARchive). You can actually open it upwith winzip or some such and see a bunch of .class files there; .class files are compiled versions of corresponding .java files. So, this means the modder has to compile their code into this form outside the game; I'd imagine mostly one would automate this using an IDE.

The benefits of doing it this way are faster startup time, being able to use all Java language features, and, well, using an IDE (Interactive Dev Environment), though you could also do the latter w/ the loose scripts in data/scripts.


You don't need to do that, the game already comes with those so there's no point to duplicating them.

Thanks for the detailed reply! I've checked the version and differences of the files' formatting, updating to the current scheme solved the phase problem. Now that Citadel phase cruiser can fly! (Albeit it keeps phase teleporting suicide in conjunction with phase cloaking... back to the drawing board!).

I see, I'll have to read the instructions carefully and find some tutorials for the IDE (NetBeans) I'm using.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Paralityk on July 28, 2016, 02:00:47 AM
How do I edit skills? For example I want Construction to give me 3% armor bonus instead of 2%. File I want to edit is:
\data\characters\skills\scripts\SkillDate
Right? I even checked all mods one by one and altered every single one that was messing with skills but values in game remains the same. Even after starting new game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Paralityk on July 29, 2016, 03:17:58 AM
Bumping my question. Still couldn't find solution on my own. Anyone?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 29, 2016, 08:49:03 AM
just wondering what would I have to edit to make it so missiles aren't rendered in the launcher?
And how can i make a weapon not a pd weapon, I modified a pdlaser and have now replaced it with a modified phase beam but its still

Remove "RENDER_LOADED_MISSILES" from the .wpn file.


How do I edit skills? For example I want Construction to give me 3% armor bonus instead of 2%. File I want to edit is:
\data\characters\skills\scripts\SkillDate
Right? I even checked all mods one by one and altered every single one that was messing with skills but values in game remains the same. Even after starting new game.

Have you tried running without any mods, just to be on the safe side and make sure nothing else is interfering? What you're doing sounds like it should work, unless I'm just missing something here.

Another way to check would be to add some gibberish to the SkillData.java file and make sure that causes the game to crash on startup. But I'd still recommend running w/o any mods to isolate what's going on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on July 29, 2016, 07:25:48 PM
Is there an up-to-date reference for how burst beams are timed/handled by the AI? Even just a thread* about how the chargeup/chargedown/burst timings change for beams would be nice; I feel like I end up doing burst-beam stats by trial and error a lot.

One thing I've noticed about burst beams as offensive weapons; the higher the damage over a shorter time, the better a beam is against shields, in part because the AI seems to drop shields more often when it's fired at a ship.

*happy to start one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 30, 2016, 12:50:22 AM
Is there any possibility to render characters like "WARNING" using default font in campaign or combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2016, 08:04:36 AM
Is there an up-to-date reference for how burst beams are timed/handled by the AI? Even just a thread* about how the chargeup/chargedown/burst timings change for beams would be nice; I feel like I end up doing burst-beam stats by trial and error a lot.

One thing I've noticed about burst beams as offensive weapons; the higher the damage over a shorter time, the better a beam is against shields, in part because the AI seems to drop shields more often when it's fired at a ship.

*happy to start one.

I'm not entirely sure what you're asking. Just, "how does the AI handle burst beams defensively"? If so, the answer is "not particularly well". Unlike for projectiles, where it's aware of individual high-damage shots, it doesn't treat burst beams any differently from regular beams with a high DPS.

Is there any possibility to render characters like "WARNING" using default font in campaign or combat?

Not at the moment, no. I keep meaning to add a text rendering API, but just haven't been able to as of yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on July 30, 2016, 07:26:04 PM
Is there an up-to-date reference for how burst beams are timed/handled by the AI? Even just a thread* about how the chargeup/chargedown/burst timings change for beams would be nice; I feel like I end up doing burst-beam stats by trial and error a lot.

One thing I've noticed about burst beams as offensive weapons; the higher the damage over a shorter time, the better a beam is against shields, in part because the AI seems to drop shields more often when it's fired at a ship.

*happy to start one.

I'm not entirely sure what you're asking. Just, "how does the AI handle burst beams defensively"? If so, the answer is "not particularly well". Unlike for projectiles, where it's aware of individual high-damage shots, it doesn't treat burst beams any differently from regular beams with a high DPS.

It's really how the .csv file's values affect the duration of the burst; I can plug the numbers for projectile weapons into a simple formula and get numbers that yield a desired DPS. I still haven't figured out how to set precise values for burst beams except by trial and error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2016, 09:05:29 PM
It's really how the .csv file's values affect the duration of the burst; I can plug the numbers for projectile weapons into a simple formula and get numbers that yield a desired DPS. I still haven't figured out how to set precise values for burst beams except by trial and error.

The code that figures out dps for burst beams:

Code: java
info.burstFireDuration = ((spec.getChargeupTime() + spec.getChargedownTime()) + spec.getBurstDuration());
info.burstDamage = spec.getDamagePerSecond() * ((chargeUpTime + spec.getChargedownTime()) * 0.333f + spec.getBurstDuration());
info.dps = info.burstDamage / (spec.getChargeupTime() + spec.getChargedownTime() + spec.getBurstDuration() + spec.getBurstCooldown());

0.333f is in there because beam damage ramps up as a square of the brightness. If it was linear, that would've been an 0.5f instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on July 30, 2016, 10:05:33 PM
It's really how the .csv file's values affect the duration of the burst; I can plug the numbers for projectile weapons into a simple formula and get numbers that yield a desired DPS. I still haven't figured out how to set precise values for burst beams except by trial and error.

The code that figures out dps for burst beams:

Code: java
info.burstFireDuration = ((spec.getChargeupTime() + spec.getChargedownTime()) + spec.getBurstDuration());
info.burstDamage = spec.getDamagePerSecond() * ((chargeUpTime + spec.getChargedownTime()) * 0.333f + spec.getBurstDuration());
info.dps = info.burstDamage / (spec.getChargeupTime() + spec.getChargedownTime() + spec.getBurstDuration() + spec.getBurstCooldown());

0.333f is in there because beam damage ramps up as a square of the brightness. If it was linear, that would've been an 0.5f instead.

Aaaahhh, no wonder the numbers didn't make sense. Thanks so much - I understand it's a fairly obscure question and I appreciate getting such a concise answer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Paralityk on July 31, 2016, 05:54:18 AM

Have you tried running without any mods, just to be on the safe side and make sure nothing else is interfering? What you're doing sounds like it should work, unless I'm just missing something here.

Another way to check would be to add some gibberish to the SkillData.java file and make sure that causes the game to crash on startup. But I'd still recommend running w/o any mods to isolate what's going on.
Well that's weird... Everything seems to work with starsector+ turned off but ALL values are changed exactly the same way in core and starsector+. Yet when I turn mod on again values are back to default. I checked it so many times that at this poin't I am not sure if game is trolling me or I am going insane :D.
With starsector+ off - skills have changed values
With starsector+ on - skills have default values

But I am 100% sure that I changed both core and starsector+ SkillData exactly the same way to make sure that one is not overwriting another. Can anyone tell me what is going on?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2016, 01:48:30 PM
It's possible SS+ is providing a compiled version of that class in a jar file and that takes precedence.


Aaaahhh, no wonder the numbers didn't make sense. Thanks so much - I understand it's a fairly obscure question and I appreciate getting such a concise answer.

Cool, glad that makes sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Paralityk on August 01, 2016, 07:27:18 AM
Thank you. That was exactly it! Little tampering with .class files and everything works like a charm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Paralityk on August 01, 2016, 05:52:55 PM
Sorry for double post but it's for another question so I hope it's fine.
Where do I change weapon size? It's not specified in weapon_data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 01, 2016, 06:42:06 PM
In the .wpn file under data/weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jamplier on August 04, 2016, 07:46:52 AM
Is there any way to make a ui sound (like Global.getSoundPlayer().playUISound()) loop? I'm currently using intervals (IntervalUtil(float,float)), but it's messy as heck.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 04, 2016, 08:42:14 AM
There's no explicit support for UI loops, but you can get around it by calling the regular playLoop() method and passing in a stereo sound.

As a side note, all stereo sounds play as-is, while mono sounds will be converted into stereo based on their location relative to the listener. So, for example, if one had a stereo sound for say weapon fire or an explosion, that would be bad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jamplier on August 04, 2016, 09:13:07 AM
Ah, that's cool, didn't know that. If I can figure things out, maybe there'll be another mod available out there in a day or two ;)
 Thank you for your help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Grizzlyadamz on August 04, 2016, 06:11:57 PM
Is there a way to change relationship-modifiers?

I feel I shouldn't get a relationship-hit for piracy when my transponder's off, (which would limit me to solo-action 'targets of opportunity'), and I'd rather not have to resort to dev commands every time that happens.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 05, 2016, 08:35:01 AM
Is there a way to change relationship-modifiers?

I feel I shouldn't get a relationship-hit for piracy when my transponder's off, (which would limit me to solo-action 'targets of opportunity'), and I'd rather not have to resort to dev commands every time that happens.

There is, but it requires some Java knowledge. On a high level, you'd want to register a plugin to handle reputation adjustment actions, check to see if the action matches your criteria (i.e. fighting a fleet, transponder off) and then handle the action appropriately.


actually to make my post relevant to the op how moddable is the metagame structure? I don't have a clue how to java but since you're working on the campaign-level game loop now, would it be hard for a modder to mod an rts-style campaign into the game that includes over-world out-of-combat gameplay? I find Homeworld fascinating but always a near-miss because of the way it's a string of pre-ordained missions and lacks over-world in-between to contextualize the combat and I would love to see starsector bridge that gap

That's an awfully general question for this thread. Overall, though, I think the campaign is pretty moddable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Grizzlyadamz on August 05, 2016, 09:46:09 AM
There is, but it requires some Java knowledge. On a high level, you'd want to register a plugin to handle reputation adjustment actions, check to see if the action matches your criteria (i.e. fighting a fleet, transponder off) and then handle the action appropriately.
Shhoot. If I have to start from scratch that's probably a bit out of my depth.

But, if anyone happens to know of a similar mod, I could probably reverse-engineer it..?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Paralityk on August 06, 2016, 12:31:07 PM
I have already asked this question in mod thread but sadly no one knows the answer or my question was simply ignored :(. My problem regards mod ApproLight. Which file do I have to edit to make Originem stay in the station for the whole month not only on 7th?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 07, 2016, 08:10:51 AM
It's probably a case of "no-one knows". Might be worth asking in that mod's thread.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on August 10, 2016, 07:04:03 AM
How do you stop your faction's fleets from flying with their transponder off?

My fleets just fly around with transponders off and have no "leader" ship, and no commanders.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on August 19, 2016, 11:20:32 PM
I've been trying to fix Citadel's star, Blaze; in the Citadel system. It's currently hollow like in previous versions of Starsector, but emits the corona as normal.

Which files do I need to modify or create to make it impassible?

Also, how do I make a planet orbit further from the centre of the star system? Citadel's Gateway is within the corona edges and its really burning up every fleet going to and fro (burn goods, burn!).

Here's the planet's API I think:

//GATEWAY
       
        PlanetAPI gateway = system.addPlanet("gateway", blaze, "Gateway", "arid", 0, 100, 1000, 381);
        gateway.setCustomDescriptionId("citadel_gateway");
        gateway.setFaction("citadeldefenders");

Also, it has an abandoned station orbiting it, do I have to change that as well? Here's its data:

//ABANDONDED STATION
       
        SectorEntityToken neutralStation = system.addOrbitalStation("citadel_abandoned_station", system.getEntityById("Gateway"), 155, 200, 53, "Abandoned Orbital Customs", "neutral");
        neutralStation.getMemory().set("$abandonedStation", true);
        MarketAPI market = Global.getFactory().createMarket("citadel_abandoned_station_market", neutralStation.getName(), 0);
        market.setPrimaryEntity(neutralStation);
        market.setFactionId(neutralStation.getFaction().getId());
        market.addCondition(Conditions.ABANDONED_STATION);
        market.addSubmarket(Submarkets.SUBMARKET_STORAGE);
        ((StoragePlugin) market.getSubmarket(Submarkets.SUBMARKET_STORAGE).getPlugin()).setPlayerPaidToUnlock(true);
        neutralStation.setMarket(market);
        neutralStation.setCustomDescriptionId("citadel_gateway_station");
        neutralStation.setInteractionImage("illustrations", "abandoned_station");

All of the above data is from Citadel.java.

Thanks for listening!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 21, 2016, 05:31:29 AM
What's the meaning of :
"specialWeaponGlowWidth":15,
"specialWeaponGlowHeight":20,   

And, there are how many steps to deal damage? If the damage dealt at a Vector2f, how to calculate all the damage it takes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on August 21, 2016, 05:43:49 AM
I don't get it (mind you, my level of skill with java coding is next to sub-zero):

Spoiler
Code: java
package data.hullmods;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.FleetDataAPI;
import com.fs.starfarer.api.campaign.BuffManagerAPI.Buff;
import com.fs.starfarer.api.combat.HullModEffect;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.MutableStat;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.MutableStat.StatMod;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.fleet.FleetMemberAPI;

public class TowCableMk2 implements HullModEffect {

public static final String HULLMOD_ID = "tow_cable_mk2";

public static class TowCableMk2Buff implements Buff {
//public boolean wasApplied = false;
private String buffId;
private int frames = 0;

public TowCableMk2Buff(String buffId) {
this.buffId = buffId;
}

public boolean isExpired() {
//return wasApplied;
return frames >= 2;
}
public String getId() {
return buffId;
}
public void apply(FleetMemberAPI member) {
// this ensures the buff lasts for exactly one frame unless wasApplied is reset (as it is later)
//wasApplied = true;
member.getStats().getMaxBurnLevel().modifyFlat(buffId, 20);
}
public void advance(float days) {
frames++;
}
};


public TowCableMk2() {

}

public void advanceInCampaign(FleetMemberAPI member, float amount) {
if (member.getFleetData() == null) return;

if (!member.getVariant().getHullMods().contains(HULLMOD_ID)) {
cleanUpTowCableMk2BuffBy(member);
return;
}

if (!member.canBeDeployedForCombat()) {
cleanUpTowCableMk2BuffBy(member);
return;
}

FleetDataAPI data = member.getFleetData();
List<FleetMemberAPI> all = data.getMembersListCopy();

int numCables = 0;
int thisCableIndex = -1;
for (FleetMemberAPI curr : all) {
if (!curr.canBeDeployedForCombat()) continue;
if (curr.getVariant().getHullMods().contains(HULLMOD_ID)) {
if (curr == member) {
thisCableIndex = numCables;
}
numCables++;
}
}
if (numCables <= 0 || thisCableIndex == -1) {
cleanUpTowCableMk2BuffBy(member);
return;
}

TowCableMk2Buff buff = getTowCableMk2BuffBy(member, true);
Map<FleetMemberAPI, Integer> cables = new HashMap<FleetMemberAPI, Integer>();
float towSpeed = member.getStats().getMaxBurnLevel().getModifiedValue();
FleetMemberAPI thisCableTarget = null;

for (int cableIndex = 0; cableIndex < numCables; cableIndex++) {
FleetMemberAPI slowest = getSlowest(all, towSpeed, cables);
if (slowest == null) break;
//slowest.getStats().getMaxBurnLevel().getModifiedValue()
Integer bonus = cables.get(slowest);
if (bonus == null) bonus = new Integer(0);
bonus++;
cables.put(slowest, bonus);

if (cableIndex == thisCableIndex) {
thisCableTarget = slowest;
Buff existing = slowest.getBuffManager().getBuff(buff.getId());
if (existing == buff) {
// make sure it's using the same buff rather than reapplying it,
// which would trigger a full stat recompute for the entire FLEET every frame
//buff.wasApplied = false;
buff.frames = 0;
//System.out.println("renewed on " + slowest);
} else {
//buff.wasApplied = false;
buff.frames = 0;
slowest.getBuffManager().addBuff(buff);
//System.out.println("Num: " + slowest.getBuffManager().getBuffs().size());
//System.out.println("added to " + slowest);
}
break;
}
}

for (FleetMemberAPI curr : all) {
if (curr != thisCableTarget) {
curr.getBuffManager().removeBuff(buff.getId());
}
}
}

private FleetMemberAPI getSlowest(List<FleetMemberAPI> all, float speedCutoff, Map<FleetMemberAPI, Integer> cables) {
FleetMemberAPI slowest = null;
float minLevel = Float.MAX_VALUE;
for (FleetMemberAPI curr : all) {
if (!isSuitable(curr)) continue;

float baseBurn = getMaxBurnWithoutCables(curr);
Integer bonus = cables.get(curr);
if (bonus == null) bonus = new Integer(0);

if (bonus >= getMaxCablesFor(curr)) continue;

float burnLevel = baseBurn + bonus;

if (burnLevel >= speedCutoff) continue;

if (burnLevel < minLevel) {
minLevel = burnLevel;
slowest = curr;
}
}
return slowest;
}

private int getMaxCablesFor(FleetMemberAPI member) {
// switch (member.getHullSpec().getHullSize()) {
// case CAPITAL_SHIP: return 4;
// case CRUISER: return 3;
// case DESTROYER: return 2;
// case FRIGATE: return 1;
// }
return 1;
}

private float getMaxBurnWithoutCables(FleetMemberAPI member) {
MutableStat burn = member.getStats().getMaxBurnLevel();
float val = burn.getModifiedValue();
float sub = 0;
for (StatMod mod : burn.getFlatMods().values()) {
if (mod.getSource().startsWith(HULLMOD_ID)) sub++;
}
return Math.max(0, val - sub);
}

private boolean isSuitable(FleetMemberAPI member) {
if (member.isFighterWing()) return false;
return true;
}

private void cleanUpTowCableMk2BuffBy(FleetMemberAPI member) {
if (member.getFleetData() == null) return;
FleetDataAPI data = member.getFleetData();
TowCableMk2Buff buff = getTowCableMk2BuffBy(member, false);
if (buff != null) {
for (FleetMemberAPI curr : data.getMembersListCopy()) {
curr.getBuffManager().removeBuff(buff.getId());
}
}
}

/**
* One instance of the buff object per ship with a Tow Cable.
*/
public static final String TOW_CABLE_MK2_KEY = "TowCableMk2_PersistentBuffs";

@SuppressWarnings("unchecked")
private TowCableMk2Buff getTowCableMk2BuffBy(FleetMemberAPI member, boolean createIfMissing) {
Map<FleetMemberAPI, TowCableMk2Buff> buffs;
if (Global.getSector().getPersistentData().containsKey(TOW_CABLE_KEY)) {
buffs = (Map<FleetMemberAPI, TowCableMk2Buff>) Global.getSector().getPersistentData().get(TOW_CABLE_MK2_KEY);
} else {
buffs = new HashMap<FleetMemberAPI, TowCableMk2Buff>();
Global.getSector().getPersistentData().put(TOW_CABLE_KEY, buffs);
}

//new HashMap<FleetMemberAPI, TowCableMk2Buff>();
TowCableMk2Buff buff = buffs.get(member);
if (buff == null && createIfMissing) {
String id = HULLMOD_ID + "_" + member.getId();
buff = new TowCableMk2Buff(id);
buffs.put(member, buff);
}
return buff;
}


public void advanceInCombat(ShipAPI ship, float amount) {
}

public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
}
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
}
public boolean isApplicableToShip(ShipAPI ship) {
return true;
}

public String getDescriptionParam(int index, HullSize hullSize) {
return null;
}

}
[close]

I just need the gorram super (and separate) version of the tow cable and I will only get errors and a nervous breakdown if I were to strain myself with it since I suck at java and recently already went through a massive nervous breakdown and I prefer (for my own mental well-being) that somebody please help me to iron it out so it doesn't crash or something. I need that kryptonian tow cable!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2016, 09:28:06 AM
@Mr. K:

  PlanetAPI gateway = system.addPlanet("gateway", blaze, "Gateway", "arid", 0, 100, 1000, 381);

Bolded parameter is the orbit radius; change that. No need to change the station if it's orbiting the planet, it'll be moved along with it.

To make the corona impassable (if that's what you're asking?) - increasing the solar wind should do the job. Something like 30 or so (since it's in "burn levels" would make sure any normal fleet can't get through it.


What's the meaning of :
"specialWeaponGlowWidth":15,
"specialWeaponGlowHeight":20,   

This is the size of the glow from stuff like the ammo feeder and the high energy focus. There are default values based on the ship sprite, but sometimes their size doesn't look right and these "special" values let you override that.

And, there are how many steps to deal damage? If the damage dealt at a Vector2f, how to calculate all the damage it takes?

That's hard to answer. Many? :) Too many to list here and have any hope for an exact calculation being correct.

I just need the gorram super (and separate) version of the tow cable and I will only get errors and a nervous breakdown if I were to strain myself with it since I suck at java and recently already went through a massive nervous breakdown and I prefer (for my own mental well-being) that somebody please help me to iron it out so it doesn't crash or something. I need that kryptonian tow cable!

Edited the code in your post so it formats nicely (=java after the "code" tag). The TowCable script is probably one of the trickier ones, so I'd be wary of messing with it. Chances of producing something that works but tanks performance are fairly high.

Also, kind of important: you didn't actually say what you want it to do; there's no question here :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on August 21, 2016, 02:47:35 PM
Edited the code in your post so it formats nicely (=java after the "code" tag). The TowCable script is probably one of the trickier ones, so I'd be wary of messing with it. Chances of producing something that works but tanks performance are fairly high.

Also, kind of important: you didn't actually say what you want it to do; there's no question here :)

I still don't understand it. If I were to right now think harder about it I'd just strain myself.

In my current state, all I can think of is where to even specify the burn level 1 of the regular tow cable to burn level 20+ for my super ships (its annoying when it slows down to a crawl when hauling another ship in the fleet).

This talk of lag and trying to understand coding right now is enough for me to just omit all non-fast ships and blowing them up instead or just making separate entries of them if I like a ship enough but can't make it go faster in the fleet by default. Also thinking of removing the tow cable from the two main modded ships since its +1 burn level for other ships is useless for me. Doesn't give me what my max burn playstyle needs but its just me feeling like crap.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on August 22, 2016, 02:21:07 AM
@Mr. K:

  PlanetAPI gateway = system.addPlanet("gateway", blaze, "Gateway", "arid", 0, 100, 1000, 381);

Bolded parameter is the orbit radius; change that. No need to change the station if it's orbiting the planet, it'll be moved along with it.

To make the corona impassable (if that's what you're asking?) - increasing the solar wind should do the job. Something like 30 or so (since it's in "burn levels" would make sure any normal fleet can't get through it.


Thanks!

I'm not sure which stats I need to modify for the star though. Just in case, here's the system's and star API:

//MAIN SYSTEM AND STAR
       
        StarSystemAPI system = sector.createStarSystem("Citadel");
        system.getLocation().set(-10000, 3000);
        system.setBackgroundTextureFilename("graphics/backgrounds/background2.jpg");

        PlanetAPI blaze = system.initStar("blaze", "star_blue", 250f, 1000f, 4f, 0.5f, 1.0f);
                                 
        blaze.setCustomDescriptionId("citadel_blaze");

What I meant by the star being passable was that I could fly my fleet straight over it. There was no push from the star.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 22, 2016, 07:50:11 AM
        PlanetAPI blaze = system.initStar("blaze", "star_blue", 250f, 1000f, 4f, 0.5f, 1.0f);

Bolded the solar wind number. It's low, that's probably why you're not feeling much pushback.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on August 22, 2016, 09:40:42 AM
       PlanetAPI blaze = system.initStar("blaze", "star_blue", 250f, 1000f, 4f, 0.5f, 1.0f);

Bolded the solar wind number. It's low, that's probably why you're not feeling much pushback.

Ok, configured the changes. But they don't work after I've restarted.

After trying that, I did some digging through some other mods files. They have a far different set-ups, so maybe I'll have to adjust accordingly.

If any, which mod would a good example of stellar bodies arrangements? Or would it best just to refer to the core files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c plus one on August 31, 2016, 12:11:23 AM
Hello!
This thread seems to me that it's the best place to post a request for HELP with fixing a (somewhat?) basic modding mistake. If this isn't the best place to ask for aid, I apologize.


*Chronology*

The Sf-Edit ship editor program is great way to add, remove, alter, relocate, etc. weapon slots on ships. I made several slot changes to the Venture cruiser, and am cautiously optimistic with the result. I've used Sf-Edit dozens of times to make conceptually simple changes to ships, and it's never let me down yet. ;D

I then made multiple, manually-typed performance tweaks (installed refits, altered the slot contents, reorganized the weapon groups) to venture_Balanced.variant .

After slowly checking my code syntax, I saved the file and went to open the game and review my changes from inside the game's Refit Screen.

But before I even got to the main menu, boom! Crash to desktop!  :o


*The most relevant quote from starsector.log* :
Code
10679 [Thread-4] INFO  com.fs.starfarer.loading.SpecStore  - Loading variant [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\data\variants\venture\venture_Balanced.variant]
10679 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\data\variants\venture\venture_Balanced.variant]
10684 [Thread-4] INFO  com.fs.profiler.Profiler  - ID     Calls   Duration    Percent
10684 [Thread-4] INFO  com.fs.profiler.Profiler  - --------------------------------
10685 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: Expected a ':' after a key at 462 [character 10 line 21]
org.json.JSONException: Expected a ':' after a key at 462 [character 10 line 21]
at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
at org.json.JSONObject.<init>(JSONObject.java:208)
at org.json.JSONTokener.nextValue(JSONTokener.java:352)
at org.json.JSONArray.<init>(JSONArray.java:125)
at org.json.JSONTokener.nextValue(JSONTokener.java:356)
at org.json.JSONObject.<init>(JSONObject.java:210)
at org.json.JSONObject.<init>(JSONObject.java:311)
at com.fs.starfarer.loading.LoadingUtils.????00(Unknown Source)
at com.fs.starfarer.loading.LoadingUtils.?0000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.????00(Unknown Source)
at com.fs.starfarer.loading.SpecStore.????00(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


*Why this error code is such a problem for me* :

1) I have no idea what com.fs.starfarer.combat.CombatMain is & why it's important, nor what an org.json.JSONException is & why it's important. What these have to do with making very simple changes to installed refits & contents of weapon slots in a single ship variant file is completely opaque to me.

2) My text-editor (Notepad++; it's awesomely useful) shows absolutely nothing amiss inside of venture_Balanced.variant at character 10 line 21! I don't know why Starsector thinks I needed a colon typed there, or anywhere in that neighborhood.

Would someone kindly point out what I did wrong, why the game can't deal with it, and how I can fix the error? I would be grateful.
:)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on August 31, 2016, 06:56:53 AM
You'll need to post your modified venture_Balanced.variant.

Quote
1) I have no idea what com.fs.starfarer.combat.CombatMain is & why it's important, nor what an org.json.JSONException is & why it's important. What these have to do with making very simple changes to installed refits & contents of weapon slots in a single ship variant file is completely opaque to me.

com.fs.starfarer.combat.CombatMain is the class in which the exception is occurring.
org.json.JSONException is the class of the exception being thrown.

In the context of fixing your problem, neither is relevant; all that's important to you is:
Code
Loading JSON from [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\data\variants\venture\venture_Balanced.variant]
and
Code
Expected a ':' after a key at 462 [character 10 line 21]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c plus one on August 31, 2016, 02:13:08 PM
You'll need to post your modified venture_Balanced.variant.

Quote
1) I have no idea what com.fs.starfarer.combat.CombatMain is & why it's important, nor what an org.json.JSONException is & why it's important. What these have to do with making very simple changes to installed refits & contents of weapon slots in a single ship variant file is completely opaque to me.

com.fs.starfarer.combat.CombatMain is the class in which the exception is occurring.
org.json.JSONException is the class of the exception being thrown.

I am ignorant of Java, but I thank you for taking the time!  :)


In the context of fixing your problem, neither is relevant; all that's important to you is:
Code
Loading JSON from [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\data\variants\venture\venture_Balanced.variant]
and
Code
Expected a ':' after a key at 462 [character 10 line 21]


As requested, here is my modded iteration of venture_Balanced.variant:
Code
{
    "displayName": "Balanced",
    "fluxCapacitors": 20,
    "fluxVents": 20,
    "hullId": "venture",
    "hullMods": [
"targetingunit",
"stabilizedshieldemitter"
],
    "quality": 0.5,
    "variantId": "venture_Balanced",
    "weaponGroups": [
        {
{
            "autofire": false,
            "mode": "ALTERNATING",
            "weapons": {
                "WS 004": "sabot",
                "WS 007": "sabot"
            }
        },
            "autofire": false,
            "mode": "ALTERNATING",
            "weapons": {
                "WS 005": "harpoonpod",
                "WS 006": "harpoonpod"
            }
        },
{
            "autofire": false,
            "mode": "LINKED",
            "weapons": {
"WS 002": "miningblaster"
}
        },
        {
            "autofire": true,
            "mode": "ALTERNATING",
            "weapons": {
                "WS0003": "lightdualac",
                "WS0004": "lightdualac",
"WS0005": "chaingun",
                "WS0006": "chaingun",
"WS0009": "lightmortar",
                "WS0010": "lightmortar"
            }
        },
        {
            "autofire": true,
            "mode": "LINKED",
            "weapons": {
                "WS 001": "flak",
                "WS 003": "flak",
"WS0001": "mininglaser",
"WS0002": "mininglaser",
"WS0011": "taclaser",
"WS0012": "lightmg",
"WS0013": "lightmg"
            }
        }
    ]
}

I can only assume that code-wise there's something wrong with my syntax, but I cannot identify what. Any ideas what it might be?

For example, I see here that the <code> feature of this forum software causes a ton of extra indents that do not exist in the Notepad++-viewed original of my .variant file; that version is far neater with its whitespace. What I put into <code> above is literally no more than a direct Select All/Copy/Paste from there to here.  ???  I've made NO formatting changes in the Preferences of Notepad++, relative to all of the other modded *.ship and *.variant files that Starsector accurately loads error-free.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FlashFrozen on August 31, 2016, 03:59:25 PM
You've modified the venture variant, with what i'm assuming is either notepad or something

It still seems to retain the original weapon groups and weaponslots so it's conflicting and most likely giving you the errors.

The venture has 7 weapon slots, you have 3 weapon groups of mixed and matched slots sizes and type with 8 different weapons.

8 weapons in 7 slots?
Probably best to redo the modded variant, you are already over op but that's fine, but you'll need to correct the weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on August 31, 2016, 06:28:57 PM
Greetings,

After happening upon dmaiski's "armor regeneration" weapon plugin script (http://fractalsoftworks.com/forum/index.php?topic=6452.msg131192#msg131192) from the Radioactive Code Dump, I've managed to link it to a custom invisible weapon that can be mounted on a ship's hardpoint.

The thing is, I now want the script to run if (and only if) the weapon group to which the player has assigned the invisible regen weapon, has toggled that group's autofire to on. This way, the player can simply press Ctrl+(#) to activate/deactivate the armor regeneration during combat, as well as granting them finer control over the hard flux build-up that is in place to balance its usage.

Currently in the public void advance(float v, CombatEngineAPI engineAPI, WeaponAPI weaponAPI) that contains the looping regen code, there is an if conditional that checks if the game is paused or if the weapon is disabled, then simply returns nothing to prevent armor regeneration:

Code
if (engine.isPaused() || weaponAPI.isDisabled())
{
    return;
}

I wish to expand this conditional by adding another OR check to see if the boolean isAutoFiring() is equal to false, but that boolean belongs to WeaponGroupAPI rather than WeaponAPI, and I couldn't find any methods inside WeaponAPI that allows me to look up the current weapon group that the script-attached weapon belongs to.

Something tells me the solution is ridiculously simple, but given how bad I am at Java OOP in general, I'm probably not even seeing it. Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on August 31, 2016, 07:09:31 PM
Never mind, that was hasty of me.

Turns out that ShipAPI has the method WeaponGroupAPI getWeaponGroupFor(WeaponAPI weapon), which returns the weapon group for whatever weapon argument is fed into the WeaponAPI weapon parameter.

Code
ShipAPI ship;
ship=weaponAPI.getShip();

if (engine.isPaused() || weaponAPI.isDisabled() || !( ship.getWeaponGroupFor(weaponAPI).isAutofiring() ) )
{
    return;
}

With this boolean check in place, I now have a working AutoFire toggle for armor regeneration! Now to start balancing the hard flux costs for multiple copies of the module across different hull sizes (ugh)...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on August 31, 2016, 10:18:42 PM
Is it possible to do animated commodity images?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on September 01, 2016, 05:20:49 AM
I can only assume that code-wise there's something wrong with my syntax, but I cannot identify what. Any ideas what it might be?

Line 13, you've got an extraneous opening brace.

I suggest you use a proper json editor; it'll make errors like this obvious.
(Eclipse json editor screenshot)
(https://dl.dropboxusercontent.com/u/54785909/starfarer/syntaxerror.png)

Also, unless you've made some significant changes to the venture.ship hull, you're using a lot of invalid weapon slot Ids.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on September 01, 2016, 03:19:50 PM
Hello again,

A few weird issues have sprung up, and I was hoping if anyone could shed some light on them.



Firstly, that armor regeneration "weapon" script I was working on a few posts back? I've been making use of the void maintainStatusForPlayerShip(Object key, String spriteName, String title, String data, boolean isDebuff) method from engineAPI to display the current armor percentage, in a fashion similar to those buff/debuff indicators in the bottom left widget of the combat interface.

Code
private String AAG_SPRITE = "Sprite Path Goes Here";

...
...

if (player)
{
    if ( (int)currArmorPercentage < 100 )
    {
        engine.maintainStatusForPlayerShip(STATUSKEY_REPAIR_PERCENT, AAG_SPRITE, weaponAPI.getDisplayName(), "armor integrity: " + String.format("%.2f", currArmorPercentage) + "%", true);
    } else {
        engine.maintainStatusForPlayerShip(STATUSKEY_REPAIR_PERCENT, AAG_SPRITE, weaponAPI.getDisplayName(), "armor integrity: " + String.format("%.2f", currArmorPercentage) + "%", false);
    }
}

...
...

While the indicators are showing up fine in-game, the green mono-colored icon to the left sometimes doesn't show up at all, depending on what I put into private String AAG_SPRITE, which in turn, is passed onto the String spriteName parameter.

For instance, in my mod's folder, I have a graphics/icons/hullsys/advanced_phase_cloak.png (which is really just a copy/paste of the vanilla phase_cloak.png). When I feed that as the path string, it shows up fine (albeit with some weird random artifacts at times, probably an engine issue).

But for some reason, that appears to be the only icon that works properly. If I, say, copy the damper_field.png icon from vanilla and paste it into my mod folder as ablative_armor_generator.png, using graphics/icons/hullsys/ablative_armor_generator.png as the path string results in a blank icon instead.

Other than making file renames, I haven't touched the icons' pixels themselves with any image editors, and I've also made sure that there are no multiple copies in both the vanilla core folders and my own mod folder... yet there is no way for me to reliably predict whether an icon will work or not.

Might this have anything to do with the way the game engine looks up the icon path? Do I need to include the parent directory (i.e. the name of my mod) in the path name as well, to explicitly separate it from the vanilla path?



The second one is much more minor: a custom ship I am working on (in the same mod folder) has its own entry in a new ship_data.csv, where it is listed as Phase Frigate under the designation column. Since that's two words, however, when in-game and entering a custom variant name in the Refit screen, the game engine has a nasty habit of separating those two words and shoving the variant input field in the middle, like Phase [Enter Variant Name] Frigate.

Most ships in vanilla only use one word for their designation, and they simply end up like [Enter Variant Name] Frigate. I've even seen the Hound, which is designated as a Combat Freighter, show up in game as [Enter Variant Name] Combat Freighter.

Is the game engine hardcoded to make an exception for ships with the word "Phase" in their designations? Is there some way to work around it, or should I just use another word other than "Phase" instead?


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on September 02, 2016, 10:43:29 AM
Fleets in my mod RWS (deadly fighters) fly with transponders off.

Fleets do not have "captains".


- How do I make them turn on transponders and have captains?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on September 02, 2016, 05:32:08 PM
I haven't worked with any files pertaining to custom fleet AI directly, but I know that in the API (com.fs.starfarer.api.campaign.ai.FleetAIFlags) there is a WANTS_TRANSPONDER_ON string (found here (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/campaign/ai/FleetAIFlags.html#WANTS_TRANSPONDER_ON)) which you can treat like a boolean. It's not much, but I reckon it's a start.

Setting captains is not strictly related to AI, I don't think. The CampaignFleetAPI interface has a void setCommander(PersonAPI commander) method (link (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/campaign/CampaignFleetAPI.html#setCommander(com.fs.starfarer.api.characters.PersonAPI))) that may suit your needs. Since I'm no good with encapsulation, I can't really come up with the exact lines of code needed, but again, there's something to work with.

Ask around, maybe someone will be better at implementation than I am.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 03, 2016, 07:30:32 AM
But for some reason, that appears to be the only icon that works properly. If I, say, copy the damper_field.png icon from vanilla and paste it into my mod folder as ablative_armor_generator.png, using graphics/icons/hullsys/ablative_armor_generator.png as the path string results in a blank icon instead.

The image isn't working because the game hasn't loaded it. The one that works works because it's been loaded due to being used somewhere else, or specified somewhere that triggers the image to load on game load (such as, say, in hull_mods.csv).

To force the game to load an image, add it to the "graphics" section in your mod's settings.json.

Is the game engine hardcoded to make an exception for ships with the word "Phase" in their designations? Is there some way to work around it, or should I just use another word other than "Phase" instead?

Yes, it's hardcoded. Other words treated similarly are "Light", "Heavy", and iirc "Fast". This is because, say, "Phase Attack Frigate" sounds right, whereas "Attack Phase Frigate" sounds silly. Naturally dependent on your variant names, though.


Fleets in my mod RWS (deadly fighters) fly with transponders off.

Set $isPatrol to true in the fleet's memory.

Fleets do not have "captains".

Take a look at FleetFactoryV2.java from the api source that comes with the game - there's a method there that adds officers and a fleet commander. Not where I can look at the source right now, or I'd give a bit more detail.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: joe130794 on September 03, 2016, 01:23:11 PM
Just wondering because I havent seen it on any mods, is it possible to make an anti-missile missile launcher. That can launch multiple missiles each targeting an incoming missile. similar to missile systems on modern destroyers? if it is possible, How would I make one or maybe edit the swarmer to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 03, 2016, 10:20:14 PM
Can a dialog option in rules.csv be hotkeyed to Enter? Neither ENTER nor RETURN seems to work with SetShortcut.
EDIT: nvm, RETURN works

Just wondering because I havent seen it on any mods, is it possible to make an anti-missile missile launcher. That can launch multiple missiles each targeting an incoming missile. similar to missile systems on modern destroyers? if it is possible, How would I make one or maybe edit the swarmer to do it.
Yes; look at Exigency's Interceptor PDM for an example. Just adding PD to the hints column in weapon_data.csv should be sufficient to induce the behaviour, although a custom autofire AI may be needed to make it not waste shots.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on September 04, 2016, 12:50:35 AM
Just wondering because I havent seen it on any mods, is it possible to make an anti-missile missile launcher. That can launch multiple missiles each targeting an incoming missile. similar to missile systems on modern destroyers? if it is possible, How would I make one or maybe edit the swarmer to do it.
There are anti-missiles in Exigency, Diable, Scy and Seeker's prototype...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thecrashingwave on September 04, 2016, 03:01:33 PM
Hey everyone, I've been playing for quite a while and understand all the basics of mod installation. I have jre at 7.80, i have the memory increased. Ive done all the leg work. But for some reason a very large amount of the mods that claim to be compatible with Nexelerin and SS+ are causing immediate ctds. Interstellar Imperium and Hirigaan Descendants are not working, for example. Both crash with an error about being unable to find ships of the mod. Does anyone have a list of mods that are working without conflict currently? I dont want to try each one by hand.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on September 04, 2016, 04:15:43 PM
Hey everyone, I've been playing for quite a while and understand all the basics of mod installation. I have jre at 7.80, i have the memory increased. Ive done all the leg work. But for some reason a very large amount of the mods that claim to be compatible with Nexelerin and SS+ are causing immediate ctds. Interstellar Imperium and Hirigaan Descendants are not working, for example. Both crash with an error about being unable to find ships of the mod. Does anyone have a list of mods that are working without conflict currently? I dont want to try each one by hand.
First of all, get rid of the Hiigs as the modder hasn't fixed the issues with it
Also, what is the exact error? If it has something to do with mobile headquarters, get rid of NGO
Third, list your mods
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thecrashingwave on September 04, 2016, 04:40:06 PM
I can get the core mods to work. All libs and SS+ and (N) Ex. After that I haven't tried and of the individual mods except Hiri and II. [0.7.2a] AI War by Histidine

[0.7.2a] AI War by Histidine (Crashing from Icarrirer Spire error)
[0.7.2a] Blackrock Drive Yards by Cycerin (untested)
[0.7.2a] Diable Avionics by FlashFrozen, Tartiflette(untested)
[0.7.2a] Flu-X by spoortje1(untested)
[0.7.2a] Hiigaran Descendants by Gotcha!, DefiasOne(crashing from attempting to load ships) wont use because above post says it isnt fixed.
[0.7.2a] Interstellar Imperium by Dark.Revenant(crashing from attempting to load ships)
[0.7.2a] Junk Pirates by mendonca(untested)
[0.7.2a] Knights Templar by Dark.Revenant, Cycerin(untested)
[0.7.2a] The Mayorate by kazi(untested)
[0.7.2a] Metelson Industries by Azmond(crashing from attempting to load ships)
[0.7.2a] Neutrino Corp. by FlashFrozen(untested)
[0.7.2a] New Galactic Order by Ahne(above post says it isnt fixed)
[0.7.2a] ORI by Runoved(untested)
[0.7.2a] Pegasus Belt Council by celestis(untested)
[0.7.2a] Scy by Tartiflette(untested)
[0.7.2a] Shadowyards Reconstruction Authority by MShadowy(untested)
[0.7.2a] Tiandong Heavy Industries by MesoTroniK(untested)

All the ones marked untested I have not tried to run a game with just that mod, but with all of them together. I made it past the load screen, but CTD at main menu

For mods that do no add ships

[0.7.2a] Audio Plus by Dark.Revenant
[0.7.2a] Autosave by LazyWizard
[0.7.2a] Combat Chatter by Histidine
[0.7.2a] Common Radar by LazyWizard
[0.7.2a] Console Commands by LazyWizard
[0.7.2a] Starsector AI Overhaul by xenoargh
[0.7.2a] Upgraded Rotary Weapons by Tartiflette
[0.7.2a] DynaSector by Dark.Revenant
[0.7.2a] Extra System by Originem
[0.7.2a] Portrait Pack by HELMUT
[0.7.2a] Starsector+ by Dark.Revenant
[0.7.2a] Nexerelin by Histidine, Zaphide

I have tried running all the ship mods together after filtering out the few once i could identify crashes from ship names without all the bonus mods. This crashed at main menu.
I then tried to run just the aux mods together. This crashed too before load screen.
My only stable mod build is Libs, SS+ Nex and audio+. Ill begin checking each other mod one by one while i wait for a reply. If possible just say which ones work and which dont. The JSON files on some of them are listed at patch 7.1 i will automatically filter these and wont check them
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thecrashingwave on September 04, 2016, 04:52:10 PM
I just had a working run with the aux mods dynasector, autosave, combat chatter, common radar, extra system and portrait pack
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on September 04, 2016, 06:02:01 PM
I can get the core mods to work. All libs and SS+ and (N) Ex. After that I haven't tried and of the individual mods except Hiri and II. [0.7.2a] AI War by Histidine

[0.7.2a] AI War by Histidine (Crashing from Icarrirer Spire error)
[0.7.2a] Blackrock Drive Yards by Cycerin (untested)
[0.7.2a] Diable Avionics by FlashFrozen, Tartiflette(untested)
[0.7.2a] Flu-X by spoortje1(untested)
[0.7.2a] Hiigaran Descendants by Gotcha!, DefiasOne(crashing from attempting to load ships) wont use because above post says it isnt fixed.
[0.7.2a] Interstellar Imperium by Dark.Revenant(crashing from attempting to load ships)
[0.7.2a] Junk Pirates by mendonca(untested)
[0.7.2a] Knights Templar by Dark.Revenant, Cycerin(untested)
[0.7.2a] The Mayorate by kazi(untested)
[0.7.2a] Metelson Industries by Azmond(crashing from attempting to load ships)
[0.7.2a] Neutrino Corp. by FlashFrozen(untested)
[0.7.2a] New Galactic Order by Ahne(above post says it isnt fixed)
[0.7.2a] ORI by Runoved(untested)
[0.7.2a] Pegasus Belt Council by celestis(untested)
[0.7.2a] Scy by Tartiflette(untested)
[0.7.2a] Shadowyards Reconstruction Authority by MShadowy(untested)
[0.7.2a] Tiandong Heavy Industries by MesoTroniK(untested)

All the ones marked untested I have not tried to run a game with just that mod, but with all of them together. I made it past the load screen, but CTD at main menu

For mods that do no add ships

[0.7.2a] Audio Plus by Dark.Revenant
[0.7.2a] Autosave by LazyWizard
[0.7.2a] Combat Chatter by Histidine
[0.7.2a] Common Radar by LazyWizard
[0.7.2a] Console Commands by LazyWizard
[0.7.2a] Starsector AI Overhaul by xenoargh
[0.7.2a] Upgraded Rotary Weapons by Tartiflette
[0.7.2a] DynaSector by Dark.Revenant
[0.7.2a] Extra System by Originem
[0.7.2a] Portrait Pack by HELMUT
[0.7.2a] Starsector+ by Dark.Revenant
[0.7.2a] Nexerelin by Histidine, Zaphide

I have tried running all the ship mods together after filtering out the few once i could identify crashes from ship names without all the bonus mods. This crashed at main menu.
I then tried to run just the aux mods together. This crashed too before load screen.
My only stable mod build is Libs, SS+ Nex and audio+. Ill begin checking each other mod one by one while i wait for a reply. If possible just say which ones work and which dont. The JSON files on some of them are listed at patch 7.1 i will automatically filter these and wont check them


Ok, some mods you have on are buggy/are incompatible under certain conditions.

For the faction mods, remove:

- Flu-X (incompatible with Nexerelin's Corvus Mode. Works ok with the non-Corvus Mode).

- Hiigaran Descendants (buggy & imbalanced for now. Java problems as well).

- New Galactic Order (it has a hull mod that was once part of Starsector+. Mod author has not made any updates to correct this. A bit buggy too).

- ORI (a bit of a weird case, has some bugs that may cause crashes on occasions).

.

For the utility base mods, remove:

- Starsector A.I. Overhaul (this only works with the core game only. A bit buggy).

- Extra system (may not work with faction mods).

.

I don't see the GraphicsLib, LazyLib and TwigLib mods, but I assume you have all three on based off your statement.

Also, have you downloaded and incorporated the .jar file fix for Knights Templars? It's necessary to prevent crashes when dealing with the faction's Lattice Shield and some factions weapons.

Mayorate has a weird bug related to their market, but it's not game crashing as far as I know.

Neutrino and Metelson just had a recent update, maybe try re-downloading them.

Hope this helps.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on September 04, 2016, 06:25:13 PM
Mayorate has a weird bug related to their market, but it's not game crashing as far as I know.
Said bug can GREATLY increase the cost of supplies (like 300 to 600 a piece) and or fuel through out the sector, so I would suggest that you remove it until it is fixed. Everything else that Mr. K said is correct
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Az the Squishy on September 09, 2016, 05:26:35 PM
How is the image of weapon sprite read?  From the top left corner, right? Bottom left, or is it from the center of the combined images?

Never mind, figured it out. It's from the center.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on September 15, 2016, 08:33:31 AM
Hello again, I have a few questions to ask.

First off, are there any imports that are missing from these lines of imports in the faction's java file? I've did comparison with other factions and they were some lines that they have that are different.

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

package data.scripts.world.citadel;

import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.econ.EconomyAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.submarkets.StoragePlugin;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;

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

Secondly, I've tried to move Gateway further out from the centre of the Citadel system by increasing its orbit radius, but too no effect. It still lies in the corona of the star and I wanted to make it a bit more defendable by the Citadel fleets, considering that most of the ships have high maintenance and large supply consumption.

Are these original lines for the star and Gateway planet missing anything? My edits doesn't work. If possible, which one do I need to edit for reducing the corona of the star and its flares instead?

Any suggestions on ideal values are welcomed!

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

//MAIN SYSTEM AND STAR
       
        StarSystemAPI system = sector.createStarSystem("Citadel");
        system.getLocation().set(-10000, 3000);
        system.setBackgroundTextureFilename("graphics/backgrounds/background2.jpg");

        PlanetAPI blaze = system.initStar("blaze", "star_blue", 250f, 1000f, 4f, 0.5f, 1.0f);
                                 
        blaze.setCustomDescriptionId("citadel_blaze");
       
        //GATEWAY
       
        PlanetAPI gateway = system.addPlanet("gateway", blaze, "Gateway", "arid", 0, 100, 1000, 381);
        gateway.setCustomDescriptionId("citadel_gateway");
        gateway.setFaction("citadeldefenders");

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

Final question, specifically about the Fighter Redesign. I'm not sure whether this was asked before.

With the fighters being converted to chips and labelled later as part of a ships weapons, does the graphics have to be made for the chip?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on September 15, 2016, 10:05:39 AM
Citadel is compiled into a jar, that means you'll need an IDE like Netbean or Eclipse to recompile it. That will also take care of your first question as IDE's will tell you what imports you need. There are a couple of tutorials on the forum that cover setting up an IDE for Starsector.
For quicker replies on anything that simple you can join us onDiscord (http://fractalsoftworks.com/forum/index.php?topic=11131.0).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 24, 2016, 12:11:05 AM
Is there a way to get whether sound was disabled in the launcher?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2016, 10:02:16 AM
Is there a way to get whether sound was disabled in the launcher?

Could've sworn that was in SettingsAPI. Well, it is now, not that that's any help. (SettingsAPI.isSoundEnabled())

Doesn't seem like there's any way to tell currently, not even indirectly.

May I ask why that was needed? In theory, the sound/music methods just return quickly when sound is turned off, and the rest of the game doesn't worry about it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 24, 2016, 10:45:12 AM
May I ask why that was needed? In theory, the sound/music methods just return quickly when sound is turned off, and the rest of the game doesn't worry about it.
My music player kept detecting that no music was playing and trying to play something.
It had no impact that I could observe (other than cluttering the log, and I could've just taken out the debug messages if I really thought that was a problem) but still... :-X
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 24, 2016, 12:51:56 PM
Any way to get drones to use the "interdictor" ship system without scripts? They don't currently seem to, though at first I thought I didn't give them enough flux (but its a flux percentage per use anyway).

The other idea was just adding the interdictor stat script to an onhit weapon effect for a beam weapon and making a custom graphic. Think that would work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2016, 07:39:07 PM
Final question, specifically about the Fighter Redesign. I'm not sure whether this was asked before.

With the fighters being converted to chips and labelled later as part of a ships weapons, does the graphics have to be made for the chip?

Missed this, sorry: no, it'll take a base graphic for all fighter chips and then render a schematic for the current fighter on top of it. The schematic is generated in code based on the fighter sprite.


Any way to get drones to use the "interdictor" ship system without scripts? They don't currently seem to, though at first I thought I didn't give them enough flux (but its a flux percentage per use anyway).

The other idea was just adding the interdictor stat script to an onhit weapon effect for a beam weapon and making a custom graphic. Think that would work?

The on-hit effect should work, I think.

Generally, fighters aren't great about using their system (though iirc I had to improve that for flares etc). Not sure why it wouldn't work entirely for drones, though - iirc, the Terminator had a phase skimmer at one point and that worked.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on September 24, 2016, 08:18:17 PM
Missed this, sorry: no, it'll take a base graphic for all fighter chips and then render a schematic for the current fighter on top of it. The schematic is generated in code based on the fighter sprite.

Will it be possible to overwrite the default sprite, if (just hypothetically) someone were a glutton for punishment and wanted to do their own?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2016, 08:20:14 PM
Yes, but only for all fighters, not for a specific fighter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on September 24, 2016, 08:25:41 PM
Alas. I guess it was a long shot that only a few people would take advantage of, though. Net advantage of diddly-squat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 25, 2016, 12:51:40 PM

Generally, fighters aren't great about using their system (though iirc I had to improve that for flares etc). Not sure why it wouldn't work entirely for drones, though - iirc, the Terminator had a phase skimmer at one point and that worked.


I know, right? Its (very strangely) the exact opposite in practice with the interdictor system. I put it on a gunship fighter and it used it flawlessly. I made interdictor drones for a heavy cruiser that is super slow so it can actually catch things and the drones hover ~300 range from any target and visibly at least do nothing (the interdictor system is pretty obvious when used since it spells it out over the enemy targets engines).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 25, 2016, 01:45:25 PM
The on-hit effect should work, I think.

Just tried this with both a projectile and a beam:

gives an error message crash in combat saying that stat change cannot be cast with onHitEffect or with beamEffect.

Any other ways around getting a drone to use the system  or effect then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on September 25, 2016, 02:51:28 PM
Any other ways around getting a drone to use the system  or effect then?

Write a custom ship system AI for it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2016, 03:01:25 PM
Just tried this with both a projectile and a beam:

gives an error message crash in combat saying that stat change cannot be cast with onHitEffect or with beamEffect.

Any other ways around getting a drone to use the system  or effect then?

Oh, right, you can't just point the onHitEffect to that script, it's not going to work. You'd have to write an OnHitEffect implementation that does the same thing the interdictor script does, more or less.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 25, 2016, 10:39:07 PM
Oh, right, you can't just point the onHitEffect to that script, it's not going to work. You'd have to write an OnHitEffect implementation that does the same thing the interdictor script does, more or less.

Ah, ok gotcha
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on September 27, 2016, 06:39:09 PM
Quick question: What happened to the Tick? Has that been removed from the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on September 27, 2016, 07:02:39 PM
Quick question: What happened to the Tick? Has that been removed from the game?
That ship belongs to the Ship and Weapon Pack (IIRC) by DR
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on September 27, 2016, 10:19:16 PM
Quick question: What happened to the Tick? Has that been removed from the game?
That ship belongs to the Ship and Weapon Pack (IIRC) by DR

Wait, really? I never saw it in the ship lists. I thought it was a vanilla ship.

Huh.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on September 29, 2016, 01:27:58 AM
Hello again,

This might be a bit of a stretch... but after seeing the work Dark.Revenant did with LWJGL to create a custom GUI element for his Knight's Templar mod, I was wondering just how much of the vanilla combat widget GUI could be expanded upon by modders.

Granted, Dark.Revenant had to go through the trouble of (I think) mathematically calculating an [x,y] Vector2f offset (based off how the Weapon Group GUI widget is rendered) to determine where to dynamically place his Priwen Burst "cooldown meter" GUI element, but I was thinking something simple, like rendering additional text elements using the same font face as the base GUI, but you could determine both its position on the GUI and font color etc.

Spoiler
This was spawned from me playing around with BaseShipSystemScript's getInfoText(), and realizing that I couldn't change the position on the combat widget where the string is rendered, let alone a way to change the color to orange, like the way that the isDebuff boolean for the maintainStatusForPlayerShip() method in the CombatEngineAPI() changes the description text from green to orange. Since I doubt the likelihood is high of Alex going through the trouble of editing the codebase/API just to satisfy this selfish little gimmick of mine, I was wondering if I could instead "overlay" new GUI text elements using LWJGL like how Dark.Revenant did, but with the same font face as the vanilla GUI so that it doesn't look too out of place.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on September 29, 2016, 01:40:44 AM
The answer is easy: None of the UI is modifiable by mods. You only can draw on top manually, and you can only draw rasterized text.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on September 29, 2016, 02:14:37 AM
Yeah, I figured as much. I'll try looking into how to code LWJGL (probably some way to invoke Graphics2D.drawString), but from the sounds of it, I may have to end up painting in each letter as a textured quad one at a time, like you said. At least I found the Victor10 font in the core graphics directory, so there's that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on September 29, 2016, 03:11:01 PM
Rendering text is not basic graphics programming - you need a solid foundation in OpenGL and how fonts/text work.  There are books on this subject that you could read.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: whatdoesthisbuttondo on October 01, 2016, 06:33:53 AM
Anyone know an easy way for playtesting custom ships?

My current approach is to make a new savegame, grab 2-3 20k bounties and then save at a market station.

Then my basic loop would be to make adjustments or add new ships, edit the savegame so that they are available for purchase at that station and buy them to test out in sumulator battles.

Problem obviously is the limited availability of equipment at the market, haven't figured out yet how to edit in modules in my savegame.

I guess I could make a savegame with enough modules stored, but that kinda takes a while and if I don't want to make it extremely tedious I'll have to level up my character and officers (which I do not really want, makes it hard to judge balance for early-game) and build relations to get a good supply of high-end modules.

Is there a better way to do this?

Or maybe someone has a pre-edited savegame for this kind of thing they're willing to share?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mangalore on October 01, 2016, 06:47:09 AM
I also have a small question concerning custom ships. My issue is I added two custom ships to the Mayorate faction, one heavy cruiser and one dreadnaught level ship. I find the heavy cruiser in high level dock yards of the Mayorate easy enough so the custom ship gets spawned but I can't find the dreadnaught level ship. Checking save files there are reference of the big ship in fleets but I wonder how I can test if everything is working for the buying and selling section?

Increased likelyhood of the dreadnaught class ships in the Mayorate faction but not sure how to best find out if it would be available properly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on October 01, 2016, 09:13:57 AM
Anyone know an easy way for playtesting custom ships?

My current approach is to make a new savegame, grab 2-3 20k bounties and then save at a market station.

Then my basic loop would be to make adjustments or add new ships, edit the savegame so that they are available for purchase at that station and buy them to test out in sumulator battles.

Problem obviously is the limited availability of equipment at the market, haven't figured out yet how to edit in modules in my savegame.

I guess I could make a savegame with enough modules stored, but that kinda takes a while and if I don't want to make it extremely tedious I'll have to level up my character and officers (which I do not really want, makes it hard to judge balance for early-game) and build relations to get a good supply of high-end modules.

Is there a better way to do this?

Or maybe someone has a pre-edited savegame for this kind of thing they're willing to share?

Add it to a mission and test there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on October 01, 2016, 09:25:44 AM
Is there a better way to do this?
Use the console commands mod - you can add ships and weapons directly to your inventory with that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DrakonST on November 15, 2016, 02:04:17 AM
Somebody can explain to me how to correct it? It mod "Valkyrian" at independent start of a new game.
Code
71128 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoSuchMethodError: com.fs.starfarer.api.campaign.StarSystemAPI.initStar(Ljava/lang/String;Ljava/lang/String;FFF)Lcom/fs/starfarer/api/campaign/PlanetAPI;
java.lang.NoSuchMethodError: com.fs.starfarer.api.campaign.StarSystemAPI.initStar(Ljava/lang/String;Ljava/lang/String;FFF)Lcom/fs/starfarer/api/campaign/PlanetAPI;
at data.scripts.world.valkyrianSystem.generate(valkyrianSystem.java:84)
at data.scripts.plugins.VKSModPlugin.onNewGame(VKSModPlugin.java:39)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.M.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.I.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.interfacesuper.o00000(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.U.super(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 24, 2016, 02:23:26 PM
Hi guys. Has anyone ever made a mod that increases the quantity of ships/weapons/cargo found in markets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaucukovnik on November 25, 2016, 01:11:29 AM
Could the AI handle a ship with the majority of firepower being missiles directed backwards + engine boost?
The idea is to get past enemy ships and hit behind their shields (provided they don't have a 360 shield already on). Is there a way to trick the AI to charge further than it intended to accomplish this? Would that make it overly suicidal? Could missiles with good tracking help the AI use the ship in semi-regular fashion at least?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 28, 2016, 08:13:13 AM
Hi guys. Has anyone ever made a mod that increases the quantity of ships/weapons/cargo found in markets?

I mean to say, Starsector feels like "Emptysector" and it would be nice if markets were stocked with a greater variety and amount of cargo and ships than is currently stored there, to change the theme of the game to "Plentysector"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 28, 2016, 10:18:42 AM
Could the AI handle a ship with the majority of firepower being missiles directed backwards + engine boost?
The idea is to get past enemy ships and hit behind their shields (provided they don't have a 360 shield already on). Is there a way to trick the AI to charge further than it intended to accomplish this? Would that make it overly suicidal? Could missiles with good tracking help the AI use the ship in semi-regular fashion at least?

It probably wouldn't work consistently well. The only thing that comes to mind is writing a custom AI for a custom ship system, sort of like a burn drive but where the AI would trigger it with the intent to overshoot. But it'd be gimmicky at best and I expect would get mauled badly in anything other than a 1-1 fight.


Hi guys. Has anyone ever made a mod that increases the quantity of ships/weapons/cargo found in markets?

I mean to say, Starsector feels like "Emptysector" and it would be nice if markets were stocked with a greater variety and amount of cargo and ships than is currently stored there, to change the theme of the game to "Plentysector"

You'd need to have an IDE set up and tweak BaseSubmarketPlugin/some extending classes. The tweaks themselves would be pretty simple.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on November 29, 2016, 03:32:44 PM
How would you replace a .java class from ../com/fs/starfarer/api/.. with a custom one that you wrote?

I created a .jar file with my custom class and included the "jars" line in the mod_info.json file. However, there has been no effect on the game (including no crashing).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 02, 2016, 01:38:06 PM
Could I get the syntax for adding built in weapons with skin files?

tried:
 
Code
		"WS 016":{"hvygatlinglaser"},
"WS 017":{"hvygatlinglaser"}

inside of:
Code
"builtInWeapons":{
    },

That didn't work. I tried to find a working example and there isn't one in Vanilla. Thanks!  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2016, 05:57:33 PM
How would you replace a .java class from ../com/fs/starfarer/api/.. with a custom one that you wrote?

I created a .jar file with my custom class and included the "jars" line in the mod_info.json file. However, there has been no effect on the game (including no crashing).

You're sort of on the right track, I think, but it's not going to just replace the file. What you need to do is provide your own implementation, and then change whatever text file/csv/json file that points to the core file to point to yours instead.

Edit: also, you need to make sure the file in your jar is a compiled version of the .java file, i.e. a .class file.

Could I get the syntax for adding built in weapons with skin files?

...

That didn't work. I tried to find a working example and there isn't one in Vanilla. Thanks!  :)

"WS 016":"hvygatlinglaser",

Something like that should do it, unless I'm misremembering. The stuff you tried isn't even valid json (http://www.json.org/) :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on December 03, 2016, 11:53:13 AM
You're sort of on the right track, I think, but it's not going to just replace the file. What you need to do is provide your own implementation, and then change whatever text file/csv/json file that points to the core file to point to yours instead.

Edit: also, you need to make sure the file in your jar is a compiled version of the .java file, i.e. a .class file.

THANKS!!! I actually got my classes to work!

Unfortunately, they require you to replace the "jre" folder with the 1.8 version of Java.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 03, 2016, 11:55:26 AM
THANKS!!! I actually got my classes to work!

Unfortunately, they require you to replace the "jre" folder with the 1.8 version of Java.

Nice!

1.8 is required because that's the version of Java you compiled them with. If you compile with an earlier version (if you're using an IDE, there should be an option in the project settings to pick which version to compile to), then it should work w/o requiring Java 8.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on December 06, 2016, 09:20:36 AM
NVM guess it doesn't matter cuz it only crashes rarely and only at one market.

Spoiler
I got a crash from the mod I built(Plentysector) when testing with Ironclads:

java.lang.OutOfMemoryError: Java heap space

When I entered a particular market of size 3 that did not have a military submarket and clicked on "Trade, or hire personel", Starsector would crash.
It would not crash if I clicked on "Buy or sell ships".

Other markets/stations do not crash however.

It seems that the market that I was at was updated right before the crash, which may be related to the cause of the crash.


Here is the log output:

Spoiler
233379 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Picking market updates
233380 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Adding Volatiles(Nilusis 3 Gas Collector)
233380 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Adding Food(Nilusis 3 Gas Collector)
254319 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
   at java.util.Arrays.copyOf(Unknown Source)
   at java.util.Arrays.copyOf(Unknown Source)
   at java.util.ArrayList.grow(Unknown Source)
   at java.util.ArrayList.ensureExplicitCapacity(Unknown Source)
   at java.util.ArrayList.ensureCapacityInternal(Unknown Source)
   at java.util.ArrayList.addAll(Unknown Source)
   at com.fs.starfarer.ui.o0oO.o00000(Unknown Source)
   at com.fs.starfarer.ui.o0oO.recompute(Unknown Source)
   at com.fs.starfarer.ui.o0oO.setOffset(Unknown Source)
   at com.fs.starfarer.ui.P.ØÒ0000(Unknown Source)
   at com.fs.starfarer.ui.P.forceSlideIn(Unknown Source)
   at com.fs.starfarer.ui.P.<init>(Unknown Source)
   at com.fs.starfarer.ui.ifnew.<init>(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.A.<init>(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.new.øo0000(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.String.public.if$super(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.String.sizeChanged(Unknown Source)
   at com.fs.starfarer.ui.o0oO.setSize(Unknown Source)
   at com.fs.starfarer.coreui.k.o00000(Unknown Source)
   at com.fs.starfarer.coreui.k.Object(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.MarketInfoPanel.sizeChanged(Unknown Source)
   at com.fs.starfarer.ui.o0oO.setSize(Unknown Source)
   at com.fs.starfarer.campaign.ui.OoOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.sizeChanged(Unknown Source)
   at com.fs.starfarer.ui.o0oO.setSize(Unknown Source)
   at com.fs.starfarer.ui.P.setSize(Unknown Source)
   at com.fs.starfarer.coreui.oo0o.sizeChanged(Unknown Source)
   at com.fs.starfarer.ui.o0oO.setSize(Unknown Source)
   at com.fs.starfarer.ui.P.setSize(Unknown Source)
   at com.fs.starfarer.ui.newui.J$5.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.h.o00000(Unknown Source)
   at com.fs.starfarer.ui.OooO.processInput(Unknown Source)
   at com.fs.starfarer.ui.Objectsuper.o00000(Unknown Source)
[close]

Is there a maximum limit of items that can be stored in a market?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HowDoIEdit on December 11, 2016, 12:48:32 PM
Modding Vanilla/Mod weapons

So I'm new to StarSector, and in either mods or the vanilla game, how do I adjust a certain weapon's damage? Same graphics/sounds, I essentially want the weapon to still exist as it normally does, but more or less deadly. 

Under the data>weapons I see both the weapon_data file and the corresponding weapon files, but when I adjust where I believe to be the correct spot it doesn't appear to do anything in game.

Any thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on December 11, 2016, 02:33:35 PM
Modding Vanilla/Mod weapons

So I'm new to StarSector, and in either mods or the vanilla game, how do I adjust a certain weapon's damage? Same graphics/sounds, I essentially want the weapon to still exist as it normally does, but more or less deadly.  

Under the data>weapons I see both the weapon_data file and the corresponding weapon files, but when I adjust where I believe to be the correct spot it doesn't appear to do anything in game.

Any thoughts?
First of all, welcome to the forums!
Now for your question, are you using any mods? Because if you are using a mod that overwrites the vanilla weapon you are trying to edit, it won't work.
It sounds like you want the STATS of the guns, which are stored in the weapons.csv. The csv files store the stats for the gun, the ships and the fighters so you can edit those as long as a mod doesn't overwrite it. If one does then all you need to do is change that mods weapons.csv to what you want. Note: THe best way to edit these, in my experience, is to use a spreadsheet program like Open Office calc or Microsoft Excel
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: coyote.j.p.m on December 11, 2016, 05:49:57 PM
Hey guys! I've lurked here for a long time, been modding on and off for a few years now. Quick question:
I have a hull that I'm trying to make a skin for, and I'm wondering if it's possible to change the engine slot style types and the defense system id for the skin.
Background on the question: it's a phase ship, and I created a different kind of phase cloak system to get the effect color I wanted. But I want the skin to have a different color.
Is it possible just via a .skin file, or will I have just have to create an entirely separate hull? Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 17, 2016, 08:23:42 PM
Is there a way to temporarily disable a missile's engine?

ShipEngineControllerAPI.forceFlameout() does nothing
ShipEngineControllerAPI.getShipEngines() returns an empty table
Even missile.setFlightTime(0); does nothing

Belated (and disappointing) reply:
I have a hull that I'm trying to make a skin for, and I'm wondering if it's possible to change the engine slot style types and the defense system id for the skin.
Background on the question: it's a phase ship, and I created a different kind of phase cloak system to get the effect color I wanted. But I want the skin to have a different color.
Is it possible just via a .skin file, or will I have just have to create an entirely separate hull?
Skins can't do either of those things directly that I know of, unfortunately. A hullmod can change the engine flame color (see Safety Overrides).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: coyote.j.p.m on December 18, 2016, 09:00:52 AM
Thanks Histidine, that does help! The engine glow is the more important one, so I'll just add a built in hull mod to the skin file to change the engine glow. I guess most hull mods are more than cosmetic changes usually, but I'm sure I could come up with a thematically appropriate bonus/detriment for it. I'll think about that...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 18, 2016, 11:09:06 AM
Is there a way to temporarily disable a missile's engine?

ShipEngineControllerAPI.forceFlameout() does nothing
ShipEngineControllerAPI.getShipEngines() returns an empty table
Even missile.setFlightTime(0); does nothing

Hmm, I don't think so. I would've expected forceFlameout() to work, though. But if it doesn't, it's probably for a reason. I'll see if I can take a look at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on December 19, 2016, 04:21:31 PM
In my ever concerning pursuit of !!SCIENCE!!, I would like to try adjusting the effects of flux capacitors and flux vents. Does there exist a way to do that easily in the current state of things?

Oh also, in the sound files, there seems to be different types of impact sounds depending on how much damage the hit dealt. What's the threshold for each category? (glancing, light, solid, heavy, etc) Is there a way to modify that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2016, 05:08:23 PM
In my ever concerning pursuit of !!SCIENCE!!, I would like to try adjusting the effects of flux capacitors and flux vents. Does there exist a way to do that easily in the current state of things?

To my shame, this is in Ship.java:
public static float FLUX_PER_CAPACITOR = 200f;
public static float DISSIPATION_PER_VENT = 10f;


Oh also, in the sound files, there seems to be different types of impact sounds depending on how much damage the hit dealt. What's the threshold for each category? (glancing, light, solid, heavy, etc) Is there a way to modify that?

There isn't, it's hardcoded. Very old code, from pre-modding days, more or less - or at least from before I had a good picture of how it would work out in practice. Sorry :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on December 19, 2016, 05:16:41 PM
ok, so without being able to modify it... Would you happen to remember the thresholds for each so I can kinda work around that?

EDIT: Oh, and my manners, thanks for the quick answer :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2016, 05:20:32 PM
In the spirit of doing this real quick, as opposed to doing it later and maybe forgetting about it:

Code: java
if (shieldDam > 0) {
SoundSet pickedShieldHit = null;
SoundSet [] shieldHitArray = shieldHitSets.get(result.getType());
if (shieldDam < 70) {
vol = shieldDam / 20f;
if (vol > 1) vol = 1;
pickedShieldHit = shieldHitArray[0];
} else if (shieldDam < 200) {
pickedShieldHit = shieldHitArray[1];
} else {
pickedShieldHit = shieldHitArray[2];
}
if (pickedShieldHit != null) {
SoundPlayer.queue(pickedShieldHit.pick(), 1f, vol, loc, vel);
}
return;
}

SoundSet picked = null;
SoundSet [] array = hitSets.get(result.getType());
if (hullDam > armorDam) {
array = hitHullSets.get(result.getType());
}

float physicalDam = armorDam + hullDam + fluxDam;
if (physicalDam < 5) {
picked = array[0];
} else if (physicalDam < 40) {
picked = array[1];
} else if (physicalDam < 150) {
picked = array[2];
} else {
picked = array[3];
}

(Edit: also, you're totally welcome :))
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on December 19, 2016, 06:15:00 PM
thanks

one last thing:
To my shame, this is in Ship.java:
public static float FLUX_PER_CAPACITOR = 200f;
public static float DISSIPATION_PER_VENT = 10f;

Is that a no to being able to change it easily? I'm terrible at java
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2016, 06:24:14 PM
Yeah, it's a no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 23, 2016, 10:22:17 PM
Alex, is there a way to fix this issue (http://fractalsoftworks.com/forum/index.php?topic=11516.0)?
I was hoping to make it immediately update to the new price (after undock and redock) by forcing a updateCargoPrePlayerInteraction() call (with reset timer) after the stability loss event, but this has no effect.

If it can't be fixed by a mod, will it go away with the 0.8 economy system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2016, 10:32:54 PM
What's the actual issue? I mean, I have the rough picture from that thread, but that doesn't tell me what's actually going on behind the scenes, what agents do, why the price goes up on re-docking, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 23, 2016, 11:27:04 PM
What's the actual issue? I mean, I have the rough picture from that thread, but that doesn't tell me what's actually going on behind the scenes, what agents do, why the price goes up on re-docking, etc.

So far as I can tell, the underlying problem is that changing a market's demand for a commodity doesn't change its price until time passes in the Sector, although changing the market's stability changes its prices instantly.

Spoiler
To recap:
1) Before doing anything, prices of hand weapons/drugs in market are X
2) Use agent to cause a stability penalty event (https://bitbucket.org/Histidine/exerelin/src/master/jars/sources/ExerelinCore/exerelin/campaign/events/AgentDestabilizeMarketEventForCondition.java) (similar to Recent Unrest but longer-lived)
3) Prices of guns/drugs are now Y, where Y < X
4) Undock and redock
5) Prices of guns/drugs are now Z, where Z > X

After doing some fresh searching, I found step 5 results from the code in Population submarket class that increases demand for hand weapons and drugs when stability drops low enough. But calling market.reapplyConditions() after the stability-reducing event doesn't make the prices update to Z before undocking. Are prices updated based on supply/demand only in an EveryFrameScript somewhere?

Spoiler
Code: java
	public void apply(String id) {
float size = market.getSize();
float pop = getPopulation(market);

//[...]

// TODO : modify this to affect all goods illegal in market
float lowStabilityBonus = getLowStabilityBonusMult(market);
float lowStabilityPenalty = getLowStabilityPenaltyMult(market);
float highStabilityBonus = getHighStabilityBonusMult(market);
float highStabilityPenalty = getHighStabilityPenaltyMult(market);

for (CommodityOnMarketAPI com : market.getAllCommodities()) {
if (market.isIllegal(com) && !com.getId().equals(Commodities.ORGANS)) {
market.getDemand(com.getId()).getDemand().modifyMult("stability_" + id, lowStabilityBonus * highStabilityPenalty);
}
}

if (!market.isIllegal(Commodities.DRUGS)) {
market.getDemand(Commodities.DRUGS).getDemand().modifyMult("stability_" + id, lowStabilityBonus * highStabilityPenalty);
}
if (!market.isIllegal(Commodities.HAND_WEAPONS)) {
market.getDemand(Commodities.HAND_WEAPONS).getDemand().modifyMult("stability_" + id, lowStabilityBonus * highStabilityPenalty);
}
if (!market.isIllegal(Commodities.LUXURY_GOODS)) {
market.getDemand(Commodities.LUXURY_GOODS).getDemand().modifyMult("stability_" + id, highStabilityBonus * lowStabilityPenalty);
}

}
[close]
[close]

Can I just tell a market to recalculate its prices?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2016, 11:39:37 PM
Ah, yeah, this makes sense. There's an updatePrices() method that wasn't in MarketAPI for some reason, added it there. It gets called in a market's advance() method if the stability changed to catch this stuff, but that doesn't catch the case where stability changes while you're in the dialog.

Is there an advance() method in MarketAPI? There is *now*, but I'm not sure about 0.7.2a. If there is, calling it with 0 as the elapsed time should resolve this as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 24, 2016, 12:36:36 AM
Ah, good!
Is there an advance() method in MarketAPI? There is *now*, but I'm not sure about 0.7.2a. If there is, calling it with 0 as the elapsed time should resolve this as well.
It's not in 0.7.2a. But advancing the whole EconomyAPI (by 0) also seems to work, ha!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2016, 08:44:22 AM
Nice :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on December 25, 2016, 02:50:07 PM
I am trying to compile some of the java sources from my mod (not the mission .java though)

However, when I start Starsector, it crashes, saying:

Spoiler
9134 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.RWSModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.RWSModPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.RWSModPlugin
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]


The crash says class not found, but my code compiled successfully. What is going on?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on December 27, 2016, 09:28:50 PM
Just because the compiler compiles, doesn't necessarily mean that the code you've put in is good. You're going to have to sift through the modplugin, and make sure everything is named appropriately (The error could be because it's trying to find a class file that doesn't exist in the .jar file).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 27, 2016, 09:49:36 PM
Hmm - this looks like a mismatch between where you're telling the game your ModPlugin is (in mod_info.json) and where it actually is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 03, 2017, 06:16:12 AM
Am I understanding these BattleAPI methods correctly?

getPlayerCombined() returns a CampaignFleetAPI consisting of all the fleet members that were on the player's side
getNonPlayerCombined()returns a CampaignFleetAPI consisting of all the fleet members that were on side opposing the player
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 04, 2017, 10:26:11 AM
Yeah, that's correct. Well, not "were", but "are".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on January 05, 2017, 01:56:01 AM
The faction files have a section that refers to lists of ship names, am I correct in assuming that section refers to the weight with which those ship name lists are chosen? If so, does it account for the size of the lists? That is to say, if I was to say double the size of the GENERAL list, for example, and still want each name in that list to appear about as frequently as names from other lists, would I have to double its weight in every single faction file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on January 06, 2017, 09:30:29 AM
From the scope of EveryFrameCombatPlugin.advance() is it possible to tell if a projectile has a specific onHitEffect or that a projectile some sort of tag from the JSON you can inspect/look for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on January 06, 2017, 09:48:22 PM
Does anyone know if it's possible to resize the text panel in an InteractionDialogAPI? I'm trying to write a pure-text dialog, so the space reserved for the visual panel is completely wasted in this case. I'd like the text area to be wider so I can fit more information onto a single page.

The setTextWidth() method doesn't appear to work. The text area doesn't resize, although it does move to the left:
Spoiler
(http://i.imgur.com/EQRkzBP.png)
[close]

Yeah, the .setTextWidth() method is all sorts of broken. I'll have to sit down and fix it at some point; unfortunately it's not an easy, obvious kind of broken.

Looks like this is still the case, has anyone found a work-around?

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 06, 2017, 10:13:42 PM
The faction files have a section that refers to lists of ship names, am I correct in assuming that section refers to the weight with which those ship name lists are chosen? If so, does it account for the size of the lists? That is to say, if I was to say double the size of the GENERAL list, for example, and still want each name in that list to appear about as frequently as names from other lists, would I have to double its weight in every single faction file?

Yeah, they're weights. No, it doesn't consider the size of the lists. In your scenario, yeah, you'd need to double the weight everywhere.


From the scope of EveryFrameCombatPlugin.advance() is it possible to tell if a projectile has a specific onHitEffect or that a projectile some sort of tag from the JSON you can inspect/look for?

Hmm. projectile.getWeapon().getId() and hardcode off that? In the next release, weapon specs have tags so you'd be able to getWeapon().getSpec().getTags(), which returns a Set<String>.


Looks like this is still the case, has anyone found a work-around?

Not that I'm aware of, but then I haven't exactly been looking. Sorry for the not-helpful answer :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: djcian on January 13, 2017, 12:02:19 PM
How would I go about making it so that every ship that is disabled in a battle is not destroyed and can be repaired?  I've tried editing the field repairs reconstruction perk in SkillData.java (FIELD_REPAIRS_DISABLED_REPAIR_PERCENTAGE = 100f) so that there is a 100% chance to repair disabled friendly ships after battle but it seems to only repair one ship per battle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 21, 2017, 10:46:42 PM
Hey all.

I'm currently working on an optional hull mod for a specific ship that increases the burn speed of all the fighters in the fleet by 2 at the cost of drastically increased refit time and just about all the OPs. I've tried looking through the Tow Cable hullmod, but because of complicated mathematical coding that ensures that only the slowest ship gets a buff, and only one ship gets a buff per ship that has the hullmod, I can't pin point the exact line that gives the buff. I've tried quite simply:

Code
        public void apply(FleetMemberAPI member) {
if member.isFighter())
            member.getStats().getMaxBurnLevel().modifyFlat(id, 2);
        }

But that doesn't work, and I've tried copy and pasting the tow cable hullmod and changing the suitability thus:

Code
    private boolean isSuitable(FleetMemberAPI member) {
        if (member.isFighterWing()) return true;
        return false;
    }

But that, too, doesn't work. Can anyone help me out and tell me what line I should be looking at please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on January 22, 2017, 11:12:34 PM
Given a ShipAPI and a CombatEngineAPI any one have a clue how to get a ships deployment value?  I've tried this horrible code below but it only works sometimes :(

Code: java
List<FleetMemberAPI> allMembers = new ArrayList<>();
allMembers.addAll(engine.getFleetManager(ship.getOwner()).getDeployedCopy());
allMembers.addAll(engine.getFleetManager(ship.getOwner()).getDestroyedCopy());
allMembers.addAll(engine.getFleetManager(ship.getOwner()).getDisabledCopy());
allMembers.addAll(engine.getFleetManager(ship.getOwner()).getReservesCopy());
allMembers.addAll(engine.getFleetManager(ship.getOwner()).getRetreatedCopy());

FleetMemberAPI fm = null; // my kingdom for a lambda
for (FleetMemberAPI fma : allMembers){
    if(fma.getId().equals(ship.getFleetMemberId())){
        fm = fma;
        break;
    }
}

if(fm != null){
    fleetPoints = fm.getFleetPointCost();
}

Edit
Nevermind, the above code might not be pretty but it works fine. PEBKC
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on January 26, 2017, 02:24:39 PM
I am trying to remove copies of ships from markets. However, the ship copies don't get removed from markets, and I don't know what the issue is.



Code
	protected void pruneShips() { // doesn't work
CargoAPI cargo = getCargo();
FleetDataAPI data = cargo.getMothballedShips();

int numSameHulls = 0;
String hullName = "";
String newHullName = "";

for (FleetMemberAPI member : data.getMembersListCopy()) {

// do a ticker, count to 10, then delete all ship copies after that
// assume same hulls one after another

newHullName = member.getHullId();

// if the same hull as the one before it in the market
if (newHullName == hullName) {

numSameHulls++;

if (numSameHulls >= 10) { // delete the copies
data.removeFleetMember(member);
}
}
else { // different hull
numSameHulls = 0;
hullName = newHullName;
}
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on January 26, 2017, 02:56:35 PM
I am trying to remove copies of ships from markets. However, the ship copies don't get removed from markets, and I don't know what the issue is.



Code
	protected void pruneShips() { // doesn't work
CargoAPI cargo = getCargo();
FleetDataAPI data = cargo.getMothballedShips();

int numSameHulls = 0;
String hullName = "";
String newHullName = "";

for (FleetMemberAPI member : data.getMembersListCopy()) {

// do a ticker, count to 10, then delete all ship copies after that
// assume same hulls one after another

newHullName = member.getHullId();

// if the same hull as the one before it in the market
if (newHullName == hullName) {

numSameHulls++;

if (numSameHulls >= 10) { // delete the copies
data.removeFleetMember(member);
}
}
else { // different hull
numSameHulls = 0;
hullName = newHullName;
}
}
}

Is  data.getMembersListCopy()  guarenteed to be ordered by HullId (have you verified that removeFleetMember is being called)?  Also the pointer equality test for the strings is probably not what you want, they might be interned and it's OK, but it's not guaranteed from the interface and a proper .equals() call should firstly test for pointer equality.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on January 26, 2017, 03:31:22 PM
nvm I figured out another way to get it to work
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on January 28, 2017, 10:54:55 AM
I'm trying to get a ship in my fleet to fire different weapons from their weapon groups, I'm using the method:

Code: java
        ShipAPI.giveCommand(ShipCommand.FIRE, someVectorFarInFrontOfShip, weaponGroupIndex);

But no matter what the value of weaponGroupIndex, group 0 always fires.  (I've even tried the deprecated USE_SELECTED_GROUP with no luck).

Am I doing something wrong here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 28, 2017, 11:08:15 PM
The weaponGroupIndex parameter only applies to the command to select a weapon group. The FIRE command always fires the currently selected group.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 29, 2017, 01:03:46 AM
Btw, could we get a way to prevent (or force) specific weapons from firing? I have a system that is supposed to prevent just the large slots from firing, but despite my best efforts using remaining cooldowns, ammo and such shenanigans, continuous beams can still fire.

Pleeeeease???  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on January 29, 2017, 10:37:59 AM
The weaponGroupIndex parameter only applies to the command to select a weapon group. The FIRE command always fires the currently selected group.

Ah got it now.  I think I tried it earlier but messed something else up.  Here's the code in case others are interested:

Code: java
// tell it which weapon group to fire  
ShipAPI.giveCommand(ShipCommand.SELECT_GROUP, null, weaponGroupIndex);

// fire the selected weapon group
ShipAPI.giveCommand(ShipCommand.FIRE, someVectorFarInFrontOfShip, weaponGroupIndex);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 31, 2017, 01:58:57 AM
Btw, could we get a way to prevent (or force) specific weapons from firing? I have a system that is supposed to prevent just the large slots from firing, but despite my best efforts using remaining cooldowns, ammo and such shenanigans, continuous beams can still fire.

Pleeeeease???  :)
Actually, just a weapon.disable(boolean permanent, boolean RepairParticles) would be enough, having giant blue sparkles is the issue with the current disable command.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2017, 11:04:30 AM
Probably not the right thread for it, but let me add it to the (long) list.

(Hmm - one could re-imagine the system as actually disabling the weapons. That seems kind of cool!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 31, 2017, 07:05:10 PM
To add some context, the system I'm talking about is the Nemean Lion's system, that closes the armor to shroud the front weapons from damage, but also prevent them from firing. I'd like to keep the other weapons firing, but for now it's not perfect.

(https://i.imgur.com/JZXdVLal.jpg) (https://i.imgur.com/JZXdVLa.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2017, 07:40:27 PM
Ah, got it. Added to WeaponGroupAPI:

WeaponAPI removeWeapon(int index);
void addWeaponAPI(WeaponAPI weapon);

That seems like that should do it, right? Assuming you'd remove the weapons from the group and add them back in depending on the state of the system.

... could get weird if a weapon was firing at the time of removal, though. Hmm.

Made a note to take a closer look later.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on February 01, 2017, 09:48:29 AM
So I can't figure out how to render a simple sprite during combat.  Hopefully this is the dumbest I'll feel all day. :)

I have a simple 20x20 pixel sprite, I'm just trying to get it to show up anywhere on the screen and I can't.  I've verified through logging that the sprite is loaded correctly and the call to SpriteAPI.renderAtCenter is being called.

Code: java
    public static void tryRendering(){
        renderSprite(new Vector2f(0, 0));
        renderSprite(Global.getCombatEngine().getViewport().getCenter());
        renderSprite(ShipAPI.getLocation());
    }

    public static void renderSprite(Vector2f location) {
        SpriteAPI sprite = Global.getSettings().getSprite("misc", "CoOp_Ready");
        sprite.renderAtCenter(location.x, location.y);
    }

I've looked at some other code that is rendering stuff and the above looks more or less the same so I must be missing something obvious...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2017, 10:28:30 AM
Where you're calling this code from is the important bit. It should probably be from either in EveryFrameCombatPlugin.renderInWorldCoords() or EveryFrameCombatPlugin.renderInUICoords().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on February 01, 2017, 10:48:09 AM
Ah, OK.  A lot of things just clicked into place.

I was trying to call it in ShipAIPlugin.advance(). I had made calls to GL11 from there without issue so I just assumed other graphics calls would work.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2017, 10:54:07 AM
Cool! (In theory, you could also render from where you're trying to, but you'd have to set up the glViewport etc to match what the game is doing, where if you do it in the aforementioned functions, that's already set up for you.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 01, 2017, 09:17:40 PM
Quick question on the U.I display for deployment cost.

Am I interpreting it correctly? It doesn't seem to correctly display the proper algorithm for determining the actual deployment cost from "ships.csv"

It should take the ratio of the CR% recovered per day and the CR% per deployment and multiply that by the number in the supplies/rec column.
Instead it seems to only display that number. Really confusing to the player if the CR% per deployment and CR% rec per day are not exactly the same.

I have also "verified"* that it correctly uses the former algorithm in the actual campaign cost of supplies per deployment though. So one of the two is off it seems.



* loosely through seeing supplies drain far faster or slower than the "-x/day" number would indicate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2017, 09:21:46 PM
Supplies/rec is "supplies to recover from deployment". So for example if a ship costs 20% to deploy and recovers 5% per day, and its recovery cost is 10 supplies, it'll cost 10 supplies to recover 20% over 4 days. If you change the recovery per day to 10%, it'll cost 10 supplies to recover 20% over 2 days.

So it just gives you the main number, the actual cost, upfront, regardless of how many days it's spread out over.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 02, 2017, 12:37:41 AM
So it just gives you the main number, the actual cost, upfront, regardless of how many days it's spread out over.

Ah thanks! Thought that could be it, but something had me under the opinion it didn't "work" like that in practice.

Ill edit the numbers based upon that and that should fix it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on February 05, 2017, 11:06:20 PM
I'm trying to get the "burst size" value stored in weapon_data.csv.  I have a WeaponAPI object (and it's DerivedWeaponStatsAPI) but I'm unable to derive burstSize from using DerivedWeaponStatsAPI.getBurstFireDuration()/DerivedWeaponStatsAPI.getRoF() as it appears RoF takes into account weapon cooldown after shooting.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: aZmoDen on February 05, 2017, 11:54:02 PM
Ive made a few hull mods, and was wondering if the ai is free to use them?
If they can is there any way to restrict their use or limit them to factions?
thanks in advance for any answers!
az.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 06, 2017, 02:49:38 AM
Ive made a few hull mods, and was wondering if the ai is free to use them?
If they can is there any way to restrict their use or limit them to factions?
By default AI ships will only use the variants specified in their faction files. So an AI faction will only use a hullmod to the extent that it exists on variants the fleet factory picks for its fleets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2017, 09:16:23 AM
I'm trying to get the "burst size" value stored in weapon_data.csv.  I have a WeaponAPI object (and it's DerivedWeaponStatsAPI) but I'm unable to derive burstSize from using DerivedWeaponStatsAPI.getBurstFireDuration()/DerivedWeaponStatsAPI.getRoF() as it appears RoF takes into account weapon cooldown after shooting.

Thanks!

WeaponAPI.getSpec(), which returns WeaponSpecAPI, which you can call .getBurstSize() on - or is that not in the current release?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on February 06, 2017, 11:51:11 AM
I'm trying to get the "burst size" value stored in weapon_data.csv.  I have a WeaponAPI object (and it's DerivedWeaponStatsAPI) but I'm unable to derive burstSize from using DerivedWeaponStatsAPI.getBurstFireDuration()/DerivedWeaponStatsAPI.getRoF() as it appears RoF takes into account weapon cooldown after shooting.

Thanks!

WeaponAPI.getSpec(), which returns WeaponSpecAPI, which you can call .getBurstSize() on - or is that not in the current release?

Nope, not in .72a. One more reason to be hyped for .8!! :)

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on February 09, 2017, 09:54:48 AM
Is there anyway to reduce the flux cost of a weapon by a flat amount?

The WeaponFluxCostMod() methods work, but are a bit wonky; they can reduce the weapon flux cost below 0, and don't really work with weapons that have a charge up time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2017, 10:43:51 AM
The way you're trying to do it would be the way to do it, and if that doesn't work, then nothing else comes to mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on February 17, 2017, 09:30:40 PM
The following code is part of a hullmod, it is meant to change the ship's shield color as an indicator of its presence. It currently works, and so does the ship system check, so the shield properly changes to the purple color of an active fortress shield.

After the system is turned off, the ship resumes its new red shield color, however it does so instantly, unlike the fortress shield gradual shift in color, and I have no idea how to achieve something similar.
 
Spoiler
Code
        public void advanceInCombat(ShipAPI ship, float amount)  {
                if ((!ship.getSystem().isActive()) && ((ship.getSystem().getId()!="TSC_RamDrive_System") || (ship.getSystem().getId()!="fortressshield"))) {
                    ship.getShield().setInnerColor(new Color (255,85,25,75));
                    ship.getShield().setRingColor(new Color (215,165,100,255));
                }
        }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2017, 09:42:19 PM
What you want to do is set the shield color gradually - keep track of how long it's been shifting vs how long you want the color shift to take, and use that to interpolate from the original color to the new color.

Important note: you don't want to save this state in a member variable in the effect class, because there's only one of those created, so that value would be shared among all ships with that hullmod. What you want is to store this value in the map returned by Global.getCombatEngine().getCustomData(); key it off something like the ship's ID.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Peace_Destroyer on March 03, 2017, 03:47:39 PM
I keep getting an error and a crash that it can't find my custom weapon sound
Quote
46052 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.float] with id [sounds/gr/fx/grweapons/g3bosslaser1.ogg] not found
java.lang.RuntimeException: Spec of class [com.fs.starfarer.loading.specs.float] with id [sounds/gr/fx/grweapons/g3bosslaser1.ogg] not found

That's the directory and the file, I've saved it as a mono .ogg in Audacity. Is something wrong with my file structure or my .wpn file? Or something else?

Here's the wpn file, it was generated via the ship editor:

 
Spoiler
{
  "animationType": "GLOW",
  "barrelMode": "ALTERNATING",
  "glowColor": [0,100,153,75],
  "hardpointAngleOffsets":
  • ,

  "hardpointOffsets": [9.5,0],
  "hardpointSprite": "graphics/gr/weapons/bigcore_blaster.png",
  "id": "bc_blaster",
  "projectileSpecId": "bcblaster_shot",
  "size": "SMALL",
  "specClass": "projectile",
  "textureType": ROUGH,
  "turretAngleOffsets":
  • ,

  "turretGunSprite": "graphics/gr/weapons/bigcore_blaster.png",
  "turretOffsets": [6,0],
  "turretSprite": "graphics/gr/weapons/bigcore_blaster.png",
  "fireSoundOne":"sounds/gr/fx/grweapons/g3bosslaser1.ogg",
  "type": "ENERGY"
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 03, 2017, 04:08:58 PM
fireSoundOne refers to a sound id defined in data/config/sounds.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Peace_Destroyer on March 03, 2017, 05:21:36 PM
fireSoundOne refers to a sound id defined in data/config/sounds.json.

Thanks a lot, I would have never figured that out on my own.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: whatdoesthisbuttondo on March 04, 2017, 05:22:42 AM
Is it possible (or will it be with the upcoming 0.8 release) to have properly working phase carriers?

I've searched the forums and only found a very old post saying that the carriers apparently service fighters even if phased out,
which is not what I want.

At the time, iirc Alex said that it was considered a feature. If that still holds true, is there maybe a way to work around this by
code?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on March 04, 2017, 02:32:53 PM
Speaking of carriers, I've got a future ship planned that I've been meaning to ask a question in regards to; namely, is some means possible to separate out flight decks so that some are used for landing and other for launch?  My current hypothetical is using empty built-in weapons slots and an attached plugin script that looks for those particular slots and pops the fighters out of them (in a BSG catapult kinda way) instead of the landing pads.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 04, 2017, 09:12:18 PM
Is it possible (or will it be with the upcoming 0.8 release) to have properly working phase carriers?

I've searched the forums and only found a very old post saying that the carriers apparently service fighters even if phased out,
which is not what I want.

At the time, iirc Alex said that it was considered a feature. If that still holds true, is there maybe a way to work around this by
code?

Still true on all counts, yeah. Sorry :)

*Technically* this is probably possible for a mod to work around by writing fully custom fighter AI, but that's massive overkill in terms of effort.

Speaking of carriers, I've got a future ship planned that I've been meaning to ask a question in regards to; namely, is some means possible to separate out flight decks so that some are used for landing and other for launch?  My current hypothetical is using empty built-in weapons slots and an attached plugin script that looks for those particular slots and pops the fighters out of them (in a BSG catapult kinda way) instead of the landing pads.

Possibly with a script that force-sets the location of a fighter to where you want it to be, as it's landing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cjuicy on March 04, 2017, 10:36:03 PM
I can see Fallout style Laser Gatlings cleaving through destroyers like a hundred thousand-degree knives slicing into a stick of butter. Overkill inbound.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: whatdoesthisbuttondo on March 06, 2017, 03:35:04 AM
Is it possible to leave out some elements in the .faction file?

My faction doesn't have capital ships, so I'd like to leave out combatCapital for instance, and
set combatLarge to a really low figure.

So far I've tried to set their preferrence really really low, and fill it with the next best size (cruiser),
but that appears to have them dump tons of cruisers in the market (maybe they dump what they
don't need themselves?).

I remember there was a post explaining the .faction file, but I couldn't find it again for the life of me...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 08, 2017, 10:05:34 AM
I quit trying to figure it out by myself:

I want a simple flavor text in a market that span two entities ora_poincare and ora_devaney, the former being the main one and the id of the market (checked in dev mode by dumping the memory)

I'm using the simplest rule possible:

flavorTextMarketDevaney,TradePanelFlavorText,"$market.id == ora_poincare score:1000","AddText""A whole load of flavor text.""textGrayColor",,,

And yet the text is the default vanilla one. In the meantime I'm using that exact same rule with another id for a single entity market and it work flawlessly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 08, 2017, 10:13:08 AM
Is it possible to leave out some elements in the .faction file?

My faction doesn't have capital ships, so I'd like to leave out combatCapital for instance, and
set combatLarge to a really low figure.

So far I've tried to set their preferrence really really low, and fill it with the next best size (cruiser),
but that appears to have them dump tons of cruisers in the market (maybe they dump what they
don't need themselves?).

I remember there was a post explaining the .faction file, but I couldn't find it again for the life of me...

Set "minPointsForCombatCapital" really high in the doctrine, (say, 100+) and then set "capital" to a low value compared to the other stuff. But, hmm - it probably will result in quite a few cruisers, since it tries to add a capital if there isn't one, adds some cruisers instead, and then tries again in another month. You could set the "fallback" for combatCapital to be combatMedium or combatSmall instead of combatLarge - that should net smaller ships than cruisers.

I quit trying to figure it out by myself:

I want a simple flavor text in a market that span two entities ora_poincare and ora_devaney, the former being the main one and the id of the market (checked in dev mode by dumping the memory)

I'm using the simplest rule possible:

flavorTextMarketDevaney,TradePanelFlavorText,"$market.id == ora_poincare score:1000","AddText""A whole load of flavor text.""textGrayColor",,,

And yet the text is the default vanilla one. In the meantime I'm using that exact same rule with another id for a single entity market and it work flawlessly.

Just FYI, there's detailed logging about which conditions for which rules fail, which rules have the highest scores, and which rules are ultimately picked, so that should generally be helpful in a case like this.

As for this, though, I think the issue is the rule id - flavorTextMarketDevaney, which I'm guessing is a duplicate of a rule that you've got for the other market - so only one of the rules actually gets loaded.

Edit: I don't remember exactly why, but it was non-trivial to make the game detect this is going on. Have run into it myself, it can be pretty confounding. Let me take another look, though. But in any case, looking at the logs should help with situations like this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 08, 2017, 10:28:07 AM
The rule name is unique, I just didn't changed it after finding out ora_poincare was used for the market id instead of ora_devaney.

Anyway found the solution actually: the documentation says that the rules are automatically reloaded in dev mode at every new Dialog interaction? Turns out that it is not the case anymore. I was docking and undocking but it didn't updated the rules.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 08, 2017, 10:32:44 AM
The rule name is unique, I just didn't changed it after finding out ora_poincare was used for the market id instead of ora_devaney.

Anyway found the solution actually: the documentation says that the rules are automatically reloaded in dev mode at every new Dialog interaction? Turns out that it is not the case anymore. I was docking and undocking but it didn't updated the rules.

Ah, ok, gotcha.

The auto-reload only works on the core rules.csv, not on modded ones - sorry about the confusion! Or, rather, it only triggers a reload if the core rules.csv is touched, but it'll reload everything if it is, including modded rules.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Takion Kasukedo on March 11, 2017, 06:55:52 AM
Is there a specific way for projectiles to be unaffected by ship velocity?

And how can you tie a maneuverability system to right-click?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on March 11, 2017, 11:33:18 AM
And how can you tie a maneuverability system to right-click?
I know that you need to use a custom version of Phasing but sadly that is all I know
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Takion Kasukedo on March 12, 2017, 06:52:23 AM
Interesting.

So phase charges are possible. I'll have to experiment when I get into Java Coding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 12, 2017, 09:43:44 AM
Is there a specific way for projectiles to be unaffected by ship velocity?

Hmm - if you made it a missile with very high acceleration, it'd max out at its own top speed quickly and the ship's velocity component would be zeroed out. But then it'd be limited to 600 top speed.

Could also write a script that does this (sets the ship-velocity component to 0), though naturally that's more involved.

And how can you tie a maneuverability system to right-click?

There are going to be issues if you try to do that - for one thing, it'll always use the phase cloak AI, iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on March 12, 2017, 06:00:38 PM
@Takion Kasukedo


The easiest way to do what you want is something like this in a .system file.

{
   "id":"exigency_superCIGEN",
   "type":"PHASE_CLOAK",
   "aiType":"CUSTOM",

   "aiScript":"data.shipsystems.scripts.ai.exigency_SuperCIGENAI",
   "statsScript":"data.shipsystems.scripts.exigency_superCIGENStats",

   "fadeActivationSoundOnChargedown":false,

   "aiHints":{}
}

In effect, creating a ship system to do whatever on right click, using methods not much different from how normal ship systems are created. There is an issue though, that it will lack any sort of UI indicator which can be solved via an everyframe to add a custom one. The most major difference is in the scripts that you call ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK to activate the system. Anyways, this is fairly advanced modding so good luck!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: whatdoesthisbuttondo on March 13, 2017, 03:17:38 AM
Is it possible to have (fixed) shield arcs on two opposing sides of a vessel, i.e. fixed 90 degrees port and starboard?

This being a ship system instead of an actual vanilla shield would fine.

And in a somewhat related question, is it possible for projectiles/missiles to have the ability to pass through a shield,
i.e. bypass the shield arc without doing damage to it, and hitting directly to armor/hull?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on March 13, 2017, 03:41:10 AM
These are fun questions, so even with my limited experience, I'm going to have a go at answering while thinking very hard about what they would entail.

Is it possible to have (fixed) shield arcs on two opposing sides of a vessel, i.e. fixed 90 degrees port and starboard?

This being a ship system instead of an actual vanilla shield would fine.

From what I've seen in all my experience with vanilla and modded Starsector... Maybe. The first thing that comes to mind is something like what Tartiflette has in the wonderful SCY Nation mod (http://fractalsoftworks.com/forum/index.php?topic=8010.0 (http://fractalsoftworks.com/forum/index.php?topic=8010.0)), in which some ships are armoured using independent vessels that can be destroyed separately to the main hull of the ship. That uses fancy code though that I don't want to delve into myself. XD

A simpler way to do what you're looking for is to have a custom drone ship system that launches two [invisible?] drones and keeps them in fixed positions facing apart on either side of the ship (see the Apogee's Sensor Drones for static drones). These custom drones would have 90 degree front-facing shields with a disproportionately large radius, and appear to give their mothership 90 degree fixed broadside shields on both the port and starboard sides. Being independent from the mothership sadly means that damage taken to those shields wouldn't affect the mothership's flux capacity at all, so you risk losing some immersion unless you specifically say "there are drones here producing the shields, not the ship itself".

This is actually a method I believe is related to upcoming features of orbital stations (http://fractalsoftworks.com/2016/09/23/orbital-stations-in-combat/ (http://fractalsoftworks.com/2016/09/23/orbital-stations-in-combat/)). I'm thinking specifically about this particular image:

Spoiler
(http://fractalsoftworks.com/wp-content/uploads/2016/09/station_base.jpg)
[close]



And in a somewhat related question, is it possible for projectiles/missiles to have the ability to pass through a shield,
i.e. bypass the shield arc without doing damage to it, and hitting directly to armor/hull?

Again, I believe the SCY Nation has a "Phase Missile Launcher", that fires missiles which actually use a modified phase cloak to evade point defence fire and obstacles until they are near enough their target to drop back into normal space and impact - although I don't think they can phase through a shield and pop out on the other side. Beyond that, and the apparent ability of the stock Ion Beam to occasionally produce ion "arcs" that jump through (pierce?) shields, I don't know any weapons or ways you can make weapons that can bypass shields.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on March 13, 2017, 04:35:12 AM
These are fun questions, so even with my limited experience, I'm going to have a go at answering while thinking very hard about what they would entail.

Is it possible to have (fixed) shield arcs on two opposing sides of a vessel, i.e. fixed 90 degrees port and starboard?

This being a ship system instead of an actual vanilla shield would fine.

From what I've seen in all my experience with vanilla and modded Starsector... Maybe. The first thing that comes to mind is something like what Tartiflette has in the wonderful SCY Nation mod (http://fractalsoftworks.com/forum/index.php?topic=8010.0 (http://fractalsoftworks.com/forum/index.php?topic=8010.0)), in which some ships are armoured using independent vessels that can be destroyed separately to the main hull of the ship. That uses fancy code though that I don't want to delve into myself. XD

A simpler way to do what you're looking for is to have a custom drone ship system that launches two [invisible?] drones and keeps them in fixed positions facing apart on either side of the ship (see the Apogee's Sensor Drones for static drones). These custom drones would have 90 degree front-facing shields with a disproportionately large radius, and appear to give their mothership 90 degree fixed broadside shields on both the port and starboard sides. Being independent from the mothership sadly means that damage taken to those shields wouldn't affect the mothership's flux capacity at all, so you risk losing some immersion unless you specifically say "there are drones here producing the shields, not the ship itself".

This is actually a method I believe is related to upcoming features of orbital stations (http://fractalsoftworks.com/2016/09/23/orbital-stations-in-combat/ (http://fractalsoftworks.com/2016/09/23/orbital-stations-in-combat/)). I'm thinking specifically about this particular image:

Spoiler
(http://fractalsoftworks.com/wp-content/uploads/2016/09/station_base.jpg)
[close]



And in a somewhat related question, is it possible for projectiles/missiles to have the ability to pass through a shield,
i.e. bypass the shield arc without doing damage to it, and hitting directly to armor/hull?

Again, I believe the SCY Nation has a "Phase Missile Launcher", that fires missiles which actually use a modified phase cloak to evade point defence fire and obstacles until they are near enough their target to drop back into normal space and impact - although I don't think they can phase through a shield and pop out on the other side. Beyond that, and the apparent ability of the stock Ion Beam to occasionally produce ion "arcs" that jump through (pierce?) shields, I don't know any weapons or ways you can make weapons that can bypass shields.
I'm 99% sure that you can't have multiple shields unless either A: You use TWIGLib, which is just Pandora's Box of Dark Code. Or B: You use the upcoming station mechanics that will hopefully be in the game.

As for shield piercing guns? One mod does have them: Exigency. Specifically their CIGEN cannons. However, the mod isn't updated to current vanilla levels and the guns themselves are hard to balance
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 13, 2017, 05:43:38 AM
FYI the implementation is to set the projectile collision type to NONE or some other type that doesn't collide with ships, then manually check each projectile for collision and change the coll. type back when it hits something. Hull-piercing weapons (e.g. the built-in on the Shadowyards Mimir) can be done in the same way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on March 13, 2017, 01:11:48 PM
FYI the implementation is to set the projectile collision type to NONE or some other type that doesn't collide with ships, then manually check each projectile for collision and change the coll. type back when it hits something. Hull-piercing weapons (e.g. the built-in on the Shadowyards Mimir) can be done in the same way.

Ah, I didn't realise "NONE" was a valid option for the collision type. Perhaps I should try mucking around with this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on March 24, 2017, 04:47:55 PM
looking to disable ship collision for a mod idea. I think I did it before so it should be possible. Does anyone know how to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on March 24, 2017, 04:55:01 PM
looking to disable ship collision for a mod idea. I think I did it before so it should be possible. Does anyone know how to do this?

Immediate thought would be to use phase ships, but outside of that I got nothing. *shrug*
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 24, 2017, 07:34:00 PM
CombatEntityAPI.setCollisionClass(CollisionClass.FIGHTER)    // ships (should) collide with projectiles but not each other... maybe, collision after engine flameout is a likely failure case
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on April 02, 2017, 06:13:07 AM
Hi there, I'm new to the plugin making part of modding, and I was wondering : Can I make a weapon that fire EMP arc in front of it (even without actual entities to target) ?
I tried to play with some parts of code, and I managed to make a engine.spawnemp that deal damage, but doesn't show anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 02, 2017, 10:08:25 PM
trying to remove a specific ship from a faction (in this case, centurion_Assault from hegemony). I deleted the entry and they're still showing up. There are no more entries for the ship in the faction's file in world/factions.

am I missing something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 03, 2017, 12:12:34 AM
trying to remove a specific ship from a faction (in this case, centurion_Assault from hegemony). I deleted the entry and they're still showing up. There are no more entries for the ship in the faction's file in world/factions.

am I missing something?

Are they still showing up in a game you had already been playing with for a bit, or in a game you started after you removed the variant from the file?

Are you sure the variant is the same? There are two stock variants of the Centurion if I remember correctly, though I'm unsure if the Hegemony use both.

Did you remove it from every location in the file? Sometimes a ship variant may be used to fulfill several different roles in the same faction. Re-read your OP and apparently you did.

EDIT: Also... Why exactly are you trying to remove the Centurion from Hegemony fleets?  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cjuicy on April 06, 2017, 12:14:30 PM
Is there a way to make a player-only hullmod, unusable by Dynasector?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on April 06, 2017, 01:36:34 PM
Is there a way to make a player-only hullmod, unusable by Dynasector?
If your mod is not integrated with vanilla or Dynasector, then any mod you make won't be used by Dyna
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on April 09, 2017, 02:57:51 AM
Another question that came when I was playing with projectiles and missile collision class : Which is the most efficient way, in a plugin, to know if the projectile/missile will score a hit on anything (ship, projectile, asteroid) at a given range ?
I was playing a bit with :
Code
Vector2f projection = new Vector2f(collideDistance, 0f);
                    Vector2f location = proj.getLocation();

                    //List<ShipAPI> checkList = engine.getShips();
                    //List<ShipAPI> finalList = new LinkedList<>();
                    Vector2f point = CollisionUtils.getCollisionPoint(location, projection, proj);
                    if (point != null && MathUtils.getDistance(location, point) <= collideDistance) {
                        //Do something, change a variable, etc... In this case, change the collisionRadius and the collisionClass back to something that may hit the entity
                    }
But that doesn't seems to work, and I guess it's because my projectile is actually a missile with collisionRadius = 0 and collisionClass = NONE. Does that make "getCollisionPoint" null ?
Is there any other way to detect if a projectile without collision will intercept another entity ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 17, 2017, 05:10:36 AM
A bit late but:
Another question that came when I was playing with projectiles and missile collision class : Which is the most efficient way, in a plugin, to know if the projectile/missile will score a hit on anything (ship, projectile, asteroid) at a given range ?
I was playing a bit with :
Code
Vector2f projection = new Vector2f(collideDistance, 0f);
                    Vector2f location = proj.getLocation();

                    //List<ShipAPI> checkList = engine.getShips();
                    //List<ShipAPI> finalList = new LinkedList<>();
                    Vector2f point = CollisionUtils.getCollisionPoint(location, projection, proj);
                    if (point != null && MathUtils.getDistance(location, point) <= collideDistance) {
                        //Do something, change a variable, etc... In this case, change the collisionRadius and the collisionClass back to something that may hit the entity
                    }
But that doesn't seems to work, and I guess it's because my projectile is actually a missile with collisionRadius = 0 and collisionClass = NONE. Does that make "getCollisionPoint" null ?
Is there any other way to detect if a projectile without collision will intercept another entity ?
getCollisionPoint doesn't check collision class, only the vectors. Collision radius of zero might break it though. (Right-click on the method in your IDE and go to the method source to see details)
Your third arg for the method call needs to be whichever entity the projectile might hit, not the projectile itself.
Also the variable assigned to projection means it'll only work for projectiles flying horizontally. To get the proper projection, multiply the projectile's velocity by the how far to extrapolate in seconds.

Although depending on what you're doing, you probably shouldn't even be using getCollisionPoint, just CombatUtils.getShipsWithinRange and the equivalent methods for missiles/asteroids followed by CollisionUtils.isPointWithinBounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on April 17, 2017, 07:20:27 AM
Oh, so that's why. Thanks, I'll try that this week and see if I can manage to make my weapon work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cjuicy on April 20, 2017, 07:00:48 PM
Is there a way to make a weapon mountable on any type of weapon slot? (Like a universal weapon type, fitting on ballistic, missile, and energy?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on April 20, 2017, 09:49:14 PM
I'm trying to port over a mod from 72 and I can't seem to get it to work... It doesn't crash but it doesn't work either
Spoiler
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class test extends BaseHullMod {

    public static final float DEPLOYMENT_PENALTY = 30f;
    public static final float LOGISTICS_BONUS = 30f;

    @Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        stats.getSuppliesPerMonth().modifyMult(id, 1f - LOGISTICS_BONUS * 0.01f);
        stats.getSuppliesToRecover().modifyMult(id, 1f - LOGISTICS_BONUS * 0.01f);
        stats.getCRPerDeploymentPercent().modifyMult(id, 1f - DEPLOYMENT_PENALTY * 0.01f);
    }

    @Override
    public String getDescriptionParam(int index, HullSize hullSize) {
        if (index == 0) {
            return "" + (int) LOGISTICS_BONUS;
        }
        if (index == 1) {
            return "" + (int) DEPLOYMENT_PENALTY;
        }
        return null;
    }
}
[close]
It is supposed to reduce the deployment by a percentage
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 22, 2017, 05:19:53 AM
Is com.fs.starfarer.api.impl.campaign.rulecmd.newgame not actually a usable package, or is there another reason my class can't be found while in it?

Code
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [NGCGetExerelinDefaults] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame

EDIT: Happening with a rule command in plain old com.fs.starfarer.api.impl.campaign.rulecmd as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on April 22, 2017, 05:40:05 AM
How are hull entries hidden from the codex? I'm looking through the hidden skins (the Pirate Shade entry isn't hidden by the way, although Pirate Afflictor is) and I can't tell what's different in the skin file. Must be somewhere else?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on April 22, 2017, 05:49:12 AM
How are hull entries hidden from the codex? I'm looking through the hidden skins (the Pirate Shade entry isn't hidden by the way, although Pirate Afflictor is) and I can't tell what's different in the skin file. Must be somewhere else?
The Afflictor has the descriptionid of "wolf". Which is weird. I assume that it should be "afflictor". Changing it doesn't seem to make it visible in the codex, however.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SainnQ on April 22, 2017, 06:18:26 AM
How difficult is it to utilize the ship editor & modify the bonuses Hullmods provide?

I would really like to try experimenting with some ship variants that utilize High Resolution Sensor & Survey Equipment Hullmods of various bonuses.

It seems odd that there aren't more ships added with .8a that already carry these. Beside the usual like the Apogee (Which is the only High Res Sensors ship I know of off-hand)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on April 22, 2017, 06:20:57 AM
How difficult is it to utilize the ship editor & modify the bonuses Hullmods provide?

I would really like to try experimenting with some ship variants that utilize High Resolution Sensor & Survey Equipment Hullmods of various bonuses.

It seems odd that there aren't more ships added with .8a that already carry these. Beside the usual like the Apogee (Which is the only High Res Sensors ship I know of off-hand)
It's relatively simple, although you should use a program that can compile everything into a .jar file. I use Eclipse, personally. It's mostly just changing a couple of numbers and taking examples from Alex's code, if you aren't comfortable writing anything entirely new.

Ship variants are very easy, especially if you're making it as a skin (like ingame D variants or the XIV variants) of an existing ship. Look at vanilla skins for a template.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on April 22, 2017, 07:54:23 AM
Strange. Replacing a core skin with a mod one that's basically identical makes previously Codex-invisible entries visible. Why...?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2017, 09:54:25 AM
Is com.fs.starfarer.api.impl.campaign.rulecmd.newgame not actually a usable package, or is there another reason my class can't be found while in it?

Code
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [NGCGetExerelinDefaults] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame

EDIT: Happening with a rule command in plain old com.fs.starfarer.api.impl.campaign.rulecmd as well.

So it's just straight up not finding *any* rule commands from a mod, or only specific ones?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2017, 09:55:38 AM
Strange. Replacing a core skin with a mod one that's basically identical makes previously Codex-invisible entries visible. Why...?

Skins that are "compatible" with the base hull (i.e. have the same weapon mounts etc) don't show in the Codex to avoid clutter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on April 22, 2017, 10:05:51 AM
Strange. Replacing a core skin with a mod one that's basically identical makes previously Codex-invisible entries visible. Why...?

Skins that are "compatible" with the base hull (i.e. have the same weapon mounts etc) don't show in the Codex to avoid clutter.

I can't quite understand the rules for this. E.g. Hegemony Wolf shows up in the Codex (despite being identical to the base Wolf other than a paintjob), but Pirate Afflictor (having D-mods and losing weapon mounts) or Buffalo (having Shielded Cargo Holds and a ballistic instead of an energy mount) doesn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2017, 10:08:53 AM
Ok, I lied - looking at the code, it filters out (D) hulls. The shade has a "- Pirates" at the end so it doesn't get picked up. Yes, it's hacky.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on April 22, 2017, 10:18:54 AM
Ok, I lied - looking at the code, it filters out (D) hulls. The shade has a "- Pirates" at the end so it doesn't get picked up. Yes, it's hacky.

 :D Heh, cool. That explains why they show up in the Codex when I edit Pirate hulls from (D) to (P) then. ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 22, 2017, 11:27:19 AM
Three short ones:
I can't remember what was the function to clear out Hyperspace nebulas around a point. This will be necessary now that custom made system can be placed well within deep hyper.

The procgen also seems to ignore them when placing its own stars, leading to some pretty bad overlap. Is it possible to clear out those as well?

And the most problematic: Systems with a custom star don't seem to spawn at all. I added it to the star_gen_data.csv but the system isn't visible in the campaign. It is however present in the intel screen's planet list, but the game crashed when trying to watch it. Am I missing something there? No idea why that system won't show but it doesn't work with a vanilla star either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2017, 11:58:27 AM
Three short ones:
I can't remember what was the function to clear out Hyperspace nebulas around a point. This will be necessary now that custom made system can be placed well within deep hyper.

Use NebulaEditor - see StarSystemGenerator.java, line 419 for use example.

The procgen also seems to ignore them when placing its own stars, leading to some pretty bad overlap. Is it possible to clear out those as well?

If your star system is added before progren runs, it should consider them the same way it considers the vanilla systems; that's not hardcoded. I suspect the issue may be your systems being added after procgen? Not 100% sure, obviously.

And the most problematic: Systems with a custom star don't seem to spawn at all. I added it to the star_gen_data.csv but the system isn't visible in the campaign. It is however present in the intel screen's planet list, but the game crashed when trying to watch it. Am I missing something there? No idea why that system won't show but it doesn't work with a vanilla star either.

I'm not sure what you were trying to do, so it's hard to say. A possibly relevant note: star_gen_data still requires a star to be defined in planets.json etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on April 22, 2017, 12:10:33 PM
Code
34509 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Filenames are case-sensitive, [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Raccoon's Arms Pack\jars\raccoonarms.jar] vs [C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Raccoon's Arms Pack\jars\raccoonarms.jar]
java.lang.RuntimeException: Filenames are case-sensitive, [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Raccoon's Arms Pack\jars\raccoonarms.jar] vs [C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Raccoon's Arms Pack\jars\raccoonarms.jar]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I know this is to stop Linux crashes, but how is it fixed? Everything seems to be in the same cases. And why is it pointing to starsector-core?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 22, 2017, 12:10:47 PM
If your star system is added before progren runs, it should consider them the same way it considers the vanilla systems; that's not hardcoded. I suspect the issue may be your systems being added after procgen? Not 100% sure, obviously.
Hum, ok good, but why would my systems be added after? I add them in the SectorGeneratorPlugin like all the vanilla systems.


Quote
I'm not sure what you were trying to do, so it's hard to say. A possibly relevant note: star_gen_data still requires a star to be defined in planets.json etc.
It was just me forgetting to un-comment the wormhole auto-generation...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2017, 12:24:55 PM
@InventorRaccoon: hotfix! (resolves the crash)

Hum, ok good, but why would my systems be added after? I add them in the SectorGeneratorPlugin like all the vanilla systems.

That's weird. Do you have a minimal-ish mod I can try this with?

It was just me forgetting to un-comment the wormhole auto-generation...

Ah, ok.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 22, 2017, 02:25:11 PM
What do the fighter wing changes do? There are new entires and some are not clear

Code
id,variant,tags,tier,rarity,fleet pts,op cost,formation,range,attackRunRange,num,role,role desc,refit,base value,,,,,,,,,,,,,number

broadsword_wing,broadsword_Fighter,"fighter4, fighter, low",0,,6,8,V,4000,500,3,FIGHTER,Heavy Fighter,10,6000,,,,,,,,,,,,,1

what are all the tags?
what does fighter4, fighter3, fighter2 do?
Tier?
rarity?
num?
 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 22, 2017, 09:35:16 PM
Is com.fs.starfarer.api.impl.campaign.rulecmd.newgame not actually a usable package, or is there another reason my class can't be found while in it?

Code
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [NGCGetExerelinDefaults] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame

EDIT: Happening with a rule command in plain old com.fs.starfarer.api.impl.campaign.rulecmd as well.

So it's just straight up not finding *any* rule commands from a mod, or only specific ones?
It fails with any rule commands in a mod, as far as I can tell.

I added this to a mod that did not have any rules commands before:
Code: java
package com.fs.starfarer.api.impl.campaign.rulecmd;

import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.util.Misc;
import java.util.List;
import java.util.Map;

public class TestRuleCmd extends BaseCommandPlugin {
   
    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
        return true;
    }
}

Code: csv
id,trigger,conditions,script,text,options,notes
myTestRule,OpenCommLink,TestRuleCmd,,La la la la la,,

And got the same error.
Spoiler
Code
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [TestRuleCmd] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame

at com.fs.starfarer.campaign.rules.A.<init>(Unknown Source)
at com.fs.starfarer.campaign.rules.Rules.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.for(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

(it also happens if the rules command is used as a script action instead of a condition)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on April 23, 2017, 02:47:46 AM
What exactly do these two lines in settings.json do?

Quote
   "officerAIMax":10,
   "baseNumOfficers":4;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 23, 2017, 03:35:27 AM
What exactly do these two lines in settings.json do?

Quote
   "officerAIMax":10,
   "baseNumOfficers":4;

Educated guess:

officerAIMax: Maximum level your officers can reach? Alternatively, could be the maximum number of officers, although seems unlikely.

baseNumOfficers: The maximum number of officers you can command at the start. Default is 4, but you can increase that with one of the Command skills (can't remember which).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 23, 2017, 06:40:56 AM
I'm pretty sure officerAIMax is the maximum number of officers an NPC fleet can have.

The officer level cap is 20, btw
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 09:17:50 AM
Is com.fs.starfarer.api.impl.campaign.rulecmd.newgame not actually a usable package, or is there another reason my class can't be found while in it?

Code
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [NGCGetExerelinDefaults] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame

EDIT: Happening with a rule command in plain old com.fs.starfarer.api.impl.campaign.rulecmd as well.

So it's just straight up not finding *any* rule commands from a mod, or only specific ones?
It fails with any rule commands in a mod, as far as I can tell.

I added this to a mod that did not have any rules commands before:
Code: java
package com.fs.starfarer.api.impl.campaign.rulecmd;

import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.util.Misc;
import java.util.List;
import java.util.Map;

public class TestRuleCmd extends BaseCommandPlugin {
   
    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
        return true;
    }
}

Code: csv
id,trigger,conditions,script,text,options,notes
myTestRule,OpenCommLink,TestRuleCmd,,La la la la la,,

And got the same error.
Spoiler
Code
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [TestRuleCmd] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame

at com.fs.starfarer.campaign.rules.A.<init>(Unknown Source)
at com.fs.starfarer.campaign.rules.Rules.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.for(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

(it also happens if the rules command is used as a script action instead of a condition)

Could you possibly send me a copy? Would make testing a bit easier.


I'm pretty sure officerAIMax is the maximum number of officers an NPC fleet can have.


Right.

what are all the tags?
Tier?
rarity?

Mostly/entirely used for drop generation. See: drop_groups.csv.

what does fighter4, fighter3, fighter2 do?

For autofit - kind of wing, and tier within that group.

num?

Internal, for sorting the spreadsheet. Not used by the game.

(Sorry this is a bit brief...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on April 23, 2017, 10:25:23 AM
After dabbling in station mechanics, got a couple of questions.

Firstly, any way to make it so that stations will appear in markets with modules? If you stick a variant into the .faction file, it'll appear in markets, but only as a blank base, no modules, and there isn't a way to attach modules. I don't think it works like a built-in weapon, just putting in the variant name of the module instead of a weapon name isn't accepted.

Secondly, what makes it so that stations explode on death? STATION tag? Presence of modules? It's great for large stations where all of their defenses and weapons are on modules, but on a smaller (around the size of a destroyer) station where the main section isn't invulnerable and has weapons, it makes balance trickier. You either have to make the modules very strong (so it's harder to actually make any progress in weakening the station) or risk having the entire station just blown away by two bombing runs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 10:31:41 AM
Firstly, any way to make it so that stations will appear in markets with modules? If you stick a variant into the .faction file, it'll appear in markets, but only as a blank base, no modules, and there isn't a way to attach modules. I don't think it works like a built-in weapon, just putting in the variant name of the module instead of a weapon name isn't accepted.

You'll need to add it directly to that submarket's cargo (i.e. getCargo().getMothballedShips().addFleetMember()). If it's through the .faction file, all you'll get is the stripped hull.

Secondly, what makes it so that stations explode on death? STATION tag? Presence of modules? It's great for large stations where all of their defenses and weapons are on modules, but on a smaller (around the size of a destroyer) station where the main section isn't invulnerable and has weapons, it makes balance trickier. You either have to make the modules very strong (so it's harder to actually make any progress in weakening the station) or risk having the entire station just blown away by two bombing runs.

I forget exactly, but if you're thinking that the base of the station could be destroyed and the modules could survive and fight on, that's going to be tricky for various reasons. For one, the station will register as disabled post-combat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on April 23, 2017, 10:34:16 AM
It fails with any rule commands in a mod, as far as I can tell.
Could you possibly send me a copy? Would make testing a bit easier.

Can confirm this. No rule commands are found no matter where I put them (even if I do the "ruleCommandPackages" in settings.json). I'll see if I can send you copy for testing.

*edit - sent via pm
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 10:47:57 AM
Thanks! Checking it out now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on April 23, 2017, 10:55:49 AM
I forget exactly, but if you're thinking that the base of the station could be destroyed and the modules could survive and fight on, that's going to be tricky for various reasons. For one, the station will register as disabled post-combat.
Grargh, I must have had a brain fart and left out some very important words. What makes a station explode when the MODULES are destroyed? My example is a small station with 2 weapon platforms, and a large mount on the base, and no Vast Bulk. There's no need for the station to die immediately when both modules are disabled, because it can still fight and can still be destroyed. Another example would be a theoretical Onslaught with both wings as modules. Instead of just immediately suffering a catastrophic failure and detonating, you'd expect it to fight on.

Independent modules that can fight on their own sounds very funky.

And by the way, did you fix that bug with non-stations having modules? My Conquest with broadside shields is now working perfectly (except for the shields deciding not to raise themselves, while I think can be fixed with a hullmod just like how Axial Rotation forces a ship to always turn right)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on April 23, 2017, 10:57:37 AM
I really like that update a lot, mostly for the new way carriers works, which lead to an important question for me : I've seen that carrier can use a built-in wing and multiple customisable others decks, but is there a way to make multiples built-in wings in a unique ship ?
I have a drone carrier that could have some benefit from using separate drones instead of a fixed drone wings (since they tends to stay close to theirs buddies, and got easily killed).
Does the
Code
"builtInWings": ["NRT_drone_birdofprey_wing"],
can be used mutiple times in a hull file, with each line adding another built-in wing ?
Or is there some way to add multiple built-in wings into that line, that way :
Code
"builtInWings": ["NRT_drone_birdofprey_wing","NRT_drone_birdofprey_wing","NRT_drone_birdofprey_wing"],
?

Also, on another hand, where can I ask some help for more complex plugins and scripts making ? I'm kinda stuck with two new contraption that doesn't work as intended, I'm asking here and there for some bits of help but I always end up in another dead end when I finally manage to make something that work and goes on to the next thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 11:07:27 AM
Can confirm this. No rule commands are found no matter where I put them (even if I do the "ruleCommandPackages" in settings.json). I'll see if I can send you copy for testing.

*edit - sent via pm

Alright, fixed it - turns out it was using the wrong classloader.

Or is there some way to add multiple built-in wings into that line, that way :
Code
"builtInWings": ["NRT_drone_birdofprey_wing","NRT_drone_birdofprey_wing","NRT_drone_birdofprey_wing"],
?

That should work, yeah. Make sure the ship_data.csv entry has the right number of fighter bays, too.

Also, on another hand, where can I ask some help for more complex plugins and scripts making ? I'm kinda stuck with two new contraption that doesn't work as intended, I'm asking here and there for some bits of help but I always end up in another dead end when I finally manage to make something that work and goes on to the next thing.

I'd say a thread in this subforum is probably best. And/or maybe discord? Not sure.

Grargh, I must have had a brain fart and left out some very important words. What makes a station explode when the MODULES are destroyed? My example is a small station with 2 weapon platforms, and a large mount on the base, and no Vast Bulk. There's no need for the station to die immediately when both modules are disabled, because it can still fight and can still be destroyed. Another example would be a theoretical Onslaught with both wings as modules. Instead of just immediately suffering a catastrophic failure and detonating, you'd expect it to fight on.

Ahh, gotcha. Looks like that's actually hardcoded at the moment, added to the list.

You could get around it for now by putting an invisible module with at least 1 OP somewhere on the middle of the ship and making it invulnerable.

And by the way, did you fix that bug with non-stations having modules? My Conquest with broadside shields is now working perfectly (except for the shields deciding not to raise themselves, while I think can be fixed with a hullmod just like how Axial Rotation forces a ship to always turn right)

Not yet, but it's on my list the the .1 release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on April 23, 2017, 11:19:04 AM
Can confirm this. No rule commands are found no matter where I put them (even if I do the "ruleCommandPackages" in settings.json). I'll see if I can send you copy for testing.

*edit - sent via pm

Alright, fixed it - turns out it was using the wrong classloader.

Thanks- that's awesome! Any chance I could get a copy of the fixed build for modding purposes? (can't do too much on my end until I can make it to the main menu)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cjuicy on April 23, 2017, 11:50:34 AM
Is there a way to make a ship always recoverable through a built-in hullmod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 12:12:19 PM
Is there a way to make a ship always recoverable through a built-in hullmod?

See: reinforced hull.

Thanks- that's awesome! Any chance I could get a copy of the fixed build for modding purposes? (can't do too much on my end until I can make it to the main menu)

Will send a PM in a bit.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on April 23, 2017, 12:17:18 PM
Or is there some way to add multiple built-in wings into that line, that way :
Code
"builtInWings": ["NRT_drone_birdofprey_wing","NRT_drone_birdofprey_wing","NRT_drone_birdofprey_wing"],
That should work, yeah. Make sure the ship_data.csv entry has the right number of fighter bays, too.
Look like it's working, now they're way better at intercepting small fightercrafts.

Also, on another hand, where can I ask some help for more complex plugins and scripts making ? I'm kinda stuck with two new contraption that doesn't work as intended, I'm asking here and there for some bits of help but I always end up in another dead end when I finally manage to make something that work and goes on to the next thing.

I'd say a thread in this subforum is probably best. And/or maybe discord? Not sure.
Does this forum have a discord ? :o If that's the case I didn't knew x)
Yeah, that should do it. There is a lot of things that I've been trying without getting anywhere while learning how scripts works in StarSector. I'll make a thread this week then, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 23, 2017, 12:47:41 PM
I don't remember exactly if it's on purpose or not, but the weapons on a ship with modules can hit the modules. So right now it's either "Fighter" armor modules but no asteroids/ship collisions, or all the weapons on the modules and no arc overlap.

Too much excitement, not enough testing...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 12:56:19 PM
Thanks, made a note.

... or all the weapons on the modules and no arc overlap.

Arc overlap should be fine, though - weapons on modules can't hit modules. Or the main hull, I think? Not 100% sure of the latter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on April 23, 2017, 01:00:24 PM
It seems to me that weapons on the main hull should not be able to hit modules - yet, that's the case right now?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 23, 2017, 01:03:07 PM
I'll double check then, it could be a scripted beam problem on my end, but it might be a tough one to solve if that's the case.

[edit] Okay never-mind, I tested it with a few weapon, but it didn't occurred to me that all the weapon on that particular variant had the same scripted beam effect that collided on the modules... This won't be an easy one to fix though. Sorry for the false alarm, modules are awesome! And the conversion from our hacky Twiglib completely painless.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: murumuru on April 23, 2017, 02:22:54 PM
Is it possible to make unique officers nowadays?

Basically, I want to create some officer with unique name and unique portrait and let them spawn in the universe.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 07:19:40 PM
Is it possible to make unique officers nowadays?

Basically, I want to create some officer with unique name and unique portrait and let them spawn in the universe.

Yes, though it'll take a bit of coding. See: OfficerManagerEvent in starfarer.api.zip.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on April 23, 2017, 07:56:19 PM
Question: How many levels would it take to max out officer skills?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Moldernado on April 23, 2017, 07:58:27 PM
Is it possible to increase the commission payment somewhere in the files? Sometimes I want to be rewarded for fighting the factions enemies, not just barely scraping by
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: coyote.j.p.m on April 23, 2017, 08:09:07 PM
I have a modded system that spawns in just fine and appears to work perfectly as coded if I find it on the map, travel there and fly around interacting with things. However, every time I click on it from the intel screen (to bring up the planets display), the game crashes with the following error:

Code
java.lang.RuntimeException: Circular dependency of sibling positions detected
at com.fs.starfarer.ui.for.o00000(Unknown Source)
at com.fs.starfarer.ui.for.recompute(Unknown Source)
at com.fs.starfarer.ui.o00O.pack(Unknown Source)
at com.fs.starfarer.campaign.ui.intel.O0oO.afterSizeFirstChanged(Unknown Source)
at com.fs.starfarer.ui.o00O.sizeChanged(Unknown Source)
at com.fs.starfarer.ui.for.setSize(Unknown Source)
at com.fs.starfarer.campaign.ui.intel.B.?0000(Unknown Source)
at com.fs.starfarer.ui.newui.J$7.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newui.J.setCurrentTab(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.showCoreUITab(Unknown Source)
at com.fs.starfarer.coreui.map.oOOO.o00000(Unknown Source)
at com.fs.starfarer.coreui.map.U.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Any ideas as to what I might be doing wrong? It's odd that only the intel screen crashes it, when the actual planets and their satellites spawn in just fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on April 23, 2017, 08:10:50 PM
Is it possible to increase the commission payment somewhere in the files? Sometimes I want to be rewarded for fighting the factions enemies, not just barely scraping by
Yep! It is in the setting file. Look for "factionCommissionBounty":300,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 08:24:49 PM
I have a modded system that spawns in just fine and appears to work perfectly as coded if I find it on the map, travel there and fly around interacting with things. However, every time I click on it from the intel screen (to bring up the planets display), the game crashes with the following error:

Can you PM me a download link? I can take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Moldernado on April 23, 2017, 08:32:55 PM
Is it possible to increase the commission payment somewhere in the files? Sometimes I want to be rewarded for fighting the factions enemies, not just barely scraping by
Yep! It is in the setting file. Look for "factionCommissionBounty":300,

Thanks alot man.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on April 23, 2017, 08:47:59 PM
Is it possible to determine which weapon group the player has selected?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2017, 09:03:09 PM
Is it possible to determine which weapon group the player has selected?

... not entirely sure, don't think so - but there could be some non-obvious way to do it.

Added ShipAPI.getSelectedGroupAPI().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 24, 2017, 12:54:48 AM
what are all the tags?
Tier?
rarity?

Mostly/entirely used for drop generation. See: drop_groups.csv.

what does fighter4, fighter3, fighter2 do?

For autofit - kind of wing, and tier within that group.

num?

Internal, for sorting the spreadsheet. Not used by the game.

(Sorry this is a bit brief...)


This should be really explained in more depth.
Plenty of people who are trying to update their mods are left scratching their heads since they have no idea what effect some fields actually have or the value ranges or anything.

You should really make a detailed post with changes to ships/fighters/weapon and what the new fields/values do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 24, 2017, 01:04:08 AM
This should be really explained in more depth.
Plenty of people who are trying to update their mods are left scratching their heads since they have no idea what effect some fields actually have or the value ranges or anything.

You should really make a detailed post with changes to ships/fighters/weapon and what the new fields/values do.
Actually this is very self-explanatory. Tier has always been there for weapons and is the same here, rarity is what it says on the tin, tags are mentioned in the patch notes, and num has always been there. Of all the things that changed, those are the most straightforward.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 24, 2017, 01:19:27 AM
I can find nothing about the tags in the OP.

So why are there so many tags?
How do I now define number of fighters in a wing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 24, 2017, 01:35:18 AM
In ships.xml...waht do these do:

supplies/rec,supplies/mo,hints,breakProb,minPieces,maxPieces,number
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 24, 2017, 01:40:46 AM
In ships.xml...waht do these do:

supplies/rec,supplies/mo,hints,breakProb,minPieces,maxPieces,number


supplies/rec: The number of supplies the ship consumes to repair after combat (not sure how relevant this is to actual game scenarios)

supplies/mo: Monthly maintenance supply cost of the ship

hints: Tags that tell the game what kind of ship it is, regarding things like commands. "Rally Civilian Craft" will rally all craft with the "CIVILIAN" tag for instance.

breakProb: Upon being disabled, the chance the ship breaks into pieces

minPieces: Minimum number of pieces the ship can break into

maxPieces: Maximum number of pieces the ship can break into

number: An id that isn't actually used in any way, and can be safely ignored
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 24, 2017, 01:42:19 AM
... On a similar note, we really need a comprehensive explanation of all the keys in the various .csv files. I agree with @Tartiflette that most of them are actually quite self-explanatory, but it might still be useful as a reference, perhaps also with examples of ships in the stock game as a good baseline.

Anyone mind if I have a crack at this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 24, 2017, 03:26:38 AM
How do I now define number of fighters in a wing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 24, 2017, 03:40:09 AM
How do I now define number of fighters in a wing?

Spoiler
(http://i.imgur.com/6nhllK1.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 24, 2017, 03:53:26 AM
How do I tell within a reportBattleFinished call if a ship was disabled and then recovered after the battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 24, 2017, 04:06:19 AM
How do I now define number of fighters in a wing?

Spoiler
(http://i.imgur.com/6nhllK1.png)
[close]

How do you get the xml to separate the text in columan? For me it just dump everything in the first one if I open with excell

EDIT: NEvermind, I think I got it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 24, 2017, 09:14:15 AM
How do I tell within a reportBattleFinished call if a ship was disabled and then recovered after the battle?

I don't believe you can.


This should be really explained in more depth.
Plenty of people who are trying to update their mods are left scratching their heads since they have no idea what effect some fields actually have or the value ranges or anything.

You should really make a detailed post with changes to ships/fighters/weapon and what the new fields/values do.

Ideally, yeah, but things are a bit hectic right now so it's not really a good option.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 24, 2017, 11:34:10 AM
Hello everyone!

I'm trying to revive my old mod again and get it to run with Starsector 0.8, problem is there's quite a lot of old code not working anymore.
I've got this script in particular:
Spoiler
package data.scripts.plugins;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lwjgl.util.vector.Vector2f;

public class Greifer_effect implements BeamEffectPlugin
{
    private IntervalUtil tracker = new IntervalUtil(0.1f, 0.2f);
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        tracker.advance(amount);
       
        CombatEntityAPI target = beam.getDamageTarget();
        //Do we have a valid Entity to effect?
        if (target != null)
        {
            //Yes!  Is it in range, and the beam's on?
            if (beam.getBrightness() >= 1f)
            {
                if(tracker.intervalElapsed())
                {
                    float force = 0f;
                    Vector2f dir;

                    if(target instanceof ShipAPI)
                    {
                        ShipAPI ship = (ShipAPI) target;
                        ShipAPI source = beam.getSource();
                        ShipSystemAPI cloak = ship.getPhaseCloak();
                        if (cloak != null && cloak.isActive())
                        {
                                return;
                        }

                        if(ship != beam.getSource())
                        {
                            force = 15 - (source.getMass() /255);            
                     
                            dir = (Vector2f) VectorUtils.getDirectionalVector(beam.getSource(), target).scale(force);
                            Vector2f.add(source.getVelocity(), dir, source.getVelocity());
                        }
                    }
                    else
                    {
                        if(target != beam.getSource())
                        {
                            force = Math.max(1 / target.getMass() * 15000f, 0.01f);
                            dir = (Vector2f) VectorUtils.getDirectionalVector(beam.getSource(), target).scale(force);
                            Vector2f.add(target.getVelocity(), dir, target.getVelocity());     
                        }
                    }
                }
            }
        }
    }   
}
[close]

and it throws this crash error at me:
Spoiler
17070 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.plugins.Greifer_effect]
java.lang.RuntimeException: Error compiling [data.scripts.plugins.Greifer_effect]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/plugins/Greifer_effect.java', Line 49, Column 79: No applicable constructor/method found for actual parameters "com.fs.starfarer.api.combat.ShipAPI, com.fs.starfarer.api.combat.CombatEntityAPI"; candidates are: "public static org.lwjgl.util.vector.Vector2f org.lazywizard.lazylib.VectorUtils.getDirectionalVector(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.Vector2f)"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/plugins/Greifer_effect.java', Line 49, Column 79: No applicable constructor/method found for actual parameters "com.fs.starfarer.api.combat.ShipAPI, com.fs.starfarer.api.combat.CombatEntityAPI"; candidates are: "public static org.lwjgl.util.vector.Vector2f org.lazywizard.lazylib.VectorUtils.getDirectionalVector(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.Vector2f)"
[close]

It would be great if anyone could help me get BGE up to date again, thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HELMUT on April 24, 2017, 11:53:31 AM
I genuinely thought you were dead or something.

Glad i'm wrong, i hope to see your space crabs soon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: coyote.j.p.m on April 24, 2017, 12:15:55 PM
Hello everyone!

I'm trying to revive my old mod again and get it to run with Starsector 0.8, problem is there's quite a lot of old code not working anymore.
I've got this script in particular:
Spoiler
package data.scripts.plugins;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lwjgl.util.vector.Vector2f;

public class Greifer_effect implements BeamEffectPlugin
{
    private IntervalUtil tracker = new IntervalUtil(0.1f, 0.2f);
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
    {
        tracker.advance(amount);
       
        CombatEntityAPI target = beam.getDamageTarget();
        //Do we have a valid Entity to effect?
        if (target != null)
        {
            //Yes!  Is it in range, and the beam's on?
            if (beam.getBrightness() >= 1f)
            {
                if(tracker.intervalElapsed())
                {
                    float force = 0f;
                    Vector2f dir;

                    if(target instanceof ShipAPI)
                    {
                        ShipAPI ship = (ShipAPI) target;
                        ShipAPI source = beam.getSource();
                        ShipSystemAPI cloak = ship.getPhaseCloak();
                        if (cloak != null && cloak.isActive())
                        {
                                return;
                        }

                        if(ship != beam.getSource())
                        {
                            force = 15 - (source.getMass() /255);            
                     
                            dir = (Vector2f) VectorUtils.getDirectionalVector(beam.getSource(), target).scale(force);
                            Vector2f.add(source.getVelocity(), dir, source.getVelocity());
                        }
                    }
                    else
                    {
                        if(target != beam.getSource())
                        {
                            force = Math.max(1 / target.getMass() * 15000f, 0.01f);
                            dir = (Vector2f) VectorUtils.getDirectionalVector(beam.getSource(), target).scale(force);
                            Vector2f.add(target.getVelocity(), dir, target.getVelocity());     
                        }
                    }
                }
            }
        }
    }   
}
[close]

and it throws this crash error at me:
Spoiler
17070 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.plugins.Greifer_effect]
java.lang.RuntimeException: Error compiling [data.scripts.plugins.Greifer_effect]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/plugins/Greifer_effect.java', Line 49, Column 79: No applicable constructor/method found for actual parameters "com.fs.starfarer.api.combat.ShipAPI, com.fs.starfarer.api.combat.CombatEntityAPI"; candidates are: "public static org.lwjgl.util.vector.Vector2f org.lazywizard.lazylib.VectorUtils.getDirectionalVector(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.Vector2f)"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/plugins/Greifer_effect.java', Line 49, Column 79: No applicable constructor/method found for actual parameters "com.fs.starfarer.api.combat.ShipAPI, com.fs.starfarer.api.combat.CombatEntityAPI"; candidates are: "public static org.lwjgl.util.vector.Vector2f org.lazywizard.lazylib.VectorUtils.getDirectionalVector(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.Vector2f)"
[close]

It would be great if anyone could help me get BGE up to date again, thanks in advance!

Just purely from looking at the error, it looks likethe VectorUtils.getDirectionalVector function from lazylib is expecting 2 Vector2f objects to be passed as parameters, rather than the currently passed ShipAPI and CombatEntityAPI objects. You can call getLocation() on these two parameters to get their coordinates to pass to the function instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 24, 2017, 12:37:58 PM
Thanks Coyote but I still don't really know how to do it now since I don't really understand coding and had a lot of help or codebashed a lot for BGE.

I think I would be better off if I could tell someone what my ships are intended to do and I would do art and animation ...

Edit: Everything I still got from BGE is a total mess btw, I really don't know anymore what would even be modifiable to work and what not.
Best would be to start from scratch I guess ...

Edit: Okay, I fixed that script I think.
But now I got this:
Spoiler
22128 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.AbstractMethodError
java.lang.AbstractMethodError
   at com.fs.starfarer.title.ooOO.o0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO$Oo.?0000(Unknown Source)
   at com.fs.starfarer.combat.A.new.new(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.render(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 24, 2017, 02:49:10 PM
I think I would be better off if I could tell someone what my ships are intended to do and I would do art and animation ...
Dammit, I would really like to help you with that but I do not have enough time to manage a 5th ( ! ) faction mod. I hope you find someone and good luck. (I'm still available if you need some animations here and there)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on April 24, 2017, 03:50:31 PM
Quote
Fatal: JSONObject["buildInWings"] is not a JSONArray.
Well, crap, I spent like 10 minutes trying to get the syntax right only for Starfarer to throw this at me. :D

So, is it possible to have multiple built-in wings? I'm only just now realizing there are no ships in Vanilla that have multiple built-in wings so... hoping that's not the case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 24, 2017, 06:57:48 PM
first glance: it's "builtInWings", not "buildInWings"

failing that, paste the file and I'll have a look, it's definitely possible to have multiple built-in wings
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on April 24, 2017, 08:36:07 PM
Good catch, but thankfully that's only a typo here and not in the file. :D

Code
{
  "bounds": [
    -40.5,
    16,
    20.5,
    27,
    30,
    16,
    43.5,
    16,
    44,
    -26,
    -43.5,
    -24
  ],
  "builtInWeapons": {
    "WS0003": "armcom_fic_turret"
  },
  "center": [
    28.5,
    48
  ],
#    "builtInWings": {
#   "LB 1": "svolbergtdi_wing",
#   "LB 1": "svolbergtdi_rapid",
#   "LB 1": "svolbergtdi_missile",
#},
#    "main": [
#        39,
#        45
#  ],
  "collisionRadius": 75,
  "engineSlots": [
    {
      "angle": 180,
      "contrailSize": 30,
      "length": 30,
      "location": [
        -45.5,
        6
      ],
      "style": "LOW_TECH",
      "width": 10
    },
    {
      "angle": 180,
      "contrailSize": 30,
      "length": 30,
      "location": [
        -45.5,
        -16
      ],
      "style": "LOW_TECH",
      "width": 10
    }
  ],
  "height": 96,
  "hullId": "m3fic",
  "hullName": "Jacobson M3 FIC",
  "hullSize": "FRIGATE",
  "shieldCenter": [
    0,
    0
  ],
  "shieldRadius": 0,
  "spriteName": "graphics/ships/ARMCOM_FIC.png",
  "style": "MIDLINE",
  "viewOffset": 0,
  "weaponSlots": [
    {
      "angle": 0,
      "arc": 75,
      "id": "WS0001",
      "locations": [
        42,
        -3
      ],
      "mount": "HARDPOINT",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 0,
      "id": "WS0002",
      "locations": [
        9,
        21
      ],
      "mount": "HARDPOINT",
      "size": "SMALL",
      "type": "MISSILE"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "WS0003",
      "locations": [
        -11,
        -10.5
      ],
      "mount": "TURRET",
      "size": "MEDIUM",
      "type": "BUILT_IN"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 1",
      "locations": [
        -29,
        -25.5
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "LAUNCH_BAY"
    },
    {
      "angle": 40,
      "arc": 5,
      "id": "WS0004",
      "locations": [
        20.5,
        8
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "SYSTEM"
    },
    {
      "angle": 140,
      "arc": 0,
      "id": "WS0005",
      "locations": [
        -38.5,
        5
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "SYSTEM"
    }
  ],
  "width": 57
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buttery on April 24, 2017, 08:46:20 PM
How would I go about fixing the placement of a weapon on a fighter? I've tried changing the weapon slot on the fighter itself and changing offsets thinking that might do it but so far none of them have worked.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 24, 2017, 09:00:23 PM
How would I go about fixing the placement of a weapon on a fighter? I've tried changing the weapon slot on the fighter itself and changing offsets thinking that might do it but so far none of them have worked.

You'll have to move the slot itself around manually. The slot has coordinates on the ship sprite relative to the ship's centrepoint. Are you using Trylobot's (or whoever-does-it-now's) Ship Editor to edit things?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buttery on April 24, 2017, 09:06:58 PM
How would I go about fixing the placement of a weapon on a fighter? I've tried changing the weapon slot on the fighter itself and changing offsets thinking that might do it but so far none of them have worked.

You'll have to move the slot itself around manually. The slot has coordinates on the ship sprite relative to the ship's centrepoint. Are you using Trylobot's (or whoever-does-it-now's) Ship Editor to edit things?

Yeah I am, and I've got it working now thanks for the help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 24, 2017, 09:45:36 PM
No problem.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 24, 2017, 10:50:07 PM
Good catch, but thankfully that's only a typo here and not in the file. :D
[snip]

are you just talking about the built in wings line you commented out? If so, that stuff uses square bracket instead of squiggly bracket, might be worth giving that a shot
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on April 25, 2017, 12:09:15 AM
That just causes Starsector to throw a syntax error, which is why I went to brace brackets to mimic the arrays for builtinweapons. With the brace brackets it at least reads the syntax, but it gives me the error I initially posted that builtinwings isn't an array, I suppose it's set-up to just be a single value but I don't know how to change that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on April 25, 2017, 03:11:42 AM
Where has the skill number/stat/percentage editing been moved? If I can't give myself hundreds of OP points then I just can't play the game. The skill_data.csv file I know of no longer has those numbers to edit in the new version of the game and I can't find it anywhere, I already dug into the starfarer.api.zip and in ShipDesign.java I found this: public static final float OP_BONUS = 10f; So I thought this would change it: public static final float OP_BONUS = 80f; ...but nope, it still has the plus 10% to ordnance points in-game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buttery on April 25, 2017, 03:40:16 AM
How would I go about making fighters show up in the market? I figured I had it solved but it seems not when I got some feedback on it, I had the worlds folder set up with the factions and what not but it didnt work at the time so I removed it, I assume thats needed though?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: OzOnyx on April 25, 2017, 04:16:30 AM
Where has the skill number/stat/percentage editing been moved? If I can't give myself hundreds of OP points then I just can't play the game. The skill_data.csv file I know of no longer has those numbers to edit in the new version of the game and I can't find it anywhere, I already dug into the starfarer.api.zip and in ShipDesign.java I found this: public static final float OP_BONUS = 10f; So I thought this would change it: public static final float OP_BONUS = 80f; ...but nope, it still has the plus 10% to ordnance points in-game.

You could just grab the console commands and add op etc...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 25, 2017, 04:23:10 AM
Some of the changes in the files seem downright ***. Pointless redundancy.

Especially the tags.
A weapon already has it's type and range defined, and has a PD hint - why the hell does it need to have all those stuff repeated again in the tags?
"pd6, kinetic3, SR"

Why not read all that data from the weapon data itself?

Similar for wings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 25, 2017, 05:00:16 AM
Quote
Fatal: JSONObject["buildInWings"] is not a JSONArray.
Well, crap, I spent like 10 minutes trying to get the syntax right only for Starfarer to throw this at me. :D

So, is it possible to have multiple built-in wings? I'm only just now realizing there are no ships in Vanilla that have multiple built-in wings so... hoping that's not the case.

NEIN:
Code: json
"builtInWings": {
   "LB 1": "svolbergtdi_wing",
   "LB 1": "svolbergtdi_rapid",
   "LB 1": "svolbergtdi_missile",
},
JA:
Code: json
"builtInWings": ["svolbergtdi_wing","svolbergtdi_rapid","svolbergtdi_missile"],
(To understand why, read up on the difference between JSON arrays (https://www.w3schools.com/js/js_json_arrays.asp) and JSON objects (https://www.w3schools.com/js/js_json_objects.asp))

How would I go about making fighters show up in the market? I figured I had it solved but it seems not when I got some feedback on it, I had the worlds folder set up with the factions and what not but it didnt work at the time so I removed it, I assume thats needed though?
You need a .faction file for ships/wings to appear in markets, yeah.
(For fighters in particular, I think the faction owning the market need some carrier variants that carry said fighters as wings defined in their .faction file, for the LPCs to appear in the store)

Some of the changes in the files seem downright ***. Pointless redundancy.

Especially the tags.
A weapon already has it's type and range defined, and has a PD hint - why the hell does it need to have all those stuff repeated again in the tags?
"pd6, kinetic3, SR"

Why not read all that data from the weapon data itself?

Similar for wings.
The tags are used for the autofitter (http://fractalsoftworks.com/forum/index.php?topic=11570.msg197294;topicseen#msg197294). The number specifies how good the weapon is at that role.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buttery on April 25, 2017, 05:05:02 AM
You need a .faction file for ships/wings to appear in markets, yeah.
(For fighters in particular, I think the faction owning the market need some carrier variants that carry said fighters as wings defined in their .faction file, for the LPCs to appear in the store)

So basically if I want it available to all carriers would I have to add in variants of all of them, and basically just create the variant files then add those to the faction files right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 25, 2017, 05:06:22 AM
You need a .faction file for ships/wings to appear in markets, yeah.
(For fighters in particular, I think the faction owning the market need some carrier variants that carry said fighters as wings defined in their .faction file, for the LPCs to appear in the store)

Actually I don't believe this is the case. My mod The Silent Armada doesn't have a new faction, or even any ships operated by existing factions, yet the fighter LPCs will still spawn in markets.

They literally should just spawn. If they don't seem to be, try dropping the tier or rarity down a few notches. When the sector generates, markets tend to stock only weapons and other equipment (fighter LPCs included) of a tech level of 0 or 1.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on April 25, 2017, 05:18:01 AM
Ah, excellent, Histidine! Thank you very much, I had attempted to construct the proper sequence but I just didn't do it correctly. Thank you for the explanatory links as well, that is useful information and I'll look more into the site itself later. Schönen tag!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on April 25, 2017, 05:37:36 AM
Where has the skill number/stat/percentage editing been moved? If I can't give myself hundreds of OP points then I just can't play the game. The skill_data.csv file I know of no longer has those numbers to edit in the new version of the game and I can't find it anywhere, I already dug into the starfarer.api.zip and in ShipDesign.java I found this: public static final float OP_BONUS = 10f; So I thought this would change it: public static final float OP_BONUS = 80f; ...but nope, it still has the plus 10% to ordnance points in-game.

You could just grab the console commands and add op etc...

I already tried that when I was testing if it works or not and it doesn't, just does bugger all and crashes the game which is due to the fact that console commands is not updated yet,  and yes I already have the newest LazyLib in my mod folder.

My gripe is the fact that I don't know where I can find and alter the skill bonuses in the new game version.

EDIT: I should've mentioned that I'm having this problem only with the newest 0.8a version of the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 25, 2017, 06:02:06 AM
Some of the changes in the files seem downright ***. Pointless redundancy.

Especially the tags.
A weapon already has it's type and range defined, and has a PD hint - why the hell does it need to have all those stuff repeated again in the tags?
"pd6, kinetic3, SR"

Why not read all that data from the weapon data itself?

Similar for wings.

Because it would take years to make the massive sorting program you'd need to perfectly asses the power of every single weapons only from their stats, and even then it wouldn't work because some have scripted damage.
Tags are simple, done in 5min for a whole mod, and they are user defined to avoid any issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buttery on April 25, 2017, 06:02:49 AM
You need a .faction file for ships/wings to appear in markets, yeah.
(For fighters in particular, I think the faction owning the market need some carrier variants that carry said fighters as wings defined in their .faction file, for the LPCs to appear in the store)

Actually I don't believe this is the case. My mod The Silent Armada doesn't have a new faction, or even any ships operated by existing factions, yet the fighter LPCs will still spawn in markets.

They literally should just spawn. If they don't seem to be, try dropping the tier or rarity down a few notches. When the sector generates, markets tend to stock only weapons and other equipment (fighter LPCs included) of a tech level of 0 or 1.

That seemed to fix it, thanks for the help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on April 25, 2017, 06:04:23 AM
Tags are simple, done in 5min for a whole mod, and they are user defined to avoid any issue.
Out of curiosity, are these tags explained somewhere or do I just need to get smart and work it out? :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 25, 2017, 06:13:50 AM
Out of curiosity, are these tags explained somewhere or do I just need to get smart and work it out? :D
In case it's not self-explanatory:
energy0 is a terrible energy weapon
energy20 is a terrific one.
If a variant requires an unavailable energy17 weapon, the auto-fit will look for all the weapons with energy tag in the market and pick the best one. Same with wings except they have one rank, a one role and a tech level.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WKOB on April 25, 2017, 06:16:21 AM
Oh neat, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on April 25, 2017, 07:11:41 AM
Well, meh. No clue to my question. Guess I'll just increase ordnance points for all ships in the game for myself. At least it isn't that much of a distress, just a bit of busy work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 25, 2017, 10:04:10 AM
Alright, I got BGE at least starting up but I had to disable some essential plugins for their unique right click system and I would need some help fixing that please.

The Plugin:
Spoiler
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.ShipAPI;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.HashMap;
import java.util.Set;
import org.apache.log4j.Level;

/**
 *
 * @author Revan
 */
public class ProtectionData {
   
            public final WeakReference source;
            //public final ShipAPI source;
            final float expiration;
            static final Set protectionMap = Collections.newSetFromMap(new HashMap());
     
    public ProtectionData(float protectionDuration, ShipAPI source)
        {
            //this.hitLoc = new AnchoredEntity(target, hitLoc);
            this.source = new WeakReference(source);
            //this.source = source;
            //sets the time WHEN it will expire
            expiration = Global.getCombatEngine().getTotalElapsedTime(false)
                    + protectionDuration;
        }
           
    public static void startProtection(float protectionDuration, ShipAPI source)
        {
            //Creates a new token in the protectionMap list
            protectionMap.add(new ProtectionData(protectionDuration, source));
            Global.getLogger(ProtectionTracker.class).log(Level.INFO,"Protection Requested");
            //Applies the mutablestats to the ship
            applyProtectionStats(source);
        }
                   
    static void applyProtectionStats(ShipAPI source)
        {
            String id = "faceMeltProtection"; //id of the buff
            Global.getLogger(ProtectionTracker.class).log(Level.INFO,"Running protection apply"); //debug code

            //Apply ship stats

        source.getMutableStats().getHighExplosiveDamageTakenMult().modifyMult(id,0.001f);

        }
    static void unApplyProtectionStats(ShipAPI source)
        {
            String id = "faceMeltProtection"; //id of the buff
            Global.getLogger(ProtectionTracker.class).log(Level.INFO,"Running protection un-apply"); //debug code

            //unpply ship stats           
            source.getMutableStats().getHighExplosiveDamageTakenMult().unmodify(id);

        }
 
}
[close]

Throws this error at me:
Spoiler
18248 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.plugins.ProtectionData]
java.lang.RuntimeException: Error compiling [data.scripts.plugins.ProtectionData]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Problem loading class [data.scripts.plugins.ProtectionData]
   at com.fs.starfarer.loading.scripts.ScriptStore.Object(Unknown Source)
   ... 2 more
Caused by: java.lang.InstantiationException: data.scripts.plugins.ProtectionData
   at java.lang.Class.newInstance(Unknown Source)
   ... 3 more
Caused by: java.lang.NoSuchMethodException: data.scripts.plugins.ProtectionData.<init>()
   at java.lang.Class.getConstructor0(Unknown Source)
   ... 4 more
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Axisoflint on April 25, 2017, 04:34:20 PM
Well, meh. No clue to my question. Guess I'll just increase ordnance points for all ships in the game for myself. At least it isn't that much of a distress, just a bit of busy work.

Console commands has been updated to work with 0.8 if that helps. I've not tested anything other than the skillpoints to see what some of the newer stuff does, so ymmv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 25, 2017, 04:47:41 PM
Well, meh. No clue to my question. Guess I'll just increase ordnance points for all ships in the game for myself. At least it isn't that much of a distress, just a bit of busy work.

If you have the ability, you could also make yourself a custom hullmod that costs negative ordnance points and install it on all your ships. That's a clean way to do it as you could do it in a mod-like format and be able to turn it on or off, or edit it, at any time without breaking the stock game. It's not the same as a percentage increase, it'd be a flat amount, but you can change the amount depending on the class (size) of the ship.

In fact, if you like, I could whip something like that up for you right now.  ;D How much more OP did you want?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on April 25, 2017, 09:01:30 PM
Well, meh. No clue to my question. Guess I'll just increase ordnance points for all ships in the game for myself. At least it isn't that much of a distress, just a bit of busy work.

If you have the ability, you could also make yourself a custom hullmod that costs negative ordnance points and install it on all your ships. That's a clean way to do it as you could do it in a mod-like format and be able to turn it on or off, or edit it, at any time without breaking the stock game. It's not the same as a percentage increase, it'd be a flat amount, but you can change the amount depending on the class (size) of the ship.

In fact, if you like, I could whip something like that up for you right now.  ;D How much more OP did you want?

Interesting idea, haven't thought of that before but it is still something I couldn't do even if I had the thought of it myself. Copying and altering some existing file(s) is one thing, writing something entirely from scratch that works in java is an entire different nut to crack for myself. While you are probably more than able to code scripts from scratch, I am not. I can't learn it either without losing my sanity and brute force something with insanity which of course is usually doomed to fail to a point of this:
Spoiler
https://www.youtube.com/watch?v=WwlNPhn64TA (https://www.youtube.com/watch?v=WwlNPhn64TA)
[close]

That aside, even though I've already edited all of the ships with more OP points of about 350-650 (I over-compensate a lot to save myself from the chore of math and for ships that are like Tiandong's Wuzhang which needs about couple of hundred more OP points to install everything.),
I just can't turn down your offer either as I'm interested to see how such a hullmod file works script/gameplay-wise despite my immense struggle to learn to code in java.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 25, 2017, 10:16:00 PM
You might be surprised. I've got very little actual coding experience - most of what I've learnt comes from copy-pasting from Starsector's core files and changing some values around. The total requirements for a mod that introduces such a hullmod would be:

- A mod environment (basically an overruling folder with a "mod_info" file)
- A java file for the hullmod effect stats
- A csv file (like a spreadsheet) for the installation/user interface stats
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on April 26, 2017, 03:25:34 AM
You might be surprised. I've got very little actual coding experience - most of what I've learnt comes from copy-pasting from Starsector's core files and changing some values around. The total requirements for a mod that introduces such a hullmod would be:

- A mod environment (basically an overruling folder with a "mod_info" file)
- A java file for the hullmod effect stats
- A csv file (like a spreadsheet) for the installation/user interface stats

And there's my problem: Hullmod effect files in the hullmods folder are the only files I can't even make heads and tails about and so it gives me a headache of sorts and in turn I toss the damn thing proverbial away and try to find and think about a much easier solution somewhere else to get what I need.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 26, 2017, 03:51:47 AM

And there's my problem: Hullmod effect files in the hullmods folder are the only files I can't even make heads and tails about and so it gives me a headache of sorts and in turn I toss the damn thing proverbial away and try to find and think about a much easier solution somewhere else to get what I need.

Yeah, they can be a little confusing. XD I suppose I kind of understand what each bit of the code means now, for most hullmods. Some are simpler than others - in fact for your situation you can create a hullmod file that doesn't actually do anything, so it can be super simple. All your doing is upping the OP count of a ship by installing a hullmod that costs negative OP.

The file itself would look like this:

Code

package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;

public class superop_upgrade extends BaseHullMod {
// Nothing to see here.
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on April 26, 2017, 04:55:22 AM
Yeah, they can be a little confusing. XD I suppose I kind of understand what each bit of the code means now, for most hullmods. Some are simpler than others - in fact for your situation you can create a hullmod file that doesn't actually do anything, so it can be super simple. All your doing is upping the OP count of a ship by installing a hullmod that costs negative OP.

The file itself would look like this:

Code

package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;

public class superop_upgrade extends BaseHullMod {
// Nothing to see here.
}


Hmm.. thanks! It's vague but kind of getting the gist of it. However I still have no idea where the number value goes. To be more specific: Where would one even put it as in how, where and in what order of coding to make it work. Most likely a silly 101 java coding for dummies question but I'm not bothered by it other than I suck at it big-time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 26, 2017, 05:05:49 AM
Hmm.. thanks! It's vague but kind of getting the gist of it. However I still have no idea where the number value goes. To be more specific: Where would one even put it as in how, where and in what order of coding to make it work. Most likely a silly 101 java coding for dummies question but I'm not bothered by it other than I suck at it big-time.

Ah, that's the magic of it! Ordnance Point count is not a "Mutable Ship Stat", meaning it is not a statistic that can be tampered with directly through a hullmod.

HOWEVER if you create a hullmod (which, as in the example code, does absolutely nothing) that costs a negative quantity of Ordnance Points to install on a ship, then you have magically given your ship more ordnance.

That's where the .csv file comes in - just like the stock game, it contains user-end information, including things like the hullmod name, description, and how much OP it costs to fit on each size of ship (frigate/destroyer/cruiser/capital).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on April 26, 2017, 06:32:45 AM
Well, at least I tried to understand it and get it working, though in vain. As far as coding goes, I am just too impatient for that and the more I fail the more I get furious to a point of doing irrational actions and outcomes.

Increasing the OP points for all ships already did the alternate easy-route trick I needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: coyote.j.p.m on April 26, 2017, 08:15:23 AM
So has anyone been able to figure out what determines salvageable ship spawning (as in, which ships can be derelicts to potentially recover)? Do they only spawn as a result of battles or is there some plugin spawning them at random as well? I see in salvage_entity_gen_data.csv there's an entry for "wreck" but I'm not sure if that's the right thing or how it's used anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: coyote.j.p.m on April 26, 2017, 08:40:34 AM
Ah, I think I figured it out actually. It's in the NearbyEventsEvent class, there's a chance every so often to spawn a derelict ship, which is a random variant of a random faction within 15LY (weighted based on faction-owned market size, where Pirates and Independents always get an extra size 5 market for the picker). So to increase the probability of random ship from my modded factions showing up, i just need more (and bigger) markets...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 26, 2017, 08:55:25 AM
Does anyone remember how I could check if a ship is in refit screen?
I think its done With a specific ship owner number but I can't remember
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 26, 2017, 10:53:57 AM
if the owner is -1 it's in refit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 26, 2017, 11:59:52 AM
Thanks a bunch Tartiflette!
Nope, somehow doesn't do it for me. It's supposed to mirror an installed weapon in refit screen but no matter how I try, it won't work.

I guess I will have to live with the fact that my little monsters will have 2 (actually more than that) right clawas in refit screen. As soon as battle starts everything is mirrored perfectly ...

The Script (Posted it once a long time ago)
Spoiler
package data.scripts.weapons;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.graphics.SpriteAPI;
import java.util.*;

public class BaseAnimateOnFireEffect2 implements EveryFrameWeaponEffectPlugin
{
    // Default to 15 frames per second
    private float timeSinceLastFrame, timeBetweenFrames = 1.0f / 140f;
    private Map pauseFrames = new HashMap();
    private int curFrame = 0, pausedFor = 0;
    private boolean isFiring = false;
   private boolean runOnce = false;
   private boolean runOnce2 = false;
   private boolean runOnce3 = false;

    protected void setFramesPerSecond(float fps)
    {
        timeBetweenFrames = 1.0f / fps;
    }

    protected void pauseOnFrame(int frame, int pauseFor)
    {
        pauseFrames.put(frame, pauseFor);
    }


    private void incFrame(AnimationAPI anim)
    {
   
        if (pauseFrames.containsKey(curFrame))
        {
            if (pausedFor < (Integer) pauseFrames.get(curFrame))
            {
                pausedFor++;
                return;
            }
            else
            {
                pausedFor = 0;
            }
        }

        curFrame = Math.min(curFrame + 1, anim.getNumFrames() - 1);
    }

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        if (engine.isPaused())
        {
            return;
        }
        if(runOnce == false){ 
            if (weapon.getShip().getOwner() == -1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()   ){ 
                SpriteAPI theSprite = weapon.getSprite(); 
                theSprite.setWidth(-theSprite.getWidth()); 
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY()); 
            } 
            runOnce = true; 
        }
        AnimationAPI anim = weapon.getAnimation();
        anim.setFrame(curFrame);

        if (isFiring)
        {
            timeSinceLastFrame += amount;

            if (timeSinceLastFrame >= timeBetweenFrames)
            {
                timeSinceLastFrame = 0f;
               
                anim.setFrame(curFrame);
                    if(runOnce2 == false){ 
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()   
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()){ 
                SpriteAPI theSprite = weapon.getSprite(); 
                theSprite.setWidth(-theSprite.getWidth()); 
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY()); 
            } 
           
        } 
             incFrame(anim);

                if (curFrame == anim.getNumFrames() - 1)
                {
                    isFiring = false;
               runOnce2 = true; 
                }
            }
        }
        else
        {
            if (weapon.isFiring() && weapon.getChargeLevel() == 1.0f)
            {
                isFiring = true;
                incFrame(anim);
                anim.setFrame(curFrame);
            }
            else
            {
                curFrame = 0;
                anim.setFrame(curFrame);
                    if(runOnce3 == false){ 
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()   
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX())
            { 
                SpriteAPI theSprite = weapon.getSprite(); 
                theSprite.setWidth(-theSprite.getWidth()); 
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY()); 
            } 
            runOnce3 = true; 
        }
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 26, 2017, 12:34:47 PM
I'm not sure but you might need
Code
.getOriginalOwner()
rather than just
Code
.getOwner()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on April 26, 2017, 01:24:24 PM
Ha! You're a genius!

Funny thing about the refit screen: the whole X/Y coordinate system is rotated by 90° clockwise, I had to change the code to this:
Spoiler
if (engine.isPaused())
        {
            return;
        }
        if(runOnce == false){  
            if (weapon.getShip().getOriginalOwner() == -1 && weapon.getLocation().getY() > weapon.getShip().getLocation().getY()   ){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            runOnce = true;  
        }
[close]

See, I had to change getX to getY or it would allways mirror both weapons, not just the one that was supposed to be mirrored

Here the whole script for anybody interrested in mirroring weapons, they're firing animation and they're location in the refit screen:
Spoiler
package data.scripts.weapons;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.graphics.SpriteAPI;
import java.util.*;

public class BaseAnimateOnFireEffect2 implements EveryFrameWeaponEffectPlugin
{
    // Default to 15 frames per second
    private float timeSinceLastFrame, timeBetweenFrames = 1.0f / 140f;
    private Map pauseFrames = new HashMap();
    private int curFrame = 0, pausedFor = 0;
    private boolean isFiring = false;
   private boolean runOnce = false;
   private boolean runOnce2 = false;
   private boolean runOnce3 = false;

    protected void setFramesPerSecond(float fps)
    {
        timeBetweenFrames = 1.0f / fps;
    }

    protected void pauseOnFrame(int frame, int pauseFor)
    {
        pauseFrames.put(frame, pauseFor);
    }


    private void incFrame(AnimationAPI anim)
    {
   
        if (pauseFrames.containsKey(curFrame))
        {
            if (pausedFor < (Integer) pauseFrames.get(curFrame))
            {
                pausedFor++;
                return;
            }
            else
            {
                pausedFor = 0;
            }
        }

        curFrame = Math.min(curFrame + 1, anim.getNumFrames() - 1);
    }

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
    {
        if (engine.isPaused())
        {
            return;
        }
        if(runOnce == false){  
            if (weapon.getShip().getOriginalOwner() == -1 && weapon.getLocation().getY() > weapon.getShip().getLocation().getY()   ){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            runOnce = true;  
        }
        AnimationAPI anim = weapon.getAnimation();
        anim.setFrame(curFrame);

        if (isFiring)
        {
            timeSinceLastFrame += amount;

            if (timeSinceLastFrame >= timeBetweenFrames)
            {
                timeSinceLastFrame = 0f;
                
                anim.setFrame(curFrame);
                    if(runOnce2 == false){  
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()  
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX()){  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            
        }  
             incFrame(anim);

                if (curFrame == anim.getNumFrames() - 1)
                {
                    isFiring = false;
               runOnce2 = true;  
                }
            }
        }
        else
        {
            if (weapon.isFiring() && weapon.getChargeLevel() == 1.0f)
            {
                isFiring = true;
                incFrame(anim);
                anim.setFrame(curFrame);
            }
            else
            {
                curFrame = 0;
                anim.setFrame(curFrame);
                    if(runOnce3 == false){  
            if (weapon.getShip().getOwner() == 0 && weapon.getLocation().getX() < weapon.getShip().getLocation().getX()  
                || weapon.getShip().getOwner() == 1 && weapon.getLocation().getX() > weapon.getShip().getLocation().getX())
            {  
                SpriteAPI theSprite = weapon.getSprite();  
                theSprite.setWidth(-theSprite.getWidth());  
                theSprite.setCenter(-theSprite.getCenterX(),theSprite.getCenterY());  
            }  
            runOnce3 = true;  
        }
            }
        }
    }
}
[close]

Next problem: script that is supposed to disble the hit ship's shields for a set amount of time doesn't work, no errors simply no effect at all:
Spoiler
Code
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import org.lwjgl.util.vector.Vector2f;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShieldAPI.ShieldType;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class DissableShieldOnHitEffect implements OnHitEffectPlugin {
    // This is how we store which ships have dissabled shields and how much
    //  longer they'll be dissabled.
    //
    // Key - ShipAPI (the affected ship)
    // Value - float (the remaining duration of shield dissable-ization)
    static Map affectedShips = new HashMap();

    static final float DISSABLE_TIME_PER_HIT = 10f; // In seconds

    @Override
public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
        if (!(target instanceof ShipAPI)) return;

        ShipAPI ship = (ShipAPI)target;

        if(!ship.isAlive() || ship.getShield() == null) return;

        if(affectedShips.containsKey(ship)) {
            affectedShips.put(ship, (Float)affectedShips.get(ship) + DISSABLE_TIME_PER_HIT);
        } else {
            affectedShips.put(ship, DISSABLE_TIME_PER_HIT);
        }
}

// This is called once each frame by the ForceShieldDissablePlugin
    public static void forceDissableShields(float amount) {
        CombatEngineAPI engine = Global.getCombatEngine();

        if(engine.isPaused()) return;

        for(Iterator iter = affectedShips.keySet().iterator(); iter.hasNext();) {
            ShipAPI ship = (ShipAPI)iter.next();
            float remainingTime = (Float)affectedShips.get(ship) - amount;

            if(remainingTime < 0) {
                // This removes the current ship from affectedShips
                iter.remove();
            } else {
                affectedShips.put(ship, remainingTime);
                ship.getShield.setActiveArc(0);
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 26, 2017, 07:25:38 PM
Where would one find Fighter wing specs? I'm trying to make a mod for my own use and it keeps throwing this error at me.

Code
7412 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Fighter wing spec [ADF_Interceptor_wing] not found
java.lang.RuntimeException: Fighter wing spec [ADF_Interceptor_wing] not found
at com.fs.starfarer.loading.O0oO.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.U$Oo.<init>(Unknown Source)
at com.fs.starfarer.loading.U.<init>(Unknown Source)
at com.fs.starfarer.loading.SpecStore.new.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 26, 2017, 07:30:16 PM
Where would one find Fighter wing specs?

In the same place they used to be, "wing_data.csv". The problem is they now have a bunch of new stats which you'll need to add. Check the stock game files for reference.

Also, don't forget that ships also now have a "fighter bays" value which is specified in "ship_data.csv", as well as the launch bays in the "___.ship" file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 26, 2017, 07:34:35 PM
Where would one find Fighter wing specs?

In the same place they used to be, "wing_data.csv". The problem is they now have a bunch of new stats which you'll need to add. Check the stock game files for reference.

Also, don't forget that ships also now have a "fighter bays" value which is specified in "ship_data.csv", as well as the launch bays in the "___.ship" file.
I know that much, i have everything marked where it's supposed to be, it's just throwing out that error.
Could it be because i've got the fighters listed in the .faction file? It worked perfectly fine before
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 26, 2017, 07:36:59 PM
I know that much, i have everything marked where it's supposed to be, it's just throwing out that error.
Could it be because i've got the fighters listed in the .faction file? It worked perfectly fine before

Ah, yeah that could cause problems. Try removing those and see what happens.

The other option is that you've got a minor spelling or syntax error somewhere that's causing the thing to throw a tantrum.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 26, 2017, 07:38:53 PM

Ah, yeah that could cause problems. Try removing those and see what happens.

The other option is that you've got a minor spelling or syntax error somewhere that's causing the thing to throw a tantrum.
Spelling isn't an issue, i've checked that about 600 times by now, I'll try the fighter wings thing.
Will have to remember to add them to the carrier's variants file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 26, 2017, 07:40:19 PM
Strange. If that doesn't work, do you mind if I take a look? Do you have some way to upload a version of the mod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 26, 2017, 07:51:56 PM
Strange. If that doesn't work, do you mind if I take a look? Do you have some way to upload a version of the mod?
Well it's not giving me that error anymore, now it's asking for a , or a } in a line that doesn't need one of those.
I can drop box it if you want me to
Edit: Am Dumb, nevermind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 26, 2017, 08:16:19 PM
Made a ship. No problem, works fine. Custom system, less so.

It's a very slightly modified temporal shell - I've only changed two lines in the actual script, most of it is in the csv.

But it's crashing, and given I downloaded the IDE tonight, I can't figure out why.

Code
19311 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: shipsystems.TemporalRipperStats
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

I've got starfarer.api set as a library, and BaseShipSystemScript over too, since temporalshell extends it. I can't figure out what the problem is - searching for it got me an old post from shaderlib, but that's about it.
My best guess is I'm missing some dependency somewhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 26, 2017, 08:18:43 PM
Spoiler
Made a ship. No problem, works fine. Custom system, less so.

It's a very slightly modified temporal shell - I've only changed two lines in the actual script, most of it is in the csv.

But it's crashing, and given I downloaded the IDE tonight, I can't figure out why.

Code
19311 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: shipsystems.TemporalRipperStats
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

I've got starfarer.api set as a library, and BaseShipSystemScript over too, since temporalshell extends it. I can't figure out what the problem is - searching for it got me an old post from shaderlib, but that's about it.
My best guess is I'm missing some dependency somewhere?
[close]
Do you have the latest version Lazylib?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 26, 2017, 08:20:35 PM
Yeah - but this isn't touching that, just base starsector stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 26, 2017, 08:24:02 PM
Yeah - but this isn't touching that, just base starsector stuff.
Odd, then i don't know what to tell you.

To keep from double posting, It's loading into the game now, but when it tries generating fleets, it (the mod i'm working on) starts asking for Fighter Specs again, I've got everything where it should be
EDIT: Was a capitalization error. Stupid me.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 26, 2017, 08:41:40 PM
Code
19311 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
java.lang.RuntimeException: Error compiling [shipsystems.TemporalRipperStats]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: shipsystems.TemporalRipperStats
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Quick check: Is your ship system's Java class in the shipsystems package? That's where it's looking and failing to find the class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 26, 2017, 08:53:47 PM
Yup. That's basically all it is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 26, 2017, 09:21:39 PM
Well it's not giving me that error anymore, now it's asking for a , or a } in a line that doesn't need one of those.
I can drop box it if you want me to
Edit: Am Dumb, nevermind

Ah, nevermind.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 26, 2017, 09:38:09 PM

Ah, nevermind.  ;D
Everything works now.
Now to teach myself how to make weapons :D
this is gonna hurt...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flying Birdy on April 26, 2017, 09:49:31 PM
Does anyone know what values to change to allow certain hull-mods to spawn in markets? I played around with hull_mods.csv and "tier" did not have any effect on what hull mods can spawn in markets. Is this something that's specified in the economics files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 26, 2017, 10:00:46 PM
Does anyone know what values to change to allow certain hull-mods to spawn in markets? I played around with hull_mods.csv and "tier" did not have any effect on what hull mods can spawn in markets. Is this something that's specified in the economics files?

They should all be able to spawn in markets by default - at least, any that don't have "hidden everywhere" set to TRUE. The "tier" is a rough suggestion of their base rarity (yes, I know there's a "rarity" tag as well - that's separate). If you set every hullmod's tier to 0 it should make them more likely to spawn.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 26, 2017, 11:31:23 PM
Does ship.getChildModulesCopy() returns only the deployed modules in this particular battle (even those still repairing for example)? Only the modules currently alive? Or all the modules listed on the variant?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sy on April 27, 2017, 07:03:54 AM
how do you tell the game where to spawn Comm Relays? specifically, i'd like to put a Relay into the vanilla Kumari Kandam system, as it doesn't have one, so i can't receive intel updates or bounty payments there. :/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inacio on April 27, 2017, 08:42:48 AM
I made a custom ship. How can I make it so it shows up in some buy menus in the campaign (I don't want it to show up in NPC fleets if that's possible)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 27, 2017, 10:57:12 AM
Does ship.getChildModulesCopy() returns only the deployed modules in this particular battle (even those still repairing for example)? Only the modules currently alive? Or all the modules listed on the variant?

The modules in that particular battle - i.e. if some were destroyed in a previous battle and not repaired enough to re-appear, they won't show up in the result. I *think* modules destroyed in the current battle will still stay in the list, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inacio on April 27, 2017, 11:29:36 AM
Another question: can I specify different image files for variants (e.g. pirate variant, damaged variant etc) without making an entirely new ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sy on April 27, 2017, 11:52:31 AM
Another question: can I specify different image files for variants (e.g. pirate variant, damaged variant etc) without making an entirely new ship?
"variants" in Starsector are default loadouts. what you're looking for is a "skin", which includes all the pirate- and Pather-specific ships. and yes, you can give those their own sprite, independent of that of the ship the skin is based on. same with description.

for example, the .skin file of the Hegemony-exclusive Kite(A) looks like this:
Spoiler
{
   "baseHullId":"kite",
   "skinHullId":"kite_hegemony",
   "hullName":"Kite (A)",
   "fleetPoints":4,
   "ordnancePoints":32,
   "descriptionId":"kite",  # optional
   "descriptionPrefix":"This ship is on the Hegemony auxiliary list and as such its systems have been upgraded to military standard and a rigorous schedule of servicing enforced with the expectation that it can be pressed into military service during emergencies.",
   "spriteName":"graphics/ships/aeroshuttle/aeroshuttle_hegemony.png",
   "baseValueMult":1.5,
   "removeHints":[CIVILIAN],
   "addHints":[],
   "removeWeaponSlots":[],       # ids
   "removeEngineSlots":[],       # indices, as engine slots have no id in the .ship file
   "removeBuiltInMods":["civgrade"],       # hullmod ids
   "removeBuiltInWeapons":[],       # weapon slot ids
   "builtInMods":["heg_militarized"],
   "builtInWeapons":{
    },
}
[close]

you can find the files in \starsector-core\data\hulls\skins.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 27, 2017, 04:03:04 PM
I'm a dumdum and can't find the weapon mount sprites. I'm sure they used to be around though. Anyone point me in the right direction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 27, 2017, 04:05:02 PM
I'm a dumdum and can't find the weapon mount sprites. I'm sure they used to be around though. Anyone point me in the right direction?

starsector-core > graphics > weapons
You may need to scroll all the way down since it's the last folder in the list and is easy to miss on a smaller window.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 27, 2017, 04:36:03 PM
Mm, I could be blind, but I can't see 'em - Found the covers, which is I THINK what you meant, but that's not it. And I've gone through the weapon sprite list four times and can't see 'em there.

I just want the base turret/hardpoint sprites to stick on a ship - the oldoldold ship editor used to let you add them to the sprite, but that thing hasn't worked since 5.2 or so :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 27, 2017, 06:39:29 PM
Mm, I could be blind, but I can't see 'em - Found the covers, which is I THINK what you meant, but that's not it. And I've gone through the weapon sprite list four times and can't see 'em there.

I just want the base turret/hardpoint sprites to stick on a ship - the oldoldold ship editor used to let you add them to the sprite, but that thing hasn't worked since 5.2 or so :P

Ohhhh, you mean the actual base sprite. I misunderstood. Those are part of the ship sprites themselves.

Fortunately you don't have to do any annoying cropping because I've done it for you! I'm happy to provide my standard "mount palette" which I use for spriting. Feel free to save it and use it for reference. You can just select the mount you want and then copy-paste it onto your sprites.

(http://i.imgur.com/Qvt8bTi.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 27, 2017, 06:46:59 PM
Thats uh, that's so much better than what I wound up going with - I lasso'd off a hammerhead and erased until it wasn't completely hideous. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 27, 2017, 06:56:12 PM
No problem. :D Having that image as a reference to copy-paste from is super useful, no lie.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buttery on April 27, 2017, 07:29:02 PM
Is there a tutorial or something on making custom hull mods/ship systems?

Also for ship data would I have to create a separate sprite for the breakprob and pieces, or is that handled by the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on April 27, 2017, 07:31:41 PM
depends on what you're looking for, this is a good place to start to look for tutorials:

http://fractalsoftworks.com/forum/index.php?topic=3342.0 (http://fractalsoftworks.com/forum/index.php?topic=3342.0)

breakprob and pieces are handled by the game, you just put the numbers in and it'll do the rest
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buttery on April 27, 2017, 07:36:22 PM
depends on what you're looking for, this is a good place to start to look for tutorials:

http://fractalsoftworks.com/forum/index.php?topic=3342.0 (http://fractalsoftworks.com/forum/index.php?topic=3342.0)

breakprob and pieces are handled by the game, you just put the numbers in and it'll do the rest

Well, I'm more so looking for how to make a custom hull mod or ship system to use, like Auxiliary Thrusters or Maneuvering Jets for example. And alrightie, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on April 27, 2017, 07:52:10 PM
Where would one be able to adjust the tracking ability of missiles? Would it be in the .proj file, the .wpn file, or in the .CSV?
Edit: found it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 28, 2017, 05:52:47 AM
HMm...is it possible to have a set of different music tracks for space travel and hyperspace travel?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Durendal5150 on April 28, 2017, 08:56:45 AM
'lo all. Long time no see. New update has got me somewhat interested in poking my head in again, and i've got a few Modding Questions That Are Too Minor To Warrant Their Own Thread™. Missile related, mostly.

1: Is it possible to make a MIRV that discharges more than one class of projectile at a time? I want to make a sort of heavy MIRV that spits out a bunch of decoys in addition to the real payload.

2: Is it possible to make missiles that fire a beam-type weapon? I vaguely remember it being discussed way back when.

3: That makes me think, can missiles spawn things other than projectiles using the MIRV code? Could I make a big stupid torpedo that vomits out a cloud of short-lived assault drones?

EDIT 4: Actually, the above has got me thinking; is it possible to make a weapon item an illegal commodity?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 28, 2017, 10:12:06 AM
In the same vein, is it possible to force a MIRV to split?

For that matter, do they have to be missiles? I've been testing, but atm mine's so broken I can't tell what is and isn't working :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Durendal5150 on April 28, 2017, 11:11:24 AM
For that matter, do they have to be missiles? I've been testing, but atm mine's so broken I can't tell what is and isn't working :P

There I'm not sure. I *think* it should work on any projectile. And even if it doesn't, a 'missile' with no engines or guidance shot out of a ballistic weapon won't be identifiable as such by the player.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 28, 2017, 11:20:57 AM
Yeah, I started off with unguided missiles, and wound up with some hella weird behavior - They'd only split if the shot would hit, and the second stage would lose all speed and sit in space forever until something flew past, where they'd split and fire :P

A probably easier question - Gave up with the MIRV idea for new, tried to make a proper shotgun. Can you apply spread to barrels individually? At the moment, I can't seem to get more than an innacurate chaingun.

Edit: SORTA got it working, but it's still a predictable spread rather than 'bullets go somewhere in the cone'
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on April 28, 2017, 02:12:12 PM
'lo all. Long time no see. New update has got me somewhat interested in poking my head in again, and i've got a few Modding Questions That Are Too Minor To Warrant Their Own Thread™. Missile related, mostly.

1: Is it possible to make a MIRV that discharges more than one class of projectile at a time? I want to make a sort of heavy MIRV that spits out a bunch of decoys in addition to the real payload.

2: Is it possible to make missiles that fire a beam-type weapon? I vaguely remember it being discussed way back when.

3: That makes me think, can missiles spawn things other than projectiles using the MIRV code? Could I make a big stupid torpedo that vomits out a cloud of short-lived assault drones?

EDIT 4: Actually, the above has got me thinking; is it possible to make a weapon item an illegal commodity?

With custom missile AI.

With custom missile AI and advanced scripting to create a "fake beam".

With custom missile AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 28, 2017, 02:30:05 PM
1: Is it possible to make a MIRV that discharges more than one class of projectile at a time? I want to make a sort of heavy MIRV that spits out a bunch of decoys in addition to the real payload.

Technically it's in the code for MIRVs to do this already.  8) Sadly I don't believe the secondary projectile can do damage, but if you look at the stock Hurricane MIRV projectile set you'll find both the projectile ("type_1_mirv"), the warhead ("mirv_warhead"), and something called "type_1_mirv_empty", which is by default commented out of the MIRV first projectile code:

Code
"behaviorSpec":{"behavior":"MIRV",
...
"projectileSpec":"mirv_warhead",
#"emptySpec":"type_1_mirv_empty",
...}

If you uncomment that for your game, it causes the missile to spawn an additional "inert" projectile (the empty projectile file is a missile but has the tag "NO_AI") upon splitting, which displays as if the initial propulsion stage of the missile carries on for a bit after it has ejected all the warheads. I don't believe it does any damage, but there probably isn't anything stopping you putting a non-inert projectile in the "emptySpec" for your missile.

Man, this actually sounds like a cool idea. I might test this myself. ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Durendal5150 on April 28, 2017, 04:24:34 PM
snip

I knew that was there but hadn't considered it. Does the AI even consider the empty canister as a valid target? I assume that NO_AI simply keeps it from trying to fly around itself. If it doesn't read as a live weapon, it wouldn't really work as a decoy, I don't think.

My intent had been to create a torpedo that separates into a pile of decoys and about 3-5 EFP skeets similar to a CBU-97.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 28, 2017, 04:26:29 PM
snip

I knew that was there but hadn't considered it. Does the AI even consider the empty canister as a valid target? I assume that NO_AI simply keeps it from trying to fly around itself. If it doesn't read as a live weapon, it wouldn't really work as a decoy, I don't think.

My intent had been to create a torpedo that separates into a pile of decoys and about 3-5 EFP skeets similar to a CBU-97.

Well, my point is that you don't have to have the "empty" spec be an inert projectile. You could have an MIRV missile where it's "warhead" spec is a decoy flare, and it's "empty" spec is a regular torpedo or something. All it's calling is a projectile file. What's in that file is irrelevant to the rest of the missile.

... You could even make it another MIRV... Oh no...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Durendal5150 on April 28, 2017, 04:35:45 PM
Well, my point is that you don't have to have the "empty" spec be an inert projectile. You could have an MIRV missile where it's "warhead" spec is a decoy flare, and it's "empty" spec is a regular torpedo or something. All it's calling is a projectile file. What's in that file is irrelevant to the rest of the missile.

... You could even make it another MIRV... Oh no...

Ahh, gotcha. That might actually work to make a series of charges that go off in stages. Which gives me ideas.

With custom missile AI.

With custom missile AI and advanced scripting to create a "fake beam".

With custom missile AI.

Any existing tutorials for how to get started with that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on April 28, 2017, 04:55:04 PM
Not really? Reference other mods but do not copy their code exactly without asking for permission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 28, 2017, 10:04:54 PM
There is a few custom missile AI to use in the Code Dump along samples to do a lot of other interesting things.
http://fractalsoftworks.com/forum/index.php?topic=6452.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Spardok on April 28, 2017, 11:05:13 PM
So i'm looking to modify a few of the base skills. I tried unpacking the api and editing the base skills from there, and I have tried throwing it in as a mod folder. Neither of which seems to work... In the mod folder I have the file setup as: C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Maint Costs\starfarer.api\com\fs\starfarer\api\impl\campaign\skills\FleetLogistics. So I am unsure what I am doing wrong here.

Thanks for any help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: D00D on April 29, 2017, 04:58:02 AM
(http://i.imgur.com/CRZNCW1.png)
Anyway to make a projectile's sprite spin? I have a mini-blackhole I plan to sent hurling towards the enemy. Do I just use a gif sprite or is there some code fiddling I need to do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 29, 2017, 05:05:23 AM
So i'm looking to modify a few of the base skills. I tried unpacking the api and editing the base skills from there, and I have tried throwing it in as a mod folder. Neither of which seems to work... In the mod folder I have the file setup as: C:\Program Files (x86)\Fractal Softworks\Starsector\mods\Maint Costs\starfarer.api\com\fs\starfarer\api\impl\campaign\skills\FleetLogistics. So I am unsure what I am doing wrong here.
You can't overwrite vanilla code directly, and anything not in data/skills needs to be compiled into a .jar anyway.
Try this (untested):

mods\Maint Costs\data\scripts\campaign\skills\FleetLogistics.java

Then include a copy of data/characters/skills/fleet_logistics.skill in your mod, replacing the contents with the following:

Code: json
{
"effectGroups":[
{
"name":"Level 1",
"requiredSkillLevel":1,
"effectBasedOnLevel":false,
"effects":[
{"type":"ALL_SHIPS_IN_FLEET", "script":"data.scripts.campaign.skills.FleetLogistics$Level2"},
]
},
{
"name":"Level 2",
"requiredSkillLevel":2,
"effectBasedOnLevel":false,
"effects":[
#{"type":"ALL_SHIPS_IN_FLEET", "script":"data.scripts.campaign.skills.FleetLogistics$Level2"},
{"type":"FLEET", "script":"data.scripts.campaign.skills.FleetLogistics$Level1B"},
]
},
{
"name":"Level 3",
"requiredSkillLevel":3,
"effectBasedOnLevel":false,
"effects":[
{"type":"ALL_SHIPS_IN_FLEET", "script":"ddata.scripts.campaign.skills.FleetLogistics$Level3"},
]
},
],
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 29, 2017, 01:37:53 PM
the sound file show hostile, neutral and friendly music for markets and encounters.
The market is self-explanatoriy - type of music playing when you visit the market depending on relation to faction

But encounter - is that a music that players ONLY when a fleet intercepts you (like cargo scan or asking you to activate transponder)?
Since that interaction only lasts a few seconds, is it even worth it to implement something like that? A few seconds of different music?

What about combat music WHILE fighting faction X?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on April 29, 2017, 08:51:16 PM
Is there anyway to force a weapon to fire? I'm talking about a decorative weapon.

the sound file show hostile, neutral and friendly music for markets and encounters.
The market is self-explanatoriy - type of music playing when you visit the market depending on relation to faction

But encounter - is that a music that players ONLY when a fleet intercepts you (like cargo scan or asking you to activate transponder)?
Since that interaction only lasts a few seconds, is it even worth it to implement something like that? A few seconds of different music?

What about combat music WHILE fighting faction X?

Encounter music is only played when encountering another fleet. Their good for just breaking up the campaign music with something a bit different and/or getting you prepped for a fight. I don't think per-faction music is a thing. I am not 100% on that though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 29, 2017, 10:07:12 PM
If you add new hullmods, and they aren't set to be unlocked by default, will they randomly generate as loot automatically, or do you need to set that manually?

What determines which mods show up in shops - manually set, or based on tier?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 30, 2017, 02:30:42 AM

Encounter music is only played when encountering another fleet. Their good for just breaking up the campaign music with something a bit different and/or getting you prepped for a fight. I don't think per-faction music is a thing. I am not 100% on that though.

Well that's a dissapointment. It takes you 3 seconds to select a response, that can't even be called "music", more of a sound effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on April 30, 2017, 03:45:01 AM
How the hell do I open the music.bin?

It doesn't look like it's a calssical .bin file magic ISO can't covert it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MinusUdn on April 30, 2017, 08:13:58 AM
Is it posible to change the owner of a vanilla planet/base?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Toxcity on April 30, 2017, 11:49:39 AM
How the hell do I open the music.bin?

It doesn't look like it's a calssical .bin file magic ISO can't covert it.

Just open it like you would an archive; with something like 7zip or Winrar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on April 30, 2017, 03:27:10 PM
Well then, here are some pretty complex things that I can't manage to make on my own, since I'm new to the java thingy :

1) I remember that there was a way to regenerate armor and hull (in the radioactive code dump, and with a skill on 0.7.2). Is this still working, and can I make some sort of healing projectile (Like, molten metal infused with nano-machine shell that repair armor and hull breach on impact with an allied ship (thanks to it's IFF), or does some damage & EMP damage on enemy ships (the nano-machine can also melt functionnal part instead of repairing breaches) ?
That would be great for my ballistic faction : Firing large weapon at allied cruisers and destroyer to patch'em up before an Onslaught fight, of using flak weaponry to repair allied fighter actually fighting a enemy destroyer.

2) In the same fashion, is there a way to make that work with a beam, in a more "stealing" mecanic ? I kinda want to do an electroleech matrix that steal armor and hull fragment to heal the firing ship, with the downside of stealing some of the flux and hard flux of the target in the process. If that's possible, I'll also make a "gravedigger" thingy that will only work on wreckage (perfect for a more predatory faction that can only "heal" after scoring some kills).

3) I know that the Templar mod have a really great shield, which seems to be really hard to make. I was wondering if, by using ship stats, I could get armor and hull damage to convert into flux (an simulate a shield with blue damage text, which is the easy part) for a less complex, less powerfull alternate shield system.

4) How can I made a guided projectile that's not really a missile (as in, doesn't distract enemy point defence and doesn't get destroyed by others shots and beam ? Being distracted by flare doesn't really bother me if that's can't be modified) ? I've tried with a missile by setting it's collision class to none and collision radius to 0, which work great at making it untargetable, but to make it collide against anything (i.e asteroids, fighters, drones, ships, missiles & bombs) I need either a script (not working at the moment, the projectile just pass trought everything) or a MIRV behavior to "split" it into a collidable projectile (but then, the splitting debris shows and while that could work for a ballistic projectile, that's quite not good for a energy projectile.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on April 30, 2017, 04:02:17 PM
For the first/second one, I can at least point you in the right direction.

Code
ShipAPI ship = (ShipAPI) target
ship.getFluxTracker().increaseFlux

Would increase the flux of the enemy ship - change it to increase your own flux and decrease the other guys, and you're half way there. Stick it in a beamEffect, and you've got doing damage + draining their flux and adding to yours. You'd need to test that repair stuff from the code dump, possibly update it to work, and stick that in as an everyFrameEffect.

You'll need to dig through the ShipAPI for the best way to designate the source ship, I dunno off the top of my head.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on May 01, 2017, 05:15:01 AM
Thanks, I've tried some little thing here and there, and I ended up with that crashlog :
Code
64439 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at data.scripts.weapons.SCQ_ElectroleechMatrix.advance(SCQ_ElectroleechMatrix.java:64)
at com.fs.starfarer.combat.entities.ship.A.void.advance(Unknown Source)
at com.fs.starfarer.combat.systems.oOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceLinked(Unknown Source)
at com.fs.starfarer.combat.systems.oOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Process finished with exit code 1

The script :
Spoiler
Pretty sure that the "ShipAPI ship = (ShipAPI) target;" should be declared differently, but I don't remember how to check if the CombatEntityAPI "target" is a ShipAPI and removing the "(ShipAPI)" part prevent me from compiling it.
Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.loading.WeaponSpecAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponSize;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.combat.entities.Ship;
import com.sun.org.apache.bcel.internal.generic.Select;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lazywizard.lazylib.combat.entities.SimpleEntity;
import org.lwjgl.util.*;
import org.lwjgl.util.vector.Vector2f;

import java.awt.*;
import java.awt.Color;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class SCQ_ElectroleechMatrix implements BeamEffectPlugin {
    private float sustainedFlux, sustainedDps, leechFluxFraction, leechHealthFraction, shipHealth, shipMaxHealth;
    private Color fluxLeechColor, healthLeechColor;
    private int targetOwner, beamOwner;
    private boolean runOnce = false;
    //private static String arcSound;
    private final IntervalUtil timer = new IntervalUtil(0.05f, 0.05f);

    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {   // public void advance(float amount, List<InputEventAPI> events) {   //for a BEFCP
        // Don't bother with any checks if the game is paused
        if (engine.isPaused()) {
            return;
        }
        if (!runOnce) {
            runOnce = true;
            if (beam.getWeapon().getSize() == WeaponSize.SMALL){
                leechFluxFraction = 1.2f;
                leechHealthFraction = 0.8f;
                fluxLeechColor = new Color(135, 100, 150, 160);
                healthLeechColor = new Color(235, 120, 50, 200);
            }  else if(beam.getWeapon().getSize() == WeaponSize.MEDIUM){
                leechFluxFraction = 1.0f;
                leechHealthFraction = 1.0f;
                fluxLeechColor = new Color(125, 60, 150, 180);
                healthLeechColor = new Color(200, 100, 40, 220);
            } else if(beam.getWeapon().getSize() == WeaponSize.LARGE){
                leechFluxFraction = 0.9f;
                leechHealthFraction = 1.1f;
                fluxLeechColor = new Color(100, 30, 130, 200);
                healthLeechColor = new Color(190, 70, 0, 240);
            }
            return;
        }

        if (beam.getBrightness() >= 1f) {
            timer.advance(amount);
            if (timer.intervalElapsed()) {
                //float bonusDamage = beam.getSource().getMutableStats().getEnergyWeaponDamageMult().getBaseValue();
                CombatEntityAPI target = beam.getDamageTarget();//does the beam hit something
                ShipAPI ship = (ShipAPI) target;
                targetOwner = target.getOwner();
                beamOwner = beam.getSource().getOwner();
                sustainedFlux = beam.getWeapon().getDerivedStats().getSustainedFluxPerSecond();
                sustainedDps = beam.getWeapon().getDerivedStats().getSustainedDps();
                shipHealth = beam.getSource().getHitpoints();
                shipMaxHealth = beam.getSource().getMaxHitpoints();
                //ship.getFluxTracker().increaseFlux
                if (ship != null) {
                    ship.getFluxTracker().decreaseFlux(sustainedFlux * leechFluxFraction);
                    engine.addHitParticle(
                            beam.getTo(), //Vector2f location
                            beam.getFrom(), //Vector2f velocity
                            MathUtils.getRandomNumberInRange(0.5f, 1.8f), //float size
                            MathUtils.getRandomNumberInRange(0.5f, 1.8f), //float brightness
                            MathUtils.getRandomNumberInRange(0.5f, 1.8f), //float duration
                            healthLeechColor); //Color color
                    if (targetOwner != beamOwner) {
                        if ((shipHealth + sustainedDps * leechHealthFraction) < shipMaxHealth) {
                            beam.getSource().setHitpoints(shipHealth + sustainedDps * leechHealthFraction);
                            engine.addHitParticle(
                                    beam.getTo(), //Vector2f location
                                    beam.getFrom(), //Vector2f velocity
                                    MathUtils.getRandomNumberInRange(0.5f, 1.8f), //float size
                                    MathUtils.getRandomNumberInRange(0.5f, 1.8f), //float brightness
                                    MathUtils.getRandomNumberInRange(0.5f, 1.8f), //float duration
                                    fluxLeechColor); //Color color
                        }
                    }
                }
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 01, 2017, 05:28:07 AM
Well then, here are some pretty complex things that I can't manage to make on my own, since I'm new to the java thingy :
1) I remember that there was a way to regenerate armor and hull (in the radioactive code dump, and with a skill on 0.7.2). Is this still working, and can I make some sort of healing projectile (Like, molten metal infused with nano-machine shell that repair armor and hull breach on impact with an allied ship (thanks to it's IFF), or does some damage & EMP damage on enemy ships (the nano-machine can also melt functionnal part instead of repairing breaches) ?
That would be great for my ballistic faction : Firing large weapon at allied cruisers and destroyer to patch'em up before an Onslaught fight, of using flak weaponry to repair allied fighter actually fighting a enemy destroyer.

IIRC, I have hull and armor repair as hullmods in the VNS add-on for Ironcalds. Do a search and just use the hullmod code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on May 01, 2017, 05:39:52 AM
Thanks, I'll go get a look
If it's working for a hullmod, may it also work as an onHitEffect/everyFrameCombatPlugin ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MinusUdn on May 01, 2017, 05:01:00 PM
How do I make custom ships appear in markets or in faction fleets? I tried creating a .faction file in the /world/factions folder but it doesn't work
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Calodine on May 01, 2017, 08:05:51 PM
So long as you've made variants and put those variants to be used in fleets, it should. For example:

Code
{
    "shipRoles":{
        "combatSmall":{
   "atx_herald_strike":2,
        },
    },
},

In independent.faction.
If you've set the value to 1, and only put like, one variant in one fleet, it might just not be showing up in markets/fleets due to coincidence. But that'll definitely do it - I got real familiar with findship in the console because I was sure I'd missed something.

By far the best/quickest way to check is to grab the console mod, start a new game, then findship (ship's name). Try a couple, you can still get unlucky. But starting a new game is easily the quickest way to refresh the markets (Until the console's updated properly).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 02, 2017, 12:51:35 AM
So I'm d***g around, trying to figure out economy. Looking into the Light Industrial Complex, I'm a bit confused.

Where are the 3 values (LIGHT_INDUSTRY_ORGANICS, LIGHT_INDUSTRY_VOLATILES, LIGHT_INDUSTRY_MACHINERY) defined?

Code
		market.getDemand(Commodities.ORGANICS).getDemand().modifyFlat(id, mult * ConditionData.LIGHT_INDUSTRY_ORGANICS);
market.getDemand(Commodities.VOLATILES).getDemand().modifyFlat(id, mult * ConditionData.LIGHT_INDUSTRY_VOLATILES);
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().modifyFlat(id, mult * ConditionData.LIGHT_INDUSTRY_MACHINERY);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 02, 2017, 04:41:51 AM
So I'm d***g around, trying to figure out economy. Looking into the Light Industrial Complex, I'm a bit confused.

Where are the 3 values (LIGHT_INDUSTRY_ORGANICS, LIGHT_INDUSTRY_VOLATILES, LIGHT_INDUSTRY_MACHINERY) defined?

Code
		market.getDemand(Commodities.ORGANICS).getDemand().modifyFlat(id, mult * ConditionData.LIGHT_INDUSTRY_ORGANICS);
market.getDemand(Commodities.VOLATILES).getDemand().modifyFlat(id, mult * ConditionData.LIGHT_INDUSTRY_VOLATILES);
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().modifyFlat(id, mult * ConditionData.LIGHT_INDUSTRY_MACHINERY);
com.fs.starfarer.api.impl.campaign.econ.ConditionData

...you know, it's in the same package.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on May 04, 2017, 05:08:20 AM
I find the derelict fights too easy and they get boring after a while. So while looking into the files to change the strength I found those lines in the salvage_entity_gen_data.csv

Code
probDefenders	minStr	maxStr	maxSize

The first is easy to understand, but I'm not sure about the other three. Is maxSize related to the max ship size that I can find? If so if I put maxStr something like 30 will they be only a bunch of frigates if I let maxSize on 1?

EDIT. Seems like this is the case from my testing. I'd like to change my question then, where would I modify what the derelict ships drop? Battles with them are fun now but I get waaay too many supplies and XP.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on May 04, 2017, 01:19:09 PM
Quick one: Does the StarSystemGenerator.addOrbitingEntities() avoids existing entities or does it add stuff anywhere past the set radius?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 04, 2017, 01:57:32 PM
EDIT. Seems like this is the case from my testing. I'd like to change my question then, where would I modify what the derelict ships drop? Battles with them are fun now but I get waaay too many supplies and XP.

Reduce supplies/rec for the domain drones in ship_data.csv - drop value is based on that.


Quick one: Does the StarSystemGenerator.addOrbitingEntities() avoids existing entities or does it add stuff anywhere past the set radius?

It assumes the area past that radius is empty.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 04, 2017, 03:26:52 PM
EDIT. Seems like this is the case from my testing. I'd like to change my question then, where would I modify what the derelict ships drop? Battles with them are fun now but I get waaay too many supplies and XP.

Reduce supplies/rec for the domain drones in ship_data.csv - drop value is based on that.

Intriguing. Is this the case for all ships when salvaging them or destroying them in combat? I know scuttling ships gives you supplies and fuel equal to their [base] monthly maintenance cost, but if the drop-rate for ships is also related to stats, that's useful to know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on May 04, 2017, 11:39:42 PM
EDIT. Seems like this is the case from my testing. I'd like to change my question then, where would I modify what the derelict ships drop? Battles with them are fun now but I get waaay too many supplies and XP.

Reduce supplies/rec for the domain drones in ship_data.csv - drop value is based on that.

Thanks, but would that affect the XP given at all?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 06, 2017, 04:12:22 AM
It's been a while and I can't find any notes in the system files themselves or in the starfarer.api.zip
What does each variable do again?

PlanetAPI hekla = system.addPlanet("hekla", thule_star, "Hekla", "toxic", 0, 160, 2870, 90);

If I'm understanding this right,it's:

addPlanet(internal ID, what does it orbit?, name that shows up, PLANET TYPE, ???, planet radius?, orbit radius?, rotation speed?);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pushover on May 06, 2017, 04:36:22 AM
It's been a while and I can't find any notes in the system files themselves or in the starfarer.api.zip
What does each variable do again?

PlanetAPI hekla = system.addPlanet("hekla", thule_star, "Hekla", "toxic", 0, 160, 2870, 90);

If I'm understanding this right,it's:

addPlanet(internal ID, what does it orbit?, name that shows up, PLANET TYPE, ???, planet radius?, orbit radius?, rotation speed?);


See the Javadoc here: http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

LocationAPI has the addPlanet function.
Code
addPlanet(java.lang.String id, SectorEntityToken focus, java.lang.String name, java.lang.String type, float angle, float radius, float orbitRadius, float orbitDays) 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on May 06, 2017, 04:54:59 AM
Quick question:

When exactly is crew loss calculated, and how? Is it done during combat, or at the end?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 06, 2017, 04:55:38 AM
Why does the second line still return true?
Code: java
Global.getSector().removeScriptsOfClass(com.fs.starfarer.api.impl.campaign.CoreScript.class);
Global.getSector().hasScript(com.fs.starfarer.api.impl.campaign.CoreScript.class);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 06, 2017, 11:20:45 AM
Intriguing. Is this the case for all ships when salvaging them or destroying them in combat? I know scuttling ships gives you supplies and fuel equal to their [base] monthly maintenance cost, but if the drop-rate for ships is also related to stats, that's useful to know.

Yeah, it is.

When exactly is crew loss calculated, and how? Is it done during combat, or at the end?

At the end, in the FleetEncounterContext class, using stats collected during combat (i.e. hull damage taken etc).

Thanks, but would that affect the XP given at all?

IIRC that would also reduce the XP - but if it doesn't, then reducing their fleet point cost will.

Why does the second line still return true?
Code: java
Global.getSector().removeScriptsOfClass(com.fs.starfarer.api.impl.campaign.CoreScript.class);
Global.getSector().hasScript(com.fs.starfarer.api.impl.campaign.CoreScript.class);

Are you absolutely sure? This seems to work for me (i.e. second line returns false).






Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 06, 2017, 07:30:28 PM
Why does the second line still return true?
Code: java
Global.getSector().removeScriptsOfClass(com.fs.starfarer.api.impl.campaign.CoreScript.class);
Global.getSector().hasScript(com.fs.starfarer.api.impl.campaign.CoreScript.class);
Are you absolutely sure? This seems to work for me (i.e. second line returns false).
It turns out I had to also remove my own custom core script (which extends vanilla CoreScript) to get it to return false.
Although now I have a new problem: Removing the scripts in this manner doesn't stop their listener methods from being called. I can tell because jettisoning cargo in space creates two cargo pod clusters, each with the full amount of dumped cargo, even after removing one or both core scripts.

Maybe I should explain what I'm trying to do:
Spoiler
If a game is started without the Nexerelin mod, and the player then enables the mod and loads the save, Nexerelin does some stuff to integrate itself into the game.
One of these things is removing the vanilla core script and adding its own. The Nexerelin version overrides assignPatrolSpawningScripts(), which adds a modded version of the patrol (and Lion's Guard) scripts to planets/stations, and uses its own logic for doing so. (Existing patrol scripts are removed).

What would you say is my best option for accomplishing this?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 06, 2017, 10:25:50 PM
Ahh, right, I see what you mean - that's an oversight on my part, let me add a getScripts() method so there's at least some way to get a reference to a particular script and de-register it as a listener.

In the meantime, in your shoes, I would override SectorGen entirely, via:
"newGameCreationEntryPoint":"data.scripts.world.SectorGen",

So that it never adds a CoreScript to begin with.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on May 07, 2017, 06:31:03 AM
Hi there, a really quick question :
Is there a way to make a weapon, especially a rotative one, that spool up when firing ? Not just a warm-up with a few animations frames without firing like it's already done, but a way that make the weapon RoF accelerate as the weapon charge progress, up to the full RoF when charge = 1.
I've been trying some things on my side but the only way I've found to set a firerate is by using the setRemainingCooldownTo(value) which doesn't really have the expected effect : my weapon fire random burst at random firerates, when it's firing at all. Most of the time, I end up with the cooldown stuck.

Any idea ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 07, 2017, 08:18:03 AM
I need to edit the following texts:
a) Skill effect descriptions
b) Campaign ability descriptions
c) The new campaign tutorial texts that are not on rules.csv and reports.csv
d) Texts on combat tutorials

Where can I find them and how do I override them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Schwartz on May 07, 2017, 09:57:47 AM
If I want to globally reduce the time acceleration for phase ships from 3x down to 2x, do I accomplish that by going into PhaseCloakStats.java and changing

public static final float MAX_TIME_MULT = 3f; to = 2f; ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 07, 2017, 10:26:05 AM
Help me out here, people.

The "shepherd_Frontier" doesn't appear anywhere at all in my files.

Code
4246 [Thread-4] INFO  com.fs.starfarer.loading.SpecStore  - Loading default_ship_roles.json
4265 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/world/factions/default_ship_roles.json)]
4265 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: G:\GAMES\Starsector\starsector-core\..\mods\Steelclad (data/world/factions/default_ship_roles.json)]
4465 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/particlealpha32sq.png (using cast)
4971 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull variant [shepherd_Frontier] not found!
java.lang.RuntimeException: Ship hull variant [shepherd_Frontier] not found!
at com.fs.starfarer.loading.A.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.U$Oo.<init>(Unknown Source)
at com.fs.starfarer.loading.U.<init>(Unknown Source)
at com.fs.starfarer.loading.SpecStore.new.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2017, 10:51:51 AM
@Mongreal: Ahh, I'm actually not sure off the top of my head. I want to say it's probably doable with a script - which you've been trying to do, looks like - but not 100% positive.

a) Skill effect descriptions

The various java class files referenced from the .skill files. To change the descriptions you also need to override the effects.

b) Campaign ability descriptions

.createTooltip() in the relevant ability class, referenced from data/campaign/abilities.csv

c) The new campaign tutorial texts that are not on rules.csv and reports.csv

com.fs.starfarer.api.impl.campaign.tutorial.CampaignTutorialScript.java

And possibly a bit in

com.fs.starfarer.api.impl.campaign.tutorial.TutorialMissionEvent.java

But you'd need to recompile those and adjust the game start to use the new versions.

d) Texts on combat tutorials

Can't, it's hardcoded.



If I want to globally reduce the time acceleration for phase ships from 3x down to 2x, do I accomplish that by going into PhaseCloakStats.java and changing

public static final float MAX_TIME_MULT = 3f; to = 2f; ?

You would need to:
1) Make a copy of that file, make the changes, recompile it
2) Change the phase cloak system to use your version of it


The "shepherd_Frontier" doesn't appear anywhere at all in my files.

Hmm - assuming this is in the context of a TC, right? Possibly needs to replace (via "replace" in mod_info.json) sim_opponents.csv, then. There's also data/config/title_screen_variants.csv, but the core one doesn't have a Shepherd in it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 07, 2017, 11:08:41 AM
The "shepherd_Frontier" doesn't appear anywhere at all in my files.

Hmm - assuming this is in the context of a TC, right? Possibly needs to replace (via "replace" in mod_info.json) sim_opponents.csv, then. There's also data/config/title_screen_variants.csv, but the core one doesn't have a Shepherd in it.

That's odd, because this is the mod file:

Code
{
"id":"Steelclad", # internal id
"name":"Steelclads", # displayed to the player
"author":"Okim/TrashMan",
"version":"v.01",
"description":"Its is 200+ years after humanity has discovered FTL drive technology. Four major factions have expanded their territory over several stars and established a fragile peace. However, greed and lust for power lead to disputes over the few habitable worlds, and the precious resources they held. As tensions rose, it was only a matter of time before war gripped the once peaceful systems.",
"gameVersion":"0.8.a",
"totalConversion":"true",


"modPlugin": "data.scripts.IroncladsModPlugin",


"replace":
[
"data/campaign/starmap.json",
"data/campaign/econ/economy.json",
"data/campaign/channels.json",
"data/characters/person_names.csv",

"data/config/custom_entities.csv",

"data/world/factions/player.faction",
"data/world/factions/neutral.faction",
"data/world/factions/pirates.faction",
"data/world/factions/independent.faction",
"data/world/factions/factions.csv",

"data/campaign/sim_opponents.csv",
"data/config/title_screen_variants.csv",
"data/missions/mission_list.csv",

"data/hulls/ship_data.csv",
"data/hulls/wing_data.csv",
"data/hullmods/hull_mods.csv",
"data/weapons/weapon_data.csv",
],

}


Hm..isn't custom_entities suppsoed to be a .json, not a .csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2017, 11:12:20 AM
Yeah, it's custom_entities.json.

Note: the mod also has to provide a sim_opponents.csv for the "replace" to do anything, the replace list just means "replace file with one from mod *if one exists*.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 07, 2017, 11:21:28 AM
Found the culprit. The sim_opponents didn't copy properly.

EDIT: Spoke too son. Nope.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2017, 12:13:16 PM
If you can upload the mod somewhere and send me a link, I can take a quick look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Galwail on May 07, 2017, 06:50:23 PM
Hi, quick modding question:

I'm trying to write a small mod, that changes the offices level up skill picks. I have written my own OfficerLevelupPlugin implementation and it works fine. The problem is, that I want my mod to be compatible with the Starsector+ mod, which uses its own OfficerLevelupPlugin implementation. Is there any way to handle this conflict? Is there any way to force the game to load a specific implementation of OfficerLevelupPlugin regardless of the content of the settings.json file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pushover on May 07, 2017, 11:24:52 PM
Found the culprit. The sim_opponents didn't copy properly.

EDIT: Spoke too son. Nope.

Could it be the tutorial? There's an instance in RogueMinerMiscFleetManager.java when it creates the miner guard fleet. I wouldn't think that it would load, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on May 08, 2017, 12:05:42 AM
Thanks Alex, I'll keep trying different things until that work.
Actually, I'm wondering if the weapon that will use such a script should be burst firing or just a regular one.
Seems like the burst mecanism may be usefull to determine if we're firing in the same spooling up sequence, but that may also be the thing that prevent the script from working.

I've tried variation of that :
Spoiler
Code
cooldown = weapon.getCooldown();
        if (weapon.isFiring() && cooldown >= minCooldown) {
            firerate = 1 / cooldown;
            nextFirerate = firerate + increment;
            nextCooldown = 1 / nextFirerate;
            weapon.setRemainingCooldownTo(nextCooldown);
        }
[close]
Dunno if isFiring() is better than getChargeLevel() >= 1f, but I don't see any change ingame.


Edit : Found something that seems to work better, by using intervals :
Spoiler
Code
charge = weapon.getChargeLevel();
        if (charge >= 0.9f) {
            if (!hasFired){
                fireInterval.advance(amount);
                if (fireInterval.intervalElapsed()) {
                    fireInterval.setInterval(0f, 1f);
                    hasFired = true;}
            }
            if (hasFired = true) {
                spoolUpInterval.advance(amount);
                if (!spoolUpInterval.intervalElapsed()) {
                        cooldown = weapon.getCooldown();
                        if (cooldown >= minCooldown) {
                            firerate = 1 / cooldown;
                            nextFirerate = firerate + (increment * spoolUpInterval.getElapsed());
                            nextCooldown = 1 / nextFirerate;
                            weapon.setRemainingCooldownTo(nextCooldown);
                        }
                    spoolUpInterval.advance(amount);
                } else if (spoolUpInterval.intervalElapsed() && charge >= 0.5f) {
                    cooldown = minCooldown;
                }
            }
        }
[close]
With that bit of code, the weapon is actually spooling up, but there is some unpredictible "cut" in the firing sequence. Also, the spool up ramp seems pretty long, looks like the firerate increase only once every three seconds or more. Any ideas on how to reduce that ramp, and why does the gun can randomly stop firing (with resuming it's spool up sequence or starting another one from 0)


Small update (but I'm still stuck !) :
I was tried to clean up my code, and end up with something that should work... If I manage to calculate if the weapon fired when the cooldown of the last shoot ended (so, the player/AI keep firing with that weapon), or if the delay was at least frame longer (meaning that during the same amount of time (here, cooldown of the last shoot elasped + 1 frame), the fire button wasn't pressed) and I can't find how to get that.
The cleaned code for the firerate (should work better with getCooldownRemaining, doesn't require a interval to ramp up or down, juste a +/- in front of the value that have to increment/decrement the firerate. Also check if we were already at the max/min firerate/cooldown, and spooling up/down ramps are more easy to work with) :
Spoiler
Code
cooldown = weapon.getCooldownRemaining();
            nextFirerate = 0f;
            firerate = 1 / cooldown;
            if (firedLastInterval) {
                if (cooldown > minCooldown) {
                    nextFirerate = firerate + modifier;     //* spoolingInterval.getElapsed())
                } else {
                    weapon.setRemainingCooldownTo(minCooldown);
                }
            } else if (!firedLastInterval) {
                if (cooldown < maxCooldown) {
                    nextFirerate = firerate - modifier;     //* spoolingInterval.getElapsed())
                } else {
                    weapon.setRemainingCooldownTo(maxCooldown);
                }
            }
            if (nextFirerate != 0f) {
                nextCooldown = 1 / nextFirerate;
                weapon.setRemainingCooldownTo(nextCooldown);
            }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 08, 2017, 02:07:55 AM
If you can upload the mod somewhere and send me a link, I can take a quick look.

Well, I just f**** up massively, since I compressed the entire mod and put it on a USB to continue work on the mod on my laptop (I travel around) and now I can't find it.
Meaning, that until I get back home (not before Firday) I can't do s***.


But I do have SOME files on the USB, so I might at least do something.
Come to think of it, given the changes to sensors, will this work?


Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipAPI;

public class AmplifiedSensors2 extends BaseHullMod {

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 50f);
mag.put(HullSize.FRIGATE, 75f);
mag.put(HullSize.DESTROYER, 100f);
mag.put(HullSize.CRUISER, 125f);
mag.put(HullSize.CAPITAL_SHIP, 150f);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}


public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getSightRadiusMod().modifyPercent(id, (Float) mag.get(hullSize));
stats.getAutofireAimAccuracy().modifyPercent(id, 25f);
stats.getSensorStrength().modifyPercent(id, 1000f);
}


}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SainnQ on May 08, 2017, 04:25:36 AM
Where would I look to tweak the size of a given factions mods?

I'm not a fan of there being something like 6-7 Independent stations, but only one proper military station, and a subpar one at that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cosmitz on May 08, 2017, 01:42:58 PM
LE: Nevermind.  Game doesn't crash at load when parsing the ship_data.csv if it cannot find the ship system attached to it. It crashes within the game when it has to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on May 08, 2017, 01:50:32 PM
Is there a way to ensure a tidally locked planet has the right facing to the star? I have a texture with clear day and night sides, but the planet always seems to be generated with a random angle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2017, 03:24:39 PM
Where would I look to tweak the size of a given factions mods?

I'm not a fan of there being something like 6-7 Independent stations, but only one proper military station, and a subpar one at that.

data/econ/economy.json and related files.

Is there a way to ensure a tidally locked planet has the right facing to the star? I have a texture with clear day and night sides, but the planet always seems to be generated with a random angle.

I'd say your best bet is to run a script post-procgen and do the tidal-locking there (i.e. set rotation to 0, set the angle to whatever is necessary, attach a custom script that would keep this up-to-date with the orbital position, etc).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cosmitz on May 08, 2017, 08:31:18 PM
I'm making a shipsystem, all fine and dandy, adds flux dissipation and a flat hard flux dissipation. The script. https://pastebin.com/GXTKrN7A

However... I'd like to force a vent at the end of the ship system. Maybe even with a forced short overload of 2-3 seconds. However, my knowledge of java is disasterous. I'd assume something like this?

public ShipSystemStatsScript.StatusData getStatusData(int index, ShipSystemStatsScript.State state, float effectLevel) {
      if (state == ShipSystemStatsScript.State.OUT) somethingsomething.FluxTrackerAPI().forceOverload(0) ?

I just don't know. Will prolly hit the books tomorrow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 09, 2017, 03:52:26 AM
Would still want an answer to my previous question, and I have more:

- I just took a glance at stations, can they have more than 3 sections? Anything specific I have to watch out for when making new stations?

- say I wanted to spaw a powerful alien fleet after 300 days or when a player reaches lvl10. What is the code for those conditional checks?
I have this script:

Code
package data.scripts.world;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import data.scripts.world.FleetSpawner;
import data.scripts.plugins.SectorScans;

import java.awt.*;
import java.util.GregorianCalendar;


public class TimeManager implements EveryFrameScript, SpawnPointPlugin {
    private static final float BASE_INTERVAL = 1.0f;
    private static final int FIRST_DAY_IN_WEEK = GregorianCalendar.SUNDAY;
    private float heartbeatInterval;
    private long lastHeartbeat;
    private  int days;
    private GregorianCalendar calendar = new GregorianCalendar();

    //private SectorAPI Player = Global.getSector();
    //private DataSafe.PlayerData data = DataSafe.getPlayerData(Player);

    private CampaignFleetAPI playerFleet;

    private static final Color HIGHLIGHT_COLOR = Global.getSettings().getColor("buttonShortcut");
    private static final Color RED = Global.getSettings().getColor("darkRedTextColor");
    private static final Color GREEN = Global.getSettings().getColor("textFriendColor");
    private static final Color YELLOW= Global.getSettings().getColor("darkYellowTextColor");
    private static final Color CYAN = Global.getSettings().getColor("textNeutralColor");

    private StarSystemAPI starSystem;

    public TimeManager()
    {
        lastHeartbeat = Global.getSector().getClock().getTimestamp();
        heartbeatInterval = (1.0f - (Global.getSector().getClock().getHour() / 24f));
    }

    private void runHourly()
    {



    }

    private void runDaily()
    {
        //playerFleet = Global.getSector().getPlayerFleet();

        relationshipChecker();
        SectorScans.probing();

        informer();
        loan_checker();
        FleetSpawner.WDW_spawner();
        FleetSpawner.MAR_spawner();
        FleetSpawner.FFS_spawner();
        FleetSpawner.pirate_spawner();
        FleetSpawner.isa_rsf_invaders_spawn();
        FleetSpawner.aliens_spawner();
        FleetSpawner.rock_spawner();
        FleetSpawner.AI_spawner();

        //Global.getSector().getCampaignUI().addMessage("A day has passed...");

    }

    private void runWeekly()
    {
        productionManager();
        //FleetSpawner.patrol_spawner();
FleetSpawner.vnsmain_spawner();
    }

    private void runEach20()
    {

        days = 0;
    }

    private void runMonthly()
    {

       
    }


    private void runYearly()
    {

    }



    public void advance(SectorAPI sectorAPI, LocationAPI locationAPI)
    {
        if (sectorAPI.getClock().getElapsedDaysSince(lastHeartbeat) >= heartbeatInterval)
        {
            doIntervalChecks(sectorAPI.getClock().getTimestamp());
            checkSynched();
        }
    }

    private void doIntervalChecks(long time)
    {
        lastHeartbeat = time;
        runDaily();
        days++;
        calendar.setTimeInMillis(time);

        /*if (days == 20)
        {
            runEach20();
        } */

        if (calendar.get(GregorianCalendar.DAY_OF_WEEK) == FIRST_DAY_IN_WEEK)
        {
            runWeekly();
        }

        if (calendar.get(GregorianCalendar.DAY_OF_MONTH) == 1)
        {
            runMonthly();

            if (calendar.get(GregorianCalendar.DAY_OF_YEAR) == 1)
            {
                runYearly();
            }
        }
    }

    private void checkSynched()
    {
        // Compensate for day-synch code in constructor
        if (heartbeatInterval != BASE_INTERVAL)
        {
            heartbeatInterval = BASE_INTERVAL;
        }
    }


    private void shipConstructor()
    {

    }


    private void relationshipChecker()
    {
        float pirate = Global.getSector().getPlayerFleet().getFaction().getRelationship("pirates");
        float indy = Global.getSector().getPlayerFleet().getFaction().getRelationship("independent");
        float wdw = Global.getSector().getPlayerFleet().getFaction().getRelationship("WDW");
        float mar = Global.getSector().getPlayerFleet().getFaction().getRelationship("MAR");

        if (indy < -0.6f && !Global.getSector().getEntityById("pixie").hasTag("most_wanted"))
        {
            Global.getSector().getPlayerFleet().getFaction().setRelationship("UIN", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("XLE", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("RSF", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("ISA", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("VNS", RepLevel.HOSTILE);

            Global.getSector().getCampaignUI().addMessage("For your continuous aggression against Free Traders Guild you are being put at 'most wanted' list by all major factions!", Color.RED);

            Global.getSector().getEntityById("pixie").addTag("most_wanted");
        }

        else if (indy > -0.15f && Global.getSector().getEntityById("pixie").hasTag("most_wanted"))
        {
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("UIN", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("XLE", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("RSF", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("ISA", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("VNS", +0.15f);

            Global.getSector().getCampaignUI().addMessage("Your attempts to repair relationship with the Free Traders Guild was noticed by the major factions.", Color.YELLOW);

            Global.getSector().getEntityById("pixie").removeTag("most_wanted");
        }

    }



    @Override
    public boolean isDone() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean runWhilePaused() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void advance(float v) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

}

But how would I check player level and current day?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vorpal+5 on May 10, 2017, 07:39:11 AM
Is there any possibility to play in slow motion / bullet time? I know what you people think about that, probably, but really, I would really enjoy that. I would even be prepare for a paypal donate if it happened, really!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on May 10, 2017, 08:24:48 AM
If you have some really basic Java knowledge, you can take the Fleet Building Tounament's mission and reverse engineer the slow-mo key function.

http://fractalsoftworks.com/forum/index.php?topic=11539.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on May 10, 2017, 11:05:35 AM
so in my question to rebalance some of the vanilla weapons, I've come upon a thing; I want to remove the rocket pod's shot spread, or at least its set-in-stone shot spread. Where is that behavior located? I see nothing in the weapons data that would indicate it
EDIT: never mind got an answer in the discord, barrel angle offset in the annihilator weapon file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 11, 2017, 05:55:24 AM
Is there a difference between the SECTOR and ENSURE_DELIVERY message priorities?

Do tariffs have any impact on NPC trade?

Does killing trade fleets actually affect trade flows in any way in 0.8?

- say I wanted to spaw a powerful alien fleet after 300 days or when a player reaches lvl10. What is the code for those conditional checks?
[...]
But how would I check player level and current day?
Player level: Global.getSector().getPlayerPerson().getStats().getLevel();
Current day: You can get the day/month/year displayed (e.g. 31 Jan 208) with a CampaignClockAPI (Global.getSector().getClock()), but for actually getting ingame time since start of game I don't know how to other than manually using advance() in a script added at the start of the game
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 11, 2017, 10:36:58 AM
Is there a difference between the SECTOR and ENSURE_DELIVERY message priorities?

Yes, SECTOR will expire after about a month of being undeliverable, while ENSURE_DELIVERY will stick around for 10k days before being discarded.

Also SECTOR is capped to 100 light-years - a holdover from when that was more than big enough to cover anything.

Do tariffs have any impact on NPC trade?

IIRC it does not.

Does killing trade fleets actually affect trade flows in any way in 0.8?

It does, but it's pretty obscure. Losses of trade fleets increase the "weight" of a market-market connection, making all trade along it flow with more difficulty.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on May 11, 2017, 11:00:49 AM
Something I never quite figured out, can you list a custom texture for "textureType" when using a BALLISTIC_AS_BEAM projectile or is it only limited to the defined textures like ROUGH etc? If not it would be nice to have that down the road someday (along with custom thruster and shield textures)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 11, 2017, 11:08:47 AM
Commented-out example from hil.wpn:

"textureType":ROUGH,
#"textureType":["graphics/fx/emp_arcs.png","graphics/fx/emp_arcs.png"],

I forget whether the first or second array entry is the fringe...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on May 11, 2017, 11:14:24 AM
I tried to play a lot with custom textures, and while it work on true beams using a custom one on ballistic_as_beam always reverted to the ROUGH one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on May 11, 2017, 11:34:01 AM
(http://i.imgur.com/bTNBtbQ.png)

The mapping is different from what I expected but seems like it definitely does something!

E: Hmm scratch that, seems like it looks like this no matter what textures I pick

E2: Oh hold on, it works but you need to not have a projectile sprite set!

E3: This is cool, you can make some seriously odd looking projectiles. I managed to make it look like its almost spinning:

https://www.youtube.com/watch?v=nJgmR-x5BkQ
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 11, 2017, 04:59:10 PM
Guys.
How can I change turret type in different skin for hull?
Like changing ballistic to missile.
I can remove them but can I add others?
Or there is some easier process?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 11, 2017, 05:13:59 PM
Guys.
How can I change turret type in different skin for hull?
Like changing ballistic to missile.
I can remove them but can I add others?
Or there is some easier process?

Don't worry, it's an easy one - and it is changed in the skin file, it's just a less common thing. For reference, have a look at the pirate Mule and Buffalo - both have weapon mount type changes which are referenced in the skin file under the tag "weaponSlotChanges".

For instance, here's the skin file for the pirate Buffalo with the relevant bit highlighted:

Spoiler

{
   "baseHullId":"buffalo",
   "skinHullId":"buffalo_pirates",
   "hullName":"Buffalo (D)",
   "descriptionId":"buffalo",  # optional
   "descriptionPrefix":"This ship has been heavily modified - and poorly maintained - by its pirate crew.",
   "spriteName":"graphics/ships/buffalo/buffalo_pirates.png",
   "removeWeaponSlots":[],       # ids
   "removeEngineSlots":[],       # indices, as engine slots have no id in the .ship file
   "removeBuiltInMods":["degraded_engines"],       # hullmod ids
   "removeBuiltInWeapons":[],       # weapon slot ids
   "weaponSlotChanges":{
      "WS 001":{
         #"angle": 0,
            #"arc": 210,
            #"mount": "TURRET",
            #"size": "SMALL",
            "type": "BALLISTIC"
      }   
   },

   #"builtInMods":["comp_armor","comp_hull","degraded_engines","faulty_grid","destroyed_mounts"],
   "builtInMods":["shielded_holds"],
   "builtInWeapons":{
   },
}

[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 11, 2017, 05:44:41 PM
Thanks, that will help.
Actually I just made separate entry at Mora_path and change their turrets.
Anyway thanks will help in other stuff.
Cheers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SainnQ on May 12, 2017, 05:46:39 AM
What is the recommended file editor to use when modifying ship stats in the Ships.csv file?

I have Notepad++ & Sublime Text 2 available.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 12, 2017, 06:31:55 AM
Thanks again Alex!

What is the recommended file editor to use when modifying ship stats in the Ships.csv file?
I use Excel and/or LibreOffice Calc. IIRC some people have reported problems with the former, but the latter should always work if the separators and text delimiters (in particular) are set up right:

Spoiler
(http://i.imgur.com/2QGHZVH.png)
[close]

Using a plain text editor probably won't work well since the only way to get the columns would be counting commas.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on May 12, 2017, 10:15:30 AM
Text-based CSV editing is possible; I just find it tedious.  My preference is to use a .xlsx master file and "bake" down to a csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on May 12, 2017, 11:35:14 AM
What is the recommended file editor to use when modifying ship stats in the Ships.csv file?

I have Notepad++ & Sublime Text 2 available.



Anything CVS I use Google sheets. New, blank sheet, open new, tab over to upload and voila, now your CVS is auto-backed up by day. Everything else I use notepad++
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 13, 2017, 05:36:01 AM
What's the meaning of tags in weapon_data.csv ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DarkerThanBlack on May 13, 2017, 10:26:52 AM
Question regarding the max burn level.
Is there a way to increase the max burn rate so I can have lighter ship fleets go faster then 20? I haven't found any setting to do that.

I know the UI has only 20 pips but I can distinctly remember being able to go past 20 in 0.7.2 that has seem to be changed in 0.8 and is now capped to 20.
The upgraded sustained burn (+5 burn) skill is kind of overpowered (this might have be indented) since I don't know of any capital ship that has a burn level of 5 or less (without D mods, in the vanilla game).
Anyways point being a light fleet will have the same speed as a capital ship fleet using sustained burn (and frankly I use S Burn all the time). The loss of agility is at best a slight inconvenience factor since chased AI fleets seem to not make any sharp turns. Or they do E Burns in the opposite direction, however that ends up not working out for them since I come in with 20 burn speed and catch them from behind before they can dodge or catch relevant speed.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 13, 2017, 11:33:42 AM
Is it me or did the launch bays change in 0.8? Every time a try to put a launch bay from Trylobot's ship editor it doesn't appear in-game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 13, 2017, 12:23:24 PM
Is it me or did the launch bays change in 0.8? Every time a try to put a launch bay from Trylobot's ship editor it doesn't appear in-game.

for some reason, you have to also define the number of bays in the ship_data.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 13, 2017, 02:44:43 PM
Is it me or did the launch bays change in 0.8? Every time a try to put a launch bay from Trylobot's ship editor it doesn't appear in-game.

for some reason, you have to also define the number of bays in the ship_data.csv

*Facepalms* yep it seems that there are new values in 0.8 that I overlooked, Anyway, thanks mate
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 13, 2017, 04:19:01 PM
What's the meaning of tags in weapon_data.csv ???

Tags act as a guide for the Autofit mechanic. If you're trying to fit a variant that requires, say, a light dual autocannon for instance, but you only have single autocannons, it'll use them instead. How does it know that one is just a better version of the other? Tags!

Best way to figure things out is look through the tags in the stock files. The letters are the tag of the weapon, and say what it's used for, and the number is a rough estimation of how good it is at that thing.

For instance the light assault gun has "he6" as a tag. "he" for High Explosive damage, and "6" for a middling level. In contrast, the assault chaingun has "he15" and "SR" (Short Range), so the game knows it's a better option for HE damage than a light assault gun, but also knows it's a short range weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 13, 2017, 09:12:26 PM
How can I...
1. immediately force disarm a missile?
2. get which ship an instance of MissileAPI is targeting?(I don't know how to use getTarget())
3. make a missile explode(with AoE damage) on contact?
4. immediately force explosion of a missile?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 13, 2017, 09:24:39 PM
What's the meaning of tags in weapon_data.csv ???

Tags act as a guide for the Autofit mechanic. If you're trying to fit a variant that requires, say, a light dual autocannon for instance, but you only have single autocannons, it'll use them instead. How does it know that one is just a better version of the other? Tags!

Best way to figure things out is look through the tags in the stock files. The letters are the tag of the weapon, and say what it's used for, and the number is a rough estimation of how good it is at that thing.

For instance the light assault gun has "he6" as a tag. "he" for High Explosive damage, and "6" for a middling level. In contrast, the assault chaingun has "he15" and "SR" (Short Range), so the game knows it's a better option for HE damage than a light assault gun, but also knows it's a short range weapon.

Thank you! I think i have understood a bit.
"he6"'s "6" is like a weight in weight picker, but if any modder make his weapon all "xx99", it will be a bad situation isnt it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 13, 2017, 10:14:01 PM
1. immediately force disarm a missile?
MissileAPI.setArmingTime(99999)

Quote
2. get which ship an instance of MissileAPI is targeting?(I don't know how to use getTarget())
MissileAIPlugin ai = MissileAI.getMissileAI()
cast to GuidedMissileAI (the AI plugin may not implement this, so do an instanceof check if you don't know whether it does)
SectorEntityToken target = ai2.getTarget()

Quote
3. make a missile explode(with AoE damage) on contact?
If for some reason you can't use the vanilla AoE tags, I'd use an onHitEffect script and apply damage to nearby entities manually. (Dunno if there's an easier way)

Quote
4. immediately force explosion of a missile?
GraphicsLib applies fatal amounts of damage to the missile for its missile self-destruct effect, but I dunno if this applies any vanilla AoE effects it might have. (If you're using a custom AoE script effect you can just call its methods ofc)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 13, 2017, 11:44:01 PM
And how do I use vanila AoE tag?
(And flak cannon suggests that force explosion is doable without script or flak has that script, hmmmmm.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 14, 2017, 12:00:10 AM
Copy the flak .wpn tags, yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 14, 2017, 12:13:52 AM
"he6"'s "6" is like a weight in weight picker, but if any modder make his weapon all "xx99", it will be a bad situation isnt it?

To clarify, it's not really a weight value. That usually refers to random selection. Autofit will always try to equip the best weapon it can, if there are ordnance points to spare. As long this "xx99" weapon isn't itself overpowered, all that tag would do is make Autofit always try to equip it (if possible). It's not weight so much as "how good this thing is at its job."
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 14, 2017, 07:31:43 AM
Posting here in hopes of getting a swift answer:

*SNIP - fixed it*

EDIT:

Trough sheer perserverance I managed to get past most bugs.
Finally got to the last stage of loading - the fleet spawning script.
but it's telling me that this line:

                target_name = xle_mining_sites[rnd.nextInt(xle_mining_sites.length)];


Line 29, Column 51: Unknown variable or type "rnd"

How does getting a random number work now?
Would:
Code
Random rnd = new Random(8);
generate a random number from 1 to 8?


EDIT2:

where is getContainingLocation() defined?
What do I have to import? can't seem to find it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 14, 2017, 09:14:10 AM
getContainingLocation() is a method of the SectorEntityToken interface.

The number arg for java.util.random is the seed (https://docs.oracle.com/javase/7/docs/api/java/util/Random.html). What you want is LazyLib's MathUtils.getRandomNumberInRange(min, max) method (https://bitbucket.org/LazyWizard/lazylib/src/5277425e96b23011fe2d90df864b0e42ea406fb7/org/lazywizard/lazylib/MathUtils.java?at=default&fileviewer=file-view-default#MathUtils.java-648:687).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 14, 2017, 09:29:29 AM
"A method named "getContainingLocation" is not declared in any enclosing class nor any supertype, nor through a static import"

which is strange, since I have

import com.fs.starfarer.api.campaign.*;

at the top of the script. SectorEntityToken should be also imported.
EDIT:

Specifying it manually seemed to work. But now I get this:

Cannot determine simple type name "Logger"

I removed all log lines and removed the "import org.apache.log4j.Logger;", but I'm still getting the error.

EDIT: Class initialization was left. I'm stupid.

EDIT3:

I have import java.util.Random;

but this:
Code
                Random rnd = new Random();
                int rng = rnd.nextInt(8);
if (rng >= 4) {
CampaignFleetAPI fleet = FleetFactory.createGenericFleet("ROCK", "Beast", 1f, 0);
fleet.getFleetData().sort();
FleetFactory.finishAndSync(fleet);
system.getContainingLocation().addEntity(fleet);

                    fleet.setLocation(system.getLocation().x + (float)Math.random()*1000, system.getLocation().y - (float)Math.random()*1000);
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, target, 1000, "traveling to an unknown destination");
                    fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, target, 30, "feeding at "+target.getName());
                    fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, system, 1000, "traveling to an unknown destination");
                    fleet.addTag("generated_rock");

                    fleet.getCargo().addCommodity("volatiles", (float) Math.random()*75 + 75);
                    fleet.getCargo().addCommodity("rare_ore", (float) Math.random()*50 + 100);
                    fleet.getCargo().addCommodity("ore", (float) Math.random()*100 + 100);
}

Doesn't work because Cannot determine simple type name "Random"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 14, 2017, 10:43:01 AM
Java just hates me.

I checked the random code several times over, checked java pages and variosu forms on how to get random number. The code is just like theirs. The class is imported.
Bu it just DOES. NOT. WORK.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 14, 2017, 05:56:53 PM
Janino issues? (http://fractalsoftworks.com/forum/index.php?topic=10973.0) (This was the first google result for 'java cannot determine simple type name Random')

If you're not using an IDE and compiling to a .jar, you really should be for such a large project.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 15, 2017, 12:46:52 AM
Nah, I didn't compile.


I only have 2 "major" scripts - the FleetSpawner and SectorGen. Sector gen works fine.
Got the mod to work by removing the FleetSpawner entirely, but that's not a solution (as now I don't have some fleets spawning)

I need help from someone who knows Java and StarSector coding a lot better than I do (which is zero)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 15, 2017, 11:44:52 AM
Where are starting ships (and system) for New Game defined?
I'm sure I ran into it in some file, but now I can't find it anywhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 15, 2017, 11:57:59 AM
Anyone of you good people know where I can find or how I can change abandoned stations that have only leave options into the one like in Jengala system where you can store stuff?
There is few of them and most do not allow to store stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 15, 2017, 04:19:12 PM
Where are starting ships (and system) for New Game defined?
I'm sure I ran into it in some file, but now I can't find it anywhere.

"rules.csv" under "data" > "campaign".

Scroll down through the file until you get to the bits that start "ngc...." (New Game Creation). Almost everything's handled there. For a more specific look, you can look at my mod "Better Beginning" here http://fractalsoftworks.com/forum/index.php?topic=12228.0 (http://fractalsoftworks.com/forum/index.php?topic=12228.0) (if you haven't already) and take a look at the custom rules file it uses.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 15, 2017, 10:02:49 PM
Sooo my attempts at making a description sort of... exploded.

It says that the hull id could not be found but I've double checked to see if it is the same as it is in the SHIP file and the ship data. Where did I goof up at?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 15, 2017, 11:28:31 PM
IIRC, it's case sensitive.

The name of the hull file, the hull ID in the file AND the id in the description all have to be exactly the same
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 16, 2017, 01:52:28 AM
Sooo my attempts at making a description sort of... exploded.

I says that the hull id could not be found but I've double checked to see if it is the same as it is in the HULL file and the ship data. What did I goof up at?

Are you sure it's the description that's the problem? And can you share a screenshot of the "descriptions.csv" file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 16, 2017, 01:24:42 PM
Sooo my attempts at making a description sort of... exploded.

I says that the hull id could not be found but I've double checked to see if it is the same as it is in the HULL file and the ship data. What did I goof up at?

Are you sure it's the description that's the problem? And can you share a screenshot of the "descriptions.csv" file?

Here

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 16, 2017, 05:02:19 PM
Strange. Everything looks in order.

It's possible you have an illegal character in the description line itself, but I can't be sure what those would be - I just know some characters don't show up the same way between the file and Starsector itself.

Try temporarily removing the descriptions file (just shift it to your desktop or somewhere safe) and start the game, to make sure that it's actually causing the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 16, 2017, 05:40:31 PM
Strange. Everything looks in order.

It's possible you have an illegal character in the description line itself, but I can't be sure what those would be - I just know some characters don't show up the same way between the file and Starsector itself.

Try temporarily removing the descriptions file (just shift it to your desktop or somewhere safe) and start the game, to make sure that it's actually causing the problem.

Did that a few times already, everytime I put the strings folder in the mod explodes. However it works fine without the csv. I could send you the mini-mod but I'll need to ask for permission first. (Sprite dump...right)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 16, 2017, 06:01:11 PM
Did that a few times already, everytime I put the strings folder in the mod explodes. However it works fine without the csv. I could send you the mini-mod but I'll need to ask for permission first. (Sprite dump...right)

That's super strange.  ??? Maybe you spelled the hull id wrong in the description file? Double check that (if you haven't already)?

And if you want to flick me a copy for troubleshooting, I'm sure that's fine. :P Just send me a private message with a download link.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 17, 2017, 06:44:52 AM
Question, I seems not found,
we can apply a special AI script for a weapon?(Like shipsystem?)
For exemple, stop the AI to use modded weak EMP weapon against shield?(Just know if we can, I do not search the code)


Edit: I will just go use the plugin every frame weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mitthrawnuruodo on May 17, 2017, 08:39:57 AM
How do I increase the chance of recruitable officers appearing in bases / stations?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 18, 2017, 06:44:11 AM
What does Global.getFactory().convertToRegularMarket(market) actually do? It doesn't even seem to actually call market.setPlanetConditionMarketOnly(false).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 18, 2017, 09:05:56 AM
It probably isn't something to worry about - all the markets in a "live" game are regular markets, and the game automatically converts the surveyable-planet markets to "condition-only" light implementations of markets when saving. So all you really need to do is setPlanetConditionMarketOnly(true) on a planet market to have it save as a full-fledged market etc.

(All the method does is create a PlanetConditionMarket (which also implements MarketAPI) and copy the conditions over to it. So, right, it's leaving the original market object unaffected.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 18, 2017, 11:20:18 AM
What method or operation allows us to show the name of a System on the Hyperspace / Intel map?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 18, 2017, 11:54:34 AM
IIRC it's down to having a not-filtered-out comm message with that star system ID.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 18, 2017, 01:30:43 PM
Soooo...
Code
Global.getSector().getCampaignUI().addMessage(system.getName());
Should do that, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 18, 2017, 07:48:35 PM
Nope, that doesn't work.  I think I need a little more detail here; it's really unclear how the mechanism in Messages works, too...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 18, 2017, 08:32:00 PM
I have no idea what I did wrong  ??? but every time I try to make a description for this mod it hates it. Fixed: Apparently the type of .csv file you save it as matters.



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 18, 2017, 11:12:58 PM
Nope, that doesn't work.  I think I need a little more detail here; it's really unclear how the mechanism in Messages works, too...

Take a look at com.fs.starfarer.api.util.FleetLog - I think that'll answer a lot of questions.

Of particular note for your use case:
message.setStarSystemId(target.getContainingLocation().getId());
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 18, 2017, 11:25:33 PM
Spoiler
For know,
He exists many interface or abstract to implement or extended for a campaign plugin.

If I put that on the settings.json:
"plugins":{
     "Looter_Name_Plugin": "src.lt.data.scripts.plugins.Looter_Name_Plugin",
    },


There are call every frame, so I guess. But only for plugin who implement a class who implement EveryFrameScript or also a extend of BaseEventPlugin ?(Like he implements a CampaignEventListener, so I guess than yes but not sure)

This is for know if I can "add" bounty or just modify bounty without touch too for just than bounty mission take also my faction, and not just pirates factions ships. I maybe go on the wrong implement/Extends, this is maybe BountyPirateFleetManager ?


Thank for your help!
[close]
Edit: Well, I will go use BountyPirateFleetManager,  on the plugin settings, i go probably found how.(With the exemple java code on starfarer who contains the means for add bounty fleet, this is probably gonna go easy)

Edit: Auto-solved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 19, 2017, 01:04:34 PM
Easy minor one:

Is the rarity value in weapons.csv a percentage reduction of the base drop chance, or a value that determines "effective rarity" as in  .7 > .5 > .3 on how "rare" the weapon is?

Cursory glance didn't bring this up, so sorry if it should be self-explanatory. I would have thought higher numbers equals higher rarity due to the .8 on AM Blaster but then Tachyon Lance remains at .5 while Ion Pulser is .6 and Plasma Cannon is .3 ... so idk. lol
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2017, 01:49:57 PM
@Snarsha: plugins are NOT auto-added in the campaign, but I guess you already figured that out :)

Is the rarity value in weapons.csv a percentage reduction of the base drop chance, or a value that determines "effective rarity" as in  .7 > .5 > .3 on how "rare" the weapon is?

It's a multiplier for the probability a given weapon will show up when an item in drop_data can have multiple weapons. For example:

wpn_:{weaponType:ENERGY}

Will pick from all energy weapons, modified by rarity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 19, 2017, 01:54:42 PM
@Snarsha: plugins are NOT auto-added in the campaign, but I guess you already figured that out :)

Is the rarity value in weapons.csv a percentage reduction of the base drop chance, or a value that determines "effective rarity" as in  .7 > .5 > .3 on how "rare" the weapon is?

It's a multiplier for the probability a given weapon will show up when an item in drop_data can have multiple weapons. For example:

wpn_:{weaponType:ENERGY}

Will pick from all energy weapons, modified by rarity.

Well, i have try many things:
Put a Bounty of Looters on event.json:
Quote
   "Looters_bounty":{
      "probabilityMult":1,
      "script":"src.lt.data.scripts.campaign.events.Looters_Bounty",
   },
Do not seems work.

Or put that on: BaseModPlugin     based of other mod.
Quote
    public void onGameLoad(boolean newGame) {
       
        if (!Global.getSector().hasScript(LootersEventProbabilityManager.class)) {
            LootersEventProbabilityManager eventStarter = new LootersEventProbabilityManager();
            Global.getSector().addScript(eventStarter);
        }
    }

    @Override
    public void configureXStream(XStream x) {
        x.alias("LootersEventProbabilityManager", LootersEventProbabilityManager.class);
        x.alias("Looters_Bounty", Looters_Bounty.class);
        x.alias("Looters_FleetFactory", Looters_FleetFactory.class);

Without real succes,  the second spawn many Looters fleets(I have put the max to 20 with x4 payement for be sure), but bounty are not available on the player logs, and when player kill them, he do not receive money. I found just their fleets with a yellow warning of quest when i go check a pirate bounty.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 02:06:40 PM
Quote
Take a look at com.fs.starfarer.api.util.FleetLog - I think that'll answer a lot of questions.
Will do, thank you!  The new Intel systems are pretty confusing atm, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 19, 2017, 02:54:31 PM
Help me out here.

Trying to troubleshoot the latest crash for my mod and I'm getting this:

Code
4267 [Thread-4] INFO  com.fs.starfarer.loading.ShipHullSpecLoader  - Loading ship hull [G:\GAMES\Starsector\starsector-core\..\mods\Steelclad\data\hulls\isa4-cr-lexington.ship]
4267 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [G:\GAMES\Starsector\starsector-core\..\mods\Steelclad\data\hulls\isa4-cr-lexington.ship]

4944 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.loading.ShipHullSpecLoader.super(Unknown Source)
at com.fs.starfarer.loading.ShipHullSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

It seems to be caused by a new ship I added, but I can't find anything wrong with the ship itself.




Code
{
  "bounds": [
    -227.5,
    -33.5,
    -218,
    -70.5,
    -206.5,
    -85.5,
    -113.5,
    -89.5,
    -106,
    -75,
    -78,
    -77.5,
    -68,
    -69,
    -33.5,
    -91.5,
    30.5,
    -85,
    28,
    -54.5,
    41.5,
    -47,
    59.5,
    -57.5,
    146.5,
    -57,
    209.5,
    -26.5,
    209.5,
    26.5,
    146.5,
    57,
    59.5,
    57.5,
    41.5,
    47,
    28,
    54.5,
    30.5,
    85,
    -33.5,
    91.5,
    -68,
    69,
    -78,
    77.5,
    -106,
    75,
    -113.5,
    89.5,
    -206.5,
    85.5,
    -218,
    70.5,
    -227.5,
    33.5
  ],
  "center": [
    105.5,
    225.5
  ],
  "collisionRadius": 231,
  "engineSlots": [
    {
      "angle": 180,
      "contrailSize": 19,
      "length": 47.5,
      "location": [
        -217,
        65
      ],
      "style": "MID_TECH",
      "width": 19
    },
    {
      "angle": -180,
      "contrailSize": 19,
      "length": 47.5,
      "location": [
        -217,
        -65
      ],
      "style": "MID_TECH",
      "width": 19
    },
    {
      "angle": 180,
      "contrailSize": 24,
      "length": 82.5,
      "location": [
        -226.5,
        14
      ],
      "style": "MID_TECH",
      "width": 24
    },
    {
      "angle": -180,
      "contrailSize": 24,
      "length": 82.5,
      "location": [
        -226.5,
        -14
      ],
      "style": "MID_TECH",
      "width": 24
    }
  ],
  "height": 451,
  "hullId": "isa4-cr-lexington",
  "hullName": "Lexington",
  "hullSize": "CRUISER",
  "shieldCenter": [
    0,
    0
  ],
  "shieldRadius": 260,
  "spriteName": "graphics/ships/ISA/isa4-cr-lexington2.png",
  "style": "MID_TECH",
  "viewOffset": 0,
  "weaponSlots": [
    {
      "angle": 45,
      "arc": 240,
      "id": "WS0001",
      "locations": [
        58,
        36
      ],
      "mount": "TURRET",
      "size": "MEDIUM",
      "type": "ENERGY"
    },
    {
      "angle": -45,
      "arc": 240,
      "id": "WS0002",
      "locations": [
        58,
        -36
      ],
      "mount": "TURRET",
      "size": "MEDIUM",
      "type": "ENERGY"
    },
    {
      "angle": 90,
      "arc": 180,
      "id": "WS0003",
      "locations": [
        6,
        31
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "ENERGY"
    },
    {
      "angle": -90,
      "arc": 180,
      "id": "WS0004",
      "locations": [
        6,
        -31
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "ENERGY"
    },
    {
      "angle": 0,
      "arc": 0,
      "id": "WS0005",
      "locations": [
        -24,
        21
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": -0,
      "arc": 0,
      "id": "WS0006",
      "locations": [
        -24,
        -21
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 0,
      "id": "WS0007",
      "locations": [
        119,
        36
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": -0,
      "arc": 0,
      "id": "WS0008",
      "locations": [
        119,
        -36
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 90,
      "arc": 180,
      "id": "WS0009",
      "locations": [
        -84,
        66
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "ENERGY"
    },
    {
      "angle": -90,
      "arc": 180,
      "id": "WS0010",
      "locations": [
        -84,
        -66
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "ENERGY"
    },
    {
      "angle": 180,
      "arc": 0,
      "id": "WS0011",
      "locations": [
        -210,
        41
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": -180,
      "arc": 0,
      "id": "WS0012",
      "locations": [
        -210,
        -41
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 0,
      "id": "WS0013",
      "locations": [
        17,
        -0
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 180,
      "arc": 270,
      "id": "WS0014",
      "locations": [
        -151.5,
        -0
      ],
      "mount": "TURRET",
      "size": "MEDIUM",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 1",
      "locations": [
        53.5,
        10,
        53.5,
        -7.5,
        87,
        10.5,
        86.5,
        -8.5
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 2",
      "locations": [
        5.5,
        62,
        -24,
        61.5
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 3",
      "locations": [
        6,
        -60.5,
        -24,
        -60.5
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 4",
      "locations": [
        -68.5,
        -10,
        -68,
        9
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    }
  ],
  "width": 211
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2017, 02:59:10 PM
It's MIDLINE, not MID_TECH, unless you have a MID_TECH style defined in your hull_styles.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 19, 2017, 03:39:07 PM
Is the rarity value in weapons.csv a percentage reduction of the base drop chance, or a value that determines "effective rarity" as in  .7 > .5 > .3 on how "rare" the weapon is?

It's a multiplier for the probability a given weapon will show up when an item in drop_data can have multiple weapons. For example:

wpn_:{weaponType:ENERGY}

Will pick from all energy weapons, modified by rarity.

Ah, so lower decimals are more rare? Darn it, I had it backwards. XD

Further question then, are weapons without a rarity value counted as rarity "1" by default?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 19, 2017, 03:42:51 PM
Stupid, stupid, so stupid!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2017, 04:33:20 PM
Further question then, are weapons without a rarity value counted as rarity "1" by default?

Yep.

Stupid, stupid, so stupid!

Happens to everyone now and again :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 19, 2017, 05:02:22 PM
Further question then, are weapons without a rarity value counted as rarity "1" by default?

Yep.

Awesome, thanks.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 06:14:51 PM
Alex, I tried this:

Code
						CommMessageAPI message = Global.getFactory().createMessage();
message.setSubject(pickedSystem.getName());
message.getSection1().setTitle("Summary");
message.setLocationString(explorerHQ.getContainingLocation().getNameWithLowercaseType());
message.setStarSystemId(explorerHQ.getContainingLocation().getId());
message.setCenterMapOnEntity(explorerHQ);
message.setType("Log Entry");
message.setShortType("Fleet log");
message.setTimeReceived(Global.getSector().getClock().getTimestamp());
message.setTimeSent(Global.getSector().getClock().getTimestamp());
message.setSmallIcon(Global.getSettings().getSpriteName("intel_categories", "star_systems"));
FleetLog.addToLog(message, null);

That still didn't result in the System's name being show on the Hyperspace map or Intel screen.  Pretty confused here; what else needs to be done?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2017, 06:22:39 PM
Not sure - are you getting the message to show up in your intel? I just tried (basically) the code you pasted and it works.

Code: java
CommMessageAPI message = Global.getFactory().createMessage();
message.setSubject("Erebus");
message.getSection1().setTitle("Summary");
message.setStarSystemId("erebus");
message.setType("Log Entry");
message.setShortType("Fleet log");
message.setTimeReceived(Global.getSector().getClock().getTimestamp());
message.setTimeSent(Global.getSector().getClock().getTimestamp());
message.setSmallIcon(Global.getSettings().getSpriteName("intel_categories", "star_systems"));
FleetLog.addToLog(message, null);

"Erebus" being a particular procgen system in that save.

http://imgur.com/a/Ia5oB

(There's a bunch of icons next to the star system because the code added a bunch of messages due to running every frame; was a quick-and-dirty test.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 06:24:01 PM
Quote
are you getting the message to show up in your intel?
Nope, it's not showing up anywhere.

This code's running during onNewGame().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2017, 06:28:36 PM
Might not be showing up because it's 2 months old, then. Filter stuff etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 06:33:24 PM
Aha!

OK, so I can write a simple iterator to find that sucker once the Economy's done, then!  I'll try that out :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 06:57:53 PM
Ah... nope?

Code
	@Override
public void afterGameSave(){
List<StarSystemAPI> systems = Global.getSector().getStarSystems();
for(StarSystemAPI system : systems){
if(system.isProcgen()){
List<SectorEntityToken> entities = system.getAllEntities();
for(SectorEntityToken entity : entities){
if(entity.getMarket() != null){
CommMessageAPI message = Global.getFactory().createMessage(); 
message.setSubject(system.getBaseName()); 
message.getSection1().setTitle("Summary"); 
message.setStarSystemId(system.getNameWithLowercaseType()); 
message.setType("Log Entry"); 
message.setShortType("Fleet log"); 
message.setTimeReceived(Global.getSector().getClock().getTimestamp()); 
message.setTimeSent(Global.getSector().getClock().getTimestamp()); 
message.setSmallIcon(Global.getSettings().getSpriteName("intel_categories", "star_systems"));
message.setLocInHyper(system.getHyperspaceAnchor().getLocationInHyperspace());
FleetLog.addToLog(message, null);
}
}
}
}
}

Sooo... am I asking the wrong question? 

I just want the Star's name to show up on the Hyperspace map, like Askonia, etc. are. 

But the procGen stars don't show up on the map, except when we're looking at the star in the Intel screen (which is weird; shouldn't they all be seen, but greyed out or something, to tell players they haven't been explored yet?).  This is involving a procGen star, so is that the issue?  Hmm, could try setting it to not-procGen and see...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2017, 07:00:04 PM
You're aware of the map filter, right? The row of buttons on the bottom? The non-intel map is set to only show inhabited systems by default. The intel maps only shows the names of systems such that there exists a message matching the *intel* filter settings tagged with that star system id.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 07:07:37 PM
But... this location is inhabited???

Code
market.setSize(6);
market.addCondition(Conditions.POPULATION_6);

What else triggers that?

Or is there something in the System?  Will look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2017, 07:14:09 PM
"inhabited" is defined as "part of the economy", i.e. getSector().getEconomy().addMarket(market) or some such.

(Which, incidentally, means that during-tutorial Galatia gets missed by the "inhabited" filter, which is a bug...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 07:16:37 PM
Hmmm.... that's weird, I thought it was already part of the economy.  Checking this out now...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2017, 07:24:29 PM
SUCCESS.  That was the missing part of this puzzle.

Well, yay, we now have a generic-ish way to generate named locations with Stations with economies and populations for Factions that non-coders can use, that use procGen Systems (i.e., no need to know all the hand-build stuff).

Not sure if it'll pass Janino yet, I'll probably need to build out the JAR to get data from a simple JSON to make it truly non-coder-friendly... but whatever, the core works now...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 20, 2017, 03:32:44 AM
1. How do I make a sound play when a MIRV splits? "fireSoundTwo" in .wpn file didn't work...

2. How do I play sound via script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 20, 2017, 03:34:38 AM
Ok, a few more questions from a local ***.


How does the number of fighter bays (and the number of actual launch bays for each) interact with the fighter number defined in the ship_data.csv?

Unless I'm mistaken, the ship_data number dictated how many wings a ship can carry. But what effect does actual number of Launch PORTS and BAYS play in the whole thing?

4 launch PORTS with 1 BAY or 1 PORT with 4 BAYs? What's the practical difference?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 20, 2017, 04:09:26 AM
How does the number of fighter bays (and the number of actual launch bays for each) interact with the fighter number defined in the ship_data.csv?

Unless I'm mistaken, the ship_data number dictated how many wings a ship can carry. But what effect does actual number of Launch PORTS and BAYS play in the whole thing?

4 launch PORTS with 1 BAY or 1 PORT with 4 BAYs? What's the practical difference?

The value under "fighter bays" under "ship_data.csv" is the number of wings the ship can carry.

The ports in the "____.ship" file mark the visible points on the ship sprite that appear to "spark" while fighters are being repaired, as well as where fighters will appear to launch from and land. Normally there'd be a handful (3-6?) of "ports" for each "bay", to add an element of randomness.

At least, that's how I use them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 20, 2017, 04:31:40 AM
So 4 bays with 2 ports and 2 bays with 4 ports function exactly the same?

Does the total number count for the repair speed or number of fighters that can be repaired at once or is it just for show?


Also, can ships that have launch bays, but don't have defined fighter wings repair friendly fighters?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2017, 10:22:59 AM
Re: launch bays defined on ships -

The game will go through the ship's fighter bays and assign a .ship launch bay to each. If the number of .ship launch bays is less than the number of fighter bays, it will cycle through launch bays, so multiple fighter bays may get the same launch bay.

When launching fighters, a fighter bay will cycle through what you're calling the "ports" of its assigned launch bay to pick the exact location where a fighter will take off or land.

Also, can ships that have launch bays, but don't have defined fighter wings repair friendly fighters?

No - fighters are 100% tied to the launching ship.



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 20, 2017, 10:33:31 AM
@Aron0621:

You can play a sound for that by running an EveryFrameCombatPlugin that watches for the new Missile type, and then plays the sound.  You'll need to build a list of Missiles that have already played a sound and not allow them to do it again, among other details.  You might want to read through Vacuum's code dealing with special shot behaviors at some point to get a basic idea of how to go about that, if you're not already conversant with Java's functions for dealing with this sort of issue.

As for playing the sound:

SoundAPI playSound(String id, float pitch, float volume, Vector2f loc, Vector2f vel);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 20, 2017, 11:52:14 AM
Re: launch bays defined on ships -

The game will go through the ship's fighter bays and assign a .ship launch bay to each. If the number of .ship launch bays is less than the number of fighter bays, it will cycle through launch bays, so multiple fighter bays may get the same launch bay.

When launching fighters, a fighter bay will cycle through what you're calling the "ports" of its assigned launch bay to pick the exact location where a fighter will take off or land.

In other words, the only effect number of bays/ports has - is the time it has to launch fighters, which is irrelevant anyway?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 20, 2017, 11:56:29 AM
are campaign level fleet AI more or less hardcoded? Is there a way to mod their behavior somehow?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2017, 12:02:30 PM
In other words, the only effect number of bays/ports has - is the time it has to launch fighters, which is irrelevant anyway?

It has no mechanical effect whatsoever.


are campaign level fleet AI more or less hardcoded? Is there a way to mod their behavior somehow?

Technically, it can mostly be overridden using these CampaignPlugin methods:
public PluginPick<AssignmentModulePlugin> pickAssignmentAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai);
public PluginPick<NavigationModulePlugin> pickNavigationAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai);
public PluginPick<StrategicModulePlugin> pickStrategicAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai);
public PluginPick<TacticalModulePlugin> pickTacticalAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai);

But that's pretty complicated. In practice, what you want to do is give it specific assignments to force certain behaviors (i.e. "go here", "hold here", "pursue this", etc.)

See: CampaignFleetAIAPI.addAssignment(), clearAssignments(), etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 20, 2017, 05:38:12 PM
Does the total number count for the repair speed or number of fighters that can be repaired at once or is it just for show?

Literally just for show.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jay2Jay on May 20, 2017, 06:18:51 PM
Got a few questions actually.

Is it possible to:

1.) Create a hullmod that can only be found on other ships?

2.) Create weapons that can only be installed on a ship with a specific hullmod?

3.) Add hullmods as being 'stock' to a ship that can be uninstalled like restoration, but through a different command/button?

4.) Add weapons to a ship that cannot be removed unless a certain hullmod is removed?

5.) Have certain ships be only recoverable with certain equipment/hullmods?

6.) Create a system to convert ships between variants? (Like one variant with more small weapon mounts and another with more large weapon mounts?)

7.) "Lock" an ability or hardpoints on a ship as long a certain hullmod is installed or not installed?

8.) Make it so that a certain module type "must" be installed on a ship to deploy it in battle, but so that several different modules can fill this role?

My idea is an AI faction similar to the Remenants and Domain drones, only I want them to be modular and have... unique effects to balance out the fact that they will, in a way, be overpower.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 20, 2017, 07:31:29 PM
Got a few questions actually.

Is it possible to:

Spoiler
1.) Create a hullmod that can only be found on other ships?

2.) Create weapons that can only be installed on a ship with a specific hullmod?

3.) Add hullmods as being 'stock' to a ship that can be uninstalled like restoration, but through a different command/button?

4.) Add weapons to a ship that cannot be removed unless a certain hullmod is removed?

5.) Have certain ships be only recoverable with certain equipment/hullmods?

6.) Create a system to convert ships between variants? (Like one variant with more small weapon mounts and another with more large weapon mounts?)

7.) "Lock" an ability or hardpoints on a ship as long a certain hullmod is installed or not installed?

8.) Make it so that a certain module type "must" be installed on a ship to deploy it in battle, but so that several different modules can fill this role?

My idea is an AI faction similar to the Remenants and Domain drones, only I want them to be modular and have... unique effects to balance out the fact that they will, in a way, be overpower.
[close]


Whoa. You have some weird ideas, but from my inexperienced modding standpoint, here's some answers.

1: Should be! Just make a hullmod that's "Hidden" (so it doesn't appear normally in the refit screen), but it will still show up as a hullmod on ships that use it in their variant file. It ought to have a chance of dropping as battle loot like any other hullmod.

2: I think with some scripting you can make certain weapons more/less expensive and such. See Tartiflette's Outer Rim Alliance mod, the ships of which include a hullmod that make beam weapons more expensive to fit (for balance purposes). In your situation you could make certain weapons cost an arbitrarily large quantity of Ordnance Points, making them unequippable.

3: Not without heavy scripting, and completely rewriting a bunch of the stock game's UI.

4: Not without heavy scripting, and even then I doubt it's possible.

5: Maybe. Don't know. Probably requires scripting anyway.

6: Yep! Requires scripting, but it's been done before in such mods as Interstellar Imperium and Tiandong Heavy Industries, which both have market tabs where you can drop off ship classes to be converted over time into something else.

7: Not without heavy scripting, and even then I doubt it's possible.

8: Not without heavy scripting, and even then I doubt it's possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 20, 2017, 09:31:48 PM
Attempting to reproduce MIRV behavior with some tweaks. The game crashes whenever it tries to go second stage - apparently I am using spawnProjectile() wrong way.

1. What is the correct way of using spawnProjectile()?

2. How can I get a weapon that fired a specific projectile(one of the parameters of spawnProjectile())?

3. Can I edit spawned projectiles? i.e. speed, damage, damage type, etc
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 20, 2017, 09:54:17 PM
What would I need to do so that the AI accepts the sacrifice of a massive ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on May 21, 2017, 02:10:59 PM
Good grief, *faceslap*. Spent an entire day attempting to merge two of my customized mod folders as one, the first is/was for the previous .7+ version of the game and then my recent new one with a fewer but new stuff in it. I couldn't figure out why sometimes it booted up and sometimes didn't and later, only to realize that about 10+ hours later that the only error I had left to overcome was with altered weapons from the last version of the game and so they didn't have the new slot for that rarity feature/tag in-between so I only had to add one extra comma for the older weapons.

Always this tiniest of details you manage you miss and then realize "Well, what the- that was this EASY the whole time to fix!?! Ugh. >_<". I'm both laughing and beating myself over the fact that I spent way too much time trying to find a simple-arse problem that was right under my nose. Good thing is I managed fix it and got my modified stuff together into one personal mod folder in a way that I don't have to switch between the two folders I had, and that 10+ hours at least in the end payed off its mild to medium irritation it had on me. Its just that I spent more time trying to fix a problem than modding and re-modding stuff in. :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 22, 2017, 03:59:12 AM
I want update some thing on wikipedia, but I have not idea for somethings:
Wing_data.csv:

Tag:
ex:"interceptor1, interceptor, low"

For be precise,
-what is the difference between interceptor1, 2 or 3? (And more?<)
-The second seems always the first without the number, so what is this?
-The third is strange, low, middle or high,  but I do not found on  combat what is this.
=Tag change something on combat, or just the role?
=Tag is used for the auto-fit?


AttackRunRange is always more low than range, they attack always when ennemi is in the range?

Rarity: Chance on the market, no problem, I think.
Tier: For know, they change something on the game? (Or maybe just when you auto-fit?)


Ship data . csv:

8/6/5/4%: Alex answer always to that, but for be sure, what is this?


Thank you!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 22, 2017, 04:11:15 PM
I want update some thing on wikipedia, but I have not idea for somethings:
Wing_data.csv:

Tag:
ex:"interceptor1, interceptor, low"

AttackRunRange is always more low than range, they attack always when ennemi is in the range?

Rarity: Chance on the market, no problem, I think.
Tier: For know, they change something on the game? (Or maybe just when you auto-fit?)

8/6/5/4%: Alex answer always to that, but for be sure, what is this?


@Snrasha,

The tags for fighter wings in wing_data.csv are used by the Autofit system. Usually, the first word is the fighter's primary role and how good it is, so "interceptor4" is a better interceptor than "interceptor3", which is better than "interceptor2" and so forth. The second word I believe is an alternative role. It may be the same as the first, or different. If different, it means the fighter can be used as something else if it really needs to be. The third word I believe is the tech level, so "low-tech", "midline", and "high-tech".

I think AttackRunRange is approximately how far out from a target fighters will open fire. This is important for bombers with torpedoes and such, to make sure the fighters get close enough to be most effective without getting destroyed by point defence.

Rarity is market chance, yes. As I was recently informed, it is a decimal multiplier of the normal spawn rate, so "0.1" means the item is 10 times rarer than a default rarity item. The smaller the number, the more rare the item is.

Tier is a more rough estimation of the item's tech level, although I believe the game treats this value differently to the "low/mid/high" bit in the "tags" column. From what I have gathered, Tier portrays where items can spawn in markets - you won't get really high-tech items spawning in the Jangala open market, for instance.

The last one I can never remember, but it has something to do with flux capacity. If you're in doubt, just set its value to the same as the ship's flux capacity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SainnQ on May 23, 2017, 03:56:34 AM
Would anyone know what is required to see changes made to a fighter wing reflect themselves in the Campaign?

I decided to root around and make some basic changes to fighter wing resupply cost & fighters per wing, the game runs fine, until I move to the main system associated with the manufacturer of said fighter wings.

I get a Fatal Error 10
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 23, 2017, 05:37:37 AM
Question - I want to make a booster module. As in, attach a solid fuel rocket to your ship for a temporary speed boost. The idea is that it would give you +X speed for Y seconds in battle.

Making a hullmod to give extra speed it easy. But how to turn it off after Y seconds?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 23, 2017, 05:47:40 AM
Question - I want to make a booster module. As in, attach a solid fuel rocket to your ship for a temporary speed boost. The idea is that it would give you +X speed for Y seconds in battle.

Making a hullmod to give extra speed it easy. But how to turn it off after Y seconds?
Quote
private IntervalUtil time_off = new IntervalUtil(1,1);
public void advanceInCombat(ShipAPI ship, float amount){
  // Code for active the flag "active" and put more speed to ship
     if(active){
          time_off.advance(amount);
          if(time_off.intervalElapsed()){
            //Code for put per default the speed of the ship.
           // And put the flag active to false;
    }
 }
}
Maybe that? I am maybe on wrong.  Amount  per frame is between 0.017 and 0.023 so put more than that on the intervalutil.
For enable per a button the flag "active", I do not know, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 24, 2017, 08:24:59 PM
Which part in the script/data file is responsible for spawnimg high-tech [REDACTED]s?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 24, 2017, 08:27:27 PM
Which part in the script/data file is responsible for spawnimg high-tech [REDACTED]s?

com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantThemeGenerator.java
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 24, 2017, 09:14:15 PM
Thanks for the prompt reply!

Aaaaand... which part is responsible for their behavior? Like, engage even when severely outnumbered, no jump to Hyperspace, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 24, 2017, 09:38:50 PM
com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantSeededFleetManager
initRemnantFleetProperties()
addRemnantInteractionConfig()
addRemnantAICoreDrops()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 24, 2017, 11:10:04 PM
Question - is that AI hard-coded for a faction "remnant" or can it be used on others?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 25, 2017, 10:12:09 PM
How does one make a ship NPC only?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 26, 2017, 01:19:49 AM
How does one make a ship NPC only?

Like the Remnant droneships? They have an "UNBOARDABLE" tag in the ship_data.csv.

Only works for factions that don't have markets though. If you had a faction with an unboardable ship, but an accessible market there's a chance the ship could spawn in the market and be purchaseable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 26, 2017, 09:02:24 AM
Is there a case where BattleAPI.getPlayerSideSnapshot() should/would be null? I'm getting an NPE with my custom FleetInteractionDialogPluginImpl  (https://bitbucket.org/Histidine/exerelin/src/2ce0cc479fefa4c4b1d4e856959560239bc9332b/jars/sources/ExerelinCore/exerelin/campaign/NexFleetInteractionDialogPluginImpl.java?at=master&fileviewer=file-view-default)after an engagement round in a battle.

Code
320436 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.backFromEngagement(FleetInteractionDialogPluginImpl.java:431)
at exerelin.campaign.NexFleetInteractionDialogPluginImpl.backFromEngagement(NexFleetInteractionDialogPluginImpl.java:62)
at com.fs.starfarer.campaign.CampaignState.prepare(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Question - is that AI hard-coded for a faction "remnant" or can it be used on others?
The AI flags can be set for any fleet in a mod's code.
(You could even call initRemnantFleetProperties directly, but since it also causes AI core drops you probably don't want to do this)

Spoiler
Code: java
public static void initRemnantFleetProperties(Random random, CampaignFleetAPI fleet, boolean dormant) {
fleet.removeAbility(Abilities.EMERGENCY_BURN);
fleet.removeAbility(Abilities.SENSOR_BURST);
fleet.removeAbility(Abilities.GO_DARK);

// to make sure they attack the player on sight when player's transponder is off
fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_SAW_PLAYER_WITH_TRANSPONDER_ON, true);
fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_FLEET, true);

fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_MAKE_AGGRESSIVE, true);
fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_NO_JUMP, true);

if (dormant) {
fleet.setTransponderOn(false);
// fleet.getMemoryWithoutUpdate().unset(MemFlags.MEMORY_KEY_PATROL_FLEET);
// fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PIRATE, true); // so they don't turn transponder on
// fleet.addAssignment(FleetAssignment.HOLD, null, 1000000f, "dormant");
fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_MAKE_ALLOW_DISENGAGE, true);
fleet.setAI(null);
fleet.setNullAIActionText("dormant");
}

addRemnantInteractionConfig(fleet);
addRemnantAICoreDrops(random, fleet, 1f);
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2017, 06:37:37 PM
Is there a case where BattleAPI.getPlayerSideSnapshot() should/would be null? I'm getting an NPE with my custom FleetInteractionDialogPluginImpl  (https://bitbucket.org/Histidine/exerelin/src/2ce0cc479fefa4c4b1d4e856959560239bc9332b/jars/sources/ExerelinCore/exerelin/campaign/NexFleetInteractionDialogPluginImpl.java?at=master&fileviewer=file-view-default)after an engagement round in a battle.

Took a quick look - looks like only if there is no player side in the battle, i.e. if neither side has the player fleet in it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 27, 2017, 02:54:25 AM
In combat, can I spawn:

1. Empty CombatEntity, with location and initial velocity vector defined
2. A ship
3. a drone, not defined by ship system(though technically same as 2)

via script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 28, 2017, 01:23:47 PM
what's the difference between the weapon hints? Specifically:

PD vs PD_ALSO VS ANTI_FTR, PD

STRIKE VS STRIKE, USE_VS_FRIGATES (now that ships use strike weapons on frigates anyway, right?)

also how is FIRE_WHEN_INEFFICIENT calculated?


also: How does the lion's guard subfaction work internally? I can't seem to figure it out by looking at the source files. If I'm say trying to make a sub faction for pirates, how would I go about doing that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 28, 2017, 03:27:48 PM
what's the difference between the weapon hints? Specifically:

PD vs PD_ALSO VS ANTI_FTR, PD


PD: Will target missiles.
PD_ALSO (when combined with PD): Will target missiles, but will prioritize fighters and warships.
ANTI_FTR: Will prioritize fighters.

These can be combined in a couple of ways, although "PD_ALSO" must be combined with "PD".


STRIKE VS STRIKE, USE_VS_FRIGATES (now that ships use strike weapons on frigates anyway, right?)

Umm. I don't know what you mean by "now that ships use strike weapons on frigates anyway". By default, a ship with a STRIKE weapon won't use it against frigates. I think there are some special circumstances where it will (if there are no other enemies on the field, if it's a last-ditch attempt to kill them, etc.) but most of the time they won't.

USE_VS_FRIGATES allows them to do that, or at least allows them to do it more readily.


Can't remember FIRE_WHEN_INEFFICIENT, but I think it has something to do with both the firing ship's flux and the target ship's flux.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 28, 2017, 07:41:39 PM
also: How does the lion's guard subfaction work internally? I can't seem to figure it out by looking at the source files. If I'm say trying to make a sub faction for pirates, how would I go about doing that?
LionsGuardFleetManager is added to Sindria (the market) and spawns patrol fleets for the Lion's Guard faction (so that it uses their ships, officers, etc.), then transfers the fleet to the Diktat faction.
You can make a pirate subfaction in the same way if so desired, but depending on what you're doing a more complex implementation may be called for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on May 29, 2017, 05:34:02 PM
How do I affect the AI's threat analysis? I made a "torpedo drone" that goes torpedo mode which disables the weapons on it, and the target ship promptly drops the shield to take torpedo damage in the face.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: isaacssv552 on May 30, 2017, 01:21:55 AM
How can I access a ships hullmods through ShipSkillEffect? I want to nullify a specific hullmod via a skill effect,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ragni on May 30, 2017, 07:04:47 PM
Can confirm this. No rule commands are found no matter where I put them (even if I do the "ruleCommandPackages" in settings.json). I'll see if I can send you copy for testing.

*edit - sent via pm

Alright, fixed it - turns out it was using the wrong classloader.

Thanks- that's awesome! Any chance I could get a copy of the fixed build for modding purposes? (can't do too much on my end until I can make it to the main menu)

I think that I am encountering the same problem.
Being very new to modding SS (and modding at all), this was very confusing.

I described my approach here and what problem i encounter: http://fractalsoftworks.com/forum/index.php?topic=12526.msg212459#msg212459
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on May 31, 2017, 07:50:04 AM
Is it possible to make a modular ship and keep it mobile (yes, it's for the Omega). Looked at the rest of the modular structures and so far I've seen that they're all immobile. Would there be a way to implement thrusters to modular structures? Also, would there be a way to keep said ship in a faction without appearing in the faction's market?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: isaacssv552 on May 31, 2017, 11:54:40 AM
Is it possible to make a modular ship and keep it mobile (yes, it's for the Omega). Looked at the rest of the modular structures and so far I've seen that they're all immobile. Would there be a way to implement thrusters to modular structures? Also, would there be a way to keep said ship in a faction without appearing in the faction's market?
Yes, but you'll want to wait for 8.1. It adds a lot of functionality to modules.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clockwork Owl on June 02, 2017, 05:52:45 AM
How do I adjust reputations by custom rules?

Using 0.81 dev version, can't find out how to use AdjustRep with custom best/worst/limits/amount.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nomadic_leader on June 07, 2017, 09:06:31 PM
Is here a way to just turn off damage decal and glow rendering? For performance reasons; and i don't care about individual pockmarks on every ship in a large battle. TMI.

Earlier in the thread (hundreds of pages back/years ago) (http://fractalsoftworks.com/forum/index.php?topic=5061.msg157407#msg157407) someone suggested pointing the damagedecal lines in hull_styles to a blank image. I haven't tried that yet but was wondering about just turning it off entirely.

I tried deleted all the damagedecal lines in hullstyles that are there, but there apparently it falls back to some default; since ships still keep getting the damagedecals/glow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 11, 2017, 01:11:19 AM
What am I looking at here?


Code
3580 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (G:\GAMES\Starsector081\starsector-core\..\mods\Steelclad\data\weapons\vns-lrg-shockwave.wpn)]
3843 [Thread-7] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Compiling script [data.scripts.world.SectorGen]
3964 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.remove(Unknown Source)
at com.fs.starfarer.loading.specs.S.addTurretAngleOffset(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

weapon in question:
Code
{
"id":"vns-lrg-shockwave",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":900,
"turretSprite":"graphics/weapons/animated/vns_shockwave/vns_shockwave_cannon00.png",
"turretGunSprite":"",
"turretGlowSprite":"",
"hardpointSprite":"graphics/weapons/animated/vns_shockwave/vns_shockwave_cannon00.png",
"hardpointGunSprite":"",
"hardpointGlowSprite":"",
"numFrames":9,
"frameRate":20,
"interruptibleBurst":false,
"visualRecoil":0,
"glowColor":[255,75,0,200],
"renderHints":[RENDER_BARREL_BELOW],
"turretOffsets":[31, 0],
"turretAngleOffsets":[0, 0],
"hardpointOffsets":[31, 0],
"hardpointAngleOffsets":[0, 0],
"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"GLOW_AND_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE

"muzzleFlashSpec":{"length":80.0,   # only used if animationType = MUZZLE_FLASH
   "spread":6.0,
   "particleSizeMin":15.0,
   "particleSizeRange":15.0,
   "particleDuration":0.25,
   "particleCount":35,
   "particleColor":[255,75,0,200]},

"projectileSpecId":"vns_bullet_shockwave",  # projectile that will be fired
"fireSoundTwo":"gun_heavy_3",
"autocharge":true,
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on June 11, 2017, 02:54:10 AM
@TrashMan

I don't know if this would cause that error, but you've got a bunch of situational values that aren't necessary.

You're making a rotary (or at least frame-animated) weapon, no? In which case, you don't actually need either the "...GunSprite" or "...GlowSprite" values. And by that I don't mean you can leave them blank: I mean you should get rid of them entirely. The same with "visualRecoil" and "RENDER_BARREL_BELOW" in renderHints.

All those values apply to different forms of weapon animation, and I have a hunch that if you try to define all of them (even with a null or zero value) for a single weapon, the game doesn't understand what form of animation you're trying to use. I could be completely wrong about that.  :-X



However, what I think almost certainly will cause a crash is your turret/hardpoint offsets and angle offsets. Bear in mind that for each gun, the regular "offset" is a pair of coordinates (x, y) but the "angle offset" is only a single value. In other words, in those arrays there should be two integers for each gun location in "offsets" and only one in "angleOffsets".

Chances are the "index out of bounds" error here is because you're defining a single gun location in the translational offset, but then defining two in the angle offset, hence the error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 11, 2017, 09:09:34 AM
Yup, hat did it. Now I get errors for another weapon

Code
9551 [Thread-4] INFO  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Applying data from weapon_data.csv to [vns-med-flak]
9885 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IllegalArgumentException: No enum constant com.fs.starfarer.api.combat.WeaponAPI.AIHints.pd6
java.lang.IllegalArgumentException: No enum constant com.fs.starfarer.api.combat.WeaponAPI.AIHints.pd6
at java.lang.Enum.valueOf(Unknown Source)
at com.fs.starfarer.loading.K.super(Unknown Source)
at com.fs.starfarer.loading.WeaponSpreadsheetLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)



Code
{
"id":"vns-med-flak",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"BALLISTIC",
"size":"MEDIUM",
"displayArcRadius":600,

"turretSprite":"graphics/weapons/vns_flak_turret_base.png",
"turretGunSprite":"graphics/weapons/vns_flak_turret_recoil.png",
"hardpointSprite":"graphics/weapons/vns_flak_hardpoint_base.png",
"hardpointGunSprite":"graphics/weapons/vns_flak_hardpoint_recoil.png",

"visualRecoil":5.0,  # the gun sprites are only used if this is non-0
"renderHints":[RENDER_BARREL_BELOW],

"turretOffsets":[21, -2, 21, 2],
"turretAngleOffsets":[0],
"hardpointOffsets":[21,-2, 21, 2],
"hardpointAngleOffsets":[0],

"separateRecoilForLinkedBarrels": true,

"barrelMode":"LINKED", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE
"muzzleFlashSpec":{"length":40.0,   # only used if animationType = MUZZLE_FLASH
   "spread":30.0,
   "particleSizeMin":16.0,
   "particleSizeRange":18.0,
   "particleDuration":0.3,
   "particleCount":46,
   "particleColor":[255,155,75,225]},
"projectileSpecId":"shot_52mm_flak",  # projectile that will be fired
"fireSoundTwo":"gun_light_flak",
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2017, 09:19:48 AM
"pd6" should go in the "tags" column, not "hints".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2017, 09:24:39 AM
Is here a way to just turn off damage decal and glow rendering? For performance reasons; and i don't care about individual pockmarks on every ship in a large battle.

There's no way to turn it off entirely, but for performance, if you go to settings.json and change:

"forceNoVBO":true,

To false, that *may* speed it up, by making the game render damage decals using a more advanced/faster graphics card feature. It's forced off by default because it's not entirely stable - I get random crashes maybe once every 4 hours or so when it's set to false - but it could just be some combination of factors specific to my computer. Still, be warned that that *could* happen for you as well, if you give it a shot. There were also some issues on OS X - waaay back - where this was ungodly slow, as in seconds-per-frame - but I'd hope that particular driver issue has been sorted by now, as it's been years.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 11, 2017, 12:46:38 PM
"pd6" should go in the "tags" column, not "hints".

Bu it is....

Redeemer Cannon,vns_med_redeemer_1b,2,,2500,700,,200,20,10,12,10,30,0.2,10,HIGH_EXPLOSIVE,10,,,1,1,,2,4,1,3,,700,,,20,,he4,19982
Redeemer Cannon 2B,vns_med_redeemer_2b,3,,4000,700,,200,20,10,12,14,40,0.2,10,HIGH_EXPLOSIVE,10,,,1,1,,2,4,1,3,,750,,,20,,he5,20006
50mm Gauss Cannon,vns_med_bal2b,2,,2000,800,,50,,0,12,8,120,1,40,KINETIC,10,,,0.4,1,0,0,6,1,6,,700,,,30,,kinetic3,19981
60mm Gauss Cannon,vns_med_bal1b,1,,1800,900,,90,,0,12,8,90,1,30,KINETIC,10,,,0.4,1,0,0,6,1,6,,700,,,30,,kinetic4,19980
X-Ray Laser Battery,vns_med_xray,2,,2500,850,,100,,0,20,14,,,,ENERGY,50,,,4,5,0.5,2,5,6,2,,900,,,,"USE_VS_FRIGATES, STRIKE",energy5,19979
Flak Battery,vns-med-flak,2,2200,600,,50,,0,45,12,60,0.5,20,FRAGMENTATION,,,,2,5,0.25,6,18,3,6,,600,,,42,"ANTI_FTR, PD",pd6,200009
Heavy Flak Battery,vns-lrg-flak,3,4600,600,,100,,0,45,16,60,0.25,20,FRAGMENTATION,,,,1,1,0.25,6,18,3,6,,600,,,42,"ANTI_FTR, PD",pd9,200010
Ion-Nova Cannon,vns-lrg-shockwave,3,4000,900,,50,500,0,9,16,,,,ENERGY,1000,,20,2,1,0,1,5,0,0,,1200,,,,STRIKE,"LR, energy9",200011


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MinusUdn on June 11, 2017, 01:26:12 PM
with the new sprite rendering order (closest to the spine above) how do I change the order weapons are rendered? can it be done?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2017, 04:44:56 PM
@TrashMan: maybe a missing comma somewhere there or something? Don't know. That error is definitely from the game trying to interpret "pd6" as a hint, though.

with the new sprite rendering order (closest to the spine above) how do I change the order weapons are rendered? can it be done?

Hardpoints are rendered before turrets.

Within that, smaller weapons are rendered below larger ones.

Within that, missile weapons get rendered before non-missile.

After that - if all the preceding criteria are the same - distance-to-center (first on horizontal axis, then on vertical) is used as a tie-breaker.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Seth on June 13, 2017, 01:52:27 PM
Quick question:
Some mods are listed 0.8, and some 0,8.1 is it okay to use 0.8 ver. mod on 0.8.1 game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on June 13, 2017, 04:02:54 PM
Quick question:
Some mods are listed 0.8, and some 0,8.1 is it okay to use 0.8 ver. mod on 0.8.1 game?

Tricky. Some are, some aren't. It depends what sort of stuff the mods change, add or use.

If in doubt though, I'd stick to only using mods for your particular version though. That's the safest option.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Seth on June 13, 2017, 07:36:09 PM
I see, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on June 14, 2017, 02:48:06 AM
How can I get a armor cell's location by cellX and cellY?
I just know callX and cellY can be get by Vector2f(Well API told me that).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jc on June 15, 2017, 11:54:49 AM
Is it possible to triple the amount of ships and weapons that show up on ALL markets across the board? Is there a global variable that just straight up triples the amount inside every single market?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mangalore on June 15, 2017, 02:17:35 PM
Hi! I'm currently trying to bring a homebrew faction over to 0.81 and have trouble with a very vague NullPointerException concerning Bounty Fleet spawing, I think.Thing is how to best debug the issue. I would think the main error cause may be in the ships specification or fleet description but since I don't have any JSON parsing error it must be more subtle than that, possibly the change of fighters. As it happens in different spawn iterations of the world creation I would guess it has to do when a specific ship is pulled.

How can I best activate/deactivate ships from the spawn pool to narrow down the problem?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on June 15, 2017, 02:45:57 PM
I've got a crash that has me scratching my head - what would cause a Ship hull spec [prv_ljus_d_default_D] not found! error? It seems to be related to post-battle ship recovery, as I got the crash just after a fight where I lost a Ljus (D).

Full log message:
Spoiler
2249109 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull spec [prv_ljus_d_default_D] not found!
java.lang.RuntimeException: Ship hull spec [prv_ljus_d_default_D] not found!
   at com.fs.starfarer.loading.F.super(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.settings.StarfarerSettings$1.getHullSpec(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.DModManager.setDHull(DModManager.java:37)
   at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.getRecoverableShips(FleetEncounterContext.java:1372)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.winningPath(FleetInteractionDialogPluginImpl.java:1698)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.goToEncount erEndPath(FleetInteractionDialogPluginImpl.java:1526)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.optionSelec ted(FleetInteractionDialogPluginImpl.java:1282)
   at com.fs.starfarer.ui.newui.newsuper$1.o00000(Unknown Source)
   at com.fs.starfarer.ui.newui.A.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.j.super(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 17, 2017, 02:09:16 AM
How do I make the procgen component of a handmade star system use names based on the star instead of the custom names (e.g. "Shaanxi IV" instead of "Tartiflette")? The withSpecialNames arg in this method seems to do nothing:
public static float addOrbitingEntities(StarSystemAPI system, SectorEntityToken parentStar, StarAge age,
                                 int min, int max, float startingRadius,
                                 int nameOffset, boolean withSpecialNames)


How can I best activate/deactivate ships from the spawn pool to narrow down the problem?
Commenting them out from the .faction file is probably the most straightforward.

I've got a crash that has me scratching my head - what would cause a Ship hull spec [prv_ljus_d_default_D] not found! error? It seems to be related to post-battle ship recovery, as I got the crash just after a fight where I lost a Ljus (D).

Full log message:
Spoiler
2249109 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull spec [prv_ljus_d_default_D] not found!
java.lang.RuntimeException: Ship hull spec [prv_ljus_d_default_D] not found!
   at com.fs.starfarer.loading.F.super(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
   at com.fs.starfarer.settings.StarfarerSettings$1.getHullSpec(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.DModManager.setDHull(DModManager.java:37)
   at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.getRecoverableShips(FleetEncounterContext.java:1372)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.winningPath(FleetInteractionDialogPluginImpl.java:1698)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.goToEncount erEndPath(FleetInteractionDialogPluginImpl.java:1526)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.optionSelec ted(FleetInteractionDialogPluginImpl.java:1282)
   at com.fs.starfarer.ui.newui.newsuper$1.o00000(Unknown Source)
   at com.fs.starfarer.ui.newui.A.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.j.super(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
It's trying to get the autogenerated D skin for your ship (which it shouldn't, since it's already a D skin).
I'm not sure how to fix it; perhaps try "restoreToBaseHull":true in your premade D .skin file? If that fails, post the hullmods the skin has defined.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kerghnox on June 17, 2017, 10:23:16 PM
I just want to make a simple mod that changes some hyperstorm values, how do you go about doing this?

Here's my embarrassing attempt that didn't change anything at all:

Code
package data.scripts.campaign.terrain;

import java.awt.Color;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;

import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignEngineLayers;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.TerrainAIFlags;
import com.fs.starfarer.api.combat.ViewportAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.graphics.SpriteAPI;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.loading.Description.Type;
import com.fs.starfarer.api.ui.Alignment;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.FlickerUtilV2;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceTerrainPlugin;

public class NearHarmlessHS extends HyperspaceTerrainPlugin {

public static float MIN_BURN_PENALTY = 0.1f;
public static float BURN_PENALTY_RANGE = 0.1f;
public static final float VISIBLITY_MULT = 0.5f;


public static final float STORM_STRIKE_SOUND_RANGE = 1500f;

public static final float STORM_CR_LOSS_MULT = 0.1f;
public static final float FUEL_USE_FRACTION = 0.1f;
//public static final float SPEED_MULT = 1f;
public static final float STORM_SPEED_MULT = 1f;
//public static final float SENSOR_RANGE_MULT = 0.5f;
public static final float STORM_SENSOR_RANGE_MULT = 1f;
public static final float STORM_VISIBILITY_FLAT = 2000f;


public static final float TILE_SIZE = 200;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sc90 on June 18, 2017, 06:07:46 AM
Any way to stop AI from retreating at all?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c0nr4d1c4l on June 18, 2017, 08:52:45 PM
Is there a way to make a hullmod that...occasionally produces food and lobsters in reasonable quantities?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nomadic_leader on June 19, 2017, 07:25:37 AM
Is there a way to make a hullmod that...occasionally produces food and lobsters in reasonable quantities?

The user Snrasha had a mod with a hullmod/ship that produces food. Here he is asking about it.

http://fractalsoftworks.com/forum/index.php?topic=5061.msg173501#msg173501

There may be some other mods; if you search confined to the modding forums you may find them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on June 19, 2017, 09:27:26 AM
Is there a way to make a hullmod that...occasionally produces food and lobsters in reasonable quantities?

The user Snrasha had a mod with a hullmod/ship that produces food. Here he is asking about it.

http://fractalsoftworks.com/forum/index.php?topic=5061.msg173501#msg173501

There may be some other mods; if you search confined to the modding forums you may find them.

Not only, look page 2 or 3 of this section, you go found a hullmod for that.


Edit:
http://fractalsoftworks.com/forum/index.php?topic=12280.0

Here, use this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 21, 2017, 09:41:42 AM
Ok, WTF already!


The game keeps complaining about this: (I'm making a TC by the way)
Code
29935 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull variant [warden_Defense] not found!
java.lang.RuntimeException: Ship hull variant [warden_Defense] not found!
at com.fs.starfarer.loading.O00O.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.thissuper$Oo.<init>(Unknown Source)
at com.fs.starfarer.loading.thissuper.<init>(Unknown Source)
at com.fs.starfarer.loading.SpecStore.new.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

But I HAVE a warden_Defense variant fully defined. I copied the graphics and the hull and the variant (but changed the weapons) from the core game
Code
{
    "displayName": "Defense",
    "fluxCapacitors": 0,
    "fluxVents": 10,
    "hullId": "warden",
    "hullMods": [],
    "quality": 0,
    "variantId": "warden_Defense",
    "weaponGroups": [
        {
            "autofire": false,
            "mode": "LINKED",
            "weapons": {"WS 001": "med-en-alien-beam"}
        },
        {
            "autofire": true,
            "mode": "LINKED",
            "weapons": {
                "WS 002": "sm-en-alien-laser"
            }
        }
    ]
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on June 21, 2017, 12:17:13 PM
Just to be sure, the file name matches the variant name with no typos, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 25, 2017, 02:11:36 AM
What?

What are you talking about? Scrips are .java, ship and weapon data is .csv. What kind of a question is that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on June 25, 2017, 07:16:55 AM
I want to ask if it is possible to code in a Hullmod script that provides bonuses (such as damage) to Faction-specific weapons.

Secondly, are there methods to give weapon scripts additional damage to certain ship sizes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 25, 2017, 08:38:24 AM
How do I make the procgen component of a handmade star system use names based on the star instead of the custom names (e.g. "Shaanxi IV" instead of "Tartiflette")? The withSpecialNames arg in this method seems to do nothing:
public static float addOrbitingEntities(StarSystemAPI system, SectorEntityToken parentStar, StarAge age,
                                 int min, int max, float startingRadius,
                                 int nameOffset, boolean withSpecialNames)


Ah, that's actually a bug, then, that the parameter doesn't do anything.

Could you try using NameAssigner.assignStructuralNames()? I think that should work.


@TrashMan: from the stack trace, I'm pretty sure this is due to the warden_Defense variant being referenced from a .faction file. I don't know if you've done it already, but you'll want to "replace" (in mod_info.json) factions.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 25, 2017, 11:15:38 AM
Quote
I want to ask if it is possible to code in a Hullmod script that provides bonuses (such as damage) to Faction-specific weapons.
That can be done, but it'd be a bit involved; essentially, you'd need an EveryFrameCombatPlugin that, for each shot / Beam / Missile that did damage, checked to see if the WeaponAPI's ShipAPI had a given HullMod installed, and then do some additional damage through additional scripting. 

Note that damage can be gotten to this way, but not range or other major variables; to influence range, you'd have to do some very counter-intuitive things. 

Quote
Secondly, are there methods to give weapon scripts additional damage to certain ship sizes?
Individual weapons, no; again, you're stuck with using the approach outlined above.  If you just want all the weapons of a certain class (say, Kinetic) on a ship to do additional damage based on size class, sure thing, but if you want to tweak individual weapon damages, no.

I really think we should just have access to WeaponAPI base stats to avoid these issues; the global-buff system is less than perfect, because these situations come up a lot and it doesn't cover most edge cases.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on June 28, 2017, 07:27:47 PM
Does anyone have any idea what this error could be referring too? I'm at my whits end because my mod does NOTHING to touch the combat engine.

Code
18969 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.scripts.ScriptStore.?0000(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.o00000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The mod is incredibly simple, containing 2 entries in rules.csv and a single script in a jar.

It must be the script because the mod works without it present, but it a) doesn't really do anything because I've commented out the active parts and b) is never called.

Script:
Spoiler
Code: java
package data.campaign.rulecmd;

import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.impl.campaign.rulecmd.BaseCommandPlugin;
import com.fs.starfarer.api.util.Misc;
import java.util.List;
import java.util.Map;

/**
 *
 * @author Thomas Goldstein
 */
public class TestChangeAlliegence extends BaseCommandPlugin {
    @Override
    public boolean execute(String ruleId,
            InteractionDialogAPI dialog,
            List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
    if (dialog == null) return false;
    SectorEntityToken target = (SectorEntityToken) dialog.getInteractionTarget();

    //MarketAPI market = target.getMarket();
    //if (market==null) return false;
    //market.setFactionId("hegemony");
    return true;
    }

}
[close]

I'm compiling the Jar using the most recent version of Netbeans, with the source format set to JDK7.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on June 29, 2017, 04:02:06 AM
Show your changes to rules.csv.

Though I'd hazard a guess you've misspelt the class name; TestChangeAlliegence
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cjuicy on June 30, 2017, 06:36:16 PM
Is it possible to limit fighter bays to a faction's specific LPC's?
And also, can you make built-in weapons lootable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on July 01, 2017, 05:21:03 PM
Show your changes to rules.csv.

Though I'd hazard a guess you've misspelt the class name; TestChangeAlliegence

Thanks for the reply - the wrong spelling was the same in both places, so it wasn't that. :P

I've fixed the problem by recreating my Netbeans project of the mod with all the exact same files, no changes.  I suspect that what happened is that I deleted some superfluous files from the project using Windows' File Explorer rather than Netbeans' interface. When I looked into the jar it was building, those deleted files were still included. I'm not sure how that could cause the weird error message, but the issue is resolved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on July 01, 2017, 05:26:25 PM
In game terms, what are a MarketAPI market's .getconnectedEntities? Their class is SectorEntityToken, which doesn't tell me much.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 01, 2017, 07:30:30 PM
In game terms, what are a MarketAPI market's .getconnectedEntities?
It should be all entities that contain the market, e.g. Jangala and its station are both connected to the shared Jangala market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jay2Jay on July 02, 2017, 01:54:15 PM
Was wondering what stats are tied to ship sizes (destroyer, frigate, cruiser, capital) and if it would be non trivial to add more 'sizes'.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on July 04, 2017, 09:52:42 AM
Right now right clicking on hullmods makes them disappear and we learn them - can we get access to right click behavior for other inventory items? Does anyone know how to run an arbitrary script when right clicking on an item?

I was thinking maybe just using custom hullmods - the hullmods do nothing, but an every frame script then checks to see if the player knows them, runs another script, and removes the hullmod from the player knowledge. The script wouldn't happen directly when the item is right clicked though, which is a pity.

I'm guess I'm asking, has anyone figured this out?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 04, 2017, 10:09:52 AM
(Let me add a todo item for making a general-purpose way of doing this...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on July 04, 2017, 10:16:24 AM
(Let me add a todo item for making a general-purpose way of doing this...)

Thanks Alex :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 12, 2017, 12:39:58 PM
So... is there any current way to iterate through all of the JSONs in a given directory, both Vanilla and mods? 

Basically, I want to iterate through all of the .PROJ files, .WPN files and .SHIP files, in part because of some .WPN and .SHIP filenames not matching their internal string IDs, but mainly to do some work before the game loads, rather than gather data during operation.

I'm kind of stumped.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on July 15, 2017, 06:13:38 AM
So I tried to make a slow-fire, high-energy cost, long-range EMP AoE tactical weapon.

But no mater what it doesn't work. I ended up buffing it's stats more and more in hope of seeing some improvement.

The inital idea was slow fire (30sec to 1min cooldown), around 2000+ energy per shot, 500m explosion radios that does 1000 EMP damage.
Yet it's crap, even after upping the EMP damage to 5000 and cooldown to 10 sec.

Hits on hull or shield to nothing, only proximiy detonations seem to have some effect, but aside from knocking out fighters/missiles if they are close, it does nothing.

WEAPON DATA:
Ion-Nova Cannon,vns-lrg-shockwave,3,,4000,1200,,300,5000,0,9,16,,,,ENERGY,1000,,3,10,1,0,1,5,0,0,,1200,,,,STRIKE,"LR, energy9",200011

WEAPON ITSELF:
Code

{
"id":"vns-lrg-shockwave",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":1200,
"turretSprite":"graphics/weapons/animated/vns_shockwave/vns_shockwave_cannon00.png",
"hardpointSprite":"graphics/weapons/animated/vns_shockwave/vns_shockwave_cannon00.png",
"numFrames":9,
"frameRate":20,
"interruptibleBurst":false,

"glowColor":[255,75,0,200],
"turretOffsets":[31, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[31, 0],
"hardpointAngleOffsets":[0],
"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"GLOW_AND_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE

"muzzleFlashSpec":{"length":80.0,   # only used if animationType = MUZZLE_FLASH
   "spread":6.0,
   "particleSizeMin":15.0,
   "particleSizeRange":15.0,
   "particleDuration":0.25,
   "particleCount":35,
   "particleColor":[255,75,0,200]},

"projectileSpecId":"vns_bullet_shockwave",  # projectile that will be fired
"fireSoundTwo":"gun_heavy_3",
"autocharge":true,
}


PROJECILE:
Code
{
"id":"vns_bullet_shockwave",
"specClass":"projectile",
"spawnType":"BALLISTIC",
"collisionClass":"PROJECTILE_FF",
"collisionClassByFighter":"PROJECTILE_FIGHTER",

"length":80.0,
"width":15,
"fadeTime":0.20,

"hitGlowRadius":100,

"fringeColor":[10,10,220,255],
"coreColor":[255,255,0,255],

"glowColor":[10,10,255,255],
"glowRadius":45,

"behaviorSpec":
{
"behavior":"PROXIMITY_FUSE",
  "range":50,
"explosionSpec":
{
"duration":0.1f, # not visual
"radius":500,
"coreRadius":500, # full damage within core radius
"collisionClass":PROJECTILE_FF,
"collisionClassByFighter":PROJECTILE_FIGHTER,
"particleSizeMin":1.0,
"particleSizeRange":5.0,
"particleDuration":1,
"particleCount":300,
"particleColor":[0,0,255,255],
"sound":"408en"},
}
}

"textureScrollSpeed":64.0,
"pixelsPerTexel":5.0,

"bulletSprite":"graphics/missiles/shell_hellbore.png"
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2017, 09:20:45 AM
So... is there any current way to iterate through all of the JSONs in a given directory, both Vanilla and mods? 

Basically, I want to iterate through all of the .PROJ files, .WPN files and .SHIP files, in part because of some .WPN and .SHIP filenames not matching their internal string IDs, but mainly to do some work before the game loads, rather than gather data during operation.

I'm kind of stumped.

Off-hand, I don't *think* so, aside from looking through the filesystem directly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 15, 2017, 09:27:47 AM
Quote
I don't *think* so, aside from looking through the filesystem directly.
Right.  But aren't we unable to use File.IO?  I mean, if we can, I can probably query that-a-way, although I'd have additional problems with seeking the SS install directory on multiple OS's.  I'll look at that later today.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2017, 09:37:50 AM
Ah, right, forgot about that.

There's also a bunch of "loadCSV" etc methods in SettingsAPI, depending on what you're doing they may be of use.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vagrant on July 16, 2017, 01:40:26 PM
I'm not sure how to go about this but would a kind of movement only autopilot be possible? sort of the inverse of weapon autofire, where the ship moves like it would with the autopilot setting, but leaves weapon and shield control to the player, and isn't turned off by interaction.

There are times, especially when piloting a larger ship on my craptop, where I'm content with how the ai handles spacing and engagement distance, but I prefer to handle the shot timing of things (especially torpedoes and longer range ballistics) myself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 16, 2017, 02:07:00 PM
Absolutely, yes.  I might even make something like that for the next version of my AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on July 16, 2017, 04:35:10 PM
That AI thing seems interesting/useful, though personally I'm just usually overly OCD about focusing all my efforts only on my main ship manually from flying, gliding, aiming and shooting to pausing to switch weapon group and hit the opposition with ballistic, missile and energy weaponry along with ship-system usage and a lot of controlled gliding.

I suck at commanding a fleet, have gotten a lot of frigates and a few other ships in my fleet usually disabled or destroyed and sometimes because out of mere sudden sight of another ship and so my trigger-happy reflexes (which are many times faster than my main logical thinking processes, I am a slow and careful thinker but once primal instinct kicks in all bets are off) have gotten either ally ships or one of my own blasted apart or both by my own faulty tunnel vision where everything in front of me is a hostile entity needing to be exterminated.

In my current on-going playthrough I accidentally turned Independents hostile both towards me and to Metelson because I was still part of Metelson then with 100/100 reputation with them. I thought I was taking out yet another Luddic Church fleet out until mission debrief screen where I saw list of ships and what faction were they from, what an amusing face palm moment with a WTF face.

Moments like that make this game even more priceless, one bad choice and a sledgehammer curve-ball in the face. :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DinoZavarski on July 17, 2017, 05:20:48 AM
Is it possible to add slots in a .skin file? I tried to do it using weaponSlotChanges, however the game crashes without reasonable error message when slot name, not present in the .ship is used in .skin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 17, 2017, 06:40:34 AM
TrashMan: I can't say why the weapon would be failing to EMP nearby weapons/engines on a hull hit. But for good effectiveness in general against larger ships, it's probably easiest to give it an EMP arc effect like vanilla's Ion Cannon has, so it can disable far-away parts of the target.

DinoZavarski: AFAIK you can't add new slots and such (anything that has a specific position on the ship), only remove them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 17, 2017, 09:57:15 AM
I tried to implement a replacement for HyperspaceTerrainPlugin last night, but it doesn't work.  The new Plugin is referred to in terrains.json.  I saw in the API that the class is explicitly called in at least three places, rather than through the alias in Misc.java.  Any idea how I can get around that?  I had a fun idea about this but I e never messed with Terrain before :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 17, 2017, 10:00:32 AM
"doesn't work" is perhaps not very informative :)

That said, I think if your plugin extends HyperspaceTerrainPlugin, that should take care of any problems - what I'm seeing is in StarSystemGenerator, it expects the hyper terrain plugin to be of that class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 17, 2017, 10:07:24 AM
Ah... I'll try it that way, might work.  I was implementing TiledTerrainPlugin.  Thanks!

And by "not working", I meant, "I saw no crashes, but no effect".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Trylobot on July 17, 2017, 03:36:59 PM
Was wondering what stats are tied to ship sizes (destroyer, frigate, cruiser, capital) and if it would be non trivial to add more 'sizes'.
Ship size tags are used to determine OP costs and effects of many hullmods; they are also probably used for AI, and for the campaign logic to determine relative fleet strength and strategies and so on. I don't think it possible to add more sizes.

Is it possible to add slots in a .skin file? I tried to do it using weaponSlotChanges, however the game crashes without reasonable error message when slot name, not present in the .ship is used in .skin.
Negative, skins can only change/remove slots. But, you can add a slot that is completely hidden and built-in in the base hull, and then change it into a "regular"/used slot in the skin; it's something I've considered doing myself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 19, 2017, 11:53:06 AM
Soooo, I have a puzzler.

Is there a way to have a Weapon that:

1.  Is not visible in the Weapon Group UI...
2. ...but can take damage as normal?

It looks like the answer to this is no; I'm wondering if there's any way to use WeaponGroupAPI to remove them from that UI, maybe? 

Or at least relegate them to Group 5 automatically?

Sorry to bug you folks with something this obscure, but, well, I got my fake Engines to behave correctly, except for this QoL issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on July 19, 2017, 11:56:06 AM
TrashMan: I can't say why the weapon would be failing to EMP nearby weapons/engines on a hull hit. But for good effectiveness in general against larger ships, it's probably easiest to give it an EMP arc effect like vanilla's Ion Cannon has, so it can disable far-away parts of the target.

I suspect EMP effect and explosion radius don't work together..which is strange. That's the only explanation I have, 500 radius for an explosion is a lot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2017, 12:04:04 PM
It looks like the answer to this is no; I'm wondering if there's any way to use WeaponGroupAPI to remove them from that UI, maybe?

Offhand, that seems like it'd work. That's what's used to remove critically-malfunctioning weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 19, 2017, 12:06:17 PM
Hmm.  But I'd have to apply during the ship-creation process, I'd think, so that it's not invasive to that UI. 

That means a special Hull Mod or thereabouts.  I'll look at that; maybe there's a weird workaround.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 19, 2017, 01:27:19 PM
Hmm.  I can do this in combat, but, apparently, not in the Refit Weapon Group UI, where we're talking about a ShipVariantAPI, and there doesn't appear to be a method to:

A.  Get to the VariantAPI from the applyEffectsBeforeShipCreation()
B.  Go from there to removing the WeaponAPI from the Group(s).

I'm stumped, I think.  Everything else is working great, but the Weapon Group UI looks like this:

(http://www.wolfegames.com/TA_Section/ss_weapongroup_problem001.png)

If I could push these Weapons to the bottom of the list or make them invisible, I'd be happy with this project.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2017, 02:04:10 PM
What if you set the weapon type to "SYSTEM", but keep the slot not hidden? That should keep the weapon damageable, and may (not 100% sure about this part) also remove it from the weapon dialog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 19, 2017, 02:08:41 PM
I'll look at that; I didn't try setting the Weapon's type.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 19, 2017, 02:17:20 PM
No dice, unfortunately.  Thanks for the suggestion, though :)

It'd be nice if that type hid it; this is just a weird use case, though, where I want something to be acting largely as a point object, sans auto-fire AI (I wrote a custom AI into the AI mod to specifically handle these "weapons" that basically does nothing) but take damage so that it can pretend to be an EngineAPI.  Sorry for the hassle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2017, 02:24:50 PM
Alright, try this:

1) Set the slot type in the ship file to DECORATIVE
2) Add "showDamageWhenDecorative":true to the .wpn file

As near as I can tell, that should make the weapon damageable but prevent it from showing up in groups.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on July 20, 2017, 03:03:57 AM
I have a QQ. I'm not all that experienced with Java as I've attempted to avoid it as much as possible but am a developer.
I'm currently attempting to hook into post battle loot generation to add a couple of new commodities after battle using an override of reportEncounterLootGenerated in a class which is extending BaseCampaignEventListener. All my other functions in that class are working fine but this one just seems to do nothing, not even outputting logging.
Is this the right place to do it?
If not, what would be a good method?
My mod is designed to run alongside Nexerelin so could this be causing the problem by generating loot a different way?

While I'm here an additional question before I get to the point of testing to discover.
I've added a hullmod which I intend to have dynamic effects based on a campaign level variable, is applyBeforeShipCreation the right place to have these adjustments where they'll be changed dynamically or should I also unapply and reapply the effects to all ships with that hullmod when the campaign variable changes?
My assumption is that these adjustments are applied before a battle and will use the current variable at that point to create the ship.

Thanks in advance for any advice. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 20, 2017, 06:00:14 AM
I have a QQ. I'm not all that experienced with Java as I've attempted to avoid it as much as possible but am a developer.
I'm currently attempting to hook into post battle loot generation to add a couple of new commodities after battle using an override of reportEncounterLootGenerated in a class which is extending BaseCampaignEventListener. All my other functions in that class are working fine but this one just seems to do nothing, not even outputting logging.
Is this the right place to do it?
reportEncounterLootGenerated is the right function.
Is your listener otherwise running (try adding another callin like reportPlayerOpenedMarket and see if any log messages appear)?
If not, I'd guess something is wrong with how the listener is being added to the sector; try posting the constructor and the code where it's called. (Also this seems unlikely to me, but try having the class implement EveryFrameScript if it doesn't already)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on July 20, 2017, 06:47:18 AM
Wow, such a facepalm stupid mistake moment, thanks a lot for the pointer, I realised my mistake when copying it to paste here.
Turns out I was actually attempting to add the class to the sector after a return so it was never actually being added.  ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on July 20, 2017, 01:54:03 PM
After getting this working I'm now getting a strange issue. Everything works as planned when starting a new game, however loading a game fails with the following:
-snip-

class[6] being mine. It seems to be related to the super variable permaRegister creating the listener, since if I flip that to false it works fine (though obviously my overrides then don't)
The process I'm employing is fairly simple to explain since I stripped it down to track down the issue:
in my basePlugin:
-snip-
then my stripped ArkManager class:
-snip-

Am I just being incredibly stupid?

edit: snipped code fragments for neatness, turns out yes I was being stupid and was attempting to do logging without setting it up correctly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 20, 2017, 03:25:11 PM
Alright, try this:

1) Set the slot type in the ship file to DECORATIVE
2) Add "showDamageWhenDecorative":true to the .wpn file

As near as I can tell, that should make the weapon damageable but prevent it from showing up in groups.
Yay, this worked... with a proviso!

To query the state of the WeaponAPI and determine whether it's been knocked out, you need to use WeaponAPI.getCurrHealth(), rather than the boolean isDisabled() / isPermanentlyDisabled().  I figured I should document that little bit, as it was slightly obscure how that operates.

Thanks very much for helping me puzzle through this; it's such a minor thing but it'll really make this new feature of the Thruster FX system polished-feeling :)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 20, 2017, 03:30:45 PM
Nice! Ahh, interesting, so they do indeed take damage but don't get disabled due to being decorative (and also don't play disabled sounds/show disabled floating text/show repair glows/etc).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 20, 2017, 03:35:22 PM
Right, and they ~do~ get repaired over time, which actually made this work right, thank goodness!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on July 22, 2017, 07:03:34 AM
Well, adding the vanillas IonCannon effect doesn't really seem to do anything.

WHY CAN'T I MAKE AN AOE EMP SHOCKWAVE CANNON?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 22, 2017, 10:09:44 AM
You totally can.  However, you'll need to write your own AOE system.  See Vacuum's SpecialShotBehaviors.java for an example.

That said, I really wish there was a generic call we could make in ShipAPI or in EveryFrameCombatPlugin where we could see damage events, no matter their source.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 23, 2017, 10:46:59 PM
Anybody know how to detect Starsector's memory(I wanna know how my class use memory)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on July 24, 2017, 02:58:03 AM
Anybody know how to detect Starsector's memory(I wanna know how my class use memory)?

Run Starsector's VM with a memory profiler attached; the JDK comes with one, as do most IDEs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on July 26, 2017, 05:18:13 AM
I've been plugging away at my mod and it's all coming along nice but have a couple of questions..
I have decent technical, but limited Java knowledge, which I'm using creating this mod to help me develop.

I'm trying to find somewhere to inject myself into the Surveying process in order to potentially add an additional possible find to interesting planets/conditions so I've created myself a SurveyPlugin Implementation which extends SurveyPluginImpl in order to create a modified getSurveyDataType, figuring it's less than an ideal place but I can call my own function before it returns and use the InteractionDialogAPI to deal with adding a notification. I see that this is called from the static addSurveyDataFor function (which would be better but isn't an option) in Misc using Global.getSettings().getNewPluginInstance("surveyPlugin");
Because of this new instancing my override for getSurveyDataType doesn't seem to be called rather the original is used.
Is there someplace I can set a new instance to use my own Implementation instead or perhaps a better place to do what I'm attempting?
I feel like there probably is a simple way using a CoreCampaignPlugin but I'm missing it.

My second Question seems so simple I must be an idiot not being able to find it myself, but I've created a couple of new commodities, these are not really designed to be sold on the market but used with my own nonsense, however I can't seem to find a way to create a new demand class for them, how would I do this? It looks a bit silly using an existing demand class as they're then price adjusted based on demand.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 26, 2017, 06:13:37 AM
On the first question, I'd think you'd want to extend SurveyPluginImpl, rather than implement SurveyPlugin; you're basically just wanting to tweak a little bit here and there, right?

On the second question, I would think you'd look at extending com.fs.starfarer.api.impl.campaign.ids.Commodities.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on July 26, 2017, 07:22:21 AM
Ahh, I am extending SurveyPluginImpl rather than SurveyPlugin, but my class isn't being used, I'm assuming because of the way the static function in Misc is calling for a new SurveyPlugin instance. Though I could be wrong here.

I've added the commodity in that way, but I still get a fatal error due to the commodity not existing, my assumption with this one is that it's because that file simply holds the strings for the commodity but no actual commodity data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 26, 2017, 07:36:21 AM
Bear in mind that a lot of things like this require a new game to be started when testing :)

When you say your "class isn't getting used", are you verifying that by printing out to the Log?

And don't forget that Commodities need to be present in the CSV, etc.

Not sure that your approach (using "shadow commodities" to manipulate Stuff) is a great idea; I suspect it'd be easier to write an EveryFrameScript to do Market analysis / changes, if that's what you're after.  Not sure what your business case is here, though; a bit more explanation might be helpful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on July 26, 2017, 08:26:47 AM
Yup, my class is very simple, extends SurveyPluginImpl, overrides getSurveyDataType and simply has a log output added. The logging never occurs:

Code
public class ArkSurvey extends SurveyPluginImpl {

public static Logger log = Global.getLogger(ArkSurvey.class);

public String getSurveyDataType(PlanetAPI planet) {

log.info("***ARK*** MY SURVEY GUFF");

-snip for size, same as source-
}

}

regarding the commodities, I didn't explain well I think, they're research material items of various types that are potential drops from combat, I have that all working fine including the trade in categorising them as supplies demand class. I'd like to create my own demand class of "research_materials" which I could then loop through when checking cargo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 26, 2017, 09:06:53 AM
Re: the plugin - you need to tell the game to use it, by pointing to it from settings.json in your mod:
"plugins":{
   "surveyPlugin":"com.fs.starfarer.api.impl.campaign.SurveyPluginImpl",
}

(Replace the class name/package w/ yours.)


Re: commodities, demand class: pick one of your commodities to be the "primary" commodity and use its id as the demand class for all of them. You don't need to define it anywhere else, a demand class is literally just the id of the primary commodity in that class. The price of the other commodities is equal to the base commodity's price, modified by their relative utility. E.G. if the base commodity has utility 1 and another commodity in the class has utility 2, the other commodity will cost double.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on July 26, 2017, 11:07:28 AM
Wow how foolish of me, I fully forgot about adding plugins to the settings.
Thanks Alex, much appreciated.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 26, 2017, 11:32:55 AM
It's totally cool, we've all been there :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 27, 2017, 09:47:17 AM
I'm trying to manipulate the Hyperspace clouds (I'm trying to write a method to get rid of them near JumpHoles).  I tried all sorts of things in HyperSpaceTerrainPlugin, but I didn't find a method that would eliminate them.  Do I need to do that during SectorGen / ProcGen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2017, 10:03:23 AM
Not knowing what you tried, it's hard to say why it didn't work. Take a look at NebulaEditor, though - that can be passed in a HyperspaceTerrainPlugin, and is what the game uses to clear hyper clouds in procedurally generated areas.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 27, 2017, 10:25:57 AM
Aha, I'll take a look at that.  I was going down a dead end trying to check distances against SectorEntityTokens with the activeCells, etc.  ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 27, 2017, 11:40:06 AM
OK, that was really straightforward!  I wrote a new function in 3 minutes, lol.  Thank you, Alex!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2017, 11:51:29 AM
Nice!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 31, 2017, 11:37:24 AM
What does the settings.json value that says it, "disables the economy" actually do (technically)?

I'm considering a couple more QoL mods- one to significantly decrease RAM usage / speed up save / load (using tricks from Vacuum) and an economy revamp (although that might be premature).

Oh, and!

What is called when the Player fleet detects another fleet's composition?  I.E., when we go from abstract contacts to a fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2017, 11:51:23 AM
What does the settings.json value that says it, "disables the economy" actually do (technically)?

I'm considering a couple more QoL mods- one to significantly decrease RAM usage / speed up save / load (using tricks from Vacuum) and an economy revamp (although that might be premature).

It stops the economy from running, i.e. it won't modify stockpiles, demand, etc.

I wouldn't spend time on an economy revamp if I were you, since that's what I'm doing right now, very extensively, so whatever you do would likely get horribly broken.

What is called when the Player fleet detects another fleet's composition?  I.E., when we go from abstract contacts to a fleet?

I'm not sure I understand the question, but here are some relevant values from settings.json:

"detectionRangeTransponderMult":1, # multiplier to detection range (NOT sensor profile) when BOTH fleets have transponders on
"detectionRangeDetailsMult":0.5, # fraction of max detection range at which fleet composition is visible w/ transponder off
"detectionRangeDetailsAlwaysMult":0.1, # fraction of max detection range at which fleet faction is visible w/ transponder off
"detectionRangeDetailsAlwaysMin":50, # min value for that range
"detectionRangeDetailsAlwaysNonFleet":0.3, # fraction of max detection range at which hidden entities are "discovered"

There's also this in the API:

public static enum VisibilityLevel {
   NONE,
   SENSOR_CONTACT,
   COMPOSITION_DETAILS,
   COMPOSITION_AND_FACTION_DETAILS,
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 31, 2017, 11:53:23 AM
Yeah I figured on the "horribly broken", lol.  I'll just wait on that :)

Ah, yeah, visibility level is what I want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Regoso on July 31, 2017, 12:16:19 PM
Can anyone tell me what files i need to change to get a faction in the game the tutorial is insanely out of date on the subject.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 31, 2017, 01:24:44 PM
Yes, it's actually fairly simple, you just need to write a .faction file, and include the faction in an otherwise-blank factions.csv file, like this:

Code
faction
data/world/factions/my_nifty_faction.faction

Faction files are pretty complicated-looking, but most of it's pretty easy to follow:

Spoiler

{
   The internal id of the Faction.  Used all over the place; it's pretty handy to use this id in the names of ids of weapons, ships, variants, etc., etc., too, to avoid name collisions in the game.
   id:"my_nifty_faction",

   Colors and circle type used on the Faction's display in the Campaign View
   "color":[135,206,255,255],
   "secondaryUIColor":[135,255,0,255],
   "secondarySegments":6,


   Names used throughout the game dialogs.
   "displayName":"My Nifty Faction",
   "displayNameWithArticle":"the Nifty Faction",
   "displayNameLong":"My Nifty Faction",
   "displayNameLongWithArticle":"The Nifty Faction",


   Relative paths to graphical logos for the Faction.
   "logo":"graphics/factions/explorer_society.png",
   "crest":"graphics/factions/crest_explorer_society.png",

   Naming conventions for randomly-generated ships.
   "shipNamePrefix":"EXP",
   "shipNameSources":{
      "SPACE":2,
   },

   This actually doesn't matter; the real description string is in strings.csv.
   "description":"The My Nifty Faction is a remnant of Domain explorer crews who were trapped a long way from the Gates after the Collapse.",

   Personal names for Captains, randomly generated from these lists.
   "names":{
      "modern":1,
      "world":1,
      "future":1,
      "myth":1,
   },

   What Hull Mods the Faction may have for sale.
   "hullMods":[
      "shields_shieldremoved",
      "shields_formshield",
      "advancedoptics",
      "turretgyros",
      "augmentedengines",
      "auxiliarythrusters",
      "fluxcoil",
      "fluxdistributor",
      "hardened_subsystems",
      "insulatedengine",
      "pointdefenseai",
      "targetingunit",
      "fluxbreakers",
      "expanded_deck_crew",
      "recovery_shuttles",
      "operations_center",
      "nav_relay",
      "ecm",
   ],

   Any goods that are illegal to sell in the open market of this Faction.  Must use the good's id, not it's name.  I think this is optional.
   "illegalCommodities":[
   ],

   Optional!  Music to be played during encounter / battles with the Faction.
   "music":{
      "theme":"music_nifty_faction_encounter_neutral",
      "market_neutral":"music_nifty_faction_market_neutral",
      "market_hostile":"music_nifty_faction_market_hostile",
      "market_friendly":"music_nifty_faction_market_friendly",
      "encounter_neutral":"music_nifty_faction_encounter_neutral",
      "encounter_hostile":"music_nifty_faction_encounter_hostile",
      "encounter_friendly":"music_nifty_faction_encounter_friendly",
   },

   I'm not entirely sure what this does yet.
   "internalComms":"tritachyon_internal",

   Faction portraits, picked at random, just like names.
   "portraits":{
      "standard_male":[
         "graphics/portraits/portrait_corporate01.png",
         "graphics/portraits/portrait_corporate03.png",
         "graphics/portraits/portrait_corporate05.png",
         "graphics/portraits/portrait_corporate06.png",
         "graphics/portraits/portrait13.png",
         "graphics/portraits/portrait25.png",
         "graphics/portraits/portrait30.png",
         "graphics/portraits/portrait35.png",
      ],
      "standard_female":[
         "graphics/portraits/portrait_corporate02.png",
         "graphics/portraits/portrait_corporate04.png",
         "graphics/portraits/portrait_mercenary02.png",
         "graphics/portraits/portrait16.png",
         "graphics/portraits/portrait_corporate04.png",
         "graphics/portraits/portrait_corporate07.png",
         "graphics/portraits/portrait34.png",
      ],
   },

   Optional!  Special titles for members of the Faction with specific roles.
   "ranks":{
      "ranks":{
         "spaceCommander":{"name":"Explorer Count"},
      },
      "posts":{
         "patrolCommander":{"name":"Explorer Baron"},
         "fleetCommander":{"name":"Explorer Knight"},
         "baseCommander":{"name":"Explorer"},
      },
   },

   Optional!  Some very specific rules about the Faction's ability to interact with the player and other Factions.
   "custom":{
      "offersCommissions":true,
      "engagesInHostilities":true,
      "buysAICores":true,
      "AICoreValueMult":3,
      "AICoreRepMult":3,
      "buysSurveyData":true,
   },   

   This is very important; essentially, it's a list of the different fleets that can be generated by the game, built up by referencing the Variants listed here for various Roles.
   "shipRoles":{
      "fastAttack":{
         "nifty_faction_cutlass_default":10,
         "fallback":{"combatSmall":1},
      },
   
      "escortSmall":{
         "nifty_faction_cutlass_default":10,
         "fallback":{"combatSmall":1},
      },
      "escortMedium":{
         "nifty_faction_cutlass_default":10,
         "nifty_faction_explorer_default":10,
         "nifty_faction_crab_default":10,
         "nifty_faction_aegean_default":7,
         "fallback":{"combatMedium":1},
      },
      "combatSmall":{
         "nifty_faction_cutlass_default":10,
         "fallback":{"escortSmall":1},
      },
      "combatMedium":{
         "nifty_faction_cutlass_default":10,
         "nifty_faction_explorer_default":10,
         "nifty_faction_crab_default":10,   
         "nifty_faction_aegean_default":7,         
         "fallback":{"combatSmall":2},
      },
      "combatLarge":{
         "nifty_faction_vespucci_default":10,   
         "nifty_faction_kraken_default":5,            
         "fallback":{"combatMedium":2},
      },
      "combatCapital":{   
         "nifty_faction_vespucci_default":5,   
         "nifty_faction_kraken_default":10,         
         "fallback":{"combatLarge":2},
      },
      
      # hybrid ships with good combat and cargo capacity
      "combatFreighterSmall":{
         "nifty_faction_hudson_default":10,
         "fallback":{"freighterSmall":1},
      },
      "combatFreighterMedium":{
         "nifty_faction_hudson_default":10,
         "nifty_faction_explorer_default":10,      
         "fallback":{"combatFreighterSmall":2},
      },
      "combatFreighterLarge":{
         "nifty_faction_hudson_default":10,
         "nifty_faction_explorer_default":10,   
         "fallback":{"combatFreighterMedium":2},
      },
      
      "civilianRandom":{
         "nifty_faction_hudson_default":10,
         "fallback":{"freighterSmall":1},
      },
   
   
      # carriers
      "carrierSmall":{
         "nifty_faction_hudson_default":10,
         "nifty_faction_vespucci_default":5,               
         "fallback":{"carrierMedium":0.5},
      },
      "carrierMedium":{
         "nifty_faction_vespucci_default":10,               
         "fallback":{"carrierSmall":2},
      },
      "carrierLarge":{
         "nifty_faction_vespucci_default":10,   
         "fallback":{"carrierMedium":2},
      },
   
      # freighters and such
      "freighterSmall":{
         "nifty_faction_hudson_default":10,
         "fallback":{"freighterMedium":0.5},
      },
      "freighterMedium":{
         "nifty_faction_hudson_default":10,
         "fallback":{"freighterSmall":2},
      },
      "freighterLarge":{
         "nifty_faction_hudson_default":10,
         "fallback":{"freighterMedium":2},
      },
      
      "tankerSmall":{
         "nifty_faction_hudson_default":10,
         "fallback":{"tankerMedium":0.5},
      },
      "tankerMedium":{
         "nifty_faction_hudson_default":10,
         "fallback":{"tankerSmall":2},
      },
      "tankerLarge":{
         "nifty_faction_hudson_default":10,
         "fallback":{"tankerMedium":2},
      },
      
      "personnelSmall":{
         "nifty_faction_hudson_default":10,
         "fallback":{"personnelMedium":0.5},
      },
      "personnelMedium":{
         "nifty_faction_hudson_default":10,
         "fallback":{"personnelSmall":2},
      },
      "personnelLarge":{
         "nifty_faction_hudson_default":10,      
         "fallback":{"personnelMedium":2},
      },
      
      # utility ships
      "tug":{
         "nifty_faction_hudson_default":10,
         "fallback":{"utility":1},
      },
      "crig":{
         "nifty_faction_hudson_default":10,
         "fallback":{"utility":1},
      },
      "utility":{
         "nifty_faction_hudson_default":10,
      },
   },

   Optional!  This can tilt Captain "personality" types towards various kinds.  Defaults to Steady.
   "traits":{
      "captain":{
         "timid":1,
         "cautious":14,
         "steady":7,
         "aggressive":3,
         "reckless":1,
      },
   },

   I'm not sure if this is optional or not, but essentially it goes with shipRoles, above, to determine the composition of randomly-generated fleets.
   "doctrine":{
      # ship distribution
      "small":8,
      "fast":10,
      "medium":10,
      "large":5,
      "capital":1,
      
      # as fraction of combat ships of same size
      "escortSmallFraction":1,
      "escortMediumFraction":1,
      
      # freighters are balanced
      "combatFreighterProbability":0.5,
         
      # tend toward smaller
      "minPointsForCombatCapital":25,
      "minPointsForLargeCarrier":20,
      
      # increased preference for carriers
      "smallCarrierProbability":0.4,
      "mediumCarrierProbability":0.4,
      "largeCarrierProbability":0.4,
         
      # officers ; My Nifty Faction is somewhat elite
      "officersPerPoint":0.45,
      "officerLevelPerPoint":0.4,
      "officerLevelBase":7,
      "officerLevelVariance":0.35,
      
      "commanderSkillsPerLevel":0.2,
      "commanderSkillChance":0.5,
      "commanderSkillLevelPerLevel":0.3,
      "commanderSkills":{
         "officer_management":2,
         "coordinated_maneuvers":7,
         "fighter_doctrine":10,
         "electronic_warfare":10,
      },
   },
},
[close]

Once you have these two things done, you're done with the core part of building a Faction.  The rest of it's building actual content (ships and variants and weapons, populating strings, etc.).  To see the Faction spawn in the game, I'd really recommend using EZ Faction (http://fractalsoftworks.com/forum/index.php?topic=12504.0), which is some code I wrote to make that part extremely simple, and then considering whether to make your Faction compatible with DynaSector (although, IIRC, DynaSector requires that the maintainer approves your mod for inclusion for whatever silly reasons).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Regoso on July 31, 2017, 03:02:54 PM
Yes, it's actually fairly simple, you just need to write a .faction file, and include the faction in an otherwise-blank factions.csv file, like this:

Code
faction
data/world/factions/my_nifty_faction.faction

Faction files are pretty complicated-looking, but most of it's pretty easy to follow:

Once you have these two things done, you're done with the core part of building a Faction.  The rest of it's building actual content (ships and variants and weapons, populating strings, etc.).  To see the Faction spawn in the game, I'd really recommend using EZ Faction (http://fractalsoftworks.com/forum/index.php?topic=12504.0), which is some code I wrote to make that part extremely simple, and then considering whether to make your Faction compatible with DynaSector (although, IIRC, DynaSector requires that the maintainer approves your mod for inclusion for whatever silly reasons).

omg https://media.giphy.com/media/2WxWfiavndgcM/200.gif i spent hours yesterday trying to find a way to get the faction in the game. iv  almost got everything else done even the .faction file is just need to do variants and 1-2 more of the weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Undefined on August 04, 2017, 03:07:28 AM
Another quick one, is it possible to modify a market's BaseQualityFactor?
I'd like to create a condition that adjusts the strength of fleets that market creates and it seems that it would be the most efficient method. If not I guess replacing the Fleet script for that market entirely would be the best route?

I decided to implement the replacing the fleet script approach, leading to an additional question:

Code
List<FleetMemberAPI> members = fleet.getFleetData().getMembersInPriorityOrder();
for (FleetMemberAPI member : members) {
member.getStats().getBallisticWeaponDamageMult().modifyPercent("", 0.15f);
member.getStats().getBeamWeaponDamageMult().modifyPercent("", 0.15f);
member.getStats().getMissileWeaponDamageMult().modifyPercent("", 0.15f);
}

Using this approach, would any ships in that fleet subsequently disabled and captured as derelicts also be given this boost or would it be removed and a new base hull generated?
I guess I could reset the mults after battle with the player if I give them an Id and it's present, or perhaps a better approach would be giving them a hullmod with the same effect and removing it if it is present after a battle or when salvaged?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 04, 2017, 12:55:48 PM
So maybe this is the EZ faction utility mod at work here, but I thought there were many levels of reputation per faction in the campaign?

I'm only seeing it jump from: NEUTRAL(-10-30?) FRIENDLY(30-69) COOPERATIVE(70-100) during a script test?

Has it changed from how it was before with things like FAVORABLE, WELCOMING etc?

I ask because scripts and descriptions based on those aren't showing up from what I can see  :-\

Edit: Nvm, ugh I'm silly.   :P

For some reason I thought the number scale for rep worked differently, but after further testing its just that the levels above friendly are below 50 and the ranges I was looking at was greater than 50 at the time  :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 06, 2017, 02:55:45 AM
sup, SS.
trying modding. sadly, without much success.
therefore need help.
(http://i.imgur.com/PUFby0O.jpg)
carrier, while launching fighters, generates copies of its own sprite, that fly to the mass center of the carrier.
carrier also has no collisions, despite having bounds properly set.
Spoiler
(http://i.imgur.com/vNk2Gsd.jpg)
[close]
heres .ship contents
Spoiler
{
  "bounds": [
    -42.5,
    1.5,
    -51,
    10,
    -79,
    10,
    -79,
    28,
    -67,
    28,
    -45.5,
    48.5,
    -34.5,
    48.5,
    -14.5,
    68.5,
    -5.5,
    59.5,
    37.5,
    59.5,
    37.5,
    45.5,
    48.5,
    34.5,
    48.5,
    -34.5,
    37.5,
    -45.5,
    37.5,
    -59.5,
    -5.5,
    -59.5,
    -14.5,
    -68.5,
    -34.5,
    -48.5,
    -45.5,
    -48.5,
    -67,
    -28,
    -79,
    -28,
    -79,
    -10,
    -51,
    -10,
    -42.5,
    -1.5
  ],
  "builtInWings": [],
  "center": [
    67.5,
    78.5
  ],
  "collisionRadius": 0,
  "engineSlots": [
    {
      "angle": -135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -29.5,
        -52.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": 135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -29.5,
        52.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": -135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -27.5,
        -54.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": 135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -27.5,
        54.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": -135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -25.5,
        -56.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": 135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -25.5,
        56.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": -135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -23.5,
        -58.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": 135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -23.5,
        58.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": -135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -21.5,
        -60.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": 135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -21.5,
        60.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": -135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -19.5,
        -62.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    },
    {
      "angle": 135,
      "contrailSize": 3.536,
      "length": 20.152542,
      "location": [
        -19.5,
        62.5
      ],
      "style": "HIGH_TECH",
      "width": 3.535534
    }
  ],
  "height": 127,
  "hullId": "TF_D3C4",
  "hullName": "D3C4",
  "hullSize": "DESTROYER",
  "shieldCenter": [
    0,
    -0.5
  ],
  "shieldRadius": 92.5,
  "spriteName": "graphics/TF/ships/carrier small.png",
  "style": "HIGH_TECH",
  "viewOffset": 0,
  "weaponSlots": [
    {
      "angle": 0,
      "arc": 360,
      "id": "WS0001",
      "locations": [
        0,
        -0
      ],
      "mount": "TURRET",
      "size": "LARGE",
      "type": "UNIVERSAL"
    },
    {
      "angle": 180,
      "arc": 0,
      "id": "WS0002",
      "locations": [
        -19.5,
        -0
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "SYSTEM"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 1",
      "locations": [
        9,
        38,
        9,
        43,
        9,
        48,
        9,
        53
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 2",
      "locations": [
        9,
        -38,
        9,
        -43,
        9,
        -48,
        9,
        -53
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    }
  ],
  "width": 135
}
[close]
can someon help me, please? what am i doing wrong.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on August 06, 2017, 03:11:45 AM
...
  "collisionRadius": 0,
...

@passwalker I think this might be the culprit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 06, 2017, 03:19:35 AM
...
  "collisionRadius": 0,
...

@passwalker I think this might be the culprit.
thanks. set it to 150, works brilliant.
but how exactly do i set it? do i always have to manually edit .ship after i generate it from ship editor? and how much this radius should be?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on August 06, 2017, 10:48:43 PM

 thanks. set it to 150, works brilliant.
but how exactly do i set it? do i always have to manually edit .ship after i generate it from ship editor? and how much this radius should be?


If you set the ship's centre of mass in the ship editor (by pressing "C"), you can left click to place the COM and hold Ctrl to adjust the radius (and then left click to confirm it).

Having said that, looking at your file you managed to do exactly that for the shield radius just fine, so I'm really confused how you couldn't do the same for the COM and collision radius.  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 08, 2017, 03:03:48 AM
sup, FS!
is there a way i can set flux vent exhaust point separately from shield center point? i mean without writing scripts, just through stats.
also
what makes ion beam so ion? where does IonBeamEffect hides? i can't find.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 08, 2017, 10:09:08 AM
Flux venting is done automatically and is pretty much hard-coded to use the ship's collision box as the basis; so far as I know, Alex hasn't exposed that part of the engine to us.  But you can make it invisible in hull_styles.json and use my FX system to make a new effect if you want.

IonBeamEffect is in the Starsector API, which is located in starsector_core.  Unzip that file somewhere and has all of the code that's currently exposed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 09, 2017, 12:27:25 AM
Flux venting is done automatically and is pretty much hard-coded to use the ship's collision box as the basis; so far as I know, Alex hasn't exposed that part of the engine to us.  But you can make it invisible in hull_styles.json and use my FX system to make a new effect if you want.

IonBeamEffect is in the Starsector API, which is located in starsector_core.  Unzip that file somewhere and has all of the code that's currently exposed.
thanks, that's very helpful, i'll try that.

also another question
where can i read something about collision types for projectiles? and is it possible to make projectile "ghost" through both shield AND hull, while dealing damage? i remember the Nidhoggr lance from shadowyards could ghost through hull long time ago, not sure if it still does. did't find anything fancy in .proj.

also another question
is it possible to make a fighter wing out of several different fighters? like a wing of 1 pirahna with 2 wasp escorts.
also can fighters be carriers? i mean launch fighters and so on
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on August 09, 2017, 12:31:24 PM
... is it possible to make projectile "ghost" through both shield AND hull, while dealing damage? i remember the Nidhoggr lance from shadowyards could ghost through hull long time ago, not sure if it still does. did't find anything fancy in .proj.

This is still possible, but you need some scripts rather than just .proj modification. You essentially do this:

Step 1: Set collision to NONE; this means it passes through everything without doing damage

Step 2: Run a EveryFrame script which causes damage at whatever point your projectile is currently at, if it's over a ship
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on August 11, 2017, 10:30:30 AM
Sorry if this has been asked before, but i could not find any answers searching through the thread:

Is it possible to (script-sidedly, preferably via hullmod) lower the damage of a certain weapon size? Failing that, is it possible to lower the damage of a specific weapon?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 11, 2017, 10:50:55 PM
hello
having troubles with scripting.
i'm not sure this is the right place to ask.
trying to adapt tartiflette's transforming script for my nefarious purposes.
so here:
Spoiler
Code: java
//by Tartiflette, this script makes various decorative weapons apeare
//feel free to use it, credit is appreciated but not mandatory
package data.scripts;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import java.util.List;
import org.lazywizard.lazylib.FastTrig;
import org.lazywizard.lazylib.MathUtils;

public class TF_C01_transform implements EveryFrameWeaponEffectPlugin {

    private WeaponAPI arm1R;
    private WeaponAPI arm2R;
    private ShipAPI ship;   
    private ShipSystemAPI system;
    private ShipEngineControllerAPI engines;
   
    public static final String slotarm1rightID = "slotARM1R";
    public static final String slotarm2rightID = "slotARM2R";
   
    private boolean runOnce=false;
    private boolean soundIN=true;
    private boolean soundOUT=true;
   
    private float arm1w, arm1h, arm2w, arm2h;
   
    private float rate=1;
    private boolean travelDrive = false;
   
    private final float rotateOffset=90;
    private final float armOffsetX=100;
    private final float armOffsetY=100;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
       
        if (Global.getCombatEngine().isPaused()) {
            return;
        }
       
        //initialise the variables
        if (!runOnce || ship==null || system==null){
            ship=weapon.getShip();
            system = ship.getSystem();
            engines = ship.getEngineController();
            List <WeaponAPI> weapons = ship.getAllWeapons();
            for (WeaponAPI w : weapons){
                switch(w.getSlot().getId()){
                    case slotarm1rightID:
                        arm1R=w;
                        arm1h=w.getSprite().getHeight();
                        arm1w=w.getSprite().getWidth();
                        break;
                    case slotarm2rightID:
                        arm2R=w;
                        arm2h=w.getSprite().getHeight();
                        arm2w=w.getSprite().getWidth();
                        break;
                }               
            }           
            runOnce=true;
            //return to avoid a null error on the ship
            return;
        }
       
        //ENGINES SHIELDS MOVEMENT ROTATIONS     
       

        //ALL THE STUFF
       
        if(ship.getTravelDrive().isActive() || ship.getFluxTracker().isVenting()){
            rate = Math.min(1,rate+amount);
            travelDrive=true;
        } else if (travelDrive){
            rate = Math.max(0,rate-amount);
            if(rate==0){
                travelDrive=false;
            }
        } else {
            rate = system.getEffectLevel();
        }
       
        if (rate==0){
            soundIN=false;
        } else if (rate==1){
            soundOUT=false;
        }
       
        if (system.isActive() || rate > 0){
           
            if(rate>0 && !soundIN){   
                soundIN=true;
                //Global.getSoundPlayer().playSound("diableavionics_transform_in", 1, 1, ship.getLocation(), ship.getVelocity());                       
            } else if (rate<1 && !soundOUT){               
                soundOUT=true;
                //Global.getSoundPlayer().playSound("diableavionics_transform_out", 1, 1, ship.getLocation(), ship.getVelocity());                     
            }
           
//lgun.setRemainingCooldownTo(1);
//rgun.setRemainingCooldownTo(1);
                       
            float rotateArms = SO(rate,0.25f,0.75f);
            float slideArms = SO(rate,0f,0.5f);
            float extendArms = SO(rate,0.5f,1f);

           
            float arm1Y = arm1h/2 + armOffsetY*slideArms;
            float arm1X = arm1w/2;
            float arm2X = arm2w/2 + armOffsetX*slideArms;


arm1R.getSprite().setCenter(ldX, dY);
arm2R.getSprite().setCenter(ldX, dY);


           
            //float clipDoors = RSO(rate,0.5f,1f);
           
     
        } else {
                   
        }
    }

    //////////////////////////////////////////
    //           SMOOTH DAT MOVE            //
    //////////////////////////////////////////
   
    public float smooth (float x){
        return 0.5f - ((float)(FastTrig.cos(x*Math.PI) /2 ));
    }
   
    //////////////////////////////////////////
    //           OFFSET DAT TIME            //
    //////////////////////////////////////////
   
    public float offset (float x, float start, float end){
        return (float) Math.min(1, Math.max( 0 , (x-start)*(1/(end-start))));
    }
   
    //////////////////////////////////////////
    //           SMOOTH + OFFSET            //
    //////////////////////////////////////////
   
    public float SO (float x, float start, float end){
        return 0.5f - ((float)( FastTrig.cos( Math.min( 1, Math.max( 0 , (x-start)*(1/(end-start)))) *Math.PI ) /2 ));
    }
   
    //////////////////////////////////////////
    //      RETURN + SMOOTH + OFFSET        //
    //////////////////////////////////////////
   
    public float RSO (float x, float start, float end){
        return 0.5f - ((float)( FastTrig.cos( Math.min( 1, Math.max( 0 , (x-start)*(1/(end-start)))) *Math.PI*2 ) /2 ));
    }
}
[close]
gives the following error:
(http://i.imgur.com/HH274Rb.jpg)
it is to my very limited understanding of java that the following part dosn't work properly. probabaly due to some wariables being declared incorrectly.
Code: java
for (WeaponAPI w : weapons){
           [u][b] switch(w.getSlot().getId()){[/b][/u]
                    case slotarm1rightID:
                        arm1R=w;
                        arm1h=w.getSprite().getHeight();
                        arm1w=w.getSprite().getWidth();
                        break;
                    case slotarm2rightID:
                        arm2R=w;
                        arm2h=w.getSprite().getHeight();
                        arm2w=w.getSprite().getWidth();
                        break;
                }               

can anyone help, please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 12, 2017, 10:25:28 AM
Sorry if this has been asked before, but i could not find any answers searching through the thread:

Is it possible to (script-sidedly, preferably via hullmod) lower the damage of a certain weapon size? Failing that, is it possible to lower the damage of a specific weapon?

Hmm - nothing comes to mind directly, but someone more versed in modding trickery may have an answer.

@passwalker: you can only run a switch statement on integers. It doesn't work on Strings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 12, 2017, 04:49:50 PM
@passwalker: you can only run a switch statement on integers. It doesn't work on Strings.
yeah, that's written in the error message, captain. but thanks anyway
i also tried forsing DA mod using the otiginal script from source instead of jar - it crashed with the same error.  well, no transformations for now.

@Nicke535: here's this thing: http://fractalsoftworks.com/forum/index.php?topic=12586.0 dunno... maybe...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on August 12, 2017, 08:10:41 PM
I'm looking for a particularly basic code, Shipsystem or Hullmod, that provides ships a Shield Type which completely covers the hull instantly, a la Star Trek/SoaSE/every other Sci-games.

Similar to the Templars but without the complex abilities like its flux discharge at critical and are only active like regular shields (Flux maintenance while active, flux increase by taking damage) while allowing armor and hull to take a portion of the damage not absorbed by the barrier.

If there isn't any, it is okay with me. I may be asking too much since this shield type is unique and requires actual coding that is not likely to exist in the Starsector base.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on August 12, 2017, 09:39:57 PM
I'm looking for a particularly basic code, Shipsystem or Hullmod, that provides ships a Shield Type which completely covers the hull instantly, a la Star Trek/SoaSE/every other Sci-games.

Similar to the Templars but without the complex abilities like its flux discharge at critical and are only active like regular shields (Flux maintenance while active, flux increase by taking damage) while allowing armor and hull to take a portion of the damage not absorbed by the barrier.

If there isn't any, it is okay with me. I may be asking too much since this shield type is unique and requires actual coding that is not likely to exist in the Starsector base.

Damper Field  :P

Also, on a similar note, for regular-type shields there is a mutableStat "shieldUnfoldSpeed" or something that affects the speed at which a shield deploys/extends.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on August 12, 2017, 10:00:27 PM
Damper Field  :P

Close, but Damper Field is an ability that depends on "Uses" and only extends to reducing damage in general and not utilize Flux unlike the Templars did.

I could remove the Weapon Lock and rig it to use flux at a constant rate, but I don't think there is a base script explicitly to gain flux from the amount of damage the shield absorbs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on August 12, 2017, 10:18:51 PM
Damper Field  :P

Close, but Damper Field is an ability that depends on "Uses" and only extends to reducing damage in general and not utilize Flux unlike the Templars did.

I could remove the Weapon Lock and rig it to use flux at a constant rate, but I don't think there is a base script explicitly to gain flux from the amount of damage the shield absorbs.

Yeah, that would be a bit more tricky. ;) I was more using the Damper Field to represent the "fast shield that instantly covers the ship" part of your query.

Although, I wasn't aware the Lattice Shields on Templar ships actually generated flux as they took damage. Huh.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 13, 2017, 01:20:46 PM
Well, it's embarassing, but I'm stumped, trying to draw a textured quad in SS. 

I have the code below built, but it doesn't appear to do anything at all, other than not crash.   I've tried looking at the examples laying around but haven't gotten anywhere.

Running in renderInWorldCoords()

Code
		int textureID = 0;
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

for(fx_Particle particle : fx_SharedLib.particleList){
if(particle.sprite.getTextureId() != textureID){
textureID = particle.sprite.getTextureId();
glBindTexture(GL_TEXTURE_2D, textureID);
}

glColor4ub((byte)particle.curColor.getRed(),
(byte)particle.curColor.getGreen(),
(byte)particle.curColor.getBlue(),
(byte)particle.curColor.getAlpha());
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
Vector2f vec = MathUtils.getPointOnCircumference(particle.position, particle.size.getX(), particle.angle + 315f);
glVertex2f(vec.getX(),vec.getY());

glTexCoord2f(1, 0);
vec = MathUtils.getPointOnCircumference(particle.position, particle.size.getX(), particle.angle + 45f);
glVertex2f(vec.getX(),vec.getY());

glTexCoord2f(1, 1);
vec = MathUtils.getPointOnCircumference(particle.position, particle.size.getX(), particle.angle + 135f);
glVertex2f(vec.getX(),vec.getY());

glTexCoord2f(0, 1);
vec = MathUtils.getPointOnCircumference(particle.position, particle.size.getX(), particle.angle + 225f);
glVertex2f(vec.getX(),vec.getY());
glEnd();
}
glPopMatrix();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 13, 2017, 01:36:34 PM
I'd try disabling GL_TEXTURE_2D and trying to render a single quad with a hardcoded color and hardcoded coordinates (probably based on the player fleet's location?) Just something where you can get anything rendering at all, that's often the hardest part :)

My guess, fwiw, is that the coordinates are off and they're rendering somewhere, just now where you can see. Or the color is borked.

Also, you probably want to put the glBegin/glEnd outside the loop, but that's a performance thing and wouldn't cause what you're seeing. Or not seeing, as it were.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 13, 2017, 01:42:48 PM
K, I'll give that a go.  Like I said, kind of embarassing, lol  ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 13, 2017, 07:16:04 PM
couple more questions
is it possible to make custom weapon slot and some weapons compatible only with this type of slots?
is it possible to make station modules equipable in refit menu and obtainable through market?
thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 14, 2017, 07:06:03 AM
1.  It's not possible to make a custom weapon slot, unfortunately.  You'll want to use Built-In weapons instead, if you want unique, Faction-specific weapons that nobody else can have.

2.  I don't know about the Station Modules, but I'm guessing no; they are "weapons" currently, but they aren't exactly set up to be friendly to equipping / modification in the Refit UI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 14, 2017, 08:08:10 PM
@xenoargh, that's disappointing, but thanks anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 15, 2017, 06:30:41 AM
What do all he new weapon slot types actually do?


Ballistic
Missile
Energy
Universal

Those are all simple

But what about the new ones? Is Hybrid ballistic+energy? ETc..?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orikson on August 15, 2017, 08:49:33 AM
What do all he new weapon slot types actually do?


Ballistic
Missile
Energy
Universal

Those are all simple

But what about the new ones? Is Hybrid ballistic+energy? ETc..?

Hybrid - You can put energy and ballistic type weapons in it.

Synergy - Energy & Missile.

Composite - Ballistic & Missile.

As with the Universal slot, the weapon fitted into them cannot be down sized (which means you can't put a small sized weapon in a medium sized slot like you can for pure type slots).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 15, 2017, 07:44:09 PM
sup!
what possible collisionclass can something have?
what exactly do different collisionclass mean?
and is it possible to make a missile NOT explode on hit, but keep flying into wall instead?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 15, 2017, 09:09:14 PM
For the specification of CollisionClass or other core game-code things, open up the Starsector API, located in starsector-core, starsector.api.zip. 

Just unzip that file somewhere and use a search tool to look for terms in it (I'm using Abacre's Advanced Find And Replace (http://abacre.com/afr/), which isn't free but is awesome, but there are lots of freeware text-search tools and grep parsers out there).

Anyhow, as to the specifics:

Code
public enum CollisionClass {
NONE,
RAY,
RAY_FIGHTER,
FIGHTER,
SHIP,
PROJECTILE_NO_FF,
PROJECTILE_FF,
MISSILE_NO_FF,
MISSILE_FF,
HITS_SHIPS_AND_ASTEROIDS,
PROJECTILE_FIGHTER,
ASTEROID,
PLANET,
GAS_CLOUD,
STAR,
;
}

Now, as to your specific questions. 

Quote
what exactly do different collisionclass mean?
Essentially, it does what it sounds like; each CollisionClass defines what type of CombatEntityAPI this object (in this case, a missile) can collide with.  Why you'd want to have projectiles collide with PLANET, GAS_CLOUD, or STAR, I have no idea, but you can.

Quote
is it possible to make a missile NOT explode on hit, but keep flying into wall instead?
You can easily make a missile not explode on hit, by setting its CollisionClass to NONE, in its PROJ file, like this:

Code
	"collisionClass":"NONE",
"collisionClassByFighter":"NONE",

Now you have a missile that will never do a collision check at all... unless you write some code to do something if the projectile's close enough to (thing).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 15, 2017, 09:25:34 PM
...
okay, thanks.
i'm most confused by _NO_FF thing. what does it mean?

also

setting missile's collisionclass to ASTEROID, combined with physical impact script from blackrock made effectively a tug/pusher drone launcher.
Spoiler
(http://i.imgur.com/5mScd1h.jpg)
[close]
the only thing left is to make ai fire them at both hostiles and friendlies.

also a question

can i use sounds from here http://freesound.org/ in my mod?

also a question

what do you guys use for balancing? i noticed that both codex and balance suite are atleast 4 yr old. and codex doesn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 17, 2017, 05:57:18 AM
- Is there something I can put in commodities.csv to make CommodityOnMarketAPI.isPersonnel() return true?
- I made my own loot event (with a showLoot() call). How do I change the image and text at the top left?

Spoiler
(http://i.imgur.com/QZ1fxUe.jpg)
[close]

can i use sounds from here http://freesound.org/ in my mod?
No reason you can't, if the sound's license permits.

Quote
what do you guys use for balancing?
Eyeball stats of comparable vanilla ships/weapons for a first pass (one shouldn't be obviously better for OP/supply cost than the other). Get a second opinion on this if one is handy.
After that, it's mostly playtesting to see if the thing behaves as expected in combat, and adjust accordingly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 17, 2017, 10:10:49 AM
- Is there something I can put in commodities.csv to make CommodityOnMarketAPI.isPersonnel() return true?

Currently, only if the demand class is "crew" or "marines". Already added a "personnel" tag in the dev version, though.

- I made my own loot event (with a showLoot() call). How do I change the image and text at the top left?

You can't, sorry - these are hardcoded. Not for any design reason, just for "had to get it done quickly at some point" reasons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on August 17, 2017, 08:08:40 PM
Is there a way to add a different standalone version of crew? I've been meaning to add a version of crew that is a hybrid of crew and marines... and if not then I'd like to at least have gazer commandos for marines and regular gazer engineers, scientists and astronauts as crew.

And if all of the above can't be done then I just seriously need to have to remove the crew requirements to survey planets and also any thing else that requires me to have crew on-board so that I can do something necessary.

EDIT: Whoops, didn't notice the Alex's post here, tired and my vision is rather blurry currently. Darn.. so what are my alternatives? :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 23, 2017, 04:16:25 AM
Is there a hard-coded limit to the number of factions or number of inhabited planets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on August 24, 2017, 12:23:41 PM
How do you make a "(D) Skin" actually spawn as that ship's D-hull? Simply creating a .skin file does not seem to work as intended:
Spoiler
Code
{
"baseHullId":"crys_halo",
"skinHullId":"crys_halo_d",
"hullName":"Halo (D)",
#"fleetPoints":7,
#"systemId":"",
"descriptionId":"crys_halo",  # optional
"descriptionPrefix":"While it may once have served the Crystanite, this vessel has been hastily welded together and modified by looters. The lack of expertise in crystanite ships has led the ship to lose much of its power.",
"restoreToBaseHull":true,
"spriteName":"graphics/crys/ships/looted/crys_halo_d.png",
"baseValueMult":.67,
#"removeHints":[],
#"addHints":[],
"removeWeaponSlots":[], # ids
"removeEngineSlots":[], # indices, as engine slots have no id in the .ship file
"removeBuiltInMods":["crys_armor"], # hullmod ids
"removeBuiltInWeapons":[], # weapon slot ids
"builtInMods":["crys_broken_armor"],
"builtInWeapons":{
  },
}
[close]
The file was copied and edited from the Buffalo (D), which (as far as I know) spawns properly.
Have tried with around 20 ships, both with and without skills, and none of them actually became this custom D hull; they simply became the vanilla auto-generated D-hulls.

Sorry if this has been asked before, but searching the forums yielded no results at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2017, 12:29:40 PM
Is there a hard-coded limit to the number of factions or number of inhabited planets?

There isn't but I wouldn't go with more than 50-60 or so markets for the time being.


How do you make a "(D) Skin" actually spawn as that ship's D-hull? Simply creating a .skin file does not seem to work as intended:

It doesn't work like that - ships with damage will always be auto-generated D-hulls. Pre-made D skins are useful if you want a predefined D-hull to use somewhere (such as, say, in a faction's fleets).

The file was copied and edited from the Buffalo (D), which (as far as I know) spawns properly.

It doesn't, i.e. if you start with a normal Buffalo and recover it as a d-hull, it will *not* be the Buffalo (D) skin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drokkath on August 24, 2017, 01:14:30 PM
Aye, what he said. In previous versions of the core game it always felt odd to me that D-hulls were a default and common ship types aka implemented certain variations and yet one couldn't wreck any other vessel into a D-class. The current .8 version of the game feels so right, as in as it should be and then some, pirates are pirates, pathers are pathers but the player is after all a mastermind-in-making character and so it makes sense for such a character to know much better about the tech between for example a healthy brawler-class and an unhealthy brawler-class of the pathers, means the ability to repair it if it is necessary enough.

Yesterday I was playing the game for a while and was wreaking havoc upon Luddic Church fleets and one of the medium sized fleets had two Mora-class ships, one of them I shot a barrage of my singular micro super swarmer missiles at along with slicing apart the large vessel with my super mininglasers. Point being that I rammed into a Mora with my super-ship while firing my micro swarmers followed by cutting beams, tore that Mora into about a dozen pieces or more, most likely beyond repair I thought at the time...

...guess what? Upon watching what ships I could recover, recovery sheet included not only one Mora that didn't get such harsh blast apart treatment.. it also included the one I just wrecked into different shapes and sizes of debris heading into 8 different directions. And to top it all of, it had only three debuff hullmods. Made me go "wait, what!??", life is cool sometimes. :D
The cause of it I can think of is probably that I didn't disintegrate that Mora's parts and so merely only broke off everything it seems, even defeated capitals are sturdy enough to withstand my fire barrage for a while until breaking point.


Apart from that I've pretty much found the right kind of overpowered super-weaponry and overpowered super-ship level(s). Not too over-the-top of over-the-top and not too under over-the-top of over-the-top, not sure what I mean by that myself but basically the gist of it is that I can still play with smaller hostile vessels as if they were a cat's prey or a toy by minimal short click to send out as little firepower as possible and having fun with the fleeing ships while the crew there crap their pants.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on August 25, 2017, 06:39:07 AM
How do you make a "(D) Skin" actually spawn as that ship's D-hull? Simply creating a .skin file does not seem to work as intended:

It doesn't work like that - ships with damage will always be auto-generated D-hulls. Pre-made D skins are useful if you want a predefined D-hull to use somewhere (such as, say, in a faction's fleets).

The file was copied and edited from the Buffalo (D), which (as far as I know) spawns properly.

It doesn't, i.e. if you start with a normal Buffalo and recover it as a d-hull, it will *not* be the Buffalo (D) skin.

Aha, that explains a lot. Well then, that made my life slightly harder...

Follow-up question: is there any call I can make in the campaign to detect whether a ship has been recovered? Or will i simply have to check whether a ship has D-mods and replace them thereafter?


EDIT: Found out that there is a isDHull check, so this question is unecessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on August 25, 2017, 02:29:04 PM
Ok, another (maybe dumb) question: what, exactly, is the .GetFleetMemberId function used for? After searching through most fleet-based code, I have yet to find any function that actually takes the "Fleet Member ID" as an argument.

Follow-up to that question, how would I go about finding a specific ship's related FleetMemberAPI? Casting does not work (obviously), and all functions in FleetAPI seems to use a sorting method that cannot be returned from the ShipAPI. I'm running tests to try and circumvent the process altogether, but if there is a way to get a FleetMemberAPI from a ShipAPI, it would streamline the process immensely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 26, 2017, 03:28:22 AM
A completely *** question from someone who never programed in Java.

Near as I can tell, .jar is just compressed, complied files.
.class are complied .java files, but java files by themselves work by being processed at run-time.

So making a .jar is not strictly necessary, right?
A mod should work with just .java file in proper directories.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 26, 2017, 09:08:09 AM
If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 26, 2017, 10:15:40 AM
If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?

For fighters, "no_sell" in the wing data file. For weapons, I believe "SYSTEM" in the hints column should do it.

Near as I can tell, .jar is just compressed, complied files.
.class are complied .java files, but java files by themselves work by being processed at run-time.

So making a .jar is not strictly necessary, right?
A mod should work with just .java file in proper directories.

The game will compile certain .java files on startup. Generally speaking those have to be somewhere under the data/scripts/ folder.

However, it uses a special compiler - called Janino - to do this. It doesn't support a number of language features and in general isn't the most reliable thing in the world. In addition, compiling on every game start makes it take longer to load.

So, basically, a jar file is all around the preferred option - the game will start faster and you're less likely to run into problems with whatever you're trying to do. Loose .java files are ok for some minor assorted things but I wouldn't recommend it for something larger. Personally, I'm moving away from using them entirely.


Ok, another (maybe dumb) question: what, exactly, is the .GetFleetMemberId function used for? After searching through most fleet-based code, I have yet to find any function that actually takes the "Fleet Member ID" as an argument.

I don't think it's currently used for anything. It's just there to keep track of a specific fleet member if that was ever needed. To "use" it, you'd just iterate over the fleet members in a fleet and check to see if one of those is the one you're looking for.

Follow-up to that question, how would I go about finding a specific ship's related FleetMemberAPI? Casting does not work (obviously), and all functions in FleetAPI seems to use a sorting method that cannot be returned from the ShipAPI. I'm running tests to try and circumvent the process altogether, but if there is a way to get a FleetMemberAPI from a ShipAPI, it would streamline the process immensely.

DeployedFleetMemberAPI CombatFleetManagerAPI.getDeployedFleetMember(ShipAPI ship);

Then that has a method that gets you a FleetMemberAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 26, 2017, 10:23:19 AM
If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?

For fighters, "no_sell" in the wing data file. For weapons, I believe "SYSTEM" in the hints column should do it.

You mean in the tag section?

AI_fighter_wing,AI-fighter_variant,"fighter2, fighter, low, no_sell",1,,6,8,BOX,5000,500,4,FIGHTER,Fighter,10,10000,,,,,,,,2004
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on August 26, 2017, 03:25:58 PM
If I want a weapon or wing LPC to NOT appear on the market, what do I do?
"remnant" tag?

For fighters, "no_sell" in the wing data file. For weapons, I believe "SYSTEM" in the hints column should do it.

You mean in the tag section?


Yep. "no_sell" in the tags for fighter wings. You can also add "no_drop" to stop the LPC dropping as loot, if it's a built-in wing you don't want to be modular (see: Shepherd's Borer Drones and Tempest's Terminator Drone).

Also, for weapons marked as "SYSTEM" in the hints, take note that by default system weapons also won't appear in the codex - though there is a "SHOW_IN_CODEX" flag you can also add to override that (which is how you can see things like the Onslaught's TPCs in the codex).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 27, 2017, 05:43:20 AM
Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipAPI;

public class AmplifiedSensors3 extends BaseHullMod {

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 75f);
mag.put(HullSize.FRIGATE, 100f);
mag.put(HullSize.DESTROYER, 125f);
mag.put(HullSize.CRUISER, 150f);
mag.put(HullSize.CAPITAL_SHIP, 200f);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}


public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getSightRadiusMod().modifyPercent(id, (Float) mag.get(hullSize));
stats.getAutofireAimAccuracy().modifyPercent(id, 25f);

}


public boolean isApplicableToShip(ShipAPI ship) {
return
!ship.getVariant().getHullMods().contains("comp_hull");
}

}

I made a sensor enhancement hullmod, but it does not work. Why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 27, 2017, 07:57:12 AM
"Does not work" is pretty vague.  Did you make sure that the id of the "comp_hull" Hull Mod you're looking for is installed on that Variant?

That would be the simplest explanation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 27, 2017, 08:43:48 AM
"Does not work" is pretty vague.  Did you make sure that the id of the "comp_hull" Hull Mod you're looking for is installed on that Variant?

That would be the simplest explanation.

comp_hull is compromised hull. No, it's not on the ship.

The hullmod doesn't seem to have any effect, as the ships sill has 20 sensor range, and it should have the highest sensor range in the fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 27, 2017, 06:03:40 PM
SightRadiusMod is for the combat sight radius, not Sensors in the Strategic view. 

So use stats.getSensorStrength() instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 28, 2017, 12:01:43 AM
SightRadiusMod is for the combat sight radius, not Sensors in the Strategic view. 

So use stats.getSensorStrength() instead.

thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 29, 2017, 10:49:56 AM
*sigh*

So I have this:
   "modPlugin":"data.scripts.SCModPlugin"


in my mod_info.json, and in my data\scripts I have this SCModPlugin.java file:

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.campaign.events.CampaignEventTarget;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAIPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.procgen.ConditionGenDataSpec;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import java.io.IOException;
import org.json.JSONException;

public class SCModPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        updateConditionSpecs();
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("ISA");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("RSF");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UIN");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("XLE");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("FFS");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("VNS");
    }

}


I get this error:
Code
34014 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.SCModPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.SCModPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.SCModPlugin'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.SCModPlugin' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 30, 2017, 03:11:06 AM
Anyone?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on August 30, 2017, 04:34:50 AM
The error seems to imply that something is wrong with either the path or the file name. It looks correct, but check your filenames and folder names.

Also you may want to clean up those imports.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 30, 2017, 06:05:25 AM
I looked at how Interstellar Imperium did it and copied, removing unnecessary code.
I did check my paths and filenames, which is why it's puzzling me.

SCModPlugin is used everywhere in proper case.

And those imports are all standard Starfarer functions and I removed all II ones, so there shouldn't be problems. I suppose I don't really need anything other than BaseModPlugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 30, 2017, 07:24:57 AM
Changing 
"modPlugin":"data.scripts.SCModPlugin"     <---- this seems to only work if it's in a .jar
into 
"modPlugin":"data\scripts\SCModPlugin.java"

stops the crash, but it does so because the game doesn't see my mod anymore. Cant select it.

WTF is going on?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 30, 2017, 08:23:15 AM
Probably the code can't be compiled by Janino.  Which is weird, because I don't see anything very obvious there, but basically, you need to compile to a JAR.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on August 30, 2017, 09:08:11 AM
Without seeing some screenshots, it's hard to say whether you've encountered a Janino bug (of which there are many, especially relating to the resolving of imports), or have made a mistake yourself.

General problem solving process should work though; reduce the number of contributing factors until it starts working, and build up from there.

Start with a class whose name & package precisely matches the source file's location & name, and which contains the absolute minimum of imports & zero functional code.

Changing  
"modPlugin":"data.scripts.SCModPlugin"     <---- this seems to only work if it's in a .jar
into  
"modPlugin":"data\scripts\SCModPlugin.java"

stops the crash, but it does so because the game doesn't see my mod anymore. Cant select it.

WTF is going on?

Don't guess; read the spec. (http://fractalsoftworks.com/forum/index.php?topic=4760.0)

The modPlugin attribute in mod_info.json should be the fully qualified name of a class implementing the com.fs.starfarer.api.ModPlugin interface.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 30, 2017, 09:16:19 AM
Also, if you haven't set up NetBeans / Eclipse, do that immediately; it would have told you that your current code has a bunch of un-necessary dependencies it's loading, any of which might be the cause of the issue.  I know that learning how to build a JAR seems rather confusing / intimidating at first, but it's basically a one-time setup hassle and after that, it's easy :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 30, 2017, 12:11:20 PM
Bloody hell. Got the SDF kit, compiled, still the same s***

Here's the contents of the .jar (attached image)

And here's the code for the SCModPlugin

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

public class SCModPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        updateConditionSpecs();
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("ISA");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("RSF");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UIN");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("XLE");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("FFS");
        SharedData.getData().getPersonBountyEventData().addParticipatingFaction("VNS");
    }

}


[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 30, 2017, 12:22:05 PM
Post a link to a copy of your mod as it is now via PM and I'll take a look.  It's probably something small that's tripping you up somewhere :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 30, 2017, 02:08:24 PM
https://www.mediafire.com/folder/r40qicb1txupx/StarSector

Steelclad_v06_TEST is the main mod (data, jar and mod_info)
You'll need the sounds.rar and graphics.rar too

Also, EZFaction or NExirilien
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 31, 2017, 11:41:47 AM
Anything?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on September 01, 2017, 08:23:31 AM
Working on making a private mod Nexerelin compatible, keeps giving me this
Code
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/AleuramPlugin.java', Line 10, Column 39: Unknown variable or type "Global"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.CachingJavaSourceClassLoader.generateBytecodes(CachingJavaSourceClassLoader.java:163)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
plugin file looks like
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import exerelin.campaign.SectorManager;

public class AleuramPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
        if (!haveNexerelin || SectorManager.getCorvusMode()){
            new ADFSectorgen().generate(Global.getSector());
        }
}
}

Any way to fix it?

Edit: Good god am i stupid
I forgot to add
Code
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;


Edit: Another error.
Code
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/AleuramPlugin.java', Line 18, Column 29: Cannot determine simple type name "AdfSysGen"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.CachingJavaSourceClassLoader.generateBytecodes(CachingJavaSourceClassLoader.java:163)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

plugin looks like
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import exerelin.campaign.SectorManager;

public class AleuramPlugin extends BaseModPlugin {

    @Override
    public void onNewGame() {
        boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
        if (!haveNexerelin || SectorManager.getCorvusMode()){
            new AdfSysGen().generate(Global.getSector());
        }
}
}
Edit: Fixed it again
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 01, 2017, 11:30:21 PM
TrashMan: Remove the updateConditionSpecs(); line. It's not defined in the plugin and I have no idea where it comes from.

Also your .jar doesn't work because it put stuff in a package named Modding.java.scripts instead of data.scripts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 02, 2017, 03:17:46 AM
TrashMan: Remove the updateConditionSpecs(); line. It's not defined in the plugin and I have no idea where it comes from.

Also your .jar doesn't work because it put stuff in a package named Modding.java.scripts instead of data.scripts.

Fixed both. Still the same.

Could it be a manifest file problem?


EDIT: Re-complied again, making sure the manifest file is updated with "Main-Class: scripts.SCModPlugin"

No change. Still the same error. The .jar is below in zip format

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 02, 2017, 07:45:20 AM
What's he difference between ModPlugin and BaseModPlugin?


Also, when compiling, do I need to somehow link to the sarfarer.api?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 02, 2017, 08:28:20 AM
Your packages are still wrong (should be data.scripts not just scripts). It works fine on my side just from changing data/scripts/SCModPlugin.java without touching the .jar, which still isn't being used.

Also don't duplicate Java files between the mod's data/scripts folder and what goes into the jar, at best it's confusing.

Also: why are you using command line instead an IDE? You're not even actually compiling the Java files as far as I can tell, just archiving them in a jar (as if it were a zip file).

What's he difference between ModPlugin and BaseModPlugin?
ModPlugin is an interface (https://docs.oracle.com/javase/tutorial/java/concepts/interface.html), BaseModPlugin is a class implementing that interface.
But the only thing you need to know: you should extend BaseModPlugin (that's what it's there for) instead of going to the trouble of implementing ModPlugin directly.

Also, when compiling, do I need to somehow link to the sarfarer.api?
Yes. (The fact that it hasn't already thrown a compile error is further evidence that it's not actually being compiled. Seriously, get an IDE, it'll save heaps of effort in the medium and long term.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 02, 2017, 10:08:48 AM
I did get it.
I made a new project. Added starfarer.api.jar to the libraries/jars.
Made a data.scripts package and put the code in there.
Compiled.
Re-named the .jar to SC.jar
Tried to start SS


Code
53249 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.scripts.ScriptStore.?00000(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.o00000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

All I wanted is to add one line that will allow my factions to generate bounties.
WHHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY?????

(https://thumb.ibb.co/jTD9oa/SS_problem2_png.jpg) (https://ibb.co/jTD9oa)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 02, 2017, 12:07:09 PM
A week of failures.

A this point, instead of trying to help me with advice, it would be faster to simply compile that .jar for me. Would take less time.... :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 02, 2017, 10:42:21 PM
Project Properties (right-click on the project in Projects window, or use the File menu) -> Sources -> Set Source/Binary Format to JDK 7
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 03, 2017, 12:44:30 AM
Project Properties (right-click on the project in Projects window, or use the File menu) -> Sources -> Set Source/Binary Format to JDK 7

Nope. Still getting the same error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on September 03, 2017, 02:45:24 AM
Getting this
Code
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.ship.A.if.startedChargeup(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.OoOO.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.D.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.D.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.OoOO.String(Unknown Source)
at com.fs.starfarer.combat.entities.ship.A.if.advance(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

each time i try to test fire a weapon i'm making for a private mod
.wpn file looks like
Code
{
"id":"ADF_PC",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"BALLISTIC",
"size":"LARGE",
"turretSprite":"graphics/weapons/ADF_PC.png",
"hardpointSprite":"graphics/weapons/ADF_PC.png",
"turretOffsets":[8.5, 0.5],
"turretAngleOffsets":[0],
"hardpointOffsets":[8.5, 0.5],
"hardpointAngleOffsets":[0],
"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",
"muzzleFlashSpec":{
"length": 75,
    "particleColor": [100,150,255,255],
    "particleCount": 30,
    "particleDuration": 2,
    "particleSizeMin": 3,
    "particleSizeRange": 4,
    "spread": 20
  },
"autocharge":true,  # whether the weapon will continue charging and fire if the LMB is tapped instead of held
"projectileSpecId":"ADF_PC_shot",  # projectile that will be fired
"fireSoundOne":"ADF_PC_CHARGE",
"firesoundTwo":"ADF_PC_FIRE",
}
.proj file looks like
Code
{
"id":"ADF_PC_shot",
"specClass":"projectile",
"spawnType":"BALLISTIC",
"collisionClass":"PROJECTILE_FF",
"collisionClassByFighter":"PROJECTILE_FIGHTER",
"length":53.0,
"hitGlowRadius":400,
"width":21.0,
"fadeTime":0.20,
"fringeColor":[96,208,240,200],
"coreColor":[96,208,240,200],
"textureScrollSpeed":64.0,
"pixelsPerTexel":5.0,
"bulletSprite":"graphics/missiles/ADF_PC_SHOT.png",

}
and the .csv entry looks like
Code
Godbreaker	ADF_PC	3			2000		60000	65000	1000	0		1			ENERGY	10000		4.8	60			0	0	0	0		12000			400	SYSTEM, SHOW_IN_CODEX		
Yes, it's supposed to be that ridiculously powerful, it's made for crushing battlestations.
Any way to fix it?
-Edit: It works if i comment out the first sound effect, but neither one plays.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 04, 2017, 07:22:53 PM
Is there any way to stop the battle before the battle occured?
And, how to make a fleet change faction when it come close to another hostile faction's fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 06, 2017, 11:21:07 PM
sup.
about lasers. the guardian PD has attribute "convergeOnPoint": true
i vvanted to make tvvinbeam laser, that converges on some point betvveen emitters. sadly, it didn't vvork, beams converge on point directly in front of the offset 1, like so:
Spoiler
(https://i.imgur.com/NNGAlkT.jpg)
[close]
is there some trickery(not scrips, i can't script) i can do to fix that issue.
if not, does anyone have a suggestion on to how such a vveapon should behave? (2 barrels vvith about 500px spacing betvveen)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on September 07, 2017, 12:30:31 AM
i vvanted to make tvvinbeam laser, that converges on some point betvveen emitters. sadly, it didn't vvork, beams converge on point directly in front of the offset 1, like so:
Spoiler
(https://i.imgur.com/NNGAlkT.jpg)
[close]
is there some trickery(not scrips, i can't script) i can do to fix that issue.

I think by default beams like this will always converge to the first offset coordinates set, so in order to get them to converge directly in the center you'd need a third beam (with its offset specified first in the array) firing from the middle of the ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 07, 2017, 08:42:59 AM

Why does the game complain hullSize is unknown variable or Type?

Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class VNSArmorRepair extends BaseHullMod
{
    private static final float ARMOR_REPAIRED_PER_SECOND = 5f;

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 10f);
mag.put(HullSize.FRIGATE, 5f);
mag.put(HullSize.DESTROYER, 3f);
mag.put(HullSize.CRUISER, 2f);
mag.put(HullSize.CAPITAL_SHIP, 1f);
}

    @Override
    public void advanceInCombat(ShipAPI ship, float amount)
    {
        // Grab the ship's armor grid and raw armor values
        final ArmorGridAPI armor = ship.getArmorGrid();
        final float[][] grid = armor.getGrid();

        // Calculate how much armor to repair per cell this frame
        // Armor per cell is NOT the same as the listed armor rating, so we have
        // to compensate by dividing max armor per cell by the 'actual' rating
        // This means 5 armor per second might only be ~0.3 armor per cell

        final float maxArmor = armor.getMaxArmorInCell(),
                toHeal = ((Float) mag.get(hullSize)) * amount * (maxArmor / armor.getArmorRating());


// If you want to repair a percentage of total armor per second instead, just change toHeal's value to
//toHeal = maxArmor * (ARMOR_REPAIRED_PER_SECOND / 100f) * amount.

        // Iterate over all armor cells and add repairs to their current value
        for (int x = 0; x < grid.length; x++)
        {
            for (int y = 0; y < grid[0].length; y++)
            {
                armor.setArmorValue(x, y, Math.min(grid[x][y] + toHeal, maxArmor));
            }
        }
    }
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getFluxDissipation().modifyPercent(id, -20f);
}


}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 07, 2017, 09:16:23 AM
Is there any way to stop the battle before the battle occured?

Depends on exactly what you mean. You can provide your own implementation of FleetInteractionDialogPluginImpl, though, which means you could do just about anything in theory.

And, how to make a fleet change faction when it come close to another hostile faction's fleet?

See: com.fs.starfarer.api.impl.campaign.SmugglingFactionChangeScript


i vvanted to make tvvinbeam laser, that converges on some point betvveen emitters. sadly, it didn't vvork, beams converge on point directly in front of the offset 1, like so:
Spoiler
(https://i.imgur.com/NNGAlkT.jpg)
[close]
is there some trickery(not scrips, i can't script) i can do to fix that issue.

I think by default beams like this will always converge to the first offset coordinates set, so in order to get them to converge directly in the center you'd need a third beam (with its offset specified first in the array) firing from the middle of the ship.

Yeah, exactly. The whole thing is a bit of a hack.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on September 07, 2017, 10:15:09 AM

Why does the game complain hullSize is unknown variable or Type?

Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.ArmorGridAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class VNSArmorRepair extends BaseHullMod
{
    private static final float ARMOR_REPAIRED_PER_SECOND = 5f;

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 10f);
mag.put(HullSize.FRIGATE, 5f);
mag.put(HullSize.DESTROYER, 3f);
mag.put(HullSize.CRUISER, 2f);
mag.put(HullSize.CAPITAL_SHIP, 1f);
}

    @Override
    public void advanceInCombat(ShipAPI ship, float amount)
    {
        // Grab the ship's armor grid and raw armor values
        final ArmorGridAPI armor = ship.getArmorGrid();
        final float[][] grid = armor.getGrid();

        // Calculate how much armor to repair per cell this frame
        // Armor per cell is NOT the same as the listed armor rating, so we have
        // to compensate by dividing max armor per cell by the 'actual' rating
        // This means 5 armor per second might only be ~0.3 armor per cell

        final float maxArmor = armor.getMaxArmorInCell(),
                toHeal = ((Float) mag.get(hullSize)) * amount * (maxArmor / armor.getArmorRating());


// If you want to repair a percentage of total armor per second instead, just change toHeal's value to
//toHeal = maxArmor * (ARMOR_REPAIRED_PER_SECOND / 100f) * amount.

        // Iterate over all armor cells and add repairs to their current value
        for (int x = 0; x < grid.length; x++)
        {
            for (int y = 0; y < grid[0].length; y++)
            {
                armor.setArmorValue(x, y, Math.min(grid[x][y] + toHeal, maxArmor));
            }
        }
    }
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getFluxDissipation().modifyPercent(id, -20f);
}


}

I can immidiately see 2 things:

1. At "final float maxArmor = armor.getMaxArmorInCell()," (row 38, I think) the line ends in a comma, not a semicolon

2. In the "advanceInCombat" function the hullSize variable is, indeed, an unknown variable. The function passes in a ShipAPI, but not the ships hullSize directly. To fix this, you would need to add:
Code
HullSize hullSize = ship.getHullSize();
inside the function. It also has to be before you try to call it (row 39, I think?).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 07, 2017, 01:48:48 PM
(Seriously, use an IDE. At this point you've spent *way* more time on errors that wouldn't happen if you had one, and if you set one up, you'll probably learn something generally-useful as well.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 07, 2017, 04:50:12 PM
@Tufted Titmouse: Just to quickly check, do you have the corresponding sounds.json entries set up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tufted Titmouse on September 08, 2017, 04:07:10 AM
@Tufted Titmouse: Just to quickly check, do you have the corresponding sounds.json entries set up?

There's supposed to be a sounds.json? Where does it go?
Nevermind, i found it, Will fix


-edit Nope, That didn't fix it
@Histidine
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 08, 2017, 11:01:28 AM
(Seriously, use an IDE. At this point you've spent *way* more time on errors that wouldn't happen if you had one, and if you set one up, you'll probably learn something generally-useful as well.)

I know. I got it and i reported that toHeal doesn't have a type (should be float).

But one thing hat I can't figure out, since this isn't my code, someone else wrote it - where the hell is "amount" defined?
It is called as a variable, but I see nothing defining it....

EDIT: Nevermind. Module works now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 08, 2017, 11:30:56 AM


See: com.fs.starfarer.api.impl.campaign.SmugglingFactionChangeScript


Thanks a lot! And I found that, if one fleet addAssignment(FleetAssignment.GO_TO_LOCATION, somewhere, 30f), it may stop  in the half way and the fleet would try to catch nearby hostile fleet, ignoring the assignment what i have gived. Is there anyway to make AI fleets concertrate on my assignments?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 09, 2017, 08:27:30 PM
2 things:

1) Anyone using intellij know why recompiling would add 100mb each compile despite no script changes?? My jar is now at 1.2 gb from relatively minor scrip cleanup and other small changes. At this point netbeans is looking way more attractive... >:(

2) I'm looking for a way to call a memory map variable in a script to check for "easymode"

something like:

Code
       easyMode = memoryMap.get(MemKeys.GLOBAL).getBoolean("$EasyStart");

Can't find the variable in a dump anywhere in the campaign.

Even just pointing to a class or script that contains it would be good enough.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 09, 2017, 10:09:16 PM
2) I'm looking for a way to call a memory map variable in a script to check for "easymode"

com.fs.starfarer.api.util.Misc.isEasy()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 09, 2017, 11:33:01 PM
com.fs.starfarer.api.util.Misc.isEasy()

Thank you! Worked perfectly!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 09, 2017, 11:48:30 PM
1) Anyone using intellij know why recompiling would add 100mb each compile despite no script changes?? My jar is now at 1.2 gb from relatively minor scrip cleanup and other small changes. At this point netbeans is looking way more attractive... >:(

Think I'm on to something with this. Its definitely something I'm not understanding with how the IDE is building its modules. Its compiling the whole mod into the jar.. including the prior jar containing, you guessed it, the whole mod, again, each compile. So that's why its exponentially growing.

I just don't quite understand what to do to stop it without breaking everything  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2017, 08:13:09 AM
I'm not familiar with intellij, but: my guess would be the output directory for the jar is inside the directory that's configured as the "source" directory for the project. It might be possible to exclude a specific file, or you might have to move it somewhere else. Again, though, not familiar w/ it so this is just a guess.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 10, 2017, 10:32:03 AM
I'm not familiar with intellij, but: my guess would be the output directory for the jar is inside the directory that's configured as the "source" directory for the project. It might be possible to exclude a specific file, or you might have to move it somewhere else. Again, though, not familiar w/ it so this is just a guess.

It was a good guess (also what I was thinking) but, no, moving the output directory outside of the source directory doesn't solve the problem. At 1.5gigs for the jar now when the scripts equal 50kb respectively.

Edit: Interesting. I didn't expect it to actually remove the prior jar from the source directory. So I'm about 90% sure now changing the directory just makes the IDE move the jar and still attempt to overwrite, adding to it. I think I'm going to start a fresh project and just move the source scripts. See if that helps.

EDIT: Solved!

Needed to further reduce the scope of the source directory. It was one level higher than it should have been and so it was still wrapping in the jar and way more than it should have been  ::) I also realized I could just exclude everything but the source directory for the scripts themselves with tags under project structure - artifacts.

Then I just needed to rebuild the jar to a completely separate directory I isolated on my desktop- for certainty. Then move the new complied (17kb!) jar back to the main mod directory (where the mod plug-in references it)

Mod also loads and runs ~3 times faster  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 11, 2017, 09:34:57 AM
I ran into a bizarre issue with EZ Faction last night that blocked a release. 

In the System Overview UI panel, where we can see the planets, their Conditions etc., and in the Intel Menu's Planet list... the planets I've been building procedurally are showing up twice.   Same names, same everything, but there are two of them.

You can click on either without any errors, but when you go to the Map View, there's only one planet, and there's only one Planet if you visit the System (and it's interacting with things just fine, with no crashes or odd behavior).

It's really weird and it's a new issue; I'll probably pull a diff with the older versions and see what's up but I was wondering what the heck I should go hunting for; most of the changes made this time for the original EZ Faction colony planets were, I thought, superficial; I mainly just changed how the planets' orbits got assigned. 

I also tried to write some code to check and see if they were duplicate Markets or something odd like that, but no luck thus far.  I haven't tried to see if I actually have two PlanetAPI's that are identical in place and name; this seems rather unlikely, given how my code works, but I haven't tried that yet.

So... how does that code pull up the Planet list for the System?  Any hints as to what it's evaluating would be appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 11, 2017, 10:02:16 AM
My guess is you've got two copies of the same star system - that'd be tough to spot (the jump-points may look a bit brighter) - but aside from that it would appear normal. I don't see how it could get multiple copies of the same planet in that list otherwise, it just goes through all the star systems and all their planets to create the list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 11, 2017, 01:50:11 PM
Whoa, that'd be weird... because I don't think I'm creating any star systems; that's kind of the point of how EZ Faction works.  

Perhaps an odd copy happens somewhere.  I'll look into this a little further; there's one weird theory I haven't tested just yet.

Well, that didn't pan out.  I suppose now I need to write something that looks for Systems that got copied somehow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on September 12, 2017, 04:38:44 AM
Whoa, that'd be weird... because I don't think I'm creating any star systems; that's kind of the point of how EZ Faction works.  

Perhaps an odd copy happens somewhere.  I'll look into this a little further; there's one weird theory I haven't tested just yet.

Well, that didn't pan out.  I suppose now I need to write something that looks for Systems that got copied somehow.

If it helps, your error isn't all that new: running the old 0.3 version of EzFaction triggers the same error on the Crystanite (have yet to test other factions with the old one)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 12, 2017, 08:30:15 AM
Yeah, it's really weird, and I didn't notice, unfortunately.  I'm looking at Alex's code for ProcGen to see if I can puzzle out what's happening there.  I'm definitely not making any new Systems; I've ruled out copies of the PlanetAPI or MarketAPI as best as I can. 

I spent some time being stumped by this last night; since I can't see the UI code, I simply don't know what it's looking for there that causes it to find a "duplicate".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 12, 2017, 11:24:56 AM
Possible that you're adding the market to the economy several times? Not sure that'd do it, but it just might.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 12, 2017, 11:56:09 AM
Project Properties (right-click on the project in Projects window, or use the File menu) -> Sources -> Set Source/Binary Format to JDK 7

Just FYI - I did get a IDE, followed all the advice here and the .jar still won't compile properly or something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 13, 2017, 08:34:41 AM
I'm still trying to find MarketAPI copies and kill them; that's the best theory I've got.  I'll take another look at this issue tonight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 13, 2017, 08:38:49 AM
I'm still trying to find MarketAPI copies and kill them; that's the best theory I've got.  I'll take another look at this issue tonight.

Are you sure it's just not some faction that causing this? I know some add their own systems. Or did you only test it with Explorers Society?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 13, 2017, 08:57:09 AM
I have four Factions that all are using EZ Faction doing stuff in my tests here; one's Explorer Society, one's Pirates (the Pirate-station feature request) and a couple of others that aren't public yet.  I'm fairly certain that the issue's related to how the Markets are getting set up, but I'm still not entirely certain how copies could be present, nor am I totally certain I've found any copies; I just built some code to attempt to kill copies but it was late and I was tired when I did; I'm sure it wasn't adequate and when I figure this out, it'll be "really obvious", lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 13, 2017, 11:19:50 AM
Hmm.  Still seeing things here that lead me to believe there's some weird issues with this.  It's almost like the MarketAPI's getting "attached" to the PlanetAPI twice, which doesn't look possible; SectorEntityToken getMarket() doesn't return multiple MarketAPIs.

What's really strange is... this bug doesn't happen with the Stations.  Just the PlanetAPIs.

I've ruled out multiple copies of the PlanetAPI; I'm not building new Systems.  

Alex, what we're seeing here looks like this, btw:

(http://www.wolfegames.com/TA_Section/ez_faction_odd_bug001.png)
(http://www.wolfegames.com/TA_Section/ez_faction_odd_bug002.png)

So... here's the code that builds the planets right now:

Spoiler
Code: java
private static SectorEntityToken buildEntity(StarSystemAPI pickedSystem, FactionAPI faction, int minMarketSize, int maxMarketSize, boolean isCapital){
int marketSize = MathUtils.getRandomNumberInRange(minMarketSize, maxMarketSize);
if(isCapital) marketSize = maxMarketSize;
if(pickedSystem == null) return null;

if(faction == null) return null;
if(pickedSystem.getStar() == null) return null;
if(pickedSystem.getStar().getName() == null) return null;
if(faction.getId() == null) return null;
if(pickedSystem.isHyperspace() || pickedSystem.isNebula()) return null;
SectorEntityToken ezColony;
try{
String starName = pickedSystem.getStar().getName();
String factionID = faction.getId();
String denomination = pickDenomination(pickedSystem,faction,false,true);
ezColony = pickedSystem.addPlanet(starName + factionID + "planet" + denomination,//Attempts to build a random numbered location id; needs improving
pickedSystem.getStar(), starName+" "+ denomination,//Probably needs improving
planetType(faction),//Pulls a string at random
MathUtils.getRandomNumberInRange(30f,60f),//Angle
MathUtils.getRandomNumberInRange(50f,300f),//Radius
MathUtils.getRandomNumberInRange(4000f,8000f),//Orbital radius
MathUtils.getRandomNumberInRange(100f,300f));//Orbital period
ezColony.addTag("customColony");
}catch (Throwable ex) {
return null;
}


ezColony.setFaction(faction.getId());
ezColony.setInteractionImage("illustrations", ILLUSTRATIONS.get((int)MathUtils.getRandomNumberInRange(0, ILLUSTRATIONS.size()-1)));
ezColony.addTag(Tags.STATION);
MarketAPI market = Global.getFactory().createMarket(faction.getId() + ezColony.getId() +"_market"+MathUtils.getRandom(), ezColony.getName(), 0);
ezColony.setMarket(market);
market.setPlanetConditionMarketOnly(false);
market.addCondition(Conditions.SPACEPORT);
market.addCondition(Conditions.OUTPOST);

market.setFactionId(faction.getId());

market.setSurveyLevel(SurveyLevel.FULL);
market.setPrimaryEntity(ezColony);

//Set up all of the Market Conditions here
if(isCapital == true || MathUtils.getRandomNumberInRange(0f, 100f) > 66f) market.addCondition(Conditions.MILITARY_BASE);
setMarketConditions(market, marketSize, ezColony, false);

//Set the market's size and population here
market.setSize(marketSize);
assignPopulation(market,marketSize);

market.addSubmarket(Submarkets.SUBMARKET_OPEN);
if(market.hasCondition(Conditions.MILITARY_BASE)){
market.addSubmarket(Submarkets.GENERIC_MILITARY);
}
market.addSubmarket(Submarkets.SUBMARKET_BLACK);
market.addSubmarket(Submarkets.SUBMARKET_STORAGE);

market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCommodity(Commodities.FOOD, 1000);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCommodity(Commodities.LUXURY_GOODS, 100);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCommodity(Commodities.ORGANICS, 3000);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCommodity(Commodities.VOLATILES, 3000);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCommodity(Commodities.HEAVY_MACHINERY, 1000);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCommodity(Commodities.METALS, 1000);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCommodity(Commodities.RARE_METALS, 1000);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addCrew(300);
market.getSubmarket(Submarkets.SUBMARKET_OPEN).getCargo().addFuel(5000);

Global.getSector().getEconomy().addMarket(market);

buildCommRelayIfNeeded(pickedSystem,faction);

Logger log = Global.getLogger(CoreScript.class);
log.info("Created EZ Faction Colony " + ezColony.getName() + " for Faction " + faction.getDisplayName() + " at System " +pickedSystem.getBaseName());

return ezColony;
}
[close]

IDK what's doing this; all I know thus far is that Global.GetSector().GetEconomy().addMarket() is really sensitive to the order of operations; all Conditions and SubMarkets appear to need to be defined first.  I really am pretty stumped by this one; nothing's technically "broken" in an obvious way; the NPE issue reported in the last build of EZ Faction was unrelated.  

It's just presented incorrectly in the game UI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2017, 12:58:23 PM
Weird. Nothing jumps out right off, but that's not *all* of the code, so it's hard to say.

Code: java
for (PlanetAPI planet : system.getPlanets()) {
MarketAPI market = planet.getMarket();
if (market == null || market.getSurveyLevel() != SurveyLevel.NONE) {
planets.add(planet);
}
}
planets.addAll(getStandaloneStations(system));

This is how it picks what entities to display on that screen, btw. One case I can see is if a market has a station and it's the "primary" entity for the market instead of the planet being the primary entity - then it would show up twice, but I'd expect both planet and station to show up then rather than two planets, so never mind.

Edit: I would suggest the time-honored practice of commenting stuff out gradually until the problem goes away.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 13, 2017, 01:51:47 PM
Ahh.... betcha it's:

ezColony.addTag(Tags.STATION);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 13, 2017, 01:56:12 PM
Yup, that was it.  IIRC, I had that in there because I think I saw it in code calling up the Dialog.  The UI bug's resolved by removing that; now I need to make sure the Dialog still works. 

<tests>

Yup.  OK, I'll test for any other weirdness and I can fiiiiiinally release.  Sorry Alex, this was just hard to pin down without clues as to what the UI was evaluating there!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2017, 03:48:09 PM
Nice, glad you got it sorted out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 15, 2017, 05:10:32 AM
Why does allowing a delegated fleet interaction dialog plugin to pull in nearby enemy fleets cause the "main" fleet to disappear here?

Spoiler
No pull in:
(https://i.imgur.com/AOfz7PI.jpg)

(the fleet interaction is in a rules dialog delegate, derived from derelict defenders)

Pull in:
(https://i.imgur.com/bNol7Bn.jpg)

Even calling BattleAPI.join(dialogInteractionTarget_fleet) doesn't make the original fleet participate.

The fleet interaction rule command:
Spoiler
Code: java
package com.fs.starfarer.api.impl.campaign.rulecmd;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.InteractionDialogPlugin;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.campaign.rules.MemKeys;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.combat.BattleCreationContext;
import com.fs.starfarer.api.impl.campaign.FleetEncounterContext;
import com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl;
import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageGenFromSeed;
import com.fs.starfarer.api.util.Misc;
import exerelin.campaign.NexFleetInteractionDialogPluginImpl;
import exerelin.campaign.fleets.ResponseFleetManager;
import exerelin.utilities.ExerelinUtilsFleet;
import java.util.List;
import java.util.Map;

// based on SalvageDefenderInteraction
public class Nex_InvasionDefenseInteraction extends BaseCommandPlugin {

public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, final Map<String, MemoryAPI> memoryMap) {
if (dialog == null) return false;

boolean isRaid = params.get(0).getBoolean(memoryMap);
final SectorEntityToken entity = dialog.getInteractionTarget();
final MarketAPI market = entity.getMarket();
final MemoryAPI memory = memoryMap.get(MemKeys.MARKET);
final String defenderMemFlag = isRaid ? "$nex_raidResponseFleet" : "$nex_invasionResponseFleet";

final CampaignFleetAPI defenders = memory.getFleet(defenderMemFlag);
if (defenders == null) return false;

dialog.setInteractionTarget(defenders);
defenders.setLocation(entity.getLocation().x, entity.getLocation().y);

final FleetInteractionDialogPluginImpl.FIDConfig config = new FleetInteractionDialogPluginImpl.FIDConfig();
config.leaveAlwaysAvailable = true;
config.showFleetAttitude = false;
config.showTransponderStatus = false;
config.showWarningDialogWhenNotHostile = false;
config.alwaysAttackVsAttack = true;
//config.pullInEnemies = false; // DEBUG
//config.pullInAllies = false;

//config.firstTimeEngageOptionText = "Engage the response fleet";
//config.afterFirstTimeEngageOptionText = "Re-engage the response fleet";

config.dismissOnLeave = false;
config.printXPToDialog = true;

//long seed = memory.getLong(MemFlags.SALVAGE_SEED);
//config.salvageRandom = Misc.getRandom(seed, 75);

final NexFleetInteractionDialogPluginImpl plugin = new NexFleetInteractionDialogPluginImpl(config);

final InteractionDialogPlugin originalPlugin = dialog.getPlugin();
config.delegate = new FleetInteractionDialogPluginImpl.BaseFIDDelegate() {
@Override
public void notifyLeave(InteractionDialogAPI dialog) {

dialog.setPlugin(originalPlugin);
dialog.setInteractionTarget(entity);

//Global.getSector().getCampaignUI().clearMessages();

if (plugin.getContext() instanceof FleetEncounterContext) {
FleetEncounterContext context = (FleetEncounterContext) plugin.getContext();
if (context.didPlayerWinEncounter()) {

SalvageGenFromSeed.SDMParams p = new SalvageGenFromSeed.SDMParams();
p.entity = entity;
p.factionId = defenders.getFaction().getId();

SalvageGenFromSeed.SalvageDefenderModificationPlugin plugin = Global.getSector().getGenericPlugins().pickPlugin(
SalvageGenFromSeed.SalvageDefenderModificationPlugin.class, p);
if (plugin != null) {
plugin.reportDefeated(p, entity, defenders);
}

memory.unset("$hasDefenders");
memory.unset(defenderMemFlag);
memory.set("$defenderFleetDefeated", true, 0.5f);
FireBest.fire(null, dialog, memoryMap, "BeatDefendersContinue");
} else {
defenders.setContainingLocation(entity.getContainingLocation());
defenders.setLocation(entity.getLocation().x, entity.getLocation().y);

ResponseFleetManager.getManager().registerResponseFleetAndSetAI(defenders, market,
Global.getSector().getPlayerFleet());

memory.unset(defenderMemFlag);
dialog.dismiss();
}
// deduct response fleet points now that fleet has spawned and is permanent (or dead)
float pointsToDeduct = ExerelinUtilsFleet.getFleetGenPoints(defenders);
Global.getLogger(this.getClass()).info("Removing " + pointsToDeduct + " reserve points from " + market.getName());
ResponseFleetManager.modifyReserveSize(market, pointsToDeduct);
// TODO: figure out what to do with stations

} else {
dialog.dismiss();
}
}
@Override
public void battleContextCreated(InteractionDialogAPI dialog, BattleCreationContext bcc) {
bcc.aiRetreatAllowed = false;
//bcc.objectivesAllowed = false;
bcc.enemyDeployAll = true;
}
};


dialog.setPlugin(plugin);
plugin.init(dialog);

return true;
}
}
[close]
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 15, 2017, 08:29:38 AM
How to get the ship's origin hull id with d-mod?
If I want to get the hull id without d-mod, should that be it:
member.getHullSpec().isDHull() ? member.getHullSpec().getDParentHullId() : member.getHullSpec().getBaseHullId()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2017, 09:56:33 AM
For d-hulls, use getDParentHullId(). getBaseHullId() is for skins, to get the parent hull of the skin.


@Histidine:
Hmm, not sure why that would be. Could you take a look at FleetInteractionDialogPluginImpl.pullInNearbyFleets()? That might point to why the fleet is being skipped over.

If you're going to add stuff to the battle manually via .join(), I think you also need to make a few more calls, e.g. at least
b.genCombined();
and
b.takeSnapshots();

Also, depending on where in the code you do that, there may be a disparity between the combined fleet that's displayed and the actual combined fleet.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 16, 2017, 12:08:24 AM
It seems as if BattleAPI.genCombined() or BattleAPI.takeSnapshots() "loses" the main enemy fleet, presumably because it's not in the same containingLocation as the other participants (see screenshot).

I worked around the issue by adding the defender fleet to the star system prior to creating the encounter dialog, and removing it afterwards.

Spoiler
(http://i.imgur.com/h05ZawE.jpg) (https://imgur.com/h05ZawE)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 16, 2017, 04:05:00 AM
sup.
wheree can i see how EMP ability works, script wise? as in how it picks random target in range and such.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on September 16, 2017, 02:13:59 PM
sup.
wheree can i see how EMP ability works, script wise? as in how it picks random target in range and such.

Assuming this gets an answer, I'd like to know too?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 20, 2017, 12:12:29 AM
Getting an error when overwriting the campaign tutorial.

Heres the error:
Spoiler
266221 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException: com.fs.starfarer.api.impl.campaign.tutorial.TutorialMissionEvent cannot be cast to archeus.campaign.tutorial.ArcheusTutorialMissionEvent
java.lang.ClassCastException: com.fs.starfarer.api.impl.campaign.tutorial.TutorialMissionEvent cannot be cast to archeus.campaign.tutorial.ArcheusTutorialMissionEvent
   at archeus.campaign.tutorial.ArcheusCampaignTutorialScript.startTutorialMissionEve nt(ArcheusCampaignTutorialScript.java:431)
   at archeus.campaign.tutorial.ArcheusCampaignTutorialScript.advance(ArcheusCampaignTutorialScript.java:284)
   at com.fs.starfarer.campaign.BaseLocation.advanceEvenIfPaused(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

And here's the lines of code its referencing in ArcheusCampaignTutorialScript.java:

Spoiler
   protected void startTutorialMissionEvent() {
      CampaignEventManagerAPI eventManager = Global.getSector().getEventManager();
      CampaignEventTarget target = new CampaignEventTarget(ancyra);
      target.setExtra(Misc.genUID());
      
      event = (ArcheusTutorialMissionEvent) eventManager.primeEvent(target, Events.TUTORIAL_MISSION, this);
      eventManager.startEvent(event);
   }
[close]

I know this isn't much detail yet, but its late. What I'm curious about for the moment is whether its the script itself or the event script that its trying to start that contains the issue.

Is it still trying to call the original TutorialMissionEvent script somewhere I'm missing or is that not it?

EDIT: Hm. Looking at is closer I'm pretty sure its just that I've overwritten the event variable but not every script in the tutorial package that assigns something to it.

EDIT2: Ok, so I don't see anywhere that the event variable is referenced other than in the tutorial script.  ??? Is it something behind the scenes with EventManagerAPI? I defined the variable as a "ArcheusTutorialMissionEvent" here:

Spoiler
   protected ArcheusTutorialMissionEvent event;
[close]

So it should never be attempting to cast it to a regular "TutorialMissionEvent" variable in the first place.  >:(

Any clue where it is attempting to do this?

The full script:

Spoiler
package archeus.campaign.tutorial;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CampaignTerrainAPI;
import com.fs.starfarer.api.campaign.CoreUITabId;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.events.CampaignEventManagerAPI;
import com.fs.starfarer.api.campaign.events.CampaignEventTarget;
import com.fs.starfarer.api.characters.AbilityPlugin;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.DModManager;
import com.fs.starfarer.api.impl.campaign.fleets.FleetFactory;
import com.fs.starfarer.api.impl.campaign.ids.Abilities;
import com.fs.starfarer.api.impl.campaign.ids.Events;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
import com.fs.starfarer.api.impl.campaign.ids.HullMods;
import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.TransmitterTrapSpeci al;
import com.fs.starfarer.api.ui.HintPanelAPI;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialWelcomeDialogPluginImpl;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialLayInCourseDialogPluginImpl;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialTransponderDialogPluginImpl;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialSustainedBurnDialogPluginIm pl;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialPirateApproachesDialogPlugi nImpl;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialLevelUpDialogPluginImpl;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialLeashAssignmentAI;
import archeus.campaign.tutorial.ArcheusRogueMinerMiscFleetManager;

public class ArcheusCampaignTutorialScript implements EveryFrameScript {

   public static final String USE_TUTORIAL_RESPAWN = "$tutorialRespawn";
   
   public static enum CampaignTutorialStage {
      SHOW_WELCOME_DIALOG,
      SHOW_DEBRIS_HINT,
      HEADING_TO_DEBRIS,
      REACHED_DEBRIS,
      SAVE_NAG_1,
      SHOW_PIRATE_DIALOG,
      SHOW_PIRATE_HINT,
      PIRATE_APPROACHES,
      SAVE_NAG_2,
      SHOW_LEVELUP_DIALOG,
      SHOW_LEVELUP_HINT,
      WAIT_CHAR_TAB,
      SHOW_LAY_IN_COURSE_DIALOG,
      SHOW_LAY_IN_COURSE_HINT,
      WAITING_TO_LAY_IN_COURSE,
      SHOW_SUSTAINED_BURN_DIALOG,
      SHOW_SUSTAINED_BURN_HINT,
      WAIT_SUSTAINED_BURN_USE,
      SHOW_TRANSPONDER_DIALOG,
      SHOW_TRANSPONDER_HINT,
      WAIT_TRANSPONDER_USE,
      DONE,
      
      WAITING_TO_QUICKSAVE,
   }
   
   
   protected boolean askedPlayerToSave = false;
   protected boolean playerSaved = false;
   protected float elapsed = 0f;
   protected float lastCheckDistToAncyra = -1f;
   
   protected StarSystemAPI system;
   protected PlanetAPI ancyra;
   protected SectorEntityToken derinkuyu;
   protected CampaignTutorialStage stage = CampaignTutorialStage.SHOW_WELCOME_DIALOG;
   
   protected boolean orbitalResetDone = false;
   
   protected CampaignTerrainAPI debrisField;
   protected CampaignFleetAPI pirateFleet;
   protected CampaignFleetAPI detachment;
   protected ArcheusTutorialMissionEvent event;
   
   public ArcheusCampaignTutorialScript(StarSystemAPI system) {
      this.system = system;
      debrisField = (CampaignTerrainAPI) system.getEntityById("debris_tutorial");
      ancyra = (PlanetAPI) system.getEntityById("ancyra");
      derinkuyu = system.getEntityById("derinkuyu_station");
      
      Global.getSector().getMemoryWithoutUpdate().set(USE_TUTORIAL_RESPAWN, true);
   }

   protected Object readResolve() {
      return this;
   }
   
   protected Object writeReplace() {
      if (askedPlayerToSave) {
         playerSaved = true;
         HintPanelAPI hints = Global.getSector().getCampaignUI().getHintPanel();
         if (hints != null) {
            hints.clearHints(false);
         }
      }
      return this;
   }
   
   protected CampaignTutorialStage quickSaveFrom = null;
   protected boolean quickSaveNag(CampaignTutorialStage nagStage, CampaignTutorialStage next, float timeout) {
      HintPanelAPI hints = Global.getSector().getCampaignUI().getHintPanel();
      
      if (stage == nagStage) {
         quickSaveFrom = nagStage;
         hints.clearHints();
         
         String control = Global.getSettings().getControlStringForEnumName("QUICK_SAVE");
         if (timeout > 0) {
            hints.setHint(0, "- Press %s to quick-save, if you like", true, Misc.getHighlightColor(), control);
         } else {
            hints.setHint(0, "- Press %s to quick-save and advance the tutorial", true, Misc.getHighlightColor(), control);
         }
         
         stage = CampaignTutorialStage.WAITING_TO_QUICKSAVE;
         elapsed = 0f;
         askedPlayerToSave = true;
         playerSaved = false;
         
         return true;
      }
      
      if (quickSaveFrom == nagStage && stage == CampaignTutorialStage.WAITING_TO_QUICKSAVE &&
            (playerSaved || (timeout > 0 && elapsed > timeout))) {
         hints.clearHints();
         stage = next;
         elapsed = 0f;
         playerSaved = false;
         askedPlayerToSave = false;
         quickSaveFrom = null;
         return true;
      }
      
      return false;
   }
   
   protected boolean charTabWasOpen = false;
   public void advance(float amount) {
      if (amount == 0) return;
      
      if (Global.getSector().isInFastAdvance()) return;
      
      CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
      if (playerFleet == null) return;
      
      HintPanelAPI hints = Global.getSector().getCampaignUI().getHintPanel();
      if (hints == null) return;
      
      //playerFleet.addAbility(Abilities.SENSOR_BURST);
      
      if (lastCheckDistToAncyra < 0) {
         lastCheckDistToAncyra = Misc.getDistance(playerFleet.getLocation(), ancyra.getLocation());
      }
      
      if (!orbitalResetDone) {
         system.getEntityById("ancyra").setCircularOrbitAngle(55f);
         system.getEntityById("ancyra_relay").setCircularOrbitAngle(55 - 60);;
         
         system.getEntityById("pontus").setCircularOrbitAngle(230);
         system.getEntityById("pontus_L4").setCircularOrbitAngle(230 + 60);
         system.getEntityById("pontus_L5").setCircularOrbitAngle(230 - 60);
         system.getEntityById("galatia_probe").setCircularOrbitAngle(230);
         system.getEntityById("galatia_jump_point_alpha").setCircularOrbitAngle(230 + 180f);
         
         system.getEntityById("tetra").setCircularOrbitAngle(340);
         system.getEntityById("derinkuyu_station").setCircularOrbitAngle(135);
         system.getEntityById("galatia_jump_point_fringe").setCircularOrbitAngle(160);;
         
         orbitalResetDone = true;
      }

      
      elapsed += amount;
      
      if (stage == CampaignTutorialStage.SHOW_WELCOME_DIALOG && elapsed > 1f) {
         if (Global.getSector().getCampaignUI().showInteractionDialog(new TutorialWelcomeDialogPluginImpl(), null)) {
            addFleets();
            stage = CampaignTutorialStage.SHOW_DEBRIS_HINT;
         }
         return;
      }
      
      if (stage == CampaignTutorialStage.SHOW_DEBRIS_HINT) {
         String control = Global.getSettings().getControlStringForAbilitySlot(5);
         hints.setHint(1, "- Move up into the debris field");
         hints.setHint(0, "- Press %s to start scavenging", false, Misc.getHighlightColor(), control);
         hints.makeDim(0);
         stage = CampaignTutorialStage.HEADING_TO_DEBRIS;
         return;
      }
      
      if (stage == CampaignTutorialStage.HEADING_TO_DEBRIS) {
         if (debrisField.getPlugin().containsEntity(playerFleet)) {
            stage = CampaignTutorialStage.REACHED_DEBRIS;
            hints.fadeOutHint(1);
            //hints.makeNormal(0);
            String control = Global.getSettings().getControlStringForAbilitySlot(5);
            hints.setHint(0, "- Press %s to start scavenging", true, Misc.getHighlightColor(), control);
         }
         return;
      }
      
      if (stage == CampaignTutorialStage.REACHED_DEBRIS) {
         AbilityPlugin scavenge = playerFleet.getAbility(Abilities.SCAVENGE);
         if (scavenge != null && scavenge.isOnCooldown()) {
            stage = CampaignTutorialStage.SAVE_NAG_1;
         }
         return;
      }
      
      if (quickSaveNag(CampaignTutorialStage.SAVE_NAG_1, CampaignTutorialStage.SHOW_PIRATE_DIALOG, 0)) {
         return;
      }

      if (stage == CampaignTutorialStage.SHOW_PIRATE_DIALOG && elapsed >= 1f) {
         if (Global.getSector().getCampaignUI().showInteractionDialog(new TutorialPirateApproachesDialogPluginImpl(), null)) {
            stage = CampaignTutorialStage.SHOW_PIRATE_HINT;
         }
         return;
      }
      
      if (stage == CampaignTutorialStage.SHOW_PIRATE_HINT) {
         addPirateFleet();
         
         hints.setHint(0, "- Wait for the pirates to approach, then engage and defeat them!");
         stage = CampaignTutorialStage.PIRATE_APPROACHES;
         return;
      }
      
      if (stage == CampaignTutorialStage.PIRATE_APPROACHES) {
         if (pirateFleet == null || !pirateFleet.isAlive()) {
            hints.clearHints();
            stage = CampaignTutorialStage.SAVE_NAG_2;
            elapsed = 0f;
            
            long xp = Global.getSector().getPlayerPerson().getStats().getXP();
            long add = Global.getSettings().getLevelupPlugin().getXPForLevel(2) - xp;
            Global.getSector().getPlayerPerson().getStats().addPoints(3);
            Global.getSector().getPlayerPerson().getStats().addXP(add);
         }
         return;
      }
      
      if (quickSaveNag(CampaignTutorialStage.SAVE_NAG_2, CampaignTutorialStage.SHOW_LEVELUP_DIALOG, 0)) {
         return;
      }
      
      if (stage == CampaignTutorialStage.SHOW_LEVELUP_DIALOG && elapsed >= 1f) {
         if (Global.getSector().getCampaignUI().showInteractionDialog(new TutorialLevelUpDialogPluginImpl(), null)) {
            stage = CampaignTutorialStage.SHOW_LEVELUP_HINT;
         }
         return;
      }
      
      if (stage == CampaignTutorialStage.SHOW_LEVELUP_HINT) {
         String character = Global.getSettings().getControlStringForEnumName("CORE_CHARACTER");
         hints.setHint(0, "- Press %s to open the character tab and consider your options", true, Misc.getHighlightColor(), character);
         stage = CampaignTutorialStage.WAIT_CHAR_TAB;
         return;
      }
      
      if (stage == CampaignTutorialStage.WAIT_CHAR_TAB) {
         CoreUITabId tab = Global.getSector().getCampaignUI().getCurrentCoreTab();
         if (tab == CoreUITabId.CHARACTER) {
            charTabWasOpen = true;
         }
         if (charTabWasOpen && !Global.getSector().getCampaignUI().isShowingDialog()) {
            stage = CampaignTutorialStage.SHOW_LAY_IN_COURSE_DIALOG;
            elapsed = 0f;
            hints.clearHints();
         }
      }

      if (stage == CampaignTutorialStage.SHOW_LAY_IN_COURSE_DIALOG && elapsed >= 1f) {
         startTutorialMissionEvent();
         if (Global.getSector().getCampaignUI().showInteractionDialog(
               new TutorialLayInCourseDialogPluginImpl(ancyra.getMarket(), event.getMainContact()), null)) {
            stage = CampaignTutorialStage.SHOW_LAY_IN_COURSE_HINT;
         }
         return;
      }
      
      
      if (stage == CampaignTutorialStage.SHOW_LAY_IN_COURSE_HINT) {
         String intel = Global.getSettings().getControlStringForEnumName("CORE_INTEL");
         String map = Global.getSettings().getControlStringForEnumName("CORE_MAP");
         
         hints.setHint(1, "- Press %s to open the intel tab, then click on the display that reads IN-SYSTEM", false, Misc.getHighlightColor(), intel);
         hints.setHint(0, "- Click on " + ancyra.getName() + " and select " +
               "%s, then press %s to close the map", false, Misc.getHighlightColor(), "\"Lay in Course\"", map);
         stage = CampaignTutorialStage.WAITING_TO_LAY_IN_COURSE;
         
//         hints.setHint(1, "- Press %s to open the map", Misc.getHighlightColor(), map);
//         hints.setHint(0, "- Find " + ancyra.getName() + ", left-click on it and select " +
//               "\"Lay in Course\", then close the map", Misc.getHighlightColor(), "\"Lay in Course\"");
//         stage = CampaignTutorialStage.WAITING_TO_LAY_IN_COURSE;
         return;
      }
      
      if (stage == CampaignTutorialStage.WAITING_TO_LAY_IN_COURSE) {
         float dist = Misc.getDistance(playerFleet.getLocation(), ancyra.getLocation());
         boolean closedIn = dist < lastCheckDistToAncyra * 0.75f;
         if (closedIn || (playerFleet.getInteractionTarget() != null &&
               playerFleet.getInteractionTarget().getMarket() == ancyra.getMarket())) {
            lastCheckDistToAncyra = dist;
            hints.clearHints();
            stage = CampaignTutorialStage.SHOW_SUSTAINED_BURN_DIALOG;
            elapsed = 0;
         }
         return;
      }
      
      
      if (stage == CampaignTutorialStage.SHOW_SUSTAINED_BURN_DIALOG && elapsed > 10f) {
         if (Global.getSector().getCampaignUI().showInteractionDialog(new TutorialSustainedBurnDialogPluginImpl(ancyra.getMarket()), null)) {
            stage = CampaignTutorialStage.SHOW_SUSTAINED_BURN_HINT;
         }
         return;
      }
      
      if (stage == CampaignTutorialStage.SHOW_SUSTAINED_BURN_HINT) {
         String control = Global.getSettings().getControlStringForAbilitySlot(4);
         hints.setHint(0, "- Press %s to engage sustained burn", true, Misc.getHighlightColor(), control);
         stage = CampaignTutorialStage.WAIT_SUSTAINED_BURN_USE;
         elapsed = 0;
         return;
      }
      
      if (stage == CampaignTutorialStage.WAIT_SUSTAINED_BURN_USE) {
         AbilityPlugin sb = playerFleet.getAbility(Abilities.SUSTAINED_BURN);
         float dist = Misc.getDistance(playerFleet.getLocation(), ancyra.getLocation());
         boolean closedIn = dist < lastCheckDistToAncyra * 0.75f;
         if ((sb != null && sb.isActive() && elapsed > 5f) || closedIn) {
            lastCheckDistToAncyra = dist;
            hints.clearHints();
            stage = CampaignTutorialStage.SHOW_TRANSPONDER_DIALOG;
            elapsed = 0f;
         }
         return;
      }
      
      
      if (stage == CampaignTutorialStage.SHOW_TRANSPONDER_DIALOG) {
         float dist = Misc.getDistance(playerFleet.getLocation(), ancyra.getLocation());
         if (dist < 6000) {
            if (Global.getSector().getCampaignUI().showInteractionDialog(new TutorialTransponderDialogPluginImpl(ancyra.getMarket()), null)) {
               stage = CampaignTutorialStage.SHOW_TRANSPONDER_HINT;
            }
         }
         return;
      }
      
      if (stage == CampaignTutorialStage.SHOW_TRANSPONDER_HINT) {
         String control = Global.getSettings().getControlStringForAbilitySlot(0);
         hints.setHint(0, "- Press %s twice to turn on the transponder", true, Misc.getHighlightColor(), control);
         stage = CampaignTutorialStage.WAIT_TRANSPONDER_USE;
         elapsed = 0;
         return;
      }
      
      if (stage == CampaignTutorialStage.WAIT_TRANSPONDER_USE) {
         AbilityPlugin transponder = playerFleet.getAbility(Abilities.TRANSPONDER);
         if ((transponder != null && transponder.isActive())) {
            hints.clearHints();
            stage = CampaignTutorialStage.DONE;
            elapsed = 0f;
         }
         return;
      }
   }
   
   
   protected void addFleets() {
      addSecurityDetachment();
      
      SectorEntityToken inner = system.getEntityById("galatia_jump_point_alpha");
      SectorEntityToken fringe = system.getEntityById("galatia_jump_point_fringe");
      SectorEntityToken derinkuyu = system.getEntityById("derinkuyu_station");
      
      CampaignFleetAPI g1 = ArcheusRogueMinerMiscFleetManager.createGuardFleet(false);
      g1.addScript(new TutorialLeashAssignmentAI(g1, system, derinkuyu));
      system.addEntity(g1);
      g1.setLocation(derinkuyu.getLocation().x, derinkuyu.getLocation().y);
      
      CampaignFleetAPI g2 = ArcheusRogueMinerMiscFleetManager.createGuardFleet(Misc.isEasy());
      
      if (!Misc.isEasy()) {
         FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "venture_d_pirates_Combat");
         member.setVariant(member.getVariant().clone(), false, false);
         g2.getFleetData().addFleetMember(member);
      }
      
      g2.getFleetData().sort();
      g2.addScript(new TutorialLeashAssignmentAI(g2, system, inner));
      system.addEntity(g2);
      g2.setLocation(inner.getLocation().x, inner.getLocation().y);
      
      CampaignFleetAPI g3 = ArcheusRogueMinerMiscFleetManager.createGuardFleet(true);
      g3.addScript(new TutorialLeashAssignmentAI(g3, system, inner));
      system.addEntity(g3);
      g3.setLocation(inner.getLocation().x, inner.getLocation().y);
      
      
      CampaignFleetAPI g4 = ArcheusRogueMinerMiscFleetManager.createGuardFleet(true);
      g4.addScript(new TutorialLeashAssignmentAI(g4, system, fringe));
      system.addEntity(g4);
      g4.setLocation(fringe.getLocation().x, fringe.getLocation().y);
      
      CampaignFleetAPI g5 = ArcheusRogueMinerMiscFleetManager.createGuardFleet(true);
      g5.addScript(new TutorialLeashAssignmentAI(g5, system, fringe));
      system.addEntity(g5);
      g5.setLocation(fringe.getLocation().x, fringe.getLocation().y);
      
   }
   
   
   protected void startTutorialMissionEvent() {
      CampaignEventManagerAPI eventManager = Global.getSector().getEventManager();
      CampaignEventTarget target = new CampaignEventTarget(ancyra);
      target.setExtra(Misc.genUID());
      
      event = (ArcheusTutorialMissionEvent) eventManager.primeEvent(target, Events.TUTORIAL_MISSION, this);
      eventManager.startEvent(event);
   }
   
   protected void addPirateFleet() {
      pirateFleet = ArcheusRogueMinerMiscFleetManager.createEmptyRogueFleet("Rogue Miner", false);
      pirateFleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_NO_SHIP_RECOVERY, true);
      
      FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "cerberus_d_pirates_Standard");
      pirateFleet.getFleetData().addFleetMember(member);
   
      system.addEntity(pirateFleet);
      CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
      pirateFleet.setLocation(playerFleet.getLocation().x + 750f, playerFleet.getLocation().y + 750f);
      
      TransmitterTrapSpecial.makeFleetInterceptPlayer(pirateFleet, true, 100f);
   }
   
   protected void addSecurityDetachment() {
      detachment = FleetFactory.createEmptyFleet(Factions.HEGEMONY, FleetTypes.PATROL_MEDIUM, ancyra.getMarket());
      detachment.setName("Security Detachment");
      detachment.setNoFactionInName(true);
      
      //detachment.getFleetData().addFleetMember("eagle_xiv_Elite");
      detachment.getFleetData().addFleetMember("dominator_XIV_Elite");
      detachment.getFleetData().addFleetMember("mora_Strike");
      detachment.getFleetData().addFleetMember("enforcer_XIV_Elite");
      detachment.getFleetData().addFleetMember("enforcer_XIV_Elite");
      detachment.getFleetData().addFleetMember("brawler_Elite");
      detachment.getFleetData().addFleetMember("wolf_hegemony_Assault");
        detachment.getFleetData().addFleetMember("wolf_hegemony_Assault");
      
      
      detachment.addAbility(Abilities.TRANSPONDER);
      detachment.addAbility(Abilities.GO_DARK);
      detachment.addAbility(Abilities.SENSOR_BURST);
      detachment.addAbility(Abilities.EMERGENCY_BURN);
      
      detachment.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_FLEET, true);
      detachment.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_NO_JUMP, true);
      
      system.addEntity(detachment);
      detachment.setLocation(ancyra.getLocation().x, ancyra.getLocation().y);
      
      detachment.addScript(new TutorialLeashAssignmentAI(detachment, system, ancyra));
      
      detachment.setId("tutorial_security_detachment");
   }
   
   

   public boolean isDone() {
      return stage == CampaignTutorialStage.DONE;
   }

   public boolean runWhilePaused() {
      return stage == CampaignTutorialStage.WAIT_CHAR_TAB;
   }

}

[close]

And the Event script its attempting to call:

Spoiler
package archeus.campaign.tutorial;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.BaseOnMessageDeliveryScript;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.CommDirectoryEntryAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.OnMessageDeliveryScript;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.CommDirectoryEntryAPI.EntryType;
import com.fs.starfarer.api.campaign.comm.CommMessageAPI;
import com.fs.starfarer.api.campaign.comm.MessagePriority;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.campaign.events.CampaignEventManagerAPI;
import com.fs.starfarer.api.campaign.events.CampaignEventTarget;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.JumpPointInteractionDialogPluginImpl;
import com.fs.starfarer.api.impl.campaign.events.BaseEventPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Abilities;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Entities;
import com.fs.starfarer.api.impl.campaign.ids.Events;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
import com.fs.starfarer.api.impl.campaign.ids.Ranks;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
import com.fs.starfarer.api.impl.campaign.submarkets.StoragePlugin;
import com.fs.starfarer.api.loading.WeaponSlotAPI;
import com.fs.starfarer.api.ui.HintPanelAPI;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.Misc.Token;
import com.fs.starfarer.api.impl.campaign.tutorial.TutorialLeashAssignmentAI;
import com.fs.starfarer.api.impl.campaign.tutorial.SaveNagScript;

public class ArcheusTutorialMissionEvent extends BaseEventPlugin {
   
   public static final String TUT_STAGE = "$tutStage";
   
   public static final String REASON = "tut";
   
   public static enum TutorialMissionStage {
      INIT,
      GO_GET_DATA,
      GOT_DATA,
      GO_GET_AI_CORE,
      GOT_AI_CORE,
      GO_RECOVER_SHIPS,
      RECOVERED_SHIPS,
      GO_STABILIZE,
      STABILIZED,
      DELIVER_REPORT,
      DONE,
      ;
   }
   
   protected float elapsedDays = 0;
   protected boolean ended = false;
   
   //protected TutorialMissionEventData data;
   protected StarSystemAPI system;
   protected PlanetAPI ancyra;
   protected PlanetAPI pontus;
   protected PlanetAPI tetra;
   protected SectorEntityToken derinkuyu;
   protected SectorEntityToken probe;
   protected SectorEntityToken inner;
   protected SectorEntityToken fringe;
   protected SectorEntityToken detachment;
   protected SectorEntityToken relay;
   
   protected PersonAPI mainContact;
   protected PersonAPI dataContact;
   protected PersonAPI jangalaContact;
   protected PlanetAPI jangala;
   
   protected TutorialMissionStage stage = TutorialMissionStage.INIT;
    @Override
   public void init(String type, CampaignEventTarget eventTarget) {
      super.init(type, eventTarget, false);
   }
   
   @Override
   public void setParam(Object param) {
      //data = (TutorialMissionEventData) param;
   }
    @Override
   public void startEvent() {
      super.startEvent();
      
      system = Global.getSector().getStarSystem("galatia");
      ancyra = (PlanetAPI) system.getEntityById("ancyra");
      pontus = (PlanetAPI) system.getEntityById("pontus");
      tetra = (PlanetAPI) system.getEntityById("tetra");
      derinkuyu = system.getEntityById("derinkuyu_station");
      probe = system.getEntityById("galatia_probe");
      inner = system.getEntityById("galatia_jump_point_alpha");
      fringe = system.getEntityById("galatia_jump_point_fringe");
      detachment = system.getEntityById("tutorial_security_detachment");
      relay = system.getEntityById("ancyra_relay");
      
//      mainContact = ancyra.getFaction().createRandomPerson();
//      mainContact.setRankId(Ranks.CITIZEN);
//      mainContact.setPostId(Ranks.POST_STATION_COMMANDER);
//      ancyra.getMarket().getCommDirectory().addPerson(mainContact);
      mainContact = createMainContact(ancyra);
      
      dataContact = Global.getSector().getFaction(Factions.INDEPENDENT).createRandomPerson();
      dataContact.setRankId(Ranks.AGENT);
      dataContact.setPostId(Ranks.POST_AGENT);
      derinkuyu.getMarket().getCommDirectory().addPerson(dataContact);
      
      String stageId = "start";
      Global.getSector().reportEventStage(this, stageId, Global.getSector().getPlayerFleet(),
                     MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));

      
      mainContact.getMemoryWithoutUpdate().set("$tut_mainContact", true);
      mainContact.getMemoryWithoutUpdate().set("$tut_eventRef", this);
      Misc.makeImportant(mainContact, REASON);
      
      updateStage(TutorialMissionStage.INIT);
   }
   
   public static PersonAPI createMainContact(PlanetAPI ancyra) {
      PersonAPI mainContact = ancyra.getFaction().createRandomPerson();
      mainContact.setRankId(Ranks.CITIZEN);
      mainContact.setPostId(Ranks.POST_STATION_COMMANDER);
      ancyra.getMarket().getCommDirectory().addPerson(mainContact);
      
      return mainContact;
   }
   
   public static PersonAPI getJangalaContact() {
      StarSystemAPI corvus = Global.getSector().getStarSystem("Corvus");
      PlanetAPI jangala = (PlanetAPI) corvus.getEntityById("jangala");
      
      for (CommDirectoryEntryAPI entry : jangala.getMarket().getCommDirectory().getEntriesCopy()) {
         if (entry.getType() == EntryType.PERSON && entry.getEntryData() instanceof PersonAPI) {
            PersonAPI curr = (PersonAPI) entry.getEntryData();
            if (Ranks.POST_STATION_COMMANDER.equals(curr.getPostId())) {
               return curr;
            }
         }
      }
      return null;
   }
   
   public PersonAPI getMainContact() {
      return mainContact;
   }

   protected void updateStage(TutorialMissionStage stage) {
      this.stage = stage;
      Global.getSector().getMemoryWithoutUpdate().set(TUT_STAGE, stage.name());
   }
   
   protected void endEvent() {
      ended = true;
      Global.getSector().getMemoryWithoutUpdate().unset(TUT_STAGE);
   }
    @Override
   public void advance(float amount) {
      if (!isEventStarted()) return;
      if (isDone()) return;
      
      float days = Global.getSector().getClock().convertToDays(amount);
      
      CampaignFleetAPI player = Global.getSector().getPlayerFleet();
      if (player == null) return;
      
      //memory.advance(days);
      elapsedDays += days;
   
      if (probe == null) probe = system.getEntityById("galatia_probe");
      if (tetra == null) tetra = (PlanetAPI) system.getEntityById("tetra");
      if (derinkuyu == null) derinkuyu = system.getEntityById("derinkuyu_station");
      if (inner == null) inner = system.getEntityById("galatia_jump_point_alpha");
      if (fringe == null) fringe = system.getEntityById("galatia_jump_point_fringe");
      if (detachment == null) detachment = system.getEntityById("tutorial_security_detachment");
      
      if (stage == TutorialMissionStage.GO_GET_AI_CORE) {
         int cores = (int) player.getCargo().getCommodityQuantity(Commodities.GAMMA_CORE);
         float distToProbe = Misc.getDistance(player.getLocation(), probe.getLocation());
         if (cores > 0 && (!probe.isAlive() || distToProbe < 300)) {
            Global.getSector().reportEventStage(this, "salvage_core_end", Global.getSector().getPlayerFleet(),
                  MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
            Misc.makeImportant(mainContact, REASON);
            updateStage(TutorialMissionStage.GOT_AI_CORE);
         }
      }
      
      if (stage == TutorialMissionStage.GO_RECOVER_SHIPS) {
         int count = 0;
         for (FleetMemberAPI member : player.getFleetData().getMembersListCopy()) {
            //if (member.getVariant().getHullSpec().isDHull()) count++;
            count++;
         }
         
         int wrecks = 0;
         for (SectorEntityToken entity : system.getEntitiesWithTag(Tags.SALVAGEABLE)) {
            String id = entity.getCustomEntityType();
            if (id == null) continue;
            if (Entities.WRECK.equals(id)) {
               wrecks ++;
            }
         }
         
         if (count >= 5 || wrecks < 3) {
            Global.getSector().reportEventStage(this, "ship_recovery_end", Global.getSector().getPlayerFleet(),
                     MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
            Misc.makeImportant(mainContact, REASON);
            Misc.makeUnimportant(tetra, REASON);
            updateStage(TutorialMissionStage.RECOVERED_SHIPS);
         }
      }
      
      if (stage == TutorialMissionStage.GO_STABILIZE) {
         boolean innerStable = inner.getMemoryWithoutUpdate().getExpire(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY) > 0;
         boolean fringeStable = fringe.getMemoryWithoutUpdate().getExpire(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY) > 0;
         
         if (innerStable || fringeStable) {
            Global.getSector().reportEventStage(this, "stabilize_jump_point_done", Global.getSector().getPlayerFleet(),
                  MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
            Misc.makeImportant(mainContact, REASON);
            Misc.makeUnimportant(inner, REASON);
            updateStage(TutorialMissionStage.STABILIZED);
         }
         
      }
   
   }
   

   @Override
   public boolean callEvent(String ruleId, final InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
      String action = params.get(0).getString(memoryMap);
      
      CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
      CargoAPI cargo = playerFleet.getCargo();
      
      if (action.equals("startGetData")) {
         Global.getSector().reportEventStage(this, "sneak_start", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(derinkuyu));
         
         dataContact.getMemoryWithoutUpdate().set("$tut_dataContact", true);
         dataContact.getMemoryWithoutUpdate().set("$tut_eventRef", this);
         Misc.makeImportant(dataContact, REASON);
         Misc.makeUnimportant(mainContact, REASON);
         
         detachment.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_ALLOW_TOFF, true);
         
         updateStage(TutorialMissionStage.GO_GET_DATA);
         
         saveNag();
      } else if (action.equals("endGetData")) {
         
         Global.getSector().reportEventStage(this, "sneak_end", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
         Misc.cleanUpMissionMemory(dataContact.getMemoryWithoutUpdate(), "tut_");
         
         Misc.makeUnimportant(dataContact, REASON);
         Misc.makeImportant(mainContact, REASON);
         
         updateStage(TutorialMissionStage.GOT_DATA);
         
      } else if (action.equals("goSalvage")) {
         Global.getSector().reportEventStage(this, "salvage_core_start", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(pontus));
         Misc.makeUnimportant(mainContact, REASON);
         Misc.makeImportant(probe, REASON);
         
         updateStage(TutorialMissionStage.GO_GET_AI_CORE);
         
         saveNag();
      } else if (action.equals("goRecover")) {
         Global.getSector().reportEventStage(this, "ship_recovery_start", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(tetra));
         Misc.makeUnimportant(mainContact, REASON);
         Misc.makeImportant(tetra, REASON);
         
         FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "mudskipper_Standard");
         playerFleet.getFleetData().addFleetMember(member);
         AddRemoveCommodity.addFleetMemberGainText(member, dialog.getTextPanel());
         
         updateStage(TutorialMissionStage.GO_RECOVER_SHIPS);
      } else if (action.equals("goStabilize")) {
         Global.getSector().reportEventStage(this, "stabilize_jump_point", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(inner));
         Misc.makeUnimportant(mainContact, REASON);
         Misc.makeImportant(inner, REASON);

         addWeaponsToStorage();
         
         inner.getMemoryWithoutUpdate().set(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE, true);
         fringe.getMemoryWithoutUpdate().set(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE, true);
         
         updateStage(TutorialMissionStage.GO_STABILIZE);
         
         saveNag();
      } else if (action.equals("pickJangalaContact")) {
         
         StarSystemAPI corvus = Global.getSector().getStarSystem("Corvus");
         jangala = (PlanetAPI) corvus.getEntityById("jangala");
         
         jangalaContact = getJangalaContact();
         
         MemoryAPI mem = mainContact.getMemoryWithoutUpdate();
         mem.set("$jangalaContactPost", jangalaContact.getPost().toLowerCase(), 0);
         mem.set("$jangalaContactLastName", jangalaContact.getName().getLast(), 0);

         float distLY = Misc.getDistanceLY(playerFleet.getLocationInHyperspace(), jangala.getLocationInHyperspace());
         distLY += 4f;

         float fuel = playerFleet.getLogistics().getFuelCostPerLightYear() * distLY;
         fuel = (float) (Math.ceil(fuel / 10) * 10);
         mem.set("$jangalaFuel", (int) fuel);
         
      } else if (action.equals("deliverReport")) {
         Global.getSector().reportEventStage(this, "deliver_message", Global.getSector().getPlayerFleet(),
                           MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(jangala));
         
         Misc.makeUnimportant(mainContact, REASON);
         Misc.cleanUpMissionMemory(mainContact.getMemoryWithoutUpdate(), REASON + "_");
         Misc.makeUnimportant(inner, REASON);
         
         jangalaContact.getMemoryWithoutUpdate().set("$tut_jangalaContact", true);
         jangalaContact.getMemoryWithoutUpdate().set("$tut_eventRef", this);
         Misc.makeImportant(jangalaContact, REASON);
         
         updateStage(TutorialMissionStage.DELIVER_REPORT);
         
         endGalatiaPortionOfMission();
         
         Global.getSector().getMemoryWithoutUpdate().unset(ArcheusCampaignTutorialScript.USE_TUTORIAL_RESPAWN);
         
      } else if (action.equals("reportDelivered")) {
         Global.getSector().reportEventStage(this, "end", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(jangala));
         
         Misc.makeUnimportant(jangalaContact, REASON);
         Misc.cleanUpMissionMemory(jangalaContact.getMemoryWithoutUpdate(), REASON + "_");
         
         updateStage(TutorialMissionStage.DONE);
         
         CampaignEventManagerAPI eventManager = Global.getSector().getEventManager();
         MarketAPI jangala = Global.getSector().getEconomy().getMarket("jangala");
         if (jangala != null) {
            eventManager.startEvent(new CampaignEventTarget(jangala), Events.SYSTEM_BOUNTY, null);
         }
         
         endEvent();
      } else if (action.equals("printRefitHint")) {
         String refit = Global.getSettings().getControlStringForEnumName("CORE_REFIT");
         String autofit = Global.getSettings().getControlStringForEnumName("REFIT_MANAGE_VARIANTS");
         String transponder = "";
         if (!playerFleet.isTransponderOn()) {
            transponder = "\n\nAlso: you'll need to re-dock with your transponder turned on to take advantage of Ancyra's facilities.";
         }
         dialog.getTextPanel().addPara("(Once this conversation is over, press %s to open the refit screen. " +
               "After selecting a specific ship, you can press %s to %s - pick a desired loadout, " +
               "and the ship will be automatically refitted to match it, using what weapons are available." +
               transponder + "",
               Misc.getHighlightColor(), refit, autofit, "\"autofit\"");
         
         dialog.getTextPanel().addPara("In addition, you now have access to local storage at Ancyra, " +
               "and some weapons and supplies have been placed there. To access it, click on the " +
               "\"Storage\" button in the trade screen.)",
               Misc.getHighlightColor(), refit, autofit, "\"Storage\"");
      }
      
      return true;
   }
   
   public static void endGalatiaPortionOfMission() {
   
      StarSystemAPI system = Global.getSector().getStarSystem("galatia");
      PlanetAPI ancyra = (PlanetAPI) system.getEntityById("ancyra");
      PlanetAPI pontus = (PlanetAPI) system.getEntityById("pontus");
      PlanetAPI tetra = (PlanetAPI) system.getEntityById("tetra");
      SectorEntityToken derinkuyu = system.getEntityById("derinkuyu_station");
      SectorEntityToken probe = system.getEntityById("galatia_probe");
      SectorEntityToken inner = system.getEntityById("galatia_jump_point_alpha");
      SectorEntityToken fringe = system.getEntityById("galatia_jump_point_fringe");
      SectorEntityToken relay = system.getEntityById("ancyra_relay");
      
      relay.getMemoryWithoutUpdate().unset(MemFlags.COMM_RELAY_NON_FUNCTIONAL);
      
      Global.getSector().getCharacterData().addAbility(Abilities.TRANSPONDER);
      Global.getSector().getCharacterData().addAbility(Abilities.GO_DARK);
      Global.getSector().getCharacterData().addAbility(Abilities.SENSOR_BURST);
      Global.getSector().getCharacterData().addAbility(Abilities.EMERGENCY_BURN);
      Global.getSector().getCharacterData().addAbility(Abilities.SUSTAINED_BURN);
      Global.getSector().getCharacterData().addAbility(Abilities.SCAVENGE);
      Global.getSector().getCharacterData().addAbility(Abilities.INTERDICTION_PULSE);
      Global.getSector().getCharacterData().addAbility(Abilities.DISTRESS_CALL);
      
      FactionAPI hegemony = Global.getSector().getFaction(Factions.HEGEMONY);
      if (hegemony.getRelToPlayer().getRel() < 0) {
         hegemony.getRelToPlayer().setRel(0);
      }
      
      Global.getSector().getEconomy().addMarket(ancyra.getMarket());
      Global.getSector().getEconomy().addMarket(derinkuyu.getMarket());
      
      HintPanelAPI hints = Global.getSector().getCampaignUI().getHintPanel();
      if (hints != null) {
         hints.clearHints(false);
      }
      
      CampaignEventManagerAPI eventManager = Global.getSector().getEventManager();
      eventManager.startEvent(new CampaignEventTarget(ancyra.getMarket()), Events.SYSTEM_BOUNTY, null);
      
      ArcheusRogueMinerMiscFleetManager script = new ArcheusRogueMinerMiscFleetManager(derinkuyu);
      for (int i = 0; i < 20; i++) {
         script.advance(1f);
      }
      system.addScript(script);
      
      for (CampaignFleetAPI fleet : system.getFleets()) {
         if (Factions.PIRATES.equals(fleet.getFaction().getId())) {
            fleet.removeScriptsOfClass(TutorialLeashAssignmentAI.class);
         }
      }
      
      inner.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY);
      inner.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE);
      
      fringe.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY);
      fringe.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE);
   }
   
   
   
   
   protected void saveNag() {
      if (!Global.getSector().hasScript(SaveNagScript.class)) {
         Global.getSector().addScript(new SaveNagScript(10f));
      }
   }
   
   
   public void addWeaponsToStorage() {
      StoragePlugin plugin = ((StoragePlugin)ancyra.getMarket().getSubmarket(Submarkets.SUBMARKET_STORAGE).getPlugin());
      plugin.setPlayerPaidToUnlock(true);
      
      CargoAPI cargo = plugin.getCargo();
      
      CampaignFleetAPI player = Global.getSector().getPlayerFleet();
      for (FleetMemberAPI member : player.getFleetData().getMembersListCopy()) {
         //if (member.getVariant().getHullSpec().isDHull()) {
            for (WeaponSlotAPI slot : member.getVariant().getHullSpec().getAllWeaponSlotsCopy()) {
               //if (member.getVariant().getWeaponId(slot.getId()) == null) {
                  String weaponId = getWeaponForSlot(slot);
                  if (weaponId != null) {
                     cargo.addWeapons(weaponId, 1);
                  }
               //}
            }
         //}
      }
        cargo.addFighters("talon_wing", 2);
      cargo.addFighters("marauder_wing", 1);
      cargo.addFighters("gauntlet_wing", 1);
      
      cargo.addSupplies(75);
      cargo.sort();
   }
   
   public String getWeaponForSlot(WeaponSlotAPI slot) {
      switch (slot.getWeaponType()) {
      case BALLISTIC:
      case COMPOSITE:
      case HYBRID:
      case UNIVERSAL:
         switch (slot.getSlotSize()) {
         case LARGE: return pick("mark9", "hephag", "hellbore");
         case MEDIUM: return pick("arbalest", "heavymortar", "shredder");
         case SMALL: return pick("lightmg", "lightac", "lightmortar");
         }
         break;
      case MISSILE:
      case SYNERGY:
         switch (slot.getSlotSize()) {
         case LARGE: return pick("hammerrack");
         case MEDIUM: return pick("firestorm", "annihilatorpod", "sabot_single");
         case SMALL: return pick("rapier", "bola", "annihilator");
         }
         break;
      case ENERGY:
         switch (slot.getSlotSize()) {
         case LARGE: return pick("miningblaster");
         case MEDIUM: return pick("mininglaser", "gravitonbeam", "hvyioncannon");
         case SMALL: return pick("pulselaser", "pdlaser", "ioncannon");
         }
         break;
      }
      
   
      return null;
   }
   
   public String pick(String ...strings) {
      return strings[new Random().nextInt(strings.length)];
   }
   
   
   public OnMessageDeliveryScript createSetMessageLocationScript(final SectorEntityToken entity) {
      return new BaseOnMessageDeliveryScript() {
         public void beforeDelivery(CommMessageAPI message) {
            if (entity != null && entity.getContainingLocation() instanceof StarSystemAPI) {
               message.setStarSystemId(entity.getContainingLocation().getId());
            } else {
               message.setStarSystemId(system.getId());
            }
            message.setCenterMapOnEntity(entity);
         }
      };
   }

    @Override
   public Map<String, String> getTokenReplacements() {
      
      Map<String, String> map = super.getTokenReplacements();
      
      addPersonTokens(map, "mainContact", mainContact);
      
      if (dataContact != null) {
         addPersonTokens(map, "dataContact", dataContact);
      }
      
      if (jangalaContact != null) {
         addPersonTokens(map, "jangalaContact", jangalaContact);
      }
      
      //map.put("$sender", "Ancyra Research Facility");
      
      map.put("$systemName", system.getNameWithLowercaseType());

      
      return map;
   }

   @Override
   public String[] getHighlights(String stageId) {
      List<String> result = new ArrayList<String>();
      
      if ("posting".equals(stageId)) {
      } else if ("success".equals(stageId)) {
      } else {
         //addTokensToList(result, "$rewardCredits");
      }
            
      return result.toArray(new String[0]);
   }
   
   @Override
   public Color[] getHighlightColors(String stageId) {
      return super.getHighlightColors(stageId);
   }
    @Override
   public boolean isDone() {
      return ended;
   }
    @Override
   public String getEventName() {
      if (stage == TutorialMissionStage.INIT) {
         return "Contact " + mainContact.getPost() + " " + mainContact.getName().getLast();
      }
      if (stage == TutorialMissionStage.DELIVER_REPORT) {
         return "Deliver Report to Jangala";
      }
      if (stage == TutorialMissionStage.DONE) {
         return "Deliver Report to Jangala - completed";
      }
      return "Stabilize the Jump-points";
   }

   
   
   @Override
   public CampaignEventCategory getEventCategory() {
      return CampaignEventCategory.MISSION;
   }

   @Override
   public String getEventIcon() {
      return Global.getSettings().getSpriteName("campaignMissions", "tutorial");
   }

   @Override
   public String getCurrentImage() {
      return ancyra.getFaction().getLogo();
   }

   
   
}
[close]

--SOLVED--

Doh! Forgot to overwrite the events entry in events.json! That's why it was still trying to call original tutorial event.

Working as intended now.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 21, 2017, 03:52:31 AM
How would one go about making a hullmod that increases the RELOAD rate of weapons?

I can increase ammo, rate of fire, but what is the variable/syntax for reload rate?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 21, 2017, 01:45:47 PM
How would one go about making a hullmod that increases the RELOAD rate of weapons?

I can increase ammo, rate of fire, but what is the variable/syntax for reload rate?

I don't think you currently can since it isn't supported by the API. (Last I checked about 6-8 months ago)

I'm pretty sure I suggested it in the API suggestion thread a while back, along with a way to lock certain tech types from fighter slots.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 21, 2017, 01:50:17 PM
You can, however, managing reloading directly; setAmmo() works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 22, 2017, 01:00:39 AM
That wouldn't change relaoad rate, just set ammo to a specific value.


There is already a missile fab system/hullmod that when activated fully reloads all missile weapons for a high flux cost. But that's not what I'm looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 23, 2017, 02:20:34 AM
sup
can someone help me, plz

why does this thing works in swp mod(twice) and templar mod, but returns "assignment conversion not possible" for me? is there something obvious, that i'm missing?
Spoiler
List<ShipAPI> targets = AIUtils.getNearbyAllies(beamtarget, area);
                    if (targets.size() > 0) {
                        ShipAPI target = targets.get(MathUtils.getRandom().nextInt(targets.size()));  <<<this thing
                        if (MathUtils.isWithinRange(point, target, area)) {...
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 23, 2017, 09:25:23 AM
Are you compiling a JAR?  Most likely, you're hitting a Janino issue there.

But mainly, you're doing that in a totally-inefficient way, from the look of that.

The isWithinRange() is redundant; if it's in the area variable, it's already in range, if the logic's written correctly.  So, for example, if you're trying to do something semi-randomized to one ship in that area (like heal them):

Code
boolean hasHealed = false;
int tooManyRepeats = 0;
//Get this list only one time, ever; expensive square-root invocation in getting distances between Vector2fs!
List<ShipAPI> targets = AIUtils.getNearbyAllies(beamtarget, area);
while(!has Healed && tooManyRepeats < 1000){
for(ShipAPI target :  AIUtils.getNearbyAllies(beamtarget, area)){
//Keep adding to this each pass so that we're limited to 1000 invocations of getRandomInRange()
//This means the while operation can fail but can't lock up the game-sim (usually the right answer for real-time code)
tooManyRepeats += 1;
//Only does this logic 1 in 100 passes
if(MathUtils.getRandomInRange(1f,100f) > 99f){
--> do healing logic here
//Use this as a break to leave the while loop
hasHealed = true;
}
}
}

Lastly, the right way to get a number from 0 --> end of a List's size:

myList.get(MathUtils.getRandomNumberInRange(0,myList.size()-1));

MathUtils.getRandomNumberInRange() is capable of getting numbers in float and integer values automatically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 26, 2017, 12:12:25 AM
Is PersonAPI.setPortraitSprite(String portraitName) bugged?

Doesn't seem to work. I put in portrait_hegemony01 (no quotes) into rules, call that into a string as a parameter of the script, then pass that into that method.

In the campaign, I get a blank portrait screen and a null pointer exception like it can't find the portrait.

The PersonAPI definition of that particular method would also work as I can't seem to find it in the API, just references to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 26, 2017, 02:26:34 AM
You need to specify the full sub-path, e.g. graphics/portraits/portrait_hegemony01.png

(This won't affect your specific example, but it also needs to be loaded somewhere by specifiying it in the faction file or in settings.json)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on September 26, 2017, 03:34:42 AM
Are you compiling a JAR?  Most likely, you're hitting a Janino issue there.

But mainly, you're doing that in a totally-inefficient way, from the look of that.

/snip


In case anyone copies that code example, it needs mentioning that its performance is broken. (See target assignment expression)
It could also be done with less, more efficient code, but that's a secondary issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 26, 2017, 09:46:15 PM
You need to specify the full sub-path, e.g. graphics/portraits/portrait_hegemony01.png

(This won't affect your specific example, but it also needs to be loaded somewhere by specifiying it in the faction file or in settings.json)

Ah, thanks! Works as intended now.  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 28, 2017, 01:39:50 AM
so i mutilated ion beam script.
now this thing fires emp arcs at everything in range around point of impact, dealing set amount of damage, evenly distributed.
affects friendlies as well - not intentional, but will make weapon harder to use. also more fair, because lightning doesn't care about IFF.

the whole script:
Spoiler
Quote
package data.scripts;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.entities.SimpleEntity;
import org.lwjgl.util.vector.Vector2f;
import org.lazywizard.lazylib.combat.CombatUtils;
import java.util.List;

public class TF_BEAM_ARC implements BeamEffectPlugin {

   float delay = 0.75f;
   
   @Override
   private IntervalUtil fireInterval = new IntervalUtil(delay, delay*3f);
   private boolean wasZero = true;
   
   public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {
      CombatEntityAPI beamtarget = beam.getDamageTarget();
      if (beamtarget instanceof CombatEntityAPI && beam.getBrightness() >= 1f) {
         float dur = beam.getDamage().getDpsDuration();
         // needed because when the ship is in fast-time, dpsDuration will not be reset every frame as it should be
         if (!wasZero) dur = 0;
         wasZero = beam.getDamage().getDpsDuration() <= 0;
         fireInterval.advance(dur);
         
         if (fireInterval.intervalElapsed()) {   
         
               Vector2f dir = Vector2f.sub(beam.getTo(), beam.getFrom(), new Vector2f());
               if (dir.lengthSquared() > 0) dir.normalise();
               dir.scale(50f);
               Vector2f point = Vector2f.sub(beam.getTo(), dir, new Vector2f());
               
               float emp = beam.getWeapon().getDamage().getFluxComponent() * delay; //emp
               float dam = beam.getWeapon().getDamage().getDamage() * delay;      //damage
               float area =600f;
               float empmainwidth = 40;
                       
                  for(CombatEntityAPI target :  CombatUtils.getEntitiesWithinRange(point, area)){
                  
            int num   = CombatUtils.getEntitiesWithinRange(point, area).size();   //get number of enemies      
                        
            Vector2f arcsplit = new Vector2f(MathUtils.getRandomPointOnLine(point,beam.getWeapon().getLocation()));   
                  //secondary emp arc. decorative
                  engine.spawnEmpArc(
                              beam.getSource(),
                              beam.getWeapon().getLocation(),
                              beam.getSource(),
                              new SimpleEntity(arcsplit),
                              DamageType.ENERGY,
                              0, // damage
                              0, // emp
                              100000f, // max range
                              "tachyon_lance_emp_impact",
                              empmainwidth,
                              beam.getFringeColor(),
                              beam.getCoreColor()
                              );    
                  //main emp arc
                  engine.spawnEmpArc(
                              beam.getSource(),
                              arcsplit,
                              beam.getSource(),
                              target,
                              DamageType.ENERGY,
                              dam/num, // damage
                              emp/num, // emp
                              100000f, // max range
                              "tachyon_lance_emp_impact",
                              empmainwidth/num,
                              beam.getFringeColor(),
                              beam.getCoreColor()
                              );
                     }   
         }
      }
   }   
}
[close]
i'm kinda ok with how it works, but would like some expert opinion if i did something horribly wrong

also

how can i insert a delay between arcs.
without using ShipAPI target = <ShipAPI>targets.get(...); which doesn't seem to work :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on September 30, 2017, 12:08:22 AM
The BRIEFEST of questions:

In weapon files, there is the line:

Code
	"renderHints":[RENDER_BARREL_BELOW],

This tells the game to render the barrel below the base sprite, easy. The question I have is: is there a RENDER_BAREEL_ABOVE or something similar? Tried render above, but it didn't seem to be recognised by the ship editor.  I'm making a sort of real-life midrange shotgun weapon, where instead of the barrel bouncing back, a sort of pump action casing outside the barrel jumps back instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 30, 2017, 01:58:25 AM
This tells the game to render the barrel below the base sprite, easy. The question I have is: is there a RENDER_BAREEL_ABOVE or something similar?
just leave the field blank. it'll do the trick.

also a question
is it possible to render "base" sprite below "under" sprite? :P

also a question
how can i make projectile use random debris sprite? so it's different for each projectile from the same weapon.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2017, 09:46:26 AM
is it possible to render "base" sprite below "under" sprite? :P

It's not.

how can i make projectile use random debris sprite? so it's different for each projectile from the same weapon.

Barring some creative hackery I'm unaware of, also no - sorry :)


how can i insert a delay between arcs.

I'm not sure I understand the question. I mean, there's the "interval" stuff in the script already to do that, so I guess the answer would be "use that instead of doing it twice in a row"? But I'm guessing you've looked at that already so I'm probably missing some aspect of the question.

Edit: another option would be to add a script to the combat engine that'll add an emp arc after a delay and then have its isDone() method return true.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on September 30, 2017, 05:37:10 PM
how can i make projectile use random debris sprite? so it's different for each projectile from the same weapon.

Barring some creative hackery I'm unaware of, also no - sorry :)

Well, two ways to go about it really.

An everyframe plugin that removes and replaces the shot choosing from a list of different projectiles. This is unfortunately rather expensive and thus unsuitable for a rapid fire weapon. Alex, why is projectile spawning via script so dang expensive? If it wasn't I would totally make things like this (cheated extremely high rate of fire, with properly staggered bullet streams)...
(https://i.imgur.com/TcIX5l0.gif)


Or the projectile uses a blank sprite, and an everyframe plugin renders the shot visual through direct sprite rendering fun, choosing from a list of different sprites. This if done correctly, is fine performance wise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 30, 2017, 06:18:29 PM
Quote
how can i make projectile use random debris sprite? so it's different for each projectile from the same weapon.
That's actually really easy to do with the FX Mod (http://fractalsoftworks.com/forum/index.php?topic=12503.0).

You'd make an invisible projectile for your weapon, then spawn an FX particle using the random SpriteAPI you want going the same velocity, etc., then tie that to the weapon (presumably, using a HashMap, where the projectile, if it's done any damage, then triggers the FX particle's lifetime to fade away).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2017, 07:16:09 PM
Alex, why is projectile spawning via script so dang expensive?

If you're passing in a null ship parameter, it has to create a fake one, so that probably takes a bit. If not, it should actually be pretty fast, as far as I can tell.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on September 30, 2017, 08:09:25 PM
Alex, why is projectile spawning via script so dang expensive?

If you're passing in a null ship parameter, it has to create a fake one, so that probably takes a bit. If not, it should actually be pretty fast, as far as I can tell.

Stuff from the past which experimented with creating weapons with ludicrous rates of fire via shot spawning (but not more than say several Vulcans firing at the same time) bogged down the performance even on rigs with high-end CPUs. And both those experiments, and modern things in the Modiverse which do not use shot spawning on weapons with high rates of fire always link the ship. So, on less powerful rigs, even not trying to mimic that gif with the Phalanx systems, is going to tank performance so I avoid using shot spawning for anything that fires faster than what might be considered "semi-automatic" as the overall rule of thumb.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2017, 07:41:13 AM
Just gave it a try; spawning a lightmg projectile 10 times per frame dropped the idle time from 94% to around 88% on my rig (with only an Apogee deployed). That's about, what, 30 Vulcans firing at the same time, so that much of a drop seems about right. Looking at a profiler, nothing unexpected there, just looks like the extra time is spent rendering/doing collision checking/etc.

Spawning 100 shots per frame drops the idle to single digits, but again, the vast majority of that load is due to having that many projectiles in flight rather than the cost of spawning new ones.

The code was this, btw, in an EveryFrameCombatPlugin:

Code: java
ShipAPI playerShip = engine.getPlayerShip();
if (playerShip != null && !playerShip.isShuttlePod()) {
WeaponAPI w = ((WeaponAPI)((WeaponGroupAPI) playerShip.getWeaponGroupsCopy().get(0)).getWeaponsCopy().get(0));
for (int i = 0; i < 10; i++) {
engine.spawnProjectile(playerShip, w, "lightmg", playerShip.getLocation(),
playerShip.getFacing() + (float) Math.random() * 360f, playerShip.getVelocity());
}
}

Passing in null for a weapon did not change things appreciably.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on October 03, 2017, 10:50:19 AM
The weapon MesoTroniK refers to is one that fires a lot of projectiles that last a long time and fly a long range, so that might just be expected results.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 03, 2017, 11:30:32 AM
Yeah, if the projectiles last a long time, then we're hitting issues with collision detection, drawing of the projectiles, etc. 

This can be dealt with by various means, though; a custom projectile system could take a localized snapshot of nearby objects at creation, for example, and only search them for collisions each frame (I used that approach for Vacuum for a few things and it worked well; yes, it'll miss things that spawn during the lifetime, but it's less-significant gameplay-wise than you'd think, tbh, because those projectiles usually aren't aimed at those new things anyhow).

IIRC, the costs to draw projectiles that aren't Missiles are somewhat significant when we're talking thousands (and even then, isn't as cheap as it could be, because it's calling glTexture() a lot); I'd really like a tag that told them not to draw at all (rather than not being seen, which doesn't get rid of the small load of building the glow around the projectiles, etc., unfortunately).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 04, 2017, 12:13:48 AM
Trying to get an illustration to load with the .setInteractionImage("illustrations", "illustration_name"); method for a planetAPI entity.

Gives me an error that the texture can't be found. If the issue is it needs to be loaded into memory first through a file, which one references those illustrations? An example would be: urban03

That works.

But the one I'm passing in (my own from the mod directory) doesn't.

I've quadruple checked name inconsistencies and even tried setting a new file path to see if having the same one was the issue for some reason.

I've also removed just that method from the SectorGeneratorPlugin script and everything else works fine, as a control.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on October 04, 2017, 01:21:04 AM
Good question:

I have a energy homing missile who change trajectory each 30 frame.
If i want than he become a energy homing projectile where they cannot be targeted per pd laser: I need to:
-Create a missile when the weapon shoot who is removed instantly for add the projectile of a static list on a everyframe script.
-For the target of the projectile, for be more simple, i put also the target of the missile and if null,  the projectile become not homing.
-We put a intervalUtils of 30 frame, all of these energy projectile will change on each interval same if they have be launched  there are  1 frame.  (So, maybe a strange effect, but wathever)

My question is:
This is good for the computer to made a energy homing projectile like that?  (Always more than check all projectile of the combat and check if correspond to the type of the homing projectile.)
Or we have better? Or i keep missile, but who have each missile, 1 interval.

Because  create 10 missile/remove 10 missile, create 10 projectile and put that on a static Map(contain also target) cost maybe less than create 10 missile, then launch each frame, their advance()    or check on all projectile, if the type is equal, launch the homing script. (I remove also the projectile of the map when he died)

The number of projectile on the combat can be to 100 on same time.


One of my weapon use that, but this is a large mount who spawn 1 missile transformed to 9 projectile who have for target, the target of the owner ship, so i never call a function for search a target.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 04, 2017, 06:03:47 AM
The best answer, if you wish to create a guided projectile that won't get engaged by PD, is not to create a MissileAPI at all, but rather, to take an ordinary DamagingProjectileAPI and set its angle and velocity every frame (i.e., build your own guidance system).  The Vanilla PD AI won't aim at DamagingProjectileAPI's that aren't MissileAPIs.

Using game-frames for guidance (which isn't IntervalUtil, btw; that handles raw time) is a bad idea; 30 frames between updates means that the projectile's going to miss more often than not unless it's pretty fast (in which case, why bother guiding it).

Some guidance systems are available in the Radioactive Code Dump thread and some pretty clean ones are in my AI project.  

Essentially, this kind of code involves doing a quadratic equation every time you need specific guidance data (what vector to aim at), so updates every few frames are inherently expensive; spawning dozens of them will involve a fairly heavy CPU load.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on October 04, 2017, 08:11:52 AM
Is there any way to make the ship without shield(short-time phase or none) more aggressive?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2017, 09:01:30 AM
Something quick and dirty:
ship.getCaptain().setPersonality(Personalities.RECKLESS);

(Note that this may affect the personality of the officer in the campaign - in fact, I think it would. So maybe not the best idea.)

Also, possibly:
ship.getAIFlags().setFlag(AIFlags.DO_NOT_BACK_OFF, 1f);

This would ... let's say "strongly advise" the ship to not back off for a second. This might cause it to keep closing the distance while venting or overloaded, though.


Also, take a look at CoreLifecyclePluginImpl.pickShipAI() - it sets up a very aggressive AI for automated ships. You could do the same sort of thing for the ship you want - by implementing your own pickShipAI() method - and then hanging on to the ShipAIConfig object so that you can adjust the values in it during combat, as needed.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 04, 2017, 11:48:27 AM
Trying to get an illustration to load with the .setInteractionImage("illustrations", "illustration_name"); method for a planetAPI entity.

Gives me an error that the texture can't be found. If the issue is it needs to be loaded into memory first through a file, which one references those illustrations? An example would be: urban03

That works.

But the one I'm passing in (my own from the mod directory) doesn't.

I've quadruple checked name inconsistencies and even tried setting a new file path to see if having the same one was the issue for some reason.

I've also removed just that method from the SectorGeneratorPlugin script and everything else works fine, as a control.

**solved** Got it, just needed a day to think on it. Settings file is where its referenced. The tag the method is referring to is the category in that file and the key is the string that points to the image file's location, wherever that may be.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on October 04, 2017, 07:57:52 PM
Something quick and dirty:
ship.getCaptain().setPersonality(Personalities.RECKLESS);

(Note that this may affect the personality of the officer in the campaign - in fact, I think it would. So maybe not the best idea.)

Also, possibly:
ship.getAIFlags().setFlag(AIFlags.DO_NOT_BACK_OFF, 1f);

This would ... let's say "strongly advise" the ship to not back off for a second. This might cause it to keep closing the distance while venting or overloaded, though.


Also, take a look at CoreLifecyclePluginImpl.pickShipAI() - it sets up a very aggressive AI for automated ships. You could do the same sort of thing for the ship you want - by implementing your own pickShipAI() method - and then hanging on to the ShipAIConfig object so that you can adjust the values in it during combat, as needed.



Oh thx! It does help me a lot!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on October 05, 2017, 12:57:54 AM
I have a energy homing missile who change trajectory each 30 frame.
If i want than he become a energy homing projectile where they cannot be targeted per pd laser: I need to:
...create a missile with collision class NONE with an AI that change it back to MISSILE_FF when inside the bounds of a ship, a bit like ORA's Invocation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on October 05, 2017, 01:06:37 AM
I have a energy homing missile who change trajectory each 30 frame.
If i want than he become a energy homing projectile where they cannot be targeted per pd laser: I need to:
...create a missile with collision class NONE with an AI that change it back to MISSILE_FF when inside the bounds of a ship, a bit like ORA's Invocation.
Thank ^^
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 15, 2017, 12:24:51 AM
Does autoresolve not work with stations?

(https://i.imgur.com/6qaSjsg.png)

The station and the fleet facing it have been in battle for several days. The station took some hull damage near the start and got its CR worn down, but otherwise nothing is happening. The fleet isn't taking any damage either.

EDIT: Should note that battles do get resolved if the station also has normal fleets on its side.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 15, 2017, 08:15:16 AM
Yeah, it's borked - never came up in vanilla playtesting and if we're being honest, it didn't occur to me to test it. Planning to fix it for the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 17, 2017, 11:15:50 PM
Is the problem fixable modside in 0.8.1?
I'm trying to modify the autoresolve plugin to handle stations correctly. Do modules exist as FleetMemberAPIs on the campaign layer, and if so, how do I get them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2017, 10:12:03 AM
You can do this:
FleetMemberAPI.getModuleVariant(String slotId)

Might just be easier to add a tag to a station and work up a reasonable "autoresolve strength" off that - probably not much point to being super-detailed here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 19, 2017, 04:45:10 AM
Thanks, that lets me get the stats using temporary fleet members. But what I really need to do is to damage/destroy the modules.
Currently member.getStatus().applyHullFractionDamage() applied to the station fleet member only works on the central hull, and (as implemented in the vanilla autoresolve plugin) doesn't reduce the hull integrity bar below 85% or so (even when FleetMemberBattleOutcome is DISABLED).

I guess that's not possible and stations have to be left as a player-only encounter for now?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 19, 2017, 09:01:52 AM
I think these methods in FleetMemberStatusAPI might cover what you want:

void setDetached(int index, Boolean detached);
void setHullFraction(int index, float hullFraction);
boolean isDetached(int index);

"index" is the index of the module, in each case. index = 0 is the main body of the station.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on October 20, 2017, 08:56:35 AM
I found that if a module ship part is overloaded, it will spread out emp arcs randomly, can i turn it off?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2017, 09:48:46 AM
I'm not sure what you mean, would you mind elaborating or posting a screenshot?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on October 23, 2017, 06:56:10 PM
Hi all!
For some weird reason, asking for
Code: java
Global.getLogger(Someclass.class).log(Level.INFO,member.getHullSpec().getShieldType());
in "public class Someclass implements Buff" results in
Spoiler
Code: java
34900 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at data.scripts.campaign.Someclass.apply(Someclass.java:129)
at com.fs.starfarer.loading.specs.c.o00000(Unknown Source)
at com.fs.starfarer.title.ooOO.OO0O.super(Unknown Source)
at com.fs.starfarer.title.ooOO.OO0O.super(Unknown Source)
at com.fs.starfarer.coreui.Oooo.super(Unknown Source)
at com.fs.starfarer.ui.j.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.OO00.renderImpl(Unknown Source)
at com.fs.starfarer.ui.newui.F.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.OO00.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Oo0O.renderImpl(Unknown Source)
at com.fs.starfarer.ui.newui.K.renderImpl(Unknown Source)
at com.fs.starfarer.ui.newui.newsuper.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.OO00.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.render(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$_1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]
line 129 is exactly "getShieldType()" one.

Any thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on October 24, 2017, 11:53:53 AM
Hi all!
For some weird reason, asking for
Code: java
Global.getLogger(Someclass.class).log(Level.INFO,member.getHullSpec().getShieldType());
in "public class Someclass implements Buff" results in
Spoiler
Code: java
34900 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at data.scripts.campaign.Someclass.apply(Someclass.java:129)
at com.fs.starfarer.loading.specs.c.o00000(Unknown Source)
at com.fs.starfarer.title.ooOO.OO0O.super(Unknown Source)
at com.fs.starfarer.title.ooOO.OO0O.super(Unknown Source)
at com.fs.starfarer.coreui.Oooo.super(Unknown Source)
at com.fs.starfarer.ui.j.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.OO00.renderImpl(Unknown Source)
at com.fs.starfarer.ui.newui.F.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.OO00.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Oo0O.renderImpl(Unknown Source)
at com.fs.starfarer.ui.newui.K.renderImpl(Unknown Source)
at com.fs.starfarer.ui.newui.newsuper.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.OO00.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.render(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$_1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]
line 129 is exactly "getShieldType()" one.

Any thoughts?

Global.getLogger(Someclass.class).log(Level.INFO,member.getHullSpec().getShieldType())
If you have a nullpointerexception, so you need to see what you have put on your line:

Here, you have probably forgot than member can be null maybe , on your code, so you need to put if(member != Null)
And, i have not idea if hullspec can be null, but else, you need to change that per if(member !=Null && member.getHullSpec() != Null)

For the shieldType, exist always, a shield can be none(else, the game crash when you try to made a ship without shieldtype, i think, but this is not the case, here), so normally, no problem.
I have not idea if Global.getLogger accept Null on the second parameter, but the second if can probably resolve your problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on October 25, 2017, 02:36:48 AM
The ShieldType on that "member" is FRONT. And the thing is, the Logger does log the ShieldType as FRONT! And then, "blam!" NullPointerException.
It does nothing with Logger call though, because it raises Exception even when I'm checking ShieldType in plain "If" statement.

If that will shed some light, I tried to check the shieldType inside the dialog, but as recall member.getHullSpec() does not require you to be in combat. And somewhy still the error comes from com.fs.starfarer.combat.CombatMain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on October 25, 2017, 02:59:13 AM
The ShieldType on that "member" is FRONT. And the thing is, the Logger does log the ShieldType as FRONT! And then, "blam!" NullPointerException.
It does nothing with Logger call though, because it raises Exception even when I'm checking ShieldType in plain "If" statement.

If that will shed some light, I tried to check the shieldType inside the dialog, but as recall member.getHullSpec() does not require you to be in combat. And somewhy still the error comes from com.fs.starfarer.combat.CombatMain.
 

You have tried like that, sure?
Code
 if(member !=Null && member.getHullSpec() != Null)
  Global.getLogger(Someclass.class).log(Level.INFO,member.getHullSpec().getShieldType());  

Else, i sincerely don't know.


Edit: you can also give the line above and belove this line for be sure?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 25, 2017, 10:16:13 AM
The ShieldType on that "member" is FRONT. And the thing is, the Logger does log the ShieldType as FRONT! And then, "blam!" NullPointerException.

If that's the case, then it's definitely not crashing on that line, whatever the stack trace says.

Also, don't worry about the CombatMain part - the entry point into the game is named that, for legacy reasons. Every stack trace will have that, regardless of whether the game is in combat or in the campaign.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on October 25, 2017, 04:29:13 PM
I've checked the
Code: java
if(member!= null && member.getHullSpec() != null && 
(member.getHullSpec().getShieldType()==ShieldType.FRONT ||
member.getHullSpec().getShieldType()==ShieldType.OMNI) )
thing and it actually works. No edits except these checks. It seems that the original mod somehow managed to sneak past "member.getHullSpec()" checks altogether in shiny armour whereas my edits were getting 'dirty' data. I still don't quite understand why did it work before, but who am i to judge the winner, after all.
Thank you @Snrasha for exceptional insight!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on October 25, 2017, 11:56:24 PM
Alex, i have a question about for made a Nebula System.

I have look on the starsystemgenerator and i have see my problem, now i have a nebula system with jumppoint for out and in without crashing.
Because AutogenerateJumpPoint dislike the lack of Star.

But:
The script who made AutogenerateJumpPoint on  random Nebula starsystem delete the Star before then after, re-insert.  But do not work if you have market on the Nebula System, it seems, else crash.
So i have autogenerateJumpPoint with the Star, then i have deleted him.

So, like say before, all work perfectly, no crash when i try to pass a jump point or i put my cursor above, and i can return on the Nebula system without problem.
The unique problem than i have now is just than: Well, the system is not display on the Map.

Nebula starsystem who contains market:
Quote
StarSystemAPI system = sector.createStarSystem("Uclora");
        system.getLocation().set(-10000, -17000);
        system.setType(StarSystemType.NEBULA);   <-- Put the system on Nebula.
        system.setBackgroundTextureFilename("graphics/backgrounds/Noir_back.jpg");

        PlanetAPI star = system.initStar("noir_staruclova", "star_yellow", 100, 10);   <-- False Star

    //  [ . . . ]    <- Planet,relay and jumppoint created here.

    
Code: Nebula system code
    system.removeEntity(star);
        StarCoronaTerrainPlugin coronaPlugin = Misc.getCoronaFor(star);
        if (coronaPlugin != null) {
            system.removeEntity(coronaPlugin.getEntity());
        }

        system.setStar(null);
        system.initNonStarCenter();
        for (SectorEntityToken entity : system.getAllEntities()) {
            if (entity.getOrbitFocus() == star
                    || entity.getOrbitFocus() == system.getCenter()) {
                entity.setOrbit(null);
            }
        }

        star.setSkipForJumpPointAutoGen(true);


        system.setStar(star);
        star.addTag(Tags.AMBIENT_LS);
        system.autogenerateHyperspaceJumpPoints(true, false);
        system.setStar(null);
        system.initNonStarCenter();
        system.getCenter().addTag(Tags.AMBIENT_LS);


Thank you!

Image of the two nebula hidden starsystem where i am:
Spoiler
(https://i.imgur.com/64qRC25.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2017, 09:23:10 AM
You've almost got it - the code to autogen the jump-points would generate a gravity well for a star if one was there, so we remove the star and replace it with initNonStarCenter() instead.

But *after* autogenerating the jump-points, we need to set a star for the system in order for it to show up on the map. In the case of a nebula, it ought to be one of:

nebula_center_old
nebula_center_average
nebula_center_young

In planets.json. You could also do up a custom one if you want something specific, based on one of those.

They are invisible in the system view, due to having no texture, and you want to set their radius to 0 as well, so they can't be clicked on. But they will show up in the hyperspace map view.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on October 26, 2017, 10:00:50 AM
Thank you.

Work properly, now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 27, 2017, 11:43:42 AM
Not sure if anyone has overwritten the tutorial so this may be an Alex question, but:

When you call this:

Global.getSector().reportEventStage(this, "eldrus_start", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(eldrus));

To create a mission log message for the player, I'm looking for all the scripts that go into what gets displayed.

I know:
      -     Reports.csv determines the contents of the dialogue
      -     The createSetMessageLocationScript(PersonAPI/CampaignFleetAPI/PlanetAPI) method determines where the sensor ping location will be on the map when you click the message.
      -     Use Misc.makeImportant(eldrusGuard, REASON); to make the yellow "!" appear on the entity for the mission.
      -     You can use (I think) Reports.csv to determine the image and logo as well as the comms channel source, but the tutorial itself doesn't use that way to do it.

So:
     -      Is this method ever called from TutorialMissionEvent.java? public String getCurrentImage()
     -      Or this one?    public String getEventIcon() {
      return Global.getSettings().getSpriteName("campaignMissions", "tutorial");
   }


      -     Do these two play any role in the above method?? If not, how does the tutorial always source from Ancyra and the Hegemony for the message?


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2017, 12:03:45 PM
    -      Is this method ever called from TutorialMissionEvent.java? public String getCurrentImage()

Yeah, it determines the big image in the message detail, i.e. when you click on it in the intel screen. I *think* it'll fall back to the faction logo for the message location entity if that returns null.

    -      Or this one?    public String getEventIcon() {
      return Global.getSettings().getSpriteName("campaignMissions", "tutorial");
   }


That's the icon in the filter in the intel screen.

     -     Do these two play any role in the above method?? If not, how does the tutorial always source from Ancyra and the Hegemony for the message?

Either those two methods, or the faction of the message-location entity, depending on what you mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 27, 2017, 12:48:34 PM
    -      Is this method ever called from TutorialMissionEvent.java? public String getCurrentImage()

Yeah, it determines the big image in the message detail, i.e. when you click on it in the intel screen. I *think* it'll fall back to the faction logo for the message location entity if that returns null.

Ah I see. Well, maybe I just have an error (like its the wrong stage I'm actually needing to check for or something) but this:

   @Override
   public String getCurrentImage() {
        if (stage == TutorialMissionStage.GO_TO_ELDRUS) {
            return eldrus.getFaction().getLogo();
        }
        if (stage == TutorialMissionStage.RETURN_FROM_ELDRUS) {
            return eldrus.getFaction().getLogo();
        } else {
            return ancyra.getFaction().getLogo();
        }


Doesn't seem to do it.  :-\

Let me test some more, but thanks for the confirmation!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 27, 2017, 02:16:19 PM
Let me test some more, but thanks for the confirmation!

After more testing, works as intended! (I was checking for the stage after the one I should have been because it was defined incorrectly earlier in the file.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on October 29, 2017, 12:07:39 AM
Quick one:

Code
        stats.getCombatEngineRepairTimeMult().modifyMult(BUFF_ID, repairMult);
        stats.getCombatWeaponRepairTimeMult().modifyMult(BUFF_ID, repairMult);

For these ones, exactly what is it modifying? Is it modifying the length time it takes to fix a weapon (I.E. putting in a bigger number makes it go longer, smaller numbers make it go smaller) or is it modifying the rate at which the repairs occur (I.E. putting in bigger numbers makes it go quicker, smaller numbers make it go slower)?

Trying to make a shipsystem that instant fixes weapons and engines.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 29, 2017, 08:53:50 AM
The length of time, iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 02, 2017, 03:48:04 PM
Any reason why this section of the CallEvent(RuleId, String RuleReference) method from an extension of TutorialMissionEvent.java wouldn't be invoked by this rule trigger?


Code block in CallEvent method:
Spoiler
        } else if (action.equals("returnFromEldrus")) {

            Global.getSector().reportEventStage(this, "sneak_end", Global.getSector().getPlayerFleet(),
                    MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));

            Misc.makeUnimportant(eldrusContact, REASON);
            Misc.makeUnimportant(eldrusGuard, REASON);
            Misc.makeImportant(mainContact, REASON);

            updateStage(TutorialMissionStage.GOT_DATA);
[close]

Rules Script:

CallEvent $tut_eventRef returnFromEldrus

For reference, this section of the very same method works with this trigger:
Spoiler
      } else if (action.equals("endGetData")) {   // 'actions' are Rules.csv string entries.
                                                                             // stage below used in Reports.csv for mission dialogue.
         Global.getSector().reportEventStage(this, "eldrus_start", Global.getSector().getPlayerFleet(),
               MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(eldrus));   // Where map pings in message.
         
         Misc.makeUnimportant(dataContact, REASON);
                        Misc.makeImportant(eldrusContact, REASON);              // sets a yellow "!" over target entity to notify player
         Misc.makeImportant(eldrusGuard, REASON);                // of its importance.

                        Misc.cleanUpMissionMemory(dataContact.getMemoryWithoutUpdate(), "tut_");     // removes prefix from entity.

                        updateStage(TutorialMissionStage.GO_TO_ELDRUS);
[close]

Trigger:

CallEvent $tut_eventRef endGetData

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 02, 2017, 03:53:25 PM
One possibility comes to mind - which memory is $tut_eventRef set in? In the game's tutorial, it's set in the person's memory, which is the default memory used during the conversation. If you're trying to access it from outside a conversation with a person, it won't work because the eventRef is not there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 02, 2017, 04:13:16 PM
One possibility comes to mind - which memory is $tut_eventRef set in? In the game's tutorial, it's set in the person's memory, which is the default memory used during the conversation. If you're trying to access it from outside a conversation with a person, it won't work because the eventRef is not there.

Oh that is most likely the reason then, yes! I did not set that variable in the PersonAPI when I created the custom character in extended GalatiaGen. Thank you!

I didn't quite know where that variable came in and since the other invocations worked I made a couple assumptions. Can you explain why it is referenced by chance? Is it a safeguard against it being the wrong entity or something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 02, 2017, 04:37:05 PM
I'm not sure I understand the question. So let's cover hopefully everything :)

CallEvent needs to know what event's callEvent() method to call, so the event reference needs to be passed in to it.

As to where that reference lives - in person memory, entity memory, or global memory - that doesn't matter, it can be wherever you like. Putting it into global memory (Global.getSector().getMemoryWithoutUpgate(), iirc?) might make it easier to reference without worrying about being in the right memory context. For something you know there's only ever going to be one of, that'd be fine to do.

If there were multiple events going on at the same time - such as, delivery missions - then it makes sense to put it into the mission contact's memory. IIRC the delivery mission creation code avoids having multiple missions with the same contact, primarily for this reason.

Does that explain what you wanted to know?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 02, 2017, 05:56:29 PM
Does that explain what you wanted to know?

Yes! Also, confirmed solved  ;D That was what I had assumed earlier (that it linked Rules.csv and the .java file), I just didn't realize that event data was passed through the local memory of the entity rather than the global memory layer for the event. After that description I see why it's smarter to do it that way though. :)

For what I'm doing, global would be fine since the story branches but I don't any plans for concurrent storylines at the moment. That could change though, so may as well keep the convention.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on November 06, 2017, 10:22:28 AM
Question: ArmorGridAPI contains the armor, but good question, the method getArmorFraction  give 1 or 0 if the sprite of the ship is completely out of the grid? (Like the hammerhead, on the level of the right/left side of the bridge, per exemple)

Thank you o/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2017, 11:00:35 AM
The armor grid is set to "fully undamaged" everywhere, initially, and only goes down from that when damage is taken. The bounds of the ship only matter since they affect where on the grid damage is likely to be taken.

Does that answer your question?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on November 06, 2017, 12:05:25 PM
The armor grid is set to "fully undamaged" everywhere, initially, and only goes down from that when damage is taken. The bounds of the ship only matter since they affect where on the grid damage is likely to be taken.

Does that answer your question?

Yes, thank. Now i know than i need to remade my detection of damaged ship also (Before, i read just the contour for the performance, but if a ship with strange aspect can have 50% of the contour undamaged, argl :p)

EDIT:The script on this gif exemple, it is not perfect on performance, i try to decrease the cost. (Anyone of these sprite are the good, this is just for test)
Spoiler
(https://i.imgur.com/zC9MvM0.gif)
[close]

And like i have not understand perfectly how work the armor. Now,  yes! Thank you very much.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on November 06, 2017, 08:49:23 PM
Asking this mostly out of curiosity... how does the game sort the weapons in markets?.

For player owned inventory it seems to be alphabetically (taking into account large weapons first, then medium, small, and finally fighter LPCs) if you use the sort function.

But that's not true for markets, meanwhile it does follow size, and if you can buy them. Weapons are not ordered alphabetically, or by what I thought applied, the number column.

Made a test giving a very large number to 2 large energy weapons, after a couple of tests (in order to get more variety of weapons spawning in the market), they appeared a first and last with other 2 weapons. Their order was not alphabetical, since it went D, M, C, P, nor was it by their number column, being actually 100001, 16, 15, 500000, neither was type since the weapons in the middle were missiles or their internal names, since 1 of the missile weapons was a cyclone reaper launcher ("cyclone") and it was in the middle of 3 weapons with the "TSC_" prefix.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2017, 08:59:57 PM
Checked - looks like it's weapon size, then *stack* size, then weapon id. Not entirely sure why it'd do stack size, the reasoning for that is lost in the mists of time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on November 08, 2017, 06:30:57 AM
@Alex,

There was a thread (http://fractalsoftworks.com/forum/index.php?topic=13096.0) about game crash while saving. It also have wonderous link to RAM/VRAM req's.
A couple of days ago I've got my rig to 12GB RAM, 2GB VRAM 'cause I use a lot of mods. But I feel indignant to experience a crash because of VRAM (I triple-checked this with useShaders option of GraphicsLib) not while actually playing the game, but rather saving the game. I simply can't comprehend, how the hell that can even happen?!
If it is possible (read: won't take too much time/effort), could you explain WHY (what leads to this event) can SS crash out of VRAM while being "suspended" for saving. And is it possible to fix?
Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 08, 2017, 08:19:01 AM
What leads you to believe it's VRAM related? That seems extremely unlikely, barring driver bugs and that sort of thing. To date, I don't think I've seen any reports of a game running out of VRAM while saving. That wouldn't make a whole lot of sense, unless it's a video card that doesn't have dedicated VRAM and instead shares RAM, like some integrated cards do.

It's possible that the useShaders option in GraphicsLib also makes the game use more regular RAM; not sure on the details there.


As far as the "during saving" crashes, I think there are two categories:
1) Someone playing with a bunch of mods and not raising the memory allocation, and
2) They raised the memory allocation, but there's a memory leak, so no matter what the memory allocation is, eventually it'll crash.

Given that I fixed a bunch of leaks in vanilla for 0.8, and there haven't been any (maybe one?) reports of a memory-related crash with just vanilla, and there have been a lot less reports of it with mods, I suspect that a specific mod might be involved in #2. Obviously can't guarantee that, can't guess which one it might be, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on November 08, 2017, 02:05:54 PM
If GraphicsLib is used along with every mod under the sun, VRAM requirements might reach as high as 2.5 GB.  I doubt that would happen with GraphicsLib disabled.  Even dedicated cards will fall back to system memory if you run out.  Not that this would be problematic if you have 12 GB of RAM, which leaves quite a healthy buffer even if you allocate 4 GB to Starsector.

In my experience, unless you simply don't allocate enough memory to Starsector (say, less than 3 GB if you have a ton of mods that add lots of markets), the only source of save failure is the bug where XStream fails midway through the saving, which isn't memory-related.  Other people have reported a separate issue where the game will just progressively slow down until it's too laggy to use (and the save freezes entirely) - I have seen this before on occasion - and it seems to be caused by DynaSector for unknown reasons.  Nobody who reported this issue has ever submitted a save file, no matter how many times I asked.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on November 08, 2017, 03:34:57 PM
Ok, the setup is "-Xms8192m -Xmx8192m" (overzealous I might be), 2.5GB taken by Win10+apps/services, 1.5GB free no matter what, 2GB swap on SSD (just a cherry on top for old apps compat), 2GB Nvidia GTX670 at 1920*1200.

Mods:
Spoiler
Active-Gates
ApproLight
Audio Plus
Autosave
Blackrock Drive Yards
Combat Chatter
Common Radar
Console Commands
Dassault-Mikoyan Engineering
DIABLEAVIONICS
DisassembleReassemble_v0.8
DynaSector
Extra System Reloaded
Galatia Complete
GraphicsLib
Interstellar Imperium
LazyLib
Leading Pip
Lightshow_with_SWP
Metelson
Neutrino corp
New Galactic Order 1.06b
Nexerelin
Omnifactory
ORA
Portrait pack
Save Transfer
SCY
Shadowyards
Ship and Weapon Pack
Simulator Overhaul
Steiner Foundation
TARGETS
Templars
Tyrador Safeguard Coalition
Underworld
UnknownSkies
UpgradedRotaryWeapons
Version Checker
[close]

When GraphicsLib is "just for compatibility" SS runs fine for hours and I haven't ever ran into a crash. But when GraphicsLib is ON, SS drops at a) the end of galaxy creation right when it tries to save the game, b) it creates galaxy fine, but next save (even right after the exact start) will crash it.
After a second thought, may be I should LOWER the 8192 to 6144 (or even 4096) in java mem-alloc options?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on November 08, 2017, 07:26:05 PM
Yes, you should reduce your allocation.

Also, with GfxLib on, you’re definitely using more than 2 GBs of VRAM with that mod list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Novaris on November 10, 2017, 04:19:25 AM
If GraphicsLib is used along with every mod under the sun, VRAM requirements might reach as high as 2.5 GB.  I doubt that would happen with GraphicsLib disabled.  Even dedicated cards will fall back to system memory if you run out.  Not that this would be problematic if you have 12 GB of RAM, which leaves quite a healthy buffer even if you allocate 4 GB to Starsector.

In my experience, unless you simply don't allocate enough memory to Starsector (say, less than 3 GB if you have a ton of mods that add lots of markets), the only source of save failure is the bug where XStream fails midway through the saving, which isn't memory-related.  Other people have reported a separate issue where the game will just progressively slow down until it's too laggy to use (and the save freezes entirely) - I have seen this before on occasion - and it seems to be caused by DynaSector for unknown reasons.  Nobody who reported this issue has ever submitted a save file, no matter how many times I asked.

Seems I'm one of these affected cases. I increased the memory limit to 5GB (simply because I use nearly every faction mod there is which is probably also the source of my issue together with DynaSector and Nexerelin) but when I play for about an hour you see the CPU idle percentagy decreasing more and more until it starts to impact the FPS, which will then gradually fall from 60 to 25. Once I save and close the game and reload the same savefile it is ok again, but only for a few minutes, then it follows essentially the same path. For now I tracked the issue down to essentially two things: the garbage collector kicking in because of all the debris in the systems and the fights going on throughout sector which the game has to calculate in the back and get rid of the objects it doesn't need anymore (once I see this phenomenon I also find a star system which is just full of space debris) and, judging from the log file, market information and fleet creation.

I tried a few things to ease the situation by switching on other garbage collection schemes but none of them really led to a better solution. The only thing that works every time is doing a save transfer into a newly created system, then the clock starts ticking again. One thing I also noticed is that this behavior starts once the first templar crusade notification pops up. My best guess is that this event leads to an increase in space battle and debris count which just accelerates the problem. I have yet to try out what happens if I deactivate the crusades though so please don't take it as blame assignment. What is also a little weird is that saving into the same save slot seems to be a lot slower than creating a new save file and does not tend to crash that often.

As for the question about the savegame: I will provide one once I'm at the machine again togeher with a mod list if you still want to investigate the matter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dark.Revenant on November 10, 2017, 10:03:04 AM
Frankly, I don't want to investigate the matter, especially if the problem space is "literally everything", given that your mod list is as large as possible.

The first Crusade generally happens at the same time every game, so I doubt it's Templar-related.  Try disabling DynaSector instead and see if that affects the timing significantly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Novaris on November 10, 2017, 10:08:01 AM
Thats what I thought, but I will try your suggestion. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 11, 2017, 12:06:09 AM
Currently trying to get a new system generated, not entirely sure what has gone wrong:

Code
74002 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addPlanet(Unknown Source)
at data.scripts.world.systems.HMI_mercy.generate(HMI_mercy.java:87)
at data.scripts.world.HMI_gen.generate(HMI_gen.java:16)
at data.scripts.HMI_modPlugin.initHMI(HMI_modPlugin.java:16)
at data.scripts.HMI_modPlugin.onNewGame(HMI_modPlugin.java:24)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.Oo0O.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.j.super(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Happens at initialization of new game. Reading it I thought something wasn't right with the planets.json, but I can't see anything wrong there. Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on November 11, 2017, 12:15:13 AM
Currently trying to get a new system generated, not entirely sure what has gone wrong:

Code
74002 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addPlanet(Unknown Source)
at data.scripts.world.systems.HMI_mercy.generate(HMI_mercy.java:87)
at data.scripts.world.HMI_gen.generate(HMI_gen.java:16)
at data.scripts.HMI_modPlugin.initHMI(HMI_modPlugin.java:16)
at data.scripts.HMI_modPlugin.onNewGame(HMI_modPlugin.java:24)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.Oo0O.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.j.super(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Happens at initialization of new game. Reading it I thought something wasn't right with the planets.json, but I can't see anything wrong there. Any ideas?

Paste the HMI_mercy line 87 will be more helpful.
This is just a nullpointerexception, so you have forgot to check if a thing can be null or not, no?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 11, 2017, 01:13:12 AM
Hmmm...I think I put the wrong thing in for a planet type. Let me check...

EDITL Yeah, that was it. Huh, didn't know those numbers actually corresponded to lines of code. Thanks Snrasha!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dk1332 on November 11, 2017, 08:15:16 AM
I got some few questions and I think I should address it here rather than making a thread for it.

-Is it possible to make a subsystem that creates a "portal" and temporarily extends a fighter's range?
-If so, is it also possible to restrict it to certain fighters by adding a hullmod?
-How do you make a weapon have another type of damage? (ex. Kinetic gun has a small percentage to deal a small amount of HE damage)
-About the recovery shuttle hullmod, is it possible to make a hullmod for a fighter that has the same effect (lowers the chance of a pilot dying)
-Is it possible to add a commodity as an expendable requirement on a ship/fighter/weapon?


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 11, 2017, 05:19:52 PM
I got some few questions and I think I should address it here rather than making a thread for it.

...

-How do you make a weapon have another type of damage? (ex. Kinetic gun has a small percentage to deal a small amount of HE damage)

My Codefu is lacking, but I do know the answer to this one: I suggest you pick up Blackrock, and have a peak at how the Shard weapons work, specifically the weapon script in the jar/src/data/scripts/weapons. Do note that this one is in a JAR, so it'll require the use of an IDE to get it to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Verrius on November 11, 2017, 06:44:58 PM
Hey everyone, I wanted to ask if there's an easy way to prevent all spawning when you start the game? The easiest way to mod the game to be a completely empty universe in a single system, with no jump points to hyperspace, etc.

I tried to search but I'm either bad at searching, or it's not outlined in a single place.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2017, 07:09:52 PM
Hey everyone, I wanted to ask if there's an easy way to prevent all spawning when you start the game? The easiest way to mod the game to be a completely empty universe in a single system, with no jump points to hyperspace, etc.

I tried to search but I'm either bad at searching, or it's not outlined in a single place.

Thanks!

I *think* if you override these in settings.json, that should cover it:

"newGameCreationEntryPoint":"data.scripts.world.SectorGen",
"newGameSectorProcGen":"com.fs.starfarer.api.impl.campaign.procgen.SectorProcGen",

You'd also have to mod new game creation (in rules.csv) to start in hyperspace instead of in a system that no longer exists.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 13, 2017, 01:38:28 PM
For this method: Global.getSector().getMemory().getFleet(key)

I'm wondering what the "key" references? Is it a memory key you can set with:

CampaignFleetAPI.getMemoryWithoutUpdate().set(key, object)

What I'm doing:
I'm trying to reference a CampaignFleetAPI (without a for loop to search the entire sector if possible) in order to invoke CampaignFleetAPI.getFlagship() and use the resulting FleetMemberAPI in visual.showFleetMemberInfo(FleetMemberAPI)


Ah, shoot nvm. Must be the same issue I had a while ago. The key is in the entity memory, and the script is checking global. Disregard  ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 16, 2017, 01:21:15 PM
Ok lots of questions about this one.  :P

When setting up a custom BattleAPI for a battle with a specifically defined context, such as ESCAPE scenario with allies supporting your retreat, do you have to also define everything in the MissionDefinitionAPI and pass that as a parameter into BattleCreationPlugin alongside another defined BattleCreationContext?

How much does the engine do for me, and if the answer is nothing then how easy is it to define those classes? Orrr, the unlikely easy way? :

As long as they are nearby in the LocationAPI, can I just get the CampaignFleetAPI's for all involved and plug them in to the BattleAPI.join(CampaignFleetAPI) boolean then make a few tweaks to who's supporting who?

If it's anything like how the tutorial scripting works, it'll be a pretty big hierarchy I'm guessing.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2017, 01:30:38 PM
If I'm understanding the question right, I'd suggest taking a look at FleetInteractionDialogPluginImpl.java - it sets up a battle, pulls in nearby fleets, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 16, 2017, 01:56:26 PM
Yes, wow there is a whole lot of detail in that file.  Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Regoso on November 28, 2017, 07:06:45 PM
This has probably been answered before (and iv looked just cant get a solid post to make it work)but ima ask anyway. Trying to use a decorative weapon to cover other weapons, so far its being rendered below them.



.wpn
Spoiler

{
   "specClass":"beam",
   "id":"laserupperdeck",
   "type":"DECORATIVE",
   "size":"LARGE",
   "showDamageWhenDecorative":true,
   "renderBelowAllWeapons":false,
   "alwaysAnimate":"true",
   "turretSprite":"graphics/weapons/decorative/Dec_1.png",
   "hardpointSprite":"graphics/weapons/decorative/Dec_1.png",
   "turretOffsets":[0, 0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[0, 0],
   "hardpointAngleOffsets":[0],
   "fringeColor":[255,255,255,255],
   "coreColor":[255,255,255,255],
   "glowColor":[255,255,255,255],
   "width":1.0,
   "textureType":ROUGH,
   "textureScrollSpeed":1.0,
   "pixelsPerTexel":1.0,
}

[close]

weapon slot
Spoiler
      "angle": 0,
      "arc": 0,
      "id": "WS0030",
      "locations": [
        44,
        -24.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "DECORATIVE"
[close]

not getting any errors its just showing up under the other weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on November 28, 2017, 08:49:16 PM
This has probably been answered before (and iv looked just cant get a solid post to make it work)but ima ask anyway. Trying to use a decorative weapon to cover other weapons, so far its being rendered below them.

...

not getting any errors its just showing up under the other weapons.

@Regoso Weapons on ships have a special render order that specifies which weapons appear over the top of others. I can't remember all the details, but the most basic rule is that the game will always render weapons closest to the ship's center of mass last, ie. "on top". A quick example is the Onslaught - if you look at the central large ballistic turret, you'll notice that its weapon will always render over the top of whatever you stick in the small turrets in front of it.

If it isn't already, you should be able to trick the game into placing your decorative weapon over another weapon with the following steps:

- Increase the height of the canvas your decorative weapon sprite is on, so it occupies the very front end of the canvas, with a bit of empty space behind it.
- Adjust the position of the decorative mount on the ship file to be closer to the center of the ship.
- Fine tune the decorative weapon's offset accordingly

That will result in the decorative weapon's actual coordinate position being closer to the ship's center of mass than the weapon (even though it should appear in the same location). It should therefore be rendered after the weapon itself, and appear on top. Hope that helps!  ;)



EDIT: I've also just been informed that apparently Large weapons will always render over Mediums (and Smalls) regardless of relative position, but since your file is saved as a LARGE weapon, it should be alright. Though just in case, it may also pay to change the mount itself to LARGE as well (instead of SMALL).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on November 29, 2017, 02:45:15 AM

(https://i.imgur.com/eymyNxP.jpg)
i've been looking for this for so long
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on November 29, 2017, 08:39:26 PM
i've been looking for this for so long

Hehe, seriously, thank MesoTronik. I just gave his feedback in my own words on his behalf. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 30, 2017, 11:59:36 PM
Is there a way I can flag a fleet so that other fleets' AI ignore it (don't try to engage it in battle, etc.)?

I'm asking because I don't think I want to run this for every CampaignFleetAPI that ever spawns:
Code: java
	public void setFleetDoNotAttackStations(CampaignFleetAPI fleet)
{
if (FLEETS_ATTACK_STATIONS) return;
for (CampaignFleetAPI station : allFleets)
{
if (fleet.getAI() == null) continue;
fleet.getAI().doNotAttack(station, 9999999);
}
}
(allFleets will have a peak size equal to maybe half the number of markets in the Sector)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 01, 2017, 01:49:07 PM
Hmm - I think you're stuck with something like that for the moment. If we're talking on the order of 100ish stations there (which it sounds like it's probably less) then I think that would be a negligible cost compared to the work of creating the fleet in the first place.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 01, 2017, 06:27:40 PM
Well it's not so much the runtime resource cost that I'm worried about as the prospect of save file bloat.
(Or am I just looking for a premature optimization here?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 01, 2017, 07:02:48 PM
Ah - well, you could clear that out on save and re-add on load, if it turns out to be significant.

Edit: to clear it out, you'd need to set the time to 0 and then call advance() on the AI - I'm reasonably sure that would work.

So you'd:
1) clear it out in ModPlugin.beforeGameSave()
2) restore it in ModPlugin.afterGameSave() and ModPlugin.onGameLoad()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on December 03, 2017, 01:35:18 PM
Is there a way to change the firerate of a weapon while it's firing ?
Well, I did manage to make a frankenstein-plugin that could act on the firerate but it was way too random and unreliable.
What I'm trying to achieve here is a slow spooling-up ramp for some gatlings. I'd like to have all of thoses starting at the same firerate and the larger ones achieve faster max firerate but accelerating at a slower pace.
I tried different things after the mitigated success of my first attempt but it doesn't work anymore.
Is there a clean way to do this ? Cleaner than "checking the cooldown after each round is fired and if that cooldown is equal or inferior to the last shot, if that's the case, decrease the cooldown of the next shot, and repeat that until the maximal fire rate is reached" ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gruberscomplete on December 07, 2017, 07:37:43 PM
Is it possible to change fleet distributions so that fleets have mostly 1-2 ships instead of like 8?

Is there a mod that does this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gwyvern on December 12, 2017, 05:38:45 PM
Is there a way to make missiles behave like projectiles?

(IE: Fade out after reaching max range, and being untargetable by PD)

If not, is there a way to get projectiles to leave persistent trails like missiles do?

This would save me from having to resort to particle effects. (which is a win win for everyone!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 12, 2017, 07:32:44 PM
You cannot get them to be ignored by PD without writing a new PDAI that specifically ignored them, no.

However, if they're not a guided projectile, they can have a "trail" that's generated as a particle via my FX library.  If they're guided, however, you'll probably have to settle for them being missiles that are simply indestructible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 13, 2017, 04:25:47 AM
Are there any ways to warp/twist the sprite in game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 14, 2017, 03:58:41 PM
Not without doing some OpenGL to write the sprite to a mesh to be deformed; there's no base effect that warps a sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 15, 2017, 07:26:51 AM
Is there a way to apply the autogenerated D-ship overlay to a premade D skin?
I have a skin of a station module, with 3 D-mods, and the spriteName tag is commented out. It still looks identical to the pristine version in mission refit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 15, 2017, 10:21:55 AM
Looking into it - this is a horrible hack on my part, but, yes there is! Make sure the *hull id* (not variant id) of the skin ends with the string "_default_D". I really should have just added a boolean to the hull data/skin data, but for whatever reason, it didn't happen that way. I think I wasn't considering the "skin" case at all, on the assumption that it'd be providing its own sprite anyway, being a skin.

Also, if it's using a custom hull style, that needs to d-hull overlays configured, like so:

"dHullOverlaySmall":"graphics/damage/ship_damage_over3.png",
"dHullOverlayLarge":"graphics/damage/ship_damage_over3.png",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 16, 2017, 12:58:49 AM
Thanks Alex! But it crashes on application load :(
Code
6023 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Ship hull variant [nex_asgard_module2_default_D_Hull] not found!
java.lang.RuntimeException: Ship hull variant [nex_asgard_module2_default_D_Hull] not found!
at com.fs.starfarer.loading.P.super(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.o00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.for(Unknown Source)
at com.fs.starfarer.loading.SpecStore.for(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

(baseHullId in skin file is nex_asgard_module2_default_D)

I'll probably just ask the artist (HELMUT) for a proper D/pirate sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2017, 09:04:47 AM
That's actually pretty weird - not seeing why it'd do that, and simple attempts to reproduce this have failed to do so. Possibly something I fixed since the release? Hmm.

Edit: making the hullName for the skin end with "(D)" (minus the quotes, of course) is worth a shot, just in case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on December 16, 2017, 10:24:35 AM
I can confirm you that it works, at least for me.

Made a "TSC_Sabre_default_D" and a "TSC_Sabre_TT_default_D" skins, and then made some variants that use them, both work ingame.
It seems the ships won't show in markets though, although I admit I did not test too much to make sure it doesn't happen (and no, I did not forget to add them to a faction, just in case).

Spoiler
(https://lh3.googleusercontent.com/JYCqAFkGx-6XGfv5z3-C18aXzoDDWT8Fx-hcUXvS5_p-kss5-Ajg-_ROLi5iiKts3ImLQNcycSHvqHYt1j3YdHGkvLrf1z2khsk4kqZuRGWoJu3MDOnkGWoAUNSllMAlpNVcfPZTfQ) (https://photos.app.goo.gl/I1fe3CFV4QdrYO9W2)
[close]

Did similarly made "_default_D" skins of every remnant station module and the station itself, copied their variants renaming the modules to the "TSC_(OriginalShipId)_default_D, it works ingame.

Spoiler
(https://lh3.googleusercontent.com/8zv3VjiDP-HMUDL1ypzBRaTN2gFiyh_756iinaQ9HpWREl54cQEKt_-HSx-q5K8yNs0Yp9_fQaYsUIAg28w74vpZspn7UR-LA-0x4bdNYUi1nEG6Rc_CuR0Kvb3QU4a5fkdjzp9T7g) (https://photos.app.goo.gl/2TmTgjV8wuG1NLbQ2)
[close]

BTW this is awesome I wanted to add this kind of (D) ships for a while, but I didn't manage it, and since it was not top priority, left it for later. Although I think it should be made a boolean in the skin file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 17, 2017, 12:17:40 AM
Okay, think I've figured it out.

Crashes:
Skin ID nex_asgard_d with baseHullId nex_asgard_default_D
Variant with hull ID nex_asgard_d

Does not crash:
Skin ID nex_asgard_default_D with baseHullId nex_asgard
Variant with hull ID nex_asgard_default_D

However, the variant does not include the D hullmods I specified in the skin file. My guess is it uses the autogenerated _default_D hull instead of the premade skin with that ID.

Fixed version:
Skin nex_asgard_p_default_D with baseHullId nex_asgard
Variant with hull ID nex_asgard_p_default_D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 19, 2017, 10:09:22 PM
I'm learning opengl by RingRenderer.java and something like this.
The texProgress finally become 2.0 and draw the picture 2 times actually, but why? What's the meaning of sprite.getTextureHeight() or getTextureWidth()?
float texPerSegment = pixelsPerSegment * texHeight / imageHeight * bandWidthInTexture / thickness; what's the meaning of this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 20, 2017, 10:12:32 AM
The texProgress finally become 2.0 and draw the picture 2 times actually, but why?

The ring texture, if you take a look at, tiles vertically. texProgress tracks the texture coordinate of the current location in the texture. So, the current slice of the ring will start at texProgress and go to texProgress + texPerSegment.

How many times it'll have to go through the entire texture depends on the circumference of the ring, relative to its width - basically we're just laying down texture as we go, and whenever we're done with the ring, we stop. There's a bit of rounding to make sure that the texture ends on a whole number, so that the place where we end the ring merges seamlessly with the place where we started - due to the texture tiling vertically.

What's the meaning of
sprite.getTextureHeight() or getTextureWidth()?
float texPerSegment = pixelsPerSegment * texHeight / imageHeight * bandWidthInTexture / thickness; what's the meaning of this?

Short version: you can actually ignore texWidth and texHeight for this code, since they'll always be 1.

Longer answer: the image you're storing in texture memory can be any width or height, but the actual texture's width and height have to be powers of two. For example, if you load a 400x200 image, it'll be stored in a 512x256 texture, and will only take up a portion of it.

In OpenGL, texture coordinates go from 0 to 1. For this 512x256 texture, the x coordinate would go from 0 to 1 across the entire 512 pixel width. The texture width (at least, in Starsector terms), then, is which fraction of the allocated texture is actually used by the image - in this case, it would be 400/512, or 0.78125. So when you're supplying texture coordinates to draw this texture, you would say "draw from 0 to 0.78125 on the x dimension".

The rest of the texture will be taken up by... I forget what it defaults to, I think Starsector sets the contents to black when it loads them. You can still draw the stuff that's in there, you just generally never want to.

You can also say "draw from 0.9 to 1.1", for example, and it'll wrap the texture. For a tiling texture (i.e. one that connects to itself seamlessly), this is what you want to do - but it has to take up the whole width or height of the texture, so that there's none of the extra buffer to get in the way of the tiling. Which is why, in RingRenderer, both texWidth and texHeight are 1 - because the source texture is, iirc, 512x256 or maybe 1024x512, I forget which.


I'd also suggest looking at some OpenGL tutorials - there's plenty around, and it may help with the basics.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 20, 2017, 10:37:46 AM
If you're trying to implement OpenGL within the context of this game, I'd honestly suggest you look at what I did to build a particle system that doesn't use SpriteAPI any more than it has to.

Basically... you use SpriteAPI as an image loader to assign a texture and store it, once only, then do OpenGL work with said texture:

public final SpriteAPI fx_muzzleflash_001 = Global.getSettings().getSprite("fx", "fx_muzzleflash_001");

As Alex just pointed out, using non-power-of-two textures means some adjustments in later code; it's generally better to plan out your textures as power-of-two for ease later on, as otherwise the game has to handle it and you'll have to handle it, too.

Then you use the stored texture to do the drawing, and it's pretty simple, actually.  

Code: java
		//OpenGL Start
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

for (Map.Entry<Integer, ArrayList<fx_Particle>> entry : fx_SharedLib.particleList.entrySet()) {
int key = entry.getKey();
glBindTexture(GL_TEXTURE_2D, key);
glBegin(GL_QUADS);
for(fx_Particle particle : entry.getValue()){
if (particle.isDead()) continue;
handleParticle(particle);
float size = particle.size.getX() / 2f;

glColor4ub((byte)particle.curColor.getRed(),(byte)particle.curColor.getGreen(),(byte)particle.curColor.getBlue(),(byte)particle.curColor.getAlpha());

glTexCoord2f(0, 1);
Vector2f vec = MathUtils.getPointOnCircumference(particle.position, size, particle.angle + 315f);
glVertex2f(vec.getX(),vec.getY());

glTexCoord2f(0, 0);
vec = MathUtils.getPointOnCircumference(particle.position, size, particle.angle + 225f);
glVertex2f(vec.getX(),vec.getY());

glTexCoord2f(1, 0);
vec = MathUtils.getPointOnCircumference(particle.position, size, particle.angle + 135f);
glVertex2f(vec.getX(),vec.getY());

glTexCoord2f(1, 1);
vec = MathUtils.getPointOnCircumference(particle.position, size, particle.angle + 45f);
glVertex2f(vec.getX(),vec.getY());
}
glEnd();
}

Please read through FX_Plugin and fx_Particle in my FX project to understand how to do that in detail (storing texture ids within a body of data so that you can reduce the number glTexture() calls to a bare minimum is massively important for excellent performance, for example).



But, for a simple ring where you're not worrying about this at all, you could do something like this:

Code: java
//How round do we want this to be?
int segments = 64;
//We're setting the center of the ring to 0,0 here; obviously, you'll want to adjust that later
Vector2f position = new Vector2f(0f,0f);
//How big is the outer edge?
float outerRing = 256f;
//How big is the inner edge?
float innerRing = 200f;

//OpenGL setup stuff; the only thing that's really important here is the glBlendFunc (in this case, it's "normal", non-additive blending).
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

//The value of "key" our texture ID, that we'll use in a second, needs to be assigned.  One quick-and-dirty way to do that would be like this:
SpriteAPI myRingSprite= Global.getSettings().getSprite("fx", "fx_RingSprite");
int key = myRingSprite.getTextureId();
//Generally speaking, you only ever want to do any of this ONCE.  You shouldn't generally be doing this within renderInWorldCoords().
//But to keep things simple in this example, I've done it this way.

//Now that we have the key value, we can bind it for traditional OpenGL here.
glBindTexture(GL_TEXTURE_2D, key);
//NOTE:  If you're going to render multiple rings per frame, and you want this to be efficient, do this part ONLY ONCE.  glBindTexture() is expensive!
//Use a HashMap or an ArrayList to store the positions / sizes / colors / blend states / whatever of all your rings and then process them below, essentially.
//If you're going to have some rings that are additive and some that aren't, you'll need to deal with that properly, too.
//The best answer typically is to draw the non-additive stuff first, then the additive stuff.  Otherwise, it'll look pretty funky, heh.
//I've only built it this way to make it simpler to understand the code flow.

//Start drawing our quads for this ring.
glBegin(GL_QUADS);

//Draws a quad for each segment of our ring.
//Goes in clock-wise order (it won't work correctly otherwise!)
for(int i=0; i<360; i++360/segments){

//Left-top ring segment quad vertex
glTexCoord2f(0, 1);
Vector2f vec = MathUtils.getPointOnCircumference(position, outerRing, (float) i);
glVertex2f(vec.getX(),vec.getY());

//Right-top ring segment quad vertex
glTexCoord2f(0, 0);
vec = MathUtils.getPointOnCircumference(position, outerRing, (float) i + (float) 360/segments);
glVertex2f(vec.getX(),vec.getY());

//Right-bottom ring segment quad vertex
glTexCoord2f(1, 0);
vec = MathUtils.getPointOnCircumference(position, innerRing, (float) i + (float) 360/segments);
glVertex2f(vec.getX(),vec.getY());

//Left-bottom ring segment quad vertex
glTexCoord2f(1, 1);
vec = MathUtils.getPointOnCircumference(position, innerRing, (float) i);
glVertex2f(vec.getX(),vec.getY());
}
glEnd();

Now... I haven't tested the above, so buyer beware... but it should work.  Makes me wonder if I ought to put a ring-renderer into the FX project; it would be pretty easy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 20, 2017, 10:45:00 AM
Fixed a couple of things to show texture-assignment, etc. within that ring-renderer example.  I think it'll basically work as advertised now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 20, 2017, 08:46:15 PM
The texProgress finally become 2.0 and draw the picture 2 times actually, but why?

The ring texture, if you take a look at, tiles vertically. texProgress tracks the texture coordinate of the current location in the texture. So, the current slice of the ring will start at texProgress and go to texProgress + texPerSegment.

How many times it'll have to go through the entire texture depends on the circumference of the ring, relative to its width - basically we're just laying down texture as we go, and whenever we're done with the ring, we stop. There's a bit of rounding to make sure that the texture ends on a whole number, so that the place where we end the ring merges seamlessly with the place where we started - due to the texture tiling vertically.

What's the meaning of
sprite.getTextureHeight() or getTextureWidth()?
float texPerSegment = pixelsPerSegment * texHeight / imageHeight * bandWidthInTexture / thickness; what's the meaning of this?

Short version: you can actually ignore texWidth and texHeight for this code, since they'll always be 1.

Longer answer: the image you're storing in texture memory can be any width or height, but the actual texture's width and height have to be powers of two. For example, if you load a 400x200 image, it'll be stored in a 512x256 texture, and will only take up a portion of it.

In OpenGL, texture coordinates go from 0 to 1. For this 512x256 texture, the x coordinate would go from 0 to 1 across the entire 512 pixel width. The texture width (at least, in Starsector terms), then, is which fraction of the allocated texture is actually used by the image - in this case, it would be 400/512, or 0.78125. So when you're supplying texture coordinates to draw this texture, you would say "draw from 0 to 0.78125 on the x dimension".

The rest of the texture will be taken up by... I forget what it defaults to, I think Starsector sets the contents to black when it loads them. You can still draw the stuff that's in there, you just generally never want to.

You can also say "draw from 0.9 to 1.1", for example, and it'll wrap the texture. For a tiling texture (i.e. one that connects to itself seamlessly), this is what you want to do - but it has to take up the whole width or height of the texture, so that there's none of the extra buffer to get in the way of the tiling. Which is why, in RingRenderer, both texWidth and texHeight are 1 - because the source texture is, iirc, 512x256 or maybe 1024x512, I forget which.


I'd also suggest looking at some OpenGL tutorials - there's plenty around, and it may help with the basics.
Thanks! I think I understand, and I have made what I want to do though
(https://i.imgur.com/HtZbmya.gif)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 20, 2017, 08:49:10 PM
Now... I haven't tested the above, so buyer beware... but it should work.  Makes me wonder if I ought to put a ring-renderer into the FX project; it would be pretty easy.
Thank for your answer but I know how things work now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 20, 2017, 09:19:59 PM
Thanks! I think I understand, and I have made what I want to do though
(https://i.imgur.com/HtZbmya.gif)

Cool! Not sure which parts of this involve the OpenGL stuff, but it all looks nice :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 20, 2017, 11:14:30 PM
Cool! Not sure which parts of this involve the OpenGL stuff, but it all looks nice :)
The bending tentacles which use GL_QUAD_STRIP to render  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Regoso on December 21, 2017, 04:49:18 AM
How does one go about getting a station_module to render below engines if that is possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 21, 2017, 08:58:14 AM
@Originem:  That looks great!  Good job  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2017, 09:05:38 AM
The bending tentacles which use GL_QUAD_STRIP to render  ;D

Ah, very nice! That's pretty tricky to do.


How does one go about getting a station_module to render below engines if that is possible.

Could you elaborate a bit? What exactly are you trying to accomplish?

Generally speaking, larger ships are rendered before smaller ships, and since station modules need to be FRIGATE for various reasons, this means they'll render above the engine glows of most other ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Regoso on December 21, 2017, 11:21:29 AM
How does one go about getting a station_module to render below engines if that is possible.

Could you elaborate a bit? What exactly are you trying to accomplish?

Generally speaking, larger ships are rendered before smaller ships, and since station modules need to be FRIGATE for various reasons, this means they'll render above the engine glows of most other ships.

Spoiler
(https://puu.sh/yLfLP/cf54ea4ba3.png)
[close]
trying to get that rear armour plate to render below the engines
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2017, 12:26:54 PM
Ah, gotcha - there's a UNDER_PARENT hint, but I'm fairly sure that's only in the dev version and not in the 0.8.1a release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Regoso on December 21, 2017, 12:57:34 PM
Ah, gotcha - there's a UNDER_PARENT hint, but I'm fairly sure that's only in the dev version and not in the 0.8.1a release.
ya it appears to not be work but thanks anyway =).

Also how does one get a station module to show up on a skin as i seem to be having trouble with that it well show up when i spawn the variant in but when i go to buy it its not on the ship its suppose to be on in the market. The base ship already has SHIP_WITH_MODULES on it but that doesnt seem to matter even when i add it to the skin "addHints":[SHIP_WITH_MODULES], it still doesnt work in the market.
The Armoured prow is whats not working on the skin.
Market img of working ship:
Spoiler
(https://puu.sh/yLjGd/76ff58d4a5.png)
[close]
market img of none working ship:
Spoiler
(https://puu.sh/yLjyC/f5cff7359e.jpg)
[close]
skin details:
Spoiler
{
  "baseHullId": "dauntless_destroyer",
  "baseValue": 35000,
  "baseValueMult": 1,
  "builtInWeapons": {
    "WS0001": "prowtorpedolauncher"
  },
  "descriptionId": "dauntless_destroyer",
  "fleetPoints": 12,
  "hullDesignation": "Destroyer",
  "hullName": "Dauntless Mk.II",
  "addHints":[SHIP_WITH_MODULES],
  "ordnancePoints": 50,
  "restoreToBaseHull": false,
  "skinHullId": "dauntless_destroyer_MkII_skin",
  "spriteName": "graphics/ships/Dauntless_Destroyer.png",
  "systemId": "maneuveringjets"
}
[close]

Edit more details:
working ships variant file:
Spoiler
{
  "displayName": "Standard",
  "fluxCapacitors": 4,
  "fluxVents": 16,
  "goalVariant": true,
  "hullId": "dauntless_destroyer",
  "hullMods": [
    "targetingunit",
    "hardenedshieldemitter"
  ],
  "permaMods": [],
  "quality": 1,
  "variantId": "dauntless_destroyer_S",
  "weaponGroups": [
    {
      "autofire": false,
      "mode": "LINKED",
      "weapons": {
        "WS0001": "heavyprowlance",
        "WS0020": "armoured_destroyer_prow_S"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0002": "lightmc",
        "WS0004": "lightmc",
        "WS0006": "lightmc",
        "WS0008": "lightmc",
        "WS0010": "lightmc",
        "WS0012": "lightmc"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0003": "lightmc",
        "WS0005": "lightmc",
        "WS0007": "lightmc",
        "WS0009": "lightmc",
        "WS0011": "lightmc",
        "WS0013": "lightmc"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0014": "lightmacrocannonturret",
        "WS0015": "lightmacrocannonturret"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0017": "vulcanmbdtower",
        "WS0018": "vulcanmbdtower",
        "WS0021": "vulcanmbdtower",
        "WS0022": "vulcanmbdtower"
      }
    }
  ],
  "wings": []
}
[close]
non working ships variants file:
Spoiler
{
  "displayName": "Standard Mk.II",
  "fluxCapacitors": 4,
  "fluxVents": 16,
  "goalVariant": true,
  "hullId": "dauntless_destroyer_MkII_skin",
  "hullMods": [
    "targetingunit",
    "hardenedshieldemitter"
  ],
  "permaMods": [],
  "quality": 1,
  "variantId": "dauntless_destroyer_S_2",
  "weaponGroups": [
    {
      "autofire": false,
      "mode": "LINKED",
      "weapons": {
        "WS0001": "heavyprowlance",
        "WS0020": "armoured_destroyer_prow_S"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0002": "lightmc",
        "WS0004": "lightmc",
        "WS0006": "lightmc",
        "WS0008": "lightmc",
        "WS0010": "lightmc",
        "WS0012": "lightmc"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0003": "lightmc",
        "WS0005": "lightmc",
        "WS0007": "lightmc",
        "WS0009": "lightmc",
        "WS0011": "lightmc",
        "WS0013": "lightmc"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0014": "lightmacrocannonturret",
        "WS0015": "lightmacrocannonturret"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0017": "vulcanmbdtower",
        "WS0018": "vulcanmbdtower",
        "WS0021": "vulcanmbdtower",
        "WS0022": "vulcanmbdtower"
      }
    }
  ],
  "wings": []
}
[close]
Base .ship file
Spoiler
{
  "bounds": [
    -135.5,
    -8,
    -129.5,
    -23.5,
    -81,
    -23.5,
    -48,
    -34.5,
    -43,
    -13,
    74,
    -13,
    91,
    0,
    74,
    13,
    -43,
    13,
    -48,
    34.5,
    -81,
    23.5,
    -129.5,
    23.5,
    -135.5,
    8
  ],
  "builtInMods": [
    "auxiliarythrusters"
  ],
  "builtInWeapons": {
    "WS0001": "heavyprowlance",
    "WS0002": "lightmc",
    "WS0003": "lightmc",
    "WS0004": "lightmc",
    "WS0005": "lightmc",
    "WS0006": "lightmc",
    "WS0007": "lightmc",
    "WS0008": "lightmc",
    "WS0009": "lightmc",
    "WS0010": "lightmc",
    "WS0011": "lightmc",
    "WS0012": "lightmc",
    "WS0013": "lightmc",
    "WS0017": "vulcanmbdtower",
    "WS0018": "vulcanmbdtower",
    "WS0019": "upperdeck_12",
    "WS0021": "vulcanmbdtower",
    "WS0022": "vulcanmbdtower"
  },
  "builtInWings": [],
  "center": [
    81,
    137.5
  ],
  "collisionRadius": 140.5,
  "engineSlots": [
    {
      "angle": 180,
      "contrailSize": 9,
      "length": 50,
      "location": [
        -131.5,
        19
      ],
      "style": "HIGH_TECH",
      "width": 9
    },
    {
      "angle": -180,
      "contrailSize": 9,
      "length": 50,
      "location": [
        -131.5,
        -19
      ],
      "style": "HIGH_TECH",
      "width": 9
    },
    {
      "angle": 180,
      "contrailSize": 9,
      "length": 49,
      "location": [
        -134.5,
        9
      ],
      "style": "HIGH_TECH",
      "width": 9
    },
    {
      "angle": -180,
      "contrailSize": 9,
      "length": 49,
      "location": [
        -134.5,
        -9
      ],
      "style": "HIGH_TECH",
      "width": 9
    },
    {
      "angle": 180,
      "contrailSize": 9,
      "length": 49,
      "location": [
        -135.5,
        -0
      ],
      "style": "HIGH_TECH",
      "width": 9
    },
    {
      "angle": 91.5,
      "contrailSize": 128,
      "length": 16.94182,
      "location": [
        65,
        15.5
      ],
      "style": "HIGH_TECH",
      "width": 4.888646
    },
    {
      "angle": -91.5,
      "contrailSize": 128,
      "length": 16.94182,
      "location": [
        65,
        -15.5
      ],
      "style": "HIGH_TECH",
      "width": 4.888646
    }
  ],
  "height": 275,
  "hullId": "dauntless_destroyer",
  "hullName": "Dauntless_Destroyer",
  "hullSize": "DESTROYER",
  "shieldCenter": [
    0,
    0
  ],
  "shieldRadius": 142.5,
  "spriteName": "graphics/ships/Dauntless_Destroyer.png",
  "style": "MIDLINE",
  "viewOffset": 0,
  "weaponSlots": [
    {
      "angle": 0,
      "arc": 90,
      "id": "WS0001",
      "locations": [
        88,
        -0
      ],
      "mount": "TURRET",
      "size": "MEDIUM",
      "type": "BUILT_IN"
    },
    {
      "angle": 81,
      "arc": 95,
      "id": "WS0002",
      "locations": [
        33,
        9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": -81,
      "arc": 95,
      "id": "WS0003",
      "locations": [
        33,
        -9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 80.800003,
      "arc": 95,
      "id": "WS0004",
      "locations": [
        18,
        9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": -80.800003,
      "arc": 95,
      "id": "WS0005",
      "locations": [
        18,
        -9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 80.599998,
      "arc": 95,
      "id": "WS0006",
      "locations": [
        4,
        9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": -80.599998,
      "arc": 95,
      "id": "WS0007",
      "locations": [
        4,
        -9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 80.400002,
      "arc": 95,
      "id": "WS0008",
      "locations": [
        -10,
        9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": -80.400002,
      "arc": 95,
      "id": "WS0009",
      "locations": [
        -10,
        -9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 80.199997,
      "arc": 95,
      "id": "WS0010",
      "locations": [
        -24,
        9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": -80.199997,
      "arc": 95,
      "id": "WS0011",
      "locations": [
        -24,
        -9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 80,
      "arc": 95,
      "id": "WS0012",
      "locations": [
        -38.5,
        9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": -80,
      "arc": 95,
      "id": "WS0013",
      "locations": [
        -38.5,
        -9.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 0,
      "arc": 330,
      "id": "WS0014",
      "locations": [
        34,
        -0
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "HYBRID"
    },
    {
      "angle": 0,
      "arc": 270,
      "id": "WS0015",
      "locations": [
        -29,
        -0
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "HYBRID"
    },
    {
      "angle": 0,
      "arc": 300,
      "id": "WS0016",
      "locations": [
        -2.5,
        -0
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "HYBRID"
    },
    {
      "angle": -90,
      "arc": 180,
      "id": "WS0018",
      "locations": [
        -45.5,
        -1.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 0,
      "arc": 0,
      "id": "WS0019",
      "locations": [
        1.5,
        -0
      ],
      "mount": "TURRET",
      "size": "LARGE",
      "type": "DECORATIVE"
    },
    {
      "angle": 0,
      "arc": 0,
      "id": "WS0020",
      "locations": [
        95.5,
        -0
      ],
      "mount": "HARDPOINT",
      "size": "MEDIUM",
      "type": "STATION_MODULE"
    },
    {
      "angle": 90,
      "arc": 180,
      "id": "WS0017",
      "locations": [
        -45.5,
        1.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": 90,
      "arc": 180,
      "id": "WS0021",
      "locations": [
        -56,
        1.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    },
    {
      "angle": -90,
      "arc": 180,
      "id": "WS0022",
      "locations": [
        -56,
        -1.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BUILT_IN"
    }
  ],
  "width": 162
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on December 24, 2017, 06:27:44 PM
I know, I just KNOW this is going to be a stupid question, but it's something I'm a bit stuck on.

Currently looking to make a basic 'mini-faction' fleet spawner, the idea being fleets of the faction spawn from an entity, raid the system, then return to the entity. This entity is just that - a marketless planet or a space station. This prevents the faction from being conquered or removed, making them an eternal pain in the neck, while also keeping market numbers down and preventing more damage to the economy in the current version. I kind of want to do it up to current spec, as the original method (http://fractalsoftworks.com/forum/index.php?topic=1282.0) I saw to do this was a tutorial from 0.6 and I'm not sure the code is still functionality.

The problem is this: I have a space station or marketless planet. I want to spawn a fleet from that place, specifically THAT place. How can I do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 27, 2017, 08:08:24 PM
Alright finally back at this after having to take a couple months off to finish my comp sci degree.  ;D

Still stuck on this encounter in my tutorial, though:

WARNING******** This contains HEAVY story spoilers for Archean Order and the standard tutorial ********WARNING

Spoiler

Context: after you salvage the derelict probe near Pontus, you are ambushed by a Trader Guilds mercenary fleet under the employ of Ancyra's commander just after grabbing the AI core.

I have built in a way to talk to your officers in my mod, and your second (a story character chosen earlier) informs you of the threat before they rush in and the dialogue encounter begins.

At the end of this dialogue, what is SUPPOSED to happen:

- enemy AI death fleet appears. Merc fleet, in dire straights, joins you in a fighting retreat and sacrifices themselves to let the player warn Ancyra.  (teaches the player about retreating)


And what ACTUALLY happens:

- battle happens anyway despite the fleet being forcibly pacified, but auto-resolved?, and the AI fleet doesn't spawn.

Screens of context and error with some devmode memory dumps.
Spoiler
(https://i.imgur.com/xAY13aT.png)
(https://i.imgur.com/hrpQT1d.png)
(https://i.imgur.com/Vctqu9T.png)
(https://i.imgur.com/SbKjkCU.png)
(https://i.imgur.com/Vsh0eal.png)
(https://i.imgur.com/Zg4TXBP.png)
(https://i.imgur.com/1dYefUB.png)
(https://i.imgur.com/7t1mXHo.png)
(https://i.imgur.com/kmGtBAV.png)
(https://i.imgur.com/BTZAAbf.png)
(https://i.imgur.com/kIkExQw.png)
(https://i.imgur.com/hEKWuy3.png)
(https://i.imgur.com/mzjtAvg.png)


Dont actually have an active battle but...
(https://i.imgur.com/oFEwn76.png)
(https://i.imgur.com/3G4VHM1.png)


...battle damage and CR decay behind the scenes.
(https://i.imgur.com/Q0iRswM.png)
[close]

[close]

Here is the code that is supposed to implement the context. It is spread out over a couple different files.
Spoiler

rules.csv script entry at the end of the merc dialogue where the error occurs:

Spoiler
MakeOtherFleetHostile false
MakeOtherFleetAggressive false
MakeOtherFleetPreventDisengage false
MakeOtherFleetNonHostile true
MakeOtherFleetNonAggressive true
MakeOtherFleetAllowDisengage true
CallEvent $tut_eventRef startAIMercBattle
AddText "You detect another enemy fleet power up systems nearby." $faction.baseColor
[close]

The script being invoked by rules.csv in ArcheusTutorialMissionEvent.java:

Spoiler
        } else if (action.equals("startAIMercBattle")) {        // invoked with Rules.csv entry under Tutorial Mercenary AI Encounter (dialogue)
            mercCompany.clearAssignments();


            AIDeathFleet = AOGuardMiscFleetManager.createAIDeathFleet(false);
            // used to find the fleet if needed
            AIDeathFleet.setId("tutorial_AI_Deathfleet");
            system.addEntity(AIDeathFleet);

            AIDeathFleet.setLocation(playerFleet.getLocation().x + 200f, playerFleet.getLocation().y + 200f);
            TransmitterTrapSpecial.makeFleetInterceptPlayer(AIDeathFleet, true, 100f);

            BattleCreationContext mercAIBattleContext = Global.getCombatEngine().getContext();
            dialog.startBattle(mercAIBattleContext);

         float distToAI = Misc.getDistance(playerFleet.getLocation(), AIDeathFleet.getLocation());

         if (!mercCompany.isAlive() || distToAI > 900) {
            Global.getSector().reportEventStage(this, "ai_ambush_end", Global.getSector().getPlayerFleet(),
                  MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));

            updateStage(TutorialMissionStage.RETURN_TO_ANCYRA);
         }
[close]

The script invoked in AOGuardMiscFleetManager.java - "createAIDeathFleet":
Spoiler
public static CampaignFleetAPI createAIDeathFleet(boolean withCaptain) {
        CampaignFleetAPI fleet = createEmptyAIFleet("AI Death Fleet", true);

        WeightedRandomPicker<String> pickerF = new WeightedRandomPicker<String>();
        pickerF.add("glimmer_Assault");
        pickerF.add("lumen_Standard");

        WeightedRandomPicker<String> pickerD = new WeightedRandomPicker<String>();
        pickerD.add("fulgent_Assault");


        WeightedRandomPicker<String> pickerC = new WeightedRandomPicker<String>();
        pickerC.add("brilliant_Standard");


        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerC.pick());
        fleet.getFleetData().addFleetMember(pickerC.pick());
        if (withCaptain) {             // to test if generating specific character necessary

        }

        fleet.getFleetData().sort();

        return fleet;
    }
[close]

The script further up in that file that the above script references - "createEmptyAIFleet(boolean withCaptain)":
Spoiler
    public static CampaignFleetAPI createEmptyAIFleet(String name, boolean withFaction) {
        CampaignFleetAPI fleet = FleetFactory.createEmptyFleet(Factions.REMNANTS, FleetTypes.PATROL_LARGE, null);

        fleet.setName(name);
        fleet.setNoFactionInName(!withFaction);

        fleet.getStats().getFleetwideMaxBurnMod().modifyMult("tutorial", 0.8f);

        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_ALLOW_TOFF, true);
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_NO_JUMP, true);
        fleet.getMemoryWithoutUpdate().set("$tut_aiDeathFleet", true);

        return fleet;
    }
[close]


[close]

Any advice or spotting bugs is greatly appreciated!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on December 29, 2017, 09:58:48 AM
Quote
The problem is this: I have a space station or marketless planet. I want to spawn a fleet from that place, specifically THAT place. How can I do this?
Look at FleetFactoryV2.java; it's currently the standardized method for building fleets. 

Also, bear in mind that a MarketAPI doesn't need a planet or anything to attach to, etc.; it can just exist, code-wise, and you can keep it stable, etc., etc. so that it'll produce the results you want.

If you want fleets out of THAT, though, the tricky bit is probably going to be writing code so that fleets from regular Markets can also traverse THAT and show up in nearby Systems if the player's there, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on December 29, 2017, 03:41:48 PM
Generally speaking, larger ships are rendered before smaller ships, and since station modules need to be FRIGATE for various reasons, this means they'll render above the engine glows of most other ships.

Alex, mainly for curiosity, could you elaborate on the various reasons?, since I have coded a ship using a module based shield shipsystem that has a script to set its collision class as a fighter, I tested it with a module that was an actual fighter and it seemed to work normally, the only undesirable thing I can remember is it showed as "Secondary Shield Wing" in its armaments list.

Also, I tried to give the same shipsystem to a fighter, and it seems it somewhat worked, since it appeared on the codex, but when spawned from a carrier they would lose it. Not sure if this is intended or some type of bug, but I guess ship modules on fighters were never supported to start with.

Stuff not relevant to the question, just some background info why I'm working with/want this.
Spoiler
To add some info on how I coded it, the shield module has a custom AI that activates its shield when its parent shipsystem is active, otherwise it turns it off. This is mainly to avoid the AI or player flickering the shields by taking its control out of their hands, without being too intrusive, like writing a complete new AI. Regarding the shipsystem itself, it is not important and it could be a dummy for all that matters...
Currently using this as a base for my mod's Ram Drive and Burt Shield shipsystems, the later one being the one alluded at the start (instant fighter collision bubble shield that grows in size for a short while and then dissipates).
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on December 29, 2017, 03:51:40 PM
Generally speaking, larger ships are rendered before smaller ships, and since station modules need to be FRIGATE for various reasons, this means they'll render above the engine glows of most other ships.

Alex, mainly for curiosity, could you elaborate on the various reasons?

I'm fairly sure one reason is to avoid cheesing of module loadouts - if a module is a FRIGATE, then you can't equip it with Converted Hangar for instance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 29, 2017, 06:23:01 PM
Alex, mainly for curiosity, could you elaborate on the various reasons?, since I have coded a ship using a module based shield shipsystem that has a script to set its collision class as a fighter, I tested it with a module that was an actual fighter and it seemed to work normally, the only undesirable thing I can remember is it showed as "Secondary Shield Wing" in its armaments list.

Fighters may actually be fine - you don't want larger ships, because they would cause screen whiteout when they explode. I know there was a second reason but I can't think of it right now.

One thing about FIGHTER-size modules is they won't collide with other ships, so depending on where on the sprite it's located that may or may not be a problem.

... but I guess ship modules on fighters were never supported to start with.

Yeah, that's not currently supported.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on December 29, 2017, 08:49:33 PM
Fighters may actually be fine...

... One thing about FIGHTER-size modules is they won't collide with other ships, so depending on where on the sprite it's located that may or may not be a problem.

Huh. This actually hadn't occured to me as something that worked. Wonder how I can make use of this?  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 31, 2017, 05:20:17 AM
I'm trying to force a fleet to attack a station, but they keep breaking off the battle after two seconds or so (apparently before the first autoresolve round) and going to the stand-down assignment. Is there a way to make them not do this?
Code: java
CampaignFleetAPI station = DefenceStationManager.getManager().getFleet(data.targetMarket);
if (station != null)
{
// clear "do not attack" memory
fleet.getAI().doNotAttack(station, 0);
fleet.getAI().advance(1);

if (fleet.getBattle() != null) fleet.getBattle().join(station);
else if (station.getBattle() != null) station.getBattle().join(fleet);
else {
Global.getFactory().createBattle(fleet, station);
fleet.getBattle().genCombined();
fleet.getBattle().takeSnapshots();
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 31, 2017, 08:29:59 AM
Hmm - looking at the code, not seeing how that might happen - not saying that it couldn't, but definitely not seeing a path that would do that.

I'd expect it to get an autoresolve round in; the delay before the first autoresolve round is .8 to 1.2 seconds, so that would be in line with an autoresolve round happening and then this. What would cause this to happen, then, is one of the fleets deciding to disengage after the autoresolve round, i.e.:

getCombinedOne().getAI().pickEncounterOption(auto.getContext(), getCombinedOne()) == EncounterOption.DISENGAGE

I *think* massively increasing the fleet points value of the station might do the job here, it's the only thing that comes to mind that might. Assuming it's the one picking to run, and not the fleet. The larger fleet strength has to be less than double the weaker to avoid a disengage.

(I'm pretty sure you need a custom autoresolve plugin to handle station battles, btw, but iirc you're aware of this.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 31, 2017, 02:52:18 PM
Alright finally back at this after having to take a couple months off to finish my comp sci degree.  ;D

Still stuck on this encounter in my tutorial, though:

WARNING******** This contains HEAVY story spoilers for Archean Order and the standard tutorial ********WARNING

Spoiler

Context: after you salvage the derelict probe near Pontus, you are ambushed by a Trader Guilds mercenary fleet under the employ of Ancyra's commander just after grabbing the AI core.

I have built in a way to talk to your officers in my mod, and your second (a story character chosen earlier) informs you of the threat before they rush in and the dialogue encounter begins.

At the end of this dialogue, what is SUPPOSED to happen:

- enemy AI death fleet appears. Merc fleet, in dire straights, joins you in a fighting retreat and sacrifices themselves to let the player warn Ancyra.  (teaches the player about retreating)


And what ACTUALLY happens:

- battle happens anyway despite the fleet being forcibly pacified, but auto-resolved?, and the AI fleet doesn't spawn.

Screens of context and error with some devmode memory dumps.
Spoiler
(https://i.imgur.com/xAY13aT.png)
(https://i.imgur.com/hrpQT1d.png)
(https://i.imgur.com/Vctqu9T.png)
(https://i.imgur.com/SbKjkCU.png)
(https://i.imgur.com/Vsh0eal.png)
(https://i.imgur.com/Zg4TXBP.png)
(https://i.imgur.com/1dYefUB.png)
(https://i.imgur.com/7t1mXHo.png)
(https://i.imgur.com/kmGtBAV.png)
(https://i.imgur.com/BTZAAbf.png)
(https://i.imgur.com/kIkExQw.png)
(https://i.imgur.com/hEKWuy3.png)
(https://i.imgur.com/mzjtAvg.png)


Dont actually have an active battle but...
(https://i.imgur.com/oFEwn76.png)
(https://i.imgur.com/3G4VHM1.png)


...battle damage and CR decay behind the scenes.
(https://i.imgur.com/Q0iRswM.png)
[close]

[close]

Here is the code that is supposed to implement the context. It is spread out over a couple different files.
Spoiler

rules.csv script entry at the end of the merc dialogue where the error occurs:

Spoiler
MakeOtherFleetHostile false
MakeOtherFleetAggressive false
MakeOtherFleetPreventDisengage false
MakeOtherFleetNonHostile true
MakeOtherFleetNonAggressive true
MakeOtherFleetAllowDisengage true
CallEvent $tut_eventRef startAIMercBattle
AddText "You detect another enemy fleet power up systems nearby." $faction.baseColor
[close]

The script being invoked by rules.csv in ArcheusTutorialMissionEvent.java:

Spoiler
        } else if (action.equals("startAIMercBattle")) {        // invoked with Rules.csv entry under Tutorial Mercenary AI Encounter (dialogue)
            mercCompany.clearAssignments();


            AIDeathFleet = AOGuardMiscFleetManager.createAIDeathFleet(false);
            // used to find the fleet if needed
            AIDeathFleet.setId("tutorial_AI_Deathfleet");
            system.addEntity(AIDeathFleet);

            AIDeathFleet.setLocation(playerFleet.getLocation().x + 200f, playerFleet.getLocation().y + 200f);
            TransmitterTrapSpecial.makeFleetInterceptPlayer(AIDeathFleet, true, 100f);

            BattleCreationContext mercAIBattleContext = Global.getCombatEngine().getContext();
            dialog.startBattle(mercAIBattleContext);

         float distToAI = Misc.getDistance(playerFleet.getLocation(), AIDeathFleet.getLocation());

         if (!mercCompany.isAlive() || distToAI > 900) {
            Global.getSector().reportEventStage(this, "ai_ambush_end", Global.getSector().getPlayerFleet(),
                  MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));

            updateStage(TutorialMissionStage.RETURN_TO_ANCYRA);
         }
[close]

The script invoked in AOGuardMiscFleetManager.java - "createAIDeathFleet":
Spoiler
public static CampaignFleetAPI createAIDeathFleet(boolean withCaptain) {
        CampaignFleetAPI fleet = createEmptyAIFleet("AI Death Fleet", true);

        WeightedRandomPicker<String> pickerF = new WeightedRandomPicker<String>();
        pickerF.add("glimmer_Assault");
        pickerF.add("lumen_Standard");

        WeightedRandomPicker<String> pickerD = new WeightedRandomPicker<String>();
        pickerD.add("fulgent_Assault");


        WeightedRandomPicker<String> pickerC = new WeightedRandomPicker<String>();
        pickerC.add("brilliant_Standard");


        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerF.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerD.pick());
        fleet.getFleetData().addFleetMember(pickerC.pick());
        fleet.getFleetData().addFleetMember(pickerC.pick());
        if (withCaptain) {             // to test if generating specific character necessary

        }

        fleet.getFleetData().sort();

        return fleet;
    }
[close]

The script further up in that file that the above script references - "createEmptyAIFleet(boolean withCaptain)":
Spoiler
    public static CampaignFleetAPI createEmptyAIFleet(String name, boolean withFaction) {
        CampaignFleetAPI fleet = FleetFactory.createEmptyFleet(Factions.REMNANTS, FleetTypes.PATROL_LARGE, null);

        fleet.setName(name);
        fleet.setNoFactionInName(!withFaction);

        fleet.getStats().getFleetwideMaxBurnMod().modifyMult("tutorial", 0.8f);

        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_ALLOW_TOFF, true);
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_NO_JUMP, true);
        fleet.getMemoryWithoutUpdate().set("$tut_aiDeathFleet", true);

        return fleet;
    }
[close]


[close]

Any advice or spotting bugs is greatly appreciated!


Going to attempt to get back on this now that the mod is released and fairly well showcased. Anyone take a crack at it?

I just have a sinking suspicion its going to take me completely reverse engineering FleetInteractionDialogPluginImpl.java lol
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 01, 2018, 01:11:54 AM
Hmm - looking at the code, not seeing how that might happen - not saying that it couldn't, but definitely not seeing a path that would do that.

I'd expect it to get an autoresolve round in; the delay before the first autoresolve round is .8 to 1.2 seconds, so that would be in line with an autoresolve round happening and then this. What would cause this to happen, then, is one of the fleets deciding to disengage after the autoresolve round, i.e.:

getCombinedOne().getAI().pickEncounterOption(auto.getContext(), getCombinedOne()) == EncounterOption.DISENGAGE

I *think* massively increasing the fleet points value of the station might do the job here, it's the only thing that comes to mind that might. Assuming it's the one picking to run, and not the fleet. The larger fleet strength has to be less than double the weaker to avoid a disengage.
Hmm you're right, the station is disengaging from the fight after the first autoresolve round. I tried forcing its encounter option in resolve() to HOLD_VS_STRONGER / HOLD / ENGAGE but it still disengages after the first round. :(

Worked around it for now by making it run 50 autoresolve rounds at once (within the scope of a single resolve()) when this happens.
I don't want to mess with the FP values too much because of the potential side effects, e.g. if I make the station not run when it's outmatched, the fleet might run when they actually have parity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 04, 2018, 02:43:37 AM
This is probably stupid, but getting a nullpointerexception:

Code
211947 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.CircularOrbitPointDown.advance(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.updateAllOrbits(Unknown Source)
at com.fs.starfarer.campaign.StarSystem.autogenerateHyperspaceJumpPoints(Unknown Source)
at com.fs.starfarer.campaign.StarSystem.autogenerateHyperspaceJumpPoints(Unknown Source)
at data.scripts.world.systems.HMI_hazard.generate(HMI_hazard.java:103)
at data.scripts.world.HMI_gen.generate(HMI_gen.java:20)
at data.scripts.HMI_modPlugin.initHMI(HMI_modPlugin.java:16)
at data.scripts.HMI_modPlugin.onNewGame(HMI_modPlugin.java:24)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.Oo0O.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.j.super(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The region in question:

Code
		JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("hazard_jumpPointB", "Chan Huan Jump-point");
OrbitAPI orbitouter = Global.getFactory().createCircularOrbit(hazard2, 270, 6000, 350);
jumpPoint.setOrbit(orbitouter);
jumpPoint.setRelatedPlanet(hazard2);
jumpPoint.setStandardWormholeToHyperspaceVisual();
system.addEntity(jumpPoint);

// generates hyperspace destinations for in-system jump points
system.autogenerateHyperspaceJumpPoints(true, true);

cleanup(system);
}

Not entirely sure what I've done wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 04, 2018, 10:45:44 AM
Call orbit.setEntity(jumpPoint). It really ought to be a parameter to createXXXOrbit, but isn't for some reason.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 04, 2018, 11:18:52 PM
Call orbit.setEntity(jumpPoint). It really ought to be a parameter to createXXXOrbit, but isn't for some reason.

No dice, I still get the error. The error is specifically at the generate jump points line, if that helps.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 05, 2018, 09:14:16 AM
Ahh, right, you don't need to call setEntity() because that happens in the jumpPoint.setOrbit(orbitouter); method. Forgot about that, explains why it's not a parameter.

That said: can you make sure that commenting out this jump-point removes the crash? Looking at this again, the crash is in a CircularOrbitPointDown, not CircularOrbit, so it's entirely unrelated to the jump-point or to any jump exits the autogenerate() method might create, which would also have CircularOrbits (without PointDown).

What happens is before/after generating new jump-points, the autogen method will update the locations of all entities - in-system, and in-hyper after - by calling advance() on their orbits with a duration of 0. One of these entities has a misconfigured CircularOrbitPointDown and that causes the crash.



(Also, it's probably easier to just set the orbit like this:
jumpPoint.setCircularOrbit(hazard2 ,270, 6000, 350);
But that shouldn't matter here.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 05, 2018, 04:19:28 PM
That said: can you make sure that commenting out this jump-point removes the crash? Looking at this again, the crash is in a CircularOrbitPointDown, not CircularOrbit, so it's entirely unrelated to the jump-point or to any jump exits the autogenerate() method might create, which would also have CircularOrbits (without PointDown).

What happens is before/after generating new jump-points, the autogen method will update the locations of all entities - in-system, and in-hyper after - by calling advance() on their orbits with a duration of 0. One of these entities has a misconfigured CircularOrbitPointDown and that causes the crash.

Well I'm a dumbass. I've been trying to find the star for a CircularOrbitPointDown by using a "system.getEntityById". Replacing this with just the id and nothing else fixes the problem.

Thanks Alex!

EDIT: ...aaaand now I'm back on the spawn fleets from a thing problem. I've tried using the LuddicPathFleetManager as the basis. Glancing at Histidine's SWP interstellar bounty script, and scripts from DR's Templar and Interstellar Imperium, I thought the general gist of what I was attempting should work.

I started changing the references to luddic church / luddic path / kol to the faction name.  While the weighted picker presumably looks through all the markets, it'll pick the one that is owned by the faction to spawn at. I have a planet, that has no actual market, but is owned by the faction, so presumably this should work. It didn't.  I changed the weighted picker from market ownership, to id of the market, thinking it'd search all the markets for that id, and then spawn it from that market. While the market doesn't exist, the id does. That didn't work either. Then I changed it from a market to a planet, thinking that's fix it. It didn't work. Finally, I just searched all entities for that entity (Which I think is the absolute wrongest thing to do). This, again, didn't work.

I feel on some fundamental level I am missing something important. The way I interpret it, is:

-Manager determines max number of fleets - I have this set up identical to the weightedpicker - if the planet is there, spawn 5 fleets, if not (Nexerellin), then don't
-Manager spawns fleet at a place determined by the picker
-Determines size of fleet
-Spawns the fleet for real
-Figures out whether the fleet spawns at a source (which is different from the target...?) or spawns it in hyperspace, depending how close the player is to either (???)
-Gives assignments - raid system, go to system and raid, etc.
-Figures out the target system from a weighted picker

Considering you should be able to spawn fleets from anything (even if it's not a market) using fleetfactoryv2, and it should pick the highest weighted thing (even if it's not a market) to spawn from, and everytime I tried it didn't work, then there is clearly something very wrong with how I'm looking at the problem. Could anyone take this bag of snakes and lay it out straight please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 07, 2018, 08:23:45 PM
Is this an outdated or bugged method or do I have any errors here?

Generic:
PlanetAPI      StarSystemAPI system.addPlanet(String Id, SectorEntityToken focus, String name, String type, Float angle, Float radius, Float orbitRadius, String faction);


This implementation
:

PlanetAPI penumbros = system.addPlanet("penumbros_archeus", star, "Penumbros", "jungle", 45f, 180f, 15000f, 600f);
penumbros.setCustomDescriptionId("planet_penumbros");

Causes this error when clicking "Show Info" on any planet in the same system using the Intel Map:

**Edit** I am now 99.9% sure this is caused by attempting to cast StarSystemAPI ("star") to SectorEntityToken.

Used:         SectorEntityToken focus = (SectorEntityToken) star;
Got Error

Used:         SectorEntityToken focus = star.getOrbitFocus();
No Error

But that puts the planet in the middle of the star since presumably the star's "orbital anchor" is in hyperspace.

Searching for a workaround to still use the star as the orbital focus for the planet.


**Edit 2**: Well... nvm. >:( I must not be adding something to the planet I should be, because:

        StarSystemAPI system = sector.getStarSystem("hybrasil");
        SectorEntityToken focus = system.getCenter();
        PlanetAPI penumbros = system.addPlanet("penumbros_archeus", focus, "Penumbros", "jungle", 145, 180, 7000, 600);

- Makes the planet spawn, and even in the correct location, but I still get the crash when I try to view it on the map.

Spoiler
28316 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.ui.intel.o0OO.void.return$new(Unknown Source)
   at com.fs.starfarer.campaign.ui.intel.o0OO.afterSizeFirstChanged(Unknown Source)
   at com.fs.starfarer.ui.Q.sizeChanged(Unknown Source)
   at com.fs.starfarer.ui.OO0O.set(Unknown Source)
   at com.fs.starfarer.ui.thisnew.super(Unknown Source)
   at com.fs.starfarer.ui.j.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.advance(Unknown Source)
   at com.fs.starfarer.ui.OO00.advanceImpl(Unknown Source)
   at com.fs.starfarer.campaign.ui.intel.O0oO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.advance(Unknown Source)
   at com.fs.starfarer.ui.OO00.advanceImpl(Unknown Source)
   at com.fs.starfarer.campaign.ui.intel.B.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.advance(Unknown Source)
   at com.fs.starfarer.campaign.ui.intel.B.Ò00000(Unknown Source)
   at com.fs.starfarer.ui.newui.if$7.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.newui.if.setCurrentTab(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.showCoreUITab(Unknown Source)
   at com.fs.starfarer.coreui.map.A.super(Unknown Source)
   at com.fs.starfarer.coreui.map.Objectsuper.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

I have narrowed the bug down to these two lines specifically using incremental, controlled rollbacks. The system in question is the Hybrasil system, but I don't think that makes a difference.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 07, 2018, 09:01:01 PM
Considering you should be able to spawn fleets from anything (even if it's not a market) using fleetfactoryv2, and it should pick the highest weighted thing (even if it's not a market) to spawn from, and everytime I tried it didn't work, then there is clearly something very wrong with how I'm looking at the problem. Could anyone take this bag of snakes and lay it out straight please?

IIRC FleetFactoryV2 does need a market - if you don't provide one, it'll look for the nearest one of the same faction, and if that fails, I think it will abort. So if a faction doesn't have any markets, that'll be trouble.


@Morrokain: wait, uhh. "star" is a StarSystemAPI? That makes no sense, the code wouldn't even compile with that as the second parameter.

I did paste this into Hybrasil.java:

PlanetAPI penumbros = system.addPlanet("penumbros_archeus", hybrasil_star, "Penumbros", "jungle", 45f, 180f, 15000f, 600f);
penumbros.setCustomDescriptionId("planet_culann");

And it seemed to work fine - planet shows up, can click show planet info fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 07, 2018, 09:49:08 PM

IIRC FleetFactoryV2 does need a market - if you don't provide one, it'll look for the nearest one of the same faction, and if that fails, I think it will abort. So if a faction doesn't have any markets, that'll be trouble.


@Morrokain: wait, uhh. "star" is a StarSystemAPI? That makes no sense, the code wouldn't even compile with that as the second parameter.

I did paste this into Hybrasil.java:

PlanetAPI penumbros = system.addPlanet("penumbros_archeus", hybrasil_star, "Penumbros", "jungle", 45f, 180f, 15000f, 600f);
penumbros.setCustomDescriptionId("planet_culann");

And it seemed to work fine - planet shows up, can click show planet info fine.

Where is that file? How are you getting hybrasil_star?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on January 07, 2018, 09:58:07 PM
Where is that file?

Code
starsector_core > data > scripts > world > systems > Hybrasil.java

Ain't you making a Total Conversion?  :P Don't tell me you don't know your way around the core files!

(Just jesting, I'm sure there's ample stuff I'm not aware of in the files, let alone the API)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 07, 2018, 10:13:53 PM
Where is that file?

Code
starsector_core > data > scripts > world > systems > Hybrasil.java

Ain't you making a Total Conversion?  :P Don't tell me you don't know your way around the core files!

(Just jesting, I'm sure there's ample stuff I'm not aware of in the files, let alone the API)

 :-[  ::) Omg.

Haha, no I knew at one time.

It actually had been a while since I messed with creating campaign planets (like .5 ish??) and couldn't remember where they were. I was looking in the zipped API folder when I was looking for it originally since that's where the vast majority of .java files are. Ugh I'm dying.

Honestly... forgot about that scripts directory all together and that might be the whole problem.

I was creating it by:


public class archeusGen implements SectorGeneratorPlugin {
   
    @Override
    public void generate(SectorAPI sector) {
        initFactionRelationships(sector);

        new archeusCorvusGen().generate(sector);
        new archeusHybrasilGen().generate(sector);
    }
}

It was based around an older version of Mayorate. You can apparently do this with stations but I'm now guessing not with planets. Guess I'll find out soon...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 07, 2018, 11:05:55 PM

I did paste this into Hybrasil.java:

PlanetAPI penumbros = system.addPlanet("penumbros_archeus", hybrasil_star, "Penumbros", "jungle", 45f, 180f, 15000f, 600f);
penumbros.setCustomDescriptionId("planet_culann");

And it seemed to work fine - planet shows up, can click show planet info fine.

Wow yup, copy-pasted my code into that file, removed the other one, and it solves the issue. Hm. So I guess I have to copy/replace each system file that I want to add things to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 08, 2018, 01:35:27 AM
IIRC FleetFactoryV2 does need a market - if you don't provide one, it'll look for the nearest one of the same faction, and if that fails, I think it will abort. So if a faction doesn't have any markets, that'll be trouble.

What defines a 'market' exactly? Is it a planet? Or is it a planet with an interactable store etc.?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 08, 2018, 04:49:16 AM
IIRC FleetFactoryV2 does need a market - if you don't provide one, it'll look for the nearest one of the same faction, and if that fails, I think it will abort. So if a faction doesn't have any markets, that'll be trouble.

What defines a 'market' exactly? Is it a planet? Or is it a planet with an interactable store etc.?
"Planet/station with store" (or a planet/station combination, like Jangala) is probably a sufficient player-facing description, yeah.

If you don't have or want one, you can create a fake market for the script, like so:
MarketAPI fakeMarket = Global.getFactory().createMarket("spawner_fake_market", "[market name]", [market size]);

Make sure to change your spawner code so that it doesn't try to spawn fleets at the market's location, since the fake market doesn't have one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 08, 2018, 08:40:23 AM

I did paste this into Hybrasil.java:

PlanetAPI penumbros = system.addPlanet("penumbros_archeus", hybrasil_star, "Penumbros", "jungle", 45f, 180f, 15000f, 600f);
penumbros.setCustomDescriptionId("planet_culann");

And it seemed to work fine - planet shows up, can click show planet info fine.

Wow yup, copy-pasted my code into that file, removed the other one, and it solves the issue. Hm. So I guess I have to copy/replace each system file that I want to add things to.

You really shouldn't need to, that code doesn't care where it runs. Well, I mean, if you want autogenerated jump-points related to what you're adding, that could be a problem since that's called from Hybrasil.java etc. But that aside, I don't see why you couldn't do what you're doing - I suspect the issue was how you got the star, and it wasn't the right entity. For example, maybe you got hold of the star's gravity well in hyperspace instead?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 08, 2018, 12:00:05 PM
You really shouldn't need to, that code doesn't care where it runs. Well, I mean, if you want autogenerated jump-points related to what you're adding, that could be a problem since that's called from Hybrasil.java etc. But that aside, I don't see why you couldn't do what you're doing - I suspect the issue was how you got the star, and it wasn't the right entity. For example, maybe you got hold of the star's gravity well in hyperspace instead?

Yeah I don't really understand it myself.  :) The ambiguity of the error makes it quite difficult to place.

The only other thing I could come up with, after pondering it quite a bit, was the use of the "new" operator somehow causing weirdness. At first I thought it was that the star had to just be initialized for some reason, but that doesn't make sense.


My thought process
: When I generated a custom planet and market - literally using the exact same method - in Galatia for use with the tutorial, it seemed to work just fine. The market showed up and you could click "Show Info" on any relevant entity. The market conditions appeared, etc. That's why I blindly re-used that method in 3 new systems, because it seemed "tried and tested." Not so.

Now, the only difference between anything implemented between those two planets is that one has a custom implemented market script, like Derinkuyu, and one does not. So, also like Derinkuyu, the market is added to the global economy during: ArcheusTutorialMissionEvent.endGalatiaPortionofMission() using:

        Global.getSector().getEconomy().addMarket(eldrus.getMarket());

where:

"eldrus" is returned by:

        SectorEntityToken eldrus = system.getEntityById("eldrus");


That being said, I had originally populated two additional planets in Isirah, again same method, and added markets to them using a .JSON file in the data/campaign/econ directory - and that also causes the error.  ::)
The market works fine, you can go there, see fleets spawn, even dock and buy things but the second you try and view the planet info, or any other planet that would pull its info within its range, you get the error.


Edit** Ok... you know what, looking at it again, I wonder if the key here is:

system.getEntityById("eldrus")

being used to put the market into the economy.


So,
Here is the script generating eldrus in galatia:
Spoiler
        StarSystemAPI system = sector.getStarSystem("galatia");

        // create the star and generate the hyperspace anchor for this system
        PlanetAPI star = system.getStar();

        // SectorEntityToken creation goes from star -> fringe
        PlanetAPI eldrus = system.addPlanet("eldrus", star, "Eldrus", "barren", 130f, 120f, 12000f, 600f);
        eldrus.setCustomDescriptionId("planet_eldrus");
        eldrus.setFaction(ArcheusFactions.ARCHEUS);
        eldrus.setInteractionImage("illustrations", "vacuum_colony");


        // create a market for eldrus - not connected to the rest of the economy to start with
        MarketAPI market = Global.getFactory().createMarket("eldrus_market", eldrus.getName(), 0);
        market.setSize(1);

        market.setSurveyLevel(MarketAPI.SurveyLevel.FULL);
        market.setPrimaryEntity(eldrus);

        market.setFactionId(eldrus.getFaction().getId());
        market.addCondition(Conditions.POPULATION_2);
        market.addCondition(Conditions.OUTPOST);

        market.addSubmarket(Submarkets.SUBMARKET_OPEN);
        market.addSubmarket(Submarkets.SUBMARKET_BLACK);
        market.addSubmarket(Submarkets.SUBMARKET_STORAGE);

        eldrus.setMarket(market);
        market.getCommDirectory().addMissionBoard();
        eldrus.addScript(new GalatiaMarketScript(market));

[close]

And one making a station in corvus:
Spoiler
        StarSystemAPI system = sector.getStarSystem("corvus");
        PlanetAPI star = system.getStar();

        //add station
        SectorEntityToken tg_station = system.addCustomEntity("jangalas_rest_station", "Jangala's Rest", "station_side02", ArcheusFactions.TRADERGUILDS);
        tg_station.setCircularOrbitPointingDown(star, 315f, 7000f, 360f);
        tg_station.setCustomDescriptionId("traderguilds_station_corvus");
[close]

The station has a market added through the .JSON file. -No error.

The planet has a market added to the global economy as displayed above. -No error.

Now if I put this:
Spoiler
        PlanetAPI penumbros = system.addPlanet("penumbros_archeus", star, "Penumbros", "jungle", 145, 180, 7000, 600);
        penumbros.setCustomDescriptionId("planet_penumbros");

        SectorEntityToken fortress = system.addCustomEntity("eldritch_fortress", "Eldritch Fortress", "station_side03", ArcheusFactions.ARCHEUS);
        fortress.setCircularOrbitPointingDown(system.getEntityById("penumbros_archeus"), 140f, 250f, 600f);
        fortress.setCustomDescriptionId("eldritch_fortress");
        fortress.setInteractionImage("illustrations", "eldritch_fortress");
[close]

 in either file at all, whether I add a market through the JSON file, or not, but I don't do what I did with Eldrus and add a market to the global economy in ArcheusTutorialMissionEvent.endGalatiaPortionofMission() like above. -Error.

That's the extent to which I understand what's going on. So, if anyone sees something I don't here please let me know! I would really like to not run into this error again in the future.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 08, 2018, 02:56:18 PM
Make sure to change your spawner code so that it doesn't try to spawn fleets at the market's location, since the fake market doesn't have one.

Um, forgive me Hist, but, how? I could set up the weighted picker to pick the fake market, but then how do you tell the game to spawn from an object and not the market? I think this is the fundamental things I couldn't, and still can't, wrap my head around. I mean, I think I can see bits and pieces in the IBB script about picking the nearest market, and a separate picker that picks a hideout location, with the idea that the IBB fleet picks the market then spawns at the hideout location, but what I don't understand is how this is done.

Regardless, you and Alex have been a tremendous help thus far, and I thank you profusely for helping me out thus far.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NightKev on January 09, 2018, 04:51:13 AM
I've been trying to change the personality of a ship based on which hullmod it has (no effect if the ship has an officer) and so far I think I've been successful, but there doesn't seem to be a way to detect when hullmods are removed and thus restore the ship to the default "Steady" personality, since it seems changing the ship's personality is permanent (unless I've missed a non-permanent method of doing it?). Is there any way to work around this?

For reference, the code for my hullmod is here:
Code
package org.tc.autonomous;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import org.apache.log4j.Logger;

public abstract class AbstractPersonalityHullMod extends BaseHullMod {
    private static Logger LOG = Global.getLogger(AutonomousCommandsPlugin.class);
    private static final String PREFIX = "autonomous_personality_";

    private String personality;

    AbstractPersonalityHullMod(String personality) {
        this.personality = personality;
    }

    @Override
    public boolean isApplicableToShip(ShipAPI ship) {
        for (String hullMod : ship.getVariant().getHullMods()) {
            if (hullMod.startsWith(PREFIX) && !hullMod.equals(PREFIX + personality)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public String getUnapplicableReason(ShipAPI ship) {
        return "Personality hullmods are mutually exclusive";
    }

    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {
        if (ship.getCaptain() != null && ship.getCaptain().isDefault()) {
            ship.getCaptain().setPersonality(personality);
            LOG.info("Personality [" + personality + "] applied to ship [" + ship.getName() + "]");
        }
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 09, 2018, 06:17:13 AM
Make sure to change your spawner code so that it doesn't try to spawn fleets at the market's location, since the fake market doesn't have one.

Um, forgive me Hist, but, how? I could set up the weighted picker to pick the fake market, but then how do you tell the game to spawn from an object and not the market? I think this is the fundamental things I couldn't, and still can't, wrap my head around. I mean, I think I can see bits and pieces in the IBB script about picking the nearest market, and a separate picker that picks a hideout location, with the idea that the IBB fleet picks the market then spawns at the hideout location, but what I don't understand is how this is done.
Code: java
CampaignFleetAPI fleet = FleetFactoryV2.createFleet(params);

SectorEntityToken spawnEntity = methodToGetASpawnPoint();  // like a planet or such
LocationAPI location = spawnEntity.getContainingLocation();  // a star system, or hyperspace
// adds our new fleet into the containing location
location.addEntity(fleet);
// positions fleet on top of the spawn entity
fleet.setLocation(spawnEntity.getLocation().x, spawnEntity.getLocation().y);

Or to spawn in hyperspace near the player, LuddicPathFleetManager does this:
Code: java
Vector2f loc = Misc.pickHyperLocationNotNearPlayer(target.getLocation(), Global.getSettings().getMaxSensorRange() + 500f);
Global.getSector().getHyperspace().addEntity(fleet);
fleet.setLocation(loc.x, loc.y);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 09, 2018, 10:42:01 AM
I've been trying to change the personality of a ship based on which hullmod it has (no effect if the ship has an officer) and so far I think I've been successful, but there doesn't seem to be a way to detect when hullmods are removed and thus restore the ship to the default "Steady" personality, since it seems changing the ship's personality is permanent (unless I've missed a non-permanent method of doing it?). Is there any way to work around this?

Hmm - one thing that comes to mind is creating a ship AI in your mod's ModPlugin.pickShipAI() and using the ShipAIConfig.personalityOverride to set the personality, which will only last for the duration of the battle.

See: CoreLifecyclePluginImpl.pickShipAI() for an example of how that might work. That one sets a specific AI config for automated ships; in your case you'd test for the presence of your relevant hullmods and set the personality override based on that.

This will not be compatible with mods that modify ship AI, though - i.e. if another mod wants to modify the ship AI config based on some parameters, only one will take effect - but I'm not sure how much of a practical issue that is.

Edit: added ShipAIPlugin.getConfig() method to make this sort of stuff easier and doable on the fly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 11, 2018, 01:36:10 AM
Code: java
CampaignFleetAPI fleet = FleetFactoryV2.createFleet(params);

SectorEntityToken spawnEntity = methodToGetASpawnPoint();  // like a planet or such
LocationAPI location = spawnEntity.getContainingLocation();  // a star system, or hyperspace
// adds our new fleet into the containing location
location.addEntity(fleet);
// positions fleet on top of the spawn entity
fleet.setLocation(spawnEntity.getLocation().x, spawnEntity.getLocation().y);

Or to spawn in hyperspace near the player, LuddicPathFleetManager does this:
Code: java
Vector2f loc = Misc.pickHyperLocationNotNearPlayer(target.getLocation(), Global.getSettings().getMaxSensorRange() + 500f);
Global.getSector().getHyperspace().addEntity(fleet);
fleet.setLocation(loc.x, loc.y);


Hot Damn Histidine thank you! I finally have a working script that spawns things from entities! Many thanks for the help, Hist!

EDIT: ...aaaand now something has gone horribly wrong.

I've been using GetMaxFleets to try and keep the amount of spawned fleets low. For the following example, I have set the number of fleets for the red and orange faction (and probably every single other unidentified contact in the following image) to 1:

Spoiler
(https://i.imgur.com/AV1PqvY.png)
[close]

Yeah, that hasn't happened.

Now, I currently have three different fleetmanagers within this mod, and one of them has a maxfleets of 10, and the other two has their MaxFleets set to 1. So, within the context of a single mod, if you set different maxfleets, does it just pick the largest and use it for all of them? Or am I doing something horrifically wrong?

Code
public class DracoFleetManager extends BaseLimitedFleetManager {
public static int DRACO_MAX_FLEETS = 1;

@Override
protected int getMaxFleets() {
return DRACO_MAX_FLEETS;
}
...

Code
public class MessFleetManager extends BaseLimitedFleetManager {
public static int MESS_MAX_FLEETS = 10;

@Override
protected int getMaxFleets() {
return MESS_MAX_FLEETS;
}
...

Code
public class FangFleetManager extends BaseLimitedFleetManager {
public static int FANG_MAX_FLEETS = 1;

@Override
protected int getMaxFleets() { return FANG_MAX_FLEETS; }
...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 13, 2018, 07:20:35 AM
How easy would it be to remove the flux generation of the "Engage Fighters" command?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 13, 2018, 10:04:24 AM
How easy would it be to remove the flux generation of the "Engage Fighters" command?

Basically impossible, it's hardcoded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 13, 2018, 10:26:36 AM
How easy would it be to remove the flux generation of the "Engage Fighters" command?

Basically impossible, it's hardcoded.

Ah ok that's what I suspected. Thanks!  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 13, 2018, 08:21:31 PM
Update on my rampant spawning bug, check the log. I am bamboozled.

The message is consistent when looking for the fleet manager:

Code
508730 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - 0 out of a maximum 1 fleets in play for [data.campaign.fleets.DracoFleetManager]
508735 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - Could not spawn fleet - returned null
508735 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - 0 out of a maximum 1 fleets in play for [data.campaign.fleets.FangFleetManager]
508741 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - Could not spawn fleet - returned null

This is clearly wrong, as the game is spawning the fleets at the right place, but doesn't seem to be aware that it is spawning the fleet. Or it's spawning the fleet on a null response? But then, why is it working for the Mess faction file, but not these two, considering the coding language is almost identical? I am really confused by this - would anyone have an inkling of what I've done wrong?

EDIT: There was some remaining code from the LuddicPathFleetManager that looked for a source market. Without this section of code, the fleetmanager worked perfectly. I still don't get why the fleetmanager worked the way it did though.

Many thanks for everyone for the help!

EDIT2: So, so very sorry guys. The absolutely final question I'll ask for the forseeable future: How does one effect the post-battle loot drops? I've taken a gander through the core game and the Templar mod, as well as the forum and it's not really clear to me. Aim is to add a commodity to drop post-battle for a specific faction - not from an event, but in general. Now I've seen something in the SeededRemnantFleetManager about this, but it refers to tags which as far as I can tell, don't actually match with the commodity information. If anyone could put me to rights, I'd appreciate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on January 14, 2018, 08:14:18 PM
Quick question, is it possible to reduce the range of weapons only for a single mount type? I'm looking to reduce the range of only ballistic weapons with a hullmod.

Specifically, I'm looking to reduce ballistic weapon range by 100 for smalls, 200 for mediums, and 300 for larges. Might add a PD exception.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 14, 2018, 08:50:11 PM
There's MutableShipStatsAPI.getBallisticWeaponRangeBonus() (which I guess you're aware of), but that's not going to let you differentiate by mount size, and there's nothing that I'm aware of that would.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on January 14, 2018, 08:54:05 PM
Yeah, I found that just as I hit send; I'm kind of an idiot.

I'll go with a flat percentage, then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 14, 2018, 11:13:12 PM
Quick question, is it possible to reduce the range of weapons only for a single mount type? I'm looking to reduce the range of only ballistic weapons with a hullmod.

Specifically, I'm looking to reduce ballistic weapon range by 100 for smalls, 200 for mediums, and 300 for larges. Might add a PD exception.

This code should filter by what you are looking for- Only ballistic, different values for small, medium, large- and a PD exception. But, I haven't found a method to modify the range of those weapons. Not sure you can.

Spoiler
   public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
      List weapons = ship.getAllWeapons();
      Iterator iter = weapons.iterator();
      while (iter.hasNext()) {
         WeaponAPI weapon = (WeaponAPI)iter.next();
         if (weapon.getType() == WeaponType.BALLISTIC && !weapon.hasAIHint(WeaponAPI.AIHints.PD)) {
             if (weapon.getSize() == WeaponSize.LARGE) {
                    weapon.getRange();
                }
                if (weapon.getSize() == WeaponSize.MEDIUM) {
                    weapon.getRange();
                }
                if (weapon.getSize() == WeaponSize.SMALL) {
                    weapon.getRange();
                }
            }
        }
    }
[close]

                   " weapon.getRange();" Is the placeholder for the actual code to modify the weapon's range. It wouldn't do that, itself.

I've only modified range across all weapons of a type using MutableShipStatsAPI and I don't think that would work here.

This will get you started though, in case someone knows something I don't.  ;)

**Edit** Submitted this late it seems. It was already pretty much answered. Still, something useful I guess.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on January 15, 2018, 03:32:02 AM
Apologies if this has already been asked, but the search function isn't helping much;

How does one go about creating a binary star system, or more specifically a binary star system with both stars circling a central point? I have tried using StarSystemAPI.initNonStarCenter and then adding the stars  and running autogenerateHyperspaceJumpPoints(causes crash upon viewing the system, I suspect jump points are behind it), doing the same without running autogenerateHyperspaceJumpPoints (no crash, but the system cannot be entered, not even from manually added jump points), and have also attempted to declare two stars and then move them programmatically (causes only one star to spawn, and makes only the Corona move, but otherwise works).

What would be the correct way to do it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2018, 09:26:17 AM
Can you take a look at the com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator code? The system type you're interested in is BINARY_CLOSE, and the method that adds the stars is addStars(). There may be a bit more to it than just that method but it should be in that file as well.

Taking a very brief look, I *think* the salient part may be that the primary star is created using initStar(), while the secondary uses addPlanet().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2018, 09:30:00 AM
EDIT2: So, so very sorry guys. The absolutely final question I'll ask for the forseeable future: How does one effect the post-battle loot drops? I've taken a gander through the core game and the Templar mod, as well as the forum and it's not really clear to me. Aim is to add a commodity to drop post-battle for a specific faction - not from an event, but in general. Now I've seen something in the SeededRemnantFleetManager about this, but it refers to tags which as far as I can tell, don't actually match with the commodity information. If anyone could put me to rights, I'd appreciate it.

Hmm - looking at RemnantSeededFleetManager, I'm not seeing what you mean about tags. It looks like it's just adding a RemnantFleetInteractionConfigGen to the spawned fleet's memory (in addRemnantInteractionConfig()), which adds AI cores to the salvage based on ship losses, and does a few other optional things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on January 15, 2018, 01:22:34 PM
Can you take a look at the com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator code? The system type you're interested in is BINARY_CLOSE, and the method that adds the stars is addStars(). There may be a bit more to it than just that method but it should be in that file as well.

Taking a very brief look, I *think* the salient part may be that the primary star is created using initStar(), while the secondary uses addPlanet().

Thanks, that did it; the first star has to be initialized with initStar() while all other has to be initialized using addPlanet(). Using two initStar() causes wierd teleportation behaviour and invisible stars, while using two addPlanet() prevents hyperspace locations from being properly spawned and causes a nullpointer error when viewing the system.

Actually changing their rotation point was simply a matter of creating a centerpoint and setting the first star's orbit around it manually afterwards (since initStar doesn't take an orbit as an argment).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2018, 01:37:55 PM
Cool, glad you got it working!

Actually changing their rotation point was simply a matter of creating a centerpoint and setting the first star's orbit around it manually afterwards (since initStar doesn't take an orbit as an argment).

Btw, if you want them to orbit around (0, 0), you could make system.getCenter() the focus of the orbit - the init-non-star-center method creates a sector entity token in the middle of the system for this purpose. Creating another sector entity token manually to serve as the orbit focus will work no problem, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 16, 2018, 01:51:25 AM
Hmm - looking at RemnantSeededFleetManager, I'm not seeing what you mean about tags. It looks like it's just adding a RemnantFleetInteractionConfigGen to the spawned fleet's memory (in addRemnantInteractionConfig()), which adds AI cores to the salvage based on ship losses, and does a few other optional things.

I was refering to the bit underneath the interaction config line in RemnantSeededFleetManager:

Code
	
public static void addRemnantAICoreDrops(Random random, CampaignFleetAPI fleet, float mult) {
if (random == null) random = new Random();
long salvageSeed = random.nextLong();
fleet.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SEED, salvageSeed);

int [] counts = new int[3];
String [] groups = new String [] {Drops.AI_CORES1, Drops.AI_CORES2, Drops.AI_CORES3};
for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
if (member.isCapital()) {
counts[2] += 2;
} else if (member.isCruiser()) {
counts[2] += 1;
} else if (member.isDestroyer()) {
counts[1] += 1;
} else if (member.isFrigate()) {
counts[0] += 1;
}
}

if (fleet.isStationMode()) {
counts[2] += 10;
}

for (int i = 0; i < counts.length; i++) {
int count = counts[i];
if (count <= 0) continue;

DropData d = new DropData();
d.group = groups[i];
d.chances = (int) Math.ceil(count * mult);
fleet.addDropRandom(d);
}

}

The drops lines tie in to tags, and I can't figure out where the tags point. I kind of want to figure out how to use this code, but I'm unsure how to add a custom commodity (and for future use, AI core) to this list. Am I looking at the wrong thing to start with?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 16, 2018, 02:39:52 AM
Templars mod adds Templar Flux Core drops by adding them to the cargo of the fleets it generates.

The other easy way is to use reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot) in a CampaignEventListener. Here's an example. (https://bitbucket.org/Histidine/ai-war-ss/src/20616ceea77f26ab7a99311cff8acb92c92f5299/jars/src/data/scripts/campaign/AIW_CampaignManager.java?at=master&fileviewer=file-view-default#AIW_CampaignManager.java-25)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NightKev on January 16, 2018, 06:15:50 AM
A couple questions about `BaseHullMod.advanceInCombat(ShipAPI ship, float amount)`:
- How often is this called?
- What is "amount"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on January 16, 2018, 07:16:22 AM
A couple questions about `BaseHullMod.advanceInCombat(ShipAPI ship, float amount)`:
- How often is this called?
- What is "amount"?
A - It should call it every frame (so hopefully 60 times per second)

B - How much time has actually passed since the last time it was called (so around 1/60 of a second if no lag is experienced)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on January 17, 2018, 03:26:49 AM
Templars mod adds Templar Flux Core drops by adding them to the cargo of the fleets it generates.

The other easy way is to use reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot) in a CampaignEventListener. Here's an example. (https://bitbucket.org/Histidine/ai-war-ss/src/20616ceea77f26ab7a99311cff8acb92c92f5299/jars/src/data/scripts/campaign/AIW_CampaignManager.java?at=master&fileviewer=file-view-default#AIW_CampaignManager.java-25)

I thought the Templars did that, but I couldn't figure out where they did that. I checked both the cheat fleet and the fleet factory files and it didn't add them.

Regards, using reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot) worked like a charm. Many thanks Histidine!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 17, 2018, 08:35:20 AM
I was refering to the bit underneath the interaction config line in RemnantSeededFleetManager:

...
The drops lines tie in to tags, and I can't figure out where the tags point. I kind of want to figure out how to use this code, but I'm unsure how to add a custom commodity (and for future use, AI core) to this list. Am I looking at the wrong thing to start with?

Ahh, ok. Take a look at data/campaign/procgen/drop_groups.csv - a lot of the random drops from exploration etc are handled through those.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 17, 2018, 10:56:50 PM
sup, FS.
is there a way i can get all ships within sertain distance from a beam, i.e. inside a rectangular area, parallel to a beam?
Spoiler
(https://i.imgur.com/ehKmzoj.jpg)
[close]
also how can i prevent getnearestally(ship_sample) from picking ship_sample's modules, and instead pick next nearest ally.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on January 18, 2018, 12:11:06 AM
sup, FS.
is there a way i can get all ships within sertain distance from a beam, i.e. inside a rectangular area, parallel to a beam?
Spoiler
(https://i.imgur.com/ehKmzoj.jpg)
[close]
also how can i prevent getnearestally(ship_sample) from picking ship_sample's modules, and instead pick next nearest ally.

My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.


As for the beam... it's possible to get the formula for that area mathematically and then check all enemies in range to see if they fit the formula. But i suspect that is far from the easiest solution, and the formula itself would grow fairly complicated.

Another solution would be to iterate a large amount of circular areas along the beam (simply moving the center coordinate from beamStart to beamEnd with sufficiently small steps), though i doubt that would be particularly performance-friendly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 18, 2018, 12:31:21 AM
My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.
i meant AIUtils.getNearestAlly(beam.getSource()). it just returns nearest ally. and if source ship has modules, they will be closer  to source than any other ship.
i can't actually put anything inside, that's lazylib function.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on January 18, 2018, 01:05:30 AM
My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.
i meant AIUtils.getNearestAlly(beam.getSource()). it just returns nearest ally. and if source ship has modules, they will be closer  to source than any other ship.
i can't actually put anything inside, that's lazylib function.

Aha. That makes things more difficult.

My recommendation is to instead run AIUtils.getNearbyAllies and then manually run a loop to see which is closest. You'll have to input a range, but if you want it global just input a really high one. This would allow you to ignore modules through the previously mentioned "if" function, though it is not quite as compact code-wise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 18, 2018, 01:32:40 AM
My recommendation is to instead run AIUtils.getNearbyAllies and then manually run a loop to see which is closest. You'll have to input a range, but if you want it global just input a really high one. This would allow you to ignore modules through the previously mentioned "if" function, though it is not quite as compact code-wise.
then i face another problem, since i keep getting "assignment conversion error" whenever i am trying to make a list of targets.  probably due to not having a .jar.
thanks for the help anyway
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on January 18, 2018, 02:54:38 AM
My recommendation is to instead run AIUtils.getNearbyAllies and then manually run a loop to see which is closest. You'll have to input a range, but if you want it global just input a really high one. This would allow you to ignore modules through the previously mentioned "if" function, though it is not quite as compact code-wise.
then i face another problem, since i keep getting "assignment conversion error" whenever i am trying to make a list of targets.  probably due to not having a .jar.
thanks for the help anyway

Are you attempting to make a List() or an ArrayList()? An ArrayList() should still work without the .jar (this is what I run on my AI scripts, which are not compiled).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 18, 2018, 04:39:31 AM
i think i set up the IDEA so thee problem is obsoleetee now.

good suggestion, but too late.

thanks anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 24, 2018, 11:03:39 AM
Spoiler
(https://i.imgur.com/ehN4wUo.png)
[close]
Hello, i have somes problems with ship with module.
No problem when this is the player who out this ship, but the ennemi do not spawn the module like you can see on this beautiful screenshoot taken per Kusar.

I have found nothing wrong on that, someone have a idea? Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on January 24, 2018, 01:50:52 PM
Does it has the SHIP_WITH_MODULE tag?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 24, 2018, 01:54:54 PM
Does it has the SHIP_WITH_MODULE tag?

Yep, he have not., this is fun to lose 1 hours to check the difference with my another ship who work and see any difference:
Spoiler
(https://i.imgur.com/bUu7TgX.png)
[close]

Thank you xD
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 24, 2018, 06:36:24 PM
Was trying to write a Mission that would allow a player to renounce their Commission without having to do anything illegal to lower their Reputation with the Faction.

I'm really confused about how the Mission structure works here and what, exactly, I'm supposed to do to alter this. 

The problem here is that there is this trifold structure:

FactionCommissionMissionEvent appears to control what happens once the "Accept" button is pressed... but does not alter whether or not the button appears in the Missions boards.

FactionCommissionMission appears to control whether the Mission is displayed in the UI, but doesn't control what happens when we attack Bounties, neutral parties, etc., etc.

Both of these appear to be hard-referenced by CoreLifeCyclePlugin, as well, which means that modification is... difficult, because that touches so much other code.

It's also very unclear how, exactly, we're supposed to inject Missions into the UI.

So...

1.  How do we detect whether a given Mission is currently active?
2.  How do we inject a Mission into the UI (i.e., offer to annul the Commission) if 1 is true?
3.  Can we invoke public code in that other Mission to end it?

That seems like the route to success here.  It's just a little messy under the hood and it's a little hard to see what to do with this system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 25, 2018, 03:38:33 AM
As you've already observed, CampaignMission objects are only used for the board, while the event handles logic for when the mission is ongoing.

1.  How do we detect whether a given Mission is currently active?
An active mission will have an event, so look for that with Global.getSector().getEventManager().isOngoing(null, eventTypeId)
(To check for the presence of a mission on a board, use the sector mission board API: Global.getSector().getMissionBoard())

Quote
2.  How do we inject a Mission into the UI (i.e., offer to annul the Commission) if 1 is true?
missionBoard.makeAvailableAt(missionObject, market)
Do this for every market where the mission will need displaying

Quote
3.  Can we invoke public code in that other Mission to end it?
Code: java
        CampaignEventPlugin eventSuper = sector.getEventManager().getOngoingEvent(null, Events.FACTION_COMMISSION);
        if (eventSuper == null) return;
        sector.getEventManager().endEvent(eventSuper);
But! This has a bug: the commission event does not fully end. It persists in the intel screen list of missions, and its isDone() method returns false, although its callins are no longer called.

Spoiler
(https://i.imgur.com/JtAZAiM.png)
[close]

Depending on what you're doing, you could override the vanilla event; change its class in events.json to a child class whose endEvent() method is public. I expect problems if more than one mod decides to do this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 25, 2018, 09:41:03 AM
Yeah, that (mod conflicts) was also on my mind with this.

I'm not sure that the problem with the Commission ending is a bug, per se, more like something acting a little wonky:

Code
	private boolean ended = false;
private void endEvent() {
ended = true;

Global.getSector().getCharacterData().getMemoryWithoutUpdate().unset(MemFlags.FCM_FACTION);
Global.getSector().getCharacterData().getMemoryWithoutUpdate().unset(MemFlags.FCM_EVENT);
}

This only gets invoked if:

Code
		RepLevel level = faction.getRelToPlayer().getLevel();
if (!level.isAtWorst(RepLevel.NEUTRAL)) {
endEvent();
Global.getSector().reportEventStage(this, "annul", findMessageSender(),
MessagePriority.ENSURE_DELIVERY,
new BaseOnMessageDeliveryScript() {
public void beforeDelivery(CommMessageAPI message) {

}
});
}

So, if that isn't happening... it won't ever return true.  Not a bug, per se, more of an oversight, because of the "you can take this Commission back later if your Reputation rises again" is probably taking place... whereas what is probably the right answer is to run cleanup()... I'll take a look at this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 25, 2018, 10:13:30 AM
Ah, yeah, this is becoming more clear.  I think that cleanup() needs to be invoked in FactionCommissionMission, not FactionCommissionEvent.

So... I need to write a watcher as an EveryFrameScript that will populate the Mission Board with the anti-mission if the player has accepted a Commission; when the anti-mission is "accepted", it should nuke the FactionCommissionMission via cleanup() and let FactionCommissionMissionCreator do its thing. 

Should be clean and easy, and if it works, feel free to port.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 25, 2018, 12:22:47 PM
Got it. 

I've gotten the bug you encountered dealt with, too; players can renounce their Commission (without losing rep) and take up the Commission again, any time they wish, and it's showing up correctly in the Intel screen.

Thanks much for the help understanding this.

Here's code, feel free to port:

EveryFrameScript for master control; needs to be started up by the ModPlugin.
Code: java
package data.scripts;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.MissionBoardAPI;
import com.fs.starfarer.api.campaign.MissionBoardAPI.MissionAvailabilityAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.util.Misc;
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("unchecked")
public class CommissionEndScript implements EveryFrameScript {

private final MissionBoardAPI board;
private final IntervalUtil tracker = new IntervalUtil(0.25f, .75f);

public CommissionEndScript() {
board = Global.getSector().getMissionBoard();
}

    //EveryFrameScripts must implement these
    @Override
    public boolean isDone()
    {
        return false;
    }

    @Override
    public boolean runWhilePaused()
    {
        return false;
    }

    @Override
    public void advance(float amount)
    {
float days = Global.getSector().getClock().convertToDays(amount);
tracker.advance(days);
if (tracker.intervalElapsed() && Misc.getCommissionFactionId() != null) {
// which factions need to have commissions on offer?
List<FactionAPI> factions = new ArrayList<>();
for (FactionAPI faction : Global.getSector().getAllFactions()) {
if(faction.getId().equalsIgnoreCase(Misc.getCommissionFactionId())) factions.add(faction);
}

// sync missions available with list of what needs to be on offer
for (MissionAvailabilityAPI ma : board.getMissionsCopy()) {
if (ma.getMission() instanceof FactionCommissionMissionAnnul) {
FactionCommissionMissionAnnul fcm = (FactionCommissionMissionAnnul) ma.getMission();
if (!factions.contains(fcm.getFaction())) {
board.removeMission(fcm, true);
} else {
fcm.setTimestamp(Global.getSector().getClock().getTimestamp());
factions.remove(fcm.getFaction());
}
}
}
//Just create this mission for the Faction we're allied with.
for (FactionAPI faction : factions) {
createMission(faction);
}
}
    }

protected void createMission(FactionAPI faction) {
FactionCommissionMissionAnnul mission = new FactionCommissionMissionAnnul(faction.getId());
for (MarketAPI market : Global.getSector().getEconomy().getMarketsCopy()) {
if (market.getFaction() == faction) {
board.makeAvailableAt(mission, market);
}
}
}
}

Core mission script, basically does the real work here:
Code: java
package data.scripts;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.MissionBoardAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.MissionBoardAPI.MissionAvailabilityAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.events.CampaignEventManagerAPI;
import com.fs.starfarer.api.campaign.events.CampaignEventPlugin;
import com.fs.starfarer.api.impl.campaign.missions.BaseCampaignMission;
import com.fs.starfarer.api.impl.campaign.missions.FactionCommissionMissionEvent;
import com.fs.starfarer.api.util.Misc;

public class FactionCommissionMissionAnnul extends BaseCampaignMission {
private FactionAPI faction;

public FactionCommissionMissionAnnul(String factionId) {
this.faction = Global.getSector().getFaction(factionId);

CampaignEventManagerAPI eventManager = Global.getSector().getEventManager();
event = eventManager.primeEvent(null, "faction_commission_annul", this);
}

@Override
public void advance(float amount) {
super.advance(amount);
}

public FactionAPI getFaction() {
return faction;
}

@Override
public String getFactionId() {
return faction.getId();
}

@Override
public String getPostingStage() {
return super.getPostingStage();
}

@Override
public String getName() {
return Misc.ucFirst(faction.getDisplayName()) + " Commission Renounce";
}

@Override
public void playerAccept(SectorEntityToken entity) {
super.playerAccept(entity);

//Remove this after accepted.
MissionBoardAPI board = Global.getSector().getMissionBoard();
for (MissionAvailabilityAPI ma : board.getMissionsCopy()) {
if (ma.getMission() instanceof FactionCommissionMissionAnnul) {
FactionCommissionMissionAnnul fcm = (FactionCommissionMissionAnnul) ma.getMission();
board.removeMission(fcm, true);
}
}

//We are doing some silly stuff here; essentially bumping player Reputation down, triggering the end of the Commission, then back up. 
//The key here to resolving that Intel bug is that we're calling Advance() before we call cleanup(), so that the FactionCommissionMissionEvent runs properly.
//Works, though!

FactionAPI commFaction = Misc.getCommissionFaction();
float rep = commFaction.getRelationship("player");
commFaction.setRelationship("player", RepLevel.SUSPICIOUS);
FactionCommissionMissionEvent tEvent = Misc.getCommissionEvent();
if(tEvent != null){
tEvent.advance(1f);
tEvent.cleanup();
}
commFaction.setRelationship("player", rep);
}

@Override
public boolean canPlayerAccept() {
return true;
}

@Override
public CampaignEventPlugin getPrimedEvent() {
return event;
}
}

This is a dummy Mission Event, pretty much just here to support the UI code that expects one.
Code: java
package data.scripts;

import java.awt.Color;
import java.util.List;
import java.util.Map;

import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.events.CampaignEventTarget;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.impl.campaign.events.BaseEventPlugin;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.Misc.Token;
import java.util.ArrayList;

public class FactionCommissionMissionAnnulEvent extends BaseEventPlugin {
private FactionCommissionMissionAnnul mission = null;

@Override
public void init(String type, CampaignEventTarget eventTarget) {
super.init(type, eventTarget, false);
}

protected Object readResolve() {
return this;
}

@Override
public void setParam(Object param) {
mission = (FactionCommissionMissionAnnul) param;
faction = mission.getFaction();
getEventTarget().getEntity().setFaction(mission.getFaction().getId());
}

@Override
public void startEvent() {
super.startEvent(true);
}

@Override
public void advance(float amount) {
}

@Override
public boolean callEvent(String ruleId, final InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
return true;
}

@Override
public Map<String, String> getTokenReplacements() {
Map<String, String> map = super.getTokenReplacements();
map.put("$sender", faction.getDisplayName());
addFactionNameTokens(map, "other", faction);
return map;
}

@Override
public String[] getHighlights(String stageId) {
List<String> result = new ArrayList<>();
addTokensToList(result, "");
return result.toArray(new String[0]);
}

@Override
public Color[] getHighlightColors(String stageId) {
return super.getHighlightColors(stageId);
}

@Override
public boolean isDone() {
return true;
}

@Override
public String getEventName() {
return Misc.ucFirst(faction.getDisplayName()) + " Commission - annulled";
}

@Override
public CampaignEventCategory getEventCategory() {
return CampaignEventCategory.MISSION;
}

@Override
public String getEventIcon() {
return faction.getCrest();
}
}

In events.json:
Code
	# missions - DO NOT supply the "image" parameter, it's not used anywhere
# implement CampaignEventPlugin.getEventIcon() instead.
"faction_commission_annul":{
"script":"data.scripts.FactionCommissionMissionAnnulEvent",
},

In reports.csv (not sure if both are necessary, but heck, why not):
Code
# faction commission annul,,,,,,,,,,,,
faction_commission_annul,posting,,,posting,"Removes your obligation to this Faction.","You will no longer be allied with this Faction.",,,,important,,
faction_commission_annul,accept,,,secure_comm,posting,"Removes your obligation to this Faction.","You will no longer be allied with this Faction.",,,important,,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 29, 2018, 06:50:26 AM
How do I reload rules.csv in devmode? The old "drag file to another folder, undo" thing no longer seems to work in 0.8.1a.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 29, 2018, 08:42:26 AM
Hmm - as far as I'm aware, nothing about how that works has changed. Can you try actually making a meaningless edit to the file? It might be your OS decided to treat the move/move back differently somehow...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 30, 2018, 01:36:17 AM
sup, FS!
how can i get shield center coordinates and shield radius of a target ship?
how can i get a point, that is different from weapon.getlocation by known amount. i.e. get weapon barrel end coordinates?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NightKev on January 30, 2018, 03:43:22 AM
For shield information, it looks like you can do `ShipAPI.getShield()` which returns a `ShieldAPI` object with information about the ship's shields, which you can then query for more information (cf: this section of the Starfarer API javadoc (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShieldAPI.html)).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 30, 2018, 08:24:17 AM
As for weapons, see my function in my AI that gets weapon barrel offsets via JSON query; you can then handle the rotational position easily by using MathUtils.getPointOnCircle() .
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 30, 2018, 08:28:46 AM
You can get the barrel offsets/angles through the API now, btw.

List<Vector2f> getHardpointFireOffsets();
List<Float> getHardpointAngleOffsets();

List<Vector2f> getTurretFireOffsets();
List<Float> getTurretAngleOffsets();

List<Vector2f> getHiddenFireOffsets();
List<Float> getHiddenAngleOffsets();

(Use the ones for the type of slot it's in...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 30, 2018, 02:39:11 PM
Thanks, but that was not exactly what i was asking.
I was asking about modifying vector2f points, how is it done in starsector.
I.e. newpointvector.x =oldpointvector.x + distance*cos(angle);
This kind of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 30, 2018, 02:49:35 PM
So, 2D vector rotation? If so, this covers the basic formula:

https://stackoverflow.com/questions/4780119/2d-euclidean-vector-rotations
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NightKev on January 30, 2018, 05:34:51 PM
Ah, in that case check out LazyLib (http://fractalsoftworks.com/forum/index.php?topic=5444.0), it has a bunch of functions to simplify that stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on February 08, 2018, 05:43:38 PM
Is there a way to clean hyperspace around an added star system? So far the two systems I added float in a mess of deep hyperspace with raging storm.

I was quite sure someone already asked something similar but cannot find it  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 10, 2018, 10:34:50 AM
Hey! There is, yes. Take a look at com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.java, in the api code.


Here's some of the relevant code:

Code: java
HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
NebulaEditor editor = new NebulaEditor(plugin);

float minRadius = plugin.getTileSize() * 2f;
for (StarSystemAPI curr : systems) {
float radius = curr.getMaxRadiusInHyperspace();
editor.clearArc(curr.getLocation().x, curr.getLocation().y, 0, radius + minRadius * 0.5f, 0, 360f);
editor.clearArc(curr.getLocation().x, curr.getLocation().y, 0, radius + minRadius, 0, 360f, 0.25f);
}

The above clears hyperspace around all the star systems; done as part of sector-generation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on February 12, 2018, 07:45:02 AM
OK, I "think" it works. I was missing the "import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator.java" part in the star system files...

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vagrant on February 12, 2018, 10:57:55 AM
So i might be missing something simple here, but is there a way to limit which barrels on a weapon fire in alternating mode / skip over barrels if that's not possible?


I'm designing a weapon with 2 barrels, but the weapon usually only has 1 ammo in the magazine, and I only want it to use the first barrel, unless the user puts extended magazines on the ship, in which case it will have two ammo and use both barrels to fire.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on February 12, 2018, 05:45:22 PM
So i might be missing something simple here, but is there a way to limit which barrels on a weapon fire in alternating mode / skip over barrels if that's not possible?


I'm designing a weapon with 2 barrels, but the weapon usually only has 1 ammo in the magazine, and I only want it to use the first barrel, unless the user puts extended magazines on the ship, in which case it will have two ammo and use both barrels to fire.
I don't think E Mags will give you enough ammo to push you over to two ammo
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 19, 2018, 05:26:12 AM
Question: Why do SectorEntityToken.setContainingLocation(null) and LocationAPI.removeEntity(token) need to be called together?

If I only do the latter the entity remains in the containing location (or at least the CampaignFleetAPI I'm testing does); only the former means entity.getContainingLocation() still returns the original LocationAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 19, 2018, 11:14:52 AM
Question: Why do SectorEntityToken.setContainingLocation(null) and LocationAPI.removeEntity(token) need to be called together?

If I only do the latter the entity remains in the containing location (or at least the CampaignFleetAPI I'm testing does); only the former means entity.getContainingLocation() still returns the original LocationAPI.

The containing location gets set every frame, IIRC, so if you just null it once, it'll be re-set the next frame. If you removeEntity(), that'll *actually* remove it, but its containingLocation will still be set to the last value it was at, even though it's no longer in that location's list of objects. I'm not sure what you mean by it remaining in the containing location; could you clarify? There's plenty of vanilla code that calls removeEntity() w/o a corresponding setContainingLocation().


In case this is relevant: a fleet's isAlive() method looks like this:

public boolean isAlive() {
   return getContainingLocation() != null && getContainingLocation().getObjects().contains(this);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 19, 2018, 04:35:58 PM
The containing location gets set every frame, IIRC, so if you just null it once, it'll be re-set the next frame. If you removeEntity(), that'll *actually* remove it, but its containingLocation will still be set to the last value it was at, even though it's no longer in that location's list of objects. I'm not sure what you mean by it remaining in the containing location; could you clarify? There's plenty of vanilla code that calls removeEntity() w/o a corresponding setContainingLocation().
Ah, sorry, miswrote: it's setContainingLocation() that makes the entity remain in the location and removeEntity() that causes containingLocation to persist, like you described.

Anyway, what I meant to ask was:
Shouldn't calling removeEntity() also automatically set the entity's containingLocation to null, and calling setContainingLocation() move/remove the entity? That's what one would naively expect the methods to do.
I'm wondering if there's a reason they're separate (and indeed why an entity's containingLocation has a setter, if the variable doesn't actually affect where the entity is and it just gets reset every frame anyway).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 19, 2018, 04:45:07 PM
It's sometimes useful to know the last containingLocation of removed entity. For example, a despawned fleet, when it's no longer in any location.

Basically, in normal usage, you don't need to call get/set containingLocation, and you just use add/removeEntity(). When you need something more specialized (i.e. previous location for a despawned fleet, hard-setting the location for whatever reason), there's a pair of dumb getter/setter methods to do the job that they might be less suited for if they were "smart".

(Edit: I should add, addEntity() also sets the containing location.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 23, 2018, 02:10:40 PM
I have a weird bug where one of my interceptor wings disappears from my inventory after I go to the refit screen.

Two hulls present in my fleet have built in versions of this wing, so could it have something to do with that? Other fighter wings don't appear to act that way as far as I know.

**Edit: Yes, it definitely seems to be because of that. It doesn't disappear from my inventory if that ship is not present.

 Is this a vanilla bug? Or did I mess something up?

**Edit2: Confirmed that this occurs with any wing present in player inventory that is also built-in to a hull in their fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on March 20, 2018, 11:41:28 AM
Started to try fiddling with rules.csv, and I'd like a bit of help with a couple of things.

1. I've got a dialogue set up very similarly to Beholder Station. I've got "$player.supplies >= 10" and "$player.supplies < 10", and they work fine and all. After trying it with 1 copy of a custom commodity, it doesn't seem to work (something like "$player.example >= 1" and "$player.example < 1", actual ID redacted for spoiler reasons). Anything obvious I should be doing?

2. A little bit of an issue. The trigger for the dialogue is set to when you interact with a specific planet, which is just a regular non-market planet that's spawned and then has the desired tag applied to it, like Beholder Station. However, it only seems to properly open the dialogue about half the time, and the other half of the time it opens up the dialogue for surveying. Any solutions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 20, 2018, 01:39:55 PM
1. I've got a dialogue set up very similarly to Beholder Station. I've got "$player.supplies >= 10" and "$player.supplies < 10", and they work fine and all. After trying it with 1 copy of a custom commodity, it doesn't seem to work (something like "$player.example >= 1" and "$player.example < 1", actual ID redacted for spoiler reasons). Anything obvious I should be doing?

The "supplies" variable, along with some other stuff, is set in the "player" memory by
com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl.updatePlayerFacts()

This isn't the case for everything in cargo; doing it for arbitrary commodities would probably not be a great idea due to the potential for variable name-clashes. You can either 1) add your own CampaignPlugin that adds this to the player memory so that rules can check against it (with hopefuly a unique prefix in the variable name), or 2) write a custom rule command that checks the value directly.

See the otherwise-unused com.fs.starfarer.api.impl.campaign.rulecmd.TakeRepCheck

For a fairly decent example of a custom rule command that could be used as a condition.


2. A little bit of an issue. The trigger for the dialogue is set to when you interact with a specific planet, which is just a regular non-market planet that's spawned and then has the desired tag applied to it, like Beholder Station. However, it only seems to properly open the dialogue about half the time, and the other half of the time it opens up the dialogue for surveying. Any solutions?

This means multiple rules have the same score and so one is picked randomly. Add a "score" to one of the conditions in your rule to make it take precedence, i.e.

$tag:whatever score:100

The base score (in the absence of "score:" parameters) is 1 point for each condition matched.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on March 20, 2018, 03:47:40 PM
2. Oh, yeah, I see. Thanks.

1. So, something like the code in the spoiler?

Spoiler
Code: Java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.BaseCampaignPlugin;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import static data.scripts.campaign.ids.AECommodities.SIERRA_CORE;

public class AECampaignPluginImpl extends BaseCampaignPlugin {

public String getId() {
return "AECampaignPluginImpl";
}

public void updatePlayerFacts(MemoryAPI memory) {
CampaignFleetAPI fleet = Global.getSector().getPlayerFleet();

memory.set("$ae_sierracore", (int)fleet.getCargo().getCommodityQuantity(SIERRA_CORE), 0);
}

}
[close]

And then I'd replace $player.supplies with $player.ae_sierracore?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 20, 2018, 03:51:45 PM
This means multiple rules have the same score and so one is picked randomly. Add a "score" to one of the conditions in your rule to make it take precedence, i.e.

$tag:whatever score:100

The base score (in the absence of "score:" parameters) is 1 point for each condition matched.

@Inventor Raccoon -On scoring from my experience:

- Depending on how many rules entries this particular entity may have in the future, I strongly encourage you to have a scoring system in place ahead of time.

For example: I have separate instances of greeting dialogues- based on both faction and rep. If I make the score the same for each check, unintended dialogue may pop up at random if I add additional factors in the future (like supply count or a custom script checking a boolean in memory).

For my system, generic sorting factors like faction get a base score of 10. Higher than default by quite a few checks, but still fairly low overall.

Things I consider "one off" encounter checks, like for story bools in memory, get a score of 1000. They only occur once, typically, so it is very important they always take precedence. But this gives a large window to add lower level checks without jeopardizing the story later.

2. Oh, yeah, I see. Thanks.

1. So, something like the code in the spoiler?

Spoiler
Code: Java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.BaseCampaignPlugin;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import static data.scripts.campaign.ids.AECommodities.SIERRA_CORE;

public class AECampaignPluginImpl extends BaseCampaignPlugin {

public String getId() {
return "AECampaignPluginImpl";
}

public void updatePlayerFacts(MemoryAPI memory) {
CampaignFleetAPI fleet = Global.getSector().getPlayerFleet();

memory.set("$ae_sierracore", (int)fleet.getCargo().getCommodityQuantity(SIERRA_CORE), 0);
}

}
[close]

And then I'd replace $player.supplies with $player.ae_sierracore?

I believe so, yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 20, 2018, 03:57:24 PM
1. So, something like the code in the spoiler?

Spoiler
Code: Java
package data.scripts.plugins;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.BaseCampaignPlugin;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import static data.scripts.campaign.ids.AECommodities.SIERRA_CORE;

public class AECampaignPluginImpl extends BaseCampaignPlugin {

public String getId() {
return "AECampaignPluginImpl";
}

public void updatePlayerFacts(MemoryAPI memory) {
CampaignFleetAPI fleet = Global.getSector().getPlayerFleet();

memory.set("$ae_sierracore", (int)fleet.getCargo().getCommodityQuantity(SIERRA_CORE), 0);
}

}
[close]

And then I'd replace $player.supplies with $player.ae_sierracore?

Yes, that looks exactly right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on March 22, 2018, 01:34:00 PM
I'm trying to create a heavy ballistics like built in hullmod that does two things: One decreases the OP costs for energy weapons and increases the op for ballistics, both by small amounts. The point is to help incentivise using energy weapons while doing the opposite for ballistics. My questions are:
1: Does this need to be compiled/ built in an IDE? I noticed that HBI was not in the hull mods folder and instead was in the api instead
2: Which one of these is right:
A:
Spoiler
Code: java
package com.fs.starfarer.api.impl.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class HeavyDEWIntegration extends BaseHullMod {

public static final float COST_INCREASE  = 2;
public static final float COST_REDUCTION  = 5;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -COST_INCREASE);
stats.getDynamic().getMod(Stats.LARGE_ENERGY_MOD).modifyFlat(id, -COST_REDUCTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + (int) COST_INCREASE + "";
return null;
if (index == 1) return "" + (int) COST_REDUCTION + "";
return null;
}

@Override
public boolean affectsOPCosts() {
return true;
}

}
[close]

B:
Spoiler
Code: java
package com.fs.starfarer.api.impl.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class HeavyDEWIntegration extends BaseHullMod {

public static final float COST_INCREASE  = 2;
public static final float COST_REDUCTION  = 5;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -COST_INCREASE);
}

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_ENERGY_MOD).modifyFlat(id, -COST_REDUCTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 1) return "" + (int) COST_REDUCTION + "";
return null;
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 1) return "" + (int) COST_REDUCTION + "";
return null;
}

@Override
public boolean affectsOPCosts() {
return true;
}

}
[close]
(I can already hear the cringing faces from here...)
Please take it easy on me; I'm an idiot that can't code their way out of a wet paper bag
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 22, 2018, 01:46:57 PM
A) looks right-ish, just delete line 20 - a return statement ends a method so code after one can't execute, and in fact this wouldn't even compile. Also, it looks like it's reducing the cost for both. *Also*, I'm not sure whether increasing the OP cost would work - seems like it should, but I haven't tested that at all.

You should not need an IDE for this, but you'd have to put the script into data/hullmods or thereabouts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 22, 2018, 01:55:30 PM
I'm trying to create a heavy ballistics like built in hullmod that does two things: One decreases the OP costs for energy weapons and increases the op for ballistics, both by small amounts. The point is to help incentivise using energy weapons while doing the opposite for ballistics. My questions are:
1: Does this need to be compiled/ built in an IDE? I noticed that HBI was not in the hull mods folder and instead was in the api instead
2: Which one of these is right:
A:
Spoiler
Code: java
package com.fs.starfarer.api.impl.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class HeavyDEWIntegration extends BaseHullMod {

public static final float COST_INCREASE  = 2;
public static final float COST_REDUCTION  = 5;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -COST_INCREASE);
stats.getDynamic().getMod(Stats.LARGE_ENERGY_MOD).modifyFlat(id, -COST_REDUCTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + (int) COST_INCREASE + "";
return null;
if (index == 1) return "" + (int) COST_REDUCTION + "";
return null;
}

@Override
public boolean affectsOPCosts() {
return true;
}

}
[close]

B:
Spoiler
Code: java
package com.fs.starfarer.api.impl.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class HeavyDEWIntegration extends BaseHullMod {

public static final float COST_INCREASE  = 2;
public static final float COST_REDUCTION  = 5;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -COST_INCREASE);
}

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_ENERGY_MOD).modifyFlat(id, -COST_REDUCTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 1) return "" + (int) COST_REDUCTION + "";
return null;
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 1) return "" + (int) COST_REDUCTION + "";
return null;
}

@Override
public boolean affectsOPCosts() {
return true;
}

}
[close]
(I can already hear the cringing faces from here...)
Please take it easy on me; I'm an idiot that can't code their way out of a wet paper bag

No worries  :)

At a glance:

The first one. But take out line 20, I believe it is redundant and may cause unexpected results.

Also, I'm pretty sure -COST_INCREASE as a parameter of line 14 will reduce the cost, not increase it. So take out the negative.


As a recommendation, an IDE is very, very useful. You can dynamically call up any method available without having to sift through all the API documentation online. It also helps debug simple syntax errors that would probably take a lot more time to find on your own.

It is a little effort to set up, but tutorials exist that get you through the hard parts.

I'm not sure it strictly would need to be compiled by one, however. That may have just been a more efficient method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 22, 2018, 01:57:10 PM
A) looks right-ish, just delete line 20 - a return statement ends a method so code after one can't execute, and in fact this wouldn't even compile. Also, it looks like it's reducing the cost for both. *Also*, I'm not sure whether increasing the OP cost would work - seems like it should, but I haven't tested that at all.

You should not need an IDE for this, but you'd have to put the script into data/hullmods or thereabouts.

Ha, beat me to it.  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 22, 2018, 02:04:40 PM
Sorry :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on March 23, 2018, 10:43:02 PM
So I've been trying and failing to get this hullmod to work right...  It keeps crashing every time I click on the add hullmod button in missions. It is NOT compiled and is just in a loose hullmod scripts mod that worked before so I know it isn't the culprit.

CSV:
Spoiler
Heavy DEW Integration,HeavyDEWIntegration,0,,special,100,TRUE,,,0,0,0,0,data.hullmods.HeavyDEWIntegration,Decreases the OP cost of Large Energy weapons by %s points but increases the cost Large Ballistics by %s points,,graphics/hullmods/generic_mod.png
[close]

Script:
Spoiler
Code: java
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class HeavyDEWIntegration extends BaseHullMod {

   public static final float COST_INCREASE  = 2;
   public static final float COST_REDUCTION  = 5;

   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
      stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, COST_INCREASE);
      stats.getDynamic().getMod(Stats.LARGE_ENERGY_MOD).modifyFlat(id, -COST_REDUCTION);
   }

   public String getDescriptionParam(int index, HullSize hullSize) {
      if (index == 0) return "" + (int) COST_INCREASE + "";
      if (index == 1) return "" + (int) COST_REDUCTION + "";
      return null;
   }

   @Override
   public boolean affectsOPCosts() {
      return true;
   }

}
[close]

Error:
Spoiler
195998 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassFormatError: Inconsistent constant value type in class file data/hullmods/HeavyDEWIntegration
java.lang.ClassFormatError: Inconsistent constant value type in class file data/hullmods/HeavyDEWIntegration
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at org.codehaus.janino.JavaSourceClassLoader.defineBytecode(JavaSourceClassLoader.java:244)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:194)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at com.fs.starfarer.loading.scripts.ScriptStore.Object(Unknown Source)
   at com.fs.starfarer.loading.specs.o00O.getEffect(Unknown Source)
   at com.fs.starfarer.coreui.refit.ModPickerDialog.Òö0000(Unknown Source)
   at com.fs.starfarer.coreui.refit.ModPickerDialog.actionPerformed(Unknown Source)
   at com.fs.starfarer.coreui.refit.ModPickerDialog.<init>(Unknown Source)
   at com.fs.starfarer.coreui.refit.D.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.j.super(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 24, 2018, 08:47:37 AM
This looks like it could be a Janino (3rd party compiler that compiles loose scripts into something that can execute) issue, since the code looks right and seems to compile fine in an IDE.

Can you try modifying lines 10 and 11 like so?

public static final float COST_INCREASE  = 2f
public static final float COST_REDUCTION  = 5f

Bolded the difference. Shouldn't have to do that, but the error seems to point towards this, so may be worth a shot. Could also try removing the "final" keyword.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on March 24, 2018, 07:16:53 PM
That fixed it to a point: It no longer crashes but there is no increase nor decrease in OP levels when it is a normal mod. Making it built in fixes it though
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 24, 2018, 09:17:49 PM
Ah, right - it has to be built-in, yeah. OP-cost modifications are not supported for non-built-in mods - it gets weird when you add or remove them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 30, 2018, 11:07:32 AM
What's the reason for SFX (specifically for weapons) being mono and low KBPS?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2018, 11:16:10 AM
Mono is required because that's how things work - OpenAL takes a mono sound effect and makes it stereo with channel balance etc based on its location relative to the listener. Stereo effects play "as is", i.e. they aren't directional; all UI effects - such as button presses etc - are stereo.

As far as the bitrate, you just want the lowest to where the quality doesn't suffer. A higher bitrate means more ram and loading time, both in significant amounts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Solinarius on March 30, 2018, 11:37:41 AM
Good grief! Thanks for the quick response!

I think I only just noticed the SFX in question was mono. I've been using a few dozen SFX replacers that are stereo. I decided to give the Tac Laser an activation sound (which is very brief), but once I did that, SFX would mute erratically in battles of moderate size or greater. Sound channels full or is that a problem with stereo SFX? I only ask because I can't test it right now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2018, 11:50:54 AM
That's a bit weird, I'm not sure why they'd mute. UI channels are more limited, but IIRC these would still play on FX channels, despite being stereo.

But they won't work well either way - if they're stereo, they will not be directional. That is to say, if a tac laser fires from the right, it won't sound any different than when it fires from the left. You'll just always get the un-altered stereo sound playing back if the effect is a stereo sound.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on March 31, 2018, 02:49:56 PM
Hopefully a quick one that's been annoying me for a little while.

I had a concept for a hullmod for certain custom ships (ie. as a built-in mod) that affects the Combat Readiness lost when you attempt to refit a ship outside of a station or planet's dry dock. The basic idea was a "Mobile Refitting Equipment" or similarly named mod, which slightly reduces the amount of CR lost when you refit a ship in deep space - the practical role of such a ship and hullmod being for those players doing a lot of exploration and ship recovery interspersed with frequent fighting in the outworlds or just around the Core Systems.

Can anyone point me to where I might find files that relate to the Combat Readiness loss due to refitting outside of a dock? Or if such code is in fact obfuscated and unable to be tampered with?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2018, 09:35:33 AM
There are settings to control this globally in settings.json, but there's nothing per-ship. You might be able to script it somehow, though.

"crLossMultForRefit":1,
"crLossMultForRefitWeapons":2,
"crLossMultForRefitHullmods":4,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 01, 2018, 02:50:08 PM
There are settings to control this globally in settings.json, but there's nothing per-ship. You might be able to script it somehow, though.

"crLossMultForRefit":1,
"crLossMultForRefitWeapons":2,
"crLossMultForRefitHullmods":4,

Interesting. My scripting capabilities are extremely limited, but I'll see what I can do with that.  ;) Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Blothorn on April 02, 2018, 03:29:43 PM
I noticed that some modded ship system scripts keep instance data (e.g. ship location when the system was activated) as non-static class variables, but the vanilla scripts have only static variables and use CustomData for instance data. Can I rely on a 1:1 mapping of ships to ship system scripts, or are they re-used across ships/recreated for one ship?

(And if non-static data is not safe, is there a reason the methods are not static?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2018, 03:35:09 PM
Looking at the code, I'm fairly sure you can - a new instance of the script class gets created for each ship system instance. Vanilla stuff uses CustomData because, iirc, there used to only be a single shared instance of each script some time ago.

Static variables are only used for constant values; it would not be at all safe to use them to hold data that changes.

Note that this does *not* apply to hullmods - for those, there is only one instance of each script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on April 07, 2018, 02:04:58 AM
Static variables are only used for constant values; it would not be at all safe to use them to hold data that changes.

May I ask why? I have several times utilized changing Static values, as Static (should) only indicates that all instances of a class share the variable value. Are you referring to "Final", or am I missing something here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on April 07, 2018, 02:29:04 AM
Oh and sorry for double posting, but I had an unrelated question regarding fighters in the refit screen:

I'm trying to make a hullmod (on a fighter) which changes effect depending on the ship it is mounted on. Is there any way to, in the refit screen, get
   A: The fighter's associated ship?
   B: The fighter's associated wing?
   C: The fighter's associated fleet?

ShipAPI.getWing returns null, which means that A and B seem impossible to me, but i have not found any function to get C working. Am i missing a function, or is there simply no way for a fighter to know which ship it is mounted on before entering combat? It should be noted that the opposite does not seem to work, either (ShipAPI.getAllWings returns an empty list, so the carrier seems unaware of the fighters it carries until it enters battle).

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2018, 08:43:32 AM
Static variables are only used for constant values; it would not be at all safe to use them to hold data that changes.

May I ask why? I have several times utilized changing Static values, as Static (should) only indicates that all instances of a class share the variable value. Are you referring to "Final", or am I missing something here?

Right, you're (naturally) correct about how static variables work. Where it gets really iffy is when you combine that with state transitions and/or loading a new game. Say you have a hullmod and a static variable, I don't know, holds a list of ships that are currently under the effect of that hullmod's... some kind of AoE field. And you're doing this as a way make sure that multiple AoEs don't affect the same ship.

So that's all well and good, but when you exit combat, that list is still around, unless you make sure to clean it up, and the elements in it may point to the combat engine /and/ to the campaign engine. So, that's one combat engine leak right there. Then you load a new game. That list is *still* around, and points to the old game engine, preventing it from being GC'ed. That's an even more severe leak of one campaign engine instance.

Less problematic issues are non-leaking bugs of the same variety, i.e. a counter or some such that doesn't get reset when another savegame is loaded, that sort of thing.

You certainly /can/ use changing static variables safely. It's just often a bit of a pain and it seems easier to use combat/campaign.getCustomData() which means you don't need to worry about these kinds of scoping issues.


Oh and sorry for double posting, but I had an unrelated question regarding fighters in the refit screen:

I'm trying to make a hullmod (on a fighter) which changes effect depending on the ship it is mounted on. Is there any way to, in the refit screen, get
   A: The fighter's associated ship?
   B: The fighter's associated wing?
   C: The fighter's associated fleet?

ShipAPI.getWing returns null, which means that A and B seem impossible to me, but i have not found any function to get C working. Am i missing a function, or is there simply no way for a fighter to know which ship it is mounted on before entering combat? It should be noted that the opposite does not seem to work, either (ShipAPI.getAllWings returns an empty list, so the carrier seems unaware of the fighters it carries until it enters battle).

Hmm, I think you're out of luck on this one - the fighters, as far as I recall, don't exist in the refit screen. I couldn't tell you if their hullmods even get their apply() method called - if they do, it's more of a "side effect" than a feature you can rely on continuing to exist.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on April 07, 2018, 09:59:55 AM
Hmm, I think you're out of luck on this one - the fighters, as far as I recall, don't exist in the refit screen. I couldn't tell you if their hullmods even get their apply() method called - if they do, it's more of a "side effect" than a feature you can rely on continuing to exist.

Interesting: they definitely get apply() called, and you can actually modify their Variants while in the refit screen: i was just looking for a way to do that dependant on the main ship. But OK, that's not intended behaviour; i'll have to find another way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2018, 10:05:19 AM
Ah - it probably creates a fighter as part of the rendering process. I /think/ it just creates one and renders it a bunch of times instead of creating one for every fighter in the wing, but yeah, that's (probably) not hooked up to the source ship etc; it's not even trying to replicate that data structure etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on April 10, 2018, 08:58:23 AM
Quick question : what determine if a ship is available within a civilian market or a military market, as well as the level of commission needed? Is it its tag (civilian, carrier...)? Or based on a calculation of some of its caracteristics? Or its use in the faction file?
For example, in Disassemble Reassemble mod, the Taurus gunship (combat frigate, no tag, 1 medium and 4 small mounts) is sometime to buy in standard market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 10, 2018, 09:06:38 AM
... you know, I don't actually remember, and that code is different in the in-dev version. I think it's 5 fp or less and a frigate = can be found in the open market, but I also think there's some other restriction in terms of what "shipRole" it's found in, as defined in the .faction file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on April 10, 2018, 09:56:54 AM
 On my skin, i have that:

 "weaponSlotChanges":{
   "WS0001":{
    "angle": 0,
    "arc": 15,
    "locations": [
      59.5,
      -13.5
    ],
    "mount": "HARDPOINT"
   },

Everything work except one thing: The Location do not move.
A means to fix that? (Or i need to remove then reput a new weapon?)

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 10, 2018, 10:12:47 AM
Yeah, location changes are not supported. Only angle/arc/mount/size/type are supported.

One way might be to have a "base" hull with both slots, and two skins which each removed one of them. Or have an empty DECORATIVE slot on the original hull, and then have the skin change it to be a different type - I think that might work as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on April 10, 2018, 11:03:56 AM
Yeah, location changes are not supported. Only angle/arc/mount/size/type are supported.

One way might be to have a "base" hull with both slots, and two skins which each removed one of them. Or have an empty DECORATIVE slot on the original hull, and then have the skin change it to be a different type - I think that might work as well.

Work perfectly, thank.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on April 10, 2018, 02:17:18 PM
... you know, I don't actually remember, and that code is different in the in-dev version. I think it's 5 fp or less and a frigate = can be found in the open market, but I also think there's some other restriction in terms of what "shipRole" it's found in, as defined in the .faction file.

I cross-checked appearance of ships in civilian market and it seems its closely related to ship roles in .faction files. Ships listed as combatFreighter, civilianrandom and other civilian types can be sell within civilian market. To follow my previous example, the Tauru is listed as combatFreighterSmall.

Anyway, thanks for you answer it gives me the right way to find what I was looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gun&drink on April 14, 2018, 09:19:54 AM
I don't know if this should go in here, but it definitely sounds like it doesn't deserve its own thread:
I was bored, browsing old threads and stuff, when I saw an sprite in a really old mod that catched my attention. Said sprite is not in use in any mod in the present, and the user owning the mod hasn't posted anything in the forums since 2012.
what is the etiquette when planning on reviving old mods/using old assets if the author is inactive for a very long time and you are unable to contact him? this is a very hypothetical question because a) I have yet to make a single modification in Starsector than works besides modifying config files, let alone making a ship from a sprite, and b) I haven't attempted to contact said author yet so I don't even know if contact is possible or not. I wanted to know the answer anyways just to have it in mind if I get a little better at modding and I decide to go for it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 14, 2018, 09:27:53 AM
Hey! If it's something you would put out as a mod for others to download, then you absolutely have to have permission from the person that made the assets. If you couldn't reach them, that'd be unfortunate, but would not make it ok to use someone's stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gun&drink on April 14, 2018, 10:19:25 AM
Hey! If it's something you would put out as a mod for others to download, then you absolutely have to have permission from the person that made the assets. If you couldn't reach them, that'd be unfortunate, but would not make it ok to use someone's stuff.
Thanks for the quick reply Alex
Good to know, I will try to contact him as soon as possible to know if he is interested in it, so that even if it takes a good while to respond I have a better chance than doing it in a few months
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on April 14, 2018, 05:08:34 PM
I'm making a rulecommand that adds an officer to the player's fleet. Mostly fine and dandy, except for when it comes to two things I'm doing extra: giving the officer a special skill, and giving the officer a specific portrait. The first gives a NPE in the dialogue and the officer fails to be added, the second adds the officer but causes a fatal:null when opening the menu to assign/check officers. Code below, the commented-out stuff is what's currently not working. Would appreciate if someone could point out anything I'm doing wrong.

Spoiler
Code: java
package data.scripts.campaign.rulecmd;

import com.fs.starfarer.api.campaign.rules.MemKeys;
import data.scripts.campaign.ids.AEIDs;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.impl.campaign.rulecmd.BaseCommandPlugin;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.characters.FullName;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Personalities;
import com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent;
import com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent.SkillPickPreference;

import java.util.List;
import java.util.Map;

public class AEAddSierraOfficer extends BaseCommandPlugin

{
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap)
    {
        final MemoryAPI localMemory = memoryMap.get(MemKeys.LOCAL);
        if (localMemory == null) return false;
        FullName name;
        CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
        PersonAPI officer = OfficerManagerEvent.createOfficer(Global.getSector().getPlayerFaction(), 3, false, SkillPickPreference.NON_CARRIER);
        name = new FullName("Sierra", "", FullName.Gender.FEMALE);

        //officer.getStats().setSkillLevel(AEIDs.SIERRA_SKILL, 3);
        officer.setRankId(AEIDs.RANK_SIERRA);
        officer.setPostId(AEIDs.POST_SIERRA);
        officer.setPersonality(Personalities.STEADY);
        officer.setFaction(Factions.INDEPENDENT);
        //officer.setPortraitSprite("graphics/portraits/sierra_portrait.png");
        officer.setName(name);
        //officer.getStats().setSkipRefresh(true);
        playerFleet.getFleetData().addOfficer(officer);
        return true;
    }
}
[close]

EDIT: Actually I think the skill thing not working is a fault elsewhere, still unsure about the portrait.

Also, is it possible to make a skill that's not available to the player?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 22, 2018, 01:51:23 AM
Is there a way to level an officer past whatever max level is defined in the settings (20, by default) without changing the officerLevelUp plugin in settings.json (which will cause conflicts if more than one mod wants to do this)?

I can define my own OfficerLevelupPlugin with an override for getMaxLevel(), and reference it using a different plugin ID in settings. But OfficerDataAPI.canLevelUp() still returns false once level 20 is reached, presumably because it always uses the plugin with the officerLevelUp key in settings.json.

@Inventor Raccoon: The portrait setting line should work and indeed other mods use it; I'm not sure why it's crashing. Maybe the portrait doesn't actually exist at the path... but it should just display a black rectangle even then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2018, 06:09:48 PM
Also, is it possible to make a skill that's not available to the player?

Offhand, I don't think you can.

Is there a way to level an officer past whatever max level is defined in the settings (20, by default) without changing the officerLevelUp plugin in settings.json (which will cause conflicts if more than one mod wants to do this)?

I can define my own OfficerLevelupPlugin with an override for getMaxLevel(), and reference it using a different plugin ID in settings. But OfficerDataAPI.canLevelUp() still returns false once level 20 is reached, presumably because it always uses the plugin with the officerLevelUp key in settings.json.

Hmm - if it's just putting an officer together for an AI fleet or whatnot, you could use the relevant methods to set that officer's skills and level directly. If it's for letting the player do it, then that's what the plugin is for, so no, I don't think so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on April 23, 2018, 08:29:07 AM
Yeah, did some experimentation and it doesn't seem like you can make skills not appear unless they're tied to an aptitude. I wouldn't know where to suggest it but it'd be a nice addition, maybe as a tag of some sort or a column in skill_data.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2018, 09:08:37 AM
Yeah, I'll keep it in mind!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 25, 2018, 04:02:37 AM
Is there an equivalent of reportEncounterLootGenerated() for loot from salvaging an entity (including debris fields)? If not, could we get one (or probably better, a common method that handles loot from any source)?

There's a couple of things one might want to do with this, but the one I'd like to do is to scrub out things that should not be in loot for whatever reason.
A mod I'm helping which needs to have its content available nowhere outside of a specific region of space, and could use this as a fallback in case the "normal" prevention methods don't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 25, 2018, 09:49:16 AM
There isn't, no. Might be a good thing to add; I'll see if I can manage that at some point.

(Any particular reason the "normal" prevention methods aren't working, or are they just not expected to be reliable in the first place?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 26, 2018, 08:04:29 AM
That would be helpful, thanks Alex!

(Yeah, I was thinking it'd mostly be a "this turned out to have a bug, in lieu of waiting for a new Starsector release we'll write a script to work around it" kind of backup thing)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 26, 2018, 09:21:46 AM
Oddly enough, just ended up putting together a better listener system for campaign events for an entirely unrelated reason.

The main point is to move away from a listener having to implement every single reportXXX method, and by default needing to be registered for everything, as that really limits how many listeners you can have overall, and makes it a pain to adjust the involved interfaces.

Since that makes it considerably easier to add new events, added this:

Code: java
public interface ShowLootListener {
void reportAboutToShowLootToPlayer(CargoAPI loot, InteractionDialogAPI dialog);
}

The way to add it would be like so:
Global.getSector().getListenerManager().addListener(listener);


And it would also need to be removed manually, if that was ever required.

ListenerManager interface:

Code: java
public interface ListenerManagerAPI {

void addListener(Object listener);
void addListener(Object listener, boolean isTransient);

void removeListener(Object listener);
void removeListenerOfClass(Class<?> c);

boolean hasListener(Object listener);
boolean hasListenerOfClass(Class<?> c);

<T> List<T> getListeners(Class<T> c);

}

Now, I haven't converted everything to use this, but will probably at least make it work for fleet events (battle, despawn), and anything new will use this scheme.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gun&drink on April 28, 2018, 05:53:25 AM
I was testing a hullmod that gives you a lot of speed, but despite the max speed being at 690, the ship won't go faster that 618: the speed bar merely fills up until that speed, leaving some unused space. is there a hard cap in ship speed? can it be removed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 28, 2018, 08:26:16 AM
Ship speed is capped at 600; you're seeing it go above 600 due to 1 frame's worth of acceleration. It's not possible to remove it. It's sort of a sanity check/failsafe; at some point beyond that level, issues such as weird collision behavior are likely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: c plus one on April 28, 2018, 05:59:11 PM
On a related note, can fighters and/or missiles travel faster than speed 600?

If so, how much faster?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Twogs on May 03, 2018, 10:12:41 AM
Hey guys,

I found the error myself, one space to much
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TJJ on May 03, 2018, 10:47:11 AM
Hey guys,

trying to get my own mini-mod up and running.

So far I only have changed some stats in the ship.csv for my (right now still the tempest sprite using) ship.

It got a name and an ID, it got these new stats, thats it. But the game won't start anymore. Am I missing something so simple that I will be laughing about it?

Quote
5989 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NumberFormatException: For input string: "255                                    "
java.lang.NumberFormatException: For input string: "255                                    "
   at java.lang.NumberFormatException.forInputString(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpecLoader.super(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpecLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Looks like it doesn't like the quote around an integer literal; perhaps you're missing the closing quote, or it shouldn't have quotes at all? (or perhaps you've missed an element separator?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 04, 2018, 05:16:49 PM
Guys. I don't know if its how things suppose to work but some modded ships have exhaust coming from their weapons when they move backwards. It looks like some sort of engine exhaust but it come from weapon mounts.
Can provide screenshots if necessary.
How to remove it?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Twogs on May 05, 2018, 05:19:21 AM
Can the explosionspec be modified so it will spread EMP damage instead of normal damage?

So energy/emp weapon would - with standard parameters - spread it's energy damage part right now, but not it's emp damage part. Can that be changed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on May 05, 2018, 05:41:58 AM
From memory, the answer is no. In order to do EMP AoE, you need to do some kind of script wizadry that is beyond me. I think it's been asked earlier in this thread, actually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Twogs on May 05, 2018, 06:24:23 AM
Than another EMP question

Is it possible to recreate the effect the Omen's emp has on missiles? I.e. disabling their guidance?

Because just giving your weapon EMP damage doesn't do the trick
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on May 06, 2018, 04:46:12 AM
Ok, not sure if this is the right thread, but here we go.

It seems as though something is very wierd when it comes to damage calculation with Proximity Fuse rounds. Featured below are 4 images, all using the same weapon firing ~20 projectiles with a combined damage of 400 (high explosive).

Spoiler
(https://i.imgur.com/lV2sbe9.png)
(https://i.imgur.com/jiPgVal.png)
(https://i.imgur.com/LbRdDBx.png)
(https://i.imgur.com/brgnJmU.png)
[close]

As you can see, not only is the damage very varying, it deals *significantly* more damage to armor and hull, around 10-30 times as much damage, in fact. Shield damage seems perfectly sane, and doesn't vary as much. Does anyone know if this is a vanilla issue with Proximity Fuse, or am I missing something obvious?

The projectile file:
Spoiler
Code
{
"id":"nictoy_heavy_flame_projectile",
"specClass":"projectile",
"spawnType":"BALLISTIC",
"collisionClass":"PROJECTILE_FF",
"collisionClassByFighter":"PROJECTILE_FIGHTER",
"length":40.0,
"hitGlowRadius":50,
"width":4.0,
"fadeTime":0.3,
"fringeColor":[255,135,50,0],
#"coreColor":[255,225,175,225],
"coreColor":[255,255,255,0],
"glowColor":[255,135,50,100],
"glowRadius":10,
"textureScrollSpeed":128.0,
"pixelsPerTexel":5.0,
"bulletSprite":"graphics/nictoy/missiles/piercer_shot.png",
"behaviorSpec":{"behavior":"PROXIMITY_FUSE",
"shotRangeVariance":0.95,
"range":25,
"explosionSpec":{"duration":0.3f,
"radius":50,
"coreRadius":25, # full damage within core radius - also equal to proximity fuse range
"collisionClass":PROJECTILE_FF,
"collisionClassByFighter":PROJECTILE_FIGHTER,
"particleSizeMin":2.2,
"particleSizeRange":4.5,
"particleDuration":0.4,
"particleCount":3,
"particleColor":[255,135,50,175],
"sound":"nictoy_drakon_heavy_flame_detonation"},
}
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 06, 2018, 10:40:13 AM
Than another EMP question

Is it possible to recreate the effect the Omen's emp has on missiles? I.e. disabling their guidance?

Because just giving your weapon EMP damage doesn't do the trick

Basically you want something like this:

if (missile.getEmpResistance() <= 0) {
   missile.flameOut();
} else {
   missile.decrEMPResistance();
}

EMP resistance is the number of EMP hits a missile can ignore for the purpose of getting insta-flamed-out.


Ok, not sure if this is the right thread, but here we go.

Hard to say re: shield w/o knowing what the shield efficiency on the target is; could be high.

I'd try changing "coreRadius":25 to be higher to see if that makes a difference. I could see variance possibly coming from the core and the fuse radius being the same.

Also, there's a chance that some fuse rounds are outright missing - i.e. exploding from the proximity detection not matching the actual collision detection. That's a possibility and is just "how things work", though generally speaking you'd see it more with long/narrow ships and not this sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on May 07, 2018, 03:40:57 AM
Ok, not sure if this is the right thread, but here we go.

Hard to say re: shield w/o knowing what the shield efficiency on the target is; could be high.

I'd try changing "coreRadius":25 to be higher to see if that makes a difference. I could see variance possibly coming from the core and the fuse radius being the same.

Also, there's a chance that some fuse rounds are outright missing - i.e. exploding from the proximity detection not matching the actual collision detection. That's a possibility and is just "how things work", though generally speaking you'd see it more with long/narrow ships and not this sort of thing.

I completely understand what you're saying, and that could be causing damage to be below the projectile damage. I can see that.

What i *don't* understand, is how any of that would *increase* the damage: as i said, the projectiles are only ~20 damage each: they shouldn't add up to ~4000 no matter how many detonate too early.

[PS] : Changed core radius to 40 and 0, didn't affect anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2018, 08:26:23 AM
Aha, I missed that part, sorry! Read it as being 400 per shot, not total.

Are you 100% sure the per-shot damage is indeed 20? Also, might be worth testing in an as-vanilla-as-possible to try to narrow down what might be going on.

... in other words, no, it doesn't make sense, and I can't see how that would happen either. Although it's certainly possible if say the damage-dealt or damage-received stats of the ship/target are modified by something else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 08, 2018, 05:34:27 AM
For now, how to decrease the chance of ship's recover that made them catchable after battle? member.getStats().getDynamic().getStat(Stats.BOARDING_CHANCE_MULT)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on May 08, 2018, 07:07:03 AM
Aha, I missed that part, sorry! Read it as being 400 per shot, not total.

Are you 100% sure the per-shot damage is indeed 20? Also, might be worth testing in an as-vanilla-as-possible to try to narrow down what might be going on.

... in other words, no, it doesn't make sense, and I can't see how that would happen either. Although it's certainly possible if say the damage-dealt or damage-received stats of the ship/target are modified by something else.
OK, I might have figured it out, but this is mostly speculation:

The problem does not persist when I ceased spawning the projectiles via scripted means [sorry I didn't mention that first, btw: might have explained a lot]. However, the behaviour of the scripted projectiles is completely fine as long as it doesn't impact hull/armor: shields work just as intended.

Thus, I believe the issue is that setting a projectile's damage via script only changes the impact damage, and not the AoE damage from a flak projectile. I might be completely wrong, but that would explain a lot of the behaviour, since the Fuse-based detonations might not affect shields in the same way as hull.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2018, 08:09:13 AM
For now, how to decrease the chance of ship's recover that made them catchable after battle? member.getStats().getDynamic().getStat(Stats.BOARDING_CHANCE_MULT)?

stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD)

(See ReinforcedBulkheads for an example.)


Thus, I believe the issue is that setting a projectile's damage via script only changes the impact damage, and not the AoE damage from a flak projectile. I might be completely wrong, but that would explain a lot of the behaviour, since the Fuse-based detonations might not affect shields in the same way as hull.

Aha - yeah, that makes sense. Added a CombatEntityAPI.getAI() method to get at proximity fuse AI from projectiles, and
added ProximityFuseAIAPI, with an updateDamage() method, so that you can force the damage changes to be picked up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 08, 2018, 08:21:04 AM
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD)

(See ReinforcedBulkheads for an example.)

So if I apply it when fleet is generated, it could take effect right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2018, 08:55:32 AM
So if I apply it when fleet is generated, it could take effect right?

No, fleet member stats are updated from scratch before battles or any time the fleet composition changes etc. In particular they do not end up in save files. Any changes you make like this should come either from a hullmod or using FleetMemberAPI.getBuffManager().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 08, 2018, 09:53:50 AM
No, fleet member stats are updated from scratch before battles or any time the fleet composition changes etc. In particular they do not end up in save files. Any changes you make like this should come either from a hullmod or using FleetMemberAPI.getBuffManager().

So can I apply it during the battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2018, 09:57:59 AM
I'm not sure. I wouldn't, really; even if that works now there's no guarantee it'll continue working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: stormbringer951 on May 11, 2018, 02:53:33 AM
How do you make a hullmod that is unlocked and installable on all ships, but is not droppable as loot from battle / research stations and not for sale?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on May 11, 2018, 06:21:19 AM
How do you make a hullmod that is unlocked and installable on all ships, but is not droppable as loot from battle / research stations and not for sale?

In data/hullmods/hull_mod.csv
The hull mod will be unlocked if "unlocked" value is "TRUE",
installable on all ships as long as you don't specify it in the .java file of the hullmod,
and not droppable if "hidden" value is "TRUE"
Also, if you don't want the hullmod to show on the refit screen for ship equipped with it (such as specificities for station, for example), you can also set the "hiddenEverywhere" value as "TRUE"

Hope it helps
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: stormbringer951 on May 11, 2018, 12:43:43 PM
How do you make a hullmod that is unlocked and installable on all ships, but is not droppable as loot from battle / research stations and not for sale?

In data/hullmods/hull_mod.csv
The hull mod will be unlocked if "unlocked" value is "TRUE",
installable on all ships as long as you don't specify it in the .java file of the hullmod,
and not droppable if "hidden" value is "TRUE"
Also, if you don't want the hullmod to show on the refit screen for ship equipped with it (such as specificities for station, for example), you can also set the "hiddenEverywhere" value as "TRUE"

Hope it helps

Hidden hullmods can't be installed, even if they're also unlocked, because unlocked hidden hullmods aren't displayed in the list :(.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 11, 2018, 12:52:53 PM
I don't 100% remember if this is only for the next release or not but adding a "no_drop" tag might be worth a shot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 13, 2018, 05:25:35 AM
public void reportBattleFinished(CampaignFleetAPI primaryWinner, BattleAPI battle)
when it will be called? each engagement finished? not the whole battle is over?
What is getCombinedOne() and Two ? I mean, which sides do they refer to?
for (CampaignFleetAPI fleet : battle.getPlayerSide()) {
            if (fleet.isPlayerFleet()) {}
}

the fleet contains the fleet members which are involved in this battle right? and the fleet does not equal to Global.getSector().getPlayerFleet()?
if it is, what will fleet.isPlayerFleet() return?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 13, 2018, 07:27:19 AM
public void reportBattleFinished(CampaignFleetAPI primaryWinner, BattleAPI battle)
when it will be called? each engagement finished? not the whole battle is over?
What is getCombinedOne() and Two ? I mean, which sides do they refer to?
for (CampaignFleetAPI fleet : battle.getPlayerSide()) {
            if (fleet.isPlayerFleet()) {}
}

the fleet contains the fleet members which are involved in this battle right? and the fleet does not equal to Global.getSector().getPlayerFleet()?
if it is, what will fleet.isPlayerFleet() return?
reportBattleFinished is called at the end of the battle, after one/both fleets have retreated or died
(while reportBattleOccured is called every autoresolve round; not sure about player engagement rounds)

I think (Alex would know for sure):


EDIT: One more thing: in reportBattleFinished you'll want to use the methods that get fleet snapshots rather than the original ones, because those don't exists anymore; the battle has been cleaned up. Source (http://fractalsoftworks.com/forum/index.php?topic=5061.msg187401;topicseen#msg187401)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 13, 2018, 08:23:20 AM
One more thing: in reportBattleFinished you'll want to use the methods that get fleet snapshots rather than the original ones, because those don't exists anymore; the battle has been cleaned up. Source (http://fractalsoftworks.com/forum/index.php?topic=5061.msg187401;topicseen#msg187401)

Well I'm in a mess, if I want to get the fleet member whose hull ids start with "XXX" and participated in the battle, what should i do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 13, 2018, 09:00:59 AM
Safest way seems to be to call battle.getSnapshotBothSides() and iterate over each fleet and its members.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2018, 09:58:04 AM
(This all sounds right.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 13, 2018, 07:47:24 PM
Safest way seems to be to call battle.getSnapshotBothSides() and iterate over each fleet and its members.
Snapshot means the members involved in the battle? but in the api:
Code
	/**
* Snapshot before the battle, containing any fleets that may have been eliminated during.
* @return
*/
List<CampaignFleetAPI> getPlayerSideSnapshot();

/**
* Snapshot before the battle, containing any fleets that may have been eliminated during.
* @return
*/
List<CampaignFleetAPI> getNonPlayerSideSnapshot();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 14, 2018, 05:06:36 AM
Not sure what you mean. The snapshot methods get the involved fleets (snapshot version), you can then get the fleet members of those snapshots with fleet.getFleetData().getMembersListCopy()
(or get the losses directly with Misc.getSnapshotMembersLost(fleet), if that's what you need)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: atreg on May 14, 2018, 02:10:36 PM
Is there a way to increase the rate at which new officers become available for hire?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 14, 2018, 02:45:56 PM
Is there a way to increase the rate at which new officers become available for hire?
You can increase maximum amount available officers for hire
   "officerMaxHireable":40,
in data/config/settings
It will increase amount of potential recruits - its especially visible when you use many mods with additional markets.
I think they refresh at the same rate that ship market refresh.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: atreg on May 14, 2018, 06:04:40 PM
I have done that in the past, especially when using a lot of mods as you said. There'd still be some officers that would stick around for months, and occasionally what felt like over a year. I had to resort to hiring then immediately firing them just to get rid of them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 15, 2018, 05:32:59 AM
BTW.
What is a order in loading mods?
Do they load in alphabetic order or something?
Why I asking this.
I tend to mildly modify most mods I use(either ships, or fleet composition). So I am asking if I need to modify mod directly(which I do) or I can create a minimod that load after it and change stats of ships or whatever I modify?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nalesh on May 15, 2018, 11:02:16 AM
How hard would it be to make a mod that zeroes out all ships maintenance cost(Effectively making it so that you only need supplies for things like CR, surveying, repairing, etc) without having to go through each ship_data.csv and changing it there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 15, 2018, 12:13:31 PM
BTW.
What is a order in loading mods?
Do they load in alphabetic order or something?
Why I asking this.
I tend to mildly modify most mods I use(either ships, or fleet composition). So I am asking if I need to modify mod directly(which I do) or I can create a minimod that load after it and change stats of ships or whatever I modify?

IIRC it's alphabetical by the mod's ID, but I could be mis-remembering something. So if you start your mini-mod id with say 10 z's (to be on the safe side), that ought to do the trick.

How hard would it be to make a mod that zeroes out all ships maintenance cost(Effectively making it so that you only need supplies for things like CR, surveying, repairing, etc) without having to go through each ship_data.csv and changing it there?

Depends on how comfortable you are with coding and figuring out how Starsector mods are set up. It probably wouldn't be too hard to write a script that zeroes it out for all the ships in the player's fleet, but getting that all up and running is definitely more knowledge-intensive than changing it in the csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nalesh on May 15, 2018, 12:58:19 PM
I code like a junker pirate, it's not gonna be pretty, it might explode at any moment, but it technically flies, if only due to the explosion.

Editing the csv files would probably be easier in the short run but it just doesn't seem elegant enough.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 15, 2018, 01:02:30 PM
junker pirate

elegant

Ahem.

(Sorry, couldn't resist.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 16, 2018, 09:16:45 AM
Thanks for info.

On side note I figured why there is some silly exhaust coming from some of my ships weapons in battle - its Accelerated Ammo feeder in use. Now I feel dumb. Still I can do some tricks right now with it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 17, 2018, 07:15:18 AM
Code
public static class WorkShopData {
        static WorkShopData Instance;
        WeakHashMap<FleetMemberAPI, BowlData> maps;

        public static void Load(SectorAPI sector) {
            if (sector.getPersistentData().containsKey(DATA_ID)) {
                Instance = (WorkShopData) sector.getPersistentData().get(DATA_ID);
            } else {
                Instance = new WorkShopData();
                Instance.maps = new WeakHashMap<>();
                sector.getPersistentData().put(DATA_ID, Instance);
            }
        }
    }
WorkShopData.Load() will be called in OnGameLoad()
Could WeakHashMap work after game load? I want the member will be automaticlly expired to prevent memory leak.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 17, 2018, 08:55:30 AM
Quote
Could WeakHashMap work after game load? I want the member will be automaticlly expired to prevent memory leak.
If the operation's terminated at the end of OnGameLoad() and there isn't any data associated with it still in use by other code, the Garbage Collector should clear it automatically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2018, 09:20:46 AM
It might, but why do it this way at all?

In my own stuff I have code like this:

Code: java
public static final String KEY = "$core_genericMissionManager";

public static GenericMissionManager getInstance() {
Object test = Global.getSector().getMemoryWithoutUpdate().get(KEY);
return (GenericMissionManager) test;
}

public GenericMissionManager() {
super();
Global.getSector().getMemoryWithoutUpdate().set(KEY, this);
}

So you never actually need a static reference to the instance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 17, 2018, 08:38:41 PM
So you never actually need a static reference to the instance.

Well that's my code habit lol
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2018, 10:25:21 PM
Fair enough, just in this case it doesn't seem like a good idea. Looking through the WeakHashMap javadoc, there are ways to mess this up and (in this case) end up with a memory leak. And since you're already putting it into persistent data...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 18, 2018, 07:37:04 AM
Fair enough, just in this case it doesn't seem like a good idea. Looking through the WeakHashMap javadoc, there are ways to mess this up and (in this case) end up with a memory leak. And since you're already putting it into persistent data...
hmm, I will have a try to see if it works.
Btw what's the difference between memory and persistent data in saving information
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 18, 2018, 08:59:54 AM
Btw what's the difference between memory and persistent data in saving information

No real difference. getPersistentData() was just around before I added the memory stuff, which also has other uses.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 18, 2018, 09:20:24 AM
Is possible to make a carrier to carry a frigate instead of fighter wing?
Frigate that behave like normal frigate not like a fighter wing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 18, 2018, 12:58:47 PM
Not without some serious coding-fu.  I built a "missile launcher" that launched Frigates at one point, though... so yeah, doable, just not easy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on May 19, 2018, 02:44:57 AM
Not without some serious coding-fu.  I built a "missile launcher" that launched Frigates at one point, though... so yeah, doable, just not easy.
That its hilarious actually.
Let me precise my question.
Can it would be possible to make carriers launch small vessels size of frigates that have collision?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on May 19, 2018, 09:47:23 AM
You can try it for yourself, change the collision class of a fighter wing.

Mind you, it doesn't precisely work...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 19, 2018, 02:21:23 PM
Quote
Can it would be possible to make carriers launch small vessels size of frigates that have collision?
Yes.  What it launched was, technically, a Missile, that I used code to replace with a Frigate immediately.  Not a Fighter or a Wing.

That's not the hard part; the hard part was weird- it was making sure said Frigates weren't added to the player's fleet at the end of the fight, if they survived. 

Anyhow, yes, this is all possible, yes.  Easy... nope.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on May 19, 2018, 06:46:20 PM
A quick one, easy to answer, not easy to explain clearly. Can a mod modify a value of something in the core game? The question can be divided into two smaller one. Are duplicate of files possible. And does the mod has priority over the core game in this case?

Two exemples:
-Let say I want to modify the caracteristic of the Wolf frigate (armor, speed, etc...). Can I copy paste its value in th ship.csv of my mod and just change the relevant value.
-Same thing with a hull mod. Let sayI just want to change the rengebonus of the targeting core. Can I copy-paste the relevant file in my mod folder, change the relevant value, and the game will take in consideration the file in the mod? Or will the game just crash because of duplicatas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2018, 06:51:21 PM
-Let say I want to modify the caracteristic of the Wolf frigate (armor, speed, etc...). Can I copy paste its value in th ship.csv of my mod and just change the relevant value.

Yes; just make sure the ship ID matches.

-Same thing with a hull mod. Let sayI just want to change the rengebonus of the targeting core. Can I copy-paste the relevant file in my mod folder, change the relevant value, and the game will take in consideration the file in the mod? Or will the game just crash because of duplicatas?

You'll have to add a line to your mod's hull_mods.csv to point that hullmod to a different implementation script, one provided by your mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 22, 2018, 02:34:27 AM
So how could I know if a FleetMemberAPI is removed in other places? If I put it into a Map, the reference will be continue, so when could I remove it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 22, 2018, 10:38:57 AM
So how could I know if a FleetMemberAPI is removed in other places? If I put it into a Map, the reference will be continue, so when could I remove it.

I'm mainly talking about not using a static reference to the instance. That just strikes me as a very bad idea.

Also, make sure that your BowlData does not refer to the fleet member, or to anything that may refer to the fleet member indirectly, as that would prevent it from getting garbage collected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 23, 2018, 08:38:02 AM
I'm mainly talking about not using a static reference to the instance. That just strikes me as a very bad idea.

Also, make sure that your BowlData does not refer to the fleet member, or to anything that may refer to the fleet member indirectly, as that would prevent it from getting garbage collected.
Well BowlData only has a float. So I could use WeakHashMap?
And another question:
Code
	/**
* Base value of the stat is 1.
* @param id
* @return
*/
MutableStat getStat(String id);

/**
* Base value of the stat is 1.
* @param id
* @return
*/
float getValue(String id);


StatBonus getMod(String id);
float getValue(String id, float base);

float getValue(String id); this method gets float from MutableStat map
float getValue(String id, float base); and this method gets float from StatBonus map, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 23, 2018, 08:57:20 AM
Well BowlData only has a float. So I could use WeakHashMap?

I think so. I don't have a lot of experience using these kinds of classes, though.

float getValue(String id); this method gets float from MutableStat map
float getValue(String id, float base); and this method gets float from StatBonus map, right?

Correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 25, 2018, 12:51:59 AM
I think so. I don't have a lot of experience using these kinds of classes, though.

Well.
com.fs.starfarer.combat.CombatMain  - java.util.ConcurrentModificationException
java.util.ConcurrentModificationException

xxxx.entrySet() in a foreach
seems I have to find another way
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 25, 2018, 08:15:36 AM
Could just do "for (Type x : new ArrayList<Type>(xxxx.entrySet())". From what I read the changes to WHM happen in the same thread that's created/using it, so it shouldn't just change w/o you calling a method on it (which may then trigger some keys being cleaned up). So creating a copy of the entry set or whatever you're using would probably do the job.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 26, 2018, 06:04:48 AM
AsteroidBeltGenPlugin creates a pair of ring bands under each asteroid belt. Is there a way to identify all such bands in a system so I can remove them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 26, 2018, 09:13:14 AM
Write a custom public class "MyAsteroidBeltGenPlugin" that implements AsteroidBeltGenPlugin, doesn't generate those ring bands, and invoke that instead.

Or hunt through all SectorEntityAPI objects and find ones that use rings_asteroids0 in their SpriteID?  It's too bad they don't have a specific Tag associated with them to make this easier, but that's how that works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2018, 10:58:01 AM
AsteroidBeltGenPlugin creates a pair of ring bands under each asteroid belt. Is there a way to identify all such bands in a system so I can remove them?

None that I can think of; what's the use case?

Also, added a couple of methods to the API get at the ring band sprite, since as far as I can see that's not currently possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 26, 2018, 08:35:30 PM
Seems I can't get the sprite of arbitrary SectorEntityTokens, so yeah. Also don't feel like replacing the star system generation code just for this.

None that I can think of; what's the use case?
A certain modder found the ring textures used for asteroid belts weren't as visually attractive as desired, so he made his own, presently used for the hand-placed asteroid belts in the mod's star system. We were exploring the possibility of using the custom texture for additional asteroid belts created by StarSystemGenerator.addOrbitingEntities() as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2018, 08:49:00 PM
Hmm, I think replacing this in settings.json:

"rings_asteroids0":"graphics/planets/rings_asteroids0.png",

With the new texture should work? That is, if it's specified in a mod's settings.json, I believe it should override the vanilla texture, at least for new games created after that change is made. Or does this not actually work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 26, 2018, 10:14:47 PM
Overwriting the asteroid ring texture isn't an option, since 1) the mod texture is set up differently (it uses the whole 1024x512 image to define one texture type, instead of four),
and 2) we don't actually want to modify the ring textures outside this one system, that's an invasive change.

Anyway, I found the easy way to replace the asteroid belt gen plugin (thanks for making StarSystemGenerator.terrainPlugins public) so the specific case is dealt with :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2018, 10:22:51 PM
Ah, gotcha. I thought it was meant to be a global change. Glad you got it worked out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gun&drink on May 27, 2018, 10:44:57 AM
So I was trying to revive an old mod (I think that the last time this was updated was in 0.5) and I managed to be able to make the ship and everything appear in-game. the problem is that when trying to fire any of the weapons of this mod the game crashes and this log is what's left:


60095 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 34
60095 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 35
60173 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 36
60173 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 37
60174 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 38
60175 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 39 - last
82423 [Thread-4] INFO  com.fs.starfarer.combat.CombatEngine  - FP1: 135, FP2: 1191, maxFP1: 200, maxFP2: 300
82423 [Thread-4] INFO  org.histidine.chatter.combat.ChatterCombatPlugin  - Chatter plugin initialized
95947 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.ship.A.if.startedChargeup(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.OoOO.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.OoOO.String(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.if.advance(Unknown Source)
   at com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
   at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

where should I start looking for what's wring with the weapons? I checked the vanilla ones to see if anything looked too different but I'm a bit lost
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 27, 2018, 12:18:36 PM
Hello, this is for know, directly with Alex, i think, well, i have a problem with my SAD Faction, who act like Remnant.

Compared to them, they drop survey data.


But like them, if you fight a fleet who flee you, then you let them go, well, you got survey data.
Than you can farm easily.  This is not worth like Ai drop, but same.


A means to fix that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 27, 2018, 12:28:35 PM
I'm assuming you copy-pasted RemnantFleetInteractionConfigGen to work for your faction? IIRC the bug is in there, so you'll need to fix it to only work for ship losses, in the postPlayerSalvageGeneration() method.

Here's what the fixed method looks like on my end, currently:

Spoiler
Code: java
				public void postPlayerSalvageGeneration(InteractionDialogAPI dialog, FleetEncounterContext context, CargoAPI salvage) {
if (!(dialog.getInteractionTarget() instanceof CampaignFleetAPI)) return;

CampaignFleetAPI fleet = (CampaignFleetAPI) dialog.getInteractionTarget();

DataForEncounterSide data = context.getDataFor(fleet);
List<FleetMemberAPI> losses = new ArrayList<FleetMemberAPI>();
for (FleetMemberData fmd : data.getOwnCasualties()) {
losses.add(fmd.getMember());
}

List<DropData> dropRandom = new ArrayList<DropData>();

int [] counts = new int[3];
String [] groups = new String [] {Drops.AI_CORES1, Drops.AI_CORES2, Drops.AI_CORES3};
//for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
for (FleetMemberAPI member : losses) {
if (member.isStation()) {
counts[2] += 10;
}

if (member.isCapital()) {
counts[2] += 2;
} else if (member.isCruiser()) {
counts[2] += 1;
} else if (member.isDestroyer()) {
counts[1] += 1;
} else if (member.isFrigate()) {
counts[0] += 1;
}
}

// if (fleet.isStationMode()) {
// counts[2] += 10;
// }

for (int i = 0; i < counts.length; i++) {
int count = counts[i];
if (count <= 0) continue;

DropData d = new DropData();
d.group = groups[i];
d.chances = (int) Math.ceil(count * 1f);
dropRandom.add(d);
}

Random salvageRandom = new Random(Misc.getSalvageSeed(fleet));
CargoAPI extra = SalvageEntity.generateSalvage(salvageRandom, 1f, 1f, 1f, null, dropRandom);
for (CargoStackAPI stack : extra.getStacksCopy()) {
salvage.addFromStack(stack);
}
}

[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 27, 2018, 01:27:17 PM
Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: stormbringer951 on June 01, 2018, 05:48:17 AM
Is there any way to change the fleet composition depending on fleet size? So small fleets might have a moderate % of small escorts relative to overall small units, while large fleets would not field them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on June 02, 2018, 02:21:16 AM
  • Lava planets will no longer show up as part of the combat background (too bright)
Speaking of Lava planets, I totally forgot to mention that since it has been a while, but I encountered some issues with those (and a few others I think) when making Unknown Skies (http://fractalsoftworks.com/forum/index.php?topic=12041.0). Some planet types do not inherit the propriety of their biome and are just empty when surveyed. I haven't looked at the code in ages though, but for certain categories just adding them to the proper list just isn't working.

Soooooo am I missing something there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2018, 10:50:59 AM
Speaking of Lava planets, I totally forgot to mention that since it has been a while, but I encountered some issues with those (and a few others I think) when making Unknown Skies (http://fractalsoftworks.com/forum/index.php?topic=12041.0). Some planet types do not inherit the propriety of their biome and are just empty when surveyed. I haven't looked at the code in ages though, but for certain categories just adding them to the proper list just isn't working.

Soooooo am I missing something there?

Hmm, could you be more specific? If it's only not working for something in particular, then the devil is probably in the details.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on June 02, 2018, 12:00:00 PM
The planets spawn alright but are empty when surveying ("there is nothing of interest here"). It did it for every Lava biome planets, and I think the hab_1s? Not exactly sure about the later, I'll test that again to be sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2018, 12:31:09 PM
What exactly do you mean by "biome"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on June 03, 2018, 03:13:38 PM
Sorry for busy you, but on my mission where you fight a fleet.

This method is not called after than i have defeated a fleet:
    public void reportBattleOccurred(CampaignFleetAPI primaryWinner, BattleAPI battle)

So, when i go on the sector, the mission finish with :
    public void advance(float amount)

And i go a failure mission because the first method have not be called...

(I have put a tried=0 who go to 1 if the reportBattleOccurred have be called)


How made the first method to work, like this is everything like personBountyEvent class?
Thank you!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 03, 2018, 03:31:35 PM
Sorry for busy you, but on my mission where you fight a fleet.

This method is not called after than i have defeated a fleet:
    public void reportBattleOccurred(CampaignFleetAPI primaryWinner, BattleAPI battle)

Did you register your class as an event listener? Just implementing the interface isn't enough.

I forget if it's possible to add listeners directly to fleets in 0.8; if it is that's the preferred way to do it. Otherwise you can Global.getSector().addListener() it. Also: make very sure to remove it once the event is over, or it'll be a performance/memory leak.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on June 03, 2018, 11:53:29 PM
Sorry for busy you, but on my mission where you fight a fleet.

This method is not called after than i have defeated a fleet:
    public void reportBattleOccurred(CampaignFleetAPI primaryWinner, BattleAPI battle)

Did you register your class as an event listener? Just implementing the interface isn't enough.

I forget if it's possible to add listeners directly to fleets in 0.8; if it is that's the preferred way to do it. Otherwise you can Global.getSector().addListener() it. Also: make very sure to remove it once the event is over, or it'll be a performance/memory leak.

Just add the add on the startEvent, on the remove on the endEvent, so?<
Edit: Work, and i do no think i can better.

Edit2: A tutorial exist for add a custom text for each fleet linked to this Event than you fight?(Like the IBB from SWP)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 04, 2018, 04:50:05 AM
Is there any way to change the fleet composition depending on fleet size? So small fleets might have a moderate % of small escorts relative to overall small units, while large fleets would not field them.
DR mods use the hack of modifying the faction's fleet doctrine before creating the fleet, then changing it back afterwards. (It's used to make larger fleets prefer big ships)
(example (https://bitbucket.org/modmafia/ship-weapon-pack/src/1360cea0c4463d1b876abfcf2f1657c03272b4a4/src/data/scripts/campaign/SWP_FleetFactory.java#lines-91:143))
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on June 04, 2018, 01:52:06 PM
Ok, new stupid question: (The previous have be fixed per this question)


For a custom text for each fleet on my bounty:

When i create the fleet, i add just:
        fleet.getMemoryWithoutUpdate().set("$text2", mission.getDescription2());


Then, he will be retired automatically when the fleet is gone?

Like this thing work for have custom description.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on June 17, 2018, 03:19:42 AM
Quick question, because I'm not sure exactly how to do this: how does one make the small mini descriptions on the UI in the bottom-left of the screen during combat? I want a little thing to pop up as a consequence of activating a speed increase at high flux for a hullmod, but I'm unsure how.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on June 17, 2018, 02:43:00 PM
Are flack weapons not ever returning true for the call DamagingProjectileAPI.didDamage() expected? I'm guessing this has something to do with them doing AoE damage (probably via spawning an explosion). 

So if that's true, is there a way to get all the current explosions and what their source was? I've looked on CombatEngineAPI but I don't see any methods that seem like they would return current explosions.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 17, 2018, 08:04:51 PM
Ok, new stupid question: (The previous have be fixed per this question)


For a custom text for each fleet on my bounty:

When i create the fleet, i add just:
        fleet.getMemoryWithoutUpdate().set("$text2", mission.getDescription2());


Then, he will be retired automatically when the fleet is gone?

Like this thing work for have custom description.

Yes but this doesn't seem like a good idea. Probably better to generate the text where you need to use it, and store whatever parameters you need to do so in memory. Otherwise you're potentially sending a bunch of redundant text data into the savefile.

Are flack weapons not ever returning true for the call DamagingProjectileAPI.didDamage() expected? I'm guessing this has something to do with them doing AoE damage (probably via spawning an explosion). 

So if that's true, is there a way to get all the current explosions and what their source was? I've looked on CombatEngineAPI but I don't see any methods that seem like they would return current explosions.

Thanks!

Pretty sure you're right & nothing comes to mind as far as getting to the explosions. Someone else might have a better idea, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on June 18, 2018, 12:04:05 AM
Ok, new stupid question: (The previous have be fixed per this question)


For a custom text for each fleet on my bounty:

When i create the fleet, i add just:
        fleet.getMemoryWithoutUpdate().set("$text2", mission.getDescription2());


Then, he will be retired automatically when the fleet is gone?

Like this thing work for have custom description.

Yes but this doesn't seem like a good idea. Probably better to generate the text where you need to use it, and store whatever parameters you need to do so in memory. Otherwise you're potentially sending a bunch of redundant text data into the savefile.


The problem is:
The custom text is extremely different of each mission, they are used when you encounter a fleet and dialog with them. The custom text is from a JSON, also, my mod is like a Mission Bounty Framework.
And i do not think than the player will have more than 3 of theses missions. (Limited to 3 on the market)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 18, 2018, 01:17:18 PM
I mean, it's totally fine as a one-off. Just a general point that if everything did it that way, it'd become a problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 19, 2018, 06:53:44 AM
Quick question, because I'm not sure exactly how to do this: how does one make the small mini descriptions on the UI in the bottom-left of the screen during combat? I want a little thing to pop up as a consequence of activating a speed increase at high flux for a hullmod, but I'm unsure how.

Phase cloak uses this:

Code: java
	protected Object STATUSKEY1 = new Object();
protected Object STATUSKEY2 = new Object();
protected Object STATUSKEY3 = new Object();
protected Object STATUSKEY4 = new Object();

protected void maintainStatus(ShipAPI playerShip, State state, float effectLevel) {
float level = effectLevel;
float f = VULNERABLE_FRACTION;

ShipSystemAPI cloak = playerShip.getPhaseCloak();
if (cloak == null) cloak = playerShip.getSystem();
if (cloak == null) return;

if (level > f) {
// Global.getCombatEngine().maintainStatusForPlayerShip(STATUSKEY1,
// cloak.getSpecAPI().getIconSpriteName(), cloak.getDisplayName(), "can not be hit", false);
Global.getCombatEngine().maintainStatusForPlayerShip(STATUSKEY2,
cloak.getSpecAPI().getIconSpriteName(), cloak.getDisplayName(), "time flow altered", false);
} else {
// float INCOMING_DAMAGE_MULT = 0.25f;
// float percent = (1f - INCOMING_DAMAGE_MULT) * getEffectLevel() * 100;
// Global.getCombatEngine().maintainStatusForPlayerShip(STATUSKEY3,
// spec.getIconSpriteName(), cloak.getDisplayName(), "damage mitigated by " + (int) percent + "%", false);
}
}

For a hullmod, use advance() instead of maintainStatus().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on June 20, 2018, 04:24:09 AM
Meso said the same thing. Got it working, thanks Histidine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sylva on July 09, 2018, 07:49:31 AM
Hello people, greenhorn modder here(copypaster)

I'm working on a faction mod (corporation) and was wondering if it is possible to get the faction's capital to move once every 3-6 months to an another system. (Thinking about a smaller, mobile starbase)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: noob_i_am on July 13, 2018, 03:22:03 AM
Im a fan of ballistic weapons and such i love to see pretty fireworks, can someone suggest me a faction mod that, preferably, is working with Nexerelin and Dyna Sector that has a nice ballistic weapons for capital ships. From what i gather, most of the factions avalaible are focusing on energy weapons - i myself like to fly and own capitals with long range balistic weapons.

So anyone have an idea?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on July 13, 2018, 09:16:23 PM
Im a fan of ballistic weapons and such i love to see pretty fireworks, can someone suggest me a faction mod that, preferably, is working with Nexerelin and Dyna Sector that has a nice ballistic weapons for capital ships. From what i gather, most of the factions avalaible are focusing on energy weapons - i myself like to fly and own capitals with long range balistic weapons.

So anyone have an idea?

DiableAvionics have many large ballistic weapons ^^.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 14, 2018, 08:07:56 PM
Blackrock has the ADC Ironweaver, which is hilarious - it's a space shotgun. In a large mount. It's as amazing as you think it is. Also has a Ferrocannon which is one of the most satisfying point-and-eliminate weapons, and the Shard Megacannon, which is hands down one of the best large ballistics options if coupled with a dedicated Targeting core.

SCY has some interesting options, like a gun that can shoot around shields, or a gun that changes from explosive to kinetic the further it travels.

Templar has some hilarious options if you can stomach the flux and OP cost for them, like a gun that shoots straight through shields, ships, etc, and one that shoots essentially a mini-EMP generator like the omen's.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 28, 2018, 08:09:01 PM
Sup, FS
i "made" a lil' script. it works, kinda.
can someone look it over and check if there is horribly wrong with it?
Spoiler
Code: java
package data.scripts;

import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import java.util.List;
import org.lwjgl.util.vector.Vector2f;
import java.awt.Color;
import org.lazywizard.lazylib.combat.entities.SimpleEntity;
import java.util.ListIterator;

public class TF_EF_VENT implements EveryFrameWeaponEffectPlugin {


float delay = 0.3f;
private IntervalUtil fluxInterval = new IntervalUtil(delay, delay*1.5f);

public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
if (engine.isPaused()) return;
if (!weapon.getShip().isAlive()) return;



ShipAPI dfship = weapon.getShip();
Vector2f dftip = MathUtils.getPointOnCircumference(weapon.getLocation(),50f,weapon.getCurrAngle());
float fluxLevel = dfship.getFluxTracker().getFluxLevel();
float maxflux = dfship.getFluxTracker().getMaxFlux();
float dfarea = weapon.getRange();
float dfdamage = weapon.getDerivedStats().getDps()*delay;
float dfflux = weapon.getDerivedStats().getEmpPerSecond()*delay;
Color dfcolor1 = new Color(255, 150, 150);
Color dfcolor2 = new Color(255, 255, 255);

fluxInterval.advance(amount * dfship.getMutableStats().getTimeMult().getModifiedValue());


if (fluxInterval.intervalElapsed()) {

engine.spawnEmpArc(
dfship, //damageSource
dftip, //point
dfship, //pointAnchor
dfship,
DamageType.ENERGY,
0, // damage
0, // emp
100000f, // max range
"",
(dfdamage/4)*(dfship.getFluxTracker().getCurrFlux()/dfship.getFluxTracker().getMaxFlux())+1f,
dfcolor1,
dfcolor2);


if (dfship.getFluxTracker().isOverloadedOrVenting()) {
List <CombatEntityAPI> targets = CombatUtils.getEntitiesWithinRange(dftip,dfarea);

ListIterator<CombatEntityAPI> iter2 = targets.listIterator(targets.size());
while (iter2.hasPrevious()) {
CombatEntityAPI target = iter2.previous();
if (target.getOwner() == dfship.getOwner()) {
iter2.remove();
continue;
}
if (target instanceof ShipAPI) {
ShipAPI ship = (ShipAPI) target;
if (ship.getCollisionClass() == CollisionClass.NONE || !ship.isAlive()) {
iter2.remove();
continue;
}
}
if (!(target instanceof ShipAPI) && !(target instanceof MissileAPI)) {
iter2.remove();
}
}

CombatEntityAPI target = new SimpleEntity(MathUtils.getRandomPointInCircle(dftip, dfarea));
if (iter2.hasNext()){
target = iter2.next();
}
engine.spawnEmpArc(
dfship, //damageSource
dftip, //point
dfship, //pointAnchor
target,
DamageType.ENERGY,
dfdamage/2, // damage
dfflux/2, // emp
100000f, // max range
"tachyon_lance_emp_impact",
dfdamage/4,
dfcolor1,
dfcolor2);

dfship.getFluxTracker().decreaseFlux(dfflux);
if (target instanceof ShipAPI){
((ShipAPI) target).getFluxTracker().increaseFlux(dfflux,true);
}

}
}
}
}
[close]

also a question:
how can i make a weapon not show in weapon groups, while keeping it available for sale
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on August 18, 2018, 03:30:37 AM
Question about something:

My mod add bounty available on a com relay.
These bountys spawn near of the com relay.
Theses bountys fleet are hostile to the player but neutral to every others factions.
When we defeat theses guys, every market on the system wannot trade with you for 2 months or more.
This is normal? If yes, how resolve this problem?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 18, 2018, 08:15:45 AM
also a question:
how can i make a weapon not show in weapon groups, while keeping it available for sale

Oh, hey - sorry I totally missed that. I'm not sure I understand the question, exactly - do you want the weapon to be mounted on the ship by the player but not show up in weapon grounds? Or?

Question about something:

My mod add bounty available on a com relay.
These bountys spawn near of the com relay.
Theses bountys fleet are hostile to the player but neutral to every others factions.
When we defeat theses guys, every market on the system wannot trade with you for 2 months or more.
This is normal? If yes, how resolve this problem?

Are you sure they're neutral and not cooperative? Looking at the code, it looks like the "hostile activity near market" timeout gets set for every market within 5500 range that's at worst cooperative with the enemy fleet
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on August 18, 2018, 09:09:48 AM
Yes, i have see the code who do that, then, i have looked on my code, and they are neutral. I have put suspicious for be sure, seems to work.
After have talked with the Nexerelin Creator, some of these problems maybe belong to some code.

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on August 29, 2018, 01:24:14 PM
Hello, i will request a solution for a another problem "Lost progression with the save".


My misc mod need to save some value and list of string and many others values too.
For many week, i have not problem of saving, but when i have inserted the option Endless battle where you can fight round more overpower on each round (with reward), i have a problem of.... integer.

My problem is simple:

Code
public class GS_EndlessContent {
    ...
    private int endlessRound = 0;
    ...
}

This class is on XStream:
Code
        x.alias("GS_EndlessContent", GS_EndlessContent.class);

And some people lost their progression, they are on the round 7, save, alt+f4, then re-launch the game and see with surprise they have now to the round 4.
The integer is saved, but look like the save do not save the current value but a old.
A means to resolve this problem?


Thank!



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 29, 2018, 02:04:19 PM
I'd be very surprised if this problem was related to game-saving. I don't recall ever seeing any issues with incorrect values being saved. The only case that was remotely similar was when a derived class had a private variable with the same name as a base class; perhaps that's what's going on here? Other than that, I'd still suspect some sort of logic error in your code - this sort of save problem seems very unlikely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on August 30, 2018, 12:42:52 AM
This is all variable and the two methods who use the endlessRound, the endlessRound is used only for be displayed on a com relay.
Code
public class GS_EndlessContent {

    private int endlessPower = 10;
    private int endlessRound = 0;
    private int roundloop = 0;
    private int reward = 0;
    private int rank = 0;

    private static final List<String> SHIPS = new ArrayList();

    static {
        SHIPS.add("GS_Guppy_Empty");
        SHIPS.add("GS_Night_Fury_Empty");
        SHIPS.add("GS_Dragonfly_Empty");
        SHIPS.add("GS_Druid_Empty");
        SHIPS.add("GS_Bloody_Submarine_Empty");
        SHIPS.add("GS_Samurai_Empty");
        SHIPS.add("GS_Guppy_Empty");
        SHIPS.add("GS_Night_Fury_Empty");
        SHIPS.add("GS_Dragonfly_Empty");
        SHIPS.add("GS_Guppy_Empty");
        SHIPS.add("GS_Night_Fury_Empty");
        SHIPS.add("GS_Dragonfly_Empty");
       
    }

    private final Set<Integer> shipTaken = new HashSet<>();
    private List<String> currentShip = new ArrayList<>();

    ...

    public int getEndlessRound() {
        return endlessRound;
    }

    public void incEndlessRound() {

        endlessRound++;
        roundloop++;

        if (roundloop > 4) {
            roundloop -= 5;
            reward++;
            rank++;
            if (rank > 5) {
                reward--;
            }

        }
    }

    ...

}
He do not have a derived class on this class.
For the logic error, this is very strange.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 31, 2018, 08:12:17 AM
I need a way to tell a fleet "touch this other fleet, do not run from stronger fleets (target included), ignore sensor state". Is there a fleet AI setting, assignment or whatever that lets me do this?

INTERCEPT seems good at making the fleet wander off in a random direction. I think HOLD might be able to do it, but I still need a way to suppress the fleeing behavior.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 31, 2018, 05:58:25 PM
Hmm, not sure - I think calling fleet.setMoveDestinationOverride() might do the job. Combined with fleet.getAI().setActionTextOverride() so that it looks like it's doing whatever you want it to be doing, which I *think* is in the current API.


This is all variable and the two methods who use the endlessRound, the endlessRound is used only for be displayed on a com relay.

...

He do not have a derived class on this class.
For the logic error, this is very strange.

That's odd - I don't have a good answer for you. Still doubt it's the save code, though; if it was going to mess up, it'd mess up worse. It wouldn't make much sense for it to just pull a slightly wrong value for that variable out of nowhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Takion Kasukedo on September 03, 2018, 03:46:12 PM
Clip size question - How do you make the reload longer and adjust clip reload size?

The clip size-per reload isn't mandatory, but i'm really confused about the reload time for said clip. Does it have to be decimals?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 03, 2018, 04:03:54 PM
If clip size is unspecified, it defaults to 1, btw.

Let's say the clip size is 20. If ammo/second is .1, this means it takes 10 seconds for 1 ammo to regenerate. Since the clip size is 20, it would take 20 * 10 = 200 seconds per clip. A more reasonable ammo/second of 1 would mean a 20 second reload time per clip. Does that make sense?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on September 05, 2018, 03:03:10 AM
Just checking: EMP disables missile warheads, making them not do damage on collision, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 05, 2018, 09:13:40 AM
A hit from the EMP ship system will, but that's not an intrinsic property of either EMP arcs or EMP weapon damage.

Missiles can also have an "emp resistance" set through code, which will make them ignore this effect for X EMP system hits.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Takion Kasukedo on September 06, 2018, 03:10:16 AM
If clip size is unspecified, it defaults to 1, btw.

Let's say the clip size is 20. If ammo/second is .1, this means it takes 10 seconds for 1 ammo to regenerate. Since the clip size is 20, it would take 20 * 10 = 200 seconds per clip. A more reasonable ammo/second of 1 would mean a 20 second reload time per clip. Does that make sense?

That seems to make sense, thanks Alex!

Another question for those modders out there, though.

How does one make a high-profile projectile that smashes through ordnance and low-profile objects, allowing it to reach it's maximum distance without having all of it's damage go into a stray rocket?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on September 06, 2018, 06:57:31 AM
Another question for those modders out there, though.

How does one make a high-profile projectile that smashes through ordnance and low-profile objects, allowing it to reach it's maximum distance without having all of it's damage go into a stray rocket?
I THINK the only way to do this is by making a projectile plasma based (IE the same thing the PCannon uses)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 06, 2018, 08:51:00 AM
Pretty sure this is correct, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 07, 2018, 08:46:55 AM
Is there an easy way to, given a Vector2f and a CombatEntityAPI, get the nearest point on the entity's targeting radius?

EDIT: or better yet, to the nearest point on its collision bounds
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 07, 2018, 09:15:16 AM
com.fs.starfarer.api.util.Misc.getTargetingRadius() gets you the targeting radius from that point; from there it's a bit of vector math. IIRC there's nothing like that for collision bounds.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 07, 2018, 11:45:18 AM
On the Plasma Cannon projectile effect... it'd sure be nice to have a boolean for other .proj types, but IIRC can't we also use collision masks?  Or does that not work any more?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on September 13, 2018, 02:16:40 AM
...or better yet, to the nearest point on its collision bounds
LazyLib has a function for this using CollisionUtils.getCollisionPoint(), which takes in two Vector2f (acting as start and end of a line) and a combatEntityAPI. It returns the first hit location the line would hit on the collision bounds of the target.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 13, 2018, 05:12:18 AM
I need the nearest point though, not the one on a line passing through the entity center.

e.g. the point marked with an orange star, not the red one:
(https://i.imgur.com/FL949nM.png)

(actually I don't need it any more, decided that using the targeting radius was good enough and the best approach I've been able to think of for the way I wanted involves ray cast spam)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2018, 09:14:17 AM
If it still matters, or for future reference:

Code: java
public static Vector2f closestPointOnSegmentToPoint(Vector2f p1, Vector2f p2, Vector2f p3) {
float u = (p3.x - p1.x) * (p2.x - p1.x) + (p3.y - p1.y) * (p2.y - p1.y);
float denom = Vector2f.sub(p2, p1, new Vector2f()).length();
denom *= denom;

u /= denom;

// if closest point on line is outside the segment, clamp to on the segment
if (u < 0) u = 0;
if (u > 1) u = 1;

Vector2f i = new Vector2f();
i.x = p1.x + u * (p2.x - p1.x);
i.y = p1.y + u * (p2.y - p1.y);
return i;
}

Segment is p1 to p2, external point is p3.

(The approach is figuring out where a normal from the line to the point would be on the line.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on September 17, 2018, 05:00:55 PM
So what is the range of the random seed used by sector generation?

Doing some testing I realized that the seed "MN-0" works, and it works up to a number that is over "MN-9000000000000000000" but below "MN-9999999999999999999" at which point the game won't recognize it as a valid seed.

Fun fact "MN-9999999999999999999" is not the limit as I expected, it is something lower than that since "MN-9999999999999999998" wouldn't work either; nor is it "MN-9000000000000000000", since the game generates seeds that are over it, although somewhat rarely?.
Also I did spend some time getting random seeds; none seemed to be less than 19 digits (I admit I might have missed some that were), that said, less than 19 digits seeds do work.

Why would I want to know about this? I actually want to have a customized star system to generate in a "random" location that is seed dependent. Considering that I could just assume the range to be "0 to 9999999999999999999", to select a "random" point between a circle, this is not a big issue...
However mainly out of curiosity, I would like to know what are the ranges for this, both the maximum and minimum the game would accept, and the range the game actually generates the seeds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2018, 05:20:37 PM
The seed is a long-type value.

However, if you're looking to use an rng based on the seed, I'd suggest just using StarSystemGenerator.random during the sector generation process.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 22, 2018, 08:03:29 AM
Could SettingsAPI.getVariant(variantId) (and maybe FactoryAPI.createFleetMember(variantId)) with a variant that doesn't exist return null instead of throwing a RuntimeException? Doing a try/catch to check if a variant exists feels pretty silly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2018, 09:09:14 AM
Added: SettingsAPI.doesVariantExist(String variantId)

I'd like to keep the runtime exception behavior since it makes it easier for me to track down problems (say, when a variant is not found due to a *bug*) because then I'll know the variant ID that caused it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on September 22, 2018, 11:57:39 PM
What program would be best used to modify .csv files?

A program that isn't microsoft excel.

I've tried libreoffice, but apparently that makes the game crash even when i save as a .csv.

so I'm wondering if I'm missing something..
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on September 23, 2018, 12:23:00 AM
LibreOffice is fine, you probably don't have the separator / delimiter options setup correctly.

(https://cdn.discordapp.com/attachments/310517733458706442/491559774601609216/unknown.png)

While that is a screenshot from Open Office, the same line of thought applies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 23, 2018, 02:21:10 AM
(https://i.imgur.com/AxJDdoN.png)

What makes the core worlds have the multi-colored background, and how do I duplicate it?

The core sector generation scripts don't create a constellation, so I'm guessing it's automatically generated from the in-system nebulae at some point. But when I create a custom constellation, it either uses a uniform nebula color for the whole starscape, or no nebula at all (with ConstellationType.NORMAL).
(I'd try not making the constellation at all, but NameAssigner needs a constellation param)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 23, 2018, 09:58:06 AM
system.setAge(StarAge.age);
system.setHasSystemwideNebula(true);

Both of the above are called from StarSystemGenerator.addSystemwideNebula(), which is how this happens for the vanilla core worlds.

The color of the nebula around the star is based on the StarAge of the system. Amber = old, purple = average, and blue = young, iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on September 26, 2018, 04:51:20 AM
Hello, i have a weird problem.
I cannot reproduce the bug, just one person has this crash(2times).
On my mod, i generate a BountyEvent with a faction then set the fleet with a casual faction(like Pirate)
Code
       fleet.setFaction(GS_Constants.GSFACTION_ID, true);

When this fleet catch the player and then crash.
Quote
332599 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain - java.lang.NullPointerException java.lang.NullPointerException at src.data.scripts.campaign.missions.GS_EventEndlessBattle.getCurrentImage(GS_EventEndlessBattle.java:438) at com.fs.starfarer.campaign.CampaignEngine.reportEventStage(Unknown Source) at com.fs.starfarer.campaign.CampaignEngine.reportEventStage(Unknown Source) at src.data.scripts.campaign.missions.GS_EventEndlessBattle.advance(GS_EventEndlessBattle.java:242) at com.fs.starfarer.campaign.events.CampaignEventManager.advance(Unknown Source) at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source) at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source) at com.fs.starfarer.BaseGameState.traverse(Unknown Source) at com.fs.state.AppDriver.begin(Unknown Source) at com.fs.starfarer.combat.CombatMain.main(Unknown Source) at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

The game try to catch the logo of the fleet and get a null.
But, this thing happens for this player after the 17th to 19th BountyEvent.(Where the fleet points is bigger each time(20capitals+ at this moment))


Code
    @Override
    public String getCurrentImage() {
        return faction.getLogo();
    }

The code is here, but i do not think this is usefull, like this thing is a random crash where just the fleet size of the fleet look like a problem.
Spoiler
https://bitbucket.org/Snrasha/gs/src/0bc1f36ba05037e443b499e4947ee81bec44ca68/src/data/scripts/campaign/missions/GS_EventEndlessBattle.java
[close]

The only other link except the size is the faction used for the generation, the remnant faction.
One of these fleet:
Spoiler
(https://i.imgur.com/mVGeCnX.png)
[close]

But i am sure than every available faction is set and have a logo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2018, 09:25:13 AM
The only possible way it can throw a NullPointerException on that line:

return faction.getLogo();

is if faction is null. So, I'd look for any reason that might be the case. Offhand, it's *probably* because:

Global.getSector().getFaction(content.getEndlessFaction());

returns null at some point. That is, the getFaction() method does, because of whatever is passed in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on September 26, 2018, 09:39:57 AM
The only possible way it can throw a NullPointerException on that line:

return faction.getLogo();

is if faction is null. So, I'd look for any reason that might be the case. Offhand, it's *probably* because:

Global.getSector().getFaction(content.getEndlessFaction());

returns null at some point. That is, the getFaction() method does, because of whatever is passed in.
But like he need the faction for made the fleet who have be created, the faction is not null :x
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2018, 09:58:41 AM
Could be that it failed to create the fleet, but it advances one frame before being removed. If so, then an "if (isDone()) return" check in advance() might fix this.

Regardless, faction is *definitely* null there. No other way for that crash to happen. Regardless of how that might seem to be impossible, that is nonetheless the case, and any investigation of the bug ought to be based on figuring out why/how it's null there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on September 29, 2018, 01:19:36 PM
Could be that it failed to create the fleet, but it advances one frame before being removed. If so, then an "if (isDone()) return" check in advance() might fix this.

Regardless, faction is *definitely* null there. No other way for that crash to happen. Regardless of how that might seem to be impossible, that is nonetheless the case, and any investigation of the bug ought to be based on figuring out why/how it's null there.

Look like this is that, for the person, he do not have crash anymore ^^. Thank.

Else, good question, but i know probably the answer:
Spoiler
(https://i.imgur.com/mRH3QlU.gif)
[close]
Any means to slow the spin of these shields when you put a texture shield on them?
Thank!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2018, 09:04:14 PM
Else, good question, but i know probably the answer:
Spoiler
(https://i.imgur.com/mRH3QlU.gif)
[close]
Any means to slow the spin of these shields when you put a texture shield on them?
Thank!

There isn't, but let me add some methods to ShieldAPI:

float getInnerRotationRate();
void setInnerRotationRate(float innerRotationRate);
float getRingRotationRate();
void setRingRotationRate(float ringRotationRate);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on September 29, 2018, 10:31:51 PM
Else, good question, but i know probably the answer:
Spoiler
(https://i.imgur.com/mRH3QlU.gif)
[close]
Any means to slow the spin of these shields when you put a texture shield on them?
Thank!

There isn't, but let me add some methods to ShieldAPI:

float getInnerRotationRate();
void setInnerRotationRate(float innerRotationRate);
float getRingRotationRate();
void setRingRotationRate(float ringRotationRate);

Thank, same if this is not very important like, i suppose, i will be the unique guy who use these methods ^^.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jay2Jay on October 22, 2018, 02:38:55 PM
Yo, I was wondering if I could make a sort of smoke stack by using like, particle effects or something to generate some thick black smog from ma ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheWetFish on November 07, 2018, 09:16:31 PM
Yo, I was wondering if I could make a sort of smoke stack by using like, particle effects or something to generate some thick black smog from ma ship.
Do you mean a small smoke stack by generating smoke particles via CombatEngineAPI.addSmokeParticle (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/CombatEngineAPI.html#addSmokeParticle(Vector2f,%20Vector2f,%20float,%20float,%20float,%20java.awt.Color)) or something bigger & better performance via MagicRender.objectspace (https://starsector.wikia.com/wiki/MagicLib#MagicRender) to draw overlapping spinning smog sprites?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 13, 2018, 04:34:43 AM
Hypothetical:

Does a fighter wing's FleetMemberAPI have persistence between battles? Or can it be identified with a specific LPC instance to serve as its permanent identifier, even if the FMAPI itself is recreated every battle?
(Suppose I want to associate a particular string value with Spark Wing #92, which is currently installed on the ISS Foobar, Drover-class, but could be moved to another ship or sold tomorrow)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 13, 2018, 09:40:05 AM
It doesn't persist, no. Hmm - nothing comes to mind, really. As far as the variant is concerned, the fighter LPC is just a string with the id of the fighter wing, so I don't think there's any way to differentiate one from another. Once installed on a ship, LPCs (and weapons) stop existing aside from just as that string.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on November 13, 2018, 07:34:47 PM
I want to make a small library only used by my own mods, so if I put the library and the mod into one jar(and there are 2 mods do so)will they conflict with each other because of class loader?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 13, 2018, 07:53:54 PM
Yeah, probably, that sounds like asking for trouble. I mean it'll probably work at first glance but could also produce some weird and hard-to-track-down issues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flet on November 20, 2018, 02:23:53 AM
How would i go about making a mod that prevents the game from generating male characters entirely?
Before anyone gets the wrong idea, i see this as a preferable alternative to having to make my own portrait pack that has both males and females of similar art style. It seems easier to just remove male npcs entirely than having to make portraits of them  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on November 20, 2018, 02:51:53 AM
males are truly the most oppressed lol gamers rise up
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2018, 08:07:27 AM
How would i go about making a mod that prevents the game from generating male characters entirely?
Before anyone gets the wrong idea, i see this as a preferable alternative to having to make my own portrait pack that has both males and females of similar art style. It seems easier to just remove male npcs entirely than having to make portraits of them  ;)

Hmm, nothing simple comes to mind. It's just a hardcoded 50/50 chance in core code.


@Deshara: let's try to keep things constructive and on-topic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 20, 2018, 09:04:29 AM
Hey hey, all. So as some of you may know I've set up a number of custom industries with my Shadowyards mod, including an alternative version of the Heavy Industry industry type present in the default game. It is intended to include support for Nanoforges, but right now this support is partial and in particular is missing a key component; while the production bonuses are being applied as intended, you can't install a Nanoforge. The installation dialogue comes up, but doesn't grab Nanoforges in your inventory.

Right now my best guess is that NanoforgeItemPlugin isn't playing ball, probably because I ended up resorting to duplicating (with modifications where appropriate) the HeavyIndustry and NanoforgeInstallableItemPlugin java classes in order to get this working. I'm not really sure how to solve this right now, so I figured I'd ask if anyone had any ideas. Thanks in advance for any help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2018, 09:50:57 AM
Does your industry have a getInstallableItems() method that returns the proper, copied plugin?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 20, 2018, 10:08:29 AM
something that looks like this, right?

Code
@Override
public List<InstallableIndustryItemPlugin> getInstallableItems() {
ArrayList<InstallableIndustryItemPlugin> list = new ArrayList<>();
list.add(new MS_NanoforgePlugin(this));
return list;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2018, 10:09:42 AM
I'm talking about this method:
@Override
public List<InstallableIndustryItemPlugin> getInstallableItems() {
   ArrayList<InstallableIndustryItemPlugin> list = new ArrayList<InstallableIndustryItemPlugin>();
   list.add(new NanoforgeInstallableItemPlugin(this));
   return list;
}

The plugins in the list it returns are used to populate the dialog with what's actually installable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 20, 2018, 10:17:02 AM
Oh, maybe it's the diamond inference; I'll try being explicit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 20, 2018, 01:10:23 PM
Okay, so finally got back to the testing and determined that it's not the diamond inference, and I'm not sure what else it could be in getInstallableItems(). So that seems like it would narrow it down to MS_NanoforgePlugin, but that class is literally just a copy/pasted NanoforgeInstallableItemPlugin script with some changed names, so I'm not sure what'd be up there.

Also, sorry. I realized you were talking about a specific thing just after I posted that, Alex.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 20, 2018, 01:16:12 PM
I had the idea of upgrading the Population & Infrastructure industry into government types. However, upon inspection it seems like this industry uses its upgrade code to handle population growth (and in game testing shows that immediately upon founding the Population starts to "upgrade" into the new industry).

Is upgrading the population industry not possible atm? If yes thats ok as I will put the functionality somewhere else, mainly I'm just looking for confirmation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2018, 01:23:24 PM
Okay, so finally got back to the testing and determined that it's not the diamond inference, and I'm not sure what else it could be in getInstallableItems(). So that seems like it would narrow it down to MS_NanoforgePlugin, but that class is literally just a copy/pasted NanoforgeInstallableItemPlugin script with some changed names, so I'm not sure what'd be up there.

Also, sorry. I realized you were talking about a specific thing just after I posted that, Alex.

If you can package it up in a mini-mod (or just post your code for the plugin and the industry in a new thread), I can take a look.

I had the idea of upgrading the Population & Infrastructure industry into government types. However, upon inspection it seems like this industry uses its upgrade code to handle population growth (and in game testing shows that immediately upon founding the Population starts to "upgrade" into the new industry).

Is upgrading the population industry not possible atm? If yes thats ok as I will put the functionality somewhere else, mainly I'm just looking for confirmation.

Yeah, confirming.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 20, 2018, 01:28:18 PM
Great, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 20, 2018, 04:27:51 PM
Anyone got any idea how to make non-standard commodities export in the colony screen?

So figured I'd try and be a bit more specific here; the SRA is the only faction I know of that has mundane custom commodities. These have been somewhat sub par for a while now, but with the 0.9a update it's become necessary to get them up to snuff. In particular, two things are needed.

They need to be able to fill a demand class; currently they're set to being luxury items, which is not exactly ideal, so being able to incorporate them into existing demand classes more smoothly, or into custom demand classes if possible, would be very nice.

And, more importantly now with player owned colonies being a thing they need to be able to produce export value. There isn't really anything to go off of here and my fumbling around hasn't been too successful; any advice would be appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 20, 2018, 06:46:03 PM
- Was the "grant autonomy" function taken out before the 0.9 release?
I'm trying to figure out how Nexerelin should handle the player conquering a large number of markets. For balance reasons, only a small portion of these should generate income for the player. Also we don't want the surplus of market inflicting massive unavoidable stability penalties on the player faction. (I could retain the old hack of keeping the "player" markets under a separate NPC faction, but that's undesirable for a bunch of reasons)

- Can I control the monthly output of tech-mining operations on a per-market basis?
Specific case to handle: Mod faction "Foobar" operates in an "alternate dimension". Tech-mining on markets in the AD should produce only Foobar ships/weapons/blueprints (i.e. not those from the vanilla or other mod factions), and tech-mining in the normal sector should never produce these Foobar items.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2018, 07:00:10 PM
- Was the "grant autonomy" function taken out before the 0.9 release?
I'm trying to figure out how Nexerelin should handle the player conquering a large number of markets. For balance reasons, only a small portion of these should generate income for the player. Also we don't want the surplus of market inflicting massive unavoidable stability penalties on the player faction. (I could retain the old hack of keeping the "player" markets under a separate NPC faction, but that's undesirable for a bunch of reasons)

Yeah. Basically same questions as you're asking, and I punted on it for the time being. If you figure it out, let me know :)

(Possibility: assigning administrators with a skill tagged "npc_only" that reduces the colony's income, sort of the opposite of Industrial Planning?)

- Can I control the monthly output of tech-mining operations on a per-market basis?
Specific case to handle: Mod faction "Foobar" operates in an "alternate dimension". Tech-mining on markets in the AD should produce only Foobar ships/weapons/blueprints (i.e. not those from the vanilla or other mod factions), and tech-mining in the normal sector should never produce these Foobar items.

If you implement a custom Tech-Mining industry, you can do that in its generateCargoForGatheringPoint() method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 20, 2018, 08:20:02 PM
Hmm. Okay, a request: Could we get a way to catch the production intel report and modify its ProductionData? Like:

- Add an IntelEventListener interface or somesuch that gets when an intel item is added
- Add a getter for the ProductionData variable in ProductionReportIntel class

Now the mod can detect when the production report comes in, and modify the ProductionData (and the gathering point's cargo) as it deems fit. The production report is thus updated for the player with the modified production.

(The alternative is modifying the techmining industry's Java class (or worse, the CoreScript), which isn't quite desirable if multiple mods end up wanting to change this.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 20, 2018, 08:44:48 PM
Is it possible to easily change the number of slots available on a colony for building? Ideally I want to reduce it, with the current number being the max.

I can think of a way by rewriting the isAvailableToBuild function in all of the industry implementations but that would be incompatible with any other mod that changed them (or that added new industries, as they would not be bound to the same restriction).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2018, 08:47:49 PM
@Histidine: made a note, shouldn't be too hard with the new listener manager system.

@Thaago: that's <checks> super hardcoded in core code, actually.

boolean canAdd = getNotHidden().size() < 12;

Oh, that's good stuff. I'll... see about doing this at some point. Fair warning, my TODO list has well over 100 items on it right now :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on November 20, 2018, 10:28:51 PM
Is there any way to force a star system that contains markets to be hidden on the hyperspace map/not show a name?

Example: I want to hand-build a pirate system out in the fringes. I can set the markets to hidden so they don't show up on the system map (though they do still show up in the planet listing... and ping when you hit 'show on map'... oops  :P) but I can't seem to find a way to set a whole system to 'undiscovered".

Ancillary question: How can I flag a station as "destroyable", like pirate/pather bases are?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 21, 2018, 09:39:53 AM
question - is there any way to limit fighter/bomber bluperints on a ship-to-ship basis?

For example, I want a ship that can only mount fighters, but not bombers.

If something like that does not exist, it should. An easy way to implement would be to add a column to the ships (hangar_size) and a column to the wing/fighter (fighter_size)
Those would be numerical values that would determine what fightercraft can be mounted.
1 - light fighter
2 - medium fighter
3 - heavy fighter
4 - bomber
5 - heavy bomber
6 - ultraheavy bomber
7 - insanity, etc...

So a carrier that has a hangar size of 5 can carry anything up to (and including) that size - any wing with a value of 5 and lower would be allowed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 21, 2018, 11:03:04 AM
Well, things that have been determined so far in my efforts:

A script seems necessary to get custom commodities to export, and it's not terribly clear how to get this to happen. So far my efforts have not met with any sign that it's doing anything at all.

Both of my scripts basically looks like this:

Spoiler
Code: java
package data.campaign.econ;

import com.fs.starfarer.api.impl.campaign.econ.BaseMarketConditionPlugin;

public class MS_hdbatteries extends BaseMarketConditionPlugin {
 
    @Override
    public void apply(String id) {
        super.apply(id);
        market.getCommodityData(id).getCommodityMarketData();
        market.getCommodityData(id).getUtilityOnMarket();
        market.getCommodityData(id).getDemand();
        market.getCommodityData(id).getExportIncome();
    }
 
    @Override
    public void unapply(String id) {
        super.unapply(id);
    }
}
[close]

I've got the scripts being called correctly via the commodity plugin field in the csv, but nothings happening. I've also tried taking the scripts out, also to no avail. It's not really clear what's going on here, so I'm just kinda fumbling around. Sorry for the trouble.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2018, 11:20:17 AM
Is there any way to force a star system that contains markets to be hidden on the hyperspace map/not show a name?

Example: I want to hand-build a pirate system out in the fringes. I can set the markets to hidden so they don't show up on the system map (though they do still show up in the planet listing... and ping when you hit 'show on map'... oops  :P) but I can't seem to find a way to set a whole system to 'undiscovered".

Ancillary question: How can I flag a station as "destroyable", like pirate/pather bases are?

I think you need to also market.setEconGroup(<something other than null>).


question - is there any way to limit fighter/bomber bluperints on a ship-to-ship basis?

For example, I want a ship that can only mount fighters, but not bombers.

There isn't directly, no. Although you could take a look at ConvertedHangar and add a similar built-in hullmod that makes the types you don't want to permit prohibitively expensive.


Well, things that have been determined so far in my efforts:

A script seems necessary to get custom commodities to export, and it's not terribly clear how to get this to happen. So far my efforts have not met with any sign that it's doing anything at all.

Both of my scripts basically looks like this:

Spoiler
Code: java
package data.campaign.econ;

import com.fs.starfarer.api.impl.campaign.econ.BaseMarketConditionPlugin;

public class MS_hdbatteries extends BaseMarketConditionPlugin {
 
    @Override
    public void apply(String id) {
        super.apply(id);
        market.getCommodityData(id).getCommodityMarketData();
        market.getCommodityData(id).getUtilityOnMarket();
        market.getCommodityData(id).getDemand();
        market.getCommodityData(id).getExportIncome();
    }
 
    @Override
    public void unapply(String id) {
        super.unapply(id);
    }
}
[close]

I've got the scripts being called correctly via the commodity plugin field in the csv, but nothings happening. I've also tried taking the scripts out, also to no avail. It's not really clear what's going on here, so I'm just kinda fumbling around. Sorry for the trouble.

I'm sorry, I have no idea what you're trying to do :)

market.getCommodityData(id).getCommodityMarketData();

id here is the id of the market condition; calling getCommodityData() with that as a parameter seems all sorts of wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 21, 2018, 11:31:39 AM
Okay, to clarify what I'm trying to do is to get a couple of commodities being produced by Industries added by my mod to export from a colony; this wasn't so important in the last version of Starsector, but since players can now establish colonies and build these industries they need to actually export the goods they produce. As it currently stands they're just a credit sink.

Unfortunately I have nothing to go on, and... well, I don't even know where to start on this, so I am basically flailing around and trying to find something that might work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bowman on November 21, 2018, 11:53:10 AM
Not sure where to ask this but don't want to make a new topic just for it so I figure this is the most reasonable place.

Is there any mod that adds phase-equipped exploration ships? Something akin to the Apogee but with a phase drive and cruiser/capital tier? I like the idea of having a phase-only exploration fleet given the phase drive drops sensor profile to 0 (not that I have particular problems with sensors, simply that the theme behind such a fleet would be fun to me).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2018, 11:57:17 AM
Okay, to clarify what I'm trying to do is to get a couple of commodities produced at Industries added by my mod to export from a colony; this wasn't so important in the last version of Starsector, but since players can now establish colonies and build these industries they need to actually export the goods they produce. As it currently stands they're just a credit sink.

Unfortunately I have nothing to go on, and... well, I don't even know where to start on this, so I am basically flailing around and trying to find something that might work.
\

This may warrant a separate thread here in Modding - too many details and too many potential complications.

One key thing to note, however, is for something to be exported, there must be demand for it. So if you're just adding a new commodity, that might be an issue.

Generally speaking, adding new commodities could be trouble; the UI space to handle them is fairly limited.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on November 21, 2018, 03:44:49 PM
Thanks for all the help & support btw, Alex. It's really appreciated -- I've never seen a game before where the dev personally helped modders figure stuff out :D

While I'm here: Is there a way to manually set a planet (in a system with markets) to be unsurveyed -- and if so, what are the prerequisites for doing that? The basics (".setSurveyLevel(SurveyLevel.NONE)") didn't seem to work for me
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2018, 04:00:52 PM
Thanks for all the help & support btw, Alex. It's really appreciated -- I've never seen a game before where the dev personally helped modders figure stuff out :D

You're welcome! I'm happy to help; and the fact that mods add such cool stuff really doesn't hurt :)

While I'm here: Is there a way to manually set a planet (in a system with markets) to be unsurveyed -- and if so, what are the prerequisites for doing that? The basics (".setSurveyLevel(SurveyLevel.NONE)") didn't seem to work for me

I think you also need to do:
for (MarketConditionAPI mc : market.getConditions()) {
    if (mc.requiresSurveying()) {
   mc.setSurveyed(false);
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on November 22, 2018, 11:41:19 AM
Would there be any extra steps needed to add a skill to an officer or administrator via rulecommand? Just wanted to check as it seems like the script I dug out from 0.8.1a  doesn't seem to work (as in, when the officer or admin shows up, they don't have that one specific skill)

Spoiler
Code: java
package data.scripts.campaign.rulecmd;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.rules.MemKeys;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.characters.FullName;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent;
import com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent.SkillPickPreference;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Personalities;
import com.fs.starfarer.api.impl.campaign.rulecmd.BaseCommandPlugin;
import com.fs.starfarer.api.util.Misc;

import java.util.List;
import java.util.Map;

public class AEAddSierraOfficer extends BaseCommandPlugin

{
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap)
    {
        final MemoryAPI localMemory = memoryMap.get(MemKeys.LOCAL);
        if (localMemory == null) return false;
        FullName name;
        CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
        PersonAPI officer = OfficerManagerEvent.createOfficer(Global.getSector().getPlayerFaction(), 3, false, SkillPickPreference.NON_CARRIER);
        name = new FullName("Sierra", "", FullName.Gender.FEMALE);
        officer.setPortraitSprite("graphics/portraits/ae_portrait_purple.png");

        officer.getStats().setSkillLevel("ae_sierrasconcord", 3);
        officer.setPersonality(Personalities.STEADY);
        officer.setFaction(Factions.INDEPENDENT);
        officer.setName(name);
        officer.getStats().setSkipRefresh(true);
        playerFleet.getFleetData().addOfficer(officer);
        return true;
    }
}
[close]

The skill itself works fine - no problems with it as a player skill. I've also tried it with an ID set in a class but it makes no difference. Also no crashing of any sort.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2018, 12:06:11 PM
This bit may cause issues:

officer.getStats().setSkipRefresh(true); 

You generally only want to call it if adding a bunch of skills so that the officer's stats don't keep updating on every skill change, and then only when it's in performance-critical code. You'd also always want to call officer.getStats().setSkipRefresh(false); when you're done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on November 22, 2018, 01:35:03 PM
Found the real issue - can't give an NPC a skill unless it's set to be available for that type of NPC (officer, admiral, admin), which is in itself an issue for what I'm trying to do but hey, sorry for being a bother.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2018, 07:52:47 PM
Hmm, fairly sure that's not it. Unless I'm misremembering, the "what's available to who" check is just done by the code that adds skills, not within CharacterStats.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Statius on November 23, 2018, 01:57:22 PM
Since the author of Project ATX seems to be gone, I decided to try and update the mod for .9 compatibility for my own use. But for some reason, one of the ships, the Valkyr, when it actually has its system, which is basically the Scarab's Temporal Shell that's used like Phase Cloak, will always cause a crash (fatal:null) upon mousing over it in the production screen, when deployed in combat, when present in the fleet screen, etc. Without its system, there's no issues. The system itself shows up in the codex without issues. The issue only comes when the ship and system are together. Any ideas what exactly is wrong?

Edit: I still have no idea where things were wrong exactly, but I fixed it by ripping out the BaseShipSystemScript and TemporalShellStats class files and shoving them into the mod's, replacing names and location references as needed, and a few number changes. I feel like this was the worst way possible to get it working, but I have no idea what I'm doing anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 24, 2018, 07:49:41 PM
I created a custom special item whose plugin extends ShipBlueprintItemPlugin, and added the base item to special_items.csv.

Now how do I tell the game to generate the specific items for X, where X is a list of ships (either by tag or manually specified)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 24, 2018, 08:19:01 PM
Something like:
cargo.addSpecial(new SpecialItemData("<base item id>", "<parameter>"), 1);

For example, for planetary shield, it's:
cargo.addSpecial(new SpecialItemData("industry_bp", "planetaryshield"), 1);

(See: RedPlanet.java.)

If you want to add them to dropRandom, see drop_groups.csv. For example:

item_ship_bp:{tags:[rare_bp, !no_drop]}

In code, this would be:
d = new DropData();
d.chances = 1;
d.addCustom("item_ship_bp:{tags:[rare_bp, !no_drop]}, p:{}}", 1f);
entity.addDropRandom(d);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on November 27, 2018, 02:11:48 PM
Getting a null pointer error with my mod, after starting a new campaign save, no idea what is causing it though, specially since I had it already running fine in the new update, and I haven't made any further campaign level modifications since getting the campaign to run.

Code
67420 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddStandardStartingScript$2.run(NGCAddStandardStartingScript.java:144)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.while.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.float.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.O0oO.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.OoO0.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?0000(Unknown Source)
at com.fs.starfarer.ui.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
at com.fs.starfarer.ui.V.super(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 27, 2018, 02:15:42 PM
GCAddStandardStartingScript.java:144

The bolded part is the line number. That line is:

jangalaContact.getRelToPlayer().setRel(0.1f);

The NPE on that line means jangalaContact is null. It could also mean thet getRelToPlayer() returned null, but that's not actually possible.

It's set with this line:
PersonAPI jangalaContact = TutorialMissionIntel.getJangalaContact();

That method, in turn, looks for a space station commander at Jangala. Looks like there isn't one there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 28, 2018, 09:01:17 AM
So, as part of my plans for the next release of Shadowyards I've been trying to further integrate the SRA's economic stuff with the vanilla factions; part of this plan involves adding Solar Arrays to some Vanilla worlds.

Now, nominally you can add an industry to a market like so:

Code: java
fooMarket.addIndustry("fooIndustry");

Adding an industry to one of the markets present in vanilla however hasn't been working out; so far I've tried two methods, neither successful, but also unclear as to why they aren't successful.

My first attempt looked something like this:

Spoiler
Code: java
        List<PlanetAPI> corvusList = corvus.getPlanets();
        for (PlanetAPI p : corvusList) {
            if (p.getId().equals("asharu")) {
                MarketAPI market = p.getMarket();
                if (market != null) {
                    market.addIndustry(MS_industries.SOLAR);
                }
            }
        }
[close]

And currently looks something like this:

Spoiler
Code: java
        List<MarketAPI> markets = Global.getSector().getEconomy().getMarketsCopy();
        for (MarketAPI m : markets) {
            if (m.getId().equals("asharu")) {
                m.addIndustry(MS_industries.SOLAR);
            }
        }
[close]

About the closest thing I've got to a hint here is a null pointer error that occurred earlier. The Solar Arrays code includes a section where it get's the star type to determine bonus production. Before I dealt with the NPE it looked like this:

Spoiler
Code: java
PlanetAPI planet = market.getPlanetEntity();
PlanetAPI star = planet.getStarSystem().getStar();
[close]

Afterwards it looks like this:

Spoiler
Code: java
        PlanetAPI planet = market.getPlanetEntity();
        PlanetAPI star;
        
        if (planet != null) {
            star = planet.getStarSystem().getStar();
        } else {
            star = planet;
        }
[close]

Initially I thought it wasn't getting the star, but what actually seems to be the case is it's not getting the planet (and thus, getting neither the market nor the star, thus resulting in an NPE crash when the Solar script tried to get the star); clearly I haven't quite figured out how to call up the market id quite right, so I guess some advice on how to do that is needed. Now, I could do altered versions of the vanilla econ.jsons, but that seems like a pretty bad solution for a huge number of reasons, and I'd really rather not do such bad practice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 28, 2018, 12:51:47 PM
Would it be possible to make a hullmod that either increases the repair speed of all ships in the fleet, or reduces repair costs?

I know how to do it for a single ship, but how for a fleet? What would the code be?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on November 28, 2018, 02:03:31 PM
@MShadowy:
Try something like this.

Code
     //Ship Recovery Test
        SectorEntityToken Arcon_Adarga_D = TSC_AddDerelict.addDerelict(
                system, //Star system
                system.getPlanets().get(1), //Orbital focus
                "TSC_Adarga_D_Attack", //Variant Id
                ShipRecoverySpecial.ShipCondition.BATTERED, //Ship condition
                550f, //Orbital radius
                true //Recoverable?
        );/

I used that to get the first planet on the star and spawn a derelict on penelope's star, might work for markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheWetFish on November 29, 2018, 03:36:55 AM
What is the intended skin restore behaviour now?

Falcon (P) has both  "baseHullId":"falcon",  and also   "restoreToBaseHull":true,  and it restores to a Falcon (P)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on November 29, 2018, 06:35:50 AM
@MShadowy
not sure what the issue in the first code piece would be. However, the second code piece fails as you're not getting all the markets in play; you're getting a copy of all markets in play (thus why it's named .getEconomy().getMarketsCopy()). Modifying these copies won't actually affect the markets themselves; they are intended as read-only.

As for the issue with not getting the planet, could that be due to spacestation-esque markets? GetPlanetEntity might return null in those cases, though I haven't tested it thoroughly so I might be wrong on that part.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: code99 on November 29, 2018, 10:13:38 PM
EDIT: Ill post this in a thread of its own if its considered more than "misc modding questions"

So, I want to tweak  the expeditions the AI sends at you once you start producing something until Alex can (hopefully) tweak/rework how they work but I need a bit of help since im not all to familiar with Java.
My first question would be, can we just edit the files in starfarer.api.zip and call it a day? Will the game read the new values as is?

Ideally I would like to increase the market share trigger. I mean, if they start sending fleets at you when you got 33% market share, i would increase to 50% for example, so that they wont send any fleets because of your market share if you are bellow that.
I dont want to disable the expeditions entirely, just reduce in frequency and how fast they come (as in how they are triggered)

By looking at the code

Code
	public static int MAX_CONCURRENT = 2;

// if more factions send non-territorial expeditions, longer timeout
public static float TARGET_NUMBER_FOR_FREQUENCY = 5f;

public static int FACTION_MUST_BE_IN_TOP_X_PRODUCERS = 3;
public static float PLAYER_FRACTION_TO_NOTICE = 0.33f;
public static final float MAX_THRESHOLD = 1000f;

MAX_CONCURRENT = 2  -  would mean that they can send multiple fleets at you (max 2)
TARGET_NUMBER_FOR_FREQUENCY = 5f;  -  This im not sure how it factors in ... obviously has to do with the longer timeout mentioned above

FACTION_MUST_BE_IN_TOP_X_PRODUCERS = 3;  -  This one seems to be a requirement for AI expeditions to happen, you must be in top 3 producers for the expeditions to start coming at you. So, if I change this value to 1 would mean they would only attack me if I am THE top producer?
PLAYER_FRACTION_TO_NOTICE = 0.33f;  -  This is the market share they notice you? I dont think so since I saw people getting raided for only 2% market share (i assume 0.33 means 33%)
MAX_THRESHOLD = 1000f;  -  Dont know what this does

Is there some other value i missed?
Do the expeditions trigger for colony size too?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 30, 2018, 03:33:32 AM
The proper way to make it work is:

Make a new mod with a mod plugin and a script MyPunitiveExpeditionManager that extends or copy-pastes PunitiveExpeditionManager. (If you need help setting up a mod with or without an IDE, probably best to ask on the unofficial Discord)

In the mod plugin, add a onNewGameAfterTimePass() call with the following:
Code: java
@Override
public void onNewGame() {
    Global.getSector().addScript(new MyPunitiveExpeditionManager());
}

This adds your modified expedition manager to the game at the start, so the default one isn't added (I think).



For your questions on the constants, looking at the code in that class:

TARGET_NUMBER_FOR_FREQUENCY is apparently used to space expeditions further apart if more than one faction is sending them. You'll have to look at the getExtraTimeout method in the manager yourself though, I'm too busy to work through the math right now.

PLAYER_FRACTION_TO_NOTICE means that if player's share is more than a third of that particular expedition faction's share, the expedition can get sent. Outrageous, I know.

MAX_THRESHOLD seems to cap the size of the expedition fleets.

Colony size only seems to be used for how much free ports make the faction mad, and also a check where if a colony built in someone's claimed territory is size 5 or larger (meaning saturation bombardment won't instakill it) they won't try to exterminate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 30, 2018, 11:18:41 AM
I've been checking out several mods and it seems every one handles the economy/planets/markets differently.

So what is the BEST way to add your own factions systems/market?

Trough economy.json and individual system economy files?
Trough code during system generation?

What's the best way?

EDIT:
Also, does StarSystemGenerator.AddOrbiting Entities also generate random planetary conditions? I heard somewhere that some code leaves planet without anything
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on November 30, 2018, 01:24:42 PM
Hello, Alex, this is for know why this custom is not a integer for a weight.   
Quote
Factions.CUSTOM_MAKES_PIRATE_BASES
Because if i wannot add a new plugin for have a random pirate(of a special faction) base who spawn, i can add this boolean, but i think, this will be better to put a integer, like that, we can choice the rarity of the faction pirate base.

Like that, if i add my faction, i have 1/2 of get my faction or the pirate. I dislike this thing, sorry xD
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Beobachter on November 30, 2018, 06:55:17 PM
When writing intel, is it better to be putting the player-facing text in the source or use the rules.csv? I've looked at the rules.csv and didn't recall seeing the text from the HegemonAIInspection intel, but the text is in the source.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 30, 2018, 07:01:18 PM
So what is the BEST way to add your own factions systems/market?

Trough economy.json and individual system economy files?
Trough code during system generation?

What's the best way?

Probably economy.json, since that's more readable/easier to change and maintain. Through code is done usually when economy.json is not an option (at least, on my end - can't speak for how mods do it), because for example a colony needs to be dynamically created. I.E. different conditions from game to game, etc.

@Snarsha: hmm, that's probably not for this thread, but yeah, that's a good suggestion.


When writing intel, is it better to be putting the player-facing text in the source or use the rules.csv? I've looked at the rules.csv and didn't recall seeing the text from the HegemonAIInspection intel, but the text is in the source.

Depends on what's more convenient. It'd be kind of hard to say put standard intel descriptions into rules.csv. But if part of the intel involves a RuleBasedDialog (i.e. you have to talk to someone, interact with a planet) then rules.csv can work and may even be the only way to reasonably make it work.

For something like picking the response options for the Hegemony Inspection, you could really do it either way. For me, it felt easier/more self-contained to do it entirely in a custom dialog plugin. But doing it in rules wouldn't be wrong, either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 01, 2018, 04:03:02 AM
How do I get a market's orbital station fleet? (I want to change its faction on market capture)

Right now I've got this:
(https://i.imgur.com/e76UGOT.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 01, 2018, 06:31:10 AM
Someone explain something to me - I'm making my factions worlds and economy.

When I add a station/waystation/starfortress to a planets industry (trough economy.json), is the space station automatically generated? Is it tied to the planets market? Can it's illustration be changed?

I'm asking because in my old files I had manually placed "defense stations" for show, bu now those are actually functional.

And lasty, if I have my own custom made stations (that work in skirmish), can I set them to be in the planes orbit and interactable + fighable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 01, 2018, 10:30:57 AM
How do I get a market's orbital station fleet? (I want to change its faction on market capture)

Misc.getStationFleet(market) for operational station
Misc.getBaseStationFleet(market) for station that's being build (i.e. just the skeleton with no modules)


When I add a station/waystation/starfortress to a planets industry (trough economy.json), is the space station automatically generated? Is it tied to the planets market? Can it's illustration be changed?

I'm asking because in my old files I had manually placed "defense stations" for show, bu now those are actually functional.

And lasty, if I have my own custom made stations (that work in skirmish), can I set them to be in the planes orbit and interactable + fighable?

IIRC if a colony has "connectedEntity" with a "station" tag, then  the oribtal station industry will use it for the station, and it'll automatically become interactable/attackable/etc. Otherwise, it'll create a new one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 01, 2018, 11:41:52 AM
Quote
IIRC if a colony has "connectedEntity" with a "station" tag, then  the oribtal station industry will use it for the station, and it'll automatically become interactable/attackable/etc. Otherwise, it'll create a new one.

;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 01, 2018, 12:46:05 PM
Hello, i have two problems!
Spoiler
(https://i.imgur.com/kbGGSbi.jpg)
[close]

First!
My station do not have mount!
I put correctly a variant with weapon: variant:Art_lte_station3_Standard   (Tested on mission)

But this is the same for every ships, they load correctly wings, but not weapons...

Quote
"knownWeapons":{
    "tags":[ "noir_bp","noir"],
    "weapons":[
      "Art_Shard12",
      "Art_Shard4",
      "Art_Shard1",
      "Art_HStulard",
      "Art_NStulard",
      "Art_LStulard",
      "Art_Enem",
      "Art_SpreadGun",
      "Art_Apon",
      "Art_AmeUltimate",
      "Art_Lightning"]
    },
    "priorityWeapons":{
      "tags":[ "noir_bp","noir"],
      "weapons":[
        "Art_Shard12",
        "Art_Shard4",
        "Art_Shard1",
        "Art_HStulard",
        "Art_NStulard",
        "Art_LStulard",
        "Art_Enem",
        "Art_SpreadGun",
        "Art_Apon",
        "Art_AmeUltimate",
        "Art_Lightning"
      ]
    },
But my blueprint is good, and these weapons too.. they just wannot be inserted on the faction...
I do not know where to look, like this is a problem than others mods do not seems to have...



My second problem is the blueprint, i do exactly like others peoples, but the "picture" is not printed on the package....
On the setting, i have that:
Quote
  "blueprint_packages":{
    "sad_tech_package":"graphics/icons/cargo/SAD_package.png",
  },
On the graphics, i have a picture of the correct size.

On the special item:
...,sad_tech_package,package_bp,...


But do not work, what i have missed?
Thank you for your help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 01, 2018, 01:10:49 PM
Is your blueprint item's plugin "com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin"? The other stuff looks correct as far as I can see.

Hard to say w/ weapons; I'm not sure. Nothing jumps out as being wrong, though you probably don't need a priorityWeapons section if it's just a copy of knownWeapons.

Also, if the weapons you're listing in the "weapons" array have either the noir_bp or noir tag, you do not need to list them individually.

But neither of those should break anything, so: not sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 01, 2018, 01:37:52 PM
Is your blueprint item's plugin "com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin"? The other stuff looks correct as far as I can see.

Hard to say w/ weapons; I'm not sure. Nothing jumps out as being wrong, though you probably don't need a priorityWeapons section if it's just a copy of knownWeapons.

Also, if the weapons you're listing in the "weapons" array have either the noir_bp or noir tag, you do not need to list them individually.

But neither of those should break anything, so: not sure.
For the plugin of Blueprint, yeah, they have everything the same plugin who is that.

Well, after bit check, look like my third faction, a remnant-like faction do not seems to have problem about factions, but like he is generated only per FleetfactoryV3, he do not have problem.

For the listing weapons array, well, like many look like to have put that, i have put them, but i will retire them so, thank ;)

Now, i need to search why i do not get weapons or the correct blueprint on my two factions and this is disturbing...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 02, 2018, 02:04:44 AM
For the weapons, they have be fixed, look like if you do not put a hint like "he16", they  do not exist when they need to be mount( on the market, they are sell correctly)


The blueprint, i have found too, i have forgot to put them on the graphics on the setting.

Sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 02, 2018, 03:40:02 AM
Question - looking back I fin a lot of thing in faction files that aren't present anymroe. So I have to ask what of the following is not used anymoire:

Quote
      "offersCommissions":true,
      "engagesInHostilities":true,
      "investigatesPlayerForGoodRepWithOtherFactions":true,
      "worthInvestigatingPlayerForGoodRepWith":true,
      "exemptFromFoodShortages":true,
      "willTradeWhenHostile":false,
      "noPatrols":false,
      "ignoreTradeWithEnemiesForReputation":false,
      "postsNoBounties":false,
      "engageWhenEvenStrength":false,
      "offerMissionsWhenHostile":false,
      "allowsTransponderOffTrade":false,


   "internalComms":"isa_internal",
   "tariffFraction":0.05,
   "tollFraction":0.09,
   "fineFraction":0.15,


   "traits":{
      "captain":{
         "timid":1,
         "cautious":5,
         "steady":10,
         "aggressive":5,
         "reckless":1,
      },
   },
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2018, 08:59:05 AM
"investigatesPlayerForGoodRepWithOtherFactions":true,
"worthInvestigatingPlayerForGoodRepWith":true,
"exemptFromFoodShortages":true,
"internalComms":"isa_internal",
"tariffFraction":0.05,
"tollFraction":0.09,
"fineFraction":0.15,

Fairly sure these are all unused.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 03, 2018, 01:50:06 AM
What about captains and traits?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 03, 2018, 01:54:35 AM
Okay, I'm at the end of my rope there:
I have a pretty simple industry right there that is supposed to "collect intelligence" and from time to time reveal a hidden base to the player.

https://pastebin.com/jrwr6N8h

Yet the game refuses to load any save because something in here triggers a "unauthorized use of reflexions" from Xstream. Actually I have been getting those quite a lot even with market scripts that used to work fine in 0.8.1 And I'm not sure to get what is considered a reflexion in these cases.


Nevermind, I have to use a Static Logger.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 03, 2018, 09:27:29 AM
What about captains and traits?

Ah yes, that's unused as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 04, 2018, 01:03:44 AM
When I add a station/waystation/starfortress to a planets industry (trough economy.json), is the space station automatically generated? Is it tied to the planets market? Can it's illustration be changed?

I'm asking because in my old files I had manually placed "defense stations" for show, bu now those are actually functional.

And lasty, if I have my own custom made stations (that work in skirmish), can I set them to be in the planes orbit and interactable + fighable?

IIRC if a colony has "connectedEntity" with a "station" tag, then  the oribtal station industry will use it for the station, and it'll automatically become interactable/attackable/etc. Otherwise, it'll create a new one.


Getting back to this..how does this work when combined with economy/industry station definition? If I set a 3rd tier high-tech station there, but on system generation put my own custom station in orbit (with custom sprite, sections, guns and so forth) what then?

Is it going to treat my station as the high-tech one?
Can I make my faction use my stations?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 04, 2018, 11:17:21 AM
See the "data" column for orbital stations in industries.csv.

If you want a custom entity for a station, you can do that, but you don't want to make it an actual fleet with the station variant etc, you just want a regular custom entity. The fleet will get filled in by the OrbitalStation industry, based on what's set in its data column.

So basically:
1) Add custom entity around colony (optional)
2) Create custom station industry (possibly several, if your station has tiers)
3) Add said industry to your colony
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 05, 2018, 01:09:40 AM
Another question:

To make a faction that aggressively attacks others outside of their home system AND/OR a faction that doesn't have a home base/station.

Do I have to code my own fleet spawners myself for both cases? I assume the second is a big yes, but the first?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on December 05, 2018, 03:06:25 AM
How to change player faction tariffs and tariffs in general?
I can change specific market tariff in data/campaign/econ specific markets file. Lack of Galatia system so I cannot change it here(its also only system that have zero tariffs in game.
I can change tariffs on mod added new markets in the same way.

Trying to change default tariffs by changing    "defaultTariff":0.1, in econ.json don't work.
(using Notepad++)
I thought that if I change value here it will also change for player faction but its still 30%.

OK it work for new save but now only default tariffs works.
Did I forgot chicken sacrifice in the process?

Can anyone help?
I tried discord but with no success.
 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2018, 01:49:20 PM
Another question:

To make a faction that aggressively attacks others outside of their home system AND/OR a faction that doesn't have a home base/station.

Do I have to code my own fleet spawners myself for both cases? I assume the second is a big yes, but the first?

Yes in both cases.



How to change player faction tariffs and tariffs in general?
I can change specific market tariff in data/campaign/econ specific markets file. Lack of Galatia system so I cannot change it here(its also only system that have zero tariffs in game.
I can change tariffs on mod added new markets in the same way.

Trying to change default tariffs by changing    "defaultTariff":0.1, in econ.json don't work.
(using Notepad++)
I thought that if I change value here it will also change for player faction but its still 30%.

OK it work for new save but now only default tariffs works.
Did I forgot chicken sacrifice in the process?

Can anyone help?
I tried discord but with no success.

I'm not sure I understand - it sounds like you got it working? It does require starting a new game, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on December 05, 2018, 05:17:27 PM
I've been trying to add a constellation name to a non procgen system, this is for a hidden star system out in the edges of the map that relies heavily on random generation, including name, location and type of nebula; but so far I haven't been able to add a constellation, the rest is working fine though...

Initially I tried this:

Code
List<StarSystemAPI> star_systems = sector.getStarSystems();
        if (!star_systems.isEmpty()) {
            StarSystemAPI closest = null;
            float closestDistance = Float.MAX_VALUE;
            for (StarSystemAPI star_system : star_systems) {
                if (!star_system.equals(system)) {
                    float distance = MathUtils.getDistance(system.getLocation(), star_system.getLocation());
                    if (distance < closestDistance) {
                        closest = star_system;
                        closestDistance = distance;
                    }
                }
                Constellation TEST = closest.getConstellation();
                system.setConstellation(TEST);
            }
        }

Figured it wasn't working because it was likely throwing null, since non procgen systems do not have constellations, and I guess they are likely generated first. I would also like to point that this didn't cause any crashes.

Tried making a new constellation(testconst) and then setting the system to use it (system.setConstellation(testconst)), but got the same result, no crashes, but no constellation label on the system either.
I thought it might just not be showing the label, so I made the following tests:

Code
List<StarSystemAPI> star_systems = testconst.getSystems();
            for (StarSystemAPI star_system : star_systems) {
                if (star_system.equals(system)){
                    system.getStar().setName("IT WORKED");
                }
            }

This didn't crash, so that should mean testconst, exists as a constellation, otherwise I should get a null pointer... I think. However the star system was still using its original name.

Finally I tried this:

Code
testconst.getSystemWithMostPlanets().getStar().setName("IT WORKED2");

this crashes with a null pointer at that line, I think it does so because testconst is empty, which would explain why the previous test didn't crash. If this is so, I would guess "system.setConstellation(testconst)" is doing nothing, but I can't be sure, I'm probably missing something.

Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on December 06, 2018, 01:52:27 AM
I have here a simple everyFrameWeaponEffect script attached to a built-in weapon aboard a ship. It simply checks to see if said ship's system is active, then shuts down / reboots said weapon accordingly.

Code
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.WeaponAPI;

public class Diableavionics_HarvestEveryFrameEffect implements EveryFrameWeaponEffectPlugin {

private ShipAPI ship;   
private ShipSystemAPI system;
private ShipEngineControllerAPI engines;
private WeaponAPI lgun;

private boolean runOnce=false;

@Override
public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {

if (Global.getCombatEngine().isPaused()) {
return;
        }


if (!runOnce || ship==null || system==null){
ship = weapon.getShip();
system = ship.getSystem();
engines = ship.getEngineController();

runOnce = true;
return;
        }

if (ship.getSystem().isOn()) {
weapon.disable();
} else {
weapon.repair();
}

if (ship.isHulk() && !weapon.isDisabled()) {
weapon.disable();
}

}

}


It runs fine, but I've got two issues with this:


Any help would be appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 06, 2018, 04:45:55 AM
When I add the local resources submarket to a market the player has captured in Nexerelin, it doesn't appear in the trade screen.
The submarket plugin's isHidden() check calls !market.isPlayerOwned(); why does that return false?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on December 06, 2018, 09:01:41 AM
Question about swapping weapons for variant: in my mod, I've added several sub-par weapon less good than their vanilla counterpart, and it seems that variants try to use these weapons instead of better one. What is the mechanic switching weapons for theorically better ones? I guess they have to fit the same role in priority. But it is then a function of OP, damage/second, range, or something else?

Another on related to missile weapons: is their a way to make single weapon system (like the locust) to split its salvo on several target? I want to create some kind of cluster MIRV, When the main head separate, submunitions would target several target in a certain radius around it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 06, 2018, 11:16:56 AM
@Machine, Obsidian Actual: I think those probably belong in separate posts rather than in here.

That said:

Code
testconst.getSystemWithMostPlanets().getStar().setName("IT WORKED2");

this crashes with a null pointer at that line, I think it does so because testconst is empty, which would explain why the previous test didn't crash. If this is so, I would guess "system.setConstellation(testconst)" is doing nothing, but I can't be sure, I'm probably missing something.

Any ideas?

Did you add the system to the constellation? Something like constellation.getSystems().add(yourSystem).


@Obsidian Actual: nothing comes to mind right, I don't *think* you can suppress disabled text. Could possibly remove the weapons from their groups, though, hmm - and then re-add them. Might cause problems, might not - can't say offhand. I do know that this is part of what critical malfunctions do, so it ought to be workable in some circumstances, anyway.

When I add the local resources submarket to a market the player has captured in Nexerelin, it doesn't appear in the trade screen.
The submarket plugin's isHidden() check calls !market.isPlayerOwned(); why does that return false?

Did you call market.setPlayerOwned(true)? That's (mostly) tracked separately from what faction it belongs to.


Question about swapping weapons for variant: in my mod, I've added several sub-par weapon less good than their vanilla counterpart, and it seems that variants try to use these weapons instead of better one. What is the mechanic switching weapons for theorically better ones? I guess they have to fit the same role in priority. But it is then a function of OP, damage/second, range, or something else?

It's the weapon's tags: for example, if it's got "he15", it'll be preferred over weapons with he14 and below in the "high explosive" role, etc. So subpar weapons should have lower numbers in their tags.

Another on related to missile weapons: is their a way to make single weapon system (like the locust) to split its salvo on several target? I want to create some kind of cluster MIRV, When the main head separate, submunitions would target several target in a certain radius around it.

You'd have to write a custom missile AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Britich on December 07, 2018, 08:05:23 AM
Ive been trying to spread systems out on the Sector map, the Start systems are easy to do as they have coordinates.
However Ive been having issues on getting the constellation systems to spread out, ie not within 3-5 days of each other more like 10-15 days, Ive fiddled with the following files:

starfarer.api.zip\com\fs\starfarer\api\impl\campaign\procgen\StarSystemGenerator.java
starfarer.api.zip\com\fs\starfarer\api\impl\campaign\procgen\ConstellationGen.java
starfarer.api.zip\com\fs\starfarer\api\impl\campaign\procgen\SectorProcGen.java

but nothing seems to change, am I barking up the wrong tree?
Any thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 07, 2018, 09:03:05 AM
I want to make a gun who's projectile is basically an AoE EMP detonation.

So it leaves the barrel and it has a proximity fuse and once if explodes is releases lightning/emp from the detonation point to all objects in range

Now I found this piece of code, but that seem to use a ship as a starting point.



Code
            Global.getCombatEngine().spawnEmpArc(ship, point, ship, targetEntity,
                    DamageType.ENERGY, //Damage type
                    LIGHTNING_DAMAGE * damageNuller, //Damage
                    LIGHTNING_EMP_DAMAGE * damageNuller, //Emp
                    100000f, //Max range
                    "zap", //Impact sound
                    MathUtils.getRandomNumberInRange(15f, 18f), // thickness of the lightning bolt
                    new Color(255, 255, 255), //Central color
                    LIGHTNING_COLOR //Fringe Color
            );

I wish I didn't suck at coding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on December 07, 2018, 11:04:15 AM

How to change player faction tariffs and tariffs in general?
I can change specific market tariff in data/campaign/econ specific markets file. Lack of Galatia system so I cannot change it here(its also only system that have zero tariffs in game.
I can change tariffs on mod added new markets in the same way.

Trying to change default tariffs by changing    "defaultTariff":0.1, in econ.json don't work.
(using Notepad++)
I thought that if I change value here it will also change for player faction but its still 30%.

OK it work for new save but now only default tariffs works.
Did I forgot chicken sacrifice in the process?

Can anyone help?
I tried discord but with no success.

I'm not sure I understand - it sounds like you got it working? It does require starting a new game, yeah.

I get working one time for specific markets.
And reliable for default tariffs for all.
Thing is when default tariffs works well I can not make specific tariffs for market.
Maybe I *** something.
Sorry to bother anyone but how specifically one can change tariffs for specific markets?
I used add
         "Tariff":0.25,
and put it under market size but its not working for me.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 07, 2018, 11:09:22 AM
Ive been trying to spread systems out on the Sector map, the Start systems are easy to do as they have coordinates.
However Ive been having issues on getting the constellation systems to spread out, ie not within 3-5 days of each other more like 10-15 days, Ive fiddled with the following files:

starfarer.api.zip\com\fs\starfarer\api\impl\campaign\procgen\StarSystemGenerator.java
starfarer.api.zip\com\fs\starfarer\api\impl\campaign\procgen\ConstellationGen.java
starfarer.api.zip\com\fs\starfarer\api\impl\campaign\procgen\SectorProcGen.java

but nothing seems to change, am I barking up the wrong tree?
Any thoughts?

Ah, that's just the source code provided for reference, changing it is not going to affect the game in any way.


Now I found this piece of code, but that seem to use a ship as a starting point.

It needs a ship as the damage-source, but "point" is a Vector2f and is the actual source point for the EMP arc.


I used add
         "Tariff":0.25,
and put it under market size but its not working for me.

Lower-case "tariff" may work. I'm not 100% sure that won't get overridden somewhere, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 08, 2018, 12:44:39 PM
Did anything change on how variants are handled in total conversions?

When looking at the variants/weapons in the dev mode viewer there are weird glitches. Weapons double on top of each other like the vanilla variant and mod variant are both being read at the same time. Do I have to "replace" variants in mod_info now or something?

There doesn't initially appear to be any json format differences between .weapon .ship and .variant files between .8 and .9 and I've already accounted for all the additional columns in weapons, ships and wings.csv

Any variants that are mod-specific appear fine.

Edit:

To see what I mean as far as weirdness-

The images below were fine with .8:

Spoiler
(https://i.imgur.com/0qxqoaQ.png)
(https://i.imgur.com/IzxdeFZ.png)
(https://i.imgur.com/kSngWjB.png)
(https://i.imgur.com/M1nxyhI.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2018, 12:47:22 PM
Could you possibly get me a minimal, standalone mod that has this problem?

I don't *think* anything changed that would cause that (and I'm having trouble imagining how weapons would double up in the refit screen, that seems... not possible, and yet) but it's possible that something did change.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 08, 2018, 01:15:12 PM
Could you possibly get me a minimal, standalone mod that has this problem?

I don't *think* anything changed that would cause that (and I'm having trouble imagining how weapons would double up in the refit screen, that seems... not possible, and yet) but it's possible that something did change.

I could try.. I'm not sure, as there is a lot that goes into this mod since its a TC. Is anyone else having this issue by chance?

But for reference, here are the same files working in .8.

Maybe the skin files have changed or something.. but that doesn't explain the Odyssey.  :(

Spoiler
(https://i.imgur.com/jMvhBhz.png)
(https://i.imgur.com/zfGTc68.png)
(https://i.imgur.com/oJK9qmp.png)
(https://i.imgur.com/H5bZw22.png)
[close]

I'll try to get more details closer to what you asked for if I can.

*Edit* looking at it more, it appears it could be the variant files are fine and maybe the ship files are the issue maybe?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2018, 01:18:54 PM
I'm not sure exactly what I'm looking at, so nothing in the screenshots necessarily jumps out as being wrong. Not seeing any doubled-up weapons, either - am I just missing something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 08, 2018, 01:22:57 PM
I'm not sure exactly what I'm looking at, so nothing in the screenshots necessarily jumps out as being wrong. Not seeing any doubled-up weapons, either - am I just missing something?

In the first set? Or the second? The first set (in the original post) is the incorrect set. The second set (in my reply) is correct and you can see the clear differences between the two. You can see where weapons are on top of each other specifically in the case of the falcon. It looks like its reading the vanilla falcon variant on the mod ship file. In the case of the Onslaught it has the correct variant file but appears to attempt to use the vanilla .ship file weapon format. Weapons are in different places and it weirdly has built-in PACs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2018, 01:50:48 PM
Ahh ok I see - didn't catch the set in the first post, I think you might've edited it after I'd already read it :) Weird!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2018, 01:57:09 PM
Aha, ok, I think I understand. Weapon and variant files were not being merged prior to 0.9, the ones from a mod just overrode them straight up. Now they *are* merged - which makes it possible to do tweaks in a way compatible with multiple mods modifying the same variant, but if you're looking to replace the variant entirely, yes, looks like they need to be in the "replace" list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 08, 2018, 02:01:50 PM
Aha, ok, I think I understand. Weapon and variant files were not being merged prior to 0.9, the ones from a mod just overrode them straight up. Now they *are* merged - which makes it possible to do tweaks in a way compatible with multiple mods modifying the same variant, but if you're looking to replace the variant entirely, yes, looks like they need to be in the "replace" list.

Doh! Just reverted everything in the variants, weapons and hulls directories and started from scratch.. oh well at least now I understand what is going on lol. Is it possible to "replace" entire directories? Or do I have to explicitly name each variant file?

As a side question regarding the new autogenerated variants by the faction files various entries, is it even worthwhile to use variants now or should I focus on reliable autogeneration doing the same thing in those files and only now replace vanilla ones going forward? Any recommendations?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2018, 02:28:16 PM
Doh! Just reverted everything in the variants, weapons and hulls directories and started from scratch.. oh well at least now I understand what is going on lol. Is it possible to "replace" entire directories? Or do I have to explicitly name each variant file?

Ahh, sorry! You have to list each file, yeah. Let me make a note to see how painful adding some basic wildcard/folder support would be.

As a side question regarding the new autogenerated variants by the faction files various entries, is it even worthwhile to use variants now or should I focus on reliable autogeneration doing the same thing in those files and only now replace vanilla ones going forward? Any recommendations?

Autogenerated variants are based on hand-crafted variants as a "target", so you still need those. The variants you care about for this are the ones in default_ship_roles.json any faction-specific ones in the .faction files (see: shipRoles in luddic_church.faction for an example of that).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 08, 2018, 03:40:43 PM
Ahh, sorry! You have to list each file, yeah. Let me make a note to see how painful adding some basic wildcard/folder support would be.

Autogenerated variants are based on hand-crafted variants as a "target", so you still need those. The variants you care about for this are the ones in default_ship_roles.json any faction-specific ones in the .faction files (see: shipRoles in luddic_church.faction for an example of that).

Thanks, that is really helpful! And yeah folder support would be great if possible.

Hmm, as a further thought I wonder if having a mod marked as a TC should automatically replace those vanilla directories by default. That would be the inherent purpose of marking a mod as a TC, anyway, right?

It's going to be a lot of replace lines for me, otherwise, but hey I'm up for the challenge. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 09, 2018, 10:07:17 PM
Do I replace the file by name without the path?

Or the path to the file in starsector-core?

Because a test of replacing the files directly by adding:

   "data/hulls/odyssey.ship",
   "data/hulls/onslaught.ship",
   "data/variants/onslaught/onslaught_Elite.variant",
   "data/variants/odyssey_Balanced.variant"]

To the end of mod_info,

Does not fix the weird variant/ship glitches with those ships.  :(

*Edit* Just tried it with weapon files and those don't work either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ogaburan on December 10, 2018, 01:46:58 AM
How to add a new officer to a new game start?

For the life of me i cant figure this one out...
rules.csv make it seem that all i need is:

Code
$ngcAddOfficer = true

Yet that line does nothing to me...
This is WIP code, but it shold work
Code
id,trigger,conditions,script,text,options,notes
ngcCabStart,AddNewGameChoices,,"SetTooltip ngcCabStart""You will start with a damaged Mercury, only 3 crew. Low supplies, fuel and cash.\n\n(Very Hard Start).""",,22001:ngcCabStart:Who me? I just used to be a cab driver!,
ngcCabStartPicked,NewGameOptionSelected,$option == ngcCabStart,"SetTooltip ngcCabContinue""You will start in the Corvus star system.""
NGCAddShip mercury_d_Standard
NGCAddCargo RESOURCES crew 4
NGCAddCargo RESOURCES supplies 8
NGCAddCredits -1500
NGCAddCargo RESOURCES fuel 10","What can I say, shutteling people around in Corvus is an honest living. Just me, my trusty piese of shi-i-p, and my 3 employees. With just 500 credits to my name though, maybe its time to rethink my life. Perhaps reset the course of my whole life that only got me so far! I think I overheard someone at the bar saying something about an abandoned terraforming platform nearby, perhaps its worth a visit...",0:ngcCabContinue: What a *** life!,
ngcCabContinueClicked,NewGameOptionSelected,$option == ngcCabContinue,"NGCSetStartingLocation Corvus -2500 3000
NGCDone",,,
ngcCopStart,AddNewGameChoices,,"SetTooltip ngcCopStart""You will have to choose betweeen several starting options.\n\nIn all fo them you will be a policeman serving in the Persean League.""",,22002:ngcCopStart:Who me? I used to be a cop!,
ngcCopStartPicked,NewGameOptionSelected,$option == ngcCopStart,"SetTooltip ngcCadet""You will start in a Kite.\n\nWith a partener, also in a Kite.""
SetTooltip ngcVeteranCop""TBA""","The Law, it is what seperates a civilized society from a barbarian rabble. The Law, it is what I stand for. If we are to stand a chance against Hegemony oppretion, we need to present a much more united front! That is my role in life, to help unite the Persean League by enforcing the law.","0:ngcCadet:I just joined the force.
1:ngcVeteranCop:I'm too old for this ***.",
ngcCadetPicked,NewGameOptionSelected,$option == ngcCadet,"NGCAddShip kite_Standard
NGCAddShip kite_Standard
NGCAddCargo RESOURCES crew 30
NGCAddCargo RESOURCES supplies 30
NGCAddCargo RESOURCES fuel 20
AddTextSmall """"Acquired level 1 officer"""" good
SetTextHighlights """"level 1 officer""""
$ngcAddOfficer = true
NGCAddCredits -1000","My time spent at the police academy on Fikenhild was not easy, mostly because I didn’t slack off. I finnished top of my class! I just hope I get a decent partner.","0:ngcCopEnd:I tracked down a crook to the corvus system, but lost him, time to get the hell out of dodge!",
ngcVeteranCopPicked,NewGameOptionSelected,$option == ngcVeteranCop,NGCAddShip mercury_d_Standard,,"0:ngcCopEnd:I tracked down a crook to the corvus system, but lost him, time to get the hell out of dodge!",
ngcCopEndPicked,NewGameOptionSelected,$option == ngcCopEnd,"NGCSetStartingLocation Corvus -2500 3000
NGCDone",,,

Yet

Code
AddTextSmall """"Acquired level 1 officer"""" good
SetTextHighlights """"level 1 officer""""
$ngcAddOfficer = true

Does not sow up in game... its as if these lines are not even written
must be something really silly im overlooking...
Please help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 10, 2018, 03:29:10 AM
@Ogaburan: Comparing to vanilla rules.csv, I think it's because your finalization rules rows don't call the following before NGCEnd?
e.g. ngcCopEndPicked should be
Code: txt
$ngcSkipTutorial = true
NGCAddCharacterPoints 3
NGCAddStandardStartingScript
NGCSetStartingLocation Corvus -2500 3000
NGCDone
(this also fixes the character skills screen not being displayed before it starts generating the new game)
(seems to make starting crew/cargo/fuel over capacity though, you shouldn't need to add resources manually like you currently are)

The officer added text not appearing is because the quote marks are doubled up for some reason.
Code: txt
AddTextSmall ""Acquired level 1 officer"" good
SetTextHighlights ""level 1 officer""

should be
Code: txt
AddTextSmall "Acquired level 1 officer" good
SetTextHighlights "level 1 officer"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ogaburan on December 10, 2018, 03:41:45 AM
Thanks Histidine!
It solved my problems.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 10, 2018, 06:24:16 AM
I've been trying to figure out the RaidIntel and related classes for Nexerelin's invasion fleets. (This is some really complicated stuff; I might have to write some notes for it as a guide for others).

Problem I have: When the fleet gets to its target planet, it just hangs around nearby and chases any enemy fleets that appear, instead of executing the raid method (i.e. performRaid isn't being called, and the return values of getRaidActionText and getRaidApproachText don't seem to be used). This is even though my current action stage class is mostly a copy of PEActionStage.
What do I change to control this? (Actually, does the punitive expedition actually do non-autoresolve raids either?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 09:09:25 AM
So if replacing variants, ships and weapons is impossible, are total conversions just dead, or is there something else I can do to solve this problem?

If I rename every file with "archeus_" as a prefix to each id then is there any places where those ids are hardcoded, or does the game now use the factions files for everything?

In other words, if I take out every default ship and variant can I replace all references to them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 09:43:39 AM
Do I replace the file by name without the path?

Or the path to the file in starsector-core?

Because a test of replacing the files directly by adding:

   "data/hulls/odyssey.ship",
   "data/hulls/onslaught.ship",
   "data/variants/onslaught/onslaught_Elite.variant",
   "data/variants/odyssey_Balanced.variant"]

To the end of mod_info,

Does not fix the weird variant/ship glitches with those ships.  :(

*Edit* Just tried it with weapon files and those don't work either.

(I'm assuming you mean in the "replace" array, not just at the end of mod_info.)

That looks right, and looking at the code, it should work, that is, the code loading variants/hulls/weapons should respect the "replace" section.

Again, if you could provide me with a mod to reproduce the problem, I'd be happy to take a look. If it has dependencies on LazyLib etc, that's fine.


I've been trying to figure out the RaidIntel and related classes for Nexerelin's invasion fleets. (This is some really complicated stuff; I might have to write some notes for it as a guide for others).

Problem I have: When the fleet gets to its target planet, it just hangs around nearby and chases any enemy fleets that appear, instead of executing the raid method (i.e. performRaid isn't being called, and the return values of getRaidActionText and getRaidApproachText don't seem to be used). This is even though my current action stage class is mostly a copy of PEActionStage.
What do I change to control this? (Actually, does the punitive expedition actually do non-autoresolve raids either?)

In your spawnFleet method in your version of raid intel, do you have this?

fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_RAIDER, true);

That's what makes fleets raid colonies.

Also, your FleetActionDelegate.canRaid(MarketAPI market) method needs to return true for the target colony.

Finally, the assignment script needs to be RaidAssignmentAI - or if it's not, it needs to handle the raiding behavior itself.

Edit: for punitive expeditions, this assignment AI is created - and the FleetActionDelegage (which is implemented by the action stage) passed in to it - in PunitivieExpeditionIntel.createAssignmentAI().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 10:21:56 AM
(I'm assuming you mean in the "replace" array, not just at the end of mod_info.)

That looks right, and looking at the code, it should work, that is, the code loading variants/hulls/weapons should respect the "replace" section.

Again, if you could provide me with a mod to reproduce the problem, I'd be happy to take a look. If it has dependencies on LazyLib etc, that's fine.

Yeah it was in the array just like how I replace skins (which works fine)

Absolutely, I can link you the entire mod on dropbox (the version those screenshots are from) if that works. There are no external dependencies right now it should work with vanilla alone.

*Edit* Whoops forgot to include the mod_info file in the mod I uploaded so if you downloaded it before this edit it is there now :P

You had originally said a minimal standalone mod, does this qualify or would you like me to fork vanilla and just add a vanilla ship/weapons override to see?

*EDIT 2*  -- Removed active mod link
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 10:31:52 AM
Gave it a quick look - erm, there's no mod_info file at all in this zip :)

You had originally said a minimal standalone mod, does this qualify or would you like me to fork vanilla and just add a vanilla ship/weapons override to see?

(This sorta qualifies, though a smaller mod would be a little easier to handle. Either way, really.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 10:33:33 AM
Gave it a quick look - erm, there's no mod_info file at all in this zip :)

You had originally said a minimal standalone mod, does this qualify or would you like me to fork vanilla and just add a vanilla ship/weapons override to see?

(This sorta qualifies, though a smaller mod would be a little easier to handle. Either way, really.)

Yeah just responded to that it is there now sorry! :)

Ok well let me know if you don't see anything at a quick. If nothing seems obvious Ill make a smaller standalone. Thanks for the help! (Was typing too fast before)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 10:34:27 AM
The file didn't upload originally because I was editing it :P

The ship to look at in this example is the Odyssey -- variant: odyssey_Balanced
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 10:50:20 AM
Got an error launching it:

java.lang.RuntimeException: Ship hull variant [kite_hegemony_Interceptor] not found!
java.lang.RuntimeException: Ship hull variant [kite_hegemony_Interceptor] not found!
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:60)
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:54)
   at com.fs.starfarer.loading.ShipRolesSpec$RoleEntry.getFPCost(ShipRolesSpec.java:71)
   at com.fs.starfarer.loading.ShipRolesSpec.<init>(ShipRolesSpec.java:183)
   at com.fs.starfarer.loading.SpecStore.loadFactions(SpecStore.java:1233)
   at com.fs.starfarer.loading.SpecStore.loadAll(SpecStore.java:128)
   at com.fs.starfarer.loading.ResourceLoaderState.init(ResourceLoaderState.java:365)
   at com.fs.state.AppDriver.begin(AppDriver.java:64)
   at com.fs.starfarer.combat.CombatMain.main(CombatMain.java:452)
   at com.fs.starfarer.StarfarerLauncher$1.run(StarfarerLauncher.java:271)
   at java.lang.Thread.run(Thread.java:745)


This one is because of:
"variantId": "kite_Interceptor",
in the kite_Interceptor.variant file.

Fixed that, ran again, got another error regarding another kite variant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 10:56:06 AM
Got an error launching it:

java.lang.RuntimeException: Ship hull variant [kite_hegemony_Interceptor] not found!
java.lang.RuntimeException: Ship hull variant [kite_hegemony_Interceptor] not found!
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:60)
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:54)
   at com.fs.starfarer.loading.ShipRolesSpec$RoleEntry.getFPCost(ShipRolesSpec.java:71)
   at com.fs.starfarer.loading.ShipRolesSpec.<init>(ShipRolesSpec.java:183)
   at com.fs.starfarer.loading.SpecStore.loadFactions(SpecStore.java:1233)
   at com.fs.starfarer.loading.SpecStore.loadAll(SpecStore.java:128)
   at com.fs.starfarer.loading.ResourceLoaderState.init(ResourceLoaderState.java:365)
   at com.fs.state.AppDriver.begin(AppDriver.java:64)
   at com.fs.starfarer.combat.CombatMain.main(CombatMain.java:452)
   at com.fs.starfarer.StarfarerLauncher$1.run(StarfarerLauncher.java:271)
   at java.lang.Thread.run(Thread.java:745)


This one is because of:
"variantId": "kite_Interceptor",
in the kite_Interceptor.variant file.

Fixed that, ran again, got another error regarding another kite variant.

Weird let me investigate. Ill provide an update when I figure out what didn't get uploaded
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 11:02:44 AM
I checked all files relevant to the kite and they are all there, even the kite_hegemony skin  ???

What was the second kite error?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 11:09:18 AM
I just downloaded the zip from the repository link I gave you, and ran it with the latest release.

It starts fine, but will likely crash on some variants in the viewer.

Try to only look at the Odyssey - odyssey_Balanced variant. I know you can get to that with the scroll wheel.

You can see the entries for the odyssey file exclusions in mod_info, but there are still merge conflicts with the ship file being mapped to the vanilla variant in some places.

You can then add entries to the replace array like:

"data/variants/onslaught/onslaught_Elite.variant",

and

"data/hulls/onslaught.ship",

And it will not affect the merge conflicts on the onslaught_Elite.variant either.

Maybe the replace array was never set up to handle those file types?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 11:29:41 AM
Ok, (sorry about message spam, but I have a potential fix for that error you are getting)

I just copied the kite_Interceptor variant and renamed its id to kite_hegemony_Interceptor so both will be present. Its in that repository. Let me know if you get any more errors for missing ids and I can add them as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 11:59:53 AM
On trying to launch the game with the mod enabled:

java.lang.RuntimeException: Ship hull variant [kite_original_Stock] not found!
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:60)
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:54)
   at com.fs.starfarer.loading.ShipRolesSpec$RoleEntry.getFPCost(ShipRolesSpec.java:71)
   at com.fs.starfarer.loading.ShipRolesSpec.<init>(ShipRolesSpec.java:183)
   at com.fs.starfarer.loading.SpecStore.loadFactions(SpecStore.java:1233)
   at com.fs.starfarer.loading.SpecStore.loadAll(SpecStore.java:128)
   at com.fs.starfarer.loading.ResourceLoaderState.init(ResourceLoaderState.java:365)
   at com.fs.state.AppDriver.begin(AppDriver.java:64)
   at com.fs.starfarer.combat.CombatMain.main(CombatMain.java:452)
   at com.fs.starfarer.StarfarerLauncher$1.run(StarfarerLauncher.java:271)
   at java.lang.Thread.run(Thread.java:745)

This is caused by the data/variants/kite/kite_Stock file having the following variantId in it:

"variantId": "kite_Stock",

Where the actual id the game looks for in various places (in this case, default_ship_roles.json) is "kite_original_Stock". I don't know how this is launching for you, that it is seems indicative of some sort of problem on your end. Either that, or the stuff in dropbox is not what you're running. In any case, what I just downloaded from dropbox can not possibly run.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 01:19:57 PM
On trying to launch the game with the mod enabled:

java.lang.RuntimeException: Ship hull variant [kite_original_Stock] not found!
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:60)
   at com.fs.starfarer.loading.ShipVariantStore.getVariant(ShipVariantStore.java:54)
   at com.fs.starfarer.loading.ShipRolesSpec$RoleEntry.getFPCost(ShipRolesSpec.java:71)
   at com.fs.starfarer.loading.ShipRolesSpec.<init>(ShipRolesSpec.java:183)
   at com.fs.starfarer.loading.SpecStore.loadFactions(SpecStore.java:1233)
   at com.fs.starfarer.loading.SpecStore.loadAll(SpecStore.java:128)
   at com.fs.starfarer.loading.ResourceLoaderState.init(ResourceLoaderState.java:365)
   at com.fs.state.AppDriver.begin(AppDriver.java:64)
   at com.fs.starfarer.combat.CombatMain.main(CombatMain.java:452)
   at com.fs.starfarer.StarfarerLauncher$1.run(StarfarerLauncher.java:271)
   at java.lang.Thread.run(Thread.java:745)

This is caused by the data/variants/kite/kite_Stock file having the following variantId in it:

"variantId": "kite_Stock",

Where the actual id the game looks for in various places (in this case, default_ship_roles.json) is "kite_original_Stock". I don't know how this is launching for you, that it is seems indicative of some sort of problem on your end. Either that, or the stuff in dropbox is not what you're running. In any case, what I just downloaded from dropbox can not possibly run.

I truly don't understand that. It 100% runs for me. I've triple checked now. To be sure, you aren't going to the codex? You are running in dev mode and using the edit variants menu?

I can make more variants with those ids if you would like.. but to be absolutely sure I downloaded that very zip and ran it with the release from here (other than setting devmode to true in settings.json under starsector-core):

http://fractalsoftworks.com/2018/11/ (http://fractalsoftworks.com/2018/11/)

It ran and I can look at the variant in question.

So, if you are using that build then this should run for you no problem.



It sounds like at this point I just need to fork the release, and add a single ship and variant to the replace array... I'll give you a link soon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 01:47:58 PM
I'm not going into the codex, no. The game crashes before the progress bar starts filling up.

... huh, but it does run if I use the installed version of -RC10 I've got. That's super weird! Let me investigate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 01:49:39 PM
So, just out of curiosity, I downloaded .9 and the mod from the link I sent you on a separate PC to see if it was an environmental issue for some reason.

Same behavior. But I can see the entries in the default_ship_roles.json you are referring to, and they are different than the mods ids. So that is quite strange. I corrected the one id in the repository if you feel like trying again, but I'm going to fork everything anyway to provide a better control.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 01:52:27 PM
So I just made a proper build from my current dev version, and when installed, that also runs the mod ok.

Which probably means there's a difference in how it's loading stuff, between the dev environment and the "proper' install. This would sort of explain the "double weapon mounts" issue, potentially, but it's ... weird. Going to investigate further; maybe it's strictly TC-related.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 03:29:57 PM
So I just made a proper build from my current dev version, and when installed, that also runs the mod ok.

Which probably means there's a difference in how it's loading stuff, between the dev environment and the "proper' install. This would sort of explain the "double weapon mounts" issue, potentially, but it's ... weird. Going to investigate further; maybe it's strictly TC-related.

My best educated guess is that the replace array simply was never intended to read those file types and is not actually replacing the vanilla files as intended. If what you say has changed will cause both files to be read and somehow conflict merged- (I feel like that would be incredibly hard to get right in every scenario so I'm glad an opt out was intended for TCs) -then the issue is probably setting up whatever code handles the replace array to handle all files.

I know the replace array works in general because skin and csv files are still replaced as intended.

*Edit* So, yes mostly TC related because most mods to my knowledge only edit existing variants and usually don't intend to fully replace them. (There are a lot of mods though, so maybe this just hasn't been caught until now)

Another possible cause could be changes to the .ship object that are not included in ship files, but that is suspect as well because non-vanilla mod ships are read and loaded correctly in the game's engine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 04:20:01 PM
Alright, I think I've got this sorted, at least partially. For... reasons... what was happening was the ship variant (and other files) was getting loaded, using the proper merge/replace logic. Then it was getting loaded again, but in a way that made it not find the modded override version - this provided the variant with the correct id, making the game not crash.

... so now, both the installed version and the dev environment version properly crash when trying to run the game with the mod :) Which means I haven't been able to verify whether this also fixes the multiple-weapon slot weirdness.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 05:09:01 PM
Alright, I think I've got this sorted, at least partially. For... reasons... what was happening was the ship variant (and other files) was getting loaded, using the proper merge/replace logic. Then it was getting loaded again, but in a way that made it not find the modded override version - this provided the variant with the correct id, making the game not crash.

... so now, both the installed version and the dev environment version properly crash when trying to run the game with the mod :) Which means I haven't been able to verify whether this also fixes the multiple-weapon slot weirdness.

Thanks for the update! Anything I can do on my end, for now?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 05:20:05 PM
If you could get me a mini-mod that 1) doesn't crash on my end and 2) reproduces the "duplicate weapon slots" etc issues on your end, that would be super!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on December 10, 2018, 06:37:50 PM
Is there a way to hide a weapon in the codex like for ships? I tried the Hint (leading to crash) and Tag fields (no changes)?
Many thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 06:39:20 PM
If you could get me a mini-mod that 1) doesn't crash on my end and 2) reproduces the "duplicate weapon slots" etc issues on your end, that would be super!

https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0 (https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0)

There you go!

Just look at the Odyssey Balanced variant. It is the only thing this mod attempts to edit. It is doubling weapon slots (look at the synergy slots seemingly on top of medium energy slots) and the vanilla variant is merged with the mod variant despite both files (variant and ship) being present, along with their file paths, in the replace array.

The ship_data.csv file is also being replaced, but this happens successfully. Notice that the Odyssey has 1 hullpoint, 1 armor strength, 1 max flux, 1 flux dissipation and 1000 ordinance points in addition to another flight bay.

I hope this helps narrow things down. :)

*Edit* now links to a mod folder instead of just the files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 10, 2018, 06:46:41 PM
Is there a way to hide a weapon in the codex like for ships? I tried the Hint (leading to crash) and Tag fields (no changes)?
Many thanks!

I think adding the SYSTEM *hint does that.

As a side note that doesn't apply for your situation currently, if you want it to show in the codex despite being a system (therefore not dropping off ships as loot) you can also add the SHOW_IN_CODEX hint.

*Edit* It is a hint, not a tag, sorry for the confusion.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2018, 10:17:18 PM
https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0 (https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0)

There you go!

Just look at the Odyssey Balanced variant. It is the only thing this mod attempts to edit. It is doubling weapon slots (look at the synergy slots seemingly on top of medium energy slots) and the vanilla variant is merged with the mod variant despite both files (variant and ship) being present, along with their file paths, in the replace array.

Thank you! I've reproduced the error on my end, will investigate tomorrow.

(Nice error mod name, btw :D)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 11, 2018, 10:23:48 AM

Thank you! I've reproduced the error on my end, will investigate tomorrow.

(Nice error mod name, btw :D)

Haha very original I know... :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 11, 2018, 07:23:48 PM
Alright, got this fixed! There was an issue with the way it was checking for overrides - if the path used \, it would work (at least, I think), but if it used /, it would fail. Now either one should work. Thank you for putting together the minimod, that really helped.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 11, 2018, 09:00:02 PM
Alright, got this fixed! There was an issue with the way it was checking for overrides - if the path used \, it would work (at least, I think), but if it used /, it would fail. Now either one should work. Thank you for putting together the minimod, that really helped.

Awesome! And not a problem I'm happy to help.  :)

Any possible way this could be a hotfix rather than a whole update before I can release my mod? Or do you think I can release it with this update if I switch that directory delimiter?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 11, 2018, 09:08:08 PM
Any possible way this could be a hotfix rather than a whole update before I can release my mod? Or do you think I can release it with this update if I switch that directory delimiter?

Pretty much no way as far as a hotfix, but, yeah, I think if you switch the delimiter it would probably work. But it would probably/possibly only work on windows. I'm actually not sure how this hasn't come up before.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 11, 2018, 09:20:58 PM
Any possible way this could be a hotfix rather than a whole update before I can release my mod? Or do you think I can release it with this update if I switch that directory delimiter?

Pretty much no way as far as a hotfix, but, yeah, I think if you switch the delimiter it would probably work. But it would probably/possibly only work on windows. I'm actually not sure how this hasn't come up before.

Nope, it won't even read the mod when I change it. *Edit* I'm on windows, too.

So, are you essentially saying this won't be fixed until 1.0? Or are you planning a smaller update cycle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 11, 2018, 09:24:18 PM
Nope, it won't even read the mod when I change it. *Edit* I'm on windows, too.

\ is an escape character, try \\ for each one instead.

Just tried this:
"data\\hulls\\odyssey.ship",

and it seems to work.

So, are you essentially saying this won't be fixed until 1.0? Or are you planning a smaller update cycle?

Oh, no no no. The next release will be 0.9.1a, with a *bunch* of bugfixes, balance tweaks, and so on. And there'll almost certainly be at least one (possibly more) release between *that* and 1.0.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 11, 2018, 09:31:17 PM
Nope, it won't even read the mod when I change it. *Edit* I'm on windows, too.

\ is an escape character, try \\ for each one instead.

Just tried this:
"data\\hulls\\odyssey.ship",

and it seems to work.

Ah, yes that does work! Great!! :D

So, are you essentially saying this won't be fixed until 1.0? Or are you planning a smaller update cycle?
Oh, no no no. The next release will be 0.9.1a, with a *bunch* of bugfixes, balance tweaks, and so on. And there'll almost certainly be at least one (possibly more) release between *that* and 1.0.

That is good to know at worst case scenario it wouldn't be another year, though at least for now it seems like I can release this update anyway. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 12, 2018, 02:54:08 AM
So I have a weapon with a really long chargup time - 9 seconds. During that time I want it to play an animation of power buildup with glows ad lighting and all that jazz.

Now, I know I can name the gun "test_gun_00.png" and add other images and if I define frames in the weapon file, it should play.
Does it works the same for the weapon glow? If i make "test_gun_glow00.png" will it work? Will it trigger duringhte charge phase or fire phase?

I'm worried because of the numbers of frame needed, since it's a BIG gun, so I'm looking into the most efficient method to achieve the effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2018, 11:30:50 AM
That one works for the main weapon sprite, it won't animate the glows the same way.

And, yeah, 9 seconds sounds like a lot of frames, especially for a large weapon. I'd probably recommend a script to spawn particles etc during chargeup, but someone more experienced with making these sorts of things might have better advice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 12, 2018, 11:42:32 AM
That one works for the main weapon sprite, it won't animate the glows the same way.

And, yeah, 9 seconds sounds like a lot of frames, especially for a large weapon. I'd probably recommend a script to spawn particles etc during chargeup, but someone more experienced with making these sorts of things might have better advice.

I'm trash at coding. Hopefully someone who knows what he's doing can help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nox4041 on December 12, 2018, 02:20:12 PM
Hello Everyone, this is my first time posting on the forums. Woot! :)

I am unsure if this should my its own post or I can add it here. Give this a try first.


Background
So first off I love the game so far so much so I wanted to add to it. I was thinking of doing something simple. I wanted to add new Bar events into the game. I notice that there is just a few and feel that I can make some fun missions and as time goes by I can even add multi-part missions and so on so forth. I am also thinking of creating a few missions the provide a more dynamic path to get blueprints and other special techs. I like the idea that you get a rumor about a space station that full of ancient tech but its ain a system full of {redeacted}. Rumors that the space pirates have found a [Cool BP] and they are trying to get it to [ System X]. YOu can then go and fight them for it. This kind of stuff would be a great addition to the game.

Technical Stuff
This is what I have found so far correct me where I may be wrong.

1. All of the Bar events are under api.impl.campaign.intel.bar. The BarEventManager is used to store all the event creators and then pick them as needed.

2. I also Understand that There are two scripts file for each event the event its self and the event creator. Still trying to figure out how to control when bar events fire off but I think that in the "Rules" but I have not looked that close yet.

3. The issue I have run into is that each event is loaded by CoreLifecyclePluginImpl (api\impl\campaign\CoreLifecyclePluginImpl.java). From my understanding, I will need to add each of my events to this file to be loaded into the game. The problem I see is per "Mod Structure & File Merging"  I would need to replace CoreLifecyclePluginImpl with my own version and it specifically recommends not doing this " Generally, only total conversions should replace the files specified above."

So my question is do I really need to replace CoreLifecyclePluginImpl with my own version to get my bar events to load or is there another place I can call the new events to be loaded into the manager?

Few Questions
I also have a few other questions.

Is there a way I can pull what blueprints the user currently has and then build a salvageable object with specific loot AKA "blueprint you do not have"? I kinda see this being done in api\impl\campaign\intel\bar\events\ScientistAICoreIntel.java with genLoot class that has been built.

How do I control when specific bar events fire off. I would like to add some mission that will let the play hunt down blueprints and other things of special value but I do not want these mission fire off until specific conditions are met like having a colony or a specific amount of credits?



PS. Thank you to anyone and everyone that can help!




Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on December 12, 2018, 02:53:31 PM
So my question is do I really need to replace CoreLifecyclePluginImpl with my own version to get my bar events to load or is there another place I can call the new events to be loaded into the manager?

How do I control when specific bar events fire off. I would like to add some mission that will let the play hunt down blueprints and other things of special value but I do not want these mission fire off until specific conditions are met like having a colony or a specific amount of credits?

Hey, I can sort of answer these questions: You don't need to override the thing! Create an EveryFrameScript or something like that, add it to the sector with .addScript, and you should be able to manage conditions for triggering a bar event in there. And you would trigger it by calling it like:

Code
PortsideBarData.getInstance().addEvent(new Kadur_RaiderBaseRumorBarEvent(this));

I do this for the crusader bases spawned by the Kadur faction in my mod, if you want to take a peek at the scripts -- link is in my sig.


EDIT: Also looking at CoreLifecyclePluginImpl, it's just a BaseModPlugin itself haha. So rather than override it, what you'd want to do is just have your own modplugin add various event management scripts for your events to the sector, like it's doing for the vanilla ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 13, 2018, 01:54:50 PM
Another weird one...

When I replace this falcon.ship file in mod_info (and all the associated skin/variant files mapped to that ship) the game fails to start with a nullpointer.

Nullpointer:
Spoiler
2990 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data\hulls\skins\falcon_p.skin)]
2990 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Archean Order TC v1.3.0 (data\hulls\skins\falcon_p.skin)]
3057 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.loading.ShipHullSpecLoader.new(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpecLoader.Ó00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.while(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

File being replaced that causes the crash.
Spoiler
{
  "bounds": [
    109.5,
    29.5,
    108.5,
    11,
    50,
    11,
    50,
    -11,
    110,
    -10,
    110.5,
    -29,
    4,
    -66,
    -0.5,
    -74.5,
    -43,
    -74.5,
    -79.5,
    -42.5,
    -81,
    -11,
    -68,
    -7.5,
    -68,
    7.5,
    -79,
    11,
    -78,
    45,
    -48,
    89,
    -30.5,
    86.5,
    -26,
    72.5
  ],
  "builtInMods": [
    "dedicated_targeting_core"
,   "warp_conduit"  ],
  "center": [
    92,
    85.5
  ],
  "collisionRadius": 126.965546,
  "engineSlots": [
    {
      "angle": 180,
      "contrailSize": 64,
      "length": 80,
      "location": [
        -81.5,
        36
      ],
      "style": "MIDLINE",
      "width": 16
    },
    {
      "angle": 180,
      "contrailSize": 64,
      "length": 80,
      "location": [
        -83,
        25
      ],
      "style": "MIDLINE",
      "width": 16
    },
    {
      "angle": 180,
      "contrailSize": 64,
      "length": 80,
      "location": [
        -84,
        15
      ],
      "style": "MIDLINE",
      "width": 16
    },
    {
      "angle": 180,
      "contrailSize": 64,
      "length": 80,
      "location": [
        -84,
        -15
      ],
      "style": "MIDLINE",
      "width": 16
    },
    {
      "angle": 180,
      "contrailSize": 64,
      "length": 80,
      "location": [
        -83.5,
        -25.5
      ],
      "style": "MIDLINE",
      "width": 16
    },
    {
      "angle": 180,
      "contrailSize": 64,
      "length": 80,
      "location": [
        -82.5,
        -36
      ],
      "style": "MIDLINE",
      "width": 16
    }
  ],
  "height": 202,
  "hullId": "falcon",
  "hullName": "Falcon",
  "hullSize": "CRUISER",
  "shieldCenter": [
    5.5,
    -0
  ],
  "shieldRadius": 128.549606,
  "spriteName": "graphics/ships/rebalance/falcon/falcon_base.png",
  "style": "MIDLINE",
  "viewOffset": 0,
  "weaponSlots": [
    {
      "angle": 0,
      "arc": 5,
      "id": "WS 001",
      "locations": [
        -33.5,
        79
      ],
      "mount": "HARDPOINT",
      "size": "MEDIUM",
      "type": "MISSILE"
    },
    {
      "angle": 0,
      "arc": 5,
      "id": "WS 002",
      "locations": [
        33,
        -47
      ],
      "mount": "HARDPOINT",
      "size": "SMALL",
      "type": "MISSILE"
    },
    {
      "angle": 155,
      "arc": 190,
      "id": "WS 003",
      "locations": [
        -60.5,
        25
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 205,
      "arc": 190,
      "id": "WS 004",
      "locations": [
        -60.5,
        -25
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": -30.963757,
      "arc": 207.219467,
      "id": "WS0003",
      "locations": [
        56,
        -20
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 30.963757,
      "arc": 207.219467,
      "id": "WS0004",
      "locations": [
        56,
        20
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 1",
      "locations": [
        27.5,
        44.5,
        35,
        38,
        44.5,
        37.5
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    },
    {
      "angle": 0,
      "arc": 360,
      "id": "LB 2",
      "locations": [
        -36.5,
        -69,
        -22,
        -70,
        -9.5,
        -69
      ],
      "mount": "HIDDEN",
      "size": "LARGE",
      "type": "LAUNCH_BAY"
    },
    {
      "angle": -90,
      "arc": 159.984039,
      "id": "WS0002",
      "locations": [
        -30.5,
        -47.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "UNIVERSAL"
    },
    {
      "angle": 90,
      "arc": 159.984039,
      "id": "WS0005",
      "locations": [
        -30.5,
        47.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "UNIVERSAL"
    },
    {
      "angle": -45,
      "arc": 200.841431,
      "id": "WS0010",
      "locations": [
        15,
        -10
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 45,
      "arc": 200.841431,
      "id": "WS0011",
      "locations": [
        15,
        10
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 6.025575,
      "id": "WS0007",
      "locations": [
        43.5,
        -0
      ],
      "mount": "HARDPOINT",
      "size": "LARGE",
      "type": "HYBRID"
    },
    {
      "angle": -60.945396,
      "arc": 180,
      "id": "WS0008",
      "locations": [
        -3.5,
        -42.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "UNIVERSAL"
    },
    {
      "angle": 60.945396,
      "arc": 180,
      "id": "WS0009",
      "locations": [
        -3.5,
        42.5
      ],
      "mount": "TURRET",
      "size": "SMALL",
      "type": "UNIVERSAL"
    },
    {
      "angle": -90,
      "arc": 0,
      "id": "WS0012",
      "locations": [
        -21.5,
        -68
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "SYSTEM"
    },
    {
      "angle": 56.309933,
      "arc": 0,
      "id": "WS0013",
      "locations": [
        34.5,
        44
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "SYSTEM"
    },
    {
      "angle": 0,
      "arc": 5,
      "id": "WS0001",
      "locations": [
        42,
        -35
      ],
      "mount": "HARDPOINT",
      "size": "SMALL",
      "type": "MISSILE"
    }
  ],
  "width": 184
}
[close]

It doesn't really give much indication where this is coming from, or at least where it seems to point to in the stack trace doesn't make sense to me. It seems to come from the falcon_p.skin file that was added in .9.

So here is that file:

Spoiler
{
   "baseHullId":"falcon",
   "skinHullId":"falcon_p",
   "hullName":"Falcon (P)",
   "descriptionId":"falcon",
   "descriptionPrefix":"This Falcon's propulsion system has been given impractical yet showy 'improvements' by some enthusiastic pirate crew; the patchwork of engine components, somehow persuaded to work toward ungainly common purpose, conform to zero safety standards.",
   "tags":[],
   "tech":"Pirate",
   "restoreToBaseHull":true,
   "baseValueMult":0.85,
   "spriteName":"graphics/ships/rebalance/falcon/falcon_pirates.png",
   "removeWeaponSlots":[],       # ids
   "removeEngineSlots":[],       # indices, as engine slots have no id in the .ship file
   "removeBuiltInMods":[],       # hullmod ids
   "removeBuiltInWeapons":[],       # weapon slot ids
   "weaponSlotChanges":{},
   "builtInMods":[],
   "builtInWeapons":{
    },
}
[close]

I don't see anything that would cause a nullpointer there unless "tech" does for some reason if the value is invalid. I would think that would just be for a string compare (so nullable) when choosing what variants to spawn.

I've made sure that these exist in their correct paths in the mod, and have their paths correct in the replace array in mod_info (minus hullmods):

 
For each variant other than the falcon_p_Strike, they would load correctly with the same ship file in .8

To ensure a proper control, the falcon_p_Strike variant was copied from an existing, vetted variant in .8 as well.


Am I missing variants or something? I can't figure out why it would throw a nullpointer only when being replaced. As long as the variants are also replaced and mapped to the same weapon mounts...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 13, 2018, 02:31:12 PM
This might be another "send me a small test mod" kind of issue :)

I suspect this is something to do with weapon ids in your replacement file, though - but given your falcon_p.skin replacement file, that doesn't look like it should matter.

(Also, might want to change restoreToBaseHull":true to false in your skin, since that's causing the "falcon(p) restores to regular falcon" bug.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 13, 2018, 03:57:06 PM
This might be another "send me a small test mod" kind of issue :)

I suspect this is something to do with weapon ids in your replacement file, though - but given your falcon_p.skin replacement file, that doesn't look like it should matter.

(Also, might want to change restoreToBaseHull":true to false in your skin, since that's causing the "falcon(p) restores to regular falcon" bug.)

Ok thanks Ill get another mini mod going or just use the same one as before and take out the old files. That should work. I'll link it here when I'm done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 13, 2018, 05:02:08 PM
Ok, remove:

"data\\hulls\\falcon.ship",

-From the replace array and the mod will start.

But, it may throw another error when variants show up for some reason, even though I've replaced all weapons and weapon files... so it may be related to that but I haven't had a chance to delve deeper into it yet.


https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0 (https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0)


*Edit* to make the mod as minimum as possible I also removed related mod wings from the variants and new hullmods the mod would introduce. Just fyi in case that helps.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 13, 2018, 05:25:08 PM
Hmm - so you've got "data/hulls/skins/falcon_p.skin", and a couple more cases of using / instead of \\ in the replace section.

This works on my end (due to the fix for detecting various separators better) but for now you've got to use \\ everywhere in the replace section.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 14, 2018, 09:45:00 AM
Hmm - so you've got "data/hulls/skins/falcon_p.skin", and a couple more cases of using / instead of \\ in the replace section.

This works on my end (due to the fix for detecting various separators better) but for now you've got to use \\ everywhere in the replace section.

Ok I'll try that then. I had thought that format works for non ship or weapon files but to be safe I should just move every line to that format for now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on December 14, 2018, 11:44:23 AM
Okay, so it turns out my CAS beams stop stations from rotating which is not really desireable; as such I need to be able to get and alter their impact to 0 if they're hitting a station. Unfortunately I'm not sure how to get a weapons impact value through the API, anyone have any ideas how to do so?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 14, 2018, 11:56:02 AM
...I've had stations rotate backwards for a bit after being rammed by an AI-controlled Odyssey.  Sometimes the Odyssey even survives.

As for impact from CAS beams: if you can't find a way to modify the impact, it might be possible to use an on-hit script to modify the station, instead, forcing its rotation values to correct.  Or maybe even just adding a zero-damage secondary hit with a negative impact?  Hm.  Possibilities to experiment with, I suppose.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 14, 2018, 12:45:57 PM
Hmm - so you've got "data/hulls/skins/falcon_p.skin", and a couple more cases of using / instead of \\ in the replace section.

This works on my end (due to the fix for detecting various separators better) but for now you've got to use \\ everywhere in the replace section.

Ok I'll try that then. I had thought that format works for non ship or weapon files but to be safe I should just move every line to that format for now.

Just wanted to pop on here and say that seemed to solve everything and now all the old .8 variants are clean and mapped correctly. :)

Time to start working on the new ones and adding the stations.

I'm going to post the full replace array in the modding resources section for anyone else who happens to be working on a TC. It took a while to get everything there so I may as well save others the time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 14, 2018, 08:49:52 PM
Am I correct in understanding that the raid intel (and derivatives thereof) sometimes doesn't spawn fleets and instead abstracts them away? Under what circumstances does this occur, and could it be disabled if someone hypothetically wanted to do so?

(Reason I'm asking: the current Nexerelin invasion code requires an actual CampaignFleetAPI with actual marines in its CargoAPI, and I'm wondering if this is going to break somewhere)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 14, 2018, 09:56:21 PM
Am I correct in understanding that the raid intel (and derivatives thereof) sometimes doesn't spawn fleets and instead abstracts them away? Under what circumstances does this occur, and could it be disabled if someone hypothetically wanted to do so?

(Reason I'm asking: the current Nexerelin invasion code requires an actual CampaignFleetAPI with actual marines in its CargoAPI, and I'm wondering if this is going to break somewhere)

Yep, correct. That's what the autoresolve() method in the various *ActionStage classes is about, in part - handling the outcomes of raids when (potentially only some of) the fleets are abstracted.

Take a look at AssembleStage.addRoutesAsNeeded() for an example of how fleets are created - what's actually created is a RouteData, via RouteManager.getInstance().addRoute(). One of the parameters to that is a RouteFleetSpawner. RouteManager then spawns/despawns these fleets - by calling the spawner to spawn the fleet when necessary - based on their proximity to the player (and whether the player has seen them; i.e. something the player has seen will stick around for a while even if it gets beyond the despawn range).

RouteManager is probably a good class to take a look at if you want to make sense of this; basically a RouteData has some parameters that govern how the fleet is spawned, and a bunch of RouteSegments - travel here, stay here, etc - which are gone through while the fleet is abstracted. It's the job of the fleet's assignment AI (which would generally extend RouteFleetAssignmentAI) to put the fleet in the right location given the current segment, and to move it along to the next segment as necessary, while the fleet is spawned. There are utility methods in RouteFleetAssignmentAI to do that for the general cases. RaidAssignmentAI is one of the simpler classes extending it - it does raid checks and provides some action text overrides, and lets the parent class handle the messier spawn-location and assignment changing business.

Rather than disabling this, it'd probably be easier to write your own custom RaidIntel, since most of the work in RaidIntel and the various raid stages deals with making things work for abstracted and non-abstracted fleets.

However, I would suggest *not* disabling it - fleets are a huge portion of the load, both in terms of performance and savefile size. There are a few cases where fleets exist permanently in vanilla (bounty fleets being a notable example) but pretty much everything else has been converted to use RouteData, or alternate systems that spawn fleets as needed (such as SourceBasedFleetManager for remnants, or DisposableFleetManager for some kinds of pirates and Pathers).

Plus, you'll run into issues where, say, if you've got an invasion fleet in a system somewhere, there wouldn't be any patrols to fight it if it's far away from the player. So if you're relying on defenders to actually fight that fleet, that would not work at all, so you'd need to do some sort of autoresolve considering those unspawned fleets anyway. (Or you could start always spawning defenders as well, but simulating every fleet is more or less untenable performance-wise... not doing that is a large part of why the 0.9 release has a generally more manageable save file size and improved performance.)

Check out the WarSimScript.getFactionStrength() method, and the various places that call it, to see how autoresolve strength calculations are handled. Basically, it tallies up the total strengths of both actual fleets and of RouteData whose current segment is in the same location.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Serenitis on December 16, 2018, 02:54:09 PM
A player.faction question.

I have a set of portraits, and a custom names list in a mini-mod.
Both of which work and appear in game as if they were just appended to the list of available characters.

Is there any way of telling the game to override the defaults and only use the 'new' data so long as this mod is active?
Currently my player.faction file only has 3 sections defined: Portraits, flags, and a name category.
If I recreated the 'full' file, would that be used in preference instead of being added onto the pre-existing data?

[e]
Nope. Creating a whole new player.faction does not replace the entries, just appends them like before.
It is a mystery.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2018, 03:21:07 PM
You'll need to add player.faction to the "replace" array in your mod_info.json in order for it to replace the core file rather than be merged with it.

Something like:

"replace":[
    "data\\world\\factions\\player.faction",
],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Serenitis on December 16, 2018, 03:29:13 PM
Is there anything else I'd need to do?
Adding the above to mod_info.json seems to still merge rather than replace.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2018, 03:36:51 PM
Hmm, no, that alone should do it.

Edit: do you perhaps have a duplicate (and empty) "replace" section there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Serenitis on December 16, 2018, 03:40:28 PM
The entire contents of the file:
Code
{
"id":"player_mini", # internal id
"name":"Player Mini-Mod", # displayed to the player
"version":"0.0.0", #lol
"description":"Adds player faction flags, portraits, and name lists",
"gameVersion":"0.9a",
"replace":[
"data\\world\\factions\\player.faction",
],
}
That last bit was just pasted in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2018, 03:59:48 PM
Hmm, maybe try "data/world/factions/player.faction"? I'm not sure why it wouldn't work, though, that's really odd.

If you don't mind uploading your mod somewhere, I could take a quick look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Serenitis on December 16, 2018, 04:15:20 PM
http://s000.tinyupload.com/index.php?file_id=61511815973634570593

I am so very very sorry :P
Also, tried single slashes. No change.
It will be some weird thing I've done because I am clearly an incompetant Pather.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2018, 04:28:23 PM
So, hmm, this actually works for me - both in the dev environment and with a fresh install of the dev version. I did make some changes based on the issues Morrokain was running into, though.

... and, yeah, this doesn't work on an install of RC10. But it'll work come 0.9.1a!

I am so very very sorry :P

Haha :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Serenitis on December 16, 2018, 04:37:34 PM
It was / instead of \ or \\.
Thank you for the time you've spent messing with this, rather than doing something productive.
Now I'm being amused by the namegen of all things...

I'll leave it up in case anyone wants a giggle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2018, 04:38:34 PM
Ah, alright - glad you got it working!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nox4041 on December 16, 2018, 08:16:28 PM
I am struggling to understand a few things about the system and I am hoping that someone here can help me understand. I think I may just be missing something.

So at this time I can copypasta and get new events to show up in game, but here is the problem. I am a completionist and I want to understand the system entirely.

I am still learning java and programming in general and this is my first time doing anything with an API.

Ok, so I understand that I can create a new event by extending BaseBarEvent and or any of its subclasses. I  then create a class that extends BaseBarEventCreator and then this is loaded into the class BarEventManager and then some magic happens and picks the events that can be shown.

Now what I think I have worked out is that BarCMD is used to execute the bar events, my question is how does the game know what text options the user has picked on the screen? I do not see any variables being returned or sent somewhere I just don't get it. I mean look at the code below.

https://imgur.com/a/JOWxicu


Like getAcceptedText does nothing other than return the text but how does the game know that I have Accepted anything? I have looked over BaseGetCommodityBarEvent which my test event is based off.  I do see some code about "public void optionSelected(String optionText, Object optionData)" and it somehow knows that the user has selected Cancel, continue or confirm. I see this optionData but I have no idea what data is being fed into this class.

I expanded my search and found BarCMD this seems to be the class that executes the events, I think, but even after looking through it and checking through BarEventDialogPlugin and so and so forth. I am completely lost.

Can someone please point me in the correct direction?

PS. Again sorry if this is somehow super simple and I have just missed something. I have just been looking over this all weekend and I feel like I have completely failed to grasp something that I thought would be simple.

Also if it is something that is simple and it's just my lack of experience in java can you give me some concepts to look up and learn?

Thank You,
Nox404

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2018, 08:32:15 PM
Hi there!

(If you've got the code loaded into Eclipse or Netbeans, "show references" (Ctrl-Shift-G in Eclipse) is your friend. It won't get you all the way there, since some stuff is called from core code, but it'll go a long way.)

getAcceptedText(), as you say, gets called from BaseGetCommodityBarEvent.optionSelected()

optionSelected() gets called from BarEventDialogPlugin.optionSelected()

If you take a look at BarCMD, you'll see this line:

dialog.setPlugin(this);

That makes the core dialog code call BarCMD's optionSelected() method. That, in turn, has the following code:

PortsideBarEvent event = (PortsideBarEvent) optionData;
BarEventDialogPlugin plugin = new BarEventDialogPlugin(this, this, event, memoryMap);
dialog.setPlugin(plugin);

Which sets the dialog plugin to the actual bar event - i.e. the class that extends BarEventDialogPlugin.


So, basically:

1) A core interaction dialog calls its current InteractionDialogPlugin's optionSelected() method when the option is selected by the player.

2) The BarCMD method juggles what the dialog's plugin actually is - itself so it can populate the options, then a specific bar event's plugin when that event is selected, then back to the originalPlugin when it's time to leave the bar.

Hope that makes sense! Feel free to ask if you'd like me to clarify something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nox4041 on December 17, 2018, 01:20:30 AM
Hi there!

(If you've got the code loaded into Eclipse or Netbeans, "show references" (Ctrl-Shift-G in Eclipse) is your friend. It won't get you all the way there, since some stuff is called from core code, but it'll go a long way.)

getAcceptedText(), as you say, gets called from BaseGetCommodityBarEvent.optionSelected()

optionSelected() gets called from BarEventDialogPlugin.optionSelected()

If you take a look at BarCMD, you'll see this line:

dialog.setPlugin(this);

That makes the core dialog code call BarCMD's optionSelected() method. That, in turn, has the following code:

PortsideBarEvent event = (PortsideBarEvent) optionData;
BarEventDialogPlugin plugin = new BarEventDialogPlugin(this, this, event, memoryMap);
dialog.setPlugin(plugin);

Which sets the dialog plugin to the actual bar event - i.e. the class that extends BarEventDialogPlugin.


So, basically:

1) A core interaction dialog calls its current InteractionDialogPlugin's optionSelected() method when the option is selected by the player.

2) The BarCMD method juggles what the dialog's plugin actually is - itself so it can populate the options, then a specific bar event's plugin when that event is selected, then back to the originalPlugin when it's time to leave the bar.

Hope that makes sense! Feel free to ask if you'd like me to clarify something.



So if I understand right and I am reading the code correctly InteractionDialogAPI.setPlugin is what tells you core code what class to execute and the only classes it can execute are classes the implement InteractionDialogPlugin?

I hope that makes sense. And thank you Alex. Your awesome.


OMG. So I was thinking about this as I was writing this. IF my logic is correct then InteractionDialogPlugin getPlugin() will pull the current plugin running in the core code?


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2018, 08:43:46 AM
So if I understand right and I am reading the code correctly InteractionDialogAPI.setPlugin is what tells you core code what class to execute and the only classes it can execute are classes the implement InteractionDialogPlugin?

Those are the only classes that you can pass in as a parameter to setPlugin() and that will be called by the core interaction dialog code, yes.

OMG. So I was thinking about this as I was writing this. IF my logic is correct then InteractionDialogPlugin getPlugin() will pull the current plugin running in the core code?

Right - so for example when a command (such as BarCMD, or others) is called, getPlugin() will return a RuleBasedInteractionDialogPluginImpl, which is in API code.

Also, take a look at CoreCampaignPluginImpl.pickInteractionDialogPlugin() - that's where the initial plugin for interacting with a particular entity is picked. Generally, that's the plugin that'll get used for much of the interaction, though for some trickier things (such as bar events, salvage specials, salvage defender combat, etc) another plugin (or plugins) will be substituted temporarily.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 17, 2018, 10:07:37 AM
If I recall correctly, at some point during your work on the Stations you and David thought about having some "underside" decorative layer:

(http://fractalsoftworks.com/wp-content/uploads/2018/02/decor_modules.jpg)

That's something I would be very interested in using but regular deco weapons are always drawn on top of the modules. So is there a trick to make it work or is that a feature that was entirely scrapped and removed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2018, 10:39:11 AM
They were implemented as modules, not decorative weapons.

They had the following hints:
UNBOARDABLE, HIDE_IN_CODEX, UNDER_PARENT

UNDER_PARENT actually makes it render under all ships.

They also had the following built-in hullmods:
"builtInMods": [
        "reduced_explosion", # probably unnecessary
        "never_detaches",
        "anchorrotation", # depends on if you actually want it to rotate...
        "vastbulk" # probably unnecessary
    ],

I don't remember what made them not get hit by weapons fire, though - tried tracking this down but not having much luck.

If you added decorative weapons to this type of module, I *think* it would still get rendered on top of everything else.

(FWIW, we didn't end up doing this because all of our attempts at it made the stations too hard to "read" in combat.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 17, 2018, 10:42:37 AM
Okay, too bad for my plans. I was looking at adding some support structure under my modules using deco weapons rather than having a full size station sprite for each three levels, and save some V-Ram.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2018, 10:46:34 AM
Hmm - this method was only really relevant for something that moves relative to the base, yeah.

As far as saving vram, yeah, this is pretty much why the various struts etc are not part of the "base" station sprites, to keep the size of those down while still letting the station spread out. In some cases, I think there's some "under" stuff baked into the base, just outside the collision bounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on December 17, 2018, 06:39:12 PM
Okay, so say hypothetically (not hypothetically) I wanted to remove the core bounty script and replace it with my own as a part of a pirate start.

I've tried putting this in my ModPlugin:

Code
    @Override
    public void onGameLoad(boolean newGame) {
        if (!Global.getSector().getFaction(Factions.PIRATES).isHostileTo(Factions.PLAYER)) {
            for (EveryFrameScript s : PersonBountyManager.getInstance().getActive()) {
                Global.getSector().removeScript(s);
            }
            if (!Global.getSector().hasScript(KadurPersonBountyManager.class)) {
                Global.getSector().addScript(new KadurPersonBountyManager());
            }
        }
    }

And it doesn't work. I've tried putting the same thing in my rulecmd for the pirate start itself (just the if/for/if block, not the method declaration) and it still doesn't work. I load in and see a bunch of bounties for 'a notorious pirate' and the log still says they're being created by PersonBountyIntel, not KadurPersonBountyIntel.

What am I missing -- do I have the arguments right? Should I be calling it from somewhere else?

Also, as an aside, I notice the intel description for personal bounties is pulling from one of two places (either the script itself or reports.csv), which one of those is actually being used?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2018, 06:53:33 PM
What you really want to do is stop the core PersonBountyManager from creating bounties before it even starts.

So, either:
sector.removeScript(PersonBountyManager.getInstance()) in your onGameLoad()

Or, in settings.json:
"minPersonBounties":0,
"maxPersonBounties":0,

If you also want to clean up existing bounties, onGameLoad probably isn't the place to do it (since then saving and loading would change the save's state, which isn't great). But what you'd do is something like:

for (EveryFrameScript s : PersonBountyManager.getInstance().getActive()) {
    ((PersonBountyIntel)s).endImmediately();
}



Also, as an aside, I notice the intel description for personal bounties is pulling from one of two places (either the script itself or reports.csv), which one of those is actually being used?

reports.csv is no longer used for anything at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on December 17, 2018, 07:58:08 PM
Alright, Alex to the rescue! I'll try it again.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on December 18, 2018, 10:46:27 AM
Here's a quick one; if you're using a custom phase cloak system, what's the best way to get the game to classify ships using it as phase ships in the doctrine and production interface? I've looked through the vanilla files for tags, etc. that would mark a ship that way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 18, 2018, 10:55:05 AM
Oh, that's easy: there currently isn't one :) ... at least, that I'm aware of.

On my list for the .1 release!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on December 18, 2018, 11:54:31 AM
Quick question; is there a way to make it so that the player needs to have, say, a certain rep level before being able to build an industry?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 18, 2018, 11:59:19 AM
Yep - override the relevant methods from BaseIndustry in your Industry's class.

public boolean isAvailableToBuild();
public boolean showWhenUnavailable();
public String getUnavailableReason();

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on December 18, 2018, 02:59:39 PM
So, there's a way to add participating factions to the bounty manager:

Code
PersonBountyEventData.addParticipatingFaction(String factionId)

But there doesn't seem to be a way to remove them. Anything I'm missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 18, 2018, 03:04:49 PM
getParticipatingFactions().remove(factionId)

There ought to be a removexxx() method to make it cleaner, but this'll do the job.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on December 18, 2018, 03:18:29 PM
Boy do I ever feel dumb right now. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 18, 2018, 03:26:15 PM
No worries :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on December 19, 2018, 11:37:13 AM
Trying to get it set up so Heavy Industry and my Modular Fabricators block each other, which is a better solution than just expecting the player to know it's a waste of a slot. However this is proving tricky. After some thinking I switched my Modular Fabs code to an extension of the Heavy Industry java in the hopes that I could get it to recognize the block.

I feel like I'm almost there, but this only works one way (Heavy Industry blocks Modular Fabricators, but not vice versa):

Spoiler
Code: java
        @Override
    public boolean isAvailableToBuild() {
        if (!super.isAvailableToBuild()) return false;
                
                boolean hasHeavy = false;
                boolean hasModular = false;
                if (market.getPlanetEntity() != null && market.hasIndustry(Industries.HEAVYINDUSTRY)) {
                    hasHeavy = true;
                }
                if (market.getPlanetEntity() != null && market.hasIndustry(MS_industries.MODULARFACTORIES)) {
                    hasModular = true;
                }
                
                if (hasModular || hasHeavy) {
                    return false;
                } else if (!hasModular && !hasHeavy) {
                    return true;
                }
                
        return false;
    }
[close]

Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2018, 11:54:22 AM
One (relatively minor) immediate thing is that this won't account for Orbital Works. You probably want to iterate through all the industries on a colony and check if it has the "heavyindustry" tag.

The other is, well, since you're only changing the code for Modular Fabricators, that's the only industry that's affected. To do what you're trying to do, you'd need to also provide your own implementation of HeavyIndustry (probably one that extends it and just overrides the isAvailableToBuild() etc methods). To do that, you'd add a "heavyindustry" row in your industries.csv, which would be a copy-paste of the vanilla one, except pointing to a different plugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 22, 2018, 06:20:36 AM
Could I get the source of FactionAPI.getRelColor()? I want to be able to get the correct relationship color given an arbitrary float value [-1, 1].
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 22, 2018, 09:09:18 AM
Here it is, slightly adjusted to point to a few utility methods from Misc instead of some older duplicates in core:

Code: java
	public Color getRelColor(String otherFactionId) {
Color relColor = new Color(125,125,125,255);
float rel = getRelationship(otherFactionId);
if (rel > 1) rel = 1;
if (rel < -1) rel = -1;

if (rel > 0) {
relColor = Misc.interpolateColor(relColor, Misc.getPositiveHighlightColor(), Math.max(0.15f, rel));
} else if (rel < 0) {
relColor = Misc.interpolateColor(relColor, Misc.getNegativeHighlightColor(), Math.max(0.15f, -rel));
}
return relColor;
}

Let me also add getRelColor(float rel) to Misc; might as well while I'm at it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ali on December 23, 2018, 06:04:23 AM
Anyone able to advise how i would change a fighters weaponry please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on December 23, 2018, 07:17:54 AM
A fighter also has a loadout in the variants folder. Just edit that
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ali on December 23, 2018, 07:26:58 AM
Many thanks Trash!

That worked great!

So happy seeing shielded, beam weapon equipped, terminators again!!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nox4041 on December 24, 2018, 01:26:42 AM
I am reading through FireBest and I am having a hard time understand this chunk of code.

Code: java
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
        
        this.ruleId = ruleId;
        this.dialog = dialog;
        this.params = params;
        this.memoryMap = memoryMap;
        String trigger = params.get(0).string;
        if (params.get(0).isVariable()) {
            VarAndMemory var = params.get(0).getVarNameAndMemory(memoryMap);
            trigger = var.memory.getString(var.name);
        }
        
        RulesAPI rules = Global.getSector().getRules();
        RuleAPI rule = rules.getBestMatching(ruleId, trigger, dialog, memoryMap);
        
        if (rule == null) return false;
        
        applyRule(rule);
        
        return true;
    }
    
    public static boolean fire(String ruleId, InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap, String params) {
        return new FireBest().execute(ruleId, dialog, Misc.tokenize(params), memoryMap);
    }


when RuleBasedInteractionDialogPluginImpl  calls firebest it sends the Trigger string "OpenInteractionDialog" the above code then sets the Trigger as a Tokenize string. Now From my understanding this would be set to OpenInteractionDialog as a tokentype.LITERAL.  That then get executed through the above code.  Now this is where I am getting confused String trigger = params.get(0).string; Should Return OpenInteractionDialog that was set by RuleBasedInteractionDialogPluginImpl when created or have I missed something? And if it does return just OpenInteractionDialog the how does rules.getBestMatching know what rule to pick. Does it check the conditions? Where in the code are they checked?


OpenInteractionDialog Being set as initialTrigger
Code: java
public RuleBasedInteractionDialogPluginImpl() {
        this("OpenInteractionDialog");
    }
    public RuleBasedInteractionDialogPluginImpl(String initialTrigger) {
        this.initialTrigger = initialTrigger;
    }


Thank you for any help you can provide! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2018, 12:43:23 PM
Now this is where I am getting confused String trigger = params.get(0).string; Should Return OpenInteractionDialog that was set by RuleBasedInteractionDialogPluginImpl when created or have I missed something? And if it does return just OpenInteractionDialog

It'll be whatever the parameter was - if you look at rules.csv, there's lots of cases of FireBest being called with different triggers. RuleBasedInteractionDialogPluginImpl calls it with the OpenInteractionDialog trigger to get things started.

the how does rules.getBestMatching know what rule to pick. Does it check the conditions? Where in the code are they checked?

It checks the conditions, and it's in core code that's not directly mod-visible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nox4041 on December 24, 2018, 01:25:08 PM
Now this is where I am getting confused String trigger = params.get(0).string; Should Return OpenInteractionDialog that was set by RuleBasedInteractionDialogPluginImpl when created or have I missed something? And if it does return just OpenInteractionDialog

It'll be whatever the parameter was - if you look at rules.csv, there's lots of cases of FireBest being called with different triggers. RuleBasedInteractionDialogPluginImpl calls it with the OpenInteractionDialog trigger to get things started.

the how does rules.getBestMatching know what rule to pick. Does it check the conditions? Where in the code are they checked?


It checks the conditions, and it's in core code that's not directly mod-visible.



I am sorry Alex, I found the StarSectorRuleScripting PDF with the answers I was looking for. I am sorry. I was trying to read the code to find out what conditions I can use but I failed to look for that information on the forums first before asking.

Thank you for always being here to help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2018, 01:29:17 PM
No worries! Btw - the PDF is pretty old and is at best a way to get started; it doesn't include everything, so it's probably best to just treat it as an extra source of info rather than the source of info, if that makes sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on December 24, 2018, 03:19:59 PM
I have this issue  Hellbore looks like this https://webmshare.com/d6O8d
It should look like this https://vignette.wikia.nocookie.net/starfarergame/images/7/72/Hellbore.gif/revision/latest?cb=20180817171741
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on December 25, 2018, 12:32:23 AM
I have this issue  Hellbore looks like this https://webmshare.com/d6O8d
It should look like this https://vignette.wikia.nocookie.net/starfarergame/images/7/72/Hellbore.gif/revision/latest?cb=20180817171741

Looks to me like you've given it two barrels.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on December 25, 2018, 05:24:01 AM
I have this issue  Hellbore looks like this https://webmshare.com/d6O8d
It should look like this https://vignette.wikia.nocookie.net/starfarergame/images/7/72/Hellbore.gif/revision/latest?cb=20180817171741

Looks to me like you've given it two barrels.
It's not what it looks officer! I'm innocent I swear!
No but really, I made a custom sound mod for the hellbore, for some reason even though I didn't change anything specific to the barrel, I got that visual effect.
So I was hoping some of you had a guess how that happened and how to fix it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 25, 2018, 05:46:48 AM
Thanks Alex!

New question: Are there any listeners or such in the current version for a colony being founded, a market being decivilized, or being destroyed by bombardment?
(actually a general market added/removed listener would be good)

I have this issue  Hellbore looks like this https://webmshare.com/d6O8d
It should look like this https://vignette.wikia.nocookie.net/starfarergame/images/7/72/Hellbore.gif/revision/latest?cb=20180817171741

Looks to me like you've given it two barrels.
It's not what it looks officer! I'm innocent I swear!
No but really, I made a custom sound mod for the hellbore, for some reason even though I didn't change anything specific to the barrel, I got that visual effect.
So I was hoping some of you had a guess how that happened and how to fix it.
Are you sure you didn't accidentally modify anything else? Post your hellbore.wpn.

Spoiler
Unmodified one I've got:
Code: json
{
"id":"hellbore",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"BALLISTIC",
"size":"LARGE",
"displayArcRadius":600,
"turretSprite":"graphics/weapons/hellbore_cannon_turret_base.png",
"turretGunSprite":"graphics/weapons/hellbore_cannon_turret_recoil.png",
"hardpointSprite":"graphics/weapons/hellbore_cannon_hardpoint_base.png",
"hardpointGunSprite":"graphics/weapons/hellbore_cannon_hardpoint_recoil.png",
"visualRecoil":10.0,  # the gun sprites are only used if this is non-0
"renderHints":["RENDER_BARREL_BELOW"],
"turretOffsets":[35, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[50, 0],
"hardpointAngleOffsets":[0],
"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",
"muzzleFlashSpec":{"length":65.0,   # only used if animationType = MUZZLE_FLASH
   "spread":15.0,
   "particleSizeMin":10.0,
   "particleSizeRange":35.0,
   "particleDuration":0.75,
   "particleCount":50,
   "particleColor":[255,120,50,245]},
"projectileSpecId":"hellbore_shot",  # projectile that will be fired
"fireSoundTwo":"hellbore_fire",
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on December 25, 2018, 11:41:22 AM
Question, on the next fix, we will got a means to do a blueprint for modded station too? 
(Like look impossible, else, because they are three "fake" industry and available per default on the list of choice of station, but you have put a blueprint for them.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 25, 2018, 11:56:16 AM
Thanks Alex!

New question: Are there any listeners or such in the current version for a colony being founded, a market being decivilized, or being destroyed by bombardment?
(actually a general market added/removed listener would be good)

Taking a quick look, I don't think so. (Sorry, still mid-adapting-to-new-PC, so feeling a bit scattered.)

For future reference, take a look in com.fs.starfarer.api.campaign.listeners.ListenerUtil - anything that's in place would have corresponding methods there.

Question, on the next fix, we will got a means to do a blueprint for modded station too? 
(Like look impossible, else, because they are three "fake" industry and available per default on the list of choice of station, but you have put a blueprint for them.)

I think it's already possible, just make a copy of the "Orbital Station" industry for your style and make the blueprint for that. It should show up under the parent category if you have the same tags.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on December 26, 2018, 10:17:15 AM
Is it possible to create new factions programmatically (or is the best we can do to handmake .faction files and "reveal" them via setShowInIntelTab)?

Related: is the code for parsing .faction files available somewhere, or is it obfuscated? Took a quick look, but I might be missing it.

Edit: Might have answered my own question. Looks like the best way to do this might be to handmake a few .faction files to customize (with preset faction colors and a few other traits) and then use these methods on FactionAPI (I imagine this is how customizing the 'player' faction works)?

Code: java
	String getDisplayNameOverride();
void setDisplayNameOverride(String displayNameOverride);
String getDisplayNameWithArticleOverride();
void setDisplayNameWithArticleOverride(String displayNameWithArticleOverride);
String getDisplayIsOrAreOverride();
void setDisplayIsOrAreOverride(String displayIsOrAreOverride);
String getShipNamePrefixOverride();
void setShipNamePrefixOverride(String shipNamePrefixOverride);
String getPersonNamePrefixAOrAnOverride();
void setPersonNamePrefixAOrAnOverride(String personNamePrefixAOrAnOverride);
String getFactionLogoOverride();
void setFactionLogoOverride(String factionLogoOverride);
String getFactionCrestOverride();
void setFactionCrestOverride(String factionCrestOverride);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2018, 10:42:49 AM
Yep, sounds like you're on the right track.

The code for parsing faction files is in core, but... well, not really, since the parsing is just new JSONObject(<string with contents of file>), *except* it also has to be stripped of #-style comments first, since JSON doesn't support that.

The method do do that looks like this:

Code: java
	public static JSONObject createJsonObjectFromStringWithComments(String filename, String jsonString) throws IOException, JSONException {
try {
StringBuffer buf = new StringBuffer();
boolean inComment = false;
for (int i = 0; i < jsonString.length(); i++) {
char c = jsonString.charAt(i);
if (c == '\n' || c == '\r') {
inComment = false;
if (c == '\n') {
buf.append('\n');
}
continue;
} else if (c == '#') {
inComment = true;
continue;
} else if (!inComment) {
buf.append(c);
}
}

JSONObject json = new JSONObject(buf.toString());
return json;
} catch (JSONException e) {
String message = filename + "\n" + e.getMessage();
e = new JSONException(message);
throw e;
}
}

Note that filename is only passed in for error-throwing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on December 26, 2018, 01:44:00 PM
Is there a way to filter out the always-known industry specs from Global.getSettings().getAllIndustrySpecs()? The player faction's knowsIndustry() returns false for all industries (https://i.imgur.com/PMCyAf4.png) (note: spoilers in that image), including the ones you can build from the start.

If not, it's not a big deal. It only creates a minor cosmetic issue with the AllBlueprints console command.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2018, 02:17:17 PM
Hmm, I don't think there is. That information is only in the code for PlanetaryShield.isAvailableToBuild(), which checks if knownIndustries contains its id. Other industries may or may not (none of the vanilla ones do), but, yeah, this is all code and no data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on December 26, 2018, 07:13:19 PM
Are you sure you didn't accidentally modify anything else? Post your hellbore.wpn.

Spoiler
Unmodified one I've got:
Code: json
{
"id":"hellbore",  # this id must match what's in the spreadsheet
"specClass":"projectile",
"type":"BALLISTIC",
"size":"LARGE",
"displayArcRadius":600,
"turretSprite":"graphics/weapons/hellbore_cannon_turret_base.png",
"turretGunSprite":"graphics/weapons/hellbore_cannon_turret_recoil.png",
"hardpointSprite":"graphics/weapons/hellbore_cannon_hardpoint_base.png",
"hardpointGunSprite":"graphics/weapons/hellbore_cannon_hardpoint_recoil.png",
"visualRecoil":10.0,  # the gun sprites are only used if this is non-0
"renderHints":["RENDER_BARREL_BELOW"],
"turretOffsets":[35, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[50, 0],
"hardpointAngleOffsets":[0],
"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",
"muzzleFlashSpec":{"length":65.0,   # only used if animationType = MUZZLE_FLASH
   "spread":15.0,
   "particleSizeMin":10.0,
   "particleSizeRange":35.0,
   "particleDuration":0.75,
   "particleCount":50,
   "particleColor":[255,120,50,245]},
"projectileSpecId":"hellbore_shot",  # projectile that will be fired
"fireSoundTwo":"hellbore_fire",
}
[close]

Here is mine
Spoiler
{
   "id":"hellbore",  # this id must match what's in the spreadsheet
   "specClass":"projectile",
   "type":"BALLISTIC",
   "size":"LARGE",
   "displayArcRadius":600,
   "turretSprite":"graphics/weapons/hellbore_cannon_turret_base.png",
   "turretGunSprite":"graphics/weapons/hellbore_cannon_turret_recoil.png",
   "hardpointSprite":"graphics/weapons/hellbore_cannon_hardpoint_base.png",
   "hardpointGunSprite":"graphics/weapons/hellbore_cannon_hardpoint_recoil.png",   
   "visualRecoil":10.0,  # the gun sprites are only used if this is non-0
   "renderHints":["RENDER_BARREL_BELOW"],
   "turretOffsets":[35, 0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[50, 0],
   "hardpointAngleOffsets":[0],
   "barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
   "animationType":"MUZZLE_FLASH",
   "muzzleFlashSpec":{"length":65.0,   # only used if animationType = MUZZLE_FLASH
                  "spread":15.0,
                  "particleSizeMin":10.0,
                  "particleSizeRange":35.0,
                  "particleDuration":0.75,
                  "particleCount":50,
                  "particleColor":[255,120,50,245]},
   "projectileSpecId":"hellbore_shot",  # projectile that will be fired
   "fireSoundTwo":"Custom_hellbore_fire",
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 26, 2018, 10:10:24 PM
Ah, I think I understand the problem now.

This is a .wpn file in a mod (i.e. not modifying the vanilla one in starsector-core/), right? If so, my guess is that it merges with the vanilla file and duplicates the weapon offset values when doing so, thus the resulting weapon def has two (identical) barrels specified.

Delete everything in your .wpn file except fireSoundTwo, since that's the only value that was modified.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on December 27, 2018, 07:18:21 AM
Ah, I think I understand the problem now.

This is a .wpn file in a mod (i.e. not modifying the vanilla one in starsector-core/), right? If so, my guess is that it merges with the vanilla file and duplicates the weapon offset values when doing so, thus the resulting weapon def has two (identical) barrels specified.

Delete everything in your .wpn file except fireSoundTwo, since that's the only value that was modified.
Yep that fixed it. Thanks a lot!
I was under the assumption that it would replace the specified file entirely and not merge and if it did merge it would replace duplicate parameters instead of having 2 of them there with the same ID.
Does it always attempt to merge things like this? Asking for better understanding in case I plan to do more stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 31, 2018, 05:20:55 AM
Does it always attempt to merge things like this? Asking for better understanding in case I plan to do more stuff.
In 0.9 just about any vanilla .csv, .json, or other definition file that uses the JSON format should merge, yes.
(For mod configurations, it depends but I think the norm is also to merge)


Okay, got a problem with Nex invasions: How do I force the market to update its GROUND_DEFENSES_MOD StatBonus?

I'm having my NPC invasion fleet do a bombardment of the market with MarketCMD.doBombardment, then immediately running its invasion code. But no loss in defense strength occurs before and after the bombardment, even though the defense industries are disrupted when I check later.

Calling market.advance() or ListenerUtil.reportTacticalBombardmentFinished() immediately after the bombardment runs doesn't seem to help. Only actually opening the market interaction dialog or waiting a considerable amount of ingame time (apparently >0.5 days) makes it update.

Can also be seen with console:

Spoiler
Code: txt
runcode SectorEntityToken ent = Global.getSector().getStarSystem("Valhalla").getEntityById("skathi");
com.fs.starfarer.api.campaign.econ.MarketAPI market = ent.getMarket();
Console.showMessage("Old strength is " + market.getStats().getDynamic().getMod("ground_defenses_mod").computeEffective(0));
com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD cmd = new com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD(ent);
cmd.doBombardment(Global.getSector().getFaction("hegemony"), com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.BombardType.TACTICAL);
Console.showMessage("New strength is " + market.getStats().getDynamic().getMod("ground_defenses_mod").computeEffective(0));
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 31, 2018, 11:29:23 AM
Global.getSector().getEconomy().nextStep() ought to do the job, though, wait, you don't actually want to do that since it could take long enough that it's generally a UI-interaction-only thing, not a "stuff happening in the background" thing, if that makes sense.

How about:

market.reapplyConditions();
market.reapplyIndustries();

I think that should do it. Reapplying the conditions may not be strictly necessary in this case but I could see it be required for possible different implementations of specific industries or market-affecting actions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on January 01, 2019, 01:05:18 AM
Just popped up in a discussion on the Discord. We were wondering if there's any particular reason why the Light Machine Gun (and Dual version) projectiles use the BALLISTIC_AS_BEAM spawn type, when it seems most other ballistic weapons use straight BALLISTIC? ??? I thought BALLISTIC_AS_BEAM was reserved for pulse energy weapons (Pulse Laser, Heavy Blaster, etc.). Why do the light machine guns use it?

(Also if anyone wants to take this as an opportunity to explain the fundamental differences between the BALLISTIC and BALLISTIC_AS_BEAM projectile spawn types, that'd be much appreciated. :D )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2019, 10:46:42 AM
They're mostly interchangeable. The main difference - iirc - is BALLISTIC_AS_BEAM hit along the entire length, as opposed to specific bounds for BALLISTIC, which are something like (half of width x 2.5 times the width), with some adjustments to ensure no collision "skips" when the framerate is at 30.

 I think at some point there were going to be substantial differences (this is way back when collisions between projectiles were on the table), but that didn't work out well.

It's possible that BALLISTIC_AS_BEAM makes PD weapons marginally more effective, but I suspect the impact is very minor.

Oh, also, BALLISTIC_AS_BEAM supports a "textureType" parameter in the .proj  file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on January 01, 2019, 12:26:18 PM
Ah, awesome, thanks for clearing that up!  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on January 01, 2019, 08:01:31 PM
On an unrelated note.

WHY does the Shrike have a 0.7 efficiency shield!?? XD Like, I know the Conquest's 1.4 is an outlier to force it not to rely on its shield. But all other ships are from 0.6 to 1.2 in 0.2 steps. Where did this rogue 0.7 come from?  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2019, 08:07:02 PM
Because 0.6 was too good, and 0.8 as too bad :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on January 02, 2019, 01:33:12 AM
Dammit Alex.  :P Why you gotta always have a sensible answer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 03, 2019, 07:02:04 AM
I'm having trouble calling Global.getSector().getCampaignUI().showPlayerFactionConfigDialog() without getting an NPE:

Code
186967 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.ui.while.show(Unknown Source)
at com.fs.starfarer.ui.impl.float.show(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.showPlayerFactionConfigDialog(Unknown Source)
at exerelin.campaign.PlayerFactionSetupNag.advance(PlayerFactionSetupNag.java:49)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.while.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.float.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.LoadGameDialog.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.OoO0.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?00000(Unknown Source)
at com.fs.starfarer.ui.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
at com.fs.starfarer.ui.V.super(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

(tried from both a transient EveryFrameScript added on game load, and from onNewGameAfterTimePass())
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 03, 2019, 09:35:04 AM
Hmm, looking at the stack trace:
com.fs.starfarer.title.TitleScreenState.dialogDismissed

This is from onNewGameAfterTimePass(), right? That has no chance of working because the game's still in the "title (main menu) state" at that point, not the "campaign state". But calling it from an EFS should work provided it's out of the "title state" at that point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 05, 2019, 07:17:20 AM
Well slap me silly and call me a ***.
After god knows how log I got rid of all errors in my code...except one:
(https://i.postimg.cc/QVb91Lbb/Untitled.jpg) (https://postimg.cc/QVb91Lbb)


Now, factions are not defined in any.java file, but in a faction file and factions.cvs

What do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 05, 2019, 08:18:19 AM
Factions.BLA only works for vanilla factions.
For your case, write the faction ID there as a string, i.e. getFaction("my_faction_id");
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheWetFish on January 05, 2019, 09:05:41 PM
What is the status of loose plugins being automatically added from \data\scripts\plugins\ ?
Is it planned to go away at some point? Is there a list of plugins is does or doesn't work with?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 05, 2019, 09:28:30 PM
What is the status of loose plugins being automatically added from \data\scripts\plugins\ ?
Is it planned to go away at some point? Is there a list of plugins is does or doesn't work with?

I don't see a reason to remove it, so it will most likely stick around indefinitely for compatibility reasons. I don't think that there are any restrictions, at least, off the top of my head - it's just a different way to get combat plugins to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 06, 2019, 07:37:43 AM
Factions.BLA only works for vanilla factions.
For your case, write the faction ID there as a string, i.e. getFaction("my_faction_id");

That works, but now, after an entire day of testing, fixing, re-compiling again and again and again...I hit a brick wall.
I keep getting a null error when SS reaches 100% load, but the description tell me absolutely nothing.

Code
14731 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/ships/afflictor/afflictor_d_pirates.png (using cast)
14734 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/ships/RSF/rsf7-trn-carriage.png (using cast)
14745 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/ships/WIDOWS/wdw2-frg-retaliator.png (using cast)
14747 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/ships/XLE/xle1-f-cobra.png (using cast)
14748 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/ships/buffalo_dd.png (using cast)
14818 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/ships/wasp_ftr.png (using cast)
15330 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.scripts.ScriptStore.?00000(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.o00000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I am a the end of my wits.
Which is why I'm asking for help.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 06, 2019, 09:42:03 PM
I'm currently trying to write a console command to help track down some common JSON errors. Is there a way to tell which mod is responsible for each element in a merged JSON? For example with CSVs we can check the undocumented fs_rowSource column, but I couldn't find an equivalent for loaded JSON data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 06, 2019, 09:49:48 PM
@TrashMan - I *think* this may be due to an issue with "coreLifecyclePlugin" in settings.json - possibly it's pointing to something that doesn't compile, or some such.


I'm currently trying to write a console command to help track down some common JSON errors. Is there a way to tell which mod is responsible for each element in a merged JSON? For example with CSVs we can check the undocumented fs_rowSource column, but I couldn't find an equivalent for loaded JSON data.

There's nothing like that, no, since for JSON it's not as clear-cut and essentially the loader would have track every bit of data separately, where for CSVs there's just naturally a row - that's going to come from a single mod - to stick the source into.

I've been trying to make the common(er) errors throw more descriptive exceptions - usually, when the exception is an unclear one, it's because the code was not expecting the game to crash in that particular way. If there are some common ones you're aware of that are particular headaches, I'd love to fix them up.

(Speaking of that, let me make the one TrashMan just run into throw something more sensible...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 06, 2019, 09:55:47 PM
The error I've seen a few different times lately is when a mod overwrites a faction's knownX entry with an empty array, which causes a crash when the fleet is inflated. Actually most of these crashes have been due to empty arrays - I could probably just check for that and warn when they're found. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 06, 2019, 10:00:04 PM
Oh, hmm - so an empty set of weapons or fighter wings causes a crash? That seems a bit unexpected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 06, 2019, 10:08:28 PM
Ah, you're right. I was mixing up two different bugs. The inflator crashes were due to a mod adding an ID that didn't exist.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 06, 2019, 10:23:18 PM
Ok, cool - I actually just added more descriptive exception messages for this that should include the wing or weapon id.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 07, 2019, 05:44:05 AM
I'm currently trying to write a console command to help track down some common JSON errors. Is there a way to tell which mod is responsible for each element in a merged JSON? For example with CSVs we can check the undocumented fs_rowSource column, but I couldn't find an equivalent for loaded JSON data.

For testing I'm only using LazyLib and MagicLib, no other mods, so I don't think any other mod could interfere.

@TrashMan - I *think* this may be due to an issue with "coreLifecyclePlugin" in settings.json - possibly it's pointing to something that doesn't compile, or some such.


Hmm..
I don't have anything like that in my settings. Here's the entire mod with all the files if anyone can take a look:

https://drive.google.com/file/d/14HqZCuLBdd-ZRXVyGKujNVoOVvIMNO__/view?usp=sharing


On this location is the entire mod - all the files. It is pretty much done (the only thing missing is the code for AI and Alien fleets)

EDIT:
the settings file is missing the plugins block (tested with and without it, no difference)


Code
    "plugins":{
        "AnimatedGlow":"data.scripts.plugins.AnimatedGlow",
        "AnimatedVents":"data.scripts.plugins.AnimatedVents",
        "RotatingDish":"data.scripts.plugins.RotatingDish",
        "RotatingDishArc":"data.scripts.plugins.RotatingDishArc",
        "EMPEffect":"data.scripts.plugins.EMPEffect",
        "EMPBeamEffect":"data.scripts.plugins.EMPBeamEffect",
        "Shrapnel408mm":"data.scripts.plugins.Shrapnel408mm",
    },

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 07, 2019, 06:14:09 AM
I think that error is from compiling for wrong Java version.
Right click on project in top-left pane -> Properties -> set Source/Binary Format to JDK 7
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 07, 2019, 09:29:55 PM
I am going to post part of this here because it may be kind of minor, but I had originally put it in its own thread so it could be more searchable since it is important for the campaign.

I am curious about the relationship between hull and weapon.csv tags (such as midline_bp/pirate_bp) and the packages that unlock their blueprints. How are those items under each tag distributed between packages and single hull/weapon blueprints in salvage? Are there any code examples of this?

Do only research stations give packages, for instance? How common are entire packages vs single blueprints?

So, do I have to implement all weapons under base_bp, rare_bp, lowtech_bp, midline_bp, hightech_bp, etc.. for them to show up in salvage and the tech-related packages? Or can I make custom tags and packages spawn in salvage (without scripts)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 10, 2019, 09:18:03 PM
I have variants listed in the variantOverrides section of the faction file and they still sometimes seem to autofit randomly in weird places... usually, but not always, medium and large weapon slots. This is especially true for capitals (maybe because they have the most weapons?). I also have the random autofitRandomizeProbability set to 0.0.

Anything that would cause this? They should have access to all the necessary weapons. Or is this a bug?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 10, 2019, 09:28:41 PM
variantOverrides does not mean that the variant will be used as-is, there's still a high probability of deviating from the goal variant. Even if all weapons are available, some may not be "available" for the given attempt to fit the ship; especially high-tier weapons are not always used even if the faction has access to them.

autofitRandomizeProbability is the chance that the goal variant will be only loosely adhered to, not that the fit will be randomized at all.

So, hmm, it kind of sounds like everything is working as expected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 10, 2019, 09:30:24 PM
variantOverrides does not mean that the variant will be used as-is, there's still a high probability of deviating from the goal variant. Even if all weapons are available, some may not be "available" for the given attempt to fit the ship; especially high-tier weapons are not always used even if the faction has access to them.

autofitRandomizeProbability is the chance that the goal variant will be only loosely adhered to, not that the fit will be randomized at all.

So, hmm, it kind of sounds like everything is working as expected.

Any way to disable it, then? Not what I'm going for at all. Random all the time is bad for my mod in many situations.

*Edit* I would even be fine with just being able to explicitly exclude certain weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 10, 2019, 09:36:31 PM
A couple of options:

if (fleet.getInflater() instanceof DefaultFleetInflater) {
   DefaultFleetInflater dfi = (DefaultFleetInflater) fleet.getInflater();
   ((DefaultFleetInflaterParams)dfi.getParams()).allWeapons = true;
}

This would make all weapons and fighters available, but there could still be some variance in hullmods and capacitors.


fleet.setInflater(null);

That should make all variants in the fleet the unchanged goal variant for each ship, I believe.


And, finally: a "no_autofit" tag in ship_data.csv; will make that hull not get auto-fitted and always just use the goal variant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 10, 2019, 09:43:02 PM
A couple of options:

if (fleet.getInflater() instanceof DefaultFleetInflater) {
   DefaultFleetInflater dfi = (DefaultFleetInflater) fleet.getInflater();
   ((DefaultFleetInflaterParams)dfi.getParams()).allWeapons = true;
}

This would make all weapons and fighters available, but there could still be some variance in hullmods and capacitors.


fleet.setInflater(null);

That should make all variants in the fleet the unchanged goal variant for each ship, I believe.


And, finally: a "no_autofit" tag in ship_data.csv; will make that hull not get auto-fitted and always just use the goal variant.

Ah great!

Does the "no_autofit" tag happen to inhibit the player's autofit options as well, such as the case where they don't have the necessary weapons in their market/holds? Or is it specific to faction patrols?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 10, 2019, 09:45:35 PM
It just affects DefaultFleetInflater, so, limited to fleets that use that. Which in vanilla is every fleet except for the player's, and zero impact in the refit screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 11, 2019, 04:39:03 AM
Is there a way to get origin of a commodity on market X (local production/same faction import/foreign import)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 11, 2019, 09:17:21 AM
Yep!

CommodityOnMarketAPI.getCommodityMarketData().getMarketShareData(market).getSource()

Returns a CommoditySourceType.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 12, 2019, 05:44:45 AM
I think that error is from compiling for wrong Java version.
Right click on project in top-left pane -> Properties -> set Source/Binary Format to JDK 7

Nope, still the same error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on January 12, 2019, 02:06:45 PM
Hello!
I've created a medium energy PDS based on 3 mining beams. However, the beams are always "off" when shooting at missile by a few pixels to the right of the screen. The beams are continuous, not in burst mode.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 12, 2019, 02:39:36 PM
Can you make sure the first barrel is in the middle of the sprite? IIRC (without checking) it might aim using the first barrel, so if that's the left or right barrel, that could be a problem. Also make sure the angle offset is 0...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on January 12, 2019, 03:16:09 PM
It's was indeed a barrel location problem... I would never have been able to figure it out. Thank you for your help and your quick answer (especially during week end!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 13, 2019, 08:50:25 AM
So, I've been working on a minimod that changes what the Planetary Shield does.

My first implementation, I made a new data.scripts.PlanetaryShield, and changed industries.csv to refer to the new class.

This... technically worked, but ran into some problems, because it turns out that the save file, in several places, refers to industries by their class name rather than their id.  Specifically, any planetary shield generators that were built or under construction when you enabled the mod would retain the old behavior, and, if you wanted to disable the mod, you had to scrap all of the new shield generators... and then wait two months or the save would crash on load because their class was being stored in the monthly planetary expenses report.

This seems like it's a bug, but it's a fairly esoteric one, and who knows, maybe there's some actual reason why it's important to store the class name.

So, try number two: see if I could overwrite com.fs.starfarer.api.impl.campaign.econ.impl.PlanetaryShield - even using a built jar file, this doesn't work; starsector continues to use its own copy of the PlanetaryShield class rather than the new one.

Before I move on to try number three, where I build code that will, on mod-add, iterate through every market to remove and re-create any existing planetary shields, I have to ask: Can anyone come up with a better way of doing this?  Because that won't solve the on-mod-remove issues, and I'd really like for this to be a straightforward add mod, get new behavior, remove mod, get old behavior, sort of thing, without any gotchas going in either direction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 13, 2019, 10:48:06 AM
It's not so much that it's referring to it by class name, but that it needs to store data for each industry (construction state, AI cores, etc), which means the object for each industry gets written out to the savefile. The data an object has is class-dependent, hence the class being specified there.

Getting a mod that changes industry classes to be save-compatible in both directions is going to be a lot of trouble. I'm not sure it's possible, actually. Depending on what you want to do, it *may* be possible to add a transient script instead that implements EconomyUpdateListener and do your work in economyUpdated(), basically overriding whatever the default PlanetaryShield class does.

This wouldn't work if it changed supply/demand (since that would happen too late to be considered by the economy), but should for example work if you were changing something like the shield visuals or defensive stats.

So, try number two: see if I could overwrite com.fs.starfarer.api.impl.campaign.econ.impl.PlanetaryShield - even using a built jar file, this doesn't work; starsector continues to use its own copy of the PlanetaryShield class rather than the new one.

Right, yeah - classes with the same package plus name generally isn't a good idea, since it depends on the order of the jar files in the classpath, and I'm not sure how it interacts with the custom classloader used for scripts. Even if it worked, it'd be the sort of thing you really wouldn't want to rely on as it might be inconsistent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 13, 2019, 11:21:19 AM
Getting a mod that changes industry classes to be save-compatible in both directions is going to be a lot of trouble. I'm not sure it's possible, actually. Depending on what you want to do, it *may* be possible to add a transient script instead that implements EconomyUpdateListener and do your work in economyUpdated(), basically overriding whatever the default PlanetaryShield class does.

This wouldn't work if it changed supply/demand (since that would happen too late to be considered by the economy), but should for example work if you were changing something like the shield visuals or defensive stats.
While I'm not directly changing the supply/demand of the shield generator, I am adding a population growth penalty, accessibility penalty, and pather interest changes, so this doesn't sound like it'd work for me.

So, try number two: see if I could overwrite com.fs.starfarer.api.impl.campaign.econ.impl.PlanetaryShield - even using a built jar file, this doesn't work; starsector continues to use its own copy of the PlanetaryShield class rather than the new one.

Right, yeah - classes with the same package plus name generally isn't a good idea, since it depends on the order of the jar files in the classpath, and I'm not sure how it interacts with the custom classloader used for scripts. Even if it worked, it'd be the sort of thing you really wouldn't want to rely on as it might be inconsistent.
I was hoping that Starsector's classloader would have a set order & put mods first.  It seemed worth trying.

Sounds like providing special code for on-mod-install is the best option, then.  Unless... hm... maybe I can do something with beforeGameSave and afterGameSave?  Swapping things around every save would be -ridiculous-, but it might also work.  Maybe.  If I can get at the internals of those monthly reports.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 13, 2019, 02:17:35 PM
While I'm not directly changing the supply/demand of the shield generator, I am adding a population growth penalty, accessibility penalty, and pather interest changes, so this doesn't sound like it'd work for me.

For accessibility, you could use a hidden market condition, since that'd apply at the right time. For population growth, you could do market.addTransientImmigrationModifier(MarketImmigrationModifier mod) - that doesn't have to come from an industry, it could just be a separate class.

For Pather interest, you'd be sol - that does have to come from industry.

Sounds like providing special code for on-mod-install is the best option, then.  Unless... hm... maybe I can do something with beforeGameSave and afterGameSave?  Swapping things around every save would be -ridiculous-, but it might also work.  Maybe.  If I can get at the internals of those monthly reports.

For adding it, sure, yeah.

For removing it, there's no way to really do it safely. The monthly report is just one of many possible places that could be hanging on to an industry reference - it could be a piece of intel, some other script, etc. You'd have to account for every possible piece of code that might do that, both in vanilla and in mods, and - while that's already highly impractical - some might also be impossible to modify on the fly like that.

Removing a piece of content like that is basically a no-go in general, just too many things could be referring to it. Adding one to an existing game is much more doable, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on January 15, 2019, 05:09:47 AM
I made a music mod for the game. The issue I have is that every time my fleet flys near a system, the in system music starts to play, constantly switching tracks from the hyperspace music.
Is there a way to make it so that in star system music plays only when you are actually inside the star system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 15, 2019, 06:50:42 PM
What's the best method to modify fleet's MutableFleetStatsAPI in a hullmod?
I am thinking about 2 ways:
onFleetSync in HullModFleetEffect
check fleet each frame in EveryFrameEffect
Which is better?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2019, 07:29:17 PM
Is there a way to make it so that in star system music plays only when you are actually inside the star system?

Nothing simple, iirc you'd have to basically take over music playing with custom code entirely.


What's the best method to modify fleet's MutableFleetStatsAPI in a hullmod?
I am thinking about 2 ways:
onFleetSync in HullModFleetEffect
check fleet each frame in EveryFrameEffect
Which is better?

And EveryFrameScript attached to the fleet may be better for performance; you'd just have to be careful how you do it.

Could also do it in HullModEffect.advanceInCampaign() - per the javadoc, it'll be called with amount = 0 when the fleet is being re-synched.

Either way, it's something to be careful with as far as performance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 15, 2019, 08:09:46 PM
Could also do it in HullModEffect.advanceInCampaign() - per the javadoc, it'll be called with amount = 0 when the fleet is being re-synched.
If I remove the hullmod, would advanceInCampaign() be called?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2019, 08:25:13 PM
No, it would not.

There's basically not a great mechanism for doing this in the game. If there's any alternate design approach, I would recommend taking it instead, of perhaps restricting the impact of the hullmod to the player's fleet only, which should make it perform better.

Given when variant generation kicks in for AI fleets (i.e. when the player mouses over their fleet, or interacts with it), it probably doesn't make too much sense for hullmod effects to apply to AI fleets anyway, as it'd be inconsistent. For example, if the goal variant has it, but the autofit variant doesn't, or vice versa, then whether the fleet gets the effect or not would depend on the player mousing over it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 15, 2019, 09:57:41 PM
There's basically not a great mechanism for doing this in the game. If there's any alternate design approach, I would recommend taking it instead, of perhaps restricting the impact of the hullmod to the player's fleet only, which should make it perform better.
well I do want to restrict the impact only to the player's fleet.
So i could do this: in an every frame script, I check the fleet members and their hullmods, if there are some, do something, else unmodify?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on January 16, 2019, 06:15:15 AM
Is there a way to make it so that in star system music plays only when you are actually inside the star system?
Nothing simple, iirc you'd have to basically take over music playing with custom code entirely.
Well fug. That's a bit more than I am willing to do.
Why is the system as it is right now, anyway?
I realize most people don't have custom music mods but it's rather annoying when I am flying by a star system on my way across the galaxy and the music fades away from the hyperspace track that's playing, into a in-star-system track for 3 seconds then fades back into the hyper space one. This happens repeatedly while passing star systems on my way to the destination. As you imagine it's some what annoying.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 16, 2019, 09:41:00 PM
well I do want to restrict the impact only to the player's fleet.
So i could do this: in an every frame script, I check the fleet members and their hullmods, if there are some, do something, else unmodify?

Yeah, this makes sense.

Why is the system as it is right now, anyway?
I realize most people don't have custom music mods but it's rather annoying when I am flying by a star system on my way across the galaxy and the music fades away from the hyperspace track that's playing, into a in-star-system track for 3 seconds then fades back into the hyper space one. This happens repeatedly while passing star systems on my way to the destination. As you imagine it's some what annoying.

I'll probably take a look at this at some point if there's time; there are reasons but they may or may not hold up. A bit off-topic for this thread, though :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 20, 2019, 09:58:08 AM
How to get damagetype by weaponspec?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 20, 2019, 10:01:34 AM
How to get damagetype by weaponspec?

Oh, oops - the method wasn't in the API. Added DamageType getDamageType() to WeaponSpecAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 20, 2019, 07:16:42 PM
So if I add stations in Industries.csv by pointing that entry to a new variant, then add the necessary path to econ\\aztlan.json in the replace array of mod_info, and put the new industry id for the new station in the replaced file, shouldn't it show up in the campaign?

It doesn't seem to replace the station at all.

Currently uploading an example mod to link. Should be done in an hour or so.

https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0 (https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0)

*Edit*

So I replace the Aztlan stations with custom Hegemony skinned variants in the example mod, and though in dev mode they show up in the variant editor just fine, the markets in Aztlan spawn the same stations they normally do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 20, 2019, 08:14:02 PM
Oh, oops - the method wasn't in the API. Added DamageType getDamageType() to WeaponSpecAPI.
... :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 20, 2019, 09:13:21 PM
So if I add stations in Industries.csv by pointing that entry to a new variant, then add the necessary path to econ\\aztlan.json in the replace array of mod_info, and put the new industry id for the new station in the replaced file, shouldn't it show up in the campaign?

It doesn't seem to replace the station at all.

Currently uploading an example mod to link. Should be done in an hour or so.

https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0 (https://www.dropbox.com/sh/x4e2o82j21b3dpk/AAB58nMhE8qpmSPJi0UUC6C8a?dl=0)

*Edit*

So I replace the Aztlan stations with custom Hegemony skinned variants in the example mod, and though in dev mode they show up in the variant editor just fine, the markets in Aztlan spawn the same stations they normally do.

Took a look! It works on my end due to the related fixes for how the "replace" section works. I think if you change it from \\aztlan.json to /aztlan.json it'll work on your end as well.

Oh, oops - the method wasn't in the API. Added DamageType getDamageType() to WeaponSpecAPI.
... :-\

Apologies :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 21, 2019, 12:20:06 AM

Took a look! It works on my end due to the related fixes for how the "replace" section works. I think if you change it from \\aztlan.json to /aztlan.json it'll work on your end as well.


Yes that does work. To be specific, the rest of the path must still be delimited by "\\" but after "econ" it changes to "/" and that replaces the file.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: manictiger on January 21, 2019, 09:16:15 AM
I'm at my wits end with this thing.  I'm trying to add a third weapon to my mod.  The first two were relatively straightforward, but this one-- I've tried everything, from reordering the names in alphabetical, to disabling the textured beam, etc.  Currently, this thing's almost a direct clone of the tactical laser and it still won't work.

Error:
Spoiler
6942 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: JSONArray[3] not found.
org.json.JSONException: JSONArray[3] not found.
   at org.json.JSONArray.get(JSONArray.java:204)
   at org.json.JSONArray.getInt(JSONArray.java:265)
   at com.fs.starfarer.loading.D.Ö00000(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.while(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Suspected file:
Spoiler
{
   "specClass":"beam",
   "id":"altca_electroplas",
   "type":"ENERGY",
   "size":"SMALL",
   #"collisionClass":"RAY",
   #"collisionClassByFighter":"RAY_FIGHTER",
   "turretSprite":"graphics/weapons/altca_electroplas_turret_base.png",
   "turretGlowSprite":"graphics/weapons/altca_electroplas_turret_glow.png",
   "hardpointSprite":"graphics/weapons/altca_electroplas_hardpoint_base.png",
   "hardpointGlowSprite":"graphics/weapons/altca_electroplas_hardpoint_glow.png",
   "turretOffsets":[15,0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[15,0],
   "hardpointAngleOffsets":[0],
   "fringeColor":[0,255,191,105],
   "coreColor":[0,255,255],
   "glowColor":[0,255,191,105],
   #"fringeColor":[128,0,255,105],
   #"coreColor":[191,0,25,155],
   #"glowColor":[191,0,255,105],
   #"darkCore":false,
   "width":13.0,
   "textureType":ROUGH,
   #"textureType":["graphics/fx/altca_electroplas_shell.png","graphics/fx/altca_electroplas_shell_fringe.png"],
   "textureScrollSpeed":72.0,
   "pixelsPerTexel":5.0,
   #"animationType":"GLOW_AND_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE
   #"muzzleFlashSpec":{"length":54.0,   # only used if animationType = MUZZLE_FLASH
   #               "spread":20.0,
   #               "particleSizeMin":18.0,
   #               "particleSizeRange":24.0,
   #               "particleDuration":0.12,
   #               "particleCount":32,
   #               "particleColor":[64, 0, 255,215]},
   "pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF],
   "fireSoundOne":"altca_electroplas_fire",
   "fireSoundTwo":"altca_laser_loop",
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 21, 2019, 09:57:45 AM
"coreColor":[0,255,255],

Probably needs a 4th element there for the alpha.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: manictiger on January 21, 2019, 10:26:21 AM
"coreColor":[0,255,255],

Probably needs a 4th element there for the alpha.

Thanks.  That solved it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 21, 2019, 06:01:44 PM
What controls whether a bar event sticks around after the player interacts with it? For example, you can refuse the commodity delivery quest and the issuer will still be there in case you change your mind.

As far as I can tell my bar event code isn't doing anything differently, but leaving the conversation will remove the person from the bar list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 21, 2019, 06:17:13 PM
Calling this:

BarEventManager.getInstance().notifyWasInteractedWith(barEvent);

Will remove it from the list. It's "interacted" in the sense of "partook in what it has to offer" rather than just "took a look and backed out" sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on January 21, 2019, 06:55:50 PM
Calling this:

BarEventManager.getInstance().notifyWasInteractedWith(barEvent);

Will remove it from the list. It's "interacted" in the sense of "partook in what it has to offer" rather than just "took a look and backed out" sense.

Ah, whoops. I did have a stray call to that method in the wrong dialog branch. At least it was something simple. :)

Just to double check: the BarEvent script instance will persist until it expires, right? I don't need to keep track of the person or quest flags in sector memory if they won't extend past this one event?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 21, 2019, 07:27:18 PM
Yep, correct. It is however possible for the same BarEvent to be shown at another market, depending on how it's coded.

BaseBarEvent's shouldShowAtMarket(MarketAPI market) method makes it not do that, but in some cases it could be desirable.


The BaseGetCommodityBarEvent class has a regen() method that it calls to reinstantiate whatever it might need to in case the market changed, although I don't think it actually needs to - but there may be a subclass I'm not thinking of where it may indeed change markets.

Basically, the bar events are not inherently tied to a market, rather they decide whether they want to be shown at the current market the player is interacting with. I think all/most vanilla events - in addition to their custom market checks - also check "and was not previously shown at another market".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 23, 2019, 01:10:14 PM
When I make a subfaction of a faction like the lion guard or knights of ludd, I know I can distinguish their fleets through full control of doctrine like the lion guard does, or make changes to things like portraits or music and ignore composition.

1) What determines where and when the subfaction is spawned? Do I need to set the subfaction id on the market?

2) How are the two factions linked? Or are they? If I only override one fleetType, say "patrolLarge", will the other fleet types spawn normally? Or just that one type on that market if it has the "patrolhq" industry?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2019, 01:12:46 PM
See: com.fs.starfarer.api.impl.campaign.econ.impl.LionsGuardHQ

The game has no concept of a "subfaction". So, for example for the Lion's Guard fleets, they're spawned using Factions.LIONS_GUARD in the fleet params - so they use the proper doctrine and so on - and then the fleet faction is set to the Diktat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Noomsy on January 23, 2019, 03:14:07 PM
So i searched through here, but only found some old posts about this....

Does anyone know how I go about adding fuel/cargo etc to a new start?

Im am dorking around with a mod/faction geared to start exploring and colonizing from day 1
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 24, 2019, 06:59:02 PM
@Noomsy

I imagine you'd have something like

Code
YourModNameLifecyclePlugin.java

class YourModNameLifecyclePlugin extends BaseModPlugin {
  @Override
  void onNewGateAftertimePass() {
    Global.getSector().getPlayerFleet().getCargo().addX;
  }
}

And then in your mod_info.json, remember to add `"modPlugin":"com.you.YourModNameLifecyclePlugin"`
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 24, 2019, 07:27:12 PM
Two questions. I accidentally wrote a book below...

1.

- I create an Intel at `com.wispborne.mod.MyIntel` and release my awesome mod.
- Time passes. People use the mod and save games with it. I am very proud.
- I realize that my package organization or naming is bad and I want to move `MyIntel` to a different package or rename it.

Is there a way to do that without breaking savegame compatibility? I mean, other than leaving MyIntel there and delegating to the new class (lol).

For example, with Gson, you can use an attribute `@NamedParameter("prefix_MyIntel")`, which tells the serializer how to refer to it, thus allowing you to decouple your implementation from the serializer contract.
I saw that XStream has `@XStreamAlias`, but it doesn't seem to do anything (presumably `xstream.autodetectAnnotations(true);` is present). Any other solutions?


2. This one is even more unlikely, but imo important, and presumably (also?) something that you, Alex, have thought about.

The API docs are ...sparse. I'm glad that modding is supported and that the API docs exist of course (and note that I'm only a 1-month veteran of Starsector), buuuuut it seems clear that working on the game is prioritized over adding to the API docs. By far, most of my time is spent trying to figure out how to do "simple" things, like bar events and intel, rather than creating exciting content. The best documentation I've found so far has been simply reading the unobfuscated classes, such as `PlanetaryShieldBarEvent`, and even then it's pretty hard to follow what classes are using that class, etc, since none of those files are indexed.
So that was a lot of complaining, which wasn't really the intent, but rather I wanted to stress that we could be generating way more really cool content much faster with better documentation.

And the question: how can we help?
You guys should keep working on what you enjoy. You're probably not gonna hire a technical writer just to update API docs. So is there a way that we as a community can contribute to the API docs? The SS modding wiki is, well, it's okay, and maybe that's the answer, but authoring an article is much more daunting than adding `BaseModPlugin: Inherit from this class to tie into the lifecycle of the game. Add the implementing class, with package, to mod_info.json`, as an example. And, I would argue, having good javadocs is more important than having a bunch of modding articles, because there are many ways of accomplishing a task and it'll be very difficult for the wiki to cover enough use cases, whereas javadocs can describe pieces in isolation. Ideally, both are great and complement each other, but again...authoring is more daunting.

Sorry for the essays! I tried to search to see if there were answers already but it's quite possible I missed things. Awesome game, I've already hooked a friend on it as well (he's on his second playthrough and blames me for sabotaging his ability to wake up early in the mornings).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2019, 07:58:54 PM
- I realize that my package organization or naming is bad and I want to move `MyIntel` to a different package or rename it.

Is there a way to do that without breaking savegame compatibility? I mean, other than leaving MyIntel there and delegating to the new class (lol).

Yep, I think so - see the configureXStream(XStream x) method in the ModPlugin interface, and its vanilla implementation in CoreLifecyclePluginImpl. You should be able to alias your MyIntel class to a name that's independent of the package and/or class name.


The best documentation I've found so far has been simply reading the unobfuscated classes, such as `PlanetaryShieldBarEvent`, and even then it's pretty hard to follow what classes are using that class, etc, since none of those files are indexed.

Yeah, taking a simpler core implementation of something and then working from that is definitely the way to go.

Could you expand on the bolded part? Is it just where it refers to/is used by core stuff that's not in the API, or do you mean something else?  For PlanetaryShieldBarEvent, "show references" (not sure what the equivalent is in Netbeans etc) shows where it's used, which I think is overall comparatively easy to follow - so I feel like I'm perhaps missing something.


And the question: how can we help?
You guys should keep working on what you enjoy. You're probably not gonna hire a technical writer just to update API docs. So is there a way that we as a community can contribute to the API docs? The SS modding wiki is, well, it's okay, and maybe that's the answer, but authoring an article is much more daunting than adding `BaseModPlugin: Inherit from this class to tie into the lifecycle of the game. Add the implementing class, with package, to mod_info.json`, as an example. And, I would argue, having good javadocs is more important than having a bunch of modding articles, because there are many ways of accomplishing a task and it'll be very difficult for the wiki to cover enough use cases, whereas javadocs can describe pieces in isolation. Ideally, both are great and complement each other, but again...authoring is more daunting.

I appreciate the thought!

Yeah, writing javadoc is just down to "when I have time" and the answer is basically "pretty much never" so it ends up being limited to things where I thought it was really, really necessary. There's no structure in place for the community to write javadoc; not sure how that'd work, really - the wiki indeed seems like the place for that.

Sorry for the essays! I tried to search to see if there were answers already but it's quite possible I missed things. Awesome game, I've already hooked a friend on it as well (he's on his second playthrough and blames me for sabotaging his ability to wake up early in the mornings).

Thank you! :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 24, 2019, 08:23:38 PM
> configureXStream(XStream x)

Oh wow, that's exactly what I was looking for. Thanks!

> since none of those files are indexed

This may be a "me" problem, and by "me" I mean "IntelliJ".

If I do a "find references" on `configureXStream` in IntelliJ, it only finds things from my own codebase, not vanilla's, because it only indexes and search my own project files.

Since we just have a jarfile of the SS api -
...
oh. I just opened up `starfarer.api.zip` for the first time. Wow.
Ok, I added that unzipped content to IntelliJ as a source and now when I "Find Usages", it finds all the usages in the vanilla files, too. That, too, is exactly what I wanted. Entirely my bad.


The only reasonable approach I could see to a community-driven javadoc would be throwing the contents of `starfarer.api.zip` (probably with the method contents removed) up on github, and accepting PRs that add to the docs.
But then that leaves you with the job of merging that into your working copy, which surely has plenty of changes from the "stable" version we're all on. And there's the question of whether people would contribute at all.
Anyway, that's all I've got for now. Thanks a bunch for the help. I try to pay it forward over on Discord whenever I'm able.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2019, 08:28:18 PM
oh. I just opened up `starfarer.api.zip` for the first time. Wow.
Ok, I added that unzipped content to IntelliJ as a source and now when I "Find Usages", it finds all the usages in the vanilla files, too. That, too, is exactly what I wanted. Entirely my bad.

Ah, excellent! Yeah, I can see how it would be a bit rough having a go at it without the api source :)


The only reasonable approach I could see to a community-driven javadoc would be throwing the contents of `starfarer.api.zip` (probably with the method contents removed) up on github, and accepting PRs that add to the docs.
But then that leaves you with the job of merging that into your working copy, which surely has plenty of changes from the "stable" version we're all on.

Yeah - it seems like it'd be fairly laborious process, unfortunately.

Anyway, that's all I've got for now. Thanks a bunch for the help. I try to pay it forward over on Discord whenever I'm able.

Glad to help! Feel free to ask more questions as things come up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 25, 2019, 12:26:03 AM
How drop data works? DropValue and DropRandom? how do they works ???
If I want a fleet drop 0~4 amount of commodity"XXX", how to add them?

And how to make fleets defend one place and ignore the hostile fleets which is far from them?(In a starsystem, there are 2 factions which is hostile to each other, the place defended is far from each other too)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 25, 2019, 09:35:23 AM
How drop data works? DropValue and DropRandom? how do they works ???
If I want a fleet drop 0~4 amount of commodity"XXX", how to add them?

DropValue will always drop some commodities from the specified group with a value equal to the number specified in the drop data with some variance (iirc +-50%).

DropRandom will have X chances to drop something from the group. If the group has a "nothing" entry, each chance may result in nothing being dropped.

For example, if you open up salvage_entity_gen_data.csv, you'll see something like this in the drop_value column:

basic:5000

This means to pick 5000 credits (+-50%) worth of stuff from the "basic" group, which is defined in drop_groups.csv.

Looking at that, we see:
metals   basic   20
heavy_machinery   basic   1
supplies   basic   10
fuel   basic   10

The number is the probability of each commodity being picked, so roughly the ratio of the commodities produced will match the ratio of these numbers.

You'll also see something like this in the drop_random column:

ai_cores2:3

This means "roll 3 times from the ai_cores2 group".

Looking at that one, we see:
nothing   ai_cores2   100
beta_core   ai_cores2   2
gamma_core   ai_cores2   5

So each roll will produce nothing with a probability of 100/107, a beta core (2/107), or a gamma core (5/107).

You might also see something like this in the drop_random column:
extended:3x3000

This means "roll 3 times from the extended drop group, and each time produce 3000 credits worth of items". This is useful for example if you want to have it drop some commodities from a list, but instead of a distribution of a little bit of everything, you want to pick a couple to focus on. For example, the group might have 20 commodities, and if rolled twice, it'll pick out two and drop a bunch of those.

DropGroups can also be set up using code - I think TechMining.generateCargoForGatheringPoint() is a decent piece of code to look at for how that works. There, it directly passes the DropData it creates o SalvageEntity.generateSalvage(), but you could also add it to a fleet using fleet.addDropRandom(DropData) (or, indeed, addDropRandom(String id, int chances) and so on.

When it comes to dropping weapons/blueprints/etc, it gets more complicated with special json syntax in place of a commodity id.


So, right, if you want a fleet to drop 0-4 of commodityXXX, you would:

1) add a drop group to drop_data.csv. Let's name it "testDrop".
nothing testDrop 50
commodityXXX testDrop 50

2) Call: fleet.addDropRandom("testDrop", 4)

Note that this would give 4 50/50 chances to drop one commodityXXX, so while you'd get 0 to 4 of them, it would not be an even probability distribution.


Hope this answers your question! Let me know if you'd like me to clarify something.


And how to make fleets defend one place and ignore the hostile fleets which is far from them?(In a starsystem, there are 2 factions which is hostile to each other, the place defended is far from each other too)

You would need to give them a custom assignment AI, for example like this one:

com.fs.starfarer.api.impl.campaign.tutorial.TutorialLeashAssignmentAI

How to do that depends on how the fleets are created.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 25, 2019, 05:46:14 PM
Hope this answers your question! Let me know if you'd like me to clarify something.
Wow. It's a detailed answer, thanks very much! And if I can just use dropdata.addCommodity to custom it not in the csv but in the script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 25, 2019, 06:01:39 PM
And if I can just use dropdata.addCommodity to custom it not in the csv but in the script?

Yep, you can do that too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 26, 2019, 09:16:49 AM
how to make a fleetmember only has 10% possible to recover?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2019, 09:29:52 AM
There's no easy way to do exactly that since it's based on the baseShipRecoveryChance (from settings.json), on the per-ship chance (that's modified by hullmods such as ReinforcedBulkheads), and on fleet commander skills.

For example, if you were to:
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyMult(id, 0.1f);

That would still get modified by the player skill recovery chance by *adding* to the chance of recovery, so it wouldn't be 10x less.


About the only thing that comes to mind is to have a ship with the UNBOARDABLE hint, then have a simple skin that does "removeHints":[UNBOARDABLE], and have the skin be 9 times less likely to be used than the base hull, using the shipRoles weights.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 26, 2019, 09:47:55 AM
There's no easy way to do exactly that since it's based on the baseShipRecoveryChance (from settings.json), on the per-ship chance (that's modified by hullmods such as ReinforcedBulkheads), and on fleet commander skills.

For example, if you were to:
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyMult(id, 0.1f);

That would still get modified by the player skill recovery chance by *adding* to the chance of recovery, so it wouldn't be 10x less.


About the only thing that comes to mind is to have a ship with the UNBOARDABLE hint, then have a simple skin that does "removeHints":[UNBOARDABLE], and have the skin be 9 times less likely to be used than the base hull, using the shipRoles weights.

It reminds me that, could I just add different sprites in one hull? I mean, make a ship can have random skins.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2019, 10:20:42 AM
By making a bunch of skins and putting them all into shipRoles, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 26, 2019, 01:52:05 PM
Is there a way to modify the hover text / tooltip that appears on the map?

(https://i.imgur.com/2EKbxEw.png)

Specifically, I'd love to be able to remove "(Inactive Gate)" so it just reads "Active Gate". I've done a lot of looking through the game files and my best guess is that it's hardcoded and obfuscated, but I've been wrong plenty of times.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2019, 09:33:32 PM
Yeah, if the name does not match the base name of the custom entity, the base name shows up in parends and this is indeed hardcoded in core code.

Defining a different custom entity (in custom_entities.json) and swapping it out with the inactive gate is an option, but you'd have to be careful since for example a debris field could be orbiting the gate. Or if an intel item is referring to the original gate, then you're pretty much out of luck, so maybe it's not a good option.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on January 27, 2019, 02:38:18 AM
Replace all the gates in the procgen stage.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 27, 2019, 07:08:03 AM
Thanks for the answer. I'll leave that as a "nice to have", then :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 28, 2019, 04:26:56 AM
Is there a way to imitate the effects of devmode's F1 in combat (enable/disable AI for selected ship on tactical map)? I can give the ship a ShipAI with blank methods and tell it to hold fire, but it does some undesirable stuff like aiming weapons at the player.

Is there a combat API method to stop asteroids from spawning (specifically in simulator)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 28, 2019, 09:37:24 AM
Is there a way to imitate the effects of devmode's F1 in combat (enable/disable AI for selected ship on tactical map)? I can give the ship a ShipAI with blank methods and tell it to hold fire, but it does some undesirable stuff like aiming weapons at the player.

The things F1 does in addition to what you're already doing is setting the velocity to 0, and calling .toggleOff() on every weapon group.

Is there a combat API method to stop asteroids from spawning (specifically in simulator)?

I don't believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kolt on January 30, 2019, 09:28:33 PM
My mod isn't showing in the mod list, what can I do to fix this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on January 30, 2019, 09:47:26 PM
What does your mod_info.json say?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kolt on January 31, 2019, 05:38:28 AM
{
   'id':'wip_mod',
   'name':'WIP Mod',
   'author':'Kolt',
   'version':'0.1',
   'description':'Yeetimus Maximus',
   'gameVersion':'0.9a-RC10',
}

Is what I have for it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kolt on January 31, 2019, 07:53:15 AM
I fixed it, I am the dumb sorry about that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: gauntman on February 02, 2019, 09:04:04 AM
I’ve been wanting to edit a list of custom system names of my own for New Sector Generation in Nex.  Does anyone know where I can find the file in that contains the list of possible system names?

I use the Nexelin mod, I’m not sure if it stored in there or somewhere in the core data files. 

Appreciate any guidance
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on February 02, 2019, 04:10:54 PM
Is there a way to have custom player portraits that can't be used by the game for any other characters? As in, is there a way to make certain portraits exclusive to the player?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on February 02, 2019, 10:26:21 PM
Put them in player.faction, delet them from (or don't put them in in the first place) all the other .faction files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: From a Faster Time on February 03, 2019, 03:07:28 AM
Put them in player.faction, delet them from (or don't put them in in the first place) all the other .faction files?
I did that, the issue with that was that some administrators for hire would still use that portrait.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 03, 2019, 10:51:29 AM
Right, yeah - officers/admins spawned on player colonies could use the portraits there. The only way I can think of to make it exclusive to the player would be to set the player's portrait in a script once the game starts, or via console commands - there's probably a way to do that using the "runCode" command.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 04, 2019, 02:21:57 AM
I'm trying to wrap my head around what governs the frequency of hulls and blueprint spawning to make some ships really uncommon.

As far as I understand it, in ship_data.csv, the rarity attribute drive how often a rare blueprint spawns and only that. With 1 being the regular drop rate and 0 being complete absence. ("rarity" being a misnomer here since it's the frequency)

What I have issues with however is how hullFrequency works in the faction files: Even with the tiniest values there (such as 0.01) those ships are omnipresent. As in all ship in fleets are "rare" ships with the odd regular vanilla one. It is as if individual hulls that do not have a frequency set in this section are defaulted to 0 rather than 1, and the global blueprint rarity doesn't get applied. And as soon as another mod add their own ships with average frequencies, the relative rarity gets properly reflected in game.

So am I completely mistaken and there is a completely different way to set the spawn rate of a ship in fleets? Or could there be a bug there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 04, 2019, 10:03:34 AM
What I have issues with however is how hullFrequency works in the faction files: Even with the tiniest values there (such as 0.01) those ships are omnipresent. As in all ship in fleets are "rare" ships with the odd regular vanilla one. It is as if individual hulls that do not have a frequency set in this section are defaulted to 0 rather than 1, and the global blueprint rarity doesn't get applied. And as soon as another mod add their own ships with average frequencies, the relative rarity gets properly reflected in game.

So am I completely mistaken and there is a completely different way to set the spawn rate of a ship in fleets? Or could there be a bug there?

For fleet compositions, the "rarity" column in ship_data has no impact. If a hull is not mentioned in the hullFrequency, it does indeed default to 1.

This is used fairly extensively in vanilla, so, hmm - it's certainly possible there might be a bug, but I remember testing it quite a bit, including with values like 0.0001, and everything seemed to work at the time.

Quick thought - you don't have variant ids specified there, do you? It's looking for hull ids.

One other possibility is to do with ship roles. For example, if you have a single carrier with a low hullFrequency, and no other options for the carrier roles, it'll get picked every time despite its low frequency, since it's the only choice.

Hope this helps!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 05, 2019, 01:06:32 AM
I definitively checked for this: for example I have one frigate hull for the pirates with a hullFrequency in the faction file of 0.1, and it becomes literally omnipresent: every single pirate frigate I could see is that one frigate. But when I add the Underworld mod that has pirate frigates in the 1.5 frequency range, then all the pirate fleets are filled with Underworld's frigates, with the odd one from my mod, and no vanilla pirate ship in sight. That's why I suspect a bug if hullFrequency is the only thing affecting the rarity in fleets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 05, 2019, 04:23:38 AM
seems that methods in HullModFleetEffect only will be called in the fleet which member has the mod?
Though it says "will be called in every fleet", I debuged that that's not true
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2019, 08:24:12 AM
I definitively checked for this: for example I have one frigate hull for the pirates with a hullFrequency in the faction file of 0.1, and it becomes literally omnipresent: every single pirate frigate I could see is that one frigate. But when I add the Underworld mod that has pirate frigates in the 1.5 frequency range, then all the pirate fleets are filled with Underworld's frigates, with the odd one from my mod, and no vanilla pirate ship in sight. That's why I suspect a bug if hullFrequency is the only thing affecting the rarity in fleets.

Hmm. Just tried a mini-mod with the following pirates.faction:

{
   "hullFrequency":{
      "hulls":{
         "omen":0.1,
      },
   },
   "shipsWhenImporting":{
      "hulls":[
         "omen",
      ],
   },   
   "knownShips":{
      "hulls":[
         "omen",
      ],
   },
}

0.1 means an Omen almost never spawns, which seems to hold up (since it'll have a .1 frequency, while there are many other competing frigate pirate_bp hulls with a frequency of 2, and still more frigate hulls with a frequency of 1). Changing it to 10 or so gets 3-4 Omens in a fairly large pirate fleet. So, this seems to be working as expected, at least on my end. Can you post what you've got? Hard to say w/o seeing, since it does seem to be working on a base level.

seems that methods in HullModFleetEffect only will be called in the fleet which member has the mod?
Though it says "will be called in every fleet", I debuged that that's not true

Looking at the code, it should be called for every fleet. The code calling it looks like this:

for (HullModSpec spec : SpecStore.getFleetEffectHullMods()) {
   spec.getFleetEffect().advanceInCampaign(this);
}

So it literally just grabs every HullModSpec that implements HullModFleetEffect; the method that does that - getFleetEffectHullMods() - is static and doesn't even know about any fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 05, 2019, 10:46:58 AM
Damnit! I still had the tag list empty, that must have erased the existing tagged blueprints. I swear this "empty fields erase everything" merging will claim my sanity someday.
Now, does that rarity affects market availability too? In particular on the black market side?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2019, 10:50:23 AM
Damnit! I still had the tag list empty, that must have erased the existing tagged blueprints. I swear this "empty fields erase everything" merging will claim my sanity someday.

Ahh, sorry :(

Now, does that rarity affects market availability too? In particular on the black market side?

No - the only thing it affects is blueprint drop frequency.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 05, 2019, 08:53:30 PM
What would be the easiest way to add addition weapons to all markets at game creation? The absence of the Light Machine Gun in .9 is truly felt in my mod. There isn't much pd weaponry at all in markets.

A pass through the full array of markets, including military and black markets, and adding things to all of them, in the NGCAddStandardStartingScript?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2019, 09:27:03 PM
Hmm - you probably want to modify the cargo in CampaignEventListener.reportPlayerOpenedMarketAndCargoUpdated(MarketAPI market). That is, implement and register a campaign event listener.

Adding stuff to the markets on new game creation is not likely to stick, since this stuff is updated (and weapons are pruned) when a player interacts with a market.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 06, 2019, 02:06:17 AM
Looking at the code, it should be called for every fleet. The code calling it looks like this:

for (HullModSpec spec : SpecStore.getFleetEffectHullMods()) {
   spec.getFleetEffect().advanceInCampaign(this);
}

So it literally just grabs every HullModSpec that implements HullModFleetEffect; the method that does that - getFleetEffectHullMods() - is static and doesn't even know about any fleet.
oh, okay, maybe I make a wrong breakpoint.
BTW, I use BuffManager to maintain the status in FleetEffect, and buffs will be removed correctly right? I don't need to remove them by myself
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2019, 09:17:29 AM
BTW, I use BuffManager to maintain the status in FleetEffect, and buffs will be removed correctly right? I don't need to remove them by myself

As long as your Buff.isExpired() returns true when you want it to be removed, yeah. If it always returns false then the buff would never be removed. There's a TempBuff class which handles simple time-based removal which you can extend or copy if you like.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Blothorn on February 06, 2019, 10:43:54 PM
I wrote a CombatPlugin that assumed init() was called before advance(); it reliably crashed in advance() during campaign load. Why was it being called then, and why advance() without init()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 07, 2019, 10:06:21 AM
No particular reason, it's just old code that hasn't been touched in a while and some things changed. Since I'm not likely to go digging around in it (and possibly break something obscure that depends on the current behavior):

1) Don't assume init() will be called before advance, and
2) Don't assume init() will only be called once
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 07, 2019, 04:59:35 PM
Hmm - you probably want to modify the cargo in CampaignEventListener.reportPlayerOpenedMarketAndCargoUpdated(MarketAPI market). That is, implement and register a campaign event listener.

Adding stuff to the markets on new game creation is not likely to stick, since this stuff is updated (and weapons are pruned) when a player interacts with a market.



I took a look at CampaignEventListener.reportPlayerOpenedMarketAndCargoUpdated(MarketAPI market). It is just an interface there isn't any actual code available in the api package. Any place I can see it?

I could possibly extend the class and override it, but I would be flying blind so to speak, and I feel like I would mess up other things. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 07, 2019, 10:24:22 PM
I'm cruious about how FleetAssignment works, is there a list to contain those assignments?
and  I found that in TutorialLeashAssignmentAI:
Code
@Override
public void advance(float amount) {
super.advance(amount);

float dist = Misc.getDistance(fleet.getLocation(), toGuard.getLocation());
if (dist > 1500 && fleet.getAI().getCurrentAssignmentType() == FleetAssignment.ORBIT_AGGRESSIVE) {
fleet.addAssignmentAtStart(FleetAssignment.ORBIT_PASSIVE, toGuard, 3f, null);
}
}
fleet.getAI().getCurrentAssignmentType() == FleetAssignment.ORBIT_AGGRESSIVE, does it mean if the current assignment not "orbit aggressive", fleet won't go back to the guard place? if I need to force them stay in one place, and they will be stopped even they are chasing a fleet when they are far from guard position, what should I do? Delete this script?

And, how to add permanent hullmod now? The inflater seems will delete the hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2019, 08:53:03 AM
I took a look at CampaignEventListener.reportPlayerOpenedMarketAndCargoUpdated(MarketAPI market). It is just an interface there isn't any actual code available in the api package. Any place I can see it?

I could possibly extend the class and override it, but I would be flying blind so to speak, and I feel like I would mess up other things. :)

What you want to do is extend BaseCampaignEventListener, which implements the CampaignEventListener interface with empty functions, and then override whatever method(s) you're interested in. The reasons for extending BaseCampaignEventListener instead of implementing CampaignEventListener directly are:

1) You don't need to add a ton of empty functions, and
2) If I add something to the CampaignEventListener interface, your code won't break since I'll also add an empty function to BaseCampaignEventListener

If you call super(true) in your implementation, that'll register the listener for you, so you just need to call "new YourClassName()" somewhere in, say, onNewGame(). I don't think there are any custom implementations of reportPlayerOpenedMarketAndCargoUpdated() in vanilla, so there's no immediate example to look at.

(I'm also going to look at weapon availability for .1, btw...)


I'm cruious about how FleetAssignment works, is there a list to contain those assignments?

Yes, the fleet AI keeps a list of assignments. Each has a duration, so as soon as it runs out, the next assignment in the list is used.

TutorialLeashAssignmentAI extends BaseAssignmentAI, which calls the pickNext() method when the fleet AI is out of assignments.

and  I found that in TutorialLeashAssignmentAI:
Code
@Override
public void advance(float amount) {
super.advance(amount);

float dist = Misc.getDistance(fleet.getLocation(), toGuard.getLocation());
if (dist > 1500 && fleet.getAI().getCurrentAssignmentType() == FleetAssignment.ORBIT_AGGRESSIVE) {
fleet.addAssignmentAtStart(FleetAssignment.ORBIT_PASSIVE, toGuard, 3f, null);
}
}
fleet.getAI().getCurrentAssignmentType() == FleetAssignment.ORBIT_AGGRESSIVE, does it mean if the current assignment not "orbit aggressive", fleet won't go back to the guard place? if I need to force them stay in one place, and they will be stopped even they are chasing a fleet when they are far from guard position, what should I do? Delete this script?

The way this works is it'll have the ORBIT_AGGRESSIVE assignment generated in pickNext(), so that's its default state - it'll chase after things it sees. But as soon as it's >1500 units away from whatever it's leashed to, it will get an ORBIT_PASSIVE assignment for 3 days, causing it to go back to the location its leashed to and stop chasing for the duration. Then it'll go back to ORBIT_AGGRESSIVE and chase again, and get leashed back if it exceeds the 1500 unit range, etc.


And, how to add permanent hullmod now? The inflater seems will delete the hullmod.

It would help to know what you're actually trying to do. The inflater generates the variants, so before it runs, the "real" variants for the fleet members don't even exist. I suspect the answer is to probably either 1) write a custom inflater or 2) set the inflater to null, but it depends on what exactly you want to do. If you can be more specific, I might be able to add something on my end to make it easier to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 08, 2019, 12:45:55 PM
I search a information, for be sure.

This is true than, now, ShipSystemAPI is instancied per ShipAPI and not just a global?

Like the log of the 0.9a have not pointed out that...

This is surely the case like people say, but like i do not found the thing on the forum.

Thank.

EDIT: Ok, thank, sorry x)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2019, 01:07:01 PM
Yeah, it's per-ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 08, 2019, 07:44:33 PM
The way this works is it'll have the ORBIT_AGGRESSIVE assignment generated in pickNext(), so that's its default state - it'll chase after things it sees. But as soon as it's >1500 units away from whatever it's leashed to, it will get an ORBIT_PASSIVE assignment for 3 days, causing it to go back to the location its leashed to and stop chasing for the duration. Then it'll go back to ORBIT_AGGRESSIVE and chase again, and get leashed back if it exceeds the 1500 unit range, etc.
Well, its current assignment remains ORBIT_AGGRESSIVE when it is chasing fleet?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2019, 08:07:58 PM
Well, its current assignment remains ORBIT_AGGRESSIVE when it is chasing fleet?

Yes - that's what ORBIT_AGGRESSIVE means, orbit something but chase enemies if they're around.

Assignments don't just change by themselves, they have to be changed by something - usually either when one assignment runs out and it goes on to the next (if it was given multiple assignments to carry out in order), or when an assignment script added to the fleet makes some changes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 08, 2019, 08:41:05 PM
It would help to know what you're actually trying to do. The inflater generates the variants, so before it runs, the "real" variants for the fleet members don't even exist. I suspect the answer is to probably either 1) write a custom inflater or 2) set the inflater to null, but it depends on what exactly you want to do. If you can be more specific, I might be able to add something on my end to make it easier to do.

I want to add a hull mod which won't be deleted when fleet is inflated or deflated.

Code
public class IL_FleetInflater extends DefaultFleetInflater {
    public IL_FleetInflater(DefaultFleetInflaterParams p) {
        super(p);
    }

    @Override
    public void inflate(CampaignFleetAPI fleet) {
        super.inflate(fleet);
        for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
            member.getVariant().addPermaMod("IL_isomery");
        }
        fleet.getFleetData().setSyncNeeded();
        fleet.getFleetData().syncIfNeeded();
    }
}

Code
 DefaultFleetInflaterParams p = new DefaultFleetInflaterParams();
        p.quality = 1f;
        p.persistent = true;
        p.seed = random.nextLong();
        p.mode = FactionAPI.ShipPickMode.PRIORITY_THEN_ALL;
        p.timestamp = params.timestamp;

        FleetInflater inflater = new IL_FleetInflater(p);
        fleet.setInflater(inflater);

will it work?
well it works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2019, 09:03:13 PM
Very nice! Wasn't thinking of doing it like this but that's very clean solution.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 08, 2019, 10:01:19 PM
I'm trying to spawn a ship with a specific ShipVariantAPI in combat (not a variant ID string, since I need it to obey player customisations to the variant).

Why does the ship spawned with the following code have the crash-mothballed icon on the command map and experience critical malfunctions, regardless of what CR is set to?

Code: java
	FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variant);
member.getRepairTracker().setCR(0.7f);
member.getRepairTracker().setMothballed(false);
member.getRepairTracker().setCrashMothballed(false);
ship = engine.getFleetManager(side).spawnFleetMember(member, tempLoc, -90, 0);
ship.getLocation().set(tempLoc);
ship.setOriginalOwner(side.ordinal());
ship.setOwner(side.ordinal());
ship.setControlsLocked(false);
// set CR again because it doesn't obey the one in repair tracker
ship.setCRAtDeployment(0.7f);
ship.setCurrentCR(0.7f);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2019, 08:46:05 AM
I think that's because the newly-created member does not have any crew.

Something like:

CrewCompositionAPI crew = FactoryAPI.createCrewComposition();
crew.setCrew(member.getMinCrew());
member.setCrewComposition(crew);

Should resolve this, unless there's also another issue I'm missing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on February 09, 2019, 03:24:48 PM
Is it possible to remove or add hyperspace terrain (voidclouds) outside of the sector generation phase (so as you are flying about the sector)? I tried using some of the functions in NebulaEditor, but these just seem instantly crash the game upon triggering...

If this is even possible i'd love for an example!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2019, 09:44:43 PM
Is it possible to remove or add hyperspace terrain (voidclouds) outside of the sector generation phase (so as you are flying about the sector)? I tried using some of the functions in NebulaEditor, but these just seem instantly crash the game upon triggering...

If this is even possible i'd love for an example!

It should be possible, though I might be forgetting about something that would make it not so. I'd suggest posting what you did and the crash you get.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on February 10, 2019, 03:49:47 AM
I've currently tacked these functions onto an EveryFrameScript (fuelDepotControl) which handles control of fuel depots around gas giants, so the implementation isn't the best, it is probably just me doing something wrong/not understanding the API causing this as well!

Here's the code i'm trying as well as the errors i get:
Spoiler
Code: java
HyperspaceTerrainPlugin hyper = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin(); //I also tried using Global.getSector().getHyperspace() with similar results
NebulaEditor editor = new NebulaEditor(hyper);

...

 CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet(); //Crashes if you give the functions static x and y coordinates as well

if (playerFleet.isInHyperspace())
{
    editor.clearArc(playerFleet.getLocation().x, playerFleet.getLocation().y, 0, 2f + 1f * 0.5f, 0, 360f); //I stuck both of the functions in here for the example, they crash on their own as well
    editor.setTileAt(playerFleet.getLocation().x, playerFleet.getLocation().y, 0);
}
(https://i.imgur.com/hSEGYWp.png)
Code: java
76739 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at control.fuelDepotControl.advance(fuelDepotControl.java:52)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher76739 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at control.fuelDepotControl.advance(fuelDepotControl.java:52)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source).run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 10, 2019, 08:08:59 AM
According to this:
at control.fuelDepotControl.advance(fuelDepotControl.java:52) 

It crashes on line 52 of fuelDepotControl.java with an NPE. So that means the crash is in your code, due to trying to use a null reference.

For example, if you had code that looked like this:

NebulaEditor editor = null;
editor.clearArc(...)

It would throw an NPE on the second line, due to trying to call "clearArc" on a null reference. (I'm sure suggesting that's the actual issue, just trying to clarify what an NPE means.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 10, 2019, 10:05:57 AM
What you want to do is extend BaseCampaignEventListener, which implements the CampaignEventListener interface with empty functions, and then override whatever method(s) you're interested in. The reasons for extending BaseCampaignEventListener instead of implementing CampaignEventListener directly are:

1) You don't need to add a ton of empty functions, and
2) If I add something to the CampaignEventListener interface, your code won't break since I'll also add an empty function to BaseCampaignEventListener

If you call super(true) in your implementation, that'll register the listener for you, so you just need to call "new YourClassName()" somewhere in, say, onNewGame(). I don't think there are any custom implementations of reportPlayerOpenedMarketAndCargoUpdated() in vanilla, so there's no immediate example to look at.

(I'm also going to look at weapon availability for .1, btw...)

Ah ok I didn't see that that was the impl class thanks! And on .1 I may hold off until then if you are looking at it anyway because there are a couple more pressing issues, actually.

Has anything changes with hiring officers?? I know admins were added but that is a separate rule. I'm getting index out of bounds when I call "CallEvent $ome_eventRef printSkills $id" but nothing in my code changes that to my knowledge, I just have custom rules that call it for my factions officers.

Any hints or do you need an example?

Same thing with turning in delivery missions to markets. The rules entries look the same but I noticed it it handled at the planet level now.. is the old rules portion deprecated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 10, 2019, 10:09:06 AM
Has anything changes with hiring officers?? I know admins were added but that is a separate rule. I'm getting index out of bounds when I call "CallEvent $ome_eventRef printSkills $id" but nothing in my code changes that to my knowledge, I just have custom rules that call it for my factions officers.

Any hints or do you need an example?

I'd suggest looking at the line where it throws the exception - all of this should be code you have access to the source of. That should point us towards what the issue is.


Same thing with turning in delivery missions to markets. The rules entries look the same but I noticed it it handled at the planet level now.. is the old rules portion deprecated?

Hmm, I'm not sure what you mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on February 10, 2019, 11:02:00 AM
According to this:
at control.fuelDepotControl.advance(fuelDepotControl.java:52) 

It crashes on line 52 of fuelDepotControl.java with an NPE. So that means the crash is in your code, due to trying to use a null reference.

For example, if you had code that looked like this:

NebulaEditor editor = null;
editor.clearArc(...)

It would throw an NPE on the second line, due to trying to call "clearArc" on a null reference. (I'm sure suggesting that's the actual issue, just trying to clarify what an NPE means.)

So i had a quick think and took a look at this, looks like the underlying issue was that the NebulaEditor does not survive saving and loading the game, i added a quick check for the Editor being null (thanks to Nicke535 on the discord for that idea) to the script and it now works swimmingly!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 10, 2019, 11:04:55 AM
I'd suggest looking at the line where it throws the exception - all of this should be code you have access to the source of. That should point us towards what the issue is.


Same thing with turning in delivery missions to markets. The rules entries look the same but I noticed it it handled at the planet level now.. is the old rules portion deprecated?

Hmm, I'm not sure what you mean.

Ok I'll take a look and get back to you on that.

Sorry, what I meant was that in .8 delivery missions were turned in at the commboard like how you turn in AI cores, but through a generated npc with a yellow quest marker attached.

When a player interacted with the new npc, a ruleset would determine if the player had the appropriate cargo and if they did, then show text to complete the mission and generate the player reward.


In .9, however, that same transaction is done when a player simply docks at a market in the market description text. So I am wondering if that is just a separate ruleset that those missions now require, and if so, is the old way in .8 and its related rules now deprecated in favor of the new system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 10, 2019, 11:28:07 AM
In .9, however, that same transaction is done when a player simply docks at a market in the market description text. So I am wondering if that is just a separate ruleset that those missions now require, and if so, is the old way in .8 and its related rules now deprecated in favor of the new system.

Unless I'm missing something, that seems incorrect. Bar delivery missions end on market interaction, but procurement missions - which involve a specific person - iirc still require getting in touch via the comm directory.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 10, 2019, 12:29:04 PM
Unless I'm missing something, that seems incorrect. Bar delivery missions end on market interaction, but procurement missions - which involve a specific person - iirc still require getting in touch via the comm directory.

Hmm, ok that makes sense I checked a while ago so maybe I got the details confused between the two delivery types.

The strange thing is that neither type can be delivered. The npc with the quest marker never shows up in the commboard, and accepting bar delivery quests are fine until you get to the planet you are supposed to drop the goods off to. The turn in dialogue never populates.

I think this may only be on new faction markets, though. There is a save and the mod that I can link that shows the problem with the market procurement side, and I think you can select a delivery mission at the bar too. (This was what another player reported)

Save game: http://www.filedropper.com/savenasty8109031963081034761

Mod:
https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0 (https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on February 10, 2019, 04:00:54 PM
So, another stupid question from me: I'm doing some very bad stuff to the hyperspace SectorEntityToken and the game is clearly not enjoying itself (see spoiler, epilepsy warning)...

Spoiler
https://i.imgur.com/nxuFfEe.mp4
(Had to link due to imgur .mp4s not being supported)
[close]

In this case i've set the SectorEntityToken for the hyperspace to orbit my fleet whenever i am in hyperspace, my question would be if there's anything that could be done about the flickering/rapid changing of the voidclouds, it seems to occur no matter if the entity is moving or if it is stationary.

I realize am doing some very bad stuff to the game at this point, so i am not expecting any miracles! :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 10, 2019, 04:08:58 PM
I think this may only be on new faction markets, though. There is a save and the mod that I can link that shows the problem with the market procurement side, and I think you can select a delivery mission at the bar too. (This was what another player reported)

Save game: http://www.filedropper.com/savenasty8109031963081034761

Mod:
https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0 (https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0)

I'll see if I can check this out at some point! Might be a bit though, digging through lots of stuff.


In this case i've set the SectorEntityToken for the hyperspace to orbit my fleet whenever i am in hyperspace

... that's not how any of this works! Well, that's not entirely fair; some small nebula patches do orbit things like stars. Since your gif doesn't actually seem to be animated, at least on my end, I'm not sure what you mean exactly.

But I suspect the answer, in any case, would be "probably not"; I wouldn't be surprised if the hyperspace terrain plugin is assuming that the terrain is centered on 0,0.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on February 10, 2019, 04:19:54 PM
... that's not how any of this works!

Hehe, i tried it as an ugly workaround to setting the location of the hyperspace terrain every frame, sadly it had the same result... (The orbit thing totally does work though, for some strange reason)

Well, that's not entirely fair; some small nebula patches do orbit things like stars. Since your gif doesn't actually seem to be animated, at least on my end, I'm not sure what you mean exactly.

But I suspect the answer, in any case, would be "probably not"; I wouldn't be surprised if the hyperspace terrain plugin is assuming that the terrain is centered on 0,0.

Here's a straight link to the imgur Mp4 i was trying to link, maybe that can better illustrate what i am talking about! https://i.imgur.com/nxuFfEe.mp4

Yeah, that's kind of what i am expecting, been looking a little at the HyperspaceTerrainPlugin class and it seems to be looking grim. I'm trying to find ways of getting away from having a large hyperspace terrain entity to try to improve on the (still decent) performance of my increased size sector. The general idea was to move the hyperspace terrain entity with the player and generate the hyperspace terrain as you go using a noise algorithm i've already somewhat successfully tested.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 10, 2019, 06:41:21 PM
I think this may only be on new faction markets, though. There is a save and the mod that I can link that shows the problem with the market procurement side, and I think you can select a delivery mission at the bar too. (This was what another player reported)

Save game: http://www.filedropper.com/savenasty8109031963081034761

Mod:
https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0 (https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0)

I'll see if I can check this out at some point! Might be a bit though, digging through lots of stuff.

Thanks! No pressure, do what you need to and I'll keep looking too of course.

Though I'm kind of at a loss right now, one thing I thought about investigating is the way the new game is generated. It is based on the old NGCStartingScript code, but there doesn't seem to be anything in there that would directly affect markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on February 10, 2019, 07:10:49 PM
I'm trying to make a custom industry for a Luddic Church market, that enables the Church to make it's own ships and grants a small buff to ship quality and fleet size. I'm basing this off HeavyIndustry, as well as code in the Prism Freeport and Shadowyards mods. However, despite the industry working in almost all respects, it critically doesn't improve the quality of the Luddic Church ships, does not remove the 'Cross-Faction imports' deficit, and does not increase the size of their fleets. I'm not sure what I'm doing wrong, or if I've missed something important. Could anyone help me out please?

Code for the industry:
Code
package data.campaign.econ.industries;

import com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.util.Pair;

public class luddenhance_refit extends BaseIndustry {
        
        @Override
        public void apply() {
super.apply(true);
                int size = market.getSize();
                
                demand(Commodities.RARE_METALS, size - 1);
demand(Commodities.METALS, size + 1);
demand(Commodities.ORGANICS, size + 1);
demand(Commodities.VOLATILES, size + 1);

                supply(Commodities.SHIPS, size - 3);
supply(Commodities.HEAVY_MACHINERY, size - 2);
supply(1, Commodities.SHIPS, 1, "Cerberus Manufactory");

                
                    Pair<String, Integer> deficit = getMaxDeficit(Commodities.RARE_METALS, Commodities.METALS, Commodities.VOLATILES, Commodities.ORGANICS);
                    int maxDeficit = size -4;
                    if (deficit.two > maxDeficit) deficit.two = maxDeficit;

                    applyDeficitToProduction(2, deficit,
Commodities.SHIPS,
Commodities.HEAVY_MACHINERY);

market.getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).modifyFlat(getModId(1), 0.25f, "Cerberus Manufactory");

float stability = market.getPrevStability();
if (stability < 5) {
float stabilityMod = (stability - 5f) / 5f;
stabilityMod *= 0.5f;
//market.getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).modifyFlat(getModId(0), stabilityMod, "Low stability at production source");
market.getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).modifyFlat(getModId(0), stabilityMod, getNameForModifier() + " - low stability");
}

if (!isFunctional()) {
supply.clear();
unapply();
}
        }

   @Override
public void unapply() {
super.unapply();
}

@Override
public boolean isAvailableToBuild() {
return false;
}

@Override
public boolean showWhenUnavailable() {
return false;
}
    }

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 11, 2019, 06:18:40 AM
Fleet size isn't affected by heavy industry/nanoforge by default (except by ensuring ship hulls & weapons demand is met) and your code isn't otherwise modifying it.
As for quality: dunno, maybe it needs the heavyindustry tag in industries.csv?


Okay, requesting a fix to the API:

Calling market.setFreePort(true) for a market with an under-construction spaceport doesn't add the free port condition, because it needs a spaceport.
But! Not only is the condition not applied when the spaceport is completed, further calls of setFreePort(true) do nothing because it's already a free port.
I can work around it for now by setting free port to false first, but maybe make this not be required?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on February 11, 2019, 06:59:13 AM
Seems like weapon render order was changed to an automatic system in 0.9, at the very least a bunch of ships have overlapping turrets in the wrong order now where before it worked fine. Assuming this is set by distance from ship or sprite center, is there any way to override it or control it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2019, 10:05:42 AM
Here's a straight link to the imgur Mp4 i was trying to link, maybe that can better illustrate what i am talking about! https://i.imgur.com/nxuFfEe.mp4

Yeah, that's kind of what i am expecting, been looking a little at the HyperspaceTerrainPlugin class and it seems to be looking grim. I'm trying to find ways of getting away from having a large hyperspace terrain entity to try to improve on the (still decent) performance of my increased size sector. The general idea was to move the hyperspace terrain entity with the player and generate the hyperspace terrain as you go using a noise algorithm i've already somewhat successfully tested.

Ah, hmm - it looks like it keeps picking a different texture or angle for each tile. Why it would do that, I'm not sure - to be perfectly honest, I don't want to really dig into it, since the most likely answer would still just be "yep, doesn't work because it's not meant to handle this", if that makes sense :)

I *do* think that the texture-switching is probably due to something other than the center moving, but, again, not sure. The main problem with what you're trying to do, btw, would be the Sector map - in non-Starscape mode, you'd see the smaller faked-up hyperspace square around the player.

If you're just concerned about the savefile size, I think a more promising approach might be to make the game not save the tile data - and regenerating it on load instead - by overriding writeReplace()/readResolve(), but, fair warning, that requires a pretty good understanding of Java and how the save system works.


I'm trying to make a custom industry for a Luddic Church market, that enables the Church to make it's own ships and grants a small buff to ship quality and fleet size. I'm basing this off HeavyIndustry, as well as code in the Prism Freeport and Shadowyards mods. However, despite the industry working in almost all respects, it critically doesn't improve the quality of the Luddic Church ships, does not remove the 'Cross-Faction imports' deficit, and does not increase the size of their fleets. I'm not sure what I'm doing wrong, or if I've missed something important. Could anyone help me out please?

Code for the industry:

This might actually be due to a bug in the ship quality calculation (which ought to be fixed for .1, but I don't remember what it was, exactly); not 100% sure. FWIW, the industry code looks fine to me.


Okay, requesting a fix to the API:

Calling market.setFreePort(true) for a market with an under-construction spaceport doesn't add the free port condition, because it needs a spaceport.
But! Not only is the condition not applied when the spaceport is completed, further calls of setFreePort(true) do nothing because it's already a free port.
I can work around it for now by setting free port to false first, but maybe make this not be required?

Ah, good point - made it so that calling setFreePort(false) is no longer required. The condition was self-removing but updating the "isFreeBort" boolean in the market object.



Seems like weapon render order was changed to an automatic system in 0.9, at the very least a bunch of ships have overlapping turrets in the wrong order now where before it worked fine. Assuming this is set by distance from ship or sprite center, is there any way to override it or control it?

It was always (at least, for as long as I can remember) an automatic system, though I do remember making a few changes.

The rules for what stuff goes below other stuff, in order of priority:
- Is a hardpoint
- Is a larger weapon size
- Is a missile weapon that renders loaded missiles
- Is further away from the spine of the ship
- Is further away from a line through the center, perpendicular to the spine of the ship

Though "further away from perpendicular" could override "further away from spine" if the distance differential is high enough.

If you could get me a mini-mod with a specific example, and what's desired, I could take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2019, 10:36:25 AM
Hmm, ok that makes sense I checked a while ago so maybe I got the details confused between the two delivery types.

The strange thing is that neither type can be delivered. The npc with the quest marker never shows up in the commboard, and accepting bar delivery quests are fine until you get to the planet you are supposed to drop the goods off to. The turn in dialogue never populates.

I think this may only be on new faction markets, though. There is a save and the mod that I can link that shows the problem with the market procurement side, and I think you can select a delivery mission at the bar too. (This was what another player reported)

Save game: http://www.filedropper.com/savenasty8109031963081034761

Mod:
https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0 (https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0)

Gave it a quick try - Filzip shows the savefile archive as being empty (ugh), and creating a new game crashes because the hegemony.faction doctrine has a shipSize of 6. (All doctrine values must be in the [1, 5] range.)

If NPCs with the quest marker never show up in the comm directory, that's... weird. I would honestly start with that - I suggest maying seeing if you can connect up a debugger and put a breakpoint in ProcurementMissionIntel somewhere (perhaps in acceptMission()) to see what might be going wrong...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 11, 2019, 03:01:06 PM
Hmm, ok that makes sense I checked a while ago so maybe I got the details confused between the two delivery types.

The strange thing is that neither type can be delivered. The npc with the quest marker never shows up in the commboard, and accepting bar delivery quests are fine until you get to the planet you are supposed to drop the goods off to. The turn in dialogue never populates.

I think this may only be on new faction markets, though. There is a save and the mod that I can link that shows the problem with the market procurement side, and I think you can select a delivery mission at the bar too. (This was what another player reported)

Save game: http://www.filedropper.com/savenasty8109031963081034761

Mod:
https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0 (https://www.dropbox.com/sh/tp24gdke0i7dzpl/AACU8gAw7fGjMuWi-cLcZMiXa?dl=0)

Gave it a quick try - Filzip shows the savefile archive as being empty (ugh), and creating a new game crashes because the hegemony.faction doctrine has a shipSize of 6. (All doctrine values must be in the [1, 5] range.)

If NPCs with the quest marker never show up in the comm directory, that's... weird. I would honestly start with that - I suggest maying seeing if you can connect up a debugger and put a breakpoint in ProcurementMissionIntel somewhere (perhaps in acceptMission()) to see what might be going wrong...

Thanks for the info on the faction doctrine (didn't know and starting a new game works in my environment) I would have likely had to change that anyway come the next update.

I'll see what I can do about the debugger.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on February 11, 2019, 03:11:12 PM
The rules for what stuff goes below other stuff, in order of priority:
- Is a hardpoint
- Is a larger weapon size
- Is a missile weapon that renders loaded missiles
- Is further away from the spine of the ship
- Is further away from a line through the center, perpendicular to the spine of the ship

Though "further away from perpendicular" could override "further away from spine" if the distance differential is high enough.

If you could get me a mini-mod with a specific example, and what's desired, I could take a look.

I seem to recall it was set by weapon slot number before, which allowed precise control over what went where for cases where several small turrets are clustered together. At least, that's my only explanation for why things don't look the way they used to. Would it be possible to override somehow, based on that? With the way it is now I'd have to redo several ships fundamentally to avoid edge cases where overlap looks bad, because there's no way to finesse the current system to do what I want it to do.

E: Here's an example of what I mean (using the biggest small weapons makes it very visible)
(https://i.imgur.com/ahBMaaA.jpg)

(https://i.imgur.com/LUm7BKC.jpg)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2019, 04:51:32 PM
I seem to recall it was set by weapon slot number before, which allowed precise control over what went where for cases where several small turrets are clustered together. At least, that's my only explanation for why things don't look the way they used to. Would it be possible to override somehow, based on that? With the way it is now I'd have to redo several ships fundamentally to avoid edge cases where overlap looks bad, because there's no way to finesse the current system to do what I want it to do.

I think we all (myself included) *thought* it was based on slot number, but it was effectively random though (usually, not always) consistent.

(Btw, I was wrong about the rules in the previous reply; got a couple of things mixed up.)

Thinking about this a bit more:
Added WEAPONS_FRONT_TO_BACK ship hint - changes tiebreaker for weapon render order to be distance from front of ship (front weapons go below rear ones) instead of distance from ship spine
   Larger weapons still render on top of smaller ones etc


I think that should cover your case - let me know if you think it doesn't!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 11, 2019, 05:34:46 PM
Low hanging fruit Alex, but figure might as well request it while this is being discussed even though it will have less use cases (but I can still think of some) than the hint you just added.

WEAPONS_BACK_TO_FRONT
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2019, 05:38:34 PM
... sure, why not. Could indeed come in handy if a similar cluster of guns on a ship is pointing backwards.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on February 11, 2019, 05:39:30 PM
Yay! Back-to-front will be ideal for something I've been tinkering with.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2019, 05:41:50 PM
Just to make sure we're on the same page: it's just a tiebreaker for when it's otherwise not clear what the order should be - i.e. when the weapons are the same size, same slot type (turret/hardpoint), neither or both are a missile with missiles rendered on the weapon, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on February 11, 2019, 05:45:54 PM
Makes me want to ask for an "ALWAYS_RENDER_ON_TOP" render hint for weapon mounts. Would come in handy for things like decorative weapon covers and the like. That said it's easy enough to achieve with other methods for now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2019, 06:01:53 PM
Might as well; added "renderAboveAllWeapons" to .wpn files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on February 11, 2019, 10:44:53 PM

I'm trying to make a custom industry for a Luddic Church market, that enables the Church to make it's own ships and grants a small buff to ship quality and fleet size. I'm basing this off HeavyIndustry, as well as code in the Prism Freeport and Shadowyards mods. However, despite the industry working in almost all respects, it critically doesn't improve the quality of the Luddic Church ships, does not remove the 'Cross-Faction imports' deficit, and does not increase the size of their fleets. I'm not sure what I'm doing wrong, or if I've missed something important. Could anyone help me out please?

Code for the industry:

This might actually be due to a bug in the ship quality calculation (which ought to be fixed for .1, but I don't remember what it was, exactly); not 100% sure. FWIW, the industry code looks fine to me.

Just an update to this. I tried changing how the markets were generated from the DME method (implementing the industry with the market in the gen file), to the Shadowyards method (attaching the heavy industry seperately to the market in the gen file), to the SCY method (using the vanilla 'economy' file method), and none of them worked. I also have the custom industry with the 'heavyindustry' tag the entire time, with no change. Using the vanilla Heavy Industry works, so I plan on using that for a stop-gap measure. Again, still not sure what I missing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 11, 2019, 11:41:32 PM
Just to make sure we're on the same page: it's just a tiebreaker for when it's otherwise not clear what the order should be - i.e. when the weapons are the same size, same slot type (turret/hardpoint), neither or both are a missile with missiles rendered on the weapon, etc.
What would cover all possible cases would be a slot size "override" for render order when defining a slot in the ship file. Something optional that would work like this:

Code
    {
      "angle": 90,
      "arc": 225,
      "id": "WS0011",
      "locations": [
        48,
        188
      ],
      "mount": "TURRET",
      "size": "MEDIUM",
      "renderOverride": "LARGE_HARDPOINT",
      "type": "BALLISTIC"
    },
That could be added when required to manually set a render position for that slot
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cycerin on February 12, 2019, 04:41:04 AM
The solution with the extra ship hint certainly bails me out of a lot of extra work, thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 12, 2019, 05:53:41 AM
Hypothetical question: is it possible for a carrier to escort a ship's module? Because I've been seeing a bunch of carrier that happen to have modules escorting themselves in a loop just like if the bug was never fixed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 12, 2019, 08:59:53 AM
Just an update to this. I tried changing how the markets were generated from the DME method (implementing the industry with the market in the gen file), to the Shadowyards method (attaching the heavy industry seperately to the market in the gen file), to the SCY method (using the vanilla 'economy' file method), and none of them worked. I also have the custom industry with the 'heavyindustry' tag the entire time, with no change. Using the vanilla Heavy Industry works, so I plan on using that for a stop-gap measure. Again, still not sure what I missing.

If you can cook up a mini-mod that just adds an industry to a market and shows this not working (as far as ship quality etc), I can take a look.

What would cover all possible cases would be a slot size "override" for render order when defining a slot in the ship file. Something optional that would work like this:

Code
    {
      "angle": 90,
      "arc": 225,
      "id": "WS0011",
      "locations": [
        48,
        188
      ],
      "mount": "TURRET",
      "size": "MEDIUM",
      "renderOverride": "LARGE_HARDPOINT",
      "type": "BALLISTIC"
    },
That could be added when required to manually set a render position for that slot

Let me just add this to weapon slot data:

renderOrderMod

Just a number (float) modifier to the render order; positive to get something to render above, negative for below. Less intuitive than a render override setting but a bit more flexible and it seems like at this point might as well go for that.


Hypothetical question: is it possible for a carrier to escort a ship's module? Because I've been seeing a bunch of carrier that happen to have modules escorting themselves in a loop just like if the bug was never fixed.

Oh, damn, yeah. Fixed! Possibly a couple more surprises like this lurking in the codebase...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 12, 2019, 09:32:24 AM
Let me just add this to weapon slot data:

renderOrderMod

Just a number (float) modifier to the render order; positive to get something to render above, negative for below. Less intuitive than a render override setting but a bit more flexible and it seems like at this point might as well go for that.
THANKS!   :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on February 12, 2019, 09:36:26 AM
That reads to me like basically full manual render order control where needed. Will this take precedence over "renderAboveAllWeapons"? I suppose the .wpn tag might not even be necessary with the render order mod setting, though, but I suppose it can't hurt to have options. Also, if we keep it, might be good to also have the counterpart "renderBelowAllWeapons"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on February 12, 2019, 09:39:25 AM
Let me just add this to weapon slot data:

renderOrderMod

Just a number (float) modifier to the render order; positive to get something to render above, negative for below. Less intuitive than a render override setting but a bit more flexible and it seems like at this point might as well go for that.
THANKS!   :D
Seconded!  This is a huge win for doing interesting things with cosmetic weapon mounts.  Much appreciated!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 12, 2019, 09:48:42 AM
THANKS!   :D
Seconded!  This is a huge win for doing interesting things with cosmetic weapon mounts.  Much appreciated!

:D

That reads to me like basically full manual render order control where needed. Will this take precedence over "renderAboveAllWeapons"? I suppose the .wpn tag might not even be necessary with the render order mod setting, though, but I suppose it can't hurt to have options. Also, if we keep it, might be good to also have the counterpart "renderBelowAllWeapons"

Ah, renderBelowAllWeapons was already in place :) renderAbove/Below take precedence over other considerations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on February 12, 2019, 11:18:07 AM
Is there a comprehensive list of all renderhints somewhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 12, 2019, 11:29:04 AM
Wiki, maybe? I don't know. There's definitely some hidden stuff in .wpn files especially since there are some obscure-ish features that are either not used by vanilla or only used by one thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 12, 2019, 06:24:07 PM
Alex, thank you so much for renderOrderMod, that is a huge thing for us! I honestly thought it would never happen and was content with WEAPONS_FRONT_TO_BACK and WEAPONS_BACK_TO_FRONT but with the latest addition too? That is great, giving full manual control when we want to do something really complex, but also having those two recently added hints as well when we need some control but just want to sledgehammer fix it easily when full manual level of control is more than is needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 12, 2019, 07:43:29 PM
Awesome, glad to hear this sounds like it'll be useful!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Blothorn on February 13, 2019, 04:25:47 PM
Is there documentation on the AIFlags? (Right now I am specifically wondering whether I should be setting OK_TO_CANCEL_SYSTEM_USE_TO_VENT in a custom system/system AI for a toggle system.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 13, 2019, 09:16:24 PM
Is there documentation on the AIFlags?

There is not :) However iirc that flag is respected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on February 13, 2019, 11:26:41 PM
1. Is there any way not to bundle the sound effect(s) in mod (and not to write down sounds.json) if using/referring to only vanilla sounds? 'cause what worked in 0.8.1a doesn't work in 0.9. Specifically:
Code
Global.getSoundPlayer().playSound("ui_char_increase_skill", 1f, 1f, new Vector2f(), new Vector2f());
or
Code
Global.getSoundPlayer().playUISound("ui_char_increase_skill_new", 1f, 1f);
now require me to pack vanilla sound in my mod.
2. Also
Code
for (FactionAPI factionAPI :Global.getSector().getAllFactions()) {
CampaignFleetAPI fleet = FleetFactory.createGenericFleet(factionAPI.getId(), "nothing", 1.5f, 20 ); // (int)((float)Math.random()*500f+500f)
...
fails dramatically with
Code
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.Faction.pickShip(Unknown Source)
at com.fs.starfarer.campaign.Faction.pickShip(Unknown Source)
at com.fs.starfarer.campaign.Faction.pickShipAndAddToFleet(Unknown Source)
at com.fs.starfarer.campaign.Faction.pickShipAndAddToFleet(Unknown Source)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactory.createGenericFleet(FleetFactory.java:361)
Moreover, pickShipAndAddToFleet and pickShip are hardcoded and not exposed and can't be debugged futher (at least with my current skills).
That also worked in 0.8.1a.
Any help is highly appreciated, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 14, 2019, 03:47:53 AM
2. Also
Code
for (FactionAPI factionAPI :Global.getSector().getAllFactions()) {
CampaignFleetAPI fleet = FleetFactory.createGenericFleet(factionAPI.getId(), "nothing", 1.5f, 20 ); // (int)((float)Math.random()*500f+500f)
...
fails dramatically with
Code
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.Faction.pickShip(Unknown Source)
at com.fs.starfarer.campaign.Faction.pickShip(Unknown Source)
at com.fs.starfarer.campaign.Faction.pickShipAndAddToFleet(Unknown Source)
at com.fs.starfarer.campaign.Faction.pickShipAndAddToFleet(Unknown Source)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactory.createGenericFleet(FleetFactory.java:361)
pickShip() crashes if it can't find a ship for a particular role it wants (http://fractalsoftworks.com/forum/index.php?topic=14464.0). I suspect it wouldn't work in general for the "fake" factions like neutral and poor.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 14, 2019, 09:04:01 AM
1. Is there any way not to bundle the sound effect(s) in mod (and not to write down sounds.json) if using/referring to only vanilla sounds? 'cause what worked in 0.8.1a doesn't work in 0.9. Specifically:
Code
Global.getSoundPlayer().playSound("ui_char_increase_skill", 1f, 1f, new Vector2f(), new Vector2f());
or
Code
Global.getSoundPlayer().playUISound("ui_char_increase_skill_new", 1f, 1f);
now require me to pack vanilla sound in my mod.

Hmm - that doesn't seem right; it's really hard for me to see how that might happen. The game calls Global.getSoundPlayer().playSound() and Global.getSoundPlayer().playUISound() in numerous places, and that works - and functionally, that's equivalent from those getting called from a mod. I suspect something else is probably going wrong here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on February 15, 2019, 01:58:10 AM
Hmm - that doesn't seem right; it's really hard for me to see how that might happen. The game calls Global.getSoundPlayer().playSound() and Global.getSoundPlayer().playUISound() in numerous places, and that works - and functionally, that's equivalent from those getting called from a mod. I suspect something else is probably going wrong here.
Here is a plain test case, mod tries to play sound right after game loaded:
Code
public class Es_ModPlugin extends BaseModPlugin
{
...
public void onGameLoad(boolean newGame){
Global.getSoundPlayer().playUISound("colony_industry_shutdown", 1f, 1f);
Without explicit description in sounds.json yields:
Code
89878 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 32
89879 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 33
90491 [Thread-8] INFO  sound.O  - Cleaning up music with id [miscallenous_main_menu.ogg]
90639 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Sound set with id [colony_industry_shutdown]  not found
java.lang.RuntimeException: Sound set with id [colony_industry_shutdown]  not found
at com.fs.starfarer.Object.I.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatMain$3.playUISound(Unknown Source)
at data.scripts.Es_ModPlugin.onGameLoad(Es_ModPlugin.java:30)

That issue aside,
Is there a way to add some (short) text to "onmouseover-ship's-stats-systems-weapons" overlay (like in fleet, market and recovery menus) https://imgur.com/a/tFbWmnl (https://imgur.com/a/tFbWmnl)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 15, 2019, 06:36:42 AM
(https://i.imgur.com/eGOB8sJ.gif)

shield.setInnerRotationRate(shield.getRingRotationRate());


Hello, this method do not seems to work, or i use it badly. (I tried to give on the below shield, the same rotation)

Thank.


Also, the rotation become weird and sometime seems "glitch"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 15, 2019, 08:57:18 AM
Hmm - that doesn't seem right; it's really hard for me to see how that might happen. The game calls Global.getSoundPlayer().playSound() and Global.getSoundPlayer().playUISound() in numerous places, and that works - and functionally, that's equivalent from those getting called from a mod. I suspect something else is probably going wrong here.
Here is a plain test case, mod tries to play sound right after game loaded:
Code
public class Es_ModPlugin extends BaseModPlugin
{
...
public void onGameLoad(boolean newGame){
Global.getSoundPlayer().playUISound("colony_industry_shutdown", 1f, 1f);
Without explicit description in sounds.json yields:
Code
89878 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 32
89879 [Thread-4] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 33
90491 [Thread-8] INFO  sound.O  - Cleaning up music with id [miscallenous_main_menu.ogg]
90639 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Sound set with id [colony_industry_shutdown]  not found
java.lang.RuntimeException: Sound set with id [colony_industry_shutdown]  not found
at com.fs.starfarer.Object.I.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatMain$3.playUISound(Unknown Source)
at data.scripts.Es_ModPlugin.onGameLoad(Es_ModPlugin.java:30)

The sound id is ui_shutdown_industry, not colony_industry_shutdown. When I change it to ui_shutdown_industry in a test mod, it works fine.

Is there a way to add some (short) text to "onmouseover-ship's-stats-systems-weapons" overlay (like in fleet, market and recovery menus) https://imgur.com/a/tFbWmnl (https://imgur.com/a/tFbWmnl)?

There isn't, no - that bit of the UI is not set up to be configurable.


shield.setInnerRotationRate(shield.getRingRotationRate());

Hello, this method do not seems to work, or i use it badly. (I tried to give on the below shield, the same rotation)

Are you calling shield.setRadius()? That would reset the rotation rates.

Also, the rotation become weird and sometime seems "glitch"

I'm not sure what you mean so I can't really suggest anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 15, 2019, 12:21:38 PM
Well, thank, same if this thing do not work same with the fix, strangely. Maybe because this is a omni shield? (This is a bubble where i need to change the radius many times too ><)

Thank you. I will just keep my shield like that, so ^^.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 15, 2019, 12:45:42 PM
(This is a bubble where i need to change the radius many times too ><)

If you call setRadius(), that should be fine if you call setInnerRotationRate() and setRingRotationRate() afterwards. It's ok to do this continually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 15, 2019, 12:47:41 PM
(This is a bubble where i need to change the radius many times too ><)

If you call setRadius(), that should be fine if you call setInnerRotationRate() and setRingRotationRate() afterwards. It's ok to do this continually.

True, but a bit "boring" to need to reput also each frame, the sprite of the shield, who is reset just after a setRadius. But maybe because the shield do not save it, so maybe this is not very important. And i will do what you say ^^.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Asauski on February 15, 2019, 06:58:28 PM
Is there any way to get the current target of point defense weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 15, 2019, 08:09:08 PM
Yes; if the weapon is not under player control, get the AI instance, then call getTargetShip(); if that returns null, then the target is a CombatEntityAPI, and (unfortunately) you'll have to determine that by using getTarget() and then finding the CombatEntityAPI closest to that point (which is quite expensive).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 15, 2019, 08:42:26 PM
Ah, hmm - for the future, added to AutofireAIPlugin: MissileAPI getTargetMissile()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Asauski on February 15, 2019, 08:52:23 PM
Yes; if the weapon is not under player control, get the AI instance, then call getTargetShip(); if that returns null, then the target is a CombatEntityAPI, and (unfortunately) you'll have to determine that by using getTarget() and then finding the CombatEntityAPI closest to that point (which is quite expensive).

Perfect! After a quick test I saw that I just needed getTarget () because what was needed was to know where the gun was pointing. Thank you :D

Ah, hmm - for the future, added to AutofireAIPlugin: MissileAPI getTargetMissile()


That would also help a lot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on February 18, 2019, 04:37:14 AM
---snip---
The sound id is ui_shutdown_industry, not colony_industry_shutdown. When I change it to ui_shutdown_industry in a test mod, it works fine.
Alrrright, understood the gimmicks,  ui_shutdown_industry is working fine, but \sfx_interface\ui_char_increase_skill_new.ogg is not in core's sounds.json, And therefore it fails. Thus said, why it is not declared? Is it not being used at all in 0.9a?

Also,
Code
"ui_char_increase_skill_new":[
{"file":"../../starsector-core/sounds/ui/ui_char_increase_skill_new.ogg","pitch":1,"volume":1}
]
does not work. Am I root-bound to only mod's own directory?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 18, 2019, 05:14:09 AM
The game looks at the merged contents of core and mod folders. It'd be just
Code: json
"ui_char_increase_skill_new":[
{"file":"sounds/ui/ui_char_increase_skill_new.ogg","pitch":1,"volume":1}
]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 18, 2019, 09:31:46 AM
.. but \sfx_interface\ui_char_increase_skill_new.ogg is not in core's sounds.json, And therefore it fails. Thus said, why it is not declared? Is it not being used at all in 0.9a?

Correct. Anything that's being used, by definition, is going to be in sounds.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 19, 2019, 02:36:51 PM
Hey, no idea if this is a bug or intended, so i post that here:


Change the faction of a fleet maded with a another faction:
fleet.setFaction(GS_Constants.GSFACTION_ID, true);

Remove every weapons, wing, for just put empty layout on ships. The fleet spawn just near to the player, so i found that pretty weird.

No idea how fix that, because if i put every weapons/fighter on my special faction, i will found some mod faction fleet with others faction mods weapons.

Anything for disable the weird autovariant-after fleet bug? (for these specials fleets)

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 19, 2019, 02:52:39 PM
I'm not 100% sure I understand, but - try also setting the inflater params factionId to the new faction?

Something like:
DefaultFleetInflater inflater = (DefaultFleetInflater)fleet.getInflater()
((DefaultFleetInflaterParams)inflater.getParams()).factionId = <your faction id>

(Untested.)

Depending on how the fleet is created - if there's a factionId set in its FleetParamsV3 - the inflater params will also have the factionId set - which will determine which faction the fleet picks weapons from.

Or, perhaps - depending on what the problem/desired behavior is - maybe you need to set factionId in your FleetParamsV3 to the faction you want to be used when picking weapons etc, regardless of the fleet's current faction. I *think* that should work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 19, 2019, 03:03:18 PM
I'm not 100% sure I understand, but - try also setting the inflater params factionId to the new faction?

Something like:
DefaultFleetInflater inflater = (DefaultFleetInflater)fleet.getInflater()
((DefaultFleetInflaterParams)inflater.getParams()).factionId = <your faction id>

(Untested.)

Depending on how the fleet is created - if there's a factionId set in its FleetParamsV3 - the inflater params will also have the factionId set - which will determine which faction the fleet picks weapons from.

Or, perhaps - depending on what the problem/desired behavior is - maybe you need to set factionId in your FleetParamsV3 to the faction you want to be used when picking weapons etc, regardless of the fleet's current faction. I *think* that should work.

Code
[...]
        fleet = FleetFactoryV3.createFleet(new FleetParamsV3(
                null,
                relay.getLocationInHyperspace(),
                faction.getId(), // Always a real faction with weapon, etc
                null,
                FleetTypes.PERSON_BOUNTY_FLEET,
                content.getEndlessPower() + random, // combatPts
                0, // freighterPts
                0, // tankerPts
                0f, // transportPts
                0f, // linerPts
                0f, // utilityPts
                1f // qualityMod
        ));
        if (fleet == null) {
            endEvent();
            return;
        }

        fleet.setCommander(person);
        fleet.getFlagship().setCaptain(person);
        FleetFactoryV3.addCommanderSkills(person, fleet, null);

        Misc.makeImportant(fleet, GS_Constants.GSFACTION_ID, 120);
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PIRATE, true);
        fleet.setNoFactionInName(true);
        
        fleet.setFaction(GS_Constants.GSFACTION_ID, true); [...]

Here, sorry, i create the fleet with TryTachion, per exemple, he made every ships with only of this pool.

Then, when i change the faction to another faction who do not have weapon, ship or anything else, i got empty ships. If i remove the last line, i do not have any problem, just the wrong faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 19, 2019, 03:31:40 PM
Ah, looking into it, this is a bug that's fixed for 0.9.1a - the way you're doing it *should* work, but the 0.9a implementation of DefaultFleetInflater doesn't handle it. This is the same issue that causes "deserter" pirate fleets to only get pirate weapons instead of getting weapons from their original faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on February 20, 2019, 04:42:09 AM
Assuming I have some ships with not-so-transient buffs and one or more of ships gets disabled in combat AND there is option to recover them, how do I check if the ship is lost forever (if chosen not to be recovered) and needs to be stripped of buffs to prevent a memory leak?
There seems to be some radical under-the-hood change in 0.9a that makes this (btw, worked in 0.8.1):
Code: java
if ( lastMember.getFleetData() == null &&
lastMember.getFleetData().getFleet() == null ||
lastMember.getFleetData().getFleet().isAIMode() ||
                    !lastMember.getFleetData().getFleet().isAlive())
to cause getFleetData() to produce NPE (why, oh WHY can't it be just null?) since your own to-be-recovered ship does not have associated fleetData (I have checked that in debugger). Is that "no fleetData on player's to-be-recovered ships" intentional?
The issue does not manifest on NPC fleets' ships, only when recovering player's ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 20, 2019, 08:14:16 AM
To be honest, I'm not 100% sure I understand what you're asking, but there appears to be a bug in your code:

lastMember.getFleetData() == null && 
                  lastMember.getFleetData().getFleet() == null

I don't think you want && here, since it'll NPE on lastMember.getFleetData().getFleet() whenever getFleetData() returns null. You probably want ||.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on February 20, 2019, 10:00:52 PM
Is there any way to get at the ship objects that are used to generate images for the fleet view?

Specifically, I'm working on building a thing that will mirror weapons; it's pretty straightforward to do this with an EveryFrameWeaponPlugin (with a boolean runOnce check), and that works fine for in combat or in the outfitting screen - but the weapons show up un-mirrored in the scrolling list of ships to the left of the outfitting screen or in the fleet view, where, as far as I can tell, EveryFrameWeaponEffectPlugin.advance() is never called.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 20, 2019, 10:10:01 PM
It's not, no - those are a bit special in that they're (mostly) not associated with a combat engine instance and exposing those... well, at a glance it seems like it'd get pretty complicated. They *are* based off the variant, though, so changing that would be the way to go if that's an option.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on February 20, 2019, 10:30:29 PM
Well that's unfortunate; I don't see anything in ShipVariantAPI that would let me do what I need to for mirroring weapon sprites.

The closest I can come up with at the moment would be to have two versions of a weapon, one with the sprite pre-mirrored, and swap them out, but that seems like it'd run into all sorts of other issues when you'd have, say, effectively-identical hellbore and hellbore_m weapons that could end up in your cargo holds, for example.  Plus it wouldn't play well with, say, any other mod deciding to do some custom fleet generation, or adding variants that don't have the mirrored versions already correctly set...

If it helps any, I don't -actually- need the ship objects at all; that was just a convenient reference point for finding the things I do need: which are the WeaponSlotAPI and SpriteAPI objects for each of the weapons I'm looking at (potentially) mirroring.  (WeaponSlotAPI has the relative ship coordinates that let me ask "is this gun on the left side of the ship?", and SpriteAPI is what I need to actually do a horizontal flip of the graphics.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kittah Khan on February 21, 2019, 12:19:20 AM
Is there a way to get access to a weapon or projectile's glow/etc colors?
That way, the emp on hit script could just read the weapon/projectile to set the arc color instead of a hardcoded value.

EDIT Right, weapon getSpec does the job for weapon glow color. No way to get anything beyond the projectile spec id, though?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2019, 10:16:40 AM
Well that's unfortunate; I don't see anything in ShipVariantAPI that would let me do what I need to for mirroring weapon sprites.

The closest I can come up with at the moment would be to have two versions of a weapon, one with the sprite pre-mirrored, and swap them out, but that seems like it'd run into all sorts of other issues when you'd have, say, effectively-identical hellbore and hellbore_m weapons that could end up in your cargo holds, for example.  Plus it wouldn't play well with, say, any other mod deciding to do some custom fleet generation, or adding variants that don't have the mirrored versions already correctly set...

If it helps any, I don't -actually- need the ship objects at all; that was just a convenient reference point for finding the things I do need: which are the WeaponSlotAPI and SpriteAPI objects for each of the weapons I'm looking at (potentially) mirroring.  (WeaponSlotAPI has the relative ship coordinates that let me ask "is this gun on the left side of the ship?", and SpriteAPI is what I need to actually do a horizontal flip of the graphics.)

I saw you start the other thread - could you clarify exactly what you're doing, there? I'm unclear by what you mean by mirroring, exactly how you're doing the rendering, etc. Still probably no easy way to expose this, but since I don't quite get the situation, I can't say 100%.


Is there a way to get access to a weapon or projectile's glow/etc colors?
That way, the emp on hit script could just read the weapon/projectile to set the arc color instead of a hardcoded value.

EDIT Right, weapon getSpec does the job for weapon glow color. No way to get anything beyond the projectile spec id, though?

Ah, right - made a note to add ProjectileSpecAPI to the API. Surprised this hasn't come up before, really.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 23, 2019, 01:59:34 AM
For NPC markets, is there any gameplay difference between market.setFreePort(true) and adding the free port market condition directly?

I ask because I just found a Nexerelin-related bug where if you call market.setFreePort(true) on a market that already has the free port condition, a second free port condition is added causing all the bonuses/penalties to be doubled.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 23, 2019, 09:13:33 AM
Generally, you should only manage free port status using setFreePort() - there's an internal boolean keeping track of whether it's a free port, and these methods keep both that and the presence of the condition in sync.

The bug you're describing could happen if, say, the FreeMarket condition was added manually, and then setFreePort(true) was called. Since the boolean would still be false at that point, that method would assume there's no free port and would add the condition again.

(There's also a bug - which IIRC you brought to my attention - where calling setFreePort(true) on a market without a spaceport will result in the condition self-removing but the boolean flag being set to true, which would make a subsequent call to setFreePort(true) fail even after a spaceport is constructed. That bug is fixed.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 23, 2019, 11:10:49 AM

Has anything changes with hiring officers?? I know admins were added but that is a separate rule. I'm getting index out of bounds when I call "CallEvent $ome_eventRef printSkills $id" but nothing in my code changes that to my knowledge, I just have custom rules that call it for my factions officers.


Figured this one out. It wasn't that script, it was a couple scripts in subsequent rule entries that weren't passing in $id (must have changed from .8 to .9)

To be safe, I also added in each relevant rule relating to admins, and I can hire faction officers and admins normally now.


In .9, however, that same transaction is done when a player simply docks at a market in the market description text. So I am wondering if that is just a separate ruleset that those missions now require, and if so, is the old way in .8 and its related rules now deprecated in favor of the new system.

Unless I'm missing something, that seems incorrect. Bar delivery missions end on market interaction, but procurement missions - which involve a specific person - iirc still require getting in touch via the comm directory.

Ok, so I dug into this a little more and as it turns out there are some exceptions and I'm not sure what causes them. I'm going to post some screenshots to show you what I mean.

Most procurement missions that are generated in intel (as opposed to a bar mission) do generate an NPC with a quest marker in the commboard of the mission delivery market, but not all. I think it may be based on the commodity requested, but I'm honestly not sure.

All bar event missions seem to operate on market interface though, and never on the commboard interface.

Images in spoiler
Spoiler
(https://i.imgur.com/cq2NByt.png)
(https://i.imgur.com/dl9Wzt9.png)
(https://i.imgur.com/MhwkGzG.png)
(https://i.imgur.com/zSoUly2.png)
(https://i.imgur.com/WAHx7qL.png)
(https://i.imgur.com/sFfsmwW.png)
(https://i.imgur.com/gpF8o0P.png)
[close]

I'm going to keep investigating why these types of mission don't seem to be returnable on faction planets.

I will say that though I haven't completely confirmed this yet, I notice it happening the most on stations. Some stations are set to orbit entities like a Gate, rather than a planet or the star at the center. Would that potentially cause problems?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 23, 2019, 12:50:24 PM
I'm going to keep investigating why these types of mission don't seem to be returnable on faction planets.

I will say that though I haven't completely confirmed this yet, I notice it happening the most on stations. Some stations are set to orbit entities like a Gate, rather than a planet or the star at the center. Would that potentially cause problems?

If you haven't already, I'd suggest looking at ProcurementMissionIntel.java. Taking a look myself just now, it doesn't look possible - a PersonAPI for the "contact" is created when the intel is created, and is then added to the comm directory first thing in missionAccepted().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 23, 2019, 02:32:46 PM
If you haven't already, I'd suggest looking at ProcurementMissionIntel.java. Taking a look myself just now, it doesn't look possible - a PersonAPI for the "contact" is created when the intel is created, and is then added to the comm directory first thing in missionAccepted().

edit* I will look in that source file too and see what I can find

Sure, I definitely get what you are saying, but that doesn't mean the interface for the turn-in script is triggered at the commboard level upon specific interaction with that PersonAPI. You can call the PersonAPI during inital market interaction with the MarketAPI just as easily, right?

I removed all mods and just ran umodded Starsector for examples of what I am talking about.

Here are screens of both types of intel-spawned procurement missions occurring without any mods running:

Spoiler
(https://i.imgur.com/6iRgkTh.png)
(https://i.imgur.com/Qq2OL7f.png)
(https://i.imgur.com/9cYkPQg.png)
(https://i.imgur.com/ZihYRcR.png)
(https://i.imgur.com/oRFJLfe.png)
(https://i.imgur.com/vHAjNfO.png)
(https://i.imgur.com/cMGk3vC.png)
(https://i.imgur.com/PTLe7bz.png)
(https://i.imgur.com/4xGKOoC.png)
(https://i.imgur.com/lBiFT7q.png)
(https://i.imgur.com/4Wl6Bmc.png)
[close]

As you can see, though both missions are accepted the same way through the intel UI, the first procurement mission is turned in through the commboard via the PersonAPI. I couldn't turn it in at the time because it was from pirates and my transponder was on.

The second mission for the Independents is turned in upon docking with the market.

That has to be a different script, and I believe it is that script that is failing for faction markets. There has to be something set in the initial script that determines which turn in interface is used, unless it is just randomly chosen in Rules based on two rule sets that operate off the same trigger. That seems unlikely, though, since the triggers for market interaction and commboard interaction would be different I'd imagine. I can't honestly see if there is still a PersonAPI generated as the contact- because it never lets me get to the commboard in this case. It is noteworthy that a quest marker is still present. The traditional commboard PersonAPI missions seem to work fine in the mod, however, and bugged missions do not have a PersonAPI with a quest marker and no quest marker shows on the market either.

I also now know it doesn't matter what commodity it is. Here is another unmodded example of Heavy Armaments that is turned in at the commboard level instead of the market level:

Spoiler
(https://i.imgur.com/TpM4pYB.png)
(https://i.imgur.com/84VgC3C.png)
(https://i.imgur.com/72vjdKy.png)
(https://i.imgur.com/nXBHHIM.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 23, 2019, 10:31:02 PM
Ahh I finally see what you're talking about - I'm sorry, it wasn't really clicking.

This code in ProcurmentMissionIntel will make it so that the contact will initiate comms when you dock with a market:

if (contactWillInitiateComms) {
   contact.incrWantsToContactReasons();
}

What was confusing me is that this contact is still in the comm directory, and you can still turn in via the comm directory if you refuse the connection, so this isn't a case of the contact *not* being in the comm directory.

There's a 50% chance the procurement contact NPC will try to get in touch.

The rule commands you want to look for, then, are:

NPCWantsComms -> which returns whether any NPC on the colony (not in the comm directory, but added via market.addPerson(), which ProcurementMissionIntel does) wants to contact the player

PickCommsNPC -> which picks, and sets as the active person, one of the NPCs that wants to contact the player

... I'm not sure if this is actually helpful, but hopefully this'll at least point you towards what to look at.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 25, 2019, 05:00:10 AM
Hi, after have add a third bar on my player HUD, i search to add it on the top right of the player ship.

Spoiler
(https://i.imgur.com/WcHrlid.png)
[close]

If i have the zoom who go to 0.5 to 2 for frigate/destroyer and 0.75 to 2.25 for cruiser/capital
I do not found what they use for have the constant offset for these ships. They do not seems to depends of the width/height of the sprite or the collision radius.
What value you use for put the flux/hull bar on the topright of the player ship?(Except the zoom)

I search to apply that also on the target of the player ship, but, i suppose than they will be pretty simple, if i do already for the player ship.



Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 25, 2019, 05:05:48 AM
Is there a way to have a rules interaction dialog refresh its memory map?

Specific issue: After a market is captured by the player in Nexerelin, the memory references still point to the old faction, so the check $faction.id != player for whether to display the "Consider your military options" option returns true.
I'm thinking of hacking it by making it also check for a "was this market just captured?" memory value, but I'm wondering if there's a better way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 09:19:55 AM
Hi, after have add a third bar on my player HUD, i search to add it on the top right of the player ship.

Spoiler
(https://i.imgur.com/WcHrlid.png)
[close]

If i have the zoom who go to 0.5 to 2 for frigate/destroyer and 0.75 to 2.25 for cruiser/capital
I do not found what they use for have the constant offset for these ships. They do not seems to depends of the width/height of the sprite or the collision radius.
What value you use for put the flux/hull bar on the topright of the player ship?(Except the zoom)

I search to apply that also on the target of the player ship, but, i suppose than they will be pretty simple, if i do already for the player ship.



Thank you.

It's... dynamic and fairly complicated. Might be too much to try to emulate - especially when you consider that these will move relative to the ship to stay on-screen as the ship moves off-screen. It's based on the shield radius, though.


Is there a way to have a rules interaction dialog refresh its memory map?

Specific issue: After a market is captured by the player in Nexerelin, the memory references still point to the old faction, so the check $faction.id != player for whether to display the "Consider your military options" option returns true.
I'm thinking of hacking it by making it also check for a "was this market just captured?" memory value, but I'm wondering if there's a better way.

There's an UpdateMemory command, which should do it. If you need to do it in code, you could also do:

((RuleBasedDialog) dialog.getPlugin()).updateMemory();

Which is what UpdateMemory does.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 25, 2019, 10:16:39 AM
Ahh I finally see what you're talking about - I'm sorry, it wasn't really clicking.

This code in ProcurmentMissionIntel will make it so that the contact will initiate comms when you dock with a market:

if (contactWillInitiateComms) {
   contact.incrWantsToContactReasons();
}

What was confusing me is that this contact is still in the comm directory, and you can still turn in via the comm directory if you refuse the connection, so this isn't a case of the contact *not* being in the comm directory.

There's a 50% chance the procurement contact NPC will try to get in touch.

The rule commands you want to look for, then, are:

NPCWantsComms -> which returns whether any NPC on the colony (not in the comm directory, but added via market.addPerson(), which ProcurementMissionIntel does) wants to contact the player

PickCommsNPC -> which picks, and sets as the active person, one of the NPCs that wants to contact the player

... I'm not sure if this is actually helpful, but hopefully this'll at least point you towards what to look at.

Thanks yeah that was helpful! My own rules regarding the MarketPostOpen trigger also had a weight of 1000 under the "faction.id ==" condition so I'm pretty sure I was overriding the rule for NPCs wanting to speak with you at the market level.

That still doesn't explain how the NPC wasn't there though.

I am going to try and reproduce that now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 25, 2019, 10:32:45 AM
Hi, after have add a third bar on my player HUD, i search to add it on the top right of the player ship.

Spoiler
(https://i.imgur.com/WcHrlid.png)
[close]

If i have the zoom who go to 0.5 to 2 for frigate/destroyer and 0.75 to 2.25 for cruiser/capital
I do not found what they use for have the constant offset for these ships. They do not seems to depends of the width/height of the sprite or the collision radius.
What value you use for put the flux/hull bar on the topright of the player ship?(Except the zoom)

I search to apply that also on the target of the player ship, but, i suppose than they will be pretty simple, if i do already for the player ship.



Thank you.

It's... dynamic and fairly complicated. Might be too much to try to emulate - especially when you consider that these will move relative to the ship to stay on-screen as the ship moves off-screen. It's based on the shield radius, though.


Ok, thank, i will do try to add a another HUD, so. Just need to try some thing, for get a correct
Spoiler
(https://i.imgur.com/XR3rHzC.png)
[close]
On my idea, this is like that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 25, 2019, 10:52:52 AM
(https://i.imgur.com/sBpkqqG.png)
I use OpenGL to make a mask come true and render it in renderInWorldCoords, but it seems the damage number renders before BaseEveryFrameCombatPlugin ???
could the render order be changed?
My main scripts:
Spoiler
Code: java
public void render() {
            SpriteAPI mask = Global.getSettings().getSprite("holyGrail", "mask");
            SpriteAPI spin = Global.getSettings().getSprite("holyGrail", "spin");
            SpriteAPI spin2 = Global.getSettings().getSprite("holyGrail", "spin");
            Vector2f loc = ship.getLocation();
            Vector2f computePosition = anchorSlot.computePosition(ship);
            Vector2f spinPosition = MathUtils.getPointOnCircumference(computePosition, 60f, ship.getFacing());
            mask.setAngle(ship.getFacing() - 90f);
            float rotate1 = ship.getFacing() - 90f + spinRotation;
            float rotate2 = ship.getFacing() - 90f - spinRotation;

            float w = ship.getCollisionRadius() * 2f;
            float h = w;


            GL11.glColorMask(false, false, false, true);

            GL11.glPushMatrix();
            GL11.glTranslatef(loc.x, loc.y, 0);
            Misc.renderQuadAlpha(0 - w / 2f - 1f, 0 - h / 2f - 1f, w + 2f, h + 2f, Misc.zeroColor, 0f);
            GL11.glPopMatrix();

            spin.setAngle(rotate1);
            spin.renderAtCenter(spinPosition.x, spinPosition.y);

            mask.setBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_ALPHA);
            mask.renderAtCenter(computePosition.x, computePosition.y);

            GL11.glColorMask(true, true, true, false);
            spin.setBlendFunc(GL11.GL_DST_ALPHA, GL11.GL_ONE_MINUS_DST_ALPHA);
            spin.setAngle(rotate1);
            spin.setColor(new Color(100, 100, 100));
            spin.renderAtCenter(spinPosition.x, spinPosition.y);


            GL11.glColorMask(false, false, false, true);

            GL11.glPushMatrix();
            GL11.glTranslatef(loc.x, loc.y, 0);
            Misc.renderQuadAlpha(0 - w / 2f - 1f, 0 - h / 2f - 1f, w + 2f, h + 2f, Misc.zeroColor, 0f);
            GL11.glPopMatrix();

            spin2.setAngle(rotate2);
            spin2.renderAtCenter(spinPosition.x, spinPosition.y);

            mask.setBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_ALPHA);
            mask.renderAtCenter(computePosition.x, computePosition.y);

            GL11.glColorMask(true, true, true, false);
            spin2.setBlendFunc(GL11.GL_DST_ALPHA, GL11.GL_ONE_MINUS_DST_ALPHA);
            spin2.setAngle(rotate2);
            spin2.renderAtCenter(spinPosition.x, spinPosition.y);
        }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 25, 2019, 12:22:06 PM
Ok, so Intel Procurement missions seem fine from a few test runs.

Bar missions, however, are not.

It seems to find the market in the description U.I just fine, and points to the correct system. No NPC is generated at that market, however, and a quest market doesn't appear either.

Spoiler
(https://i.imgur.com/mCqcRAQ.png)
(https://i.imgur.com/q4Wnt6m.png)
(https://i.imgur.com/XDfNSbb.png)
(https://i.imgur.com/ikZuMAF.png)
[close]

Are these also handled in ProcurementMissionIntel? Or are bar events separate?


EDIT*

Well, they work if the destination market is a non-faction market. It is probably another case of me overriding MarketPostOpen unintentionally, so I'll have to find the entry for bar mission turn ins in Rules.

As it turns out, bar procurement missions don't generate a quest marker or npc ever. They just complete when you dock at the market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 12:57:48 PM
I use OpenGL to make a mask come true and render it in renderInWorldCoords, but it seems the damage number renders before BaseEveryFrameCombatPlugin ???
could the render order be changed?

(Edited your post to add code=java to make it more readable, btw.)

You know, I might as well make it possible - I think a lot of mods might get some use out of this, and it's already doable in the campaign.

Added support for rendering at different layers in combat using a custom combat entity
   Added to CombatEngineAPI:
      void removeObject(Object object);
   void addLayeredRenderingPlugin(CombatLayeredRenderingPlugin plugin);
   Added CombatLayeredRenderingPlugin interface:
      public void init();
      public void cleanup();
      public boolean isExpired();
      public void advance(float amount);
      public EnumSet<CombatEngineLayers> getActiveLayers();
      public float getRenderRadius();
      public void render(CombatEngineLayers layer, ViewportAPI viewport);
   Added BaseCombatLayeredRenderingPlugin
   Added CombatEngineLayers enum


In action:
https://twitter.com/amosolov/status/1100136541576413189

Ok, so Intel Procurement missions seem fine from a few test runs.

Bar missions, however, are not.

It seems to find the market in the description U.I just fine, and points to the correct system. No NPC is generated at that market, however, and a quest market doesn't appear either.

Are these also handled in ProcurementMissionIntel? Or are bar events separate?


EDIT*

Well, they work if the destination market is a non-faction market. It is probably another case of me overriding MarketPostOpen unintentionally, so I'll have to find the entry for bar mission turn ins in Rules.

As it turns out, bar procurement missions don't generate a quest marker or npc ever. They just complete when you dock at the market.

Right, yes, bar missions are entirely separate. You can search for "delivery" in rules.csv - or for some of the text - should let you find the relevant rules pretty quick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 25, 2019, 01:30:42 PM

Ok, so Intel Procurement missions seem fine from a few test runs.

Bar missions, however, are not.

It seems to find the market in the description U.I just fine, and points to the correct system. No NPC is generated at that market, however, and a quest market doesn't appear either.

Are these also handled in ProcurementMissionIntel? Or are bar events separate?


EDIT*

Well, they work if the destination market is a non-faction market. It is probably another case of me overriding MarketPostOpen unintentionally, so I'll have to find the entry for bar mission turn ins in Rules.

As it turns out, bar procurement missions don't generate a quest marker or npc ever. They just complete when you dock at the market.

Right, yes, bar missions are entirely separate. You can search for "delivery" in rules.csv - or for some of the text - should let you find the relevant rules pretty quick.


I think I finally got it. Or, I'm at least very close.

The original set of rules in .8 relating to MarketOpenDefault fire the script "FireBest MarketPostOpen" but as I'm looking at it now the new rules for .9 instead fire the script "FireBest MarketPostDock"

The rule entries for turning in bar event missions are under MarketPostDock, as I think is crew leaving because of debt, and so forth, so I am assuming that after anything related to those rules is completed the next script fired is "FireBest MarketPostOpen" to go back to the original market menu?

My custom rules entries for Faction markets were ported from .8 and were still firing MarketPostOpen and so were circumventing the turn in scripts.

When I change those scripts to fire "MarketPostDock" the turn-in script indeed fires, but I am getting a nullpointer when redocking for some reason.

Still, progress...


*EDIT*

Yup, I got it. :)

"FireBest MarketPostOpen" still needs to be fired from any "MarketOpen" Rules, but now instead of the "PostMarketOpen" rules firing "FireAll PopulateOptions" it fires "FireBest MarketPostDock" and the default of that set of rules fires "FireAll PopulateOptions" if nothing else, such as a turn-in from a bar event, is active.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 01:38:37 PM
If you look at the rule with id marketDock, that's the "default" rule that triggers - other MarketPostDock-trigger rules have higher scores and go first. They generally call FireBest MarketPostDock when they finish, so it'll just go through every matching MarketPostDock rule in order of score until it gets to the marketDock rule which'll populate the standard options. Or until it gets to a rule that doesn't call FireBest MarketPostDock.

MarketPostDock comes after MarketPostOpen. The reason for separating them out is MarketPostOpen prints some text describing the approach to the market and its description, and we don't want to keep doing that for every special. So, MarketPostOpen fires once and then calls MarketPostDock, which can recurse for a bit until it finally settles down to providing the standard options, if that makes sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 25, 2019, 01:44:44 PM
^

Thanks! I just got done digging through it and essentially made the same discovery. :) (see edit for details)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 01:51:46 PM
Ah yes, excellent :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 25, 2019, 01:52:53 PM
For be sure, this thing will not cause any issues?

This is a video:
https://imgur.com/gZIYWoT
And also, like i have just see the 0.9.1 hotfix will add combat render layer, i suppose than i can put this thing on the same layer than the other, no?
For fix it:
Spoiler
(https://i.imgur.com/RlKaTAC.png)
[close]
(And do not need to hidden it when i want deploy more ship)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 02:21:56 PM
For be sure, this thing will not cause any issues?

I think? Hard to say for sure but it seems like it ought to work.

And also, like i have just see the 0.9.1 hotfix will add combat render layer, i suppose than i can put this thing on the same layer than the other, no?

No - the topmost layer that combat entities get rendered at is just below this kind of UI stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 25, 2019, 02:25:54 PM
Thank you  :)


A bit sad for the UI stuff, but meh. This is life. And sometimes i need to do with life.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 25, 2019, 05:05:42 PM
Alex thank you so much for the upcoming control over render order for scripted things in combat, that is huge! Like really huge, it is groundbreaking actually :)

For years now we have designed so much stuff around enforced render order, often times having to painstakingly do things in a very specific way to make it work that also eats Vram like blackhole heh. This will not only allow doing many things more efficiently but also doing stuff we simply never could before as well. You have my deepest thank you, for this and some other goodies getting added in 0.9.1 easily makes it one of if not the best patch for the Modiverse ever.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 06:28:28 PM
Excellent - glad to hear it's going to be put to good use :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on February 25, 2019, 06:43:42 PM
Added support for rendering at different layers in combat using a custom combat entity
   Added to CombatEngineAPI:
      void removeObject(Object object);
   void addLayeredRenderingPlugin(CombatLayeredRenderingPlugin plugin);
   Added CombatLayeredRenderingPlugin interface:
      public void init();
      public void cleanup();
      public boolean isExpired();
      public void advance(float amount);
      public EnumSet<CombatEngineLayers> getActiveLayers();
      public float getRenderRadius();
      public void render(CombatEngineLayers layer, ViewportAPI viewport);
   Added BaseCombatLayeredRenderingPlugin
   Added CombatEngineLayers enum

In action:
https://twitter.com/amosolov/status/1100136541576413189

This is awesome! What are the values of CombatEngineLayers? I'm wondering how granular this is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 07:07:40 PM
Code: java
public enum CombatEngineLayers {
PLANET_LAYER,
ABOVE_PLANETS,
CLOUD_LAYER,
BELOW_SHIPS_LAYER,
UNDER_SHIPS_LAYER,
ASTEROIDS_LAYER,
CAPITAL_SHIPS_LAYER,
CRUISERS_LAYER,
DESTROYERS_LAYER,
FRIGATES_LAYER,
BELOW_PHASED_SHIPS_LAYER,
PHASED_SHIPS_LAYER, //need to be below fighters to avoid artifacts when phasing back in
STATION_WEAPONS_LAYER,
CONTRAILS_LAYER,
FIGHTERS_LAYER,
BELOW_INDICATORS_LAYER,
FF_INDICATORS_LAYER,
ABOVE_SHIPS_LAYER,
ABOVE_SHIPS_AND_MISSILES_LAYER,
JUST_BELOW_WIDGETS,
}

I'm a bit hesitant to add more since it could have performance implications, but could perhaps add one or two more if it seems necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 25, 2019, 08:13:27 PM
You know, I might as well make it possible - I think a lot of mods might get some use out of this, and it's already doable in the campaign.

Added support for rendering at different layers in combat using a custom combat entity
   Added to CombatEngineAPI:
      void removeObject(Object object);
   void addLayeredRenderingPlugin(CombatLayeredRenderingPlugin plugin);
   Added CombatLayeredRenderingPlugin interface:
      public void init();
      public void cleanup();
      public boolean isExpired();
      public void advance(float amount);
      public EnumSet<CombatEngineLayers> getActiveLayers();
      public float getRenderRadius();
      public void render(CombatEngineLayers layer, ViewportAPI viewport);
   Added BaseCombatLayeredRenderingPlugin
   Added CombatEngineLayers enum


In action:
https://twitter.com/amosolov/status/1100136541576413189

Wow that's great, so all widgets means UI stuffs including float damage text right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 08:16:10 PM
Wow that's great, so all widgets means UI stuffs including float damage text right?

Right, the floating text would be above everything that's rendered using a CombatLayeredRenderingPlugin, but below target reticles, hull/flux bar indicators, and the rest of the UI. So floating text is separate - it's above the engine stuff, but below the UI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 25, 2019, 08:37:59 PM
Code: java
public enum CombatEngineLayers {
PLANET_LAYER,
ABOVE_PLANETS,
CLOUD_LAYER,
BELOW_SHIPS_LAYER,
UNDER_SHIPS_LAYER,
ASTEROIDS_LAYER,
CAPITAL_SHIPS_LAYER,
CRUISERS_LAYER,
DESTROYERS_LAYER,
FRIGATES_LAYER,
BELOW_PHASED_SHIPS_LAYER,
PHASED_SHIPS_LAYER, //need to be below fighters to avoid artifacts when phasing back in
STATION_WEAPONS_LAYER,
CONTRAILS_LAYER,
FIGHTERS_LAYER,
BELOW_INDICATORS_LAYER,
FF_INDICATORS_LAYER,
ABOVE_SHIPS_LAYER,
ABOVE_SHIPS_AND_MISSILES_LAYER,
JUST_BELOW_WIDGETS,
}

I'm a bit hesitant to add more since it could have performance implications, but could perhaps add one or two more if it seems necessary.

Awesome, that is even more granular than I was guessing it would be. Well, the only one I could think of to ask for Alex would be BELOW_PLANETS. Is it *needed* per say? No, but it could do some really useful and immersive things, here are some examples.

This one is a spoiler to something in a mod, viewer beware!
Spoiler
- Making the mega structure artificial rings in the Tyrador Safeguard Coalition mod also show in combat, not just the campaign.
(https://cdn.discordapp.com/attachments/402202419863355393/546150878911004745/SPOILER_unknown.png)

[close]
- Battles going on in the far background as part of selling a huge battle as part of a quest, explosions and stuff and with enough creativity maybe even more.
- Animated backgrounds, not in full would eat too much Vram. But animating parts of them.
- Various unusual star system background elements represented in combat.
- Blah blah the list goes on.

Anyways, least as far as I can tell being able to place something behind a planet is the only thing missing from that list and it would have a fair few use cases :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2019, 09:22:01 PM
Ah - PLANET_LAYER is actually a bit outdated and refers to the layer that non-background planets are on, which are, afaik, only used in the title screen at this point. The background planet(s) is/are rendered before any entities (and therefore anything using this type of plugin), so this approach wouldn't work for that at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 25, 2019, 09:47:14 PM
Ah I see, well was worth a shot asking.

Anyways maybe someone else will have an idea for a new render layer that they could use. But at least as far as I can imagine things that one which is impossible would be the only one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on February 26, 2019, 12:21:43 AM
YES
FINALLY

You cannot understand how glad I am this is finally becoming an option; I don't even mind how much work re-writing all render scripts to use this approach is gonna be, it's invaluable for rendering things in natural ways. Maybe most importantly, I can finally render non-additive effects without worrying about completely clipping off other effects.

MagicLib's trail plugin will be updated within a day or two max after the new patch, mark my words. If Tartiflette doesn't beat me to it, MagicRender will most likely get the same treatment
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 26, 2019, 04:43:56 AM
Is there a way to tell if a ship has broken up on death, within the EveryFrameWeaponEffectPlugin of a weapon attached to the ship?

It seems that it takes many frames (up to 10 in my most recent test) between ShipAPI.isHulk() returning true and ShipAPI.isPiece() returning true, and by the time isPiece returns true the plugin's advance() method is no longer being called...
I'd ask the fleet manager, but I can't seem to get the FleetMemberAPI from the ShipAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2019, 11:18:42 AM
Ah I see, well was worth a shot asking.

Yeah, no harm in asking - could see doing this as a separate thing at some point.


YES
FINALLY

You cannot understand how glad I am this is finally becoming an option; I don't even mind how much work re-writing all render scripts to use this approach is gonna be, it's invaluable for rendering things in natural ways. Maybe most importantly, I can finally render non-additive effects without worrying about completely clipping off other effects.

MagicLib's trail plugin will be updated within a day or two max after the new patch, mark my words. If Tartiflette doesn't beat me to it, MagicRender will most likely get the same treatment

Awesome! Really glad this is looking useful.


Is there a way to tell if a ship has broken up on death, within the EveryFrameWeaponEffectPlugin of a weapon attached to the ship?

It seems that it takes many frames (up to 10 in my most recent test) between ShipAPI.isHulk() returning true and ShipAPI.isPiece() returning true, and by the time isPiece returns true the plugin's advance() method is no longer being called...
I'd ask the fleet manager, but I can't seem to get the FleetMemberAPI from the ShipAPI.

This is actually tricky. What happens is when a ship breaks up, there's a ShipBreakingAnimation that starts, with the goal being to spread the computationally-expensive ship-splitting calculations over several frames. However, it's possible for an attempt to split the ship into pieces to fail, if it's unable to generate a valid set of pieces. Since that process involved randomness, it's... random whether a specific hull will successfully split or not; failures don't happen often but they do happen. I believe the ship would still be flagged as "destroyed" post-combat in this case, though.

Hmm - could you perhaps add a new script to the engine when the weapon detects the ship isHulk() and then wait a half second to see if it becomes a piece or not? Depends on what you actually need to do; let me know and I could probably add some more API support here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on February 26, 2019, 01:20:27 PM
Hi
No see nowhere, but with the new Inflater system, we got so many crash because of some error from modders. (Like me.)
But they crash on campaign, and sometimes, modders do not seems them.
While the inflater crash( the famous than you have see maybe everywhere), do not send any ID string of the culprit.

This is for know if you have added a log before the nullpointerexception for indicate what ship/wing/weapon caused the crash.
Just a line to add, but so much for everyone.

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2019, 01:35:22 PM
Yes, I did this - the exception there should include the type and id of the thing that's missing. For example for fighters it should say:

Fighter wing with spec id [" + wingId + "] not found
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Machine on February 26, 2019, 04:35:37 PM
Ah I see, well was worth a shot asking.

Yeah, no harm in asking - could see doing this as a separate thing at some point.


And for the reason Mesotronik pointed, I would greatly appreciate it ;). To be honest, I would also try and find more ways to abuse it, it's just too cool (in relation to all the render order stuff), to not do so.

Imagines several repeating sprites that go above the ship layers all across the map, and also similar, but darker and smaller, sprites on the background, with a planet in the middle, meanwhile 2 fleets battle between them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2019, 04:42:47 PM
Ohh, this would make a tiling "ground" type background possible, wouldn't it...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 26, 2019, 09:28:52 PM
Is there an easy way to have beams cause hard flux?

I haven't done this in my mod and I'm wondering if there is an example of that in unmodded starsector yet or if that has been added into the weapon file as a setting at all.

----
Can the plug-in parameters of the special_items.csv file be a comma separated list, or can it only accept one bp tag? Someone reported one of my bp packages as coming up empty and I'm wondering if that caused it.

Ohh, this would make a tiling "ground" type background possible, wouldn't it...

Hmm, that wasn't lost on me. That may have just made it more possible for me to mod in ground battles in the future. If so, I appreciate it! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on February 26, 2019, 09:42:12 PM
Is there an easy way to have beams cause hard flux?

I haven't done this in my mod and I'm wondering if there is an example of that in unmodded starsector yet or if that has been added into the weapon file as a setting at all.

Not in vanilla, but I believe Tyrador has such a weapon. That'd be the place to look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 27, 2019, 01:27:15 AM
What exactly does a Faction or a Market set up for a Faction need to do to:

1.  Sell ships on the Open Market?
2.  Military Market?
3.  Not sell generic (D) junk on the Black Market, but use their own custom stuff?
4.  Create Patrols?

I have everything else working in EZ Faction again, but testing brought up these issues.  Can "fix" by writing my own script to create these things in the Markets / Systems, but I'd prefer to work within the Vanilla design here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 27, 2019, 02:50:31 AM
Right, the floating text would be above everything that's rendered using a CombatLayeredRenderingPlugin, but below target reticles, hull/flux bar indicators, and the rest of the UI. So floating text is separate - it's above the engine stuff, but below the UI.
Another question,     "showDamageWhenDecorative":true
the decorative weapon using this tag seems wired while damaged. Can there be a tag like "damageRenderedAbove", just making decal sprites rendered above the deco weapon?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 27, 2019, 07:35:47 AM
What is the relationship between a Beam's textureScrollSpeed and the Beam Speed in the CSV?  I'm seeing odd visuals where the Beam seems to take quite some time to fully "bloom", when the Beam Speed's 3000 and the textureScrollSpeed is 260 (the default).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on February 27, 2019, 09:53:06 AM
Speed 3000 beams should extend at 3000 speed, which while fast, isn't instant.

I don't think textureScrollSpeed is anything but graphical.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 27, 2019, 10:48:37 AM
Not in vanilla, but I believe Tyrador has such a weapon. That'd be the place to look.

Thanks, I wasn't sure where I had heard that was a weapon feature. I guess it will depend upon how resource intensive the script is.
-----------------------------------------------------

(Re-posting this because it was a later edit of the old post and come to think of it- was probably a bad idea and should have been a separate entry :P)

Can the plug-in parameters of the special_items.csv file be a comma separated list, or can it only accept one bp tag? Someone reported one of my bp packages as coming up empty and I'm wondering if that caused it.

Has anyone tried multiple tags with blueprint packages?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2019, 12:13:58 PM
Can the plug-in parameters of the special_items.csv file be a comma separated list, or can it only accept one bp tag? Someone reported one of my bp packages as coming up empty and I'm wondering if that caused it.

The parameters are just a string that gets interpreted by the item's plugin, so it could be just about anything.

In this case, if you look at MultiBlueprintItemPlugin (and that's the plugin class you're using, right?), you can see that it does indeed support a comma-separated list of tags.


What exactly does a Faction or a Market set up for a Faction need to do to:

1.  Sell ships on the Open Market?
2.  Military Market?
3.  Not sell generic (D) junk on the Black Market, but use their own custom stuff?
4.  Create Patrols?

I have everything else working in EZ Faction again, but testing brought up these issues.  Can "fix" by writing my own script to create these things in the Markets / Systems, but I'd prefer to work within the Vanilla design here.

1 & 2: add an open and military submarkets.
3: custom code, probably, if adding a black market doesn't do what you want. But since presumably the goal of EZ Faction is to replicate what vanilla does, you probably would just want to add a black market. Which does iirc tend to have higher-quality ships than baseline for the market.
4: Add a patrolhq industry, or one of its upgrades.

Another question,     "showDamageWhenDecorative":true
the decorative weapon using this tag seems wired while damaged. Can there be a tag like "damageRenderedAbove", just making decal sprites rendered above the deco weapon?

Weird how? It might help to see a screenshot.

As far as something like "damageRenderedAbove", hmm - that might be a bit tricky implementation-wise.

Also, if the deco weapons extend past the edges of the base ship sprite, the damage decals would get clipped to the sprite, so it would look weird. And if the deco weapon could rotate, it would look weird as well because the damage decal would not rotate with it, but I'm guessing it probably can't rotate.

My preferred approach would be to make the weapon damage decals look better assuming it's at all doable given what you're trying to do.


What is the relationship between a Beam's textureScrollSpeed and the Beam Speed in the CSV?  I'm seeing odd visuals where the Beam seems to take quite some time to fully "bloom", when the Beam Speed's 3000 and the textureScrollSpeed is 260 (the default).

Speed 3000 beams should extend at 3000 speed, which while fast, isn't instant.

I don't think textureScrollSpeed is anything but graphical.

Right, exactly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 27, 2019, 12:44:42 PM
Can the plug-in parameters of the special_items.csv file be a comma separated list, or can it only accept one bp tag? Someone reported one of my bp packages as coming up empty and I'm wondering if that caused it.

The parameters are just a string that gets interpreted by the item's plugin, so it could be just about anything.

In this case, if you look at MultiBlueprintItemPlugin (and that's the plugin class you're using, right?), you can see that it does indeed support a comma-separated list of tags.

Yes. Hmm, that's how I thought it worked... I double checked the spelling of the strings in the tags column of ship_data, weapon_data, as well as the entry in the relevant skin files- they all seem good. I wonder what could cause that?

I'm going to have to try and reproduce it (hopefully with console commands) later on to get some more info.

Thank you for the fast response, btw, and sorry about the bother. :)

(I know with enough time I could maybe dig in and understand that code class on my own but I really appreciate answers to questions that can save me a lot of time if someone is already familiar with it --especially new features like blueprints that may take some time to understand.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2019, 12:47:27 PM
Btw - one thing I just fixed up there is that if you've got an extra space somewhere, such as <bp1>, <bp2> (note the space after the comma) it would consider the space to be part of bp2 and thus not work.

Thank you for the fast response, btw, and sorry about the bother. :)

(I know with enough time I could maybe dig in and understand that code class on my own but I really appreciate answers to questions that can save me a lot of time if someone is already familiar with it --especially new features like blueprints that may take some time to understand.)

Yeah, it's cool. I will say that longer-term it's probably beneficial to look at the code at least a bit before asking, just so you'll build up more of an understanding - this'll likely save you time in the long run.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 27, 2019, 01:30:09 PM
Btw - one thing I just fixed up there is that if you've got an extra space somewhere, such as <bp1>, <bp2> (note the space after the comma) it would consider the space to be part of bp2 and thus not work.

Thank you for the fast response, btw, and sorry about the bother. :)

(I know with enough time I could maybe dig in and understand that code class on my own but I really appreciate answers to questions that can save me a lot of time if someone is already familiar with it --especially new features like blueprints that may take some time to understand.)

Yeah, it's cool. I will say that longer-term it's probably beneficial to look at the code at least a bit before asking, just so you'll build up more of an understanding - this'll likely save you time in the long run.

A very fair point, and one I will consider more in the future. :)

I thought of spacing being the culprit and the special_items file, at least, doesn't include spaces in the plugin params. I'll look and make sure it doesn't need to be wrapped in quotes or something else I'm missing. Unless it also can't include spaces in the tags portion of ship_data or weapon_data. Those values do have spaces after the comma in the list, but I didn't think that was a problem since the rest of the tags seem to read fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2019, 01:51:00 PM
I thought of spacing being the culprit and the special_items file, at least, doesn't include spaces in the plugin params. I'll look and make sure it doesn't need to be wrapped in quotes or something else I'm missing. Unless it also can't include spaces in the tags portion of ship_data or weapon_data. Those values do have spaces after the comma in the list, but I didn't think that was a problem since the rest of the tags seem to read fine.

Those should be fine with spaces; not handling them in the blueprint package plugin was an oversight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 27, 2019, 03:31:44 PM
I'm going through the plugin to try and find out why, but using a comma separated list of strings does not work for MultiBlueprintItemPlugin for me.

It seems to have the right method for parsing the list:
Code
param.split(",")

What I am seeing in my campaign:

Spoiler
(https://i.imgur.com/4tU5Hxu.png)
(https://i.imgur.com/6hd3SJR.png)
(https://i.imgur.com/JTMMcfN.png)
[close]

The one that shows up with ships and weapons only has a single tag in its param for the plugin.
When I change the other two to a single tag, they also then show the list of weapons and ships.

My first guess at a quick pass:

Code
boolean known = areAllKnown(ships, weapons, fighters);
at line 197 is probably returning true when it shouldn't be.

I'll give more info when I know more, but splitting between time doing this and rl work (working pretty late tonight, likely).

EDIT* Forgot to add what I have in special items that cause the above screenshots.

Code
Corrupted Phasetech Blueprint Package,archean_package,rare_package_bp,,40000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,archean_bp,Partially hacked and defective production masterchip that enables heavy industry to produce basic but effective hulls and weapons utilized by the Archean Order.,281
Damaged Phasetech Blueprint Package,archean_package_tier2,ultra_rare_package_bp,,90000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,"archean_bp,archean_bp_tier2",Damaged but mostly operational production masterchip that enables heavy industry to produce extremely powerful hulls and weapons utilized by the Archean Order.,282
Pristine Phasetech Blueprint Package,archean_package_tier3,"ultra_rare_package_bp, no_drop",,100000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,"archean_bp,archean_bp_tier2,archean_bp_tier3",Fully operational production masterchip that enables heavy industry to produce the most powerful hulls and weapons utilized by the Archean Order. A fully operational masterchip such as this is extremely rare.,283
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 27, 2019, 04:11:42 PM
On the question of textureScrollSpeed, I'm seeing weird results, where the Beam first has the thin segment, then the thicker one (but with quite a long delay).  I'll investigate whether there's something else I need to do to get the Beam to appear fully (graphically) almost immediately after it's active; on the 10000-speed Beams that switch off quickly (PD systems) the thicker outer edge of the Beam never even gets started.

On the issue of the Open Market / Black Market stuff, I'll just write some custom code that runs whenever the player changes Systems that populates that Cargo, like I did for Vacuum.  I was just hoping there was some "magic bullet" code I could run that would instantiate the Market vis-a-vis the built-in systems for populating that part of the Market, as there appears to be for the Faction's weapons (to a degree), etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 27, 2019, 04:59:55 PM

My first guess at a quick pass:

Code
boolean known = areAllKnown(ships, weapons, fighters);
at line 197 is probably returning true when it shouldn't be.

I'll give more info when I know more, but splitting between time doing this and rl work (working pretty late tonight, likely).


Ok, so based upon my understanding that returning true is definitely the case, and that comes from somewhere within these returning empty lists I would think:

Code
		List<String> ships = getShipIds(tags);
List<String> weapons = getWeaponIds(tags);
List<String> fighters = getWingIds(tags);

I'm trying to understand what this does:

Code
boolean not = tag.startsWith("!");
tag = not ? tag.substring(1) : tag;

First line isn't so bad- check to see if the tag doesn't have a ! operator in front? To lock out tags specifically I suppose?
What does the second line do, exactly?

Finally, as another thought:

Code
Global.getSettings().getAllShipHullSpecs();
Global.getSettings().getAllWeaponSpecs();
Global.getSettings().getAllFighterWingSpecs();

These should return mod specs too right? (I know probably should assume yes, but trying to find out what could be wrong. Other than a couple places I don't quite understand, it seems good on the surface.)

Other than that:

Code
		Collections.sort(specs, new Comparator<WeaponSpecAPI>() {
public int compare(WeaponSpecAPI o1, WeaponSpecAPI o2) {
return o2.getSize().ordinal() - o1.getSize().ordinal();
}
});

I don't understand, but unlikely to be the cause since it isn't present in getWingIds and that would return a wing in the fail case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 27, 2019, 05:38:07 PM
^ Actually, no that can't be right because when the tag is alone it pulls in all the relevant ids just fine... so scratch all of that. Logically, it has to be an issue with:

Code
		String param = spec.getParams();
if (!param.isEmpty()) {
for (String tag : param.split(",")) {
tags.add(tag);
}
}

*Edit* Alright, giving it up for tonight I think. I tried to set up a debugger in my run configuration after copying the plugin to my project and setting up some breakpoints in performRightClickAction().

I can't open up the necessary port in localhost. Getting:

Error running Starsector-Debug: Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused: connect
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 27, 2019, 09:15:13 PM
Weird how? It might help to see a screenshot.

As far as something like "damageRenderedAbove", hmm - that might be a bit tricky implementation-wise.

Also, if the deco weapons extend past the edges of the base ship sprite, the damage decals would get clipped to the sprite, so it would look weird. And if the deco weapon could rotate, it would look weird as well because the damage decal would not rotate with it, but I'm guessing it probably can't rotate.

My preferred approach would be to make the weapon damage decals look better assuming it's at all doable given what you're trying to do.
(https://i.imgur.com/Gn7I0IX.png)
these orange heated part doesn't render on the deco weapon.
And I find that if a weapon is too big, that tag seems won't work.
and can there be a tag making a module ship could hide their hp ui while cursor is over it? Also, a tag could made the modules won't seem dark in the refit screen?(and how to make them unselectable)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 28, 2019, 02:32:23 PM
So, I'm almost done with EZFaction's rewrite, all appears to be stable... but once again, hit something weird.

I'm trying to populate the Faction's locations with their Known Ships and Known Weapons.  I wrote an extended EveryFrameScript that tries to update the CargoAPIs.

Problem is... they don't appear to have any Known Ships or Known Weapons... despite those being explicitly defined in the .faction file.

I can read the JSON for the Faction and do it the hard way, but... shouldn't that data get populated on runtime?  This is weird.  Anyhow, I'll probably just work around this, but figured I'd note that this is a thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2019, 03:22:09 PM
@Morrokain:

Looking at this, bolded relevant part:
Corrupted Phasetech Blueprint Package,archean_package,rare_package_bp,,40000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,archean_bp,Partially hacked and defective production masterchip that enables heavy industry to produce basic but effective hulls and weapons utilized by the Archean Order.,281
Damaged Phasetech Blueprint Package,archean_package_tier2,ultra_rare_package_bp,,90000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,"archean_bp,archean_bp_tier2",Damaged but mostly operational production masterchip that enables heavy industry to produce extremely powerful hulls and weapons utilized by the Archean Order.,282
Pristine Phasetech Blueprint Package,archean_package_tier3,"ultra_rare_package_bp, no_drop",,100000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,"archean_bp,archean_bp_tier2,archean_bp_tier3",Fully operational production masterchip that enables heavy industry to produce the most powerful hulls and weapons utilized by the Archean Order. A fully operational masterchip such as this is extremely rare.,283

It's just going to assume these are different columns, there's absolutely no way for it to tell that these two are supposed to be within the same column. You need to put it in quotes, like so:

Corrupted Phasetech Blueprint Package,"archean_package,rare_package_bp",,40000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,archean_bp,Partially hacked and defective production masterchip that enables heavy industry to produce basic but effective hulls and weapons utilized by the Archean Order.,281

... and probably add a column because that would make your columns not line up.




(https://i.imgur.com/Gn7I0IX.png)
these orange heated part doesn't render on the deco weapon.
And I find that if a weapon is too big, that tag seems won't work.

Hmm - it's supposed to scale the damage decals based on the size of the weapon. If you can get me a mini-mod so I can take a look, I'd be happy to check it out.

and can there be a tag making a module ship could hide their hp ui while cursor is over it? Also, a tag could made the modules won't seem dark in the refit screen?(and how to make them unselectable)

If you also don't want the module to be attackable, I think just adding the "vastbulk" hullmod will do the job on all counts. Or, I believe, anything that reduces hull damage taken to 0.


Problem is... they don't appear to have any Known Ships or Known Weapons... despite those being explicitly defined in the .faction file.

Hmm, you might just need to create a new game - existing saves won't pick up changes to known ships/weapons/etc in .faction files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 28, 2019, 04:31:23 PM
I've been starting a new game with every build.  Here's the .faction file:

Spoiler
Code
{
id:"explorer_society",
"color":[135,206,255,255],
"secondaryUIColor":[135,255,0,255],
"secondarySegments":6,
"displayName":"Explorer Society",
"displayNameWithArticle":"the Explorer Society",
"displayNameLong":"Explorer Society",
"displayNameLongWithArticle":"The Explorer Society",
"logo":"graphics/factions/explorer_society.png",
"crest":"graphics/factions/crest_explorer_society.png",
"shipNamePrefix":"EXP",
"shipNameSources":{
"SPACE":2,
},
"description":"The Explorer Society is a remnant of Domain explorer crews who were trapped a long way from the Gates after the Collapse.",
"names":{
"modern":1,
"world":1,
"future":1,
"myth":1,
},

# variantOverrides restricts hulls to listed variants and adjusts their probability
"variantOverrides":{
},

# multiplier for how often hulls show up in the faction's fleets
"hullFrequency":{
"tags":{
"explorer_society_bp":2,
},
"hulls":{
},
},

# ships the faction gets access to when importing S&W out-of-faction
"shipsWhenImporting":{
"tags":["explorer_society_bp"],
"hulls":[
"explorer_society_aegean",
"explorer_society_crab",
"explorer_society_cutlass",
"explorer_society_explorer",
"explorer_society_ferdinand",
"explorer_society_hawk",
"explorer_society_hudson",
"explorer_society_kraken",
"explorer_society_pelagic",
"explorer_society_vespucci",
],
},

"knownShips":{
"tags":["explorer_society_bp"],
"hulls":[
"explorer_society_aegean",
"explorer_society_crab",
"explorer_society_cutlass",
"explorer_society_explorer",
"explorer_society_ferdinand",
"explorer_society_hawk",
"explorer_society_hudson",
"explorer_society_kraken",
"explorer_society_pelagic",
"explorer_society_vespucci",
],
},

# listing ships here will make the faction mostly use them even if other hulls become available
"priorityShips":{
"tags":["explorer_society_bp"],
"hulls":[
"explorer_society_aegean",
"explorer_society_crab",
"explorer_society_cutlass",
"explorer_society_explorer",
"explorer_society_ferdinand",
"explorer_society_hawk",
"explorer_society_hudson",
"explorer_society_kraken",
"explorer_society_pelagic",
"explorer_society_vespucci",
],
},

"knownFighters":{
"tags":["explorer_society_bp"],
"fighters":[
"explorer_society_49er_wing",
"explorer_society_cepter_wing",
"explorer_society_runabout_wing",
],
},

"priorityFighters":{
"tags":["explorer_society_bp"],
"fighters":[
"explorer_society_49er_wing",
"explorer_society_cepter_wing",
"explorer_society_runabout_wing",
],
},

"knownWeapons":{
"tags":["explorer_society_bp"],
"weapons":[
"exp_heavy_bolter",
"exp_heavy_plasma_cannon",
"exp_javelin",
"exp_javelin_pod",
"exp_med_plasma_cannon",
"exp_medlaser",
"exp_millenium",
"exp_phasor_cannon",
"exp_plasma_blaster",
"exp_plasma_triple_blaster",
],
},
"priorityWeapons":{
"tags":["explorer_society_bp"],
"weapons":[
"exp_heavy_bolter",
"exp_heavy_plasma_cannon",
"exp_javelin",
"exp_javelin_pod",
"exp_med_plasma_cannon",
"exp_medlaser",
"exp_millenium",
"exp_phasor_cannon",
"exp_plasma_blaster",
"exp_plasma_triple_blaster",
],
},

"knownHullMods":{
"tags":["base_bp", "hegemony"],
"hullMods":[
"shields_formshield",
"advancedoptics",
"turretgyros",
"augmentedengines",
"auxiliarythrusters",
"fluxcoil",
"fluxshunt",
"fluxdistributor",
"hardened_subsystems",
"insulatedengine",
"pointdefenseai",
"targetingunit",
"fluxbreakers",
"expanded_deck_crew",
"recovery_shuttles",
"operations_center",
"nav_relay",
"ecm",
],
},

"illegalCommodities":[
#NONE
],
"music":{
"theme":"music_tritach_encounter_neutral",
"market_neutral":"music_tritach_market_neutral",
"market_hostile":"music_tritach_market_hostile",
"market_friendly":"music_tritach_market_friendly",
"encounter_neutral":"music_tritach_encounter_neutral",
"encounter_hostile":"music_tritach_encounter_hostile",
"encounter_friendly":"music_tritach_encounter_friendly",
},
"internalComms":"tritachyon_internal",
"portraits":{
"standard_male":[
"graphics/portraits/portrait_corporate01.png",
"graphics/portraits/portrait_corporate03.png",
"graphics/portraits/portrait_corporate05.png",
"graphics/portraits/portrait_corporate06.png",
"graphics/portraits/portrait13.png",
"graphics/portraits/portrait25.png",
"graphics/portraits/portrait30.png",
"graphics/portraits/portrait35.png",
],
"standard_female":[
"graphics/portraits/portrait_corporate02.png",
"graphics/portraits/portrait_corporate04.png",
"graphics/portraits/portrait_mercenary02.png",
"graphics/portraits/portrait16.png",
"graphics/portraits/portrait_corporate04.png",
"graphics/portraits/portrait_corporate07.png",
"graphics/portraits/portrait34.png",
],
},
"ranks":{
"ranks":{
"spaceCommander":{"name":"Explorer Count"},
},
"posts":{
"patrolCommander":{"name":"Explorer Baron"},
"fleetCommander":{"name":"Explorer Knight"},
"baseCommander":{"name":"Explorer"},
},
},

"factionDoctrine":{
"warships":4,
"carriers":2,
"phaseShips":1,

"officerQuality":5,
"shipQuality":1,
"numShips":1,

"shipSize":4,

"aggression":1,

"combatFreighterProbability":0,      # instead of some portion of the freighters in a fleet
"combatFreighterCombatUseFraction":0,  # as part of the normal combat lineup
"combatFreighterCombatUseFractionWhenPriority":0,   # as part of normal combat lineup, when marked as priority ship
"autofitRandomizeProbability":0.1,

"commanderSkillsShuffleProbability":0,
"commanderSkills":[
"officer_management",
"coordinated_maneuvers",
"fighter_doctrine",
"electronic_warfare",
],
},
"custom":{
"offersCommissions":true,
"engagesInHostilities":true,
"buysAICores":true,
"AICoreValueMult":3,
"AICoreRepMult":3,
"buysSurveyData":true,
"hostilityImpactOnGrowth":true,
"caresAboutAtrocities":true,
"punitiveExpeditionData":{
"vsCompetitors":false,
"vsFreePort":false,
"canBombard":false,
"territorial":true,
},
}
},
[close]
I basically copied the Hegemony as a template.  Dunno what's wrong here, but it's not populating with that data.  I can read it in from JSON, but I'm thinking that this must be what's causing patrols to not spawn, etc.- the Faction doesn't have Known Ships / Known Weapons to use, therefore it builds nothing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 28, 2019, 04:50:17 PM
@Morrokain:

Looking at this, bolded relevant part:
Corrupted Phasetech Blueprint Package,archean_package,rare_package_bp,,40000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,archean_bp,Partially hacked and defective production masterchip that enables heavy industry to produce basic but effective hulls and weapons utilized by the Archean Order.,281
Damaged Phasetech Blueprint Package,archean_package_tier2,ultra_rare_package_bp,,90000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,"archean_bp,archean_bp_tier2",Damaged but mostly operational production masterchip that enables heavy industry to produce extremely powerful hulls and weapons utilized by the Archean Order.,282
Pristine Phasetech Blueprint Package,archean_package_tier3,"ultra_rare_package_bp, no_drop",,100000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,"archean_bp,archean_bp_tier2,archean_bp_tier3",Fully operational production masterchip that enables heavy industry to produce the most powerful hulls and weapons utilized by the Archean Order. A fully operational masterchip such as this is extremely rare.,283

It's just going to assume these are different columns, there's absolutely no way for it to tell that these two are supposed to be within the same column. You need to put it in quotes, like so:

Corrupted Phasetech Blueprint Package,"archean_package,rare_package_bp",,40000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,archean_bp,Partially hacked and defective production masterchip that enables heavy industry to produce basic but effective hulls and weapons utilized by the Archean Order.,281

... and probably add a column because that would make your columns not line up.

Oh wait, archean_package is the id, not the tag for the drop group. The only drop group tag should be rare_package_bp, but again I may be misunderstanding how that works. I thought when the drop group spawns in loot it pulls in just any package under the drop tag (but only one).

(I basically just solved this another way by adding weapons to packages and leaving only a single string in the params column for any package).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2019, 05:20:07 PM
Oh wait, archean_package is the id, not the tag for the drop group. The only drop group tag should be rare_package_bp, but again I may be misunderstanding how that works. I thought when the drop group spawns in loot it pulls in just any package under the drop tag (but only one).

(I basically just solved this another way by adding weapons to packages and leaving only a single string in the params column for any package).

Oh, my bad, I didn't pay close enough attention. Sorry! That does look correct then, assuming the columns actually line up right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 28, 2019, 07:12:43 PM
Oh, my bad, I didn't pay close enough attention. Sorry! That does look correct then, assuming the columns actually line up right.

No worries thanks for taking the time to look at it!

I'm still not sure what is going on there, for now, unless one of the filters deeper in the plugin that removes items from the resulting List or Array (can't quite remember what it finally returns, but either way I think it is looking for duplicates in the players known blueprints with the filter logic) somehow has a bug and removes everything it added in the first place- but only in the case of multiple tags. Ugh, idk the plugin honestly looked good to me, so I wonder if its my csv editor causing issues that don't show up in a text editor or something. Behaviorally, though, a single string of any bp tag works fine (verified by spawning the package with console commands and checking known blueprints after consuming it), and multiple comma separated tags definitely do not no matter what I try.  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 28, 2019, 07:31:39 PM

Hmm - it's supposed to scale the damage decals based on the size of the weapon. If you can get me a mini-mod so I can take a look, I'd be happy to check it out.


If you also don't want the module to be attackable, I think just adding the "vastbulk" hullmod will do the job on all counts. Or, I believe, anything that reduces hull damage taken to 0.

well this mod is depended on my ApproLight, plz enable them both.
https://www.dropbox.com/s/8n61iqz2h139hn5/ApproLight%200.7.0-RC4.zip?dl=0 (http://)
https://www.dropbox.com/s/exvn2nvhukngwrj/ApproLightPlus.zip?dl=0 (http://)

Oh I don't mean to make it unattackable! just want to know is there way to hide there float hp UI, and make the uneditable module bright in refit screen.(if they can't be realized I hope it could be realized in the near future)(I knew that 0 OP will make the module unselectable.)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2019, 07:38:23 PM
well this mod is depended on my ApproLight, plz enable them both.
https://www.dropbox.com/s/8n61iqz2h139hn5/ApproLight%200.7.0-RC4.zip?dl=0 (http://)
https://www.dropbox.com/s/exvn2nvhukngwrj/ApproLightPlus.zip?dl=0 (http://)

Cool! What's the name of the ship?

Oh I don't mean to make it unattackable! just want to know is there way to hide there float hp UI, and make the uneditable module bright in refit screen.(if they can't be realized I hope it could be realized in the near future)(I knew that 0 OP will make the module unselectable.)

Ah, ok - I don't think there's a way to do it now, let me make a note to add a tag or some such.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 28, 2019, 08:51:45 PM
Cool! What's the name of the ship?
HolyGrail-class
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2019, 09:01:07 PM
Thank you - will check this out tomorrow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on February 28, 2019, 09:39:11 PM
OK, I wrote a way to get the JSON data in, so that Known Ships gets populated, etc., etc.  I also wrote code that populates the Markets with Faction-appropriate hulls.  Whew!

1.  My locations show a Fleet Doctrine of 0%.  I'm guessing this means that they don't have a Fleet Doctrine defined.  As you can see in the Faction files, it is.
 Probably other stuff's weird / missing / broken too.

2.  When the Known Ships code worked at a basic level... I observed that the Markets were putting single Fighters into their Cargoes (i.e., selling them on the Open Market, etc.).  I wrote code to obliterate this problem, but, uh, yeah, that doesn't make sense; if you look at my Faction, it clearly doesn't put Fighters into the wrong category.  

3.  Sometimes the code works beautifully and weapons and ships show up.  Sometimes all of the Cargo appears to get nuked (i.e., no goods or whatnot).  Adding Mothballed FleetMemberAPI's shouldn't nuke Cargo, so I'm wondering if it's the weapons.

So, I'll probably need to write some code to kill that off, lest, when I get the locations functional as proper fleet-spawners, they spawn Fighters in their CampaignFleetAPIs, which will probably lead to all sorts of Bad Things (although I must say, it was super-amusing to fly a fighter around, even if it was unarmed, lol).  

I got weapons and Fighters sorted (I think) and then noticed something else.  

Colonies apparently cannot generate their Orbital Stations unless... something.  There's some prerequisite.

Speaking of Stations... if they're generated, they aren't automatically hooked to the complete MarketAPI of the PlanetAPI.  Just some of it.  So I feel like there are some pre-requisites lurking here.

We'll see how much gets sorted when I manually add in all of the Faction's data and clear out any junk along the way.  This went from "fun hobby project" to "major dive into SS's API" though, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 01, 2019, 03:58:44 AM
xenoargh: Not sure why the JSON is otherwise loadable, but the ID is broken:

Code: json
id:"explorer_society",
should be
Code: json
"id":"explorer_society",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 01, 2019, 09:00:56 AM
Great catch; it's probably been that way for three versions now  ::)  Fixing that didn't change anything, unfortunately.  But I'll double-check all the brackets, etc.  Meh, I cannot wait until the .faction file isn't getting changed with each new version, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 01, 2019, 11:12:43 AM
I'm still not sure what is going on there, for now, unless one of the filters deeper in the plugin that removes items from the resulting List or Array (can't quite remember what it finally returns, but either way I think it is looking for duplicates in the players known blueprints with the filter logic) somehow has a bug and removes everything it added in the first place- but only in the case of multiple tags. Ugh, idk the plugin honestly looked good to me, so I wonder if its my csv editor causing issues that don't show up in a text editor or something. Behaviorally, though, a single string of any bp tag works fine (verified by spawning the package with console commands and checking known blueprints after consuming it), and multiple comma separated tags definitely do not no matter what I try.  ???

Oh. Right! Looking at the code, multiple tags here are treated as an "and" rather than an "or".

... so I would recomment adding tags to your ships/weapons so that you only need to use one tag.

(Sorry I didn't spot this sooner! Just wasn't thinking of this as a possible place to look, and since it's never used in vanilla, it wasn't exactly something I was actively aware of.)


*Edit* Alright, giving it up for tonight I think. I tried to set up a debugger in my run configuration after copying the plugin to my project and setting up some breakpoints in performRightClickAction().

I can't open up the necessary port in localhost. Getting:

Error running Starsector-Debug: Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused: connect

I'm pretty sure you need to change vmparams to enable debugging, but I'm not sure what else is involved. Could someone with some experience running a debugger w/ a release build of Starsector chime in?




xenoargh: Not sure why the JSON is otherwise loadable, but the ID is broken:

Code: json
id:"explorer_society",
should be
Code: json
"id":"explorer_society",

I'm not sure offhand whether the json spec allows this or not, but the 3rd party json parser Starsector is using handles this. Quotes around string values are optional, as well, and you could do x:false or x:"false", etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dabclipers on March 01, 2019, 02:32:09 PM
So, I backed Starsector way back when and played off and on for a few years using Uomoz's Sector mod.  I got reminded of the game a few days ago and noticed when reinstalling that he has ceased to update his mod.  Is there a mod out there that is similar to his (Including multiple modded factions that interact with one another)? I've been looking at the Nexerelin mod as I see it's up to date, so perhaps that one?

Additionally, is it possible to add out of date mods to the game or will they simply not work?  So many talented modders have created excellent faction mods but many of these haven't been updated in a while, can I still use them?

Thanks for any help that can be provided.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Blothorn on March 01, 2019, 03:53:54 PM
Outdated faction mods will almost certainly not work; even if they successfully load (unlikely) you will run into weird bugs down the line.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LazyWizard on March 01, 2019, 07:32:16 PM
*Edit* Alright, giving it up for tonight I think. I tried to set up a debugger in my run configuration after copying the plugin to my project and setting up some breakpoints in performRightClickAction().

I can't open up the necessary port in localhost. Getting:

Error running Starsector-Debug: Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused: connect

I'm pretty sure you need to change vmparams to enable debugging, but I'm not sure what else is involved. Could someone with some experience running a debugger w/ a release build of Starsector chime in?

Quote from: vmparams
-agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n

But if you're running it through your IDE it should enable debugging automatically. Maybe the port is in use already? Try another port and see if it works.


Edit: here's what I have in my run configuration (IntelliJ IDEA):
Spoiler
(https://i.imgur.com/ohYMFEy.png)
[close]

With the following VM options:
Quote
-agentlib:jdwp=transport=dt_socket,server=y,address=51423,suspend=n -Djava.library.path=native\windows -Xms3g -Xmx3g -Xss1024k -Dcom.fs.starfarer.settings.paths.logs=. -Dcom.fs.starfarer.settings.paths.saves=../saves -Dcom.fs.starfarer.settings.paths.screenshots=../screenshots -Dcom.fs.starfarer.settings.paths.mods=../mods -classpath janino.jar;commons-compiler.jar;commons-compiler-jdk.jar;starfarer.res.jar;starfarer.api.jar;starfarer_obf.jar;jogg-0.0.7.jar;jorbis-0.0.15.jar;json.jar;lwjgl.jar;lwjgl_util_applet.jar;jinput.jar;lwjgl_test.jar;log4j-1.2.9.jar;lwjgl_util.jar;fs.sound_obf.jar;fs.common_obf.jar;xstream-1.4.10.jar com.fs.starfarer.StarfarerLauncher
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on March 01, 2019, 07:44:25 PM
So, I backed Starsector way back when and played off and on for a few years using Uomoz's Sector mod.  I got reminded of the game a few days ago and noticed when reinstalling that he has ceased to update his mod.  Is there a mod out there that is similar to his (Including multiple modded factions that interact with one another)? I've been looking at the Nexerelin mod as I see it's up to date, so perhaps that one?

Additionally, is it possible to add out of date mods to the game or will they simply not work?  So many talented modders have created excellent faction mods but many of these haven't been updated in a while, can I still use them?

Thanks for any help that can be provided.

1) Nexerelin, yes, but you'll have to grab the faction mods separately. I believe the Nex OP contains a few recommended ones!

EDIT: oh, it doesn't, my bad. well, some old faction mods like Neutrino, Junk Pirates and Shadowyards are still up to date, and my own Kadur Remnant is a continuation after a fashion of the old Kadur Theocracy mod -- I think Blackrock is coming "soon" as well. But really, just grab some that are marked 0.9 compatible in the mod index, the worst that can happen is you don't like 'em and have to remove them on the next run ;)

2) It's not possible, no. You could probably update them to bare-minimum compatibility yourself with some work for your own personal use, but I'd recommend just jumping into the current ones instead -- it'd basically be wasted effort and there are certainly enough high quality currently-updated faction mods to fill up the sector, if that's what you're after.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 02, 2019, 12:58:59 AM
Hmmmm.  Getting closer to understanding what's up.

Apparently, my Faction has a FleetDoctrine, and I was able to populate it with data directly from the JSON.  So... it's probably right-ish, maybe. 

However, it still won't create Patrols. 

I'm still sorting through some last buggy behaviors with the Restock script.  It mainly works, except:

1.  When we try to get WeaponAPIs that have AI hint SYSTEM... they're like, invisible.

thisMarket.getSubmarket(Submarkets.SUBMARKET_BLACK).getCargo().getNumWeapons(weaponSpec.getWeaponId());

This doesn't appear to catch these.  It should; they're valid WeaponAPIs; they just shouldn't be in CargoAPI's, ever (honestly, I'd just prefer that attempting to put them there results in a non-crashing boolean false, personally, so they can get caught but don't crash).

So I wrote some code to kill them, too, but ouch.  The weapon that's showing up is a Built-In; it's literally never meant to show up in Known Weapons, etc.

2.  I had some initial trouble because I just wanted the script to run if the Player's Fleet .getContainingLocation() matched the Market's .getContainingLocation().  Problem is... this only happens to happen after the Player has visited the SectorEntityAPI, so the first time, it didn't work, next time we visited, all was well.  Rewrote the code to merely check whether the Market's active this frame:

Code
for(SectorEntityToken thisLoc : market.getConnectedEntities()){
if(thisLoc.getContainingLocation().activeThisFrame()){
clearShipsAndWeapons(market);
addRandomShipsAndWeapons(market);
}
}
...This appears to address it, but I'm concerned about scaling issues, as the rest of the code that follows is, because certain things aren't working (like populating directly from Known Weapons or Known Ships)... rather recursive, for example:


Code
		FactionAPI stationFaction = thisMarket.getFaction();
String stationFactionID = stationFaction.getId();

List<String> factionFleets = new ArrayList<>(Global.getSector().getFaction(stationFactionID).getKnownShips());
List<String> killMe = new ArrayList<>();
for(String memID : factionFleets){
for(ShipHullSpecAPI spec : Global.getSettings().getAllShipHullSpecs()){
if(spec.getBaseHullId().equals(memID) && spec.getHullSize().equals(HullSize.FIGHTER)){
killMe.add(spec.getBaseHullId());
}
}
}
for(String killMeString : killMe){
if(factionFleets.contains(killMeString)){
factionFleets.remove(killMeString);
}
}

        CargoAPI sCargo;
if(thisMarket.hasSubmarket(Submarkets.GENERIC_MILITARY)){
sCargo = thisMarket.getSubmarket(Submarkets.GENERIC_MILITARY).getCargoNullOk();
for(int i = 0; i < 20; i++){
randomShipAdd(factionFleets, sCargo);
}
}
I'm pretty sure Known Ships shouldn't ever return Fighter Wings (let alone Fighter Wings I never put there in the first place; how this data got there is, I presume, related to the new Auto-Fit systems) and that CargoAPI should ignore attempts to add Fighter Wings via addMothballedShip() now that Wings are kind-of-sorta-like-WeaponAPIs... but that's about the only way I've figured out that gets rid of them.

I'm still seeing a 0% Fleet Doctrine on locations.  IDK what do about that, other than set it by fiat; whatever Stuff runs that normally clearly isn't working and it's unclear how to get it working for these custom Markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dabclipers on March 02, 2019, 11:33:50 AM
Thanks for the help guys, I was pretty glad to check it out so many years later and see allot of my old favorites are still around being updated and that a number of new high quality mods have been added.  Kudos to all of the modders out there sticking with Starsector!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 02, 2019, 12:58:04 PM
1.  When we try to get WeaponAPIs that have AI hint SYSTEM... they're like, invisible.

thisMarket.getSubmarket(Submarkets.SUBMARKET_BLACK).getCargo().getNumWeapons(weaponSpec.getWeaponId());

This doesn't appear to catch these.  It should; they're valid WeaponAPIs; they just shouldn't be in CargoAPI's, ever (honestly, I'd just prefer that attempting to put them there results in a non-crashing boolean false, personally, so they can get caught but don't crash).

So I wrote some code to kill them, too, but ouch.  The weapon that's showing up is a Built-In; it's literally never meant to show up in Known Weapons, etc.

I just double-checked that getNumWeapons() returns the right count for SYSTEM weapons. Perhaps some other code you've written to mess with the inventory is cleaning them out? I think part of the issue here is that you've ended up with a bunch of code that "fixes" things that aren't necessarily broken in the first place, so it's hard to tell what's going on and why.

I would suggest looking at PirateBaseIntel for an example of a bit of code adding a simple, functional market to the game that spawns fleets, has an orbital station, and has ships/weapons/etc for sale. The main things you would want to not do is set the econ group or make it hidden; aside from that the market-creation code is pretty general-purpose.

Also, I think continued discussion of this probably warrants a separate thread; this one is for simpler, more focused questions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 02, 2019, 05:43:16 PM
(Non-campaign) mission code: Trying to randomize fleets using the inflater. Why does the last line throw an NPE (seemingly no matter what args I pass to setVariant)?

Code: java
	CampaignFleetAPI fleet = FleetFactoryV3.createFleet(params);
List<FleetMemberAPI> fleetList = fleet.getFleetData().getMembersListCopy();

if (randomMode) {
DefaultFleetInflaterParams inflaterParams = new DefaultFleetInflaterParams();
inflaterParams.quality = quality;
inflaterParams.mode = ShipPickMode.PRIORITY_THEN_ALL;
DefaultFleetInflater inf = new DefaultFleetInflater(inflaterParams);
inf.inflate(fleet);
}

for (FleetMemberAPI m : fleetList)
{
if (!randomMode) {
String variant = m.isFighterWing() ? m.getSpecId() : m.getVariant().getHullVariantId();
api.addToFleet(side, variant, m.getType(), m.getShipName(), (!m.isFighterWing() && !flagshipChosen));
}
else {
ShipVariantAPI variant = m.getVariant();
String hullId = m.getHullSpec().getHullId();
if (hullId.endsWith("_default_D")) {
hullId = hullId.replace("_default_D", "");
}
FleetMemberAPI member = api.addToFleet(side, hullId + "_Hull",
m.getType(), m.getShipName(), (!m.isFighterWing() && !flagshipChosen));
member.setVariant(variant, false, true);
}
}

Code
53526 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.title.C.for.super(Unknown Source)
at com.fs.starfarer.title.C.for.render(Unknown Source)
at com.fs.starfarer.title.C.for.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.donew.renderImpl(Unknown Source)
at com.fs.starfarer.title.C.oo0O.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.donew.renderImpl(Unknown Source)
at com.fs.starfarer.title.C.D.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.D.oooO.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.donew.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.ui.donew.renderImpl(Unknown Source)
at com.fs.starfarer.ui.Q.render(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.render(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 02, 2019, 09:47:36 PM
I'm not sure, but DefaultFleetInflater assumes it's being used in the campaign, so I'd consider it a happy accident if it worked (and it might be dependent on, say, whether a campaign was loaded prior, what state it was in, etc.) It's probably a better idea to set up a CoreAutofitPlugin (like the inflater does) and loop through the fleet members. If that still crashes, I'd be happy to take a closer look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Beobachter on March 04, 2019, 07:01:27 AM
When applying an alpha core to an industry, if the presence of an alpha core changes the output (commodity A to commodity B), would the check be in the inital apply() function or would it be better to put it in a function related to the alphacore? Hitting an NPE with a custom industry and not sure if I should move the offending line or not.
Code
 @Override
    public void apply(){
        super.apply(true);
        int marketSize = market.getSize();
       
        modifyStabilityWithBaseMod(); //Apply stabilty penalty
       
        demand(0, Commodities.HEAVY_MACHINERY, marketSize/2, BASE_VALUE_TEXT); //Demands Heavy Machinery equal to hydroponics

        Pair<String, Integer> deficit = getMaxDeficit(Commodities.HEAVY_MACHINERY); //Get deficits
        log.debug("Deficit: " + deficit.one + "," + deficit.two);
       
        if(!getAICoreId().equals(Commodities.ALPHA_CORE)) { //If core is alpha core, generate lobster
            log.debug("Generating Lobsters for player.");
            supply(Commodities.LOBSTER, marketSize - 5 - deficit.two);
        }
supply(Commodities.FOOD, marketSize - deficit.two);
if (!isFunctional()) { supply.clear(); }
    }
Spoiler
https://bitbucket.org/nullAurelian/darkerbusiness/src
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 04, 2019, 09:07:37 AM
The reason you're getting an NPE is getAICoreId() returns null when there's no AI core, so, the code ought to check for that before using it.

Could either do:
if (getAICoreId() != null && getAICoreId().equals(Commodities.ALPHA_CORE))

Or:

if (Commodities.ALPHA_CORE.equals(getAICoreId()))

The latter works because the String.equals() method can handle the parameter being null.


Btw, it seems like you've got an extra ! in there; the code doesn't match the comment.

if (!getAICoreId().equals(Commodities.ALPHA_CORE))


Also, if you haven't done it already, you'll possibly want to override the addAlphaCoreDescription() method so that the effect of the alpha core shows up in its description in the AI core dialog/various industry tooltips.

As to whether to do it in apply() - you could do that, yeah, seems like probably the place to put it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on March 04, 2019, 10:40:31 PM
Dipping my toes into adding some ships (see spoiler below) and i'd just like to ask if there's any list of the Missiletypes in the .wpn file and different missile tags in the CSV (missile1, missile2, etc.)?

Having a list of their respective behaviors would be great!

Spoiler
https://www.youtube.com/watch?v=kL9FuyX0uDU
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2019, 10:12:03 AM
(Video says its unavailable.)

This is the MissileType enum:

Code: java
public static enum MissileType {
FLARE,
FLARE_SEEKER,
FLARE_JAMMER,
ROCKET,
MISSILE,
MISSILE_TWO_STAGE_SECOND_UNGUIDED,
HEATSEEKER,
MIRV,
TORPEDO,
BOMB,
BOMB_WITH_SLOW,
BOMB_WITH_ACCEL,
PHASE_CHARGE,
PHASE_MINE,
NO_AI,
}

99% of what type does is what kind of AI the missile gets. Some are unused, though (i.e. fairly sure TORPEDO isn't actually used since it's the same as ROCKET and ROCKET is used instead.) So, use with caution - I'd recommend grepping through the .proj files to see what's actually used; this way you can see what the behavior is as well.

It's also possible to create your own missile AI, using ModPlugin.pickMissileAI().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on March 07, 2019, 12:42:03 PM
I just found out that warning beacons give their tag exclusively to the beacon itself. Would it be possible for them to tag the system as well?  ;D Right now it's both difficult and annoying to figure out which systems have warning beacons as the beacon entities don't seem to link to anything either -- I know the beacon levels correspond to remnant theme tags but that goes out the window when you have mod content, haha. Beacons are constant though!

I was also wondering how the theme tags are "categorized" or broken down:

Code: java
	public static final String THEME_CORE_UNPOPULATED = "theme_core_unpopulated";
public static final String THEME_CORE_POPULATED = "theme_core_populated";

public static final String THEME_MISC = "theme_misc";
public static final String THEME_MISC_SKIP = "theme_misc_skip";

public static final String THEME_RUINS = "theme_ruins";
public static final String THEME_RUINS_MAIN = "theme_ruins_main";
public static final String THEME_RUINS_SECONDARY = "theme_ruins_secondary";

public static final String THEME_DERELICT = "theme_derelict";
public static final String THEME_DERELICT_MOTHERSHIP = "theme_derelict_mothership";
public static final String THEME_DERELICT_CRYOSLEEPER = "theme_derelict_cryosleeper";
public static final String THEME_DERELICT_SURVEY_SHIP = "theme_derelict_survey_ship";
public static final String THEME_DERELICT_PROBES = "theme_derelict_probes";

public static final String THEME_REMNANT = "theme_remnant";
public static final String THEME_REMNANT_MAIN = "theme_remnant_main";
public static final String THEME_REMNANT_SECONDARY = "theme_remnant_secondary";
public static final String THEME_REMNANT_NO_FLEETS = "theme_remnant_no_fleets";
public static final String THEME_REMNANT_DESTROYED = "theme_remnant_destroyed";
public static final String THEME_REMNANT_SUPPRESSED = "theme_remnant_suppressed";
public static final String THEME_REMNANT_RESURGENT = "theme_remnant_resurgent";

For example, can a system generate with both the THEME_MISC and the THEME_REMNANT tags? What about THEME_MISC and THEME_MISC_SKIP and THEME_CORE_UNPOPULATED? Or THEME_REMNANT, THEME_REMNANT_NO_FLEETS, THEME_REMNANT_SECONDARY, and THEME_REMNANT_SUPPRESSED?

What I'm hoping for is a clear categorization like (this is also my best guess):

1) theme tags, mutually exclusive with eachother: THEME_MAIN, THEME_RUINS, THEME_DERELICT, THEME_REMNANT
2) system type tags, mutually exclusive with eachother: *_MAIN, *_SECONDARY, *_SKIP, *_POPULATED, *_UNPOPULATED
3) system status tags, mutually exclusive with eachother: , *_NO_FLEETS, *_DESTROYED, *_SUPPRESSED, *_RESURGENT

But I really have no idea how it works. Is that somewhat close, at least?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 07, 2019, 01:12:09 PM
I just found out that warning beacons give their tag exclusively to the beacon itself. Would it be possible for them to tag the system as well?  ;D Right now it's both difficult and annoying to figure out which systems have warning beacons as the beacon entities don't seem to link to anything either -- I know the beacon levels correspond to remnant theme tags but that goes out the window when you have mod content, haha. Beacons are constant though!

Beacons generally are orbiting something so you could probably figure out the system it's related to based on that. If you've got a system, then a beacon that's orbiting its hyperspace anchor is going to be the one that's related to this system.

I'm not sure about adding their tags to systems - let me think about it. For some reason it feels not right but I can't put a finger on why right now.


For example, can a system generate with both the THEME_MISC and the THEME_REMNANT tags? What about THEME_MISC and THEME_MISC_SKIP and THEME_CORE_UNPOPULATED? Or THEME_REMNANT, THEME_REMNANT_NO_FLEETS, THEME_REMNANT_SECONDARY, and THEME_REMNANT_SUPPRESSED?

What I'm hoping for is a clear categorization like (this is also my best guess):

1) theme tags, mutually exclusive with eachother: THEME_MAIN, THEME_RUINS, THEME_DERELICT, THEME_REMNANT
2) system type tags, mutually exclusive with eachother: *_MAIN, *_SECONDARY, *_SKIP, *_POPULATED, *_UNPOPULATED
3) system status tags, mutually exclusive with eachother: , *_NO_FLEETS, *_DESTROYED, *_SUPPRESSED, *_RESURGENT

But I really have no idea how it works. Is that somewhat close, at least?

Yeah, you've geeeeenerally got the right idea. Except the "types" are just _MAIN and _SECONDARY (and iirc that's remnant-specific). *_SKIP, *_POPULATED, *_UNPOPULATED are all just one-off tags independent of the other stuff.

I'm not sure what you mean by THEME_MAIN in 1).

IIRC MISC and MISC_SKIP are mutually exclusive - _SKIP is meant to mark that the system was explicitly decided to be left empty by the Misc theme generator.

_NO_FLEETS is not exclusive with the other tags, it just marks there are no remnant fleets in a technically-remnant system. IIRC it could happen for DESTROYED or SUPPRESSED.

To be sure, basically you'd want to "show references" in whatever IDE you're using and see how the tags are assigned.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on March 07, 2019, 01:22:45 PM
(oops, that was meant to be THEME_MISC in 1)

Thank you! Think I've got it now.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ChaosRemnant on March 11, 2019, 09:51:04 AM
Not sure if this has been asked yet, but want to just in case it has not.
Spoiler
(Bit too lazy to search 300 pages :P)
[close]
Is it possible to make a mod that allows for planets to have more than 12 buildings?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 11, 2019, 09:53:15 AM
It's not, no - the UI doesn't support that and the number is extremely hardcoded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ChaosRemnant on March 11, 2019, 10:01:46 AM
Alright seems a bit weird that you can't, but I assume that is mainly due to it just being implemented this version or just the that devs don't want a single planet to do everything. Second question then. Is the limit on planet admins or owning planets the same then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 11, 2019, 10:06:05 AM
That's actually easily changeable! In data/config/settings.json:

"baseMaxOutposts":2,
"baseMaxAdmins":1,
"colonyOverMaxPenalty":2,

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ChaosRemnant on March 11, 2019, 10:07:48 AM
Thanks once again, now onwards to making infinite colonies! (probably not a good idea)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 12, 2019, 03:27:27 PM
If we add a new ship to a Faction's Known Ships, how soon should we expect that Known Ship to start showing up in the Faction's inventory?  I just added two ships to the Pirates, and they're still not spawning, a game-month later.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 12, 2019, 03:42:06 PM
Within a month, since iirc that's the longest it might take for the inventory to be updated after the player looked at it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 12, 2019, 05:05:06 PM
Hmm.

So, do Pirates never get to have Capitals?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 12, 2019, 05:43:12 PM
I'm not sure exactly what you mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 12, 2019, 07:27:26 PM
OK, so I figured out why ships weren't being populated and why the Pirates weren't getting their ships, too.  Variants need to be in default_ship_roles to function correctly, in terms of being "in the population".  It isn't sufficient to merely include the Ship via the BP in the CSV file.

Sooooo... yeah, I may just need to obliterate the EveryFrameScript that populates the ships and let the game's logic do it's thing.  Heck, maybe even weapons will start populating normally now.  Question is, will the Markets now (finally) generate fleets?

<waits a minute>

Yesssssssss.

So, finally, finally FINALLY, EZFaction works again, properly, with all the bells and whistles.

Alex, if I may... I'd really like to suggest that, in the final build, maybe... don't have "how ships get built by Faction" be quite this labyrinthine?  I mean, really; we have:

1.  Ship listings in the actual Faction file, that determine what-gets-built / imported, but not what gets actually, you know, used.
2.  BP listings in the CSV that don't have obvious correlations with anything (I presume they're only for Blueprints you can collect when you're doing Pokemon-stuff in lategame).
3.  default_ship_roles, which controls quite a lot, actually, but isn't exactly the obvious go-to text file.
4.  All the code in the API, none of which explicitly refers back to 3 at all; it all looks like it's working with #1.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on March 12, 2019, 10:29:48 PM
Actually xeno it's extremely simple. I don't know about the API for this, but the other three bulletpoints there synergize together in a very clever, adaptive, and controllable way. I'll try explain it nonetheless.

- Ship HULLS are tagged with either a blueprint package, a single blueprint, or a faction tag.

- Ships each have a number of VARIANTS which are given fleet roles in default_ship_roles.

- Factions have a list of what HULLS they can use, by combination of individual hull IDs and also by faction or blueprint package IDs - such as the pirates having access to all ships labelled with the "pirate_bp" tag.

- A faction looks at its available ship HULLS from that specified collection, then builds a fleet of ship VARIANTS with certain roles based on where each of the available ships appear with variants in default_ship_roles.

On top of that you can then adjust individual ship chances, within a faction, with the rarity modifiers. The current system gives an unbelievable amount of control to modders (and the Devs for that matter), and while it's definitely a step above the previous system, I haven't found it confusing in the slightest.

(Pirates absolutely have access to capitals - fleet roles are no longer set on a faction-by-faction basis, but the pirates by default don't have access to any capital HULLS, hence they don't normally use them. Have you not tried selling ship blueprints to the pirates before? You should. They start using them.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 08:32:42 AM
Code: java
package data.scripts.campaign.fleet;

import com.fs.starfarer.api.campaign.BuffManagerAPI;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantAssignmentAI;

import static com.fs.starfarer.api.campaign.BuffManagerAPI.*;


public class Knight_ArrivalFleetBuffAndAI extends RemnantAssignmentAI {
    private static final String BUFF_ID = "Knight_arrivalFBA";

    public Knight_ArrivalFleetBuffAndAI(CampaignFleetAPI fleet, StarSystemAPI homeSystem, SectorEntityToken source) {
        super(fleet, homeSystem, source);
    }

    @Override
    public void advance(float amount) {
        super.advance(amount);
        boolean needSync = false;
        for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
            Buff buff = member.getBuffManager().getBuff(BUFF_ID);
            if (buff instanceof EnhanceBuff) {
                ((EnhanceBuff) buff).setDur(0.2f);
            } else {
                member.getBuffManager().addBuff(new EnhanceBuff(BUFF_ID, 0.2f));
                needSync = true;
            }
        }
        if (needSync) {
            fleet.forceSync();
        }
    }

    public class EnhanceBuff implements Buff {
        private static final float DAMAGE_REDUCTION = 20f;
        private static final float DAMAGE_INCREASE = 20f;
        private static final float HULL_BONUS = 20f;

        private String id;
        private float dur;

        public EnhanceBuff(String id, float dur) {
            this.id = id;
            this.dur = dur;
        }

        public void advance(float days) {
            dur -= days;
        }

        public void apply(FleetMemberAPI member) {
            member.getStats().getHullBonus().modifyMult(getId(), 2f);
            member.getStats().getEnergyDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getHighExplosiveDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getKineticDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getFragmentationDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getEnergyWeaponDamageMult().modifyPercent(getId(), DAMAGE_INCREASE);
            member.getStats().getMissileWeaponDamageMult().modifyPercent(getId(), DAMAGE_INCREASE);
            member.getStats().getBallisticWeaponDamageMult().modifyPercent(getId(), DAMAGE_INCREASE);
        }

        public String getId() {
            return id;
        }

        public boolean isExpired() {
            return dur <= 0;
        }

        public float getDur() {
            return dur;
        }

        public void setDur(float dur) {
            this.dur = dur;
        }
    }
}
Why such buffs doesn't work on AI's fleet(I have add them to the fleet)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 13, 2019, 09:51:00 AM
@Originem:

If I understand your question correctly, you're trying to write a Buff that's specific to a type of Faction Fleet, correct? 

If so, all you really need is an EveryFrameScript that also implements Buff and applies it to a given FleetMember if the EveryFrameScript finds a CampaignFleetAPI object that is from <faction> or meets <other condition>.


@AxleMC131:

"Extremely simple" was back when adding ships to a Faction was merely putting Variants into a Faction file built around stock fleet types and the game took care of the rest under the hood.

Spoiler
I get that for fine-tuned control this is "better", but frankly, it's becoming a major barrier-to-entry for new modders, especially as the public documentation needs updating.  On the code-side (since that was mainly what I was doing) I can tell you right now that things have gotten considerably more complicated and somewhat black-box under the hood.  It's telling that I got through that, and even Alex didn't have an explanation for why stuff didn't Just Work.

Ideally, we'd have a simple system where it's obvious what needs doing for a given Faction (rather than default_ship_roles, which is inherently confusing, because it's not tied explicitly to the Factions at all) and something like EZFaction built into the game whereby "my first mod" was largely making changes to a copypasta .faction file, giving it some (optional) parameters to auto-populate the Sector and building out some .ship / .wpn / .proj files and the graphics, sounds, etc. to support same.

Ah well, it works again. 

Hopefully it'll only get seriously broken one more time, somewhere around 1.0, lol.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 10:10:46 AM
If I apply this buff to player's fleet using other ways, it works well.
It's strange.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 13, 2019, 10:25:57 AM
I think you're just not using Update() in the correct context; that's why I was suggesting a simpler approach using EveryFrameScript instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 10:34:20 AM
I think you're just not using Update() in the correct context; that's why I was suggesting a simpler approach using EveryFrameScript instead.
I don't think you understand my question.
All buffs' "apply()" in BuffManager should be called when a fleet member's stats are updated or going to update, and it does work well in player's fleet. what I can't understand is that it couldn't affect AI's fleets. Though breakpoint at apply() works when I move my cursor to one fleetmember in the right screen in the fleet dialog, it's stats are still not updated.
I tried to set the inflater to null, but it still not works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Blothorn on March 13, 2019, 10:44:14 AM
Xenoargh--the only "barrier to entry" is that you need to copy-paste two files instead of one, and know to do that. I think your problem was assuming the game was broken and trying to "fix" it, where most modders would ask "what am I forgetting to do?" and likely getting a quick answer.

As far as why this change was made--this is necessary to get the player faction/pirates (with their ability to use BPs sold to the black market) working. They can't use a faction-specific ship role table--how would they know what roles to add when unlocking a new blueprint? And adding this as an alternate path while keeping the legacy path for factions with static known ships (or specifically bounded known ships, given the possibility of relying on imported ship parts and thus only having access to a portion of known ships) would complicate both the codebase and the API.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 13, 2019, 11:18:40 AM
@Origenem:

Just try a straightforward approach in an EveryFrameScript:

Code
		for(LocationAPI location : Global.getSector().getAllLocations()){
for(CampaignFleetAPI fleet : location.getFleets()){
//Set up criteria here
if(/*criteria*/ 1 == 1){
for(FleetMemberAPI member : fleet.getMembersWithFightersCopy()){
if(!member.isFighterWing()){
//Deploy the Buff
}
}
}
}
}

@Blothorn:  I think that further discussion of this philosophical stuff needs to be taken to Suggestions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 11:59:25 AM
I don't mean this and it's not a good idea I think...

And Alex I found that Misc.getInflater() won't find my campaign plugin which has overriden the pickFleetInflater
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2019, 12:16:23 PM
Spoiler
Code: java
package data.scripts.campaign.fleet;

import com.fs.starfarer.api.campaign.BuffManagerAPI;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantAssignmentAI;

import static com.fs.starfarer.api.campaign.BuffManagerAPI.*;


public class Knight_ArrivalFleetBuffAndAI extends RemnantAssignmentAI {
    private static final String BUFF_ID = "Knight_arrivalFBA";

    public Knight_ArrivalFleetBuffAndAI(CampaignFleetAPI fleet, StarSystemAPI homeSystem, SectorEntityToken source) {
        super(fleet, homeSystem, source);
    }

    @Override
    public void advance(float amount) {
        super.advance(amount);
        boolean needSync = false;
        for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
            Buff buff = member.getBuffManager().getBuff(BUFF_ID);
            if (buff instanceof EnhanceBuff) {
                ((EnhanceBuff) buff).setDur(0.2f);
            } else {
                member.getBuffManager().addBuff(new EnhanceBuff(BUFF_ID, 0.2f));
                needSync = true;
            }
        }
        if (needSync) {
            fleet.forceSync();
        }
    }

    public class EnhanceBuff implements Buff {
        private static final float DAMAGE_REDUCTION = 20f;
        private static final float DAMAGE_INCREASE = 20f;
        private static final float HULL_BONUS = 20f;

        private String id;
        private float dur;

        public EnhanceBuff(String id, float dur) {
            this.id = id;
            this.dur = dur;
        }

        public void advance(float days) {
            dur -= days;
        }

        public void apply(FleetMemberAPI member) {
            member.getStats().getHullBonus().modifyMult(getId(), 2f);
            member.getStats().getEnergyDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getHighExplosiveDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getKineticDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getFragmentationDamageTakenMult().modifyPercent(getId(), -DAMAGE_REDUCTION);
            member.getStats().getEnergyWeaponDamageMult().modifyPercent(getId(), DAMAGE_INCREASE);
            member.getStats().getMissileWeaponDamageMult().modifyPercent(getId(), DAMAGE_INCREASE);
            member.getStats().getBallisticWeaponDamageMult().modifyPercent(getId(), DAMAGE_INCREASE);
        }

        public String getId() {
            return id;
        }

        public boolean isExpired() {
            return dur <= 0;
        }

        public float getDur() {
            return dur;
        }

        public void setDur(float dur) {
            this.dur = dur;
        }
    }
}
[close]
Why such buffs doesn't work on AI's fleet(I have add them to the fleet)

Hmm - tested this out, by pasting this class into core code, and then doing:

fleet.addScript(new Knight_ArrivalFleetBuffAndAI(fleet, (StarSystemAPI) engine.getCurrentLocation(), engine.getPlayerFleet()));

To a newly-spawned pirate fleet. Made no code changes and it seems to work correctly - it applies the stats in the campaign screen and when spawning the ships in combat. So, I'm not sure why it wouldn't work for you, that's very strange!


Btw, side note: you might want to use an IntervalUtil to apply the buffs instead of checking to see if they're present for every fleet member every frame. This wouldn't matter if there's just one fleet like that but if there are many fleets this sort of thing could add up and be bad for performance.

I'd do something like:

Code: java
	protected IntervalUtil interval = new IntervalUtil(0.1f, 0.15f);

public Knight_ArrivalFleetBuffAndAI(CampaignFleetAPI fleet, StarSystemAPI homeSystem, SectorEntityToken source) { 
super(fleet, homeSystem, source);
interval.forceIntervalElapsed();
}

@Override
public void advance(float amount) {
super.advance(amount);

float days = Global.getSector().getClock().convertToDays(amount);
interval.advance(days);
if (interval.intervalElapsed()) {
// the same code you've already got to refresh/add a buff as needed
}
}

That'd make sure the work is not done on every frame and is spread out between different frames when there are multiple fleets.



I don't mean this and it's not a good idea I think...

And Alex I found that Misc.getInflater() won't find my campaign plugin which has overriden the pickFleetInflater

Is your plugin returning a higher PickPriority?

The core one returns this:
return new PluginPick<FleetInflater>(new DefaultFleetInflater(p), PickPriority.CORE_GENERAL);

For yours, you probably want:
return new PluginPick<FleetInflater>(new DefaultFleetInflater(p), PickPriority.MOD_GENERAL);

Or a higher priority. If you're already doing this, I'd need to have a look at the code.



It's telling that I got through that, and even Alex didn't have an explanation for why stuff didn't Just Work.

Well, I had no idea you were adding new ships and assumed it was vanilla ones! If you'd mentioned this, I'd have pointed you to default_ship_roles right off the bat.

If a question is, for example, phrased like this:
So, do Pirates never get to have Capitals?

I literally just have no idea what exactly you're asking, you know? So many ways this could be interpreted. I think if you try to be more specific, it'll save everyone a lot of headaches; for a lot of your questions, it does seem like you're possibly assuming I know exactly what you're doing. Which I don't, so I end up making assumptions, and this can backfire (as it did here).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 12:29:58 PM
Hmm - tested this out, by pasting this class into core code, and then doing:

fleet.addScript(new Knight_ArrivalFleetBuffAndAI(fleet, (StarSystemAPI) engine.getCurrentLocation(), engine.getPlayerFleet()));

To a newly-spawned pirate fleet. Made no code changes and it seems to work correctly - it applies the stats in the campaign screen and when spawning the ships in combat. So, I'm not sure why it wouldn't work for you, that's very strange!

Is your plugin returning a higher PickPriority?

The core one returns this:
return new PluginPick<FleetInflater>(new DefaultFleetInflater(p), PickPriority.CORE_GENERAL);

For yours, you probably want:
return new PluginPick<FleetInflater>(new DefaultFleetInflater(p), PickPriority.MOD_GENERAL);

Or a higher priority. If you're already doing this, I'd need to have a look at the code.
Well, manager here:(I use inflater to build in a hullmod just now so don't mind that)
Spoiler
Code: java
package data.scripts.campaign.fleet;

import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.combat.BattleCreationContext;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.FleetEncounterContext;
import com.fs.starfarer.api.impl.campaign.fleets.DefaultFleetInflaterParams;
import com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3;
import com.fs.starfarer.api.impl.campaign.fleets.FleetParamsV3;
import com.fs.starfarer.api.impl.campaign.fleets.SourceBasedFleetManager;
import com.fs.starfarer.api.impl.campaign.ids.Abilities;
import com.fs.starfarer.api.impl.campaign.ids.Drops;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
import com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantAssignmentAI;
import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageEntity;
import com.fs.starfarer.api.util.Misc;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import static com.fs.starfarer.api.campaign.FleetEncounterContextPlugin.*;
import static com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.*;
import static com.fs.starfarer.api.impl.campaign.procgen.SalvageEntityGenDataSpec.*;

public class Knight_ArrivalFleetManager extends SourceBasedFleetManager {

    public static final String MEM_ARRIVAL_FLEET_KEY = "$Knight_arrivalFleet";
    private static final int BASIC_DROP_FACTOR = 60;
    private int minPts;
    private int maxPts;
    private int totalLost;

    public Knight_ArrivalFleetManager(SectorEntityToken source, float thresholdLY, int minFleets, int maxFleets, float respawnDelay,
                                      int minPts, int maxPts) {
        super(source, thresholdLY, minFleets, maxFleets, respawnDelay);
        this.minPts = minPts;
        this.maxPts = maxPts;
    }

    @Override
    protected CampaignFleetAPI spawnFleet() {
        Random random = new Random();

        int combatPoints = minPts + random.nextInt(maxPts - minPts + 1);

        int bonus = totalLost * 4;
        if (bonus > maxPts) bonus = maxPts;

        combatPoints += bonus;

        String type = FleetTypes.PATROL_SMALL;
        if (combatPoints > 8) type = FleetTypes.PATROL_MEDIUM;
        if (combatPoints > 16) type = FleetTypes.PATROL_LARGE;

        combatPoints *= 8f;

        FleetParamsV3 params = new FleetParamsV3(
                source.getMarket(),
                source.getLocationInHyperspace(),
                "knight",
                1f,
                type,
                combatPoints, // combatPts
                0f, // freighterPts
                0f, // tankerPts
                0f, // transportPts
                0f, // linerPts
                0f, // utilityPts
                0f // qualityMod
        );
        params.officerNumberBonus = 10;
        params.random = random;

        CampaignFleetAPI fleet = FleetFactoryV3.createFleet(params);
        if (fleet == null) return null;

        if (!(fleet.getInflater() instanceof Knight_ArrivalFleetInflater))
            fleet.setInflater(new Knight_ArrivalFleetInflater((DefaultFleetInflaterParams) fleet.getInflater().getParams()));

        LocationAPI location = source.getContainingLocation();
        location.addEntity(fleet);

        initFleetProperties(random, fleet);

        fleet.setLocation(source.getLocation().x, source.getLocation().y);
        fleet.setFacing(random.nextFloat() * 360f);

        fleet.addScript(new Knight_ArrivalFleetBuffAndAI(fleet, (StarSystemAPI) source.getContainingLocation(), source));

        return fleet;
    }


    @Override
    public void reportFleetDespawnedToListener(CampaignFleetAPI fleet, CampaignEventListener.FleetDespawnReason reason, Object param) {
        super.reportFleetDespawnedToListener(fleet, reason, param);
        if (reason == CampaignEventListener.FleetDespawnReason.DESTROYED_BY_BATTLE) {
            totalLost++;
        }
    }

    private void initFleetProperties(Random random, CampaignFleetAPI fleet) {
        if (random == null) random = new Random();

        fleet.removeAbility(Abilities.EMERGENCY_BURN);
        fleet.removeAbility(Abilities.SENSOR_BURST);
        fleet.removeAbility(Abilities.GO_DARK);

        // to make sure they attack the player on sight when player's transponder is off
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_SAW_PLAYER_WITH_TRANSPONDER_ON, true);
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_FLEET, true);
        fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_ALLOW_LONG_PURSUIT, true);
        fleet.getMemoryWithoutUpdate().set(MEM_ARRIVAL_FLEET_KEY, true);

        //set InteractionConfig
        fleet.getMemoryWithoutUpdate().set(MemFlags.FLEET_INTERACTION_DIALOG_CONFIG_OVERRIDE_GEN,
                new KnightFleetInteractionConfigGen());
        //addRemnantAICoreDrops(random, fleet, 1f);

        long salvageSeed = random.nextLong();
        fleet.getMemoryWithoutUpdate().set(MemFlags.SALVAGE_SEED, salvageSeed);
    }

    public static class KnightFleetInteractionConfigGen implements FIDConfigGen {
        public FIDConfig createConfig() {
            FIDConfig config = new FIDConfig();
            config.showTransponderStatus = false;
            config.delegate = new FIDDelegate() {
                public void postPlayerSalvageGeneration(InteractionDialogAPI dialog, FleetEncounterContext context, CargoAPI salvage) {
                    if (!(dialog.getInteractionTarget() instanceof CampaignFleetAPI)) return;

                    CampaignFleetAPI fleet = (CampaignFleetAPI) dialog.getInteractionTarget();

                    DataForEncounterSide data = context.getDataFor(fleet);
                    List<FleetMemberAPI> losses = new ArrayList<>();
                    for (FleetMemberData fmd : data.getOwnCasualties()) {
                        losses.add(fmd.getMember());
                    }

                    List<DropData> dropRandom = new ArrayList<>();

                    int[] counts = new int[3];
                    String[] groups = new String[]{Drops.AI_CORES1, Drops.AI_CORES2, Drops.AI_CORES3};
                    int bpFactor = 0;
                    for (FleetMemberAPI member : losses) {
                        if (member.isStation()) {
                            counts[2] += 10;
                            bpFactor += 20;
                        }

                        if (member.isCapital()) {
                            counts[2] += 2;
                            bpFactor += 8;
                        } else if (member.isCruiser()) {
                            counts[2] += 1;
                            bpFactor += 4;
                        } else if (member.isDestroyer()) {
                            counts[1] += 1;
                            bpFactor += 2;
                        } else if (member.isFrigate()) {
                            counts[0] += 1;
                            bpFactor += 1;
                        }
                    }

// if (fleet.isStationMode()) {
// counts[2] += 10;
// }

                    for (int i = 0; i < counts.length; i++) {
                        int count = counts[i];
                        if (count <= 0) continue;

                        DropData d = new DropData();
                        d.group = groups[i];
                        d.chances = (int) Math.ceil(count * 1f);
                        dropRandom.add(d);
                    }

                    Random salvageRandom = new Random(Misc.getSalvageSeed(fleet));

                    int bpChance;


                    if (bpFactor < BASIC_DROP_FACTOR) {
                        bpChance = salvageRandom.nextFloat() < (bpFactor / (float) BASIC_DROP_FACTOR) ? 1 : 0;
                    } else {
                        bpChance = bpFactor / BASIC_DROP_FACTOR + salvageRandom.nextFloat() < ((bpFactor % BASIC_DROP_FACTOR) / (float) BASIC_DROP_FACTOR) ? 1 : 0;
                    }

                    DropData bp = new DropData();
                    bp.group = "knight_drop";
                    bp.chances = bpChance;
                    dropRandom.add(bp);

                    CargoAPI extra = SalvageEntity.generateSalvage(salvageRandom, 1f, 1f, 1f, 1f, null, dropRandom);
                    for (CargoStackAPI stack : extra.getStacksCopy()) {
                        salvage.addFromStack(stack);
                    }
                }

                public void notifyLeave(InteractionDialogAPI dialog) {
                }

                public void battleContextCreated(InteractionDialogAPI dialog, BattleCreationContext bcc) {
                    bcc.aiRetreatAllowed = false;
                    bcc.objectivesAllowed = false;
                }
            };
            return config;
        }
    }
}
[close]




Code: java
public class Knight_CampaignPlugin extends BaseCampaignPlugin {
    @Override
    public String getId() {
        return "Knight_campaignPlugin";
    }

    @Override
    public PluginPick<FleetInflater> pickFleetInflater(CampaignFleetAPI fleet, Object params) {
        if (params instanceof DefaultFleetInflaterParams) {
            DefaultFleetInflaterParams p = (DefaultFleetInflaterParams) params;
            if (fleet.getMemoryWithoutUpdate().contains(Knight_ArrivalFleetManager.MEM_ARRIVAL_FLEET_KEY)) {
                return new PluginPick<FleetInflater>(new Knight_ArrivalFleetInflater(p), PickPriority.MOD_SPECIFIC);
            }
        }
        return null;
    }
}
This is in Modplugin
Code: java
    private void syncScriptsIfNeeded() {
        if (!Global.getSector().hasScript(Knight_ArrivalManager.class)) {
            Global.getSector().addScript(new Knight_ArrivalManager());
        }
        Global.getSector().registerPlugin(new Knight_CampaignPlugin());
    }

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2019, 12:38:00 PM
Does Knight_CampaignPlugin also have this method?

public boolean isTransient() {
   return false;
}

By default campaign plugins are transient (which is perhaps a bad choice default), which means if you create a game and the reload it, the plugin would go away unless you re-registered it on game load. Not sure where syncScriptsIfNeeded() gets called from - if it's called on load then that should indeed work.

... OH, never mind. You're 1) creating the fleet and then 2) setting MEM_ARRIVAL_FLEET_KEY to true in its memory. But at that point it's too late, since the inflater was already set at the end of fleet creation. So, what you're doing - manually setting the inflater to something else - is the way to go.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 12:41:46 PM
... OH, never mind. You're 1) creating the fleet and then 2) setting MEM_ARRIVAL_FLEET_KEY to true in its memory. But at that point it's too late, since the inflater was already set at the end of fleet creation. So, what you're doing - manually setting the inflater to something else - is the way to go.
Oh, ***. I know that...But it's a bit strange that I couldn't change anything before the fleet creation
But the buff still not work
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2019, 12:44:13 PM
Are you 100% sure? It worked for me with zero issues, so it's really confusing. Have you tried having it modify some stat you couldn't possibly miss? Say, making the ships do 1000x weapon damage or something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 12:51:31 PM
Are you 100% sure? It worked for me with zero issues, so it's really confusing. Have you tried having it modify some stat you couldn't possibly miss? Say, making the ships do 1000x weapon damage or something?
yes I'm pretty sure. And If I add this to player fleet, it works well! ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2019, 01:10:18 PM
I'm not sure what to suggest, then - based on the code I've seen, it seems like it should work, and it does work on my end. If you could put together a mini-mod that makes this easy to reproduce, I could take another look!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 01:35:11 PM
I'm not sure what to suggest, then - based on the code I've seen, it seems like it should work, and it does work on my end. If you could put together a mini-mod that makes this easy to reproduce, I could take another look!
wired things, in combat it works, but in the More Information , it remains no effect
(https://i.imgur.com/EI53dr8.png)
(https://i.imgur.com/BoqaYql.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 01:44:56 PM
Here is the link
AL+ (https://www.dropbox.com/s/mo80jevjmoi6ubo/ApproLightPlus.zip?dl=0)
enable approlight when use it(I sent u before
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2019, 01:58:07 PM
Ah - buff-related changes would not show up in "more information" since that takes you to the Codex, which shows a "generic" ship of that variant, not the specific one which might have been modified by buffs etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 02:01:31 PM
Ah - buff-related changes would not show up in "more information" since that takes you to the Codex, which shows a "generic" ship of that variant, not the specific one which might have been modified by buffs etc.
well, in fleet interaction dialog, it don't show these changes ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2019, 02:47:18 PM
Aha - same here. Will take a look a bit later. At least now we're both seeing the same thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 13, 2019, 08:44:25 PM
Aha - same here. Will take a look a bit later. At least now we're both seeing the same thing.
O K A Y
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 14, 2019, 10:08:30 AM
Sorted this out - this was a display bug on my end. The stats would indeed be changed by the buff but the tooltip would not show that, for AI fleets only.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 14, 2019, 07:27:03 PM
Sorted this out - this was a display bug on my end. The stats would indeed be changed by the buff but the tooltip would not show that, for AI fleets only.
So this will be fixed in the next update right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 14, 2019, 07:41:03 PM
Correct! To be perfectly clear: what you've got now works but just doesn't show the right values in the tooltip.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 14, 2019, 09:51:14 PM
Correct! To be perfectly clear: what you've got now works but just doesn't show the right values in the tooltip.
okay, I know..
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on March 15, 2019, 12:45:03 PM
Hi, sorry to busy you, but for a purpose to add variant with filled with 4-6 mods but maybe not all enabled, i add them on a another place, where i load them if needed. They are 100% like vanilla variant else.
This is the method addCustomVariant:
https://bitbucket.org/Snrasha/gs/src/master/src/data/scripts/campaign/GS_TinyFleetFactoryV2.java
Quote
37671 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.fleet.CampaignFleetMemberView.renderWeapons(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleetMemberView.renderSingle(Unknown Source)

But, if i have not problem for add a normal ship before, i got a big problem of ships with modules, where these modules do not spawn.
Then, DR has explain me than i needed a existant variant. This is what i have done, but now, i got a problem than i cannot found...

The variant used, here,  is the Cathedral from SWP and do not have any decorative weapon, just one built-in weapon(redeemer), many modules and many built-in hullmods.

Thank for help me to explain what i have go wrong on my thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2019, 12:49:37 PM
I *think* this could be caused by having an invalid weapon slot ID in a variant. IIRC I'd changed the code to throw a more meaningful error when this happens. (Checking: yep, I did.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on March 15, 2019, 01:02:19 PM
I *think* this could be caused by having an invalid weapon slot ID in a variant. IIRC I'd changed the code to throw a more meaningful error when this happens. (Checking: yep, I did.)

How this is possible, when i just used the variant gived per the game? (For some others cases)
https://bitbucket.org/Snrasha/gs/src/master/data/config/gsounty/gladiator_variants/cathedral/
He do not have any invalid weapon slot ID. Like this is the same(who him, load correctly) than one of SWP?  (And for module, they look all good)


EDIT: (yeah, same time than i posted this thing)
Nothing modified except than now, i break the loop when i search a variant valid to use.
Spoiler
(https://i.imgur.com/5S2H3FW.png)
[close]
But work now. What?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2019, 01:12:58 PM
Another possibility could be an invalid weapon ID. But I'm not sure I understand exactly what you mean as far as what works/doesn't work/etc; what I'm saying is just based on the stack trace and what might cause that specific exception.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AngelOfDeathIX on March 20, 2019, 01:57:29 AM
Hey, I'm new to modding this game.  I've got ship and weapon modding down no problem, but now that I'm trying to make a faction to use the stuff I've made, I hit a wall.  Got the faction to show up in game, got the star system generated, now I just need to add a market to one of the planets.  I cannot for the life of me figure out how to do this.  The closest that I've gotten is for the planet to register as "under the control" of my faction, but when I go to it, it only has one dialogue option and when you mouse over the conditions at the top right, it puts the "hovered over" click on repeat.  Here is the code for my market:

Spoiler
Code
		PlanetAPI ventor_ii = system.addPlanet("ventor_ii", ventor_star, "Ventor II", "terran-eccentric", 180, 145, radiusAfter1+2600, 210);
        SectorEntityToken ventor_station = system.addCustomEntity(
                "ventor_station",
                "Ventor II Station",
                "station_side04",
                "ventoran");
        ventor_station.setCircularOrbitPointingDown(system.getEntityById("ventor_ii"), 275, 600, 45);
SectorEntityToken system1 = system.getEntityById("ventor_ii");



MarketAPI ventor_ii_market = Global.getFactory().createMarket("ventor_market", ventor_ii.getName(), 8);
ventor_ii_market.setPlanetConditionMarketOnly(false);
ventor_ii_market.addCondition(Conditions.HABITABLE);
ventor_ii_market.addCondition(Conditions.MILD_CLIMATE);
ventor_ii_market.addCondition(Conditions.ORE_RICH);
ventor_ii_market.addCondition(Conditions.RARE_ORE_RICH);
ventor_ii_market.addCondition(Conditions.ORGANICS_PLENTIFUL);
ventor_ii_market.addCondition(Conditions.FARMLAND_ADEQUATE);
ventor_ii_market.addCondition(Conditions.POPULATION_8);
ventor_ii_market.getFirstCondition(Conditions.HABITABLE).setSurveyed(true);
ventor_ii_market.setPrimaryEntity(ventor_ii);
ventor_ii.setMarket(ventor_ii_market);
ventor_ii_market.setFactionId("ventoran");
ventor_ii_market.addIndustry(Industries.POPULATION);
ventor_ii_market.addIndustry(Industries.STARFORTRESS);
ventor_ii_market.addIndustry(Industries.FARMING);
ventor_ii_market.addIndustry(Industries.MEGAPORT);
ventor_ii_market.addIndustry(Industries.HEAVYBATTERIES);
ventor_ii_market.addIndustry(Industries.HIGHCOMMAND);
ventor_ii_market.addIndustry(Industries.MINING);
ventor_ii_market.addIndustry(Industries.ORBITALWORKS);
ventor_ii_market.addIndustry(Industries.REFINING);
ventor_ii_market.addIndustry(Industries.FUELPROD);
PlanetAPI ventor_iia = system.addPlanet("ventor_iia", ventor_ii, "Ventor IIa", "barren", 180, 65, 450, 40);
[close]

That is in my Mod Plugin .java. 
Result:
Spoiler
(https://i.imgur.com/cX73ApD.jpg)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on March 20, 2019, 09:20:00 AM
Hey, I'm new to modding this game.  I've got ship and weapon modding down no problem, but now that I'm trying to make a faction to use the stuff I've made, I hit a wall.  Got the faction to show up in game, got the star system generated, now I just need to add a market to one of the planets.  I cannot for the life of me figure out how to do this.  The closest that I've gotten is for the planet to register as "under the control" of my faction, but when I go to it, it only has one dialogue option and when you mouse over the conditions at the top right, it puts the "hovered over" click on repeat.  Here is the code for my market:

Spoiler
Code
		PlanetAPI ventor_ii = system.addPlanet("ventor_ii", ventor_star, "Ventor II", "terran-eccentric", 180, 145, radiusAfter1+2600, 210);
        SectorEntityToken ventor_station = system.addCustomEntity(
                "ventor_station",
                "Ventor II Station",
                "station_side04",
                "ventoran");
        ventor_station.setCircularOrbitPointingDown(system.getEntityById("ventor_ii"), 275, 600, 45);
SectorEntityToken system1 = system.getEntityById("ventor_ii");



MarketAPI ventor_ii_market = Global.getFactory().createMarket("ventor_market", ventor_ii.getName(), 8);
ventor_ii_market.setPlanetConditionMarketOnly(false);
ventor_ii_market.addCondition(Conditions.HABITABLE);
ventor_ii_market.addCondition(Conditions.MILD_CLIMATE);
ventor_ii_market.addCondition(Conditions.ORE_RICH);
ventor_ii_market.addCondition(Conditions.RARE_ORE_RICH);
ventor_ii_market.addCondition(Conditions.ORGANICS_PLENTIFUL);
ventor_ii_market.addCondition(Conditions.FARMLAND_ADEQUATE);
ventor_ii_market.addCondition(Conditions.POPULATION_8);
ventor_ii_market.getFirstCondition(Conditions.HABITABLE).setSurveyed(true);
ventor_ii_market.setPrimaryEntity(ventor_ii);
ventor_ii.setMarket(ventor_ii_market);
ventor_ii_market.setFactionId("ventoran");
ventor_ii_market.addIndustry(Industries.POPULATION);
ventor_ii_market.addIndustry(Industries.STARFORTRESS);
ventor_ii_market.addIndustry(Industries.FARMING);
ventor_ii_market.addIndustry(Industries.MEGAPORT);
ventor_ii_market.addIndustry(Industries.HEAVYBATTERIES);
ventor_ii_market.addIndustry(Industries.HIGHCOMMAND);
ventor_ii_market.addIndustry(Industries.MINING);
ventor_ii_market.addIndustry(Industries.ORBITALWORKS);
ventor_ii_market.addIndustry(Industries.REFINING);
ventor_ii_market.addIndustry(Industries.FUELPROD);
PlanetAPI ventor_iia = system.addPlanet("ventor_iia", ventor_ii, "Ventor IIa", "barren", 180, 65, 450, 40);
[close]

That is in my Mod Plugin .java.  
Result:
Spoiler
(https://i.imgur.com/cX73ApD.jpg)
[close]

I think you're actually just missing a few small things, like setting the market conditions to 'surveyed' and maybe adding the submarkets. BUT, for the sake of futureproofing and making it easier for you to do this again later when you want to add more markets, maybe try adding an addMarketplace() function to one of your scripts and calling that instead!

Here's mine, you can copy it entirely if you want:

Code: java
public static MarketAPI addMarketplace(String factionID, SectorEntityToken primaryEntity, ArrayList<SectorEntityToken> connectedEntities, String name,
            int size, ArrayList<String> marketConditions, ArrayList<String> submarkets, Boolean WithJunkAndChatter, Boolean PirateMode) {
        EconomyAPI globalEconomy = Global.getSector().getEconomy();
        String planetID = primaryEntity.getId();
        String marketID = planetID + "market";

        MarketAPI newMarket = Global.getFactory().createMarket(marketID, name, size);
        newMarket.setFactionId(factionID);
        newMarket.setPrimaryEntity(primaryEntity);
        newMarket.getTariff().modifyFlat("generator", newMarket.getFaction().getTariffFraction());

        if (submarkets != null) {
            for (String market : submarkets) {
                newMarket.addSubmarket(market);
            }
        }

        for (String condition : marketConditions) {
            try {
                newMarket.addCondition(condition);
            } catch (RuntimeException e) {
                newMarket.addIndustry(condition);
            }
        }

        if (connectedEntities != null) {
            for (SectorEntityToken entity : connectedEntities) {
                newMarket.getConnectedEntities().add(entity);
            }
        }

        globalEconomy.addMarket(newMarket, WithJunkAndChatter);
        primaryEntity.setMarket(newMarket);
        primaryEntity.setFaction(factionID);

        if (connectedEntities != null) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
                entity.setFaction(factionID);
            }
        }

        if (PirateMode) {
            newMarket.setEconGroup(newMarket.getId());
            newMarket.setHidden(true);
            primaryEntity.setSensorProfile(1f);
            primaryEntity.setDiscoverable(true);
            primaryEntity.getDetectedRangeMod().modifyFlat("gen", 5000f);
            newMarket.getMemoryWithoutUpdate().set(DecivTracker.NO_DECIV_KEY, true);
        } else {
            for (MarketConditionAPI mc : newMarket.getConditions()) {
                mc.setSurveyed(true);
            }
            newMarket.setSurveyLevel(SurveyLevel.FULL);
        }
        
        newMarket.reapplyIndustries();
        return newMarket;
    }

and then in your systemgen script you would call it like so:

Code: java
// the Kadur are reduced to hiding in their heavily-guarded star fortress, towed here through hyperspace following the final battle over Oasis
        SectorEntityToken khs_refugestation = system.addCustomEntity("khs_refugestation", "Star Fortress Requiem", "station_side06", "kadur_remnant");
        khs_refugestation.setInteractionImage("illustrations", "industrial_megafacility");
        khs_refugestation.setCustomDescriptionId("khs_requiem");
        khs_refugestation.setCircularOrbitPointingDown(gehennaII, 0, 220, 70);
        
        MarketAPI khs_refugestationmarket = addMarketplace(
                "kadur_remnant", // faction id
                khs_refugestation, // id or reference of the PRIMARY ENTITY (i.e. in this case the station, could be that or the planet for you)
                null, // LIST of secondary entities, if you want a typical station-and-planet market you'd put a single-item list with one of them in it here
                "Star Fortress Requiem", // name of the market
                5, // size of the market
                new ArrayList<>(
                        Arrays.asList( // list of market_condition and/or industry ids
                                "population_5",
                                "frontier",
                                "headquarters",
                                "stealth_minefields",
                                "khs_kadur_refugees",
                                "khs_kadur_majority",
                                "khs_hardened_populace",
                                "dark",
                                "hydroponics_complex",
                                Industries.POPULATION,
                                Industries.SPACEPORT,
                                Industries.HEAVYBATTERIES,
                                Industries.MILITARYBASE,
                                Industries.WAYSTATION,
                                Industries.STARFORTRESS_MID)),
                new ArrayList<>(
                        Arrays.asList( // which submarkets to generate
                                Submarkets.GENERIC_MILITARY,
                                Submarkets.SUBMARKET_BLACK,
                                Submarkets.SUBMARKET_OPEN,
                                Submarkets.SUBMARKET_STORAGE)),
                                true, // with junk and chatter?
                                false); // pirate mode? (i.e. hidden)
        
        // can't figure out how to add items inside my addmarketplace, too complicated, just brute force it separately
        khs_refugestationmarket.addIndustry(Industries.ORBITALWORKS,new ArrayList<>(Arrays.asList(Items.PRISTINE_NANOFORGE)));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AngelOfDeathIX on March 20, 2019, 12:54:16 PM
I missed quite a few necessary imports so digging for those was a pain, but I finally got it to work, and it works perfectly.  Thanks so much for helping and letting me use your code!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on March 20, 2019, 09:06:30 PM
I missed quite a few necessary imports so digging for those was a pain, but I finally got it to work, and it works perfectly.  Thanks so much for helping and letting me use your code!

Cheers! And sorry about the imports -- I'm used to modders using an IDE like Netbeans, which handles those automatically. Maybe something to look into for you, there's a pretty good tutorial (http://fractalsoftworks.com/forum/index.php?topic=3173.msg45967) for setting it up on the forums. And you can always pop by #creative_corner in the unofficial discord (https://discord.gg/7JS4UJH) if you need more help. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: manictiger on March 25, 2019, 08:49:49 PM
Is there a way to get a specific blueprint to spawn on a specific planet?  I'm trying to make an "extinct faction" that has left behind its blueprints on its former capital planet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 28, 2019, 03:38:05 PM
So I'm making a bunch of custom market conditions for some planets, but it seems that the scan screen doesn't compute their effect at all (whether it is hazard or accessibility changes from other conditions I'm making):

(https://i.imgur.com/w4mSolg.jpg)

The code is nothing special, just a modification of existing vanilla conditions (the commented out portion didn't worked either:

Spoiler
Code: Java
public class US_virus extends BaseHazardCondition implements MarketImmigrationModifier {

    private float DEFENSE_MALUS = 0.5f;
   
    @Override
    public void apply(String id) {
       
        super.apply(id);
//        Object test = Global.getSettings().getSpec(ConditionGenDataSpec.class, condition.getId(), true);
//        if (test instanceof ConditionGenDataSpec) {
//            ConditionGenDataSpec spec = (ConditionGenDataSpec) test;
//            float hazard = spec.getHazard();
//            if (hazard != 0) {
//                market.getHazard().modifyFlat(id, hazard, condition.getName());
//            }
//        }
       
        market.getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).modifyMult(id, DEFENSE_MALUS, "Lingering Virus");
        market.addTransientImmigrationModifier(this);
    }

    @Override
    public void unapply(String id) {
        super.unapply(id);
//        market.getHazard().unmodify(id);
        market.getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).unmodify(id);
        market.removeTransientImmigrationModifier(this);
    }

    @Override
    public void modifyIncoming(MarketAPI market, PopulationComposition incoming) {
        incoming.add(Factions.POOR, 10f);
        incoming.getWeight().modifyFlat(getModId(), getThisImmigrationBonus(), Misc.ucFirst(condition.getName().toLowerCase()));
    }

    private float getThisImmigrationBonus() {
        return -3*market.getSize();
    }
   
    @Override
    protected void createTooltipAfterDescription(TooltipMakerAPI tooltip, boolean expanded) {
        super.createTooltipAfterDescription(tooltip, expanded);
        tooltip.addPara(
                "%s defense rating.",
                10f,
                Misc.getHighlightColor(),
                "" + (int)((DEFENSE_MALUS-1)*100) + "%"
        );
        tooltip.addPara(
                "%s population growth (based on market size).",
                10f,
                Misc.getHighlightColor(),
                "" + (int) getThisImmigrationBonus()
        );
    }
}
[close]

Am I missing something here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2019, 03:59:21 PM
Hmm - seeing the pre-survey screen that shows what the hazard rating is comprised of would be helpful. Nothing jumps out as being wrong here - unless, is the "Military Virus" condition marked as something that's not shown until the planet is surveyed? Hazard-rating-affecting conditions can not require surveying, as the cost of a full survey depends on the hazard rating.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 28, 2019, 04:13:57 PM
Right, it is indeed a discoverable condition and I would have liked to keep it that way but I could live with without. Other conditions I have though really wouldn't feel right to be shown without a survey though.
Stuff like a "Floating Continent" that reduce the hazard of some gas giants, a "Crashed Terraformation Drone" that lower the hazard rating but only for small colonies, or a "Space Elevator" that increases accessibility for small colonies too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2019, 04:18:16 PM
Stuff that increases accessibility should be fine, I *think*. I also believe that the hazard conditions should start working once they're discovered - perhaps just not being reflected in the "colonize" screen, but it might update properly if you actually colonize, or even re-open the colonize screen. Didn't look much into the code, though, so not 100% sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 28, 2019, 04:25:50 PM
That's the issue, neither the accessibility or the hazard seems to be updated when trying to colonize, or even when leaving the planet and then going back to try to colonize it. The modifiers do get applied correctly once the planet is colonized but it's not reflected in any way before that, which is less than idea.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2019, 04:44:58 PM
Took a look; possible I'm missing something but at least this aspect of it is easy to address. Fixed it up so that 1) the hazard from an un-found condition does not apply to the cost to survey (which it didn't to begin with), and 2) the colonize screen reapplies the conditions, so that the hazard rating etc from these is visible in that screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 28, 2019, 04:54:03 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: manictiger on March 29, 2019, 10:49:43 AM
Is there any way to force a specific blueprint to spawn on a planet or derelict?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2019, 11:01:09 AM
You probably want to add a custom drop group to drop_groups.csv (configured to, say, include all blueprints with a certain tag, and whatever chance you like of nothing being there), and then, in the code, something like:

Code: java
DropData d = new DropData();
d.chances = 10; // or whatever number of drop chances you want
d.group = "<your drop group id>";
entity.addDropRandom(d);

I think that ought to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on April 02, 2019, 11:23:11 AM
Acutally I'm wondering about the function of checkOutPerson and returnPerson, I can't understand the meaning of 'check out' and 'return'...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2019, 03:50:27 PM
"Check out" = mark as being used for something specific (the "reason" parameter). "Return" = mark as no longer being used.

For example if a person on the colony is someone you need to make a commodity delivery to, the code for the delivery mission could not handle two missions having the same person as the target. So the person is "checked out" as the delivery target, and then new delivery missions don't pick that person since they're "checked out" for the same reason the new mission wants to check them out for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 04, 2019, 10:19:38 PM
Is there a way to add a new campaign ability to an existing game?

This doesn't seem to do the trick:
Code
package sun.fs;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

public class ModPlugin extends BaseModPlugin {
    @Override
    public void onGameLoad(boolean newGame) {
        if(!Global.getSector().getPlayerFleet().hasAbility("sun_fs_siphon_fuel")) {
            Global.getSector().getCharacterData().addAbility("sun_fs_siphon_fuel");
            Global.getSector().getPlayerFleet().addAbility("sun_fs_siphon_fuel");
        }
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2019, 10:33:19 PM
Hmm - looking at com.fs.starfarer.api.impl.campaign.rulecmd.AddAbility (and possibly how/where it's used) might be helpful. This is how the campaign tutorial adds the abilities along the way.

I *think* what you might be missing is assigning the ability to a slot, and it might already be added and would be visible if you clicked on a slot to assign an ability.

(Global.getSector().getCharacterData().addAbility(abilityId) adds it to the fleet as well, btw.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 04, 2019, 10:46:33 PM
Ok, thanks for the quick reply Alex. I've been clicking an empty skill slot to try to assign it, but no luck. I'll take a look at that file and see what I can learn.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 04, 2019, 10:57:23 PM
Turns out I just forgot to add the modPlugin entry to mod_info.json... Man am I rusty...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 05, 2019, 10:19:25 AM
Happens to the best of us :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 07, 2019, 03:04:37 AM
CombatTaskManagerAPI:
Code: java
	/**
* target should be one of:
* BattleObjectiveAPI
* DeployedFleetMemberAPI
* the result of createWaypoint()
*
* @param type
* @param target
* @param useCommandPointIfNeeded
* @return
*/
AssignmentInfo createAssignment(CombatAssignmentType type, AssignmentTargetAPI target, boolean useCommandPoint);
But neither BattleObjectiveAPI nor DeployedFleetMemberAPI implement the AssignmentTargetAPI interface. Wut?

If I want to give an escort order on a ship in combat, should I create my own class that implements AssignmentTargetAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2019, 09:11:10 AM
Oh, that's... definitely weird. For the moment, you should be able to cast any of these to AssignmentTargetAPI - while the DeployedFleetMemberAPI / BattleObjectiveAPI interfaces do not implement it, the core implementations do.

Let me make these two extend AssignmentTargetAPI; there, done.


If I want to give an escort order on a ship in combat, should I create my own class that implements AssignmentTargetAPI?

(That wouldn't work, btw - the method expects a core implementation, and the AssignmentTargetAPI is more of a marker interface, anyway.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 11, 2019, 08:29:41 AM
So I got reminded of a miscellaneous problem I'm having in relation to fighter wing rarity, and I was kinda wondering if I'm missing something on it.

In a relatively recent update of Shadowyards I added the Shikome, a sort of advanced prototype fighter that's basically just kinda monstrous; suitably for it's lore and capabilities I set it to be pretty rare -- presuming a default weighting of 1, the Shikome has a weighting of 0.05, so it should be getting selected about 1/20th as often as a fighter with the probable default weighting.

This doesn't actually seem to be happening, however, and Shikomes appear regularly in Shadowyards fleets; in fact this query got started by some reporting a battle with 8(!?!?!) of the things at once, which is probably way more than you should encounter at one time. I can only presume I've got the weighting messed up somehow and am wondering if anyone has any insight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 11, 2019, 09:10:50 AM
Actually, since we recently got a documentation post about loot drops, I owuldn't mind an in-depth look at how rarity works for everything, weapons wings and hulls.

The way I understand it, it is highly dependent on the number of available hulls for each role, and I suspect having a few rarity "tiers" rather than just a multiplier would help maintaining a consistent rarity regarless of the number of active mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 11, 2019, 10:46:28 AM
Rarity is just for drops - it doesn't affect fleet composition or weapon/fighter selection at all.

For weapons, higher tier means a lower chance of being available. For fighters, this isn't the case - there aren't enough fighters, i.e. there's no "Talon, but worse" and "Talon, but better" etc progression for each kind of fighter, so that didn't work very well. Instead, it just picks a couple of the available fighters for each autofit category.

com.fs.starfarer.api.impl.campaign.fleets.DefaultFleetInflater.java is a good place to look for the details; if you want specific behavior with regard to rarity etc, writing a custom one is probably the way to go. See also: CampaignPlugin.pickFleetInflater().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 11, 2019, 11:20:27 AM
Alright, gotcha; thanks for the heads up then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on April 12, 2019, 01:50:32 PM
Is there any way to get weapon Impact via script? I don't see it in any of the methods on WeaponAPI, WeaponSpecAPI, DamagingProjectileAPI, or DamageAPI, but I might just have missed it.

Also curious about weapon spread stats -- the only one that seems accessible is current spread via getCurrSpread() but it'd be nice to be able to get min, max, per shot, and decay from the WeaponAPI as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2019, 04:20:44 PM
Is there any way to get weapon Impact via script? I don't see it in any of the methods on WeaponAPI, WeaponSpecAPI, DamagingProjectileAPI, or DamageAPI, but I might just have missed it.

There isn't, no. (And it's somewhat non-trivial to expose as it's part of an internal ProjectileSpec class that's not currently exposed in the API at all. Like, it's not hard, but it's also not just me adding a method to an existing interface.)

Also curious about weapon spread stats -- the only one that seems accessible is current spread via getCurrSpread() but it'd be nice to be able to get min, max, per shot, and decay from the WeaponAPI as well.

Ah, let me add methods for these to WeaponSpecAPI - done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on April 12, 2019, 06:07:43 PM
Is there any way to get weapon Impact via script? I don't see it in any of the methods on WeaponAPI, WeaponSpecAPI, DamagingProjectileAPI, or DamageAPI, but I might just have missed it.

There isn't, no. (And it's somewhat non-trivial to expose as it's part of an internal ProjectileSpec class that's not currently exposed in the API at all. Like, it's not hard, but it's also not just me adding a method to an existing interface.)

Also curious about weapon spread stats -- the only one that seems accessible is current spread via getCurrSpread() but it'd be nice to be able to get min, max, per shot, and decay from the WeaponAPI as well.

Ah, let me add methods for these to WeaponSpecAPI - done.

Ah, I see. Thanks for adding the spread methods! Out of curiosity, will those values just be readable, or did you add .set methods too?  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2019, 06:13:45 PM
With the set methods, yes.

I'm curious - is anyone actually using setXXX() methods in WeaponSpecAPI? Those change the values for all weapons of that type, not just the weapon in question. ... ahhh, right, there's WeaponAPI.ensureClonedSpec() for this; never mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zmey on April 15, 2019, 07:08:44 AM
Are there schematics for projectile trail plugins? What do I need to make one besides graphics of trails, vector utis.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on April 15, 2019, 09:14:25 AM
For basic projectile trails you just need to load the texture in your settings.json and duplicate trail_data.csv from MagicLib to your mod with your projectile entry. There are more detailed instructions in the original file.

For advanced stuff, you can take a look at the Trail manager script in MagicLib for pointers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on April 17, 2019, 12:50:00 AM
On the topic of weapon-related API methods, is there a way to get the burst duration of a beam? Either the "burst size" value or the actual burst duration including chargedown. WeaponSpecAPI.getBurstSize() returns an int, and DamageAPI.getDpsDuration() seems to be a dynamic counter for the actual amount of time since the last damage tick or something to that effect, and neither of those seem to work.

EDIT: Wait, I found it! DerivedWeaponStatsAPI.getBurstFireDuration() works. I'll leave this here so others might see it if they're likewise confused.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 17, 2019, 09:23:10 AM
Let me add getBurstDuration() to WeaponSpecAPI, all the same.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JDCollie on April 17, 2019, 11:21:53 AM
Where/how do I control if a faction requires a commission to access military markets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 21, 2019, 01:21:51 PM
As a bit of a followup to my earlier question are there any particular steps I would need to do in order to get an extension of the DefaultFleetInflater set up, or is it more likely that I'll just have to put in a complete replacement of the class?

E: To be more clear I currently have an extension of the DefaultFleetInflater written as a plugin, which I decided on because I was hoping to avoid having to replace the entire Inflater. It replaces the public void inflate section with some modifications to try and adjust the fighter spawning. However, as it currently doesn't seem to be doing anything and trying to directly load the plugin causes a crash, I figure I've gotten things mixed up somewhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 21, 2019, 03:56:36 PM
Once you've got your inflater written, you'll want to either:

1)

YourInflater inflater = new YourInflater();
// do whatever config is necessary
fleet.setInflater(inflater);

or

2)

Override this method:
public PluginPick<FleetInflater> pickFleetInflater(CampaignFleetAPI fleet, Object params)

In a CampaignPlugin.

Either one will ultimately assign your inflater to the fleet. The first method works if you're spawning the fleet yourself; the second method can work then too, but would also work if you wanted to change the inflater for a fleet being spawned by, say, core vanilla code - without changing said code to set the inflater directly. Does this make sense/clear things up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 21, 2019, 04:28:59 PM
so presumably something like this then?

Code: java
    @Override
    public PluginPick<FleetInflater> pickFleetInflater(CampaignFleetAPI fleet, Object params) {
        DefaultFleetInflaterParams p = null;
        return new PluginPick<FleetInflater>(new MS_FleetInflaterPlugin(p), CampaignPlugin.PickPriority.MOD_SET);
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 21, 2019, 04:45:05 PM
This would set your inflater to be used for all fleets - so, if that's what you want, yes.

Also "params" is going to be an instance DefaultFleetInflaterParams, so you probably want to cast that and pass that in, like so:

Code: java
if (params instanceof DefaultFleetInflaterParams) {
    DefaultFleetInflaterParams p = (DefaultFleetInflaterParams) params; 
    return new PluginPick<FleetInflater>(new MS_FleetInflaterPlugin(p), CampaignPlugin.PickPriority.MOD_SET); 
}
return null;

The "instanceof" check being necessary just in case a mod uses a different kind of inflater with a different params class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 21, 2019, 05:03:18 PM
For the moment at least, since the main reasoning behind this is controlling some of the fighter spawning behavior. It would probably be more stable if I had it set up to only effect Shadowyards related fleet spawns though; not quite sure how to do that just yet, however.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 21, 2019, 05:09:51 PM
For the moment at least, since the main reasoning behind this is controlling some of the fighter spawning behavior. It would probably be more stable if I had it set up to only effect Shadowyards related fleet spawns though; not quite sure how to do that just yet, however.

Something like:

if (params instanceof DefaultFleetInflaterParams && fleet.getFactionId().equals("shadowyards")) {

Unless that's not what you mean.

That's generally the point of the various pickXXXPlugin methods - they check the parameters to see whether they should provide a custom implementation or return null and let something else handle it (such as the default implementation).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 21, 2019, 05:35:33 PM
That is exactly what I mean; it's a lot simpler than I was expecting, though I kinda have a bad habit of overcomplicating things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on April 23, 2019, 10:43:38 AM
Is there any way to "catch" damage and modify it before it's taken by a ship?

Specifically what I'm looking for is a way to make a hullmod that reduces High Explosive damage by a percentage that scales upward with total, i.e. the ship takes 50% of the damage from a Hammer, but 90% of the damage from a Light Assault Gun. It looks like the stuff I might want could possibly exist through some method on CombatDamageData but I'm not sure if damage is held there for a frame so it can be modified or how to do that exactly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2019, 10:58:12 AM
It's not possible, no - there's no hook to modify the damage as it's being applied.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on April 23, 2019, 11:09:22 AM
It's not possible, no - there's no hook to modify the damage as it's being applied.

Alas :( but thanks for the confirmation! Any way this could go on a to-do list for some point in the distant future?

EDIT: Wait, is there a way to get damage dealt to a ship in the last frame? I might be able to implement the concept in a hacky alternative and slightly different way anyway :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2019, 11:58:12 AM
Alas :( but thanks for the confirmation! Any way this could go on a to-do list for some point in the distant future?

Yeah, though I'm not sure if I'll get to it. It's a bit tricky for various reasons.

EDIT: Wait, is there a way to get damage dealt to a ship in the last frame? I might be able to implement the concept in a hacky alternative and slightly different way anyway :P

I think other mods may have done similar-ish things, but I'm not entirely sure how/what the best way to go about it would be.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on April 25, 2019, 07:21:03 PM
A rather silly question I'm afraid:
I want to make a mod for a makeshift salvage gantry. It will be exactly the same as the current one except with worse bonus and the ability to get it in the skill tree (like Expanded Missile Rack for example). But the hull mod is located in a java file so I guess it's related to its action in the campaign and not just for combat like most mods located in the data folder.
So how do I get my hullmod in a .java file? Is it like opening it with a archive software like WinRAR or so? Or can I put it in the data folder of my mod like other hullmods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 25, 2019, 07:54:34 PM
I suspect the only reason the salvage gantry script isn't in the hullmods folder is that it's more complex than most hullmod scripts. I don't see any reason you wouldn't be able copy the code from com.fs.starfarer.api.impl.campaign.RepairGantry into a script located in the folder (but I may be wrong). Here's the code:
Spoiler
Code
package com.fs.starfarer.api.impl.campaign;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.GameState;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.ui.LabelAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.Misc;

public class RepairGantry extends BaseHullMod {

private static Map mag = new HashMap();
static {
mag.put(HullSize.FRIGATE, 10f);
mag.put(HullSize.DESTROYER, 25f);
mag.put(HullSize.CRUISER, 30f);
mag.put(HullSize.CAPITAL_SHIP, 40f);
}

public static final float BATTLE_SALVAGE_MULT = .2f;
public static final float MIN_CR = 0.1f;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
//stats.getDynamic().getMod(Stats.SALVAGE_VALUE_MULT_MOD).modifyFlat(id, SALVAGE_MODIFIER);
stats.getDynamic().getMod(Stats.SALVAGE_VALUE_MULT_MOD).modifyFlat(id, (Float) mag.get(hullSize) * 0.01f);
//stats.getDynamic().getMod(Stats.BATTLE_SALVAGE_VALUE_MULT_MOD).modifyFlat(id, (Float) mag.get(hullSize) * 0.01f * (Float) mag.get(hullSize) * 0.01f);
}

public String getDescriptionParam(int index, HullSize hullSize) {
//if (index == 0) return "" + (int) (SALVAGE_MODIFIER * 100f);
//if (index == 1) return "" + (int) (BATTLE_SALVAGE_MODIFIER * 100f);

if (index == 0) return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue() + "%";
if (index == 1) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue() + "%";
if (index == 2) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue() + "%";
if (index == 3) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue() + "%";
if (index == 4) return "" + (int)Math.round(BATTLE_SALVAGE_MULT * 100f) + "%";

return null;
}

@Override
public void advanceInCombat(ShipAPI ship, float amount) {

}


@Override
public boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec) {
return true;
}

@Override
public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
float pad = 3f;
float opad = 10f;
Color h = Misc.getHighlightColor();
Color bad = Misc.getNegativeHighlightColor();

tooltip.addPara("Each additional ship with a salvage gantry provides diminishing returns.", opad);

if (isForModSpec || ship == null) return;
if (Global.getSettings().getCurrentState() == GameState.TITLE) return;

CampaignFleetAPI fleet = Global.getSector().getPlayerFleet();
float fleetMod = getAdjustedGantryModifier(fleet, null, 0f);
float currShipMod = (Float) mag.get(hullSize) * 0.01f;

float fleetModWithOneMore = getAdjustedGantryModifier(fleet, null, currShipMod);
float fleetModWithoutThisShip = getAdjustedGantryModifier(fleet, ship.getFleetMemberId(), 0f);

tooltip.addPara("The total resource recovery bonus for your fleet is %s.", opad, h,
"" + (int)Math.round(fleetMod * 100f) + "%");

float cr = ship.getCurrentCR();
for (FleetMemberAPI member : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
if (member.getId().equals(ship.getFleetMemberId())) {
cr = member.getRepairTracker().getCR();
}
}

if (cr < MIN_CR) {
LabelAPI label = tooltip.addPara("This ship's combat readiness is below %s " +
"and the gantry can not be utilized. Bringing this ship into readiness " +
"would increase the fleetwide bonus to %s.",
opad, h,
"" + (int) Math.round(MIN_CR * 100f) + "%",
"" + (int)Math.round(fleetModWithOneMore * 100f) + "%");
label.setHighlightColors(bad, h);
label.setHighlight("" + (int) Math.round(MIN_CR * 100f) + "%", "" + (int)Math.round(fleetModWithOneMore * 100f) + "%");

// tooltip.addPara("Bringing this ship into readiness " +
// "would increase the fleet's bonus to %s.", opad, h,
// "" + (int)Math.round(fleetModWithOneMore * 100f) + "%");
} else {
if (fleetMod > currShipMod) {
tooltip.addPara("Removing this ship would decrease it to %s. Adding another ship of the same type " +
"would increase it to %s.", opad, h,
"" + (int)Math.round(fleetModWithoutThisShip * 100f) + "%",
"" + (int)Math.round(fleetModWithOneMore * 100f) + "%");
} else {
tooltip.addPara("Adding another ship of the same type " +
"would increase it to %s.", opad, h,
"" + (int)Math.round(fleetModWithOneMore * 100f) + "%");
}
}

tooltip.addPara("The fleetwide post-battle salvage bonus is %s.", opad, h,
"" + (int)Math.round(getAdjustedGantryModifierForPostCombatSalvage(fleet) * 100f) + "%");
// "" + Misc.getRoundedValueMaxOneAfterDecimal(
// getAdjustedGantryModifierForPostCombatSalvage(fleet) * 100f) + "%");

}


public static float getAdjustedGantryModifierForPostCombatSalvage(CampaignFleetAPI fleet) {
return getAdjustedGantryModifier(fleet, null, 0) * BATTLE_SALVAGE_MULT;
}

public static float getAdjustedGantryModifier(CampaignFleetAPI fleet, String skipId, float add) {
//List<Pair<FleetMemberAPI, Float>> values = new ArrayList<Pair<FleetMemberAPI,Float>>();

float max = 0f;
float total = 0f;
for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
if (member.isMothballed()) continue;
if (member.getRepairTracker().getCR() < MIN_CR) continue;

if (member.getId().equals(skipId)) {
continue;
}
float v = member.getStats().getDynamic().getMod(Stats.SALVAGE_VALUE_MULT_MOD).computeEffective(0f);
if (v <= 0) continue;

// Pair<FleetMemberAPI, Float> p = new Pair<FleetMemberAPI, Float>(member, v);
// values.add(p);
if (v > max) max = v;
total += v;
}
if (add > max) max = add;
total += add;

if (max <= 0) return 0f;
float units = total / max;
if (units <= 1) return max;
float mult = Misc.logOfBase(2.5f, units) + 1f;
float result = total * mult / units;
if (result <= 0) {
result = 0;
} else {
result = Math.round(result * 100f) / 100f;
result = Math.max(result, 0.01f);
}
return result;
}
}
[close]

Instead of copying the code in it's entirety, I'd recommend extending the RepairGantry class if you're comfortable with that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 25, 2019, 09:04:27 PM
There's a good chance it wouldn't work as a loose script - I don't think enhanced for loops are supported by Janino, though I could be misremembering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 25, 2019, 09:11:32 PM
There's a good chance it wouldn't work as a loose script - I don't think enhanced for loops are supported by Janino, though I could be misremembering.
Oh, that's a good point. I didn't consider Janino limitations.

@MajorTheRed:
Feel free to hit me up on Discord or PM me if you run into any trouble.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 30, 2019, 03:56:35 PM
Is there a reliable way to get the affected FleetMemberAPI from within BaseHullMod.applyEffectsBeforeShipCreation?
I'm working on a way to add randomly generated traits to ships, like this:
Spoiler
(https://i.imgur.com/Vsr5yNQ.jpg)
[close]
(Yes, I'm stealing Voiddweller's idea (http://fractalsoftworks.com/forum/index.php?topic=15291.0))

Currently, I'm appending the ship's ID to it's variant ID and using that as an identifier, like this:
Code
    FleetMemberAPI findShip(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats) {
        List<FleetMemberAPI> members = Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy();

        for (FleetMemberAPI s : members) {
            if (stats.getVariant().getHullVariantId().equals(s.getVariant().getHullVariantId())) {
                return s;
            }
        }

        return null;
    }
stats.getEntity frequently seems to return null, unfortunately.

If there's no better approach, does anyone have any advice for improving the reliability of the variant ID method I'm currently using? The only problem I've found so far is that the 'hullmod' effects aren't applied while the ship is in storage, but this is a very dirty hack, so I have some concerns (like the variant ID changing).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 30, 2019, 04:19:38 PM
Hmm - how about "if (stats == s.getStats())? I *think* that ought to do it.

(Yes, I'm stealing Voiddweller's idea (http://fractalsoftworks.com/forum/index.php?topic=15291.0))

Variations on this have come up once or twice, and I'm pretty sure I've thought about almost this exact thing several times :) Very cool to see you doing it, this looks amazing!

(And I'm also unreasonably excited by the extensive use of the TooltipMakerAPI features on display here.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 30, 2019, 05:40:28 PM
Hmm - how about "if (stats == s.getStats())? I *think* that ought to do it.
I may be misremembering, but I think the case in which that didn't work was the refit screen. I assume a copy of the ship is used there that has a new stats instance. I'll test that out again though.

Variations on this have come up once or twice, and I'm pretty sure I've thought about almost this exact thing several times :) Very cool to see you doing it, this looks amazing!
Glad you think so! If you ever do decide to implement something like this (which would be awesome), hopefully my mod would help you avoid whatever design mistakes I inevitably end up making  :)

(And I'm also unreasonably excited by the extensive use of the TooltipMakerAPI features on display here.)
I was likewise unreasonably excited when I found out how much tooltip versatility was exposed by the API  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 30, 2019, 05:56:06 PM
I may be misremembering, but I think the case in which that didn't work was the refit screen. I assume a copy of the ship is used there that has a new stats instance. I'll test that out again though.

Yeah, it might be worth another look. You could definitely be right, but at least looking at the code briefly, it doesn't seem like that should be the case. Unfortunately not a great time for me to delve into this right now, what with .1 being very soon.

Glad you think so! If you ever do decide to implement something like this (which would be awesome), hopefully my mod would help you avoid whatever design mistakes I inevitably end up making  :)

I was likewise unreasonably excited when I found out how much tooltip versatility was exposed by the API  :)

:D The latter, if we're being honest, is largely a product of me using it for so much of the core stuff.

(Oh, hey, minor random thing I noticed in the tooltip: it should be "its" rather than "it's" in all three places. Sorry, I'm a bit ocd about that, though naturally I also make my share of mistakes :D)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 01, 2019, 12:26:13 AM
Unfortunately not a great time for me to delve into this right now, what with .1 being very soon.
No worries. Trust me; I don't want to slow you down!

it should be "its" rather than "it's" in all three places.
Thanks! Wow, I must make that mistake a lot...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 02, 2019, 11:01:17 AM
How does EmpResistance on MissileAPIs work?  ???

Code: java
	/**
* Number of times a missile will ignore being hit by an system EMP *arc* (not emp damage) instead of flaming out.
* @param empResistance
*/
void setEmpResistance(int empResistance);
int getEmpResistance();
void decrEMPResistance();

I mean, how to use the methods is pretty self-explanatory, but what I'm wondering is:
1) Do missiles have any "innate" EmpResistance? Is it based on HP?
2) Will arcs created by spawnEmpArc or spawnEmpArcPierceShields always flame out a missile (regardless of damage/EMP damage) if they hit one with no EmpResistance remaining?
3) Is there any relation to arc damage or arc EMP damage in any part of this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 02, 2019, 11:37:30 AM
No/yes/no :)

Basically it's a (currently) modding-only thing that you can use to have missiles ignore a fixed number of EMP arc hits.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 02, 2019, 11:49:02 AM
Ah okay, awesome. I was kinda imagining it'd be tied to HP, like missiles would get one EmpResistance for every 400 HP or something. This is much simpler, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 07, 2019, 09:29:31 AM
If two mods use the same key for a list of strings in the "custom" section of a faction's JSON, will the lists merge when using getCustom() in FactionAPI?

For example:
Code: JSON
# mod A
"custom":{
   "ListKey":[
      "item1"
   ]
}
and

Code: JSON
# mod B
"custom":{
   "ListKey":[
      "item2",
      "item3"
   ]
}
results in "ListKey":["item1", "item2", "item3]?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2019, 10:07:55 AM
I believe so, but I'm not 100% sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 07, 2019, 01:43:53 PM
Can someone confirm if this error is from the core game, and not my mod?
Game crashed during combat (missile heavy)

Code
266937 [Thread-4] INFO  org.histidine.chatter.ChatterDataManager  - Assigning character default to officer  
266937 [Thread-4] INFO  org.histidine.chatter.ChatterDataManager  - Assigning character badass to officer 
373840 [Thread-8] INFO  sound.public  - Cleaning up music with id [Battle - Accelerated World.ogg]
373938 [Thread-10] INFO  sound.public  - Creating streaming player for music with id [Battle - Accelerated World.ogg]
373944 [Thread-10] INFO  sound.null  - Playing music with id [Battle - Accelerated World.ogg]
374465 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.C.oooO.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.missile.MirvAI.checkSplit(Unknown Source)
at com.fs.starfarer.combat.ai.missile.MirvAI.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2019, 02:00:46 PM
This *may* be caused by a missing "splitSound" from a MIRV missile's behaviorSpec.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 08, 2019, 06:59:47 AM
Hmm... I know it's possible to make a shipsystem that boosts energy or ballistic


but is it possible to make one that boosts only PD weapons? Or failing that, only small ones?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 08, 2019, 07:35:40 AM
Another question:

Sometimes when I mouse over a fleet I get a crash and this in the errorlog. Seems to happen also with fleets that aren't form my mod, so I assume this is a core game issue?

Code
1328127 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.plugins.impl.CoreAutofitPlugin.fitFighters(CoreAutofitPlugin.java:907)
at com.fs.starfarer.api.plugins.impl.CoreAutofitPlugin.doFit(CoreAutofitPlugin.java:380)
at com.fs.starfarer.api.impl.campaign.fleets.DefaultFleetInflater.inflate(DefaultFleetInflater.java:395)
at com.fs.starfarer.campaign.fleet.CampaignFleet.inflateIfNeeded(Unknown Source)
at com.fs.starfarer.ui.impl.StandardTooltipV2.createFleetTooltip(Unknown Source)
at com.fs.starfarer.campaign.C.super(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 08, 2019, 11:43:02 AM
Would anyone here know how to get a script reference from a .json? I think all the examples in Starsector vanilla are buried in the obfuscated APIs, or at least, all the ones I thought to check.

Specifically, I want to call whatever script is referenced in a string in a .json file. Like how shipsystem JSONs have
Code: java
"aiScript":"data.shipsystems.scripts.ai.VayraFluxOverdriveAI",
How do I write java to call the script at a dynamic string address? I can load values, lists, and maps from a JSON fine but I have no idea how to load a script from one.  :-\


EDIT: LazyWizard, that beautiful titan of intellect, answered my question on the Discord. For anyone else struggling with this who finds this post, they linked their Console Commands source as an example: https://bitbucket.org/LazyWizard/console-commands/src/ca2384da59e8508b6dd8914fe8f0a62da32ce349/src/main/java/org/lazywizard/console/CommandStore.java#lines-76
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2019, 12:07:30 PM
An alternate, simpler but more limited solution:

1) Put plugin in the "plugins" section in settings.json, i.e.:
"plugins":{
    "aiScript":"data.shipsystems.scripts.ai.VayraFluxOverdriveAI",
}
2) Call Global.getSettings().getNewPluginInstance("aiScript");

Under the hood this does much the same thing as LW's code. The limitation is, of course, that for this to work, the config needs to be in the "plugins" section of the settings file.


Hmm... I know it's possible to make a shipsystem that boosts energy or ballistic

but is it possible to make one that boosts only PD weapons? Or failing that, only small ones?

Stats-wise, yeah. As far as the visual glow, I don't think so - the current "make it glow" code is limited to weapon mount types, i.e. energy/ballistic/missile.

Sometimes when I mouse over a fleet I get a crash and this in the errorlog. Seems to happen also with fleets that aren't form my mod, so I assume this is a core game issue?

Fairly sure this is an issue with invalid fighter wing ids being available to a faction, but not 100%. If you want to make dig in a bit, you can open up:

com.fs.starfarer.api.plugins.impl.CoreAutofitPlugin.fitFighters(CoreAutofitPlugin.java:907)

To line 907 and see what it says; might help point us in the right direction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 08, 2019, 09:47:27 PM
How do you make a fleet drop extra credits during salvage?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 08, 2019, 10:37:18 PM
How do you make a fleet drop extra credits during salvage?
I know it's possible to do that by overriding com.fs.starfarer.api.impl.campaign.FleetEncounterContextPlugin.getCreditsLooted(), but that has a lot of downsides.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 08, 2019, 10:43:54 PM
How do you make a fleet drop extra credits during salvage?

I am also interested in the answer to this
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 09, 2019, 05:30:10 AM
Sometimes when I mouse over a fleet I get a crash and this in the errorlog. Seems to happen also with fleets that aren't form my mod, so I assume this is a core game issue?

Fairly sure this is an issue with invalid fighter wing ids being available to a faction, but not 100%. If you want to make dig in a bit, you can open up:

com.fs.starfarer.api.plugins.impl.CoreAutofitPlugin.fitFighters(CoreAutofitPlugin.java:907)

To line 907 and see what it says; might help point us in the right direction.


Line 097 is if (!category.fallback.isEmpty()) {

Code
		FighterWingSpecAPI desired = Global.getSettings().getFighterWingSpec(desiredWingId);
if (desired == null) continue;

//List<String> categories = getCategoriesInPriorityOrder(desired.getTags());
List<String> categories = desired.getAutofitCategoriesInPriorityOrder();

List<String> alternate = altWeaponCats.get(desired);
if (randomize && (alternate != null || random.nextFloat() < RANDOMIZE_CHANCE)) {
if (alternate == null) {
alternate = new ArrayList<String>();
for (String cat : categories) {
Category category = this.categories.get(cat);
if (!category.fallback.isEmpty()) {
int index = random.nextInt(category.fallback.size() - 1) + 1;
if (index != 0) {
alternate.add(category.fallback.get(index));
}
}
}
altFighterCats.put(desired, alternate);
}
if (!alternate.isEmpty()) {
categories = alternate;
}
} else if (randomize) {
altFighterCats.put(desired, new ArrayList<String>());
}



Also, regarding the PD booster, would this work (I'm not sure my syntax is corrrect)

Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.impl.combat.BaseShipSystemScript;

public class sc_pd_booster extends BaseShipSystemScript {


    @Override
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {

        stats.getMaxSpeed().modifyMult(id, 1-(effectLevel*0.75f));
        stats.getMaxTurnRate().modifyMult(id, 1-(effectLevel*0.5f));

        stats.getAutofireAimAccuracy().modifyMult(id, 2+effectLevel);
        stats.getPDWeaponRangeBonus().modifyMult(id, 1+(effectLevel));
        stats.getPDWeaponDamageBonus().modifyMult(id, 1+(effectLevel));
    }

    @Override
    public void unapply(MutableShipStatsAPI stats, String id) {
        stats.getMaxSpeed().unmodify(id);
        stats.getMaxTurnRate().unmodify(id);

        stats.getAutofireAimAccuracy().unmodify(id);
        stats.getBallisticWeaponRangeBonus().unmodify(id);
        stats.getPDWeaponRangeBonus().unmodify(id);
        stats.getPDWeaponDamageBonus().unmodify(id);
    }

    @Override
    public StatusData getStatusData(int index, State state, float effectLevel) {
        float bonusPercent = (int) (effectLevel * 100f);
        if (index == 0) {
            return new StatusData("PD 0verdrive" + (int) bonusPercent + "%", false);
        }
        return null;
    }
}


Do getPDWeaponDamageBonus() and getPDWeaponRangeBonus() even exist?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 09, 2019, 01:11:11 PM
How do you make a fleet drop extra credits during salvage?

I am also interested in the answer to this

I don't think there's any easy/direct way to do that.


Line 097 is if (!category.fallback.isEmpty()) {

This most likely means one of the fighter wings in one of the mods has an invalid autofit tag.
For example if one had something like this:
fihgter4 (note the spelling)
That might do it. As might an entirely new tag with a number after it (such as say "blah12").

(I might be misremembering something, btw. If anyone else can chime in? This has come up before, iirc.)

Also, regarding the PD booster, would this work (I'm not sure my syntax is corrrect)

Do getPDWeaponDamageBonus() and getPDWeaponRangeBonus() even exist?

You can check the javadoc to see what methods exist. IIRC for PD it might be just range modifiers, not 100% sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 09, 2019, 02:19:23 PM
How do you make a fleet drop extra credits during salvage?

I am also interested in the answer to this

I don't think there's any easy/direct way to do that.

Nooooooo  :'(

Line 097 is if (!category.fallback.isEmpty()) {

This most likely means one of the fighter wings in one of the mods has an invalid autofit tag.
For example if one had something like this:
fihgter4 (note the spelling)
That might do it. As might an entirely new tag with a number after it (such as say "blah12").

(I might be misremembering something, btw. If anyone else can chime in? This has come up before, iirc.)

My mod was causing a very similar crash (crashing on mouseover of SOME fleets SOMETIMES) and someone PM'd me on Discord to tell me that they asked you about it and you said that something like this ("messed up tags") was the cause then too, so I'd buy that as the answer for sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 10, 2019, 02:57:44 PM
Also, regarding the PD booster, would this work (I'm not sure my syntax is corrrect)

Do getPDWeaponDamageBonus() and getPDWeaponRangeBonus() even exist?

You can check the javadoc to see what methods exist. IIRC for PD it might be just range modifiers, not 100% sure.

Well, I can't find a single method that is designed to boost PD. At all. Something that could be added in the near future.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 11, 2019, 08:25:54 AM
Line 097 is if (!category.fallback.isEmpty()) {

This most likely means one of the fighter wings in one of the mods has an invalid autofit tag.
For example if one had something like this:
fihgter4 (note the spelling)
That might do it. As might an entirely new tag with a number after it (such as say "blah12").

(I might be misremembering something, btw. If anyone else can chime in? This has come up before, iirc.)

My mod was causing a very similar crash (crashing on mouseover of SOME fleets SOMETIMES) and someone PM'd me on Discord to tell me that they asked you about it and you said that something like this ("messed up tags") was the cause then too, so I'd buy that as the answer for sure.


Ahh..I went trough the files a dozen times. Mission works fine. But mouse over a fleet and crash.

Here's my entire wing_data file. Can anyone see something wrong? Because I can't.

Code
id,variant,tags,tier,rarity,fleet pts,op cost,formation,range,attackRunRange,attackPositionOffset,num,role,role desc,refit,base value,,,,,,,,,,,,,number
dart_wing,ftg1-f-dart_variant,"fighter2, interceptor, low, basic_bp",1,,6,8,BOX,4000,500,,4,INTERCEPTOR,Interceptor,10,1800,,,,,,,2002,,,,,,
follower_wing,ftg1-f-follower_variant,"fighter2, interceptor, low, lowtech_bp",1,,5,8,V,4000,500,,4,INTERCEPTOR,Interceptor,10,1500,,,,,,,2008,,,,,,
stunner_wing,ftg1-f-stunner_variant,"fighter2, fighter, low, midline_bp",2,,4,8,BOX,4000,500,,4,SUPPORT,Support,10,4500,,,,,,,20608,,,,,,

hunter_wing,pir1-f-hunter_variant,"fighter2, fighter, low, pirate_bp",1,,5,8,V,4000,500,,4,INTERCEPTOR,Interceptor,10,2000,,,,,,,20202,,,,,,
harpoon_wing,pir1-f-harpoon_variant,"fighter2, fighter, low, pirate_bp",1,,3,8,V,4000,500,,4,SUPPORT,Support,10,4500,,,,,,,202023,,,,,,
sparker_wing,pir1-f-sparker_variant,"fighter2, fighter, low, pirate_bp",2,,2,8,V,4000,500,,4,ASSAULT,Assault,10,12000,,,,,,,7624,,,,,,

mig99_wing,rsf1-f-mig99_variant,"fighter2, interceptor, low, rsf_bp1",1,,5,8,BOX,4000,500,,4,INTERCEPTOR,Interceptor,6,3000,,,,,,,2002,,,,,,
su57_wing,rsf1-f-su57_variant,"fighter2, fighter, low, rsf_bp1",2,,3,8,CLAW,4000,500,,3,SUPPORT,Support,8,6000,,,,,,,2000,,,,,,
su74_wing,rsf1-f-su74_variant,"fighter2, fighter, mid,  rsf_bp2",2,,3,8,CLAW,4000,500,,3,FIGHTER,Fighter,8,7500,,,,,,,20004,,,,,,
su252_wing,rsf1-f-su522_variant,"fighter3, fighter, mid,  rsf_bp2",2,,3,10,CLAW,4000,500,,3,ASSAULT,Assault,10,6000,,,,,,,20004,,,,,,
tu610_wing,rsf1-f-tu610_variant,"bomber2, bomber, mid,  rsf_bp1",3,,2,12,CLAW,4000,500,,2,BOMBER,Bomber,10,15000,,,,,,,2001,,,,,,
tu620_wing,rsf1-f-tu620_variant,"fighter4, fighter, high,  rsf_bp2",3,,2,10,CLAW,4000,500,,2,ASSAULT,Assault,10,12000,,,,,,,20012611,,,,,,

f61_wing,isa1-f-f61_variant,"fighter2, interceptor, low,  isa_bp1",1,,4,8,BOX,4000,500,,4,INTERCEPTOR,Interceptor,10,3500,,,,,,,2008,,,,,,
a110_wing,isa1-f-a110_variant,"fighter3, fighter, low,  isa_bp1",2,,4,8,BOX,4000,500,,4,ASSAULT,Assault,10,8000,,,,,,,20700,,,,,,
f135_wing,isa1-f-f135_variant,"fighter4, fighter, mid,  isa_bp2",2,,3,8,V,4000,500,,4,FIGHTER,Fighter,10,10000,,,,,,,2006,,,,,,
mq90_wing,isa1-f-mq90_variant,"fighter2, fighter, mid,  isa_bp2",1,,3,8,V,4000,500,,4,FIGHTER,Fighter,10,8000,,,,,,,20044,,,,,,
f171_wing,isa1-f-f171_variant,"fighter3, fighter, mid,  isa_bp1",2,,3,10,V,4000,500,,3,SUPPORT,Support,10,9000,,,,,,,20306,,,,,,
b202_wing,isa1-f-b202_variant,"bomber2, bomber, high,  isa_bp1",3,,2,12,BOX,4000,500,,3,BOMBER,Bomber,10,15000,,,,,,,2007,,,,,,
ac300_wing,isa1-f-ac300_variant,"fighter4, fighter, high,  isa_bp2",3,,2,10,BOX,4000,500,,3,ASSAULT,Assault,10,12000,,,,,,,207007,,,,,,

tornado_wing,uin1-f-tornado_variant,"fighter2, interceptor, low, uin_bp1",1,,5,8,V,4000,500,,4,INTERCEPTOR,Interceptor,10,4500,,,,,,,20608,,,,,,
hurricane_wing,uin1-f-hurricane_variant,"fighter2, interceptor, mid, uin_bp1",2,,3,8,V,4000,500,,4,INTERCEPTOR,Interceptor,10,9000,,,,,,,202608,,,,,,
blizzard_wing,uin1-f-blizzard_variant,"fighter3, fighter, mid, uin_bp2",2,,3,8,V,4000,500,,4,SUPPORT,Support,10,8500,,,,,,,206078,,,,,,
lancer_wing,uin1-f-lancer_variant,"fighter4, fighter, mid, uin_bp2",2,,2,8,BOX,4000,500,,4,SUPPORT,Support,10,12000,,,,,,,2060782,,,,,,

viper_wing,xle1-f-viper_variant,"fighter2, interceptor, low, xle_bp1",1,,4,8,BOX,4000,500,,4,INTERCEPTOR,Interceptor,10,3600,,,,,,,20023,,,,,,
stinger_wing,xle1-f-stinger_variant,"fighter2, fighter, low, xle_bp1",1,,3,8,CLAW,4000,500,,4,FIGHTER,Fighter,10,5600,,,,,,,2002313,,,,,,
cobra_wing,xle1-f-cobra_variant,"fighter3, fighter, mid, xle_bp1",2,,3,8,CLAW,4000,500,,4,FIGHTER,Fighter,10,6400,,,,,,,200233,,,,,,
raptor_wing,xle1-f-raptor_variant,"fighter4, fighter, mid, xle_bp2",2,,3,8,CLAW,4000,500,,4,ASSAULT,Assault,10,7200,,,,,,,2002373,,,,,,

claw_wing,wdw1-ftr-claw_variant,"fighter2, fighter, low, midline_bp",1,,4,8,V,4000,500,,4,FIGHTER,Fighter,10,4000,,,,,,,2008,,,,,,

keeper_wing,ffs1-f-keeper_variant,"fighter1, fighter, mid, ffs_bp",1,,6,8,CLAW,5000,500,,3,INTERCEPTOR,Interceptor,10,5000,,,,,,,20304,,,,,,
regulator_wing,ffs1-f-regulator_variant,"fighter2, fighter, high, ffs_bp",,,3,8,CLAW,5000,500,,3,FIGHTER,Fighter,10,11000,,,,,,,20304,,,,,,

ASF14_wing,vns-f-phnh_assault,"fighter5, fighter, high, pns_bp2",3,,8,12,CLAW,5000,500,,3,FIGHTER,Heavy Fighter,10,15000,,,,,,,100940,,,,,,
ASF14E_wing,vns-f-phnh_elite,"fighter5, fighter, high, pns_bp4",4,,,8,CLAW,5000,500,,3,FIGHTER,Heavy Assault,10,18000,,,,,,,100942,,,,,,
Falcon_wing,vns-f-falcon_variant,"fighter3, fighter, mid, pns_bp1",1,,5,8,V,4000,500,,4,FIGHTER,Fighter,8,8000,,,,,,,100943,,,,,,
PhnI_wing,vns-f-phni_standard,"fighter4, interceptor, mid, pns_bp3",2,,8,10,V,5000,500,,3,INTERCEPTOR,Adv. Interceptor,10,15000,,,,,,,100944,,,,,,
PhnI_Spec_wing,vns-f-phni_specops,"fighter4, interceptor, mid, pns_bp4",3,,8,12,V,5000,500,,3,INTERCEPTOR,Spec. Ops.,10,18000,,,,,,,100945,,,,,,
Armageddon_wing,vns-f-armageddon2_variant,"bomber5, bomber, high, pns_bp1",4,,10,16,BOX,5000,500,,2,BOMBER,Super Bomber,30,25000,,,,,,,100946,,,,,,
Armageddon_t_wing,vns-f-armageddon2_APOC,"bomber5, bomber, high, pns_bp4",5,,10,16,BOX,5000,500,,2,BOMBER,Strategic Bomber,30,30000,,,,,,,100947,,,,,,
Lightbringer_wing,vns-f-lightbringer_std,"bomber3, bomber, mid, pns_bp2",3,,5,10,BOX,5000,500,,2,BOMBER,Beam Bomber,10,20000,,,,,,,100948,,,,,,
Thunderbird_wing,vns-f-thunderbird_variant,"fighter2, fighter, mid, pns_bp2",1,,4,9,V,4000,500,,3,FIGHTER,Interceptor,8,10000,,,,,,,100950,,,,,,
Valkyrie_wing,vns-f-drone_variant,"fighter1, fighter, mid, pns_bp1",1,,4,10,V,4000,500,,3,FIGHTER,Drone,8,12000,,,,,,,100951,,,,,,

AI_fighter_wing,AI-fighter_variant,"fighter2, fighter, no_sell",1,,6,8,BOX,5000,500,,4,FIGHTER,Fighter,10,10000,,,,,,,2004,,,,,,

alien_fighter_wing,alien-fighter_variant,"fighter2, fighter, no_sell",1,,6,8,BOX,4000,500,,5,FIGHTER,Fighter,10,12500,,,,,,,2003,,,,,,
alien_bomber_wing,alien-bomber_variant,"bomber2, bomber, no_sell",1,,2,8,BOX,4000,500,,4,SUPPORT,Support,10,16000,,,,,,,200333,,,,,,

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on May 12, 2019, 04:41:22 AM
The shipsystem:
Quote
{
    "id":"SAD_DisturbSystem",
    "type":"STAT_MOD",
    "aiType":"WEAPON_BOOST",
    "statsScript":"src.data.shipsystems.scripts.SAD_DisturbSystem",

    "useSound":"system_targeting_feed",
    "outOfUsesSound":"gun_out_of_ammo",
}
The crash:
Quote
71268 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
    at com.fs.starfarer.combat.ai.system.do.o00000(Unknown Source)
    at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
    at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)

When the ai play with the ship, when a ship appears on the vision of it, it crash.  Not happens on 0.9.a


EDIT:
Like someone has answer me on Discord: Without, the game crash
Quote
"weaponTypes":[BALLISTIC],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on May 13, 2019, 03:05:03 PM
Is it possible for a mod to replace a vanilla java file/plugin that isn't one of them in settings.json? Something like BattleCreationPluginImpl?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2019, 03:40:09 PM
Is it possible for a mod to replace a vanilla java file/plugin that isn't one of them in settings.json? Something like BattleCreationPluginImpl?

Yes - provide this kind of method in a CampaignPlugin (you'll want to extend BaseCampaignPlugin, though):

Code: java
public PluginPick<BattleCreationPlugin> pickBattleCreationPlugin(SectorEntityToken opponent) {
if (opponent instanceof CampaignFleetAPI) {
return new PluginPick<BattleCreationPlugin>(new BattleCreationPluginImpl(), PickPriority.CORE_GENERAL);
}
return null;
}

With a higher priority than CORE_GENERAL. And doing any necessary checks if you only want to use your plugin in some set of circumstances instead of across the board.

See: com.fs.starfarer.api.impl.campaign.CoreCampaignPluginImpl for vanilla implementations of these kinds of methods.

Edit: btw, for this sort of thing you generally want to open up your IDE, make sure it knows where the API source is, and then do "show references" (or some such) on the class you're interested in. That'll show you where it's used, and in particular where new instances of it are created - and seeing how that's done should let you know whether it's something that's structured so another class can be provided, or not.


@TrashMan: took a look, and unfortunately nothing jumps out as looking wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 13, 2019, 09:18:49 PM
Some DamageAPI questions...  ;D

1) Does a beam's DamageAPI.getDamage() fluctuate in any way (i.e. based on time, damage target, ??) or does it always return the DPS of the beam (plus skill/hullmod effects)?

and

2) Does a beam's DamageAPI.computeDamageDealt(amount) take damage type into account -- as in, will it return a higher number if the beam is Kinetic and hitting a shield? (looking at it, it seems like probably not since I can't see the damage target being passed to the DamageAPI anywhere, but I figure it pays to ask)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2019, 09:37:26 PM
It fluctuates based on the beam brightness and it's 0 on the frames where the beam isn't doing damage.

And, right, computeDamageDealt does not take a target into account. I'm not sure I'd use that method for anything reliable - it does some behind-the-scenes stuff i.e. figures out the beam damage this frame based on damage.setDpsDuration(), which is called from the beam code every X frames when it's time to do a tick of damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 13, 2019, 09:43:52 PM
It fluctuates based on the beam brightness and it's 0 on the frames where the beam isn't doing damage.

And, right, computeDamageDealt does not take a target into account. I'm not sure I'd use that method for anything reliable - it does some behind-the-scenes stuff i.e. figures out the beam damage this frame based on damage.setDpsDuration(), which is called from the beam code every X frames when it's time to do a tick of damage.

Okay, so if I wanted to get the base damage per tick on a beam, I'd want to do something like...

Code
damage = (beam.getDamage().getDamage() * beam.getBrightness()) / 10f;

?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2019, 09:56:51 PM
No; getDamage().getDamage() would return 0 on non-damaging frames, and would already factor in the brightness on damaging frames. Basically trying to get anything super exact here seems like it'll be troublesome.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 13, 2019, 10:34:54 PM
No; getDamage().getDamage() would return 0 on non-damaging frames, and would already factor in the brightness on damaging frames. Basically trying to get anything super exact here seems like it'll be troublesome.

Ah, I'll just leave the brightness out then. It sounds like this might work for me, actually. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 16, 2019, 03:31:10 PM
Is there a good summary of what all the different ProjectileSpawnTypes and CollisionClasses are or do?

Specifically I've never really been clear on:
OTHER -- what is it?
BALLISTIC_AS_BEAM with the new passThroughMissiles flag vs. PLASMA -- Is it that PLASMA always hides the projectile sprite and passes through missiles, and with BALLISTIC_AS_BEAM both of those are optional? (I forget if BALLISTIC_AS_BEAM alwyas hides the projectile sprite or not  :-X)

and then on the CollisionClass side PROJECTILE_FF, MISSILE_FF, and MISSILE_NO_FF are all pretty clear, but:
RAY, RAY_FIGHTER -- what's the difference between these and the PROJECTILE CollisionClasses?
PROJECTILE_NO_FF vs. PROJECTILE_FIGHTER -- is there a difference here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 17, 2019, 05:37:23 AM
So I'm planning to halve population growth rates of NPC markets (in conjunction with manually implemented market size increases).

I have a singleton "manager" class that I'm currently using for a range of other things:
Code: java
public class ColonyManager extends BaseCampaignEventListener implements EveryFrameScript,
EconomyTickListener, InvasionListener
Will undesired effects happen if I make such a class implement MarketImmigrationModifier and use the one instance as a transient immigration modifier for multiple markets?
(i.e. should I put the immigration modifier code in a market condition instead?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on May 17, 2019, 06:47:17 AM
So I have two beam textures that work perfectly fine when used for beams.

https://imgur.com/a/X8DKK9V (https://imgur.com/a/X8DKK9V)

However, the first one will work fine when used on a BALLISTIC_AS_BEAM projectile, while the second on will cause a nullpointer exception like this:
Code
88841 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.renderers.K.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.MovingRay.render(Unknown Source)
at com.fs.starfarer.combat.entities.MovingRay.render(Unknown Source)
at com.fs.graphics.LayeredRenderer.render(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.render(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

any idea what could be causing this? It's definitely not a typo or anything, I checked that a dozen times now.

EDIT:
Update on this issue: I have managed to get the beam texture to work by also assigning it to a beam weapon. What this means is that BALLISTIC_AS_BEAM projectiles only accept custom textures that are also already used by an existing beam weapon. This might require some sorting out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2019, 10:30:42 AM
Is there a good summary of what all the different ProjectileSpawnTypes and CollisionClasses are or do?

Specifically I've never really been clear on:
OTHER -- what is it?
BALLISTIC_AS_BEAM with the new passThroughMissiles flag vs. PLASMA -- Is it that PLASMA always hides the projectile sprite and passes through missiles, and with BALLISTIC_AS_BEAM both of those are optional? (I forget if BALLISTIC_AS_BEAM alwyas hides the projectile sprite or not  :-X)

and then on the CollisionClass side PROJECTILE_FF, MISSILE_FF, and MISSILE_NO_FF are all pretty clear, but:
RAY, RAY_FIGHTER -- what's the difference between these and the PROJECTILE CollisionClasses?
PROJECTILE_NO_FF vs. PROJECTILE_FIGHTER -- is there a difference here?

Maybe there is one somewhere in this thread :)

I can't quite dig through all the details right now, but: PLASMA is used for the special visuals. _FIGHTER ones are for when stuff is fired by fighters and needs to pass over friendly ships (such as, say, regular weapons fired by fighters). Torpedoes on the other hand hit friendly ships when fire by fighters. This is specified using "collisionClassByFighter" in the .proj file.

I don't believe there's any difference between _NO_FF and _FIGHTER but I may be mistaken.


So I'm planning to halve population growth rates of NPC markets (in conjunction with manually implemented market size increases).

I have a singleton "manager" class that I'm currently using for a range of other things:
Code: java
public class ColonyManager extends BaseCampaignEventListener implements EveryFrameScript,
EconomyTickListener, InvasionListener
Will undesired effects happen if I make such a class implement MarketImmigrationModifier and use the one instance as a transient immigration modifier for multiple markets?
(i.e. should I put the immigration modifier code in a market condition instead?

The singleton manager should be fine, literally the only place immigration modifiers are used is in the CoreImmigrationPlugin:

Code
for (MarketImmigrationModifier mod : market.getAllImmigrationModifiers()) {
  mod.modifyIncoming(market, inc);
}

So I have two beam textures that work perfectly fine when used for beams.

Spoiler
https://imgur.com/a/X8DKK9V (https://imgur.com/a/X8DKK9V)

However, the first one will work fine when used on a BALLISTIC_AS_BEAM projectile, while the second on will cause a nullpointer exception like this:
Code
88841 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.renderers.K.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.MovingRay.render(Unknown Source)
at com.fs.starfarer.combat.entities.MovingRay.render(Unknown Source)
at com.fs.graphics.LayeredRenderer.render(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.render(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

any idea what could be causing this? It's definitely not a typo or anything, I checked that a dozen times now.

EDIT:
Update on this issue: I have managed to get the beam texture to work by also assigning it to a beam weapon. What this means is that BALLISTIC_AS_BEAM projectiles only accept custom textures that are also already used by an existing beam weapon. This might require some sorting out.
[close]

Ahh, that makes sense. The game isn't loading those textures, but will use them if they're already loaded (via another weapon using them in a way that does get loaded, or by specifying them in the "graphics" section of settings.json somewhere.)

This is a bug; fixed so that the game will load fringe/core textures specified in projectile files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 17, 2019, 11:24:44 AM
I'm using this inside my system script, but the nebula/warpstorms around the systems are not cleaned. Is this valid?

Code
    void cleanup(StarSystemAPI system){
        HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
NebulaEditor editor = new NebulaEditor(plugin);       
        float minRadius = plugin.getTileSize() * 2f;
       
        float radius = system.getMaxRadiusInHyperspace();
        editor.clearArc(system.getLocation().x, system.getLocation().y, 0, radius + minRadius * 0.5f, 0, 360f);
        editor.clearArc(system.getLocation().x, system.getLocation().y, 0, radius + minRadius, 0, 360f, 0.25f);
    } 

FYI, this is inside the main system class, but not insidie the generate one.
Here's the full script:

Code
package data.scripts.world.systems;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.OrbitAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.impl.campaign.ids.StarTypes;
import com.fs.starfarer.api.impl.campaign.ids.Terrain;
import com.fs.starfarer.api.impl.campaign.procgen.NebulaEditor;
import com.fs.starfarer.api.impl.campaign.procgen.StarAge;
import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceTerrainPlugin;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;
import com.fs.starfarer.api.impl.campaign.terrain.AsteroidFieldTerrainPlugin.AsteroidFieldParams;
import com.fs.starfarer.api.impl.campaign.terrain.MagneticFieldTerrainPlugin.MagneticFieldParams;

public class isa_Argos {

public void generate(SectorAPI sector) {

StarSystemAPI system = sector.createStarSystem("Argos's Star");
LocationAPI hyper = Global.getSector().getHyperspace();
system.setBackgroundTextureFilename("graphics/backgrounds/background4.jpg");

system.getLocation().set(27300, 14000);     

// create the star and generate the hyperspace anchor for this system
PlanetAPI argos_star = system.initStar("argos", // unique id for this star
StarTypes.RED_GIANT,  // id in planets.json
    1100f,   // radius (in pixels at default zoom)
    500); // corona radius, from star edge
system.setLightColor(new Color(255, 200, 210)); // light color in entire system, affects all entities

// hot asteroid belt
system.addAsteroidBelt(argos_star, 50, 2200, 100, 30, 40, Terrain.ASTEROID_BELT, null);
system.addRingBand(argos_star, "misc", "rings_asteroids0", 256f, 3, Color.white, 256f, 13750, 345f, Terrain.ASTEROID_BELT, null);

PlanetAPI argos1 = system.addPlanet("argos1", argos_star, "Argos 1", "lava_minor", 30, 110, 2850, 90);

PlanetAPI ammonia = system.addPlanet("ammonia", argos_star, "Ammonia", "desert", 50, 150, 4500, 135);
ammonia.getSpec().setPlanetColor(new Color(230,240,255,255));
ammonia.applySpecChanges();
ammonia.setCustomDescriptionId("planet_ammonia");

//jump points
JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("argos_jump_point", "Jump Point");
OrbitAPI orbit = Global.getFactory().createCircularOrbit(argos_star, 55.0F, 5000.0F, 150.0F);
jumpPoint.setOrbit(orbit);
jumpPoint.setRelatedPlanet(null);
jumpPoint.setStandardWormholeToHyperspaceVisual();
system.addEntity(jumpPoint);

PlanetAPI dwarf = system.addPlanet("dwarf", argos_star, "Dwarf", "rocky_metallic", 120, 150, 6800, 225);
dwarf.getSpec().setPlanetColor(new Color(230,240,255,255));
dwarf.applySpecChanges();
dwarf.setCustomDescriptionId("planet_dwarf");

// ARgos shipyard : main ISA shipyard
SectorEntityToken argos_shipyard = system.addCustomEntity("argos_shipyard", "Argos Shipyard", "station_side07", "ISA");
argos_shipyard.setCircularOrbitPointingDown(system.getEntityById("dwarf"), 90, 420, 25);
argos_shipyard.setCustomDescriptionId("argos_shipyard");
argos_shipyard.setInteractionImage("illustrations", "Shipyard3");




// Aeolus, magnetic storms
PlanetAPI argos4 = system.addPlanet("argos4", argos_star, "Aeolus", "gas_giant", 230, 275, 9500, 450);
argos4.getSpec().setPlanetColor(new Color(150,245,255,255));
argos4.getSpec().setGlowTexture(Global.getSettings().getSpriteName("hab_glows", "banded"));
argos4.getSpec().setGlowColor(new Color(250,225,55,64));
argos4.getSpec().setUseReverseLightForGlow(true);
argos4.applySpecChanges();

PlanetAPI argos4b = system.addPlanet("argos4b", argos4, "Acidia", "toxic_cold", 120, 70, 1000, 45);
argos4b.getSpec().setPlanetColor(new Color(190,235,255,255));
argos4b.applySpecChanges();
// todo: abortive orbital AM harvesting scheme?

// Argos trojans
SectorEntityToken argosL4 = system.addTerrain(Terrain.ASTEROID_FIELD,
new AsteroidFieldParams(
400f, // min radius
600f, // max radius
16, // min asteroid count
24, // max asteroid count
4f, // min asteroid radius
16f, // max asteroid radius
"Argos L4 Asteroids")); // null for default name

argosL4.setCircularOrbit(argos_star, 230 + 60, 9500, 450);

system.addRingBand(argos4, "misc", "rings_special0", 256f, 1, new Color(200,200,200,255), 256f, 600, 30f, Terrain.RING, null);


// Asteroid belt.
system.addRingBand(argos_star, "misc", "rings_asteroids0", 256f, 0, Color.white, 256f, 13750, 345f, Terrain.RING, null);
system.addAsteroidBelt(argos_star, 100, 13750, 200, 330, 360, Terrain.ASTEROID_BELT, "The Cyclopeans");

// Ismara : mass driven volatiles, looted
PlanetAPI argos5 = system.addPlanet("argos5", argos_star, "Ismara", "cryovolcanic", 130, 100, 14520, 335);

SectorEntityToken pixie = system.addCustomEntity("pixie", "Pixie station", "station_side07", "pirates");
pixie.setCircularOrbitPointingDown(system.getEntityById("argos5"), 90, 420, 25);
pixie.setCustomDescriptionId("pixie");
pixie.setInteractionImage("illustrations", "pirate_station");


system.autogenerateHyperspaceJumpPoints(true, true);
}

    void cleanup(StarSystemAPI system){
        HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
NebulaEditor editor = new NebulaEditor(plugin);       
        float minRadius = plugin.getTileSize() * 2f;
       
        float radius = system.getMaxRadiusInHyperspace();
        editor.clearArc(system.getLocation().x, system.getLocation().y, 0, radius + minRadius * 0.5f, 0, 360f);
        editor.clearArc(system.getLocation().x, system.getLocation().y, 0, radius + minRadius, 0, 360f, 0.25f);
    } 

}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 17, 2019, 04:14:49 PM
So I'm trying to use Global.getCombatEngine().getDamageData() to find out how much hull damage each ship did during a battle. For the most part it works great, but I'm having a hard time finding a way to pair fighters with their carriers. I can use getSourceShip() with a fighter's ShipAPI, but I can't figure out how to match that up with the FleetMemberAPI either. The FleetMemberAPIs that CombatDamageData uses as keys don't seem to have any uniquely identifying information with their ShipAPI or FighterWingAPI counterparts (comparing FleetMemberAPI.getId() to ShipAPI.getFleetMemberId() doesn't even work. Is there any way to use CombatDamageData to figure out how much hull damage a carrier dealt via it's fighters?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2019, 04:33:10 PM
Let me just step through this; possibly I'm missing something, but it seems doable. Say you've got:

ShipAPI fighter;

Then you could:
Ship carrier = fighter.getWing().getSourceShip();  (which I think you're already doing...)

(I'd suggest checking here that fighter.getWing() != null and then that carrier != null, just to be on the safe side.)

(comparing FleetMemberAPI.getId() to ShipAPI.getFleetMemberId() doesn't even work.

I believe this will not work for fighters since they don't have "real" fleet members and fake ones get created, but it should in fact work - and match - for the carrier's ShipAPI and its FleetMemberAPI.

That seems like the last piece of it, right? At this point you should be able to match the carrier to the FleetMemberAPI.

If that's not working, could you send me a bit of code to reproduce the issue?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 17, 2019, 05:08:33 PM
I believe this will not work for fighters since they don't have "real" fleet members and fake ones get created, but it should in fact work - and match - for the carrier's ShipAPI and its FleetMemberAPI.

That seems like the last piece of it, right? At this point you should be able to match the carrier to the FleetMemberAPI.
Yeah, the ShipAPI and FleetMemberAPI match up just fine for carriers, and I could use that to get all of the ShipAPIs for the carrier's fighters, but I still wouldn't have any way (afaik) to link those fighter ShipAPIs to the wing FleetMemberAPIs I would need to use as a key.

Here's my latest attempt:
Code
public class CombatPlugin implements EveryFrameCombatPlugin {
    boolean damageHasBeenLogged = false;

    int tick = 0;
    Map<String, String> map = new HashMap<>();

    @Override
    public void advance(float amount, List<InputEventAPI> events) {
        try {
            CombatEngineAPI engine = Global.getCombatEngine();

            if (engine == null || !engine.isInCampaign() || Global.getSector() == null || Global.getSector().getPlayerFleet() == null)
                return;


            if (tick++ % 60 == 0) {
                for (ShipAPI ship : engine.getShips()) {
                    if (!ship.isFighter() || ship.getWing() == null) continue;

                    String key = ship.getId();
                    //String key = ship.getFleetMemberId();
                    //String key = ship.getWing().getLeader().getId();;
                    //String key = ship.getWing().getWingId();

                    if (!map.containsKey(key)) {
                        Global.getLogger(this.getClass()).info(ship.getHullSpec().getHullId() + " - " + key + " - " + ship.getWing().getSourceShip().getFleetMemberId());
                        map.put(key, ship.getWing().getSourceShip().getFleetMemberId());
                    }
                }

            }

            if (!damageHasBeenLogged && engine.isCombatOver()) {

                Set<String> playerShips = new HashSet<>();
                for (FleetMemberAPI ship : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
                    playerShips.add(ship.getId());
                }

                for (Map.Entry<FleetMemberAPI, CombatDamageData.DealtByFleetMember> e : engine.getDamageData().getDealt().entrySet()) {

                    String sourceID = e.getKey().isFighterWing() && map.containsKey(e.getKey().getId())
                            ? map.get(e.getKey().getId())
                            : e.getKey().getId();

                    if (playerShips.contains(sourceID)) {
                        CampaignScript.recordDamage(sourceID, getFpWorthOfDamageDealt(e.getValue()));
                    }
                }

                damageHasBeenLogged = true;
            }
        } catch (Exception e) { ModPlugin.reportCrash(e); }
    }

    float getFpWorthOfDamageDealt(CombatDamageData.DealtByFleetMember dmgBy) {
        if(dmgBy == null || dmgBy.getDamage().isEmpty()) return 0;

        float acc = 0;

        for(Map.Entry<FleetMemberAPI, CombatDamageData.DamageToFleetMember> e : dmgBy.getDamage().entrySet()) {
            FleetMemberAPI target = e.getKey();
            float dmg = e.getValue().hullDamage;
            float hp = target.getStats().getHullBonus().computeEffective(target.getHullSpec().getHitpoints());

            if(target.isAlly() || target.isFighterWing() || target.isMothballed() || target.isCivilian() || dmg <= 1)
                continue;

            String msg = dmgBy.getMember().getHullId() + " dealt " + dmg + "/" + hp + " damage to " + target.getHullId();
            Global.getLogger(this.getClass()).info(msg);

            acc += (dmg / hp) * target.getDeploymentCostSupplies();
        }

        return acc;
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2019, 05:41:18 PM
Ahh, hmm. There's actually this method in the Ship class:
FleetMemberAPI getFleetMember();
But it wasn't in ShipAPI due to an oversight.

Here's the code for that method, roughly:
Code: java
private boolean computedFleetMember = false;
private FleetMemberAPI fleetMember = null;
public FleetMemberAPI getFleetMember() {
if (computedFleetMember) return fleetMember;

CombatFleetManager manager = CombatEngine.getInstance().getFleetManager(getOriginalOwner());
if (manager != null) {
DeployedFleetMember dfm = manager.getDeployedFleetMemberEvenIfDisabled(this);
if (dfm != null) {
computedFleetMember = true;
fleetMember = dfm.getMember();
if (fleetMember != null) {
if (getOriginalOwner() == 0) {
fleetMember.setOwner(0);
} else if (getOriginalOwner() == 1) {
fleetMember.setOwner(1);
}
}
}
}
return fleetMember;
}

It's using internal classes but I believe every method is exposed in the corresponding API interfaces. This should do the job, right? (It *might* flake out if used for fighters that retreated; not 100% sure on that use case.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 17, 2019, 06:09:59 PM
Looks like that'll do the trick. Thank you, Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 18, 2019, 06:39:05 AM
UUugh... I can't get this shipsystem to wrok:

Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.impl.combat.BaseShipSystemScript;

public class AIASsystem extends BaseShipSystemScript {

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {

stats.getFluxDissipation().modifyMult(id, 2.0f)
stats.getHardFluxDissipationFraction().modifyFlat(id, 100.0f)
}

public void unapply(MutableShipStatsAPI stats, String id) {
stats.getHardFluxDissipationFraction().unmodify(id);
stats.getFluxDissipation().unmodify(id);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("hard flux venting at 100%, max flux vent rate doubled", false);
}
return null;
}
}



I keep getting:
Code
19712 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.shipsystems.scripts.AIASsystem]
java.lang.RuntimeException: Error compiling [data.shipsystems.scripts.AIASsystem]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.shipsystems.scripts.AIASsystem'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/shipsystems/scripts/AIASsystem.java', Line 10, Column 41: Expression "stats.getFluxDissipation().modifyMult(id, 2.0f)" is not a type
at org.codehaus.janino.Java$Located.throwCompileException(Java.java:111)
at org.codehaus.janino.Java$Atom.toTypeOrCompileException(Java.java:2687)
at org.codehaus.janino.Parser.parseBlockStatement(Parser.java:1157)
at org.codehaus.janino.Parser.parseBlockStatements(Parser.java:1085)
at org.codehaus.janino.Parser.parseMethodDeclarationRest(Parser.java:938)
at org.codehaus.janino.Parser.parseClassBodyDeclaration(Parser.java:565)
at org.codehaus.janino.Parser.parseClassBody(Parser.java:515)
at org.codehaus.janino.Parser.parseClassDeclarationRest(Parser.java:481)
at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:269)
at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:168)
at org.codehaus.janino.JavaSourceIClassLoader.findCompilationUnit(JavaSourceIClassLoader.java:203)
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:146)
... 7 more

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 18, 2019, 07:36:41 AM
Looks like you're missing your semicolons at the end of these two lines:
Code
	stats.getFluxDissipation().modifyMult(id, 2.0f)		
stats.getHardFluxDissipationFraction().modifyFlat(id, 100.0f)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 18, 2019, 10:31:23 AM
How the FRAK did I miss that????  ??? ??? ???
WTF is wrong with me?
 :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 18, 2019, 10:57:35 AM
Happens to the best of us :P
Are you using an IDE? That helps a lot with that sort of thing. I've been really impressed with IntelliJ
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 18, 2019, 08:59:47 PM
(https://i.imgur.com/c7Z85LH.png?1)

Following up on my last question about projectile and collision types...

Is recoil for BALLISTIC_AS_BEAM (or RAY, maybe it's tied to collisionClass and not spawnType? either way) completely zeroed out... but only on hardpoints?

Is this intended, and was it always like this?  :-\

This is the same gun on turret vs hardpoint on a stock Dominator. If I change the proj to BALLISTIC + PROJECTILE it has less recoil on the hardpoint, which I know is intended, but not zero.


EDIT:
Nevermind! Mystery solved. BALLISTIC_AS_BEAM (or maybe RAY) projectiles are continually affected by spread decay vs BALLISTIC (or maybe PROJECTILE) guns not decaying until you stop firing, and my spread decay was set real high.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 18, 2019, 09:47:44 PM
That doesn't sound right, just off the top of my head, the code that tracks recoil doesn't know about what kind of projectiles the shots are.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 18, 2019, 10:32:12 PM
That doesn't sound right, just off the top of my head, the code that tracks recoil doesn't know about what kind of projectiles the shots are.

Whatever it is, setting a weapon with high spread decay to BALLISTIC_AS_BEAM/RAY changes its recoil behavior dramatically on hardpoint mounts.  :-X
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 19, 2019, 04:22:30 AM
I have a BIG weapon that has a reeeeealy long fire cycle. And by that I mean it warms up for 8 seconds.

Now, if I want o animate it to give he player visual feedback, I'm running into the problem of requireing FAR too many frames, that are mostly unnecessary, since parts of the animation can by cycled - like electricity going down the rails.

Basically:
ReflexCannon00
ReflexCannon01
ReflexCannon02   <--- 2 to 5 can repeat several times before
ReflexCannon03
ReflexCannon04
ReflexCannon05
ReflexCannon06  <--- 6 to 8 can repeat several times
ReflexCannon07
ReflexCannon08
ReflexCannon09
ReflexCannon10

Etc.. You get the idea. Basically during the chargeup, to tell the game exactly which image to show in what sequence.
Show ReflexCannon01 for 200 miliseconds, then ReflexCannon02, etc ,etc..
Can something like his be done? I suppose it can in weapon script but I don't know how that would go..

Here's the gun (frame 00 not included)

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 19, 2019, 07:43:50 AM
Is there any way to detect the earliest point at which the player can "Claim Victory" in a battle?

Edit: Global.getCombatEngine().isCombatOver() only seems to return true a few seconds after that point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2019, 10:26:39 AM
I have a BIG weapon that has a reeeeealy long fire cycle. And by that I mean it warms up for 8 seconds.

Now, if I want o animate it to give he player visual feedback, I'm running into the problem of requireing FAR too many frames, that are mostly unnecessary, since parts of the animation can by cycled - like electricity going down the rails.

Spoiler
Basically:
ReflexCannon00
ReflexCannon01
ReflexCannon02   <--- 2 to 5 can repeat several times before
ReflexCannon03
ReflexCannon04
ReflexCannon05
ReflexCannon06  <--- 6 to 8 can repeat several times
ReflexCannon07
ReflexCannon08
ReflexCannon09
ReflexCannon10

Etc.. You get the idea. Basically during the chargeup, to tell the game exactly which image to show in what sequence.
Show ReflexCannon01 for 200 miliseconds, then ReflexCannon02, etc ,etc..
Can something like his be done? I suppose it can in weapon script but I don't know how that would go..

Here's the gun (frame 00 not included)
[close]

Yeah, you'd want to do this in a script - see WeaponAPI.getAnimation(), and AnimationAPI. You'd have to keep track of the timing in the script etc.

You'd want to use an "everyFrameEffect"; see:
"everyFrameEffect":"com.fs.starfarer.api.impl.combat.BlinkerEffect",

For a very basic example that's in vanilla but not actually used by any ships.


Whatever it is, setting a weapon with high spread decay to BALLISTIC_AS_BEAM/RAY changes its recoil behavior dramatically on hardpoint mounts.  :-X

I'm just saying, something else is in play here :) Hardpoints get half the recoil overall, btw - both the maximum and the recoil per shot, so that definitely factors in independently of spawn type.


Is there any way to detect the earliest point at which the player can "Claim Victory" in a battle?

Edit: Global.getCombatEngine().isCombatOver() only seems to return true a few seconds after that point.

Ahh, another case of "method is not exposed in API". In this case, it's CombatEngineAPI.isEnemyInFullRetreat(). Added it to the API; in the meantime here's an adapted (to use the API) version of the method:
Code
public boolean isEnemyInFullRetreat2() {
CombatFleetManagerAPI cfm = Global.getCombatEngine().getFleetManager(FleetSide.ENEMY);
if (cfm == null) return false;

CombatTaskManagerAPI taskManager = cfm.getTaskManager(false);
if (taskManager == null) return false;

boolean allDeployedRetreating = true;
//for (DeployedFleetMember dfm : cfm.getDeployed()) {
for (DeployedFleetMemberAPI dfm : cfm.getDeployedCopyDFM()) {
if (dfm.isFighterWing()) continue;
if (!dfm.getShip().isRetreating()) {
allDeployedRetreating = false;
}
}

if (!allDeployedRetreating) return false;

cfm = Global.getCombatEngine().getFleetManager(FleetSide.PLAYER);
if (cfm == null) return false;
if (cfm.getReservesCopy().isEmpty() && cfm.getDeployedCopy().isEmpty()) {
return false;
}

cfm = Global.getCombatEngine().getFleetManager(FleetSide.ENEMY);
return cfm.getReservesCopy().isEmpty() || taskManager.isInFullRetreat();
}

It's not 100% the same but should be functionally identical or extremely close to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 19, 2019, 11:05:55 AM
Fighting some pirates and I'm getting this error

Code
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - pir1-f-harpoon - 84ff009d-a13d-4818-b8c7-e2d30bd565b3 - 30e85
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - pir1-f-harpoon - d4433f98-2d86-4665-b8ff-1b9a914b4f1b - 30e85
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - vns-f-thunderbird - e8b3a4d5-e26d-4e26-b663-06cc806d7f8b - 32825
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - wdw1-ftr-claw - 12e214d0-cf13-4219-bf0f-a55aae998054 - 32825
99946 [Thread-4] INFO  sound.public  - Cleaning up music with id [Ambient - Breathe In The Light.ogg]
99958 [Thread-8] INFO  sound.public  - Cleaning up music with id [Battle - Accelerated World.ogg]
100233 [Thread-10] INFO  sound.public  - Creating streaming player for music with id [Battle - Accelerated World.ogg]
100233 [Thread-10] INFO  sound.H  - Playing music with id [Battle - Accelerated World.ogg]
100446 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.specs.BaseWeaponSpec.getHiddenFireOffset(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.OoOO.new(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.O0oO.startedChargeup(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.Ô00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.O0oO.advance(Unknown Source)
at com.fs.starfarer.combat.systems.void.advanceLinked(Unknown Source)
at com.fs.starfarer.combat.systems.void.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I cannot figure out what exactly is causing the error. I assume it's a weapon, but I cannot narrow it down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gennadios on May 20, 2019, 02:05:45 PM
I'm trying to double the raw material demand of fuel production and heavy industry.

I found the two relevant .java files in starfarer\api\impl\campaign\econ\impl (FuelProduction.java and HeavyIndustry.java)

I have the barebones mod_info.json file and tried putting the edited source files into \Data\campaign\econ\impl of the mod folder but resource demand isn't budging from the base game.

Sorry for the uber noob question but what am I missing here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 21, 2019, 07:43:48 PM
Is there a way to modify the credits earned from shutting down a structure/industry?

Context: Nexerelin has a bit of a balance problem where you can make (relatively) easy money by buying several hundred marines, invading a market, selling everything on it, and then abandoning it. Kapetyn Starworks can net you a cool 1 million credits.
(Not sure how I'd fix it even if I had any API method I wanted, tbh)

Fighting some pirates and I'm getting this error

Code
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - pir1-f-harpoon - 84ff009d-a13d-4818-b8c7-e2d30bd565b3 - 30e85
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - pir1-f-harpoon - d4433f98-2d86-4665-b8ff-1b9a914b4f1b - 30e85
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - vns-f-thunderbird - e8b3a4d5-e26d-4e26-b663-06cc806d7f8b - 32825
78427 [Thread-4] INFO  starship_legends.CombatPlugin  - wdw1-ftr-claw - 12e214d0-cf13-4219-bf0f-a55aae998054 - 32825
99946 [Thread-4] INFO  sound.public  - Cleaning up music with id [Ambient - Breathe In The Light.ogg]
99958 [Thread-8] INFO  sound.public  - Cleaning up music with id [Battle - Accelerated World.ogg]
100233 [Thread-10] INFO  sound.public  - Creating streaming player for music with id [Battle - Accelerated World.ogg]
100233 [Thread-10] INFO  sound.H  - Playing music with id [Battle - Accelerated World.ogg]
100446 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.fs.starfarer.loading.specs.BaseWeaponSpec.getHiddenFireOffset(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.OoOO.new(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.O0oO.startedChargeup(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.B.Ô00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.O0oO.advance(Unknown Source)
at com.fs.starfarer.combat.systems.void.advanceLinked(Unknown Source)
at com.fs.starfarer.combat.systems.void.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I cannot figure out what exactly is causing the error. I assume it's a weapon, but I cannot narrow it down.
Do all your weapons have their hardpointOffsets and turretOffsets set? That's my best guess, at any rate.

I'm trying to double the raw material demand of fuel production and heavy industry.

I found the two relevant .java files in starfarer\api\impl\campaign\econ\impl (FuelProduction.java and HeavyIndustry.java)

I have the barebones mod_info.json file and tried putting the edited source files into \Data\campaign\econ\impl of the mod folder but resource demand isn't budging from the base game.

Sorry for the uber noob question but what am I missing here?
You can't overwrite vanilla classes directly.
In this case you have to make your own classes (which you've already done) and then include an industries.csv (in [mod name]/data/campaign) with the fuel production and heavy industry rows. Modify the plugin column to point to your modded classes.
(Note: Industries in existing saves will still use the old classes) (http://fractalsoftworks.com/forum/index.php?topic=5061.msg242268#msg242268)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2019, 09:14:08 PM
Is there a way to modify the credits earned from shutting down a structure/industry?

Context: Nexerelin has a bit of a balance problem where you can make (relatively) easy money by buying several hundred marines, invading a market, selling everything on it, and then abandoning it. Kapetyn Starworks can net you a cool 1 million credits.
(Not sure how I'd fix it even if I had any API method I wanted, tbh)

The shutdown refund is based on Industry.getBuildCost() and "industryRefundFraction" in settings.json. So, modifying it on a case-by-case basis would be really tricky, but just turning it way down globally would be straightforward.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 22, 2019, 01:44:49 AM
Do all your weapons have their hardpointOffsets and turretOffsets set? That's my best guess, at any rate.

Aaand the error dissapeared after starting a new game. Weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gennadios on May 23, 2019, 02:06:24 AM
I'm trying to double the raw material demand of fuel production and heavy industry.

I found the two relevant .java files in starfarer\api\impl\campaign\econ\impl (FuelProduction.java and HeavyIndustry.java)

I have the barebones mod_info.json file and tried putting the edited source files into \Data\campaign\econ\impl of the mod folder but resource demand isn't budging from the base game.

Sorry for the uber noob question but what am I missing here?
You can't overwrite vanilla classes directly.
In this case you have to make your own classes (which you've already done) and then include an industries.csv (in [mod name]/data/campaign) with the fuel production and heavy industry rows. Modify the plugin column to point to your modded classes.
(Note: Industries in existing saves will still use the old classes) (http://fractalsoftworks.com/forum/index.php?topic=5061.msg242268#msg242268)

Thanks for the help, the refinery changes are working without a hitch. However, I've been having trouble getting FuelProduction implemented. It's a way more complex class and the Synchrotron core function has been causing all sorts of errors. I got around most of them except one fatal error;

Fetal Error:
java.lang.ClassNotFoundException: File 'data/campaign/econ/impl/FuelProduction.java', Line 161, Column 15: No applicable constructor/method found for actual parameters "data.campaign.econ.impl.FuelProduction"; candidates are: "com.fs.starfarer.api.impl.campaign.econ.impl.SynchrotronInstallableItemPlugin(com.fs.starfarer.api.impl.campaign.econ.impl.FuelProduction)"

Code
	@Override
public List<InstallableIndustryItemPlugin> getInstallableItems() {
ArrayList<InstallableIndustryItemPlugin> list = new ArrayList<InstallableIndustryItemPlugin>();
list.add(new SynchrotronInstallableItemPlugin(this)); //<- Exception line 161
return list;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 23, 2019, 12:47:10 PM
It looks to me like the problem is that the constructor for SynchrotronInstallableItemPlugin is expecting an instance of com.fs.starfarer.api.impl.campaign.econ.impl.FuelProduction, but what you're giving it is your new fuel production class. The best way to resolve the issue would probably be to make your class extend the vanilla one, thereby making it into a class that the SynchrotronInstallableItemPlugin will accept as an argument. This would also give you the advantage of only replacing the code you need to change instead of copying the whole class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gennadios on May 23, 2019, 01:16:20 PM
It looks to me like the problem is that the constructor for SynchrotronInstallableItemPlugin is expecting an instance of com.fs.starfarer.api.impl.campaign.econ.impl.FuelProduction, but what you're giving it is your new fuel production class. The best way to resolve the issue would probably be to make your class extend the vanilla one, thereby making it into a class that the SynchrotronInstallableItemPlugin will accept as an argument. This would also give you the advantage of only replacing the code you need to change instead of copying the whole class.

Yeah, that was it. Alot of sloppy work on my part - I hadn't touched a programming language in years ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 25, 2019, 01:32:02 PM
What am I supposed to do with an error like his?

6041 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (G:\GAMES\Starsector0.91\starsector-core\data\variants\wolf\wolf_PD.variant)]
6041 [Thread-4] INFO  com.fs.starfarer.loading.SpecStore  - Loading variant [G:\GAMES\Starsector0.91\starsector-core\data\variants\wolf\wolf_Starting.variant]
6042 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (G:\GAMES\Starsector0.91\starsector-core\data\variants\wolf\wolf_Starting.variant)]
6042 [Thread-4] INFO  com.fs.starfarer.loading.SpecStore  - Loading variant [G:\GAMES\Starsector0.91\starsector-core\data\variants\wolf\wolf_Strike.variant]
6042 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (G:\GAMES\Starsector0.91\starsector-core\data\variants\wolf\wolf_Strike.variant)]
6255 [Thread-4] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/particlealpha32sq.png (using cast)
6676 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.loading.SpecStore.OO0000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.?O0000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 25, 2019, 01:39:28 PM
As far as general programming practices go, the thing to do is test things frequently enough that the set of changes that might be at fault is small. Then, back those out until it stops happening, to narrow down what the issue is.

Looking at the stack trace, on the bright side, this seems to be happening on game load, so the remove/test cycle should be a bit less forgiving that it might have been. I don't have any other pointers for you, unfortunately - as you say, it's not a particularly informative stack trace.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 26, 2019, 06:53:24 AM
What's the best way to check if a FleetMemberAPI instance has been destroyed or otherwise removed from the game so that references to it can be cleaned up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2019, 08:43:58 AM
That's the kind of question that makes me scared about what the underlying reason for asking it is :)

Hmm - at a base level, you could do member.getFleetData().getFleet().isAlive()

But some of those will return null if the ship is in storage somewhere. Or another mod could be hanging on to it in some way. Say, I don't know, if some kind of event temporarily removed some ships from your fleet but would return them later. Depending on your reason for wanting to keep track of it, that could be ok or not.

Basically, I don't think I can give a generic answer; need more info about what you're doing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 26, 2019, 09:15:35 AM
That's the kind of question that makes me scared about what the underlying reason for asking it is :)
lol That's understandable. I should have offered more context. One of my mods (starship legends) keeps records for certain ships. Once those ships are destroyed the records serve no purpose but to bloat the save file, so I would like to remove them. The idea is to iterate through my records in beforeGameSave and cull any records that refer to destroyed ship and are therefore no longer necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2019, 09:29:59 AM
Hmm - how about adding a FleetEventListener to the player's fleet, and then detecting what got destroyed in the reportBattleOccurred() method? SystemBountyIntel has a decent reference implementation, though it adds the listener to Global.getSector().getListenerManager() instead of fleet.addEventListener(). Either way works; the latter only gets called for fleet events for that fleet so is a bit better performance-wise.

One thing to watch out for would be re-adding the listener when the player fleet despawns.

This wouldn't catch ships being scuttled, though.

This seems like it's fundamentally impossible to do perfectly - see case of "scripted event removes ships for a bit, does stuff, and puts them back later" - how could you ever detect that those ships are still around? So any solution would be partial.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vorpal+5 on May 26, 2019, 11:36:22 AM
Are the mods in general working if applied to a current game?

Mods that add ships, sectors, tweak rules?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2019, 11:40:21 AM
That depends on the mod and how it's coded, and on what it's changing - kind of impossible to answer exactly in general. E.G. a mod that changes some settings may apply to a current game ... unless the setting in question are used when creating the game and not looked at afterwards. Or, a mod that adds a star system may do it in a way that only happens on new game creation - or may have code that adds the system to an existing game.

Mostly, though, I'd expect mods that add star systems, factions, and so on to require a new game. So that's less theoretical and probably closer to the answer you're looking for :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 26, 2019, 11:44:51 AM
Hmm - how about adding a FleetEventListener to the player's fleet, and then detecting what got destroyed in the reportBattleOccurred() method? SystemBountyIntel has a decent reference implementation, though it adds the listener to Global.getSector().getListenerManager() instead of fleet.addEventListener(). Either way works; the latter only gets called for fleet events for that fleet so is a bit better performance-wise.

One thing to watch out for would be re-adding the listener when the player fleet despawns.

This wouldn't catch ships being scuttled, though.

This seems like it's fundamentally impossible to do perfectly - see case of "scripted event removes ships for a bit, does stuff, and puts them back later" - how could you ever detect that those ships are still around? So any solution would be partial.
Ok, that makes sense. I'll just clean up whatever I can based on events. Thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2019, 11:49:43 AM
... you know, I've got a really weird idea for this that just might work. The way to go would be to keep the tracked data in the fleet member itself, right? Might not be structured in a way that allows that on your end, but this just got me thinking.

FleetMemberAPI doesn't have an explicit container for custom data (i.e. a MemoryAPI) but it does have buffs - which can be any custom class implementing Buff. So you could in theory have a class that implements Buff holding all your data for that fleet member, and if it wasn't referenced elsewhere, it would be, ah, self-cleaning.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 26, 2019, 12:33:59 PM
Holy crap, that's a beautiful hack!  :D
I wish I'd thought of it a few months ago. At this point I'd have to backtrack too much to use that method. I'll keep it in mind for the future.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2019, 12:58:19 PM
Ah yeah, figures it'd be too much of a refactor at this point.

(Have to admit, I'm kind of happy with myself for thinking up that one :D)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vorpal+5 on May 26, 2019, 02:13:40 PM
Another newbie question if you allow!

Do I get a slow down in speed (like in Mount&Blade) by having a lot of ships? Or that's always the slowest one that dictate speed? What is the practical limit to the number of ships in my fleet (my budget?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on May 26, 2019, 07:22:04 PM
That's not a mod question, but more general, and better asked elsewhere.

The slowest ship determines your speed, while bigger fleets are harder to accelerate, decelerate and move around. So having a small fleet feels nimble and responsive, while bigger fleets take time to get up to speed. Practical limit is simply by preference and determined through trial and error, although if you ask this question in the right area you'll no doubt get more detailed responses.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2019, 08:26:18 PM
The slowest ship determines your speed, while bigger fleets are harder to accelerate, decelerate and move around. So having a small fleet feels nimble and responsive, while bigger fleets take time to get up to speed. Practical limit is simply by preference and determined through trial and error, although if you ask this question in the right area you'll no doubt get more detailed responses.

I think that's a mod feature, and vanilla doesn't have that mechanic - all fleets accelerate the same, depending on abilities. But as far as speed, yeah, it's just the slowest ship.

(Early versions of the game actually had the "larger fleet = slower" approach...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 27, 2019, 12:53:42 AM
Any way to fix relations? How are they even handled?
It seems completely random as factions declare war agaisnt Independants or the factions they are supposed to be friendly too (starting relation 0.5+)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 27, 2019, 04:10:00 AM
(sorry, forgot to reply the last time you asked)

The faction hostility event is indeed random. You can prevent it for any particular other-faction by making it cooperative with your faction, or for all factions by setting the custom boolean "engagesInHostilities":false, in your .faction file (see independents for an example). But I dunno what's going on if someone is starting hostilities with independents.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on May 28, 2019, 03:19:47 AM
A quick one - is it possible to add a line to a skin file to ensure it doesn't show up in the codex?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 28, 2019, 03:29:59 AM
Question: There is no tutorial or good info on making custom faction fleets (like Remnants), so one has to dig and try to reverse-engineer, which is tiresome.
Especially if what you want is something SIMPLER - no warning beacons, no dormant/resurgent, nothing.
Just fleet spawned in a system that either patrol or decide to attack some market somewhere.

Now, with recent changes most things work without a complied .jar. So far my entire mod seesm to work without it. If I want to create such faction fleets, will it also work without compiling a jar?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on May 30, 2019, 06:02:59 AM
I wanted to make a hullmod that boosts damage on medium mounts by 25%, but looking at MutableShipStats, it seems I can only do boosts based on weapon type, not mount size. I guess this is a no-go?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on May 30, 2019, 06:15:34 PM
A quick one - is it possible to add a line to a skin file to ensure it doesn't show up in the codex?

Add the HIDE_IN_CODEX hint?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 01, 2019, 10:47:13 AM
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF


This is driving me insane
Quote
301606 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.loading.specs.HullVariantSpec.computeWeaponOPCost(Unknown Source)
   at com.fs.starfarer.loading.specs.HullVariantSpec.computeOPCost(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMember.getMemberStrength(Unknown Source)
   at com.fs.starfarer.api.util.Misc.getMemberStrength(Misc.java:3777)
   at com.fs.starfarer.campaign.fleet.FleetData.updateFleetPointsUsed(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.syncIfNeeded(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.sort(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetData.sort(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.createFleet(FleetFactoryV3.java:408)
   at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.addShips(BaseSubmarketPlugin.java:472)
   at com.fs.starfarer.api.impl.campaign.submarkets.MilitarySubmarketPlugin.updateCar goPrePlayerInteraction(MilitarySubmarketPlugin.java:53)
   at com.fs.starfarer.campaign.ui.E.<init>(Unknown Source)
   at com.fs.starfarer.coreui.o00o.<init>(Unknown Source)
   at com.fs.starfarer.coreui.o00o.<init>(Unknown Source)
   at com.fs.starfarer.ui.newui.J$5.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.newui.J.setCurrentTab(Unknown Source)
   at com.fs.starfarer.ui.newui.J.setCurrentTab(Unknown Source)
   at com.fs.starfarer.ui.newui.U.showCoreInternal(Unknown Source)
   at com.fs.starfarer.ui.newui.U.showCore(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.rulecmd.OpenCoreTab.execute(OpenCoreTab.java:40)
   at com.fs.starfarer.ui.newui.super.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.k.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.oooO.new(Unknown Source)
   at com.fs.starfarer.ui.oooO.processInput(Unknown Source)
   at com.fs.starfarer.ui.Stringsuper.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Is this a weapon error?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 01, 2019, 10:49:38 AM
This looks like it's likely to be "variant references a weapon ID, but there's no weapon with that ID". Could happen, say, if you change a weapon ID and load an older save, or disable a mod that provided that weapon.

(Let me make the error more helpful in this specific case. Been trying to do that for various *things* that can go wrong...)

Edit: this could also if there's an invalid fighter wing id.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 01, 2019, 11:11:41 AM
I did change some fighter wing loadouts.

Would refreshing the market help (as it crashes only on specific markets)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 01, 2019, 11:17:56 AM
It might or it might not, hard to say for sure as it depends on whether that ship would get re-rolled or not. If you cleared the market contents that might do the job. Assuming that it is in fact due to a ship in that market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 01, 2019, 11:18:14 AM
On another note, I'm having an issue with hullmods that do not work. I have several, they all appear on the list and are selectable, but 3 do not work (nothing happens when I click on them, they are not installed).
I've been over hte files a dozen time but cannto find ANYTHINg wrong. they are properly defined and references in hull_mods.cvs

For example, THIS works:
Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

@SuppressWarnings("unchecked")
public class Radiators extends BaseHullMod {

public static final int HARD_FLUX_DISSIPATION_PERCENT = 50;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
{
stats.getHardFluxDissipationFraction().modifyFlat(id, (float)HARD_FLUX_DISSIPATION_PERCENT * 0.02f);
stats.getFluxDissipation().modifyPercent(id, 20f);
stats.getArmorBonus().modifyPercent(id, -20f);
stats.getHullBonus().modifyPercent(id, -10);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + HARD_FLUX_DISSIPATION_PERCENT;
return null;
}

@Override
public boolean isApplicableToShip(ShipAPI ship) {
return
((!ship.getVariant().getHullMods().contains("heavyarmor")) &&
(!ship.getVariant().getHullMods().contains("comp_armor")) &&
(!ship.getVariant().getHullMods().contains("Deflectors")));
}
}


But these don't

Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShieldAPI;
import com.fs.starfarer.api.combat.ShieldAPI.ShieldType;

@SuppressWarnings("unchecked")
public class PoweredArmour extends BaseHullMod {

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
{
stats.getArmorBonus().modifyPercent(id, 25f);
stats.getArmorDamageTakenMult().modifyPercent(id, -20f);
stats.getEmpDamageTakenMult().modifyPercent(id, -50f);
}

public void applyEffectsAfterShipCreation(ShipAPI ship, String id)
{
ship.setShield(ShieldType.NONE, 0f, 0f, 0f);

}


@Override
public boolean isApplicableToShip(ShipAPI ship) {
return
((!ship.getVariant().getHullMods().contains("PoweredArmour")) &&
(!ship.getVariant().getHullMods().contains("EnergyAbsorbers")) &&
(!ship.getVariant().getHullMods().contains("comp_armor")) &&
(!ship.getVariant().getHullMods().contains("Deflectors")));
}
}



Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class EnergyAbsorbers extends BaseHullMod {

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getArmorBonus().modifyPercent(id, -10f);
stats.getEnergyDamageTakenMult().modifyPercent(id, -25f);
}

@Override
public boolean isApplicableToShip(ShipAPI ship) {
return
((!ship.getVariant().getHullMods().contains("PoweredArmour")) &&
(!ship.getVariant().getHullMods().contains("EnergyAbsorbers")) &&
(!ship.getVariant().getHullMods().contains("heavyarmor")) &&
(!ship.getVariant().getHullMods().contains("comp_armor")) &&
(!ship.getVariant().getHullMods().contains("Deflectors")));
}

}


Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;
import com.fs.starfarer.api.combat.ShipAPI;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class Deflectors extends BaseHullMod {

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getFluxDissipation().modifyPercent(id, -20f);

stats.getProjectileDamageTakenMult().modifyPercent(id, -20f);
}

@Override
public boolean isApplicableToShip(ShipAPI ship) {
return
((!ship.getVariant().getHullMods().contains("PoweredArmour")) &&
(!ship.getVariant().getHullMods().contains("EnergyAbsorbers")) &&
(!ship.getVariant().getHullMods().contains("heavyarmor")) &&
(!ship.getVariant().getHullMods().contains("comp_armor")) &&
(!ship.getVariant().getHullMods().contains("Deflectors")));
}

}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vorpal+5 on June 01, 2019, 11:30:11 AM
Is there a mod that allow more zoom-in in tactical combat (because sometime it's hard to see what's going on) and more zoom-out in hyperspace (to understand the 'lay of the land' nebula and storm wise) ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 04, 2019, 02:57:37 AM
How to prevent a beam weapon from targeting fighters? I've got an anti-capital beam that turned out to be FRIGHTENINGLY effective against fighters and when under AI control the guns seem to prioritize fighters
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on June 04, 2019, 08:39:26 AM
Is there a mod that allow more zoom-in in tactical combat (because sometime it's hard to see what's going on) and more zoom-out in hyperspace (to understand the 'lay of the land' nebula and storm wise) ?
For combat, there are these two settings:
   "minCombatZoom":0.5, # zoomed in all the way
   "maxCombatZoom":2.0, # zoomed out all the way
I don't know of anything similar for the campaign layer.

How to prevent a beam weapon from targeting fighters? I've got an anti-capital beam that turned out to be FRIGHTENINGLY effective against fighters and when under AI control the guns seem to prioritize fighters
I'm pretty rusty on ways to manipulate weapon AI, but I think some tags will make weapons avoid fighters. I'm pretty sure "strike" is one. However, I would advise against intentionally making the AI avoid an effective strategy. You might want to consider toning down whatever makes the weapon so effective against fighters, or possibly even making the beam pass through them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceMonster on June 04, 2019, 06:26:57 PM
Is it possible to increase the number of ships shown in the fleet bubble? I mean visually only.
I like to run with large fleet vs large fleet but the numbers in the bubble seem so small when there's 40-50+ ships in the fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 04, 2019, 06:31:38 PM
No, that's actually hard-limited to 20 total. Sorry!

(The reason it's not showing all ships is this has quite a large impact on performance, and since the bubbles stop getting larger at some point anyway, showing more ships inside them wouldn't do *that* much.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 04, 2019, 10:17:10 PM
There doesn't seem to be a listener for "player founded a colony". If so, could we get one?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceMonster on June 05, 2019, 11:06:37 AM
How do I get bounties to spawn with large menacing fleets? I tried setting "maxShipsInAIFleet" to 100 but this seems to only result in a few more kites/shuttles/fluff.
My goal is to have a 50+ ship bounty fleet with, like, 5+ onslaughts or something. A big fleet vs big fleet challenge.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Legion0047 on June 05, 2019, 11:27:15 AM
So is there any reason why there are no mod stations?
Is it just that modders haven't had time to make new sprites and implement them or is there another reason?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 05, 2019, 11:55:23 AM
There doesn't seem to be a listener for "player founded a colony". If so, could we get one?

Oh, yep - let me add a PlayerColonizationListener. There; done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: stormbringer951 on June 05, 2019, 12:11:45 PM
How do I get bounties to spawn with large menacing fleets? I tried setting "maxShipsInAIFleet" to 100 but this seems to only result in a few more kites/shuttles/fluff.
My goal is to have a 50+ ship bounty fleet with, like, 5+ onslaughts or something. A big fleet vs big fleet challenge.

The major factor which affects bounty fleet size is how many bounties you've done before. To make the AI get more powerful fleets in general, you need to defeat bounty fleets, which slowly increases how many points are allocated to future bounties to generate their fleet with.

Increasing maxShipsInAIFleet generally makes the game easier because the AI will generate larger fleets of smaller ships. When the game goes over the AI's fleet size limit, it consolidates into larger ships. That said, it's nice to increase the fleet point limit when there are too many capital ships generated per fleet and battles turn into a slog.

So is there any reason why there are no mod stations?
Is it just that modders haven't had time to make new sprites and implement them or is there another reason?

Shadowyards and Blue have custom stations. They do seem like a lot of work though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 05, 2019, 11:53:13 PM
The Hiddne Hardpoint Offset error is the bane of my existence.

It's so hard to pinpoint what is causing it, as it seems to appear almost randomly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 06, 2019, 12:35:54 AM
So is there any reason why there are no mod stations?
Is it just that modders haven't had time to make new sprites and implement them or is there another reason?

Dunno. Making a station doesn't seem to difficult - I made one.
It is a bit more involved than making a ship (more parts)
But if you want it to be properly buildable and usable, it has to also be added as an industry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on June 06, 2019, 12:49:25 AM
So is there any reason why there are no mod stations?
Is it just that modders haven't had time to make new sprites and implement them or is there another reason?

Stations are a ton of work, mostly spriting but also placing modules is kind of a pain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 06, 2019, 02:22:50 AM
So is there any reason why there are no mod stations?
Is it just that modders haven't had time to make new sprites and implement them or is there another reason?

Stations are a ton of work, mostly spriting but also placing modules is kind of a pain.

Nah, you just have to keep in mind how they are placed. The very center of the module sprite will be the point that will go on the module hardpoint.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on June 06, 2019, 07:47:27 AM
Is there a way to clean up my code while a combat engine should be GC?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 06, 2019, 08:45:22 AM
Is there a way to clean up my code while a combat engine should be GC?

The simplest would be not to store references to any combat objects outside combat plugins etc. Then it would be automatic.

If you need to check whether the combat engine was cleaned up, you could put a custom value into Global.getCombatEngine().getCustomData(). Once that value is not there anymore, that would tell you that a new instance of the combat engine has been created and the old one either has been gc'ed or will be soon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on June 06, 2019, 12:34:00 PM
So is there any reason why there are no mod stations?
Is it just that modders haven't had time to make new sprites and implement them or is there another reason?

I accept Paypal.

It's not that there are no mod stations (I made one, and a supership that might as well be a station), it's that there aren't as many as you'd like.

Spriting and placing modules aren't all that bad (at least to me), it's the conceptual side that I think gets people. Coming up with a good idea for a station, testing it, refining it... it's a decent chunk of work. I did a small station, which was fun, but also really brought home how difficult it is to make an interesting station.

Give it time. Lots of people are still getting to grips with the basics. As more people get comfortable with stations in the game, you'll see more modded stations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on June 09, 2019, 03:38:28 PM
I've added an indicator to the deployment dialogue:
Spoiler
(https://i.imgur.com/mFJDeZ8.png)
[close]

But it renders over top of tooltips:
Spoiler
(https://i.imgur.com/I8jtQPE.png)
[close]

So is there a way to render between the deployment dialogue and ship tooltips? Or maybe a way to detect when a tooltip is shown so that I can hide the indicator?

Also, is there any way to circumstantially hide or overwrite the cursor image?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 09, 2019, 03:54:29 PM
No on all counts, I'm afraid. The UI is generally just not set up for custom rendering like that, except for where it really is (i.e. intel, interaction dialogs, etc).

... well, as far as the cursor: you could use Mouse.setNativeCursor(). I'd be very careful, though; it has the potential to crash things.

(Edit: to slightly expand on that - I remember trying some cursor-switching (beyond what the game currently does for friendly/enemy target) and I could never figure out exactly the problem, but sometimes it would cause a native crash w/ no log. So it's been a "stay away" for me.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on June 09, 2019, 04:02:40 PM
Ok, gotcha. I was afraid of that, but just thought I'd ask. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 11, 2019, 06:20:35 AM
Is there a way to stop a faction from issuing procurement/survey missions? (I suspect there isn't, but want to be sure)
(in this case making all the markets hidden isn't an option)

Is there currently any instance where FactionAPI.getDisplayName() and getDisplayNameWithArticleWithoutArticle() return different things?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2019, 08:54:19 AM
Is there a way to stop a faction from issuing procurement/survey missions? (I suspect there isn't, but want to be sure)
(in this case making all the markets hidden isn't an option)

Doesn't look like it, no.

... well, there's the nuclear option -

Using GenericMissionManager.getInstance().getCreators() to clear out the default mission creators, and then adding your own which would market.setHidden(true) any markets to exclude before calling the AnalyzeEntityMissionIntel etc constructors, then setting them back to not hidden again. But, yeah, that's a fair bit of work.

The default creators are added in CoreLifecyclePluginImpl, like so:

Code: java
GenericMissionManager manager = GenericMissionManager.getInstance();
if (!manager.hasMissionCreator(ProcurementMissionCreator.class)) {
manager.addMissionCreator(new ProcurementMissionCreator());
}
if (!manager.hasMissionCreator(AnalyzeEntityIntelCreator.class)) {
manager.addMissionCreator(new AnalyzeEntityIntelCreator());
}
if (!manager.hasMissionCreator(SurveyPlanetIntelCreator.class)) {
manager.addMissionCreator(new SurveyPlanetIntelCreator());
}

Is there currently any instance where FactionAPI.getDisplayName() and getDisplayNameWithArticleWithoutArticle() return different things?

Pirates and independents:

"displayName":"pirates",
"displayNameWithArticle":"the pirates",

"displayName":"independent",
"displayNameWithArticle":"the independents",

That method is basically just there to only highlight the "independents" part (without the "the") of stuff like "a fleet sent by the independents" etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on June 13, 2019, 01:38:59 PM
Is there any way to add a mouse over text pop up for a BaseIntelPlugin?  Or maybe a mouse-in/mouse-out event for a location?  I'd like to add some clarifying text when an element is moused-over.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2019, 01:44:39 PM
Hmm - if you open the intel screen and mouse over the map icon for the intel item, that tooltip gets created using BaseIntelPlugin.createIntelInfo() with mode == ListInfoMode.MAP_TOOLTIP, but I'm not sure if that's what you're asking or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on June 13, 2019, 02:47:58 PM
Sorry for the confusion. 

Specifically if I have some code like:
Code
TooltipMakerAPI image = panel.createUIElement(imageSize, imageSize, false);
Is there a way to have some mouse over text appear when the cursor enters the TooltipMakerAPI area?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2019, 09:29:54 PM
Ah, I see - you mean tooltips for elements inside a more detailed/involved intel description, right? It's not set up for that, sorry! Though it should be... fairly doable. I'll make a note and see if I can work that in at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vorpal+5 on June 15, 2019, 03:21:30 AM
Can the number of ships shown in the 'fleet bubble', currently 20 max be de-hardcoded, for the player only? I know it has been done this way for performance reason, but given the beast of the computer I have, showing 30 instead of 20 is most probably not an issue! :-)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 15, 2019, 05:59:38 AM
Why are some of the most important things so poorly documented?

Things like adding your own NPC to a planet of fleet or making custom fleets that fly around - there's nothing on that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on June 17, 2019, 12:45:39 PM
Why are some of the most important things so poorly documented?

Things like adding your own NPC to a planet of fleet or making custom fleets that fly around - there's nothing on that.

Be the documentation you want to see in the world.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 18, 2019, 07:30:41 AM
Can the number of ships shown in the 'fleet bubble', currently 20 max be de-hardcoded, for the player only? I know it has been done this way for performance reason, but given the beast of the computer I have, showing 30 instead of 20 is most probably not an issue! :-)

This probably belongs in another thread, but, let me make a note to see if I can work it in at some point. Wouldn't be too difficult, and not a bad idea, just need to get around to it :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on June 18, 2019, 08:41:44 AM
Code
13200 [Thread-4] INFO  com.fs.starfarer.settings.StarfarerSettings  - Loading settings
13202 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/config/settings.json)]
13222 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: B:\Starsector09\Starsector\starsector-core\..\mods\Console Commands (data/config/settings.json)]
13225 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: B:\Starsector09\Starsector\starsector-core\..\mods\MagicLib (data/config/settings.json)]
13227 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: B:\Starsector09\Starsector\starsector-core\..\mods\SpeedUp (data/config/settings.json)]
13228 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: B:\Starsector09\Starsector\starsector-core\..\mods\GraphicsLib (data/config/settings.json)]
13230 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: B:\Starsector09\Starsector\starsector-core\..\mods\ApproLightPlus (data/config/settings.json)]
13233 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: B:\Starsector09\Starsector\starsector-core\..\mods\ApproLight (data/config/settings.json)]
13259 [Thread-4] INFO  com.fs.graphics.L  - Using refresh rate:75
error init: Could not locate OpenAL library.
13536 [Thread-4] ERROR sound.B  - org.lwjgl.LWJGLException: Could not locate OpenAL library.
org.lwjgl.LWJGLException: Could not locate OpenAL library.
at org.lwjgl.openal.AL.create(AL.java:156)
at org.lwjgl.openal.AL.create(AL.java:102)
at org.lwjgl.openal.AL.create(AL.java:206)
at sound.B$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sound.B.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I use idea as IDE, in someday, I couldn't activate sound option while debugging
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 18, 2019, 01:56:47 PM
Hmm - one possibility is that you need to specify the location of the native dll files in the debug configuration, something like:

-Djava.library.path=<path to where the various LWJGL dll files are>

(Not at my work computer, or I'd be a bit more precise.)

Another possibility is needing to install OpenAL on your system; sometimes the one that comes with the game just won't get picked up for windows reasons. The installer for that is here: https://www.openal.org/downloads/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 18, 2019, 05:09:55 PM
Is there any way to tell when a MIRV or AOE DamagingProjectileAPI has detonated? 

I can't seem to find a flag or anything that would say "yes" if checking it.  MissileAPI has isMirv(), but what we really need is a boolean hasDetonated() that flags DamagingProjectileAPIs that are exploding / MIRV-ing this frame or something like that, so that it can get caught / used, just like didDamage().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 19, 2019, 07:50:56 AM
Not sure - can anyone else chime in? Not at my main computer right now so can't dig into it :)

(If not, then yeah, some way of being able to detect this would certainly be useful.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 19, 2019, 11:20:46 AM
Sorry to bug about something this minor, lol.  It's been a roadblock for a couple of minor things for ages, is all. 

I've tried checking for the existence of a DamagingProjectileAPI between one frame and the next; that doesn't appear to catch them; I'm guessing that when they detonate, they're being removed from the DamagingProjectileAPIs immediately or something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 19, 2019, 09:52:43 PM
...I don't suppose the Replace operation in mod_info could support wildcards?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 20, 2019, 04:47:16 PM
Where is hammerhead_Tutorial.variant referenced?  I'm presuming it's hard-coded for now...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 21, 2019, 03:58:46 AM
Why are some of the most important things so poorly documented?

Things like adding your own NPC to a planet of fleet or making custom fleets that fly around - there's nothing on that.

Be the documentation you want to see in the world.

That's like asking a plumber to perform surgeon himself.

There's poeple who clearly know, but nothing is documented, no tutorials exist, nothing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 24, 2019, 09:50:25 AM
OK, on those two questions:

1.  Adding your own NPC to a planet:  an example of that is in TutorialMissionIntel.java in the API (which I'm going to presume you've unzipped somewhere as a code reference). 

It's a little confusing there, if you haven't read through that stuff much; look at mainContact.  If you don't already have one installed, I'm going to firmly recommend you install a good search / grep tool, when trying to figure out things in the API.

2.  Making a "custom fleet that flies around" is too vague.  If you just want to spawn a FleetAPI, then go look at RogueMinerMiscFleetManager, for example; it shows how to use Factory to spawn a CampaignFleetAPI.


On the general question of, "why is there no documentation for my specific needs":

A.  Alex has done a great job documenting the core functions / interfaces in the API. 

B.  If you're poking around in there, you're kind of expected to know what you're doing, Java-wise, or programming-wise in general (before I came here, I had zero experience with Java, but a bloody million other languages).

C.  The game's not done yet.  Stuff changes; old stuff that worked, but no longer works the way Alex wanted, gets removed / deprecated / altered.  When you wonder why a lot of mods have been made / abandoned for the engine, now you know.  I imagine that when the dust finally settles, we'll see a lot more stuff, simply because the ground will quit shifting every 6-9 months on average.

D.  Maybe whatever you want to do hasn't been done yet?  There are some really brilliant people here, but they aren't gods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 24, 2019, 10:53:13 AM
So... is there some hidden limit to the breakProb variable for Hulls?

I want a ship or ships to have, say, a 1% chance of being non-destroyed.  When I set breakProb to 0.99, it doesn't appear to be a 1% chance (with, admittedly, a small sample size).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2019, 11:11:34 AM
Sometimes the algorithm to find a way to break the hull into two pieces fails to find a good-enough solution and doesn't break the hull (though IIRC it's still considered "destroyed" mechanically, and gets the pertinent d-mod).

The odds of this happening depend on the ship boundaries; if it's a more complex shape it's generally more likely but I forget the details. It shouldn't fail *too* often, but, yeah, it'll probably be more than 1% in any case.

(Basically what the algorithm does is give it a couple of randomized tries, and then checks if each produced solution is "good enough" (which, IIRC, involves the shape being "reasonable" for some definition of reasonable, i.e. no boundary self-overlaps or some such). If it fails to find one after X tries, it gives up.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 24, 2019, 12:16:33 PM
Aha. 

So, maybe the best call is to reduce the number of maxPieces / minPieces to let that algo have a better chance of reaching a valid solution.  I'd made some assumptions about how it works that obviously aren't valid (I presumed it couldn't fail, it just might not reach (n)maxPieces without sub-dividing some Pieces after the first iteration).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2019, 12:23:21 PM
It gets to the specified number of pieces by continually dividing the biggest chunk left in two. So if the ship didn't break, that means the first attempt to divide it in two failed. Meaning, the goal number of pieces doesn't matter for that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 24, 2019, 12:29:49 PM
Right.

You can prevent that.

Check a random collision point; do ray-tests between each other point for line-intersection between the two (i.e., for line-segment starting at Vector2f A, does it collide with the collision mesh at any point that isn't ending-point Vector2f B); failures get discarded.   

Start with a random other point from the set and work clockwise / anticlockwise until a valid ray appears (there will never be a failure, even on concave collision meshes; there's always the third point on the triangle).  Pick a success out of a hat and sub-divide.

A little expensive, but Rare Event rule applies here.  It can't fail; at worst, it'll produce the occasional Ugly Sliver, which is OK.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 24, 2019, 12:56:28 PM
If the above's not described well-enough, I can psuedocode it.  Heck, let's do it:

Code: java

//Get ArrayList of points from the collision mesh
ArrayList<Vector2f> CollisionPointsOfCurrentlyEvaluatedMesh;

if(CollisionPointsOfCurrentlyEvaluatedMesh.size() < 3){return false}; //FAIL GRACEFULLY HERE; can't sub-divide triangles!

int randomNumber = randomNumberInRange(0,CollisionPointsOfCurrentlyEvaluatedMesh.size()-1);

Vector2f pointA = randomlySelectAPointFromArrayList(CollisionPointsOfCurrentlyEvaluatedMesh,int randomNumber);

//Presumption here is that collision points wind clockwise; obviously, writing a reversal is trivial.
//Uses good-old Iterator to check int values
ArrayList validCollisionPoints;
for(int counter = 0; counter < CollisionPointsOfCurrentlyEvaluatedMesh.size()-1; counter++){
  if(counter != randomNumber && counter != randomNumber +1 && counter != randomNumber-1 && !getCollidesWithCollisionMesh(pointA, point, CollisionPointsOfCurrentlyEvaluatedMesh)){
     validCollisionPoints.add(point);//This will always result in at least one good result, so long as we're not talking about a triangle
  }
}

//Now pick a point from validCollisionPoints; we have a A-->B line segment we know is valid

//Perturb the line into line segments for prettiness, if it's long enough

//Sub-divide the shipAPI into two new shipAPIs which are Pieces (I presume that code doesn't need to change here at all)

//Repeat with the largest surface area Piece

[EDIT]Ouch, that can fail on a concave quad, can't it?  So... do a speedup; sort out all concave points first by checking the interior angle, use them, they'll always have a valid triangle somewhere, I'd think.  I'll look at the other corner-cases for this problem.[/EDIT]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 24, 2019, 01:15:28 PM
Ah, yeah.  If the interior angle test of any point says it's a concave point, the easiest first division of the polygon will always be a randomly-selected point from the array of concave points.

E.G.:  https://geidav.wordpress.com/tag/concave-polygon/

That's a lot faster than attempting the ray-tests via brute-force, honestly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2019, 02:14:54 PM
The bounds can be self-intersecting. There are also other considerations, e.g. certain angles of cuts tend to produce better-looking results.

I think I might've also given you the wrong idea; the split-lines aren't *totally* random but use the sort of stuff you're talking about; all the other stuff is necessary because that stuff isn't sufficient.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 24, 2019, 03:01:54 PM
Ah, I'd forgotten that the bounds can cross each other, or even be collinear.  Honestly, I think that if modders do such things, code oughtta catch that and crash with a friendly warning, lol.

I was thinking while I was doing errands:  you can pre-compute the initial solutions at run-time, saving them to ArrayLists of Vector2f pairs; and same for whether a bounds is convex; a convex bounds is obviously a much-neater problem.  That'd solve most of the issues with time-complexity for this, and at a guess, it'd only take a second or two.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2019, 03:54:18 PM
Ah, I'd forgotten that the bounds can cross each other, or even be collinear.  Honestly, I think that if modders do such things, code oughtta catch that and crash with a friendly warning, lol.

It's occasionally necessary. Check out the Paragon's bounds sometime :)

I was thinking while I was doing errands:  you can pre-compute the initial solutions at run-time,

Not a bad idea! Don't really see touching this code, though; it works fine and the very occasional "oops, ship didn't break" isn't exactly an issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 26, 2019, 11:30:48 AM
I can confirm that if a ship fails a Split, it doesn't become a Piece, but is Disabled instead. 

I set minPieces to 1 to allow it to reach a minimal solution, but that doesn't work, either.  Brute-forcing splitShip() is quite expensive.

Looks like I'll have to handle what I want (essentially, a game rule that makes getting intact ships quite a lot rarer) via some other method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 26, 2019, 11:59:48 AM
A ship that failed to split is still marked as "destroyed" post-battle. The ShipAPI will not be a piece, though, that's correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 26, 2019, 12:08:41 PM
Ahhhh.  Gotcha.  I'll check that.  So long as it doesn't show up in the loot lists, it's all good.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 26, 2019, 12:12:16 PM
Destroyed ships are recoverable, though at a lower rate than disabled ones, and they get a "compromised structure" d-mod.

Also, in case you're not aware: ships with "Reinforced Bulkheads" do not (currently, I'm considering that) break apart.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on June 27, 2019, 02:34:55 AM
OK, on those two questions:

1.  Adding your own NPC to a planet:  an example of that is in TutorialMissionIntel.java in the API (which I'm going to presume you've unzipped somewhere as a code reference). 

It's a little confusing there, if you haven't read through that stuff much; look at mainContact.  If you don't already have one installed, I'm going to firmly recommend you install a good search / grep tool, when trying to figure out things in the API.

I'll check it out

Quote
2.  Making a "custom fleet that flies around" is too vague.  If you just want to spawn a FleetAPI, then go look at RogueMinerMiscFleetManager, for example; it shows how to use Factory to spawn a CampaignFleetAPI.

The code to spawn a fleet in a random system (or picked from a list) and send it to roam around/attack a market isn't that difficult. Plugging it into the game is.
Remnants are spawned at sector generation, but that's not what I need.
I need to periodically (let's say once a month) check for conditions (number of active fleets, etc..) and spawn fleets and that is what is giving me trouble.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 27, 2019, 08:46:06 PM
Quote
Destroyed ships are recoverable, though at a lower rate than disabled ones, and they get a "compromised structure" d-mod.

Also, in case you're not aware: ships with "Reinforced Bulkheads" do not (currently, I'm considering that) break apart.
I'll take a look at that.  Also, there are a few other things in Skills that boost that, that may be affecting AI ships.

Overall, it's pretty difficult to get the rate down to what I wanted (roughly: 1% for a Capital).  I'll probably rewrite Reinforced Bulkheads; I don't want loot drop free Cruiser+ ships to be nearly as common as they are now.

Basically, I'm playing around with putting ship prices high, drop rates low, for the high-end ships; it won't completely change the power-curve for high-end, optimized fleets in a game where the player can take Officers to Level 29, but it's better than nothing and it should get better as the somewhat-meh Skills get evened out a bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on June 27, 2019, 08:50:00 PM
I need to periodically (let's say once a month) check for conditions (number of active fleets, etc..) and spawn fleets and that is what is giving me trouble.

Isn't that basically what either the raid or Lion's Guard HQ (depending on what you're trying to do) scripts do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 01, 2019, 03:06:35 AM
Hum, is there a reason why planet mouse-over descriptions can have multiple paragraphs displayed while stations will only show the first one?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 01, 2019, 07:17:15 AM
There really isn't; I think it's also supposed to limit it to 1 paragraph for planets, but that hasn't come up so I never noticed it. That much text is a bit much for that tooltip, imo; the first paragraph in all (or nearly all) descriptions is supposed to work as a stand-alone summary. General idea being to have something brief the player can read and not throw too much text at them, especially in a hover-over campaign tooltip that hides what's going on underneath it.

IIRC for planets, you can view the full text in the planet detail screen while for stations you should see it on interacting with the station, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 01, 2019, 08:55:00 AM
Actually yes indeed, the cutoff is dependent on the total length. Problem is, the text in the intel screen is not scrollable, so that's an issue at lower resolutions:

Spoiler
(https://i.imgur.com/km97Jr1.jpg)
[close]

I was trying to divide my texts into,
tooltip: historical description of the place
interaction text: technical description of the place, plus some flavor if needed
market flavor: in character impression, visual description of the place.

So while technically possible, cramming everything in the interaction text is less than ideal, especially since I have a few places that do have a lot to tell about themselves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 01, 2019, 09:06:56 AM
Let me make a note to add a scrolly thing there.

Does seem like a less than ideal place to lore-dump, though, hmm. Another option might be to add an intel item when first visiting a planet like this; that would have a lot more room to work with (especially if it was using the large description). Just in general, the intel screen is more suited to that sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on July 01, 2019, 09:56:26 AM
Well, soon I'll probably start to add permanent "Local magazines" to read in those planet's bars, a bit like what we started implementing in one of my mod with LazyWizard, where you can meet various people that break up the lore dumps into smaller, more digestible dialogs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 01, 2019, 10:06:32 AM
Cool! That sounds great.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 03, 2019, 12:34:08 PM
When end-users click on a location (System in Hyperspace, location in a System) in the Map view, or have a fleet destination set via the Intel screen (clicking on a Bounty, for example) where is that data stored?  I'm having a little trouble finding this in the API.

I want to play around with new ways to travel around the map, essentially.

Ah, nevermind!  It's apparently in Global.getSector().getUIData().getCourseTarget()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on July 05, 2019, 04:06:49 AM
I need to periodically (let's say once a month) check for conditions (number of active fleets, etc..) and spawn fleets and that is what is giving me trouble.

Isn't that basically what either the raid or Lion's Guard HQ (depending on what you're trying to do) scripts do?

Where are those scripts located? I want to check them out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on July 05, 2019, 08:48:01 AM
If you're using IntelliJ, you can right click on starsector.api.jar and choose "find in path..." to search the API for keywords. This is extremely useful for finding vanilla examples of what your'e trying to do. Netbeans probably has a similar feature.
Spoiler
(https://i.imgur.com/QB6JGHg.png)
[close]

If you're not writing enough code to justify installing an IDE (which doesn't seem to be the case), then you can unzip the API jar and search for keywords in java files using a command console, like this:
Spoiler
(https://i.imgur.com/wASbNvi.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on July 05, 2019, 09:50:37 PM
Three quick (hopefully) questions:

1. Is there a good way to tell if a station is one of those partially complete pirate stations with only one module prior to battle? I haven't been able to find a way to differentiate them from complete stations with the same hull ID. I can count their modules, but only after I have a ShipAPI to work with, and by that time it's too late.

2. For ships with multiple sections, like stations, do stats adjustments from things like hullmods and officer skills propagate to the modules?

3. Is there a good hook I could use to override "$dangerLevelOverride" for every fleet the player might view the tooltip of?

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 06, 2019, 08:55:13 AM
1. Is there a good way to tell if a station is one of those partially complete pirate stations with only one module prior to battle? I haven't been able to find a way to differentiate them from complete stations with the same hull ID. I can count their modules, but only after I have a ShipAPI to work with, and by that time it's too late.

Use member.getStatus().isPermaDetached(int index) - this'll let you figure out which modules, if any, are permanently removed, which is what the not-full-strength pirate stations use.


2. For ships with multiple sections, like stations, do stats adjustments from things like hullmods and officer skills propagate to the modules?

Officer skills: yes. Hullmods: no. (Thus, for example, the Targeting Supercomputer is installed on every module that needs it.)

3. Is there a good hook I could use to override "$dangerLevelOverride" for every fleet the player might view the tooltip of?

Hmm - a custom inflater, possibly, though I don't 100% remember if the timing would be right for that to work. Or (as you've probbably considered) a script that updates this for fleets around the player...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on July 06, 2019, 12:04:16 PM
Use member.getStatus().isPermaDetached(int index) - this'll let you figure out which modules, if any, are permanently removed, which is what the not-full-strength pirate stations use.
Exactly what I was looking for, thank you! It worked like a charm once I realized the core of the station could be detached (at first I was only iterating until ship.getVariant().getModuleSlots().size()).

Officer skills: yes. Hullmods: no. (Thus, for example, the Targeting Supercomputer is installed on every module that needs it.)
Ok, makes sense, just not for my specific case. Thought I'd make sure before implementing a method of propagation myself.

Hmm - a custom inflater, possibly, though I don't 100% remember if the timing would be right for that to work. Or (as you've probbably considered) a script that updates this for fleets around the player...
Yeah, I'm currently using a script that updates every few seconds and when certain things happen, but fleets slip through the cracks every once in a while. I'll experiment with a custom inflater.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on July 06, 2019, 04:07:11 PM
How do you spawn a system bounty? Been trying to figure this one out for awhile and making no progress. As far as I can tell, every system has a SystemBountyManager which spawns the events, but I can't figure out how to get the SystemBountyManager for a given system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 06, 2019, 04:09:07 PM
Quick example for starting a system bounty from Jangala; this is from CoreLifecyclePluginImpl:

Code: java
MarketAPI jangala = Global.getSector().getEconomy().getMarket("jangala");
if (jangala != null) {
SystemBountyManager.getInstance().addOrResetBounty(jangala);
}

(Edit: to clarify, there's a single system bounty manager for all system bounties, hence SystemBountyManager.getInstance())
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on July 06, 2019, 04:10:53 PM
Wow. Thanks for the fast response! Going to try this out....  ;)

*edit - works.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 07, 2019, 06:19:28 AM
Hmm - one possibility is that you need to specify the location of the native dll files in the debug configuration, something like:

-Djava.library.path=<path to where the various LWJGL dll files are>

(Not at my work computer, or I'd be a bit more precise.)

Another possibility is needing to install OpenAL on your system; sometimes the one that comes with the game just won't get picked up for windows reasons. The installer for that is here: https://www.openal.org/downloads/

I have to say I try all I could but nothing worked....
FINE I could debug correctly now.
I downloaded an OpenAL64.dll and put it into folder system32(There has OpenAL32.dll), then everything returned to the correct order.
I found that
Code: java
public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice) throws LWJGLException {
        if (created) {
            throw new IllegalStateException("Only one OpenAL context may be instantiated at any one time.");
        } else {
            String libname;
            String[] library_names;
            switch(LWJGLUtil.getPlatform()) {
            case 1:
                libname = "openal";
                library_names = new String[]{"libopenal64.so", "libopenal.so", "libopenal.so.0"};
                break;
            case 2:
                libname = "openal";
                library_names = new String[]{"openal.dylib"};
                break;
            case 3:
                if (Sys.is64Bit()) {
                    libname = "OpenAL64";
                    library_names = new String[]{"OpenAL64.dll"};
                } else {
                    libname = "OpenAL32";
                    library_names = new String[]{"OpenAL32.dll"};
                }
                break;
            default:
                throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform());
            }

            String[] oalPaths = LWJGLUtil.getLibraryPaths(libname, library_names, AL.class.getClassLoader());
            LWJGLUtil.log("Found " + oalPaths.length + " OpenAL paths");
            String[] arr$ = oalPaths;
            int len$ = oalPaths.length;
            int i$ = 0;

            while(i$ < len$) {
                String oalPath = arr$[i$];

                try {
                    nCreate(oalPath);
                    created = true;
                    init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice);
                    break;
                } catch (LWJGLException var13) {
                    LWJGLUtil.log("Failed to load " + oalPath + ": " + var13.getMessage());
                    ++i$;
                }
            }

            if (!created && LWJGLUtil.getPlatform() == 2) {
                nCreateDefault();
                created = true;
                init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice);
            }

            if (!created) {
                throw new LWJGLException("Could not locate OpenAL library.");
            }
        }
    }
Lwjdl is doing such thing, but why it works well in normal game but not in the IDEA
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 07, 2019, 08:00:23 AM
Wow. Thanks for the fast response! Going to try this out....  ;)

*edit - works.  ;D

Awesome :)


Lwjdl is doing such thing, but why it works well in normal game but not in the IDEA

Windows can just be really weird about loading dlls sometimes...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on July 07, 2019, 09:30:24 PM
Did we ever get a working "no_drop" tag or other method to prevent weapons from spawning as exploration content loot?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 07, 2019, 10:01:54 PM
no_drop should do the job now, I believe - if you look in drop_groups, stuff is set up to be aware of that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on July 07, 2019, 10:40:26 PM
Awesome, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 08, 2019, 03:20:59 PM
If a Skill has ScopeDescription.ALL_SHIPS, and more than one Officer in a CampaignFleetAPI has that Skill, does the Skill stack?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 08, 2019, 03:34:21 PM
ScopeDescription is just for the description. What affects the actual application of the effect is "type" in the .skill file, which for all ships would be ALL_SHIPS_IN_FLEET. However, skills with that type only apply when they're on the fleet commander, so: the skill won't stack and won't even apply once, if it's on an officer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 08, 2019, 04:01:36 PM
Ah!  Good!  I'll try and tackle Operation Make All Skills Give Fleet Bonuses, then, lol.  I wanna see if my theory pans out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 11, 2019, 05:13:50 AM
A quick question - how do you add a specific ship/station to a fight from exploring a derelict? I've been trying to find the Mothership spawn code in the game files but I have been unsuccessful. Does it have to do with FleetMember, or some extra lines in the 'defender' area?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 11, 2019, 08:30:41 AM
For this one, it's actually just data, no code needed.

In salvage_entity_gen_data.csv, there's a "stationRole"column. For the mothership, it says "derelictMothership".

In derelict.faction, we've got:
"shipRoles":{
   "derelictMothership":{
      "station_derelict_survey_mothership_Standard":10,
   },
},

And that's it.

If you wanted to do something fancier, you could use a SalvageDefenderModificationPlugin (see: SalvageGenFromSeed). This is, for example, how the game handles increasing derelict defense strengths, and a couple of other special defenders (red planet, cryosleeper).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 11, 2019, 07:40:22 PM
Many thanks Alex! That's exactly what I was looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 12, 2019, 08:02:35 PM
Another question, except this time a bit more involved;

This is a script I used to give my GMDA ships a boost to stats above a certain flux threshold and when the ship is not overloaded. This is based off a script that Histidine wrote for me ages ago that I've since adapted. The code worked in 0.9, however as of 0.9.1a it no longer works, and I can't determine why. The only clue I have is the fact that the compiler required the String id section at the front to compile correctly, and since then the code doesn't work. I feel I'm overlooking something basic, but I lack the know-how to interpret. Could anyone lend me a hand please?
Spoiler
Code
    public void advanceInCombat(ShipAPI ship, String id) {
        if (ship.getFluxTracker().getFluxLevel() >= 0.65 && !ship.getFluxTracker().isOverloaded()){
            Global.getCombatEngine().maintainStatusForPlayerShip(SPEEDKEY, "graphics/icons/hullsys/temporal_shell.png",
                    "Bludknock Overdrive System Active",
                    "Increased Speed and Venting!",
                    false);
            ship.getMutableStats().getMaxSpeed().modifyMult(id, HIGH_SPEED_MOD);
            ship.getMutableStats().getFluxDissipation().modifyMult(id, HIGH_VENT_MOD);
            ship.getMutableStats().getAcceleration().modifyMult(id, HANDLING_MULT);
            ship.getMutableStats().getDeceleration().modifyMult(id, HANDLING_MULT);
            ship.getMutableStats().getMaxTurnRate().modifyMult(id, HANDLING_MULT);
            ship.getMutableStats().getTurnAcceleration().modifyMult(id, HANDLING_MULT);
        }
            if (ship.getFluxTracker().getFluxLevel() >= 0.65 && ship.getFluxTracker().isOverloaded()){
                ship.getMutableStats().getMaxSpeed().unmodifyMult(id);
                ship.getMutableStats().getFluxDissipation().unmodifyMult(id);
                ship.getMutableStats().getAcceleration().unmodifyMult(id);
                ship.getMutableStats().getDeceleration().unmodifyMult(id);
                ship.getMutableStats().getMaxTurnRate().unmodifyMult(id);
                ship.getMutableStats().getTurnAcceleration().unmodifyMult(id);

            }
            if (ship.getFluxTracker().getFluxLevel() < 0.65){
                ship.getMutableStats().getMaxSpeed().unmodifyMult(id);
                ship.getMutableStats().getFluxDissipation().unmodifyMult(id);
                ship.getMutableStats().getAcceleration().unmodifyMult(id);
                ship.getMutableStats().getDeceleration().unmodifyMult(id);
                ship.getMutableStats().getMaxTurnRate().unmodifyMult(id);
                ship.getMutableStats().getTurnAcceleration().unmodifyMult(id);}
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 13, 2019, 09:01:10 AM
All of the advanceInCombat methods you could override have "ShipAPI ship" and "float amount" as parameters. If your parameters don't match that exactly, the game won't call the method.

The compiler complained at you because it couldn't find where id is declared. The simplest solution is to add a declaration above the first if-statement, like this:

Code
String id = "GMDA_BOSA";

On a side note, you can compress the last two if-statements into:
Code
if (ship.getFluxTracker().isOverloaded() || ship.getFluxTracker().getFluxLevel() < 0.65) {
    ship.getMutableStats().getMaxSpeed().unmodifyMult(id);
    ship.getMutableStats().getFluxDissipation().unmodifyMult(id);
    ship.getMutableStats().getAcceleration().unmodifyMult(id);
    ship.getMutableStats().getDeceleration().unmodifyMult(id);
    ship.getMutableStats().getMaxTurnRate().unmodifyMult(id);
    ship.getMutableStats().getTurnAcceleration().unmodifyMult(id);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on July 13, 2019, 01:59:14 PM
Is it possible to set the name of a ShipAPI or somehow update it to match the FleetMemberAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 13, 2019, 09:08:36 PM
Let me add setName() to ShipAPI. Various UI elements might not update when it changes, though, i.e. if you have a target reticle, it'd most likely keep displaying the name-that-was at the time the ship was targeted.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 13, 2019, 11:09:26 PM
If I wanted a fleet created by a RouteFleetSpawner to go straight to its destination instead of chasing down random enemy fleets, how would I do it? Is there a part of RouteFleetAssignmentAI that I should change?

As an aside: Should there be a more reliable way of generating loot drops from killing enemies (e.g. AI cores from Remnants)?
The current method of using an FID config gen override on MyFleet breaks if that config gen isn't called by the fleet interaction dialog plugin for any reason... such as when the player interacts with another fleet and MyFleet is pulled in. This doesn't come up in vanilla and a mod could add its own handling (e.g. with reportEncounterLootGenerated in a listener), but an easier approach would be nice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 14, 2019, 01:20:30 AM
Thanks SafariJohn! That worked perfectly!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 14, 2019, 07:36:00 AM
If I wanted a fleet created by a RouteFleetSpawner to go straight to its destination instead of chasing down random enemy fleets, how would I do it? Is there a part of RouteFleetAssignmentAI that I should change?

You'd probably want to override addLocalAssignment, addStartingAssignment, addTravelAssignment, and addEndingAssignment to ... basically do the same thing they're doing, but using one of the DELIVER_* assignments to move them around - which makes a fleet move somewhere and not chase unless the enemy fleet overlaps.

Could also set $isTradeFleet to true in the fleet's memory, but that may have some undesired side effects.

Let me make a note to add another flag that does this w/o flagging it as a trader, since this seems to come up a fair bit.

Edit: you could also call ModularFleetAIAPI.getStrategicModule().getDoNotAttack() and periodically add all nearby fleets to it - either in another script added to the fleet, or in the fleet's assignment AI if it has a custom one already.

As an aside: Should there be a more reliable way of generating loot drops from killing enemies (e.g. AI cores from Remnants)?
The current method of using an FID config gen override on MyFleet breaks if that config gen isn't called by the fleet interaction dialog plugin for any reason... such as when the player interacts with another fleet and MyFleet is pulled in. This doesn't come up in vanilla and a mod could add its own handling (e.g. with reportEncounterLootGenerated in a listener), but an easier approach would be nice.

Let me make a note to take a look at this; good point about the "fleet being pulled in" case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tzuridis on July 16, 2019, 07:39:27 AM
Random question, mostly on what you guys think would be the best way to go about this. I want to create a mod that changes combat somewhat, basically doing this:

Small ships are faster either by 50%, more or less (using the designations?). As are missiles and torpedoes. Missiles and torpedoes also do 3x - 5x more damage but all weapons can fire 100 - 200% further similar to the hullmod for the battle station. The whole point of this is to make it so that small ships are still capable of taking down big fellas if they can get around as shield strength will be the same. Would test it out a bit, mess around, maybe push the mod so people can try a new experience.

So my idea to implement this was in hope of finding a base hullmod that all ships had, perhaps hidden or something. Not really applicable to apply to all .ship files especially with other mods. I did find the basehullmod in the API, is there one in hullmods that applies to all ships? I was hoping I could find something in there so I could import the supercomputer targetting mod. I'm pretty sure my way is wrong, so any advice as to what should I take a look at? I am guessing it is all in the API?

I don't know java but I know js so I think I could figure it out eventually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 16, 2019, 07:57:00 AM
I think you're thinking about this in a good way as far as structuring it, but, yeah - there's no such hullmod.

That being absent, the best way to go is probably an EveryFrameCombatPlugin that keeps track of which ships it's seen so far, and then applies your desired changes to ships right after they get deployed.

See: data.scripts.plugins.TestCombatPlugin for a really messy and extremely random implementation of a combat plugin; it's one I've used to test an assortment of things. If you put it in data.scripts.plugins, you don't need to register it. If you put it elsewhere (say because you've set things up to compile your mod's code into a jar) you'd need to add it to the "plugins" section in settings.json for it to be picked up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 16, 2019, 08:25:46 AM
Here's a basic, bare-bones structure for what Alex said.  I was going to recommend going down the Built-In Hull Mod route, but this will work for testing basic concepts or global effects like this. 

You'll really, really want to install a Java IDE first and learn to make "my first JAR", etc.  See Modding Tools; there are great, newbie-friendly instructions for installing NetBeans, Intellij, etc. here.

Code: java
public class my_awesome_plugin_example implements EveryFrameCombatPlugin {

private CombatEngineAPI engine;

    @Override
    public void init(CombatEngineAPI cEngine) {
engine = cEngine;
    }

    @Override
    public void advance(float amount, List events) {
         //If we're paused or not in combat or whatever, stop here.
         if(engine == null
             || engine.isPaused()
             || (!engine.isInCampaign() && !engine.isInCampaignSim() && !engine.isMission() && !engine.isSimulation())){
                return;
         }   

         //Get all of the ships currently on the battlefield, iterate through them.
         for(ShipAPI ship : engine.getShips()){
                  //Do stuff to ships here, depending on what they are, etc.
         }

    }

    @Override
    public void renderInWorldCoords(ViewportAPI viewport) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void renderInUICoords(ViewportAPI viewport) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

@Override
public void processInputPreCoreControls(float f, List<InputEventAPI> list) {
}

}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tzuridis on July 16, 2019, 08:31:16 AM
Awesome thanks for the quick replies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tzuridis on July 17, 2019, 06:57:04 AM
2 quick if you guys have time. I am editing the testcombat plugin. I tried to use this method:

Code
public class TestCombatPlugin extends BaseEveryFrameCombatPlugin { 

public static float DAMAGE_MISSILES_PERCENT = 200f;
public static float SPEED_MISSILES_PERCENT = 500f;

public static float SPEED_BONUS = 525f;
public static float TURN_BONUS = 20f;

/**
* Set this to true to have the plugin actually do stuff.
*/
private static boolean TEST_MODE = true;

private CombatEngineAPI engine;
public void init(CombatEngineAPI engine) {
this.engine = engine;
}

   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDamageToMissiles().modifyPercent(id, DAMAGE_MISSILES_PERCENT);
stats.getMaxSpeed().modifyPercent(id, SPEED_BONUS);
stats.getBallisticWeaponRangeBonus().modifyFlat(id, 600f);
stats.getBeamWeaponRangeBonus().modifyFlat(id, 300f);
}
I am not sure how to do this exactly. I see this stems from basehull which I believe is not passed down to baseeveryframecombat plugin? Not really any methods that I can pull from there right?

Could you give me a little more syntax as to how I could write the for loop you gave me below? .getShips doesn't take the parameters right? Could I even use stats.getMaxSpeed() or methods like that. I have stats imported through MutableShipStatsAPI.



 
Code
@Override
    public void advance(float amount, List events) {
         //If we're paused or not in combat or whatever, stop here.
         if(engine == null
             || engine.isPaused()
             || (!engine.isInCampaign() && !engine.isInCampaignSim() && !engine.isMission() && !engine.isSimulation())){
                return;
         }   

         //Get all of the ships currently on the battlefield, iterate through them.
         for(ShipAPI ship : engine.getShips()){
                 
         }

    }

This part is not in the file by the way, only the top part I couldn't figure out the syntax for this part. If I am totally wrong I am to take a fee java course.

Thanks for any help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 17, 2019, 10:02:55 AM
You're going to want to write something that changes the MutableShipStatsAPI, accessible through ShipAPI (hence why I gave it that way).  Essentially, just tweak their max stats directly through a buff.

The only tricky bit, in terms of performance, is designing it so that it doesn't repeat; this is best-achieved through a HashSet, so that you can check .contains() for the presence of the ShipAPI in question and only alter its stats once.

Sorry if that went whoosh over your head, but basically, in Java, there are traditional data structures like arrays and a bunch of more exotic ones that offer great lookup performance, but are a little more difficult to understand initially.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 19, 2019, 09:44:16 PM
Is there a way to add a pre-existing LabelAPI to a TooltipMakerAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 20, 2019, 07:30:53 AM
TooltipMakerAPI.addCustom() should let you do it, if you cast the LabelAPI to a UIComponentAPI.

Be careful if that same LabelAPI already shows up somewhere in the UI, though - the behavior when the same UI element is added to the UI multiple times is undefined.

(Also, probably goes without saying, but hanging on to a LabelAPI in any sort of data that ends up in a savefile would not be a good idea.)

Edit: I guess what I'm trying to say is "it's possible, but the question sets off potential alarm bells" :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on July 21, 2019, 12:50:19 AM
I've got a ship with a module, which I'm trying to dynamically change (as in, the whole module) with a hullmod setup. I got this from ShipVariantAPI:

Code
void setModuleVariant(String slotId, ShipVariantAPI variant);

Frustratingly, it doesn't seem to work for me. I'm very sure I've got the weapon slot ID right, and I've got an actual ShipVariantAPI instance that I'm plugging into it (I've tried several), but no matter how I swing it that line of code acts as if it's just not executing - the ship remains sans-modules, or in the previous tests the module just doesn't change when it should.

Am I missing something obvious? Does this method only work in certain circumstances? I have only been testing in single missions, so if this is another thing that only works in the campaign please let me know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 21, 2019, 08:00:15 AM
What method are you calling this in? applyEffectsBeforeShipCreation() or applyEffectsAfterShipCreation()? The former has a chance of working (not 100% sure on how the order of operations works out); the latter has no chance since at that point the modules will have already been spawned.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on July 21, 2019, 11:17:41 PM
What method are you calling this in? applyEffectsBeforeShipCreation() or applyEffectsAfterShipCreation()? The former has a chance of working (not 100% sure on how the order of operations works out); the latter has no chance since at that point the modules will have already been spawned.

Ahhh, that would explain it. Yes I've been calling this in applyEffectsAfter...() and scratching my head. I'll try it in applyEffectsBefore...() and see if that works, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 22, 2019, 03:20:27 PM
Please let us know; that's an interesting one, in terms of where it's meant to be applied; if I'm reading that code correctly, it was designed largely for CampaignFleetAPI manipulations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on July 23, 2019, 12:24:19 AM
Hum. Problem: Trying to use "setModuleVariant()" in applyEffectsBefore...() is giving me a null warning because it's a method I'm applying to the ship's variant - and in applyEffectsBefore...(), the variant API instance doesn't necessarily exist yet.  ???

Code: java
@Override
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

    ShipAPI ship = null;
    if (stats.getEntity() instanceof ShipAPI) {
        ship = (ShipAPI) stats.getEntity();
    }

    if (SAVED_DATA.get(id) != null) {
        SAVED_DATA.put(id, "dara_unity_module0_Standard");
    }

    String variantId = SAVED_DATA.get(id);
    ShipVariantAPI thisModuleVariant = Global.getSettings().getVariant(variantId);

--> ship.getVariant().setModuleVariant("WS0001", thisModuleVariant);
    // This last line is causing a null warn. Netbeans is underlining the ".getVariant" bit, saying it's dereferencing a possible null pointer.
}
(SAVED_DATA is storing the variant ID of the module from elsewhere, don't worry about that.)

Any ways to get around this? Is it possible to make the last line only run once the variant has been created? I've tried putting it inside a "if (ship.getVariant() != null) {}" check, but it did the same thing on the if check.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 23, 2019, 08:48:27 AM
Hmm. Try stats.getVariant(), perhaps?

The ship might not actually be null at this point, I'm not 100% sure. Netbeans is just giving you a warning; that doesn't mean the code wouldn't work.

The "correct" way to code something like this would be, say:

ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
    ship = (ShipAPI) stats.getEntity();
} else {
    return;
}

But mainly that would just make it fail without crashing. If ship is null at that point and you're relying on it not being null to retrieve the vairant...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 23, 2019, 04:59:14 PM
In general, when NetBeans gives that warning, I address it; you just don't know when it'll be bye-bye, gamestate.

But it should be clean:

   @Override
   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
      ShipVariantAPI thisVariant = stats.getVariant();
      ShipVariantAPI thisModuleVariant = Global.getSettings().getVariant("variant_we_want");
      thisVariant.setModuleVariant("WS0001", thisModuleVariant);
        }

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on July 23, 2019, 11:14:17 PM
Netbeans is just giving you a warning; that doesn't mean the code wouldn't work.

Oh, no it definitely didn't work. :-[ I usually ignore Netbeans' yellow underlines, but in this case it was actually right - the mission with the test ship failed to load, and the "WARN" info in the game log pointed my to the line highlighted in my previous comment.

Hmm. Try stats.getVariant(), perhaps?

...

The "correct" way to code something like this would be, say:

ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
    ship = (ShipAPI) stats.getEntity();
} else {
    return;
}

But mainly that would just make it fail without crashing. If ship is null at that point and you're relying on it not being null to retrieve the vairant...

... I didn't know you could get a variant directly from the MutableStats instance. ??? That's funky.

I'll try that check, but I've gotta ask: If an instance of ShipAPI exists, must it have a variant? I assumed that the ship existed but its variant didn't, is that not the case? Is it actually that during my check the ship itself doesn't exist yet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on July 24, 2019, 01:10:03 AM
Update: Wow, so yeah I can get the variant from the stats instance ("wat"), however I'm so far unable to change the module using this method. I'm not really sure if I've got it set up right, but either way the advice so far appears to have helped, so thanks muchly for that.



Further update: Yeah I think the function just straight-up isn't working. I've taken out a bunch of the mutable/dynamic bits and am now simply trying to force the module to change to a different one in applyEffectsBefore...(), and nothing is happening.  :-\ Might be a lost cause unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 24, 2019, 04:56:52 AM
The NetBeans warning is indeed because ship might be null.
In the displayed code, it's assigned to null at start and only gets assigned to something else if a certain check passes. The IDE thus sees that it can't count on ship not being null when the code tries to use it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on July 24, 2019, 06:32:11 AM
I am really bad at moding, but I do have a question.

I can add a .faction file with only the "portrait" (variable?, property? i dont know how to name it) defined to append custom portrait to the hegemony. But if I wanted to replace existing portrait (so the old one wouldnt show up) how would I do it?

At least it was my understanding that a mod hegemony.faction only appended to the existing one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 24, 2019, 09:28:21 AM
Oh, no it definitely didn't work. :-[ I usually ignore Netbeans' yellow underlines, but in this case it was actually right - the mission with the test ship failed to load, and the "WARN" info in the game log pointed my to the line highlighted in my previous comment.

I was just saying that this doesn't *necessarily* mean it won't work. It could be, for example, that the conditions of the if statement that assign a value to it are always met, but Netbeans might not know about that depending on what the conditions are.

I'll try that check, but I've gotta ask: If an instance of ShipAPI exists, must it have a variant? I assumed that the ship existed but its variant didn't, is that not the case? Is it actually that during my check the ship itself doesn't exist yet?

Yeah, a ship is going to have a variant. (Unless bugs / some kind of weird edge case / etc, of course.)


I am really bad at moding, but I do have a question.

I can add a .faction file with only the "portrait" (variable?, property? i dont know how to name it) defined to append custom portrait to the hegemony. But if I wanted to replace existing portrait (so the old one wouldnt show up) how would I do it?

At least it was my understanding that a mod hegemony.faction only appended to the existing one.

You could have the portrait .pngs be named the same as the ones in the faction (which may not be desirable as I think some portraits are used across multiple factions). You could also add the .faction file to a "replace" section in your mod_info.json file, though that means you'd need to provide the full faction file, not just the portraits section.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 24, 2019, 09:52:54 AM
Rats, I thought that would be clean and "just work", Axle.

So, let's look at the case where it's invoked.  The only place in the API where that occurs is for Stations in CoreAutoFitPlugin, specifically this function:

Code
	protected Set<String> availableMods;
protected Set<String> slotsToSkip = new HashSet<String>();
protected Set<Integer> baysToSkip = new HashSet<Integer>();
protected boolean fittingModule = false;
protected int missilesWithAmmoOnCurrent = 0;
public void doFit(ShipVariantAPI current, ShipVariantAPI target, AutofitPluginDelegate delegate) {
if (!fittingModule) {
fittedWeapons.clear();
fittedFighters.clear();

randomize = isChecked(RANDOMIZE);

availableMods = new LinkedHashSet<String>(delegate.getAvailableHullmods());
}

current.getStationModules().putAll(target.getStationModules());

int index = 0;
for (String slotId : current.getStationModules().keySet()) {
ShipVariantAPI moduleCurrent = current.getModuleVariant(slotId);
if (moduleCurrent == null) continue;
if (moduleCurrent.isStockVariant()) {
moduleCurrent = moduleCurrent.clone();
moduleCurrent.setSource(VariantSource.REFIT);
moduleCurrent.setHullVariantId(moduleCurrent.getHullVariantId() + "_" + index);
}
index++;

// String variantId = current.getStationModules().get(slotId);
// ShipVariantAPI moduleTarget = Global.getSettings().getVariant(variantId);
ShipVariantAPI moduleTarget = target.getModuleVariant(slotId);
if (moduleTarget == null) continue;

fittingModule = true;
doFit(moduleCurrent, moduleTarget, delegate);
fittingModule = false;

current.setModuleVariant(slotId, moduleCurrent);
}
current.setSource(VariantSource.REFIT);

weaponFilterSeed = random.nextLong();

emptyWingTarget = null;
if (delegate.getAvailableFighters().size() > 0) {
emptyWingTarget = delegate.getAvailableFighters().get(random.nextInt(delegate.getAvailableFighters().size())).getId();
}

altWeaponCats.clear();
altFighterCats.clear();

slotsToSkip.clear();
baysToSkip.clear();

missilesWithAmmoOnCurrent = 0;

boolean strip = isChecked(STRIP);
if (strip) {
stripWeapons(current, delegate);
stripFighters(current, delegate);

current.setNumFluxCapacitors(0);
current.setNumFluxVents(0);
if (delegate.isPlayerCampaignRefit()) {
for (String modId : current.getNonBuiltInHullmods()) {
boolean canRemove = delegate.canAddRemoveHullmodInPlayerCampaignRefit(modId);
if (canRemove) {
current.removeMod(modId);
}
}
} else {
current.clearHullMods();
}
} else {
slotsToSkip.addAll(current.getFittedWeaponSlots());
for (int i = 0; i < 20; i++) {
String wingId = current.getWingId(i);
if (wingId != null && !wingId.isEmpty()) {
baysToSkip.add(i);
}
}
}

//boolean randomize = isChecked(RANDOMIZE);


boolean reinforcedHull = isChecked(ALWAYS_REINFORCED_HULL);
boolean blastDoors = isChecked(ALWAYS_BLAST_DOORS);

if (reinforcedHull) {
addHullmods(current, delegate, HullMods.REINFORCEDHULL);
}
if (blastDoors) {
addHullmods(current, delegate, HullMods.BLAST_DOORS);
}

addHullmods(current, delegate, target.getNonBuiltInHullmods().toArray(new String[0]));

int addedRandomHullmodPts = 0;
if (randomize) {
addedRandomHullmodPts = addRandomizedHullmodsPre(current, delegate);
}


fitFighters(current, target, false, delegate);
fitWeapons(current, target, false, delegate);

if (current.hasHullMod(HullMods.FRAGILE_SUBSYSTEMS) &&
(current.getHullSize() == HullSize.FRIGATE || current.getHullSize() == HullSize.DESTROYER)) {
addHullmods(current, delegate, HullMods.HARDENED_SUBSYSTEMS);
}


float addedMax = current.getHullSpec().getOrdnancePoints(stats) * 0.1f;
if (randomize && addedRandomHullmodPts <= addedMax) {
addRandomizedHullmodsPost(current, delegate);
}

float ventsCapsFraction = 1f;
boolean upgrade = isChecked(UPGRADE);
if (upgrade) {
ventsCapsFraction = 0.5f;
//ventsCapsFraction = 0f;
}

addVentsAndCaps(current, target, ventsCapsFraction);


// now that we're at the target level of vents and caps
// see if we can upgrade some weapons
if (upgrade) {
fitFighters(current, target, true, delegate);
fitWeapons(current, target, true, delegate);
addVentsAndCaps(current, target, 1f - ventsCapsFraction);
}

// float dissipation = current.getHullSpec().getFluxDissipation() + current.getNumFluxVents() * 10f;
// float generation = 0f;
// for (String slotId : current.getFittedWeaponSlots()) {
// WeaponSpecAPI spec = current.getWeaponSpec(slotId);
// generation += spec.getDerivedStats().getSustainedFluxPerSecond();
// }

addHullmods(current, delegate, HullMods.REINFORCEDHULL, HullMods.BLAST_DOORS, HullMods.HARDENED_SUBSYSTEMS);
addExtraVentsAndCaps(current, target);
addModsWithSpareOPIfAny(current, target, delegate);

current.setVariantDisplayName(target.getDisplayName());

current.getWeaponGroups().clear();
for (WeaponGroupSpec group : target.getWeaponGroups()) {
WeaponGroupSpec copy = new WeaponGroupSpec(group.getType());
copy.setAutofireOnByDefault(group.isAutofireOnByDefault());
for (String slotId : group.getSlots()) {
if (current.getWeaponId(slotId) != null) {
copy.addSlot(slotId);
}
}
if (!copy.getSlots().isEmpty()) {
current.addWeaponGroup(copy);
}
}

boolean player = fleetCommander != null && fleetCommander.isPlayer();

if (player) {
if (current.getWeaponGroups().isEmpty() || randomize || current.hasUnassignedWeapons()) {
current.autoGenerateWeaponGroups();
}
//current.assignUnassignedWeapons();
} else {
current.getWeaponGroups().clear(); // will get auto-assigned when deployed in combat; until then don't care
}

if (!fittingModule) {
delegate.syncUIWithVariant();
}
}


There's a lot going here; it'll take a me a little bit to unpack.  But we know it actually works here, if not in your context.

But it's calling for AutofitPluginDelegate, is in AutofitPlugin; it might be necessary to have that in this, since it appears there are some UI calls, etc. going on when a new Module is installed.

AutofitPluginDelegate:
Code
	public interface AutofitPluginDelegate {
void fitFighterInSlot(int index, AvailableFighter fighter, ShipVariantAPI variant);
void clearFighterSlot(int index, ShipVariantAPI variant);
void fitWeaponInSlot(WeaponSlotAPI slot, AvailableWeapon weapon, ShipVariantAPI variant);
void clearWeaponSlot(WeaponSlotAPI slot, ShipVariantAPI variant);

List<AvailableWeapon> getAvailableWeapons();
List<AvailableFighter> getAvailableFighters();

boolean isPriority(WeaponSpecAPI weapon);
boolean isPriority(FighterWingSpecAPI wing);

List<String> getAvailableHullmods();
void syncUIWithVariant();

ShipAPI getShip();

FactionAPI getFaction();

boolean isPlayerCampaignRefit();
boolean canAddRemoveHullmodInPlayerCampaignRefit(String modId);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on July 24, 2019, 10:04:07 AM
Aha, here's Thing No. 1; in doFit, it presumes we're flipping Variants, not changing the internals of the Variant... I think?  Anyhow... here's one bit that appears to apply specifically to your problem:

Code
		int index = 0;
for (String slotId : current.getStationModules().keySet()) {
ShipVariantAPI moduleCurrent = current.getModuleVariant(slotId);
if (moduleCurrent == null) continue;
if (moduleCurrent.isStockVariant()) {
moduleCurrent = moduleCurrent.clone();
moduleCurrent.setSource(VariantSource.REFIT);
moduleCurrent.setHullVariantId(moduleCurrent.getHullVariantId() + "_" + index);
}
index++;

ShipVariantAPI moduleTarget = target.getModuleVariant(slotId);
if (moduleTarget == null) continue;

fittingModule = true;
doFit(moduleCurrent, moduleTarget, delegate);
fittingModule = false;

current.setModuleVariant(slotId, moduleCurrent);
}
current.setSource(VariantSource.REFIT);

Some of that isn't necessary, like the call to doFit(), etc., but current.setSource() looks relevant.

There's also the question of the last bit, here:

Code
		
if (!fittingModule) {
delegate.syncUIWithVariant();
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on July 24, 2019, 05:00:03 PM
You could have the portrait .pngs be named the same as the ones in the faction (which may not be desirable as I think some portraits are used across multiple factions). You could also add the .faction file to a "replace" section in your mod_info.json file, though that means you'd need to provide the full faction file, not just the portraits section.

How does that interact with other mods that might add portrait by appending to the base file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 24, 2019, 05:08:35 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl 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);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra 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
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra 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?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 25, 2019, 01:15:09 PM
Hah, that's exactly right, actually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra 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?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh 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).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 26, 2019, 09:27:13 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?

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.

Quick update on this: changed $spawnFPMult to be the ratio of actual fleet points in the spawned fleet to the total points specified in the FleetParamsV3.

That way it also covers cases like asking for too many points, i.e. when the fleet has to be cut down to fit in the 30 ship limit, or even just when the total number of points doesn't quite match the asked-for number because, say, there's 2 points left and no ship that costs that little.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 26, 2019, 08:22:58 PM
Thanks for the help and the work, Alex :)

How long does the "Recent trade/events" modification to commodity availability last?
Is there an API method to apply/modify the recent trade availability bonus to a market? (Searched for "Recent trade/events" in API but couldn't find anything)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 26, 2019, 09:02:34 PM
How long does the "Recent trade/events" modification to commodity availability last?
Is there an API method to apply/modify the recent trade availability bonus to a market? (Searched for "Recent trade/events" in API but couldn't find anything)

30 days, see: BaseSubmarketPlugin.TRADE_IMPACT_DAYS

Also see CommodityOnMarketAPI:
addTradeMod()
addTradeModPlus()
addTradeModMinus()
getTradeMod()
getTradeModPlus()
getTradeModMinus()

The duration is passed in as a parameter to those methods.

The Plus and Minus versions can only ever increase (or decrease, for Minus) the "available" units. It's a bit dodgy, though, I forget exactly the circumstances that cause it, but using *Minus can lead to profitable buy/sell cycles (i.e. infinite money), so I'd say probably don't use that. AFAIK the other (i.e. not *Minus) methods work fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ross on July 30, 2019, 04:21:26 PM
Is there a way to get what key/button is bound for a certain action in-game? For example, if I wanted to get the "strafe left" key?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2019, 09:45:25 PM
Sort of.

Global.getSettings().getControlStringForEnumName(<string>)

However, the enum in question is not exposed in the API. Here's the subset for ship commands:

Spoiler
SHIP_FIRE("Fire selected weapon group", Category.FLIGHT),
      SHIP_SHIELDS("Toggle shields or phase cloak", Category.FLIGHT),
      //SHIP_SHIELDS_LOCK("Lock omni-directional shields to a relative facing", Category.FLIGHT),
      SHIP_USE_SYSTEM("Use ship's active system", Category.FLIGHT),
      SHIP_VENT_FLUX("Vent flux", Category.FLIGHT),
      SHIP_HOLD_FIRE("Hold fire", Category.FLIGHT),
      SHIP_PULL_BACK_FIGHTERS("Toggle fighter engage/regroup", Category.FLIGHT),
      SHIP_ACCELERATE("Accelerate", Category.FLIGHT),
      SHIP_ACCELERATE_BACKWARDS("Accelerate backwards", Category.FLIGHT),
      SHIP_DECELERATE("Decelerate", Category.FLIGHT),
      SHIP_TURN_LEFT("Turn left", Category.FLIGHT),
      SHIP_TURN_RIGHT("Turn right", Category.FLIGHT),
      SHIP_STRAFE_KEY("Strafe and turn to cursor", Category.FLIGHT),
      SHIP_STRAFE_LEFT_NOTURN("Strafe left", Category.FLIGHT),
      SHIP_STRAFE_RIGHT_NOTURN("Strafe right", Category.FLIGHT),
      SHIP_SELECT_GROUP_1("Select weapon group 1", Category.FLIGHT),
      SHIP_SELECT_GROUP_2("Select weapon group 2", Category.FLIGHT),
      SHIP_SELECT_GROUP_3("Select weapon group 3", Category.FLIGHT),
      SHIP_SELECT_GROUP_4("Select weapon group 4", Category.FLIGHT),
      SHIP_SELECT_GROUP_5("Select weapon group 5", Category.FLIGHT),
      SHIP_TOGGLE_GROUP_1("Toggle autofire for weapon group 1", Category.FLIGHT),
      SHIP_TOGGLE_GROUP_2("Toggle autofire for weapon group 2", Category.FLIGHT),
      SHIP_TOGGLE_GROUP_3("Toggle autofire for weapon group 3", Category.FLIGHT),
      SHIP_TOGGLE_GROUP_4("Toggle autofire for weapon group 4", Category.FLIGHT),
      SHIP_TOGGLE_GROUP_5("Toggle autofire for weapon group 5", Category.FLIGHT),
      SHIP_TARGET_SHIP("Target ship/clear target", Category.FLIGHT),
      SHIP_TOGGLE_XPAN_MODE("Switch view to target", Category.FLIGHT),
      SHIP_SHOW_WARROOM("Show map & command UI", Category.FLIGHT, Category.C2, Category.C2_WAYPOINT, Category.C2_FRIENDLY, Category.C2_HOSTILE),
      SHIP_TOGGLE_WEAPON_ARCS("Toggle weapon arcs", Category.FLIGHT),
      SHIP_RETREAT("Initiate travel drive to retreat", Category.FLIGHT),
      SHIP_RAISE_FLUX("Raise flux levels", Category.UNCONFIGURABLE),
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ross on July 31, 2019, 04:17:34 AM
Cool, thanks!

And it looks like I can use Keyboard.getKeyIndex() to get the integer key code from the control string. (In case anyone else is trying the same thing I am.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 01, 2019, 04:26:50 AM
Calling market.setFreePort(true) on a market with free port boolean set to false but having the Free Port market condition, still adds a second Free Port condition >:(

I suppose someone should yell at the modders to fix their market generation code (to not add the condition without applying the boolean), but I doubt we can count on them actually doing so. Meh, I'll just add the check for the condition to my own code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 01, 2019, 08:22:05 AM
Argh. Yeah, it's not a condition that ought to be added manually, just via setFreePort(). Made it not add duplicates, although that doesn't fix the underlying problem of "adding the condition manually gets it out of sync with the boolean so don't do that"...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on August 01, 2019, 04:21:37 PM
I suppose someone should yell at the modders to fix their market generation code (to not add the condition without applying the boolean), but I doubt we can count on them actually doing so.

Well, this is the first I'm hearing about it, so I guess you'll never know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 02, 2019, 11:54:00 PM
When I create a SectorEntityToken with LocationAPI.createToken(), then assign it an orbit with setCircularOrbit, it remains stationary (I can tell from the things I put in orbit around the token). How should I work around this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 03, 2019, 02:50:03 PM
I think the missing step is to location.addEntity(token), which will make sure the orbit's advance() method gets called. The createToken method does not actually add it to the location as it's not required for many of the uses.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 04, 2019, 04:13:55 PM
Am I correct in thinking that these are the only methods available for dynamically adjusting the specs of a ship system?
Code
    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
        ShipSystemAPI myShipSystem = ship.getSystem();
        myShipSystem.setCooldown((float) Math.PI);
        myShipSystem.setFluxPerSecond((float) Math.E);
        myShipSystem.setFluxPerUse(Float.MAX_VALUE);
    }
I'm trying to adjust ship system values like those, but I was hoping for a way to adjust charge regen rate as well.

Also, is there a better way to get ship system specs than loading ship_systems.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 05, 2019, 09:53:19 AM
Correct, yeah.

Made a few additions:
Added to SettingsAPI:
   ShipSystemSpecAPI getShipSystemSpec(String id);
   List<ShipSystemSpecAPI> getAllShipSystemSpecs();
Added a lot of methods to ShipSystemSpecAPI
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stargazer7x on August 05, 2019, 10:32:47 AM
How would I go about increasing the maximum amount of random constellations and planets generated in the sector?
I already modified the sector's size and I am not sure if that makes a difference or not, but I would like to use a method that allows more fine tuning if at all possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 05, 2019, 11:04:18 AM
Many thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xerdies on August 05, 2019, 11:04:46 PM
Hey hey, quick question.

I would like to add one more commodity item. The item is already in the game but, as there is no way to create it nor a demand, I wanted to ask where I should look to build the "industry" for it - and how to entice the generator to build said new industry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 05, 2019, 11:36:42 PM
How would I go about increasing the maximum amount of random constellations and planets generated in the sector?
I already modified the sector's size and I am not sure if that makes a difference or not, but I would like to use a method that allows more fine tuning if at all possible.
Hey, welcome to the forums  :)
I'm not sure of a good place to look for something like that in vanilla files.
You might try looking at the files in "Starsector\mods\Blackrock Drive Yards\jars\src\data\scripts\world\blackrock", which are used to create two new star systems.
http://fractalsoftworks.com/forum/index.php?topic=4018.0

I would like to add one more commodity item. The item is already in the game but, as there is no way to create it nor a demand, I wanted to ask where I should look to build the "industry" for it - and how to entice the generator to build said new industry.
Welcome to you as well!
Industries are defined in "\Starsector\starsector-core\data\campaign\industries.csv"
You can find the files used to designate which industries the vanilla worlds have (among other things) in "\Starsector\starsector-core\data\campaign\econ"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xerdies on August 05, 2019, 11:37:56 PM
Thank you so much <3
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 05, 2019, 11:46:34 PM
No problem! I look forward to finding out what you're working on  :)

btw, the unofficial Starsector discord (http://fractalsoftworks.com/forum/index.php?topic=11488.msg195852#msg195852) is a great place to get quick answers
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psinet on August 06, 2019, 09:10:17 PM
Hi, How would I go about adding/editing ui elements of the game. I want to add 4 more slots for industries on the colony info screen. If it too much work just point me in the right direction and I'll go at it till it doesn't work anymore. Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 06, 2019, 09:14:27 PM
How would I go about increasing the maximum amount of random constellations and planets generated in the sector?
I already modified the sector's size and I am not sure if that makes a difference or not, but I would like to use a method that allows more fine tuning if at all possible.

That requires a bunch of coding - take a look at com.fs.starfarer.api.impl.campaign.procgen.SectorProcGen, if you're so inclined. The source code is in starfarer.api.zip, but to actually get the game to use any changes you might make, you'd need to compile it (which involves setting up a dev environment) and point to your code from settings.json, via "newGameSectorProcGen".


Hi, How would I go about adding/editing ui elements of the game. I want to add 4 more slots for industries on the colony info screen. If it too much work just point me in the right direction and I'll go at it till it doesn't work anymore. Thanks

That's not actually possible, I'm afraid. (Well, you could do it by hacking the bytecode, but that's against the ToS, and it'd be... difficult.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Psinet on August 06, 2019, 09:29:00 PM
Hi, How would I go about adding/editing ui elements of the game. I want to add 4 more slots for industries on the colony info screen. If it too much work just point me in the right direction and I'll go at it till it doesn't work anymore. Thanks

That's not actually possible, I'm afraid. (Well, you could do it by hacking the bytecode, but that's against the ToS, and it'd be... difficult.)

Well that's disappointing, as confident I am in my computer skills programing was never my skill. Thanks for the quick response.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 07, 2019, 05:17:35 PM
Thanks Alex for redirecting me here!

I have been following the guide over at the wiki;
I am trying to make a mod that adds (more) drones, sadly the wiki does not appear to cover that.
After a few hours of trying to no avail, I attempted to dissect other people's mods (I use no code, just look at how it works), but I came back empty-handed, except for a higher understanding of the file structure and the CVS files.

Needless to say, I have zero experience modding this game and I am thoroughly lost as to how to make a drone.

What steps should I take?
I got the required files to make it load in the game menu.
I have made the ships list (which contains the drone stats, or at least thats how I understand it)
And I have the sprites (though I was not able to figure out how to use the sprite editor, I downloaded the new sf-ship-ed.3.0.0-alpha-5 today, but had no chance of using it, will try it tomorrow)

Hopefully, my question is not to vexing. Thank you in advance.

Edit: Apparently my in-writing post got posted for some reason, I deleted it and posted this (the finished version) in its stead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 07, 2019, 05:43:11 PM
Roughly, you need:
1) the sprite
2) a .ship file, which defines the drone's hull - engine locations, weapon locations, bounds, etc
3) a .variant file, which defines a specific loadout for the drone - i.e. the actual weapons it uses
4) a .system file, which defines the system you'll be assigning to the ship that spawns the drone


... actually, what exactly do you mean by "drone"? A ship system that launches drones, or a drone fighter wing, like the Mining Drones or the Borer Drones?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kazi on August 07, 2019, 07:32:50 PM
How do you add cargo to a market? I though the way to go would be the following, but after some debugging, there aren't actually any submarkets for whatever reason to add cargo to. The market itself was created via json file in data/campaign/econ

Code
// we start off with the MarketAPI "market"
SubmarketAPI submarket = market.getSubmarket("military"); // submarket is null and there are no submarkets as far as i can tell
submarket.getCargo().addWeapons("tachyonlance", 100);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 07, 2019, 07:51:12 PM
IIRC a market like that wouldn't have a military submarket unless it had a military base. You can add a submarket via market.addSubmarket(String id) (again, iirc - the method name could be slightly off, but I think that should be right).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 07, 2019, 09:46:28 PM
Based on the class below (which I happened to read for the first time today), I suspect "military" might not be the correct key for getting military submarkets.
Code
package com.fs.starfarer.api.impl.campaign.ids;

public class Submarkets {

public static final String GENERIC_MILITARY = "generic_military";

public static final String SUBMARKET_STORAGE = "storage";
public static final String SUBMARKET_OPEN = "open_market";
public static final String SUBMARKET_BLACK = "black_market";

public static final String LOCAL_RESOURCES = "local_resources";
}
Makes me wonder what type of future military submarket might not be generic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TeaJay on August 08, 2019, 12:43:45 AM
Not sure if this counts as a modding question, but is it possible to unlock the maximum amount of skills an officer has in the files somewhere? I've already increased the max level, but it seems they can't get more then the UI can hold. Don't mind if it clips trough the window or anything, I just want OP officers ^^
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on August 08, 2019, 02:02:46 AM
Is there a simple way to change a faction's default station variant while still using the vanilla station?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 08, 2019, 05:19:41 AM
Roughly, you need:
1) the sprite
2) a .ship file, which defines the drone's hull - engine locations, weapon locations, bounds, etc
3) a .variant file, which defines a specific loadout for the drone - i.e. the actual weapons it uses
4) a .system file, which defines the system you'll be assigning to the ship that spawns the drone


... actually, what exactly do you mean by "drone"? A ship system that launches drones, or a drone fighter wing, like the Mining Drones or the Borer Drones?

They were called drones on the files I inspected, but yeah, thats what I mean, like the Talon Interceptor Wing. Sorry I didnt make it clear enough.

Edit (Update more like): Iv been messing with the S&W editor and I have a few questions as to the usage.
I found that if you set it to "wing" edit mode, it lets you edit the CSV data of the wing fighter.
(https://cdn.discordapp.com/attachments/265790273718583296/609002649903300618/unknown.png)
The data shown here is different from the one stored in ship_data.cvs.
Here is the code I got in ship_data.cvs, Its literally a Dassault-Mikoyan cvs with a few small changes (to see if it works, then do the actual changes once I see that it all loads)
Code
Standard Mech,INDM,,Here goes Tech/manu,,,75,25,300,,50,,,300,450,450,240,250,5,NONE,,0,0,0,,,0,0,,,,,,,,,,,,,,,,0,,,
I believe I understand how this works, both CVS(es) use the ID to call upon each other when loading, but there is one tiny thing I dont understand, when im in wing mode, I cannot edit the bounds, infact, I cannot even load an image...
(https://cdn.discordapp.com/attachments/265790273718583296/609006465591672844/unknown.png)
My guess is that I must create the CVS, then a hull and merge both manually into one single file, correct?

On a side note, I found https://fractalsoftworks.com/forum/index.php?topic=13279.msg223716#msg223716, which I will look into when I have to edit the Jar, im guessing ill need it to actually spawn the wings into the game world; so it will come in handy.

On a side side note, this post might get a bit long, as I find stuff out and try new stuff I like to post about it; because theres nothing worse than trying to help someone and have them reply "oh well actually I already figured that out" or "Oh but I changed the method to this way so this is invalid"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 08, 2019, 01:36:19 PM
Not sure if this counts as a modding question, but is it possible to unlock the maximum amount of skills an officer has in the files somewhere? I've already increased the max level, but it seems they can't get more then the UI can hold. Don't mind if it clips trough the window or anything, I just want OP officers ^^

I'm not 100% sure if it just limits the skills it shows - you might still be able to level them up and add the skills, they just might not show in the officer list. Either way, though, there's no other setting to tweak, beyond the one you've already found. You *could* write some code to give them all the skills, but that's considerably more work.

Is there a simple way to change a faction's default station variant while still using the vanilla station?

Hmm, I don't think so. Might be some creative workaround, but all that comes to mind right now is a new mostly-copy-paste industries.csv entry.

Spoiler
Roughly, you need:
1) the sprite
2) a .ship file, which defines the drone's hull - engine locations, weapon locations, bounds, etc
3) a .variant file, which defines a specific loadout for the drone - i.e. the actual weapons it uses
4) a .system file, which defines the system you'll be assigning to the ship that spawns the drone


... actually, what exactly do you mean by "drone"? A ship system that launches drones, or a drone fighter wing, like the Mining Drones or the Borer Drones?

They were called drones on the files I inspected, but yeah, thats what I mean, like the Talon Interceptor Wing. Sorry I didnt make it clear enough.

Edit (Update more like): Iv been messing with the S&W editor and I have a few questions as to the usage.
I found that if you set it to "wing" edit mode, it lets you edit the CSV data of the wing fighter.
(https://cdn.discordapp.com/attachments/265790273718583296/609002649903300618/unknown.png)
The data shown here is different from the one stored in ship_data.cvs.
Here is the code I got in ship_data.cvs, Its literally a Dassault-Mikoyan cvs with a few small changes (to see if it works, then do the actual changes once I see that it all loads)
Code
Standard Mech,INDM,,Here goes Tech/manu,,,75,25,300,,50,,,300,450,450,240,250,5,NONE,,0,0,0,,,0,0,,,,,,,,,,,,,,,,0,,,
I believe I understand how this works, both CVS(es) use the ID to call upon each other when loading, but there is one tiny thing I dont understand, when im in wing mode, I cannot edit the bounds, infact, I cannot even load an image...
(https://cdn.discordapp.com/attachments/265790273718583296/609006465591672844/unknown.png)
My guess is that I must create the CVS, then a hull and merge both manually into one single file, correct?

On a side note, I found https://fractalsoftworks.com/forum/index.php?topic=13279.msg223716#msg223716, which I will look into when I have to edit the Jar, im guessing ill need it to actually spawn the wings into the game world; so it will come in handy.

On a side side note, this post might get a bit long, as I find stuff out and try new stuff I like to post about it; because theres nothing worse than trying to help someone and have them reply "oh well actually I already figured that out" or "Oh but I changed the method to this way so this is invalid"
[close]

I can't really speak to using the editor - not very familiar with it.

What you need:

A .ship file, with the basic data for the ship that's *not* its stats (i.e. we're defining bounds, engine glows, weapon slots, etc)
A ship_data.csv entry for the ship, with its stats (speed, OP, flux, etc)
A .variant file for the ship, which defines its loadout - weapons, etc
A wing_data.csv entry for the fighter wing, defining its parameters - number of fighters, fighter variant, etc

At that point, you should be able to run the game in devMode (data/config/settings.json; set devMode to true), press "Edit Variants" from the main menu, scroll down to any carrier, and if you click on one of its fighter bays, your fighter should show up there as an option to install. (Unless it has tags that prevent it from showing up there; make sure you copy something "normal" for the wing_data.csv row; i.e. a Talon or something.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 09, 2019, 05:18:53 AM
Spoiler
Not sure if this counts as a modding question, but is it possible to unlock the maximum amount of skills an officer has in the files somewhere? I've already increased the max level, but it seems they can't get more then the UI can hold. Don't mind if it clips trough the window or anything, I just want OP officers ^^

I'm not 100% sure if it just limits the skills it shows - you might still be able to level them up and add the skills, they just might not show in the officer list. Either way, though, there's no other setting to tweak, beyond the one you've already found. You *could* write some code to give them all the skills, but that's considerably more work.

Is there a simple way to change a faction's default station variant while still using the vanilla station?

Hmm, I don't think so. Might be some creative workaround, but all that comes to mind right now is a new mostly-copy-paste industries.csv entry.

Spoiler
Roughly, you need:
1) the sprite
2) a .ship file, which defines the drone's hull - engine locations, weapon locations, bounds, etc
3) a .variant file, which defines a specific loadout for the drone - i.e. the actual weapons it uses
4) a .system file, which defines the system you'll be assigning to the ship that spawns the drone


... actually, what exactly do you mean by "drone"? A ship system that launches drones, or a drone fighter wing, like the Mining Drones or the Borer Drones?

They were called drones on the files I inspected, but yeah, thats what I mean, like the Talon Interceptor Wing. Sorry I didnt make it clear enough.

Edit (Update more like): Iv been messing with the S&W editor and I have a few questions as to the usage.
I found that if you set it to "wing" edit mode, it lets you edit the CSV data of the wing fighter.
(https://cdn.discordapp.com/attachments/265790273718583296/609002649903300618/unknown.png)
The data shown here is different from the one stored in ship_data.cvs.
Here is the code I got in ship_data.cvs, Its literally a Dassault-Mikoyan cvs with a few small changes (to see if it works, then do the actual changes once I see that it all loads)
Code
Standard Mech,INDM,,Here goes Tech/manu,,,75,25,300,,50,,,300,450,450,240,250,5,NONE,,0,0,0,,,0,0,,,,,,,,,,,,,,,,0,,,
I believe I understand how this works, both CVS(es) use the ID to call upon each other when loading, but there is one tiny thing I dont understand, when im in wing mode, I cannot edit the bounds, infact, I cannot even load an image...
(https://cdn.discordapp.com/attachments/265790273718583296/609006465591672844/unknown.png)
My guess is that I must create the CVS, then a hull and merge both manually into one single file, correct?

On a side note, I found https://fractalsoftworks.com/forum/index.php?topic=13279.msg223716#msg223716, which I will look into when I have to edit the Jar, im guessing ill need it to actually spawn the wings into the game world; so it will come in handy.

On a side side note, this post might get a bit long, as I find stuff out and try new stuff I like to post about it; because theres nothing worse than trying to help someone and have them reply "oh well actually I already figured that out" or "Oh but I changed the method to this way so this is invalid"
[close]

I can't really speak to using the editor - not very familiar with it.

What you need:

A .ship file, with the basic data for the ship that's *not* its stats (i.e. we're defining bounds, engine glows, weapon slots, etc)
A ship_data.csv entry for the ship, with its stats (speed, OP, flux, etc)
A .variant file for the ship, which defines its loadout - weapons, etc
A wing_data.csv entry for the fighter wing, defining its parameters - number of fighters, fighter variant, etc

At that point, you should be able to run the game in devMode (data/config/settings.json; set devMode to true), press "Edit Variants" from the main menu, scroll down to any carrier, and if you click on one of its fighter bays, your fighter should show up there as an option to install. (Unless it has tags that prevent it from showing up there; make sure you copy something "normal" for the wing_data.csv row; i.e. a Talon or something.)
[close]

How do you make ship files? Given that you dont use the ship editor, I assume you just calculate it mathematically and then write it down on the file itself? I just wanna know since I was able to do most but not all of the work with the ship editor and I need to finish it via another method, the code is in the spoiler-folder below (in case you wanted to see it), I was not able to add engines or built-in weapon slots.
Spoiler
Code
{
  "bounds": [
    -15.5,
    -22,
    -18.5,
    -11,
    -18.5,
    11,
    -15.5,
    22,
    17,
    19.5,
    10,
    9,
    10,
    -9,
    17,
    -19.5
  ],
  "center": [
    22,
    18.5
  ],
  "collisionRadius": 29.5,
  "coversColor": "\r",
  "engineSlots": [],
  "height": 37,
  "hullId": "IND_JunkMech",
  "hullName": "Junk Mech",
  "hullSize": "FIGHTER",
  "shieldCenter": [
    0,
    0
  ],
  "shieldRadius": 33,
  "spriteName": "graphics/ships/IND_JunkMech.png",
  "style": "LOW_TECH",
  "viewOffset": 0,
  "weaponSlots": [],
  "width": 44
}
[close]

IF it is based on the actual pixel location (as I assume, though that 29.5 in the col radius scares me), ill have a version were I add the weapon and engine slots manually in the zip file at the end of this post.
(Note, I got no idea what "contrailSize" dictates, I can more or less imagine but its the details that im lacking.)
Turns out im stupid and I can use the editor to get the position so I can manually add a location to the weapons, oops.

A pair of sidenotes:
To anyone reading this, given that it is a public forum and you can see this, install Libre Office, its fantastic for CSV files and it saves the headache of having to upload stuff to google sheets.
Also, this post is a bit hard to read, mainly because it is written in real-time as I do stuff, so I make sure to document everything as it happens.

As I edit the wing_data.csv file, I come across the following questions:
1. What does "role(number)" mean? (Such as: Fighter2, Bomber6)? Is it some form of behavioural designation?
2. How does rarity work? It seems only a few fighters have a spawnrate set to them, yet they all spawn.
3. Does a tier do anything? Like locking it out of specific low-level enemies?
4. What about "attackPositionOffset"? I assume it is the angle at which the choice to fight (such as shooting missiles sideways??)
5. What about "refit"? I assume this affects the damage done to the fleet if this wing is added to a ship mid-flight?

As far as I can tell, all I need is the files you mentioned, yet when I try to run it I get:
Code
227952 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NumberFormatException: For input string: "
"
java.lang.NumberFormatException: For input string: "
"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at com.fs.starfarer.loading.ShipHullSpecLoader.o00000(Unknown Source)
at com.fs.starfarer.loading.ShipHullSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.?O0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

From what I can tell, this does not appear to originate from my mod...?

EDIT: Forgot the zip lol
https://filebin.net/c8714tkahxyatcfu

Oh and also, given that you are an admin I thought id tell you this, the IP logger on the forum seems to be getting my IP wrong, not sure why.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 09, 2019, 05:45:39 AM
Your wing_data.csv has a bunch of garbage in it (column AC in spreadsheet editor)
e.g.
Code: csv
id,variant,tags,tier,rarity,fleet pts,op cost,formation,range,attackRunRange,attackPositionOffset,num,role,role desc,refit,base value,,,,,,,,,,,,,number
IND_JunkMech,IND_JunkMech_variant,"fighter4, fighter, low, lowtech_bp",0,,3,2,V,4000,450,,4,FIGHTER,Fighter,5,1500,,,,,,,,,,,,,1
,,,,,,,,,,,,,,,,,,,,,,,,,,,,2
,,,,,,,,,,,,,,,,,,,,,,,,,,,,3
,,,,,,,,,,,,,,,,,,,,,,,,,,,,4
,,,,,,,,,,,,,,,,,,,,,,,,,,,,5
,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,6
,,,,,,,,,,,,,,,,,,,,,,,,,,,,7
,,,,,,,,,,,,,,,,,,,,,,,,,,,,8
,,,,,,,,,,,,,,,,,,,,,,,,,,,,9
,,,,,,,,,,,,,,,,,,,,,,,,,,,,10
,,,,,,,,,,,,,,,,,,,,,,,,,,,,11
,,,,,,,,,,,,,,,,,,,,,,,,,,,,12
,,,,,,,,,,,,,,,,,,,,,,,,,,,,13
,,,,,,,,,,,,,,,,,,,,,,,,,,,,10
,,,,,,,,,,,,,,,,,,,,,,,,,,,,10
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 09, 2019, 09:40:59 AM
Your wing_data.csv has a bunch of garbage in it (column AC in spreadsheet editor)
e.g.
Code: csv
id,variant,tags,tier,rarity,fleet pts,op cost,formation,range,attackRunRange,attackPositionOffset,num,role,role desc,refit,base value,,,,,,,,,,,,,number
IND_JunkMech,IND_JunkMech_variant,"fighter4, fighter, low, lowtech_bp",0,,3,2,V,4000,450,,4,FIGHTER,Fighter,5,1500,,,,,,,,,,,,,1
,,,,,,,,,,,,,,,,,,,,,,,,,,,,2
,,,,,,,,,,,,,,,,,,,,,,,,,,,,3
,,,,,,,,,,,,,,,,,,,,,,,,,,,,4
,,,,,,,,,,,,,,,,,,,,,,,,,,,,5
,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,6
,,,,,,,,,,,,,,,,,,,,,,,,,,,,7
,,,,,,,,,,,,,,,,,,,,,,,,,,,,8
,,,,,,,,,,,,,,,,,,,,,,,,,,,,9
,,,,,,,,,,,,,,,,,,,,,,,,,,,,10
,,,,,,,,,,,,,,,,,,,,,,,,,,,,11
,,,,,,,,,,,,,,,,,,,,,,,,,,,,12
,,,,,,,,,,,,,,,,,,,,,,,,,,,,13
,,,,,,,,,,,,,,,,,,,,,,,,,,,,10
,,,,,,,,,,,,,,,,,,,,,,,,,,,,10

I tried deleting the numbers that were not in usage, it still gave me the error.
I deleted the entire row and I still got the error... what else should I try?

Edit: I check this page about 20 times a day, I really gotta find more ways to spend time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 09, 2019, 06:49:44 PM
Ah, checked the log and found that the problem was in IND_JunkMech.ship. The coversColor tag is corrupted (not sure if bug in ship editor or it got there later).
Code
  "coversColor": "\r",
Removing that fixes the error, although it crashes again later during startup (the mod plugin referenced in the modinfo doesn't actually exist).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 10, 2019, 03:59:46 AM
Ah, checked the log and found that the problem was in IND_JunkMech.ship. The coversColor tag is corrupted (not sure if bug in ship editor or it got there later).
Code
  "coversColor": "\r",
Removing that fixes the error, although it crashes again later during startup (the mod plugin referenced in the modinfo doesn't actually exist).

Well do I feel stupid now... Thank you. Very much so, I probably would have never figured this one out on my own.

At that point, you should be able to run the game in devMode (data/config/settings.json; set devMode to true), press "Edit Variants" from the main menu, scroll down to any carrier, and if you click on one of its fighter bays, your fighter should show up there as an option to install. (Unless it has tags that prevent it from showing up there; make sure you copy something "normal" for the wing_data.csv row; i.e. a Talon or something.)
And just like that it works!
(https://cdn.discordapp.com/attachments/237305246852841472/609697060312055848/unknown.png)
It shows up in the edit variant thing but I have not been able to see whether or not it spawns on markets, I guess ill find out if I test for long enough.

Now that all seems to work, im gonna start adding more and more mechs to my mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 10, 2019, 08:21:41 AM
Nice! To make it available for sale, you'll need to make it available to the faction that controls the market, via its .faction file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: froppyfropfrop on August 10, 2019, 09:47:56 AM
Suppose you made a custom industry for a custom faction. For player planets I want that industry to be locked behind the appropriate blueprint, and said blueprints to be available from the nation's markets. How would I accomplish this, if at all?

I could find lots of info on how to do this for ships and items, but not buildings, and I can't seem to find a way to tag my industry to be part of a blueprint pack.

If that's impossible:
Do all industries just *have* to be available to the player?

If not, how would I mark an industry such that a player can never construct it? (i.e. make it a unique planetary feature)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 10, 2019, 10:12:52 AM
Take a look at com.fs.starfarer.api.impl.campaign.econ.impl.PlanetaryShield

Code: java
@Override
public boolean isAvailableToBuild() {
if (!Global.getSector().getPlayerFaction().knowsIndustry(getId())) {
return false;
}
return market.getPlanetEntity() != null;
}

The BaseIndustry implementation of that method doesn't check whether the player knows the industry blueprint, i.e. by default industries are available, and ones that aren't (like PlanetaryShield or LionsGuardHQ) implement this method in the appropriate way for that use case. The LionsGuardHQ method just returns false, for example.

There's no "blueprint pack" item for industries, there's just a base industry blueprint item. The way to create a blueprint for a specific industry with code is something like:

cargo.addSpecial(new SpecialItemData("industry_bp", "planetaryshield"), 1);

Replacing "planetaryshield" with your industry id. "industry_bp" is the id of the base industry blueprint item, defined in data/campaign/special_items.csv.

You could also have an industry blueprint drop via drop_groups.csv (or code to create a drop group); the "commodity" column for this would be this:

item_industry_bp:planetaryshield

item_ says it's a special item
industry_bp is the id of the item
After the : follows the special data parameter, same as the second parameter in new SpecialItemData("industry_bp", "planetaryshield")
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 10, 2019, 11:42:27 AM
Nice! To make it available for sale, you'll need to make it available to the faction that controls the market, via its .faction file.
I assume I must go to each individual faction file (which there seems to be quite a few of, I didnt know half of them) and add the item's ID... But where?

Code
"knownFighters":{
I assume this is which fighter they have a chance of spawning with? Or do they actually have to have the item itself beforehand?
Or perhaps adding it to the list above will actually make it spawn in their markets, which if so, since it uses tags, it should already work because I tagged the fighter as "lowtech_bp".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 10, 2019, 11:57:58 AM
Yeah, that's the section. If you've got the tag, then, yeah, you're right, it should already show.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 10, 2019, 12:45:26 PM
Yeah, that's the section. If you've got the tag, then, yeah, you're right, it should already show.
I have a question, how do I assign a specific gun to a fighter hull?
I wanna give my mech a dual machinegun and 2 missile launchers, I assume this must be done via the hull file itself, but im not sure on the details.
Code
"weaponSlots": [
    {
      "angle": 0,
      "arc": 60,
      "id": "WS 001",
      "locations": [
        29.5,
        -29.5
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 5,
      "id": "WS 002",
      "locations": [
        27.5,
        31.5
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "BALLISTIC"
    },
    {
      "angle": 0,
      "arc": 5,
      "id": "WS 003",
      "locations": [
        27.5,
        41
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "BALLISTIC"
    }
  ],
What do I do?[/s]

EDIT: IM STUPID
I forgot variants were a thing. My bad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on August 10, 2019, 01:19:24 PM
Fighter weapons are usually assigned in the .variant file rather than being built into the hull itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 10, 2019, 02:54:37 PM
Yet another question arises, how do I change the respawn timer on fighters? My OP fighter respawns too quick, which makes it impossible for the enemy to attack.

Edit 2: How do I make my fighter fire its missile from a distance? He keeps getting ontop of the enemy in order to fire its torpedo, its madness.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on August 10, 2019, 04:23:08 PM
Yet another question arises, how do I change the respawn timer on fighters? My OP fighter respawns too quick, which makes it impossible for the enemy to attack.

"refit time" in wing_data.csv. It's the time, in seconds, it takes the carrier to build a new fighter if one is lost. Higher number = slower replacement.

How do I make my fighter fire its missile from a distance? He keeps getting ontop of the enemy in order to fire its torpedo, its madness.

What's the range of the torpedo weapon, and is it guided? What do you have set for the fighter's "engagement range" in wing_data.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 10, 2019, 05:05:12 PM
Yet another question arises, how do I change the respawn timer on fighters? My OP fighter respawns too quick, which makes it impossible for the enemy to attack.

"refit time" in wing_data.csv. It's the time, in seconds, it takes the carrier to build a new fighter if one is lost. Higher number = slower replacement.

How do I make my fighter fire its missile from a distance? He keeps getting ontop of the enemy in order to fire its torpedo, its madness.

What's the range of the torpedo weapon, and is it guided? What do you have set for the fighter's "engagement range" in wing_data.csv?

I had totally forgotten that engagement range was a thing... somehow. Thanks, now my mechs actually aim!!

Oh and thanks for telling me about the refit time, I thought this affected the amount of time it took for your fleet to adapt to a change mid-flight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 10, 2019, 06:08:52 PM
Is there any way to change the behaviour so that instead of making a "fly-by" it stays at a safe distance and snipes? Is it bound to the weapon perhaps?

Edit: its 4 am and im starting to get tired, so I think ill stop for the day; I added my first custom weapon, which instantly resulted in a crash.
Logs were not... super helpful, so im not sure whats the cause, ill look into it tomorrow first thing in the morning (or afternoon if I sleep through the morning haha), until then, if anyone wants to check it out, go ahead and be my guest.
https://filebin.net/iotwql56uqo7bf0w

Edit 2: Found a solution, just not getting into complex stuff yet. /lol

Edit 3: That was a good decision, my mod is coming along nicely, I just need some more med and superheavy mechs and ill publish the first release. Also I think I might have figured out the fly by thing, but I cant say for sure right now.

Edit 4 (electric boogaloo): Im publishing my mod as a WIP thing so I can get feedback.

Edit 5 (final edit on this post I promise): Hurray its out (http://fractalsoftworks.com/forum/index.php?topic=15998.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rencor12 on August 11, 2019, 09:20:41 PM
Hello, does anyone know how to increase the number of colonies the player character can personally administrate?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nawj on August 12, 2019, 04:37:16 AM
Could someone explain to me how portrait packs are made? I love the available portrait packs on the forums, but I've been wanting to remove the portraits from them I feel don't fit the aesthetic. I figure the best way to go about this is to just make my own portrait mod and combine all of the images I want from the portrait mods on the forum.
I tried searching for a topic about this but I didn't really find anything, sorry if this is a question that's been asked a lot or if there is a thread/guide for it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 12, 2019, 05:40:09 AM
Could someone explain to me how portrait packs are made? I love the available portrait packs on the forums, but I've been wanting to remove the portraits from them I feel don't fit the aesthetic. I figure the best way to go about this is to just make my own portrait mod and combine all of the images I want from the portrait mods on the forum.
I tried searching for a topic about this but I didn't really find anything, sorry if this is a question that's been asked a lot or if there is a thread/guide for it.
I have looked into this myself and as far as I can tell, its quite easy.
1. Have all the default mod files (check out the first time modding tutorial)
2. Have all the images in your graphics folder
3. Have a data/factions folder, then inside copy over the factions you want to give the portraits to (ex: all, including "player faction")
4. Open the faction file and under the "male" or "female" portrait list, add the name of your files as a new line.

The easiest way to do this is to borrow someone else's mod and modify it.
I recommend the degenerate pack, delete (or replace) the portraits and then just go ahead and re-write the faction files there, they already come clear of all unnecessary code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 12, 2019, 09:53:59 AM
Is there any way to set a min distance for wings (fighters) to stay at? All my mechs keep trying to get inside of their target.
I just want them to fire from the distance, removing the run distance parameter makes them float around and shoot, but at times they still try to close in...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 12, 2019, 10:07:10 AM
I don't believe so - what you're seeing is "how it works" as far as fighter behavior.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alemismun on August 12, 2019, 11:23:40 AM
I don't believe so - what you're seeing is "how it works" as far as fighter behavior.
I guess ill just have to live with suicidal mechs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: guedez on August 12, 2019, 02:58:16 PM
Is there any mod that lets you add custom intel to sectors? I'd like to keep track where the stations that I didn't search because I had too much stuff to carry are
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 15, 2019, 09:14:48 AM
I've been trying to experiment a bit with the economy, generally to slow the progression a bit, and i have a question.

I tried to, among other things, make it so that the markets take longer to replenish the stockpiles (more than the default 30 days). I found the getStockpilingAddRateMult in the BaseMarketPlugin and adjusted it. It worked but the problem is that the commodities in stock do not translate into Available and Excess values. For instance, a market has 1000 organics after the game starts but the F1 tooltip shows it has 3000 available with 400 excess. So the numbers seem to still be tied to the production units or something.

There are also other weird interactions, but I want to be be brief. Is there a way to make it so that the numbers, that is the demand, supply and excess, play along nicely with the change to the add rate? I tried looking through other files, but im a layman when it comes to java coding so it wasn't really that productive  :P .
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 15, 2019, 10:25:30 AM
What's shown as "available" in the F1 tooltip is an estimate assuming the colony has had time to catch up, i.e. for the stockpiles to reach the stable point. Since what you've done makes it take longer to do that, it'll be out-of-sync until enough time passes.

You might fix this by, say, having the rate only be lower after the player has interacted with the colony once. Or by making the initial new-game-advance step take longer so that things reach the stable point (offhand, not 100% if that's easily doable).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 15, 2019, 10:59:45 AM
Alright, so i forgot to mention that i also reduced the stockpile consumption rate when there is a demand as well. I just wanted to know if these changes may upset the economy or something, since one of the werid situations i mentioned was that a commodity had an excess of 1000 shown when there were only 400 in stock.

 I was also concerned that there is a separate script for the stock ammount and the available and excess numbers that are just attuned to work together and i changed the variable only for one. So the stock would grow or fall inadequately to the excess or demand, disrupting the market price as you can just buy things at excess all the time. What you are saying is that it will eventually normalize? I'm fairly new to the game and i'm not fully familiar with the innards of the economy system yet, so sorry if I'm making nonsensical assumptions.

 Anyway, thank you for the answer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 15, 2019, 11:02:40 AM
Alright, so i forgot to mention that i also reduced the stockpile consumption rate when there is a demand as well.

That only matters for colonies with "use local stockpiles to counter unmet demand" set, so, pretty much player colonies plus Galatia during the tutorial, iirc.


I don't think messing with the rate at which stockpiles refill would break anything. If you change the maximum stockpiles, though, I think that would affect prices.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 15, 2019, 11:38:58 AM
 That's all i needed to know. Thank you for clearing things up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 16, 2019, 01:02:55 AM
I have a question abut Ground Support Package. How does it work beneath the hood?

Does the number of ships with it matter? Does it only work on troop transports or would any ship equip with it give a bonus? Does it scale?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 16, 2019, 01:21:33 AM
So i did manage to get the economy to start stabilized but the problem with the discrepancy between the stockpile in a colony and its supply and demand still persists. Now i reduced the rate the stockpile is removed in addAndRemoveStockpiledResources to compensate for the reduced add rate. I set both to be 10x slower to more easily observe the changes.

To illustrate the problem, a colony needs 4000 fuel so i sell them the amount and fulfill that demand. The demand is at zero, and after a month it goes back up to 4000. The actual stockpile only decreased by 400. The same goes for the supply, it gets reset a month after i had bought it all, while the stockpile only gets 1/10 of the amount, as per the change to the add rate. This means i can always buy stuff from colonies with excess for a reduced price and sell for a higher price to colonies with deficit. The stockpile will never catch up unless i allow it to.

Is it possible to make the two things somehow tick in tandem without meddling with the code too much?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 16, 2019, 10:25:25 AM
I have a question abut Ground Support Package. How does it work beneath the hood?

Does the number of ships with it matter? Does it only work on troop transports or would any ship equip with it give a bonus? Does it scale?

Take a look at:

com.fs.starfarer.api.combat.BaseHullMod.GroundSupport

And anywhere that uses Stats.FLEET_GROUND_SUPPORT, if you need more detail.


So i did manage to get the economy to start stabilized but the problem with the discrepancy between the stockpile in a colony and its supply and demand still persists. Now i reduced the rate the stockpile is removed in addAndRemoveStockpiledResources to compensate for the reduced add rate. I set both to be 10x slower to more easily observe the changes.

To illustrate the problem, a colony needs 4000 fuel so i sell them the amount and fulfill that demand. The demand is at zero, and after a month it goes back up to 4000. The actual stockpile only decreased by 400. The same goes for the supply, it gets reset a month after i had bought it all, while the stockpile only gets 1/10 of the amount, as per the change to the add rate. This means i can always buy stuff from colonies with excess for a reduced price and sell for a higher price to colonies with deficit. The stockpile will never catch up unless i allow it to.

Is it possible to make the two things somehow tick in tandem without meddling with the code too much?

With the caveat that syncing everything up will probably be tricky, the thing you might want to do is change

BaseSubmarketPlugin.TRADE_IMPACT_DAYS to something other than 30. That determines how long the player buying/selling things influences the colony's supply/demand for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alec on August 17, 2019, 12:26:58 AM
Is there anyway to modify the class SectorProcGen? In particular the generate() method?
I want more stars and a less random and more evenly distributed map.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nawj on August 17, 2019, 01:09:12 AM
Out of these highlighted mods, which do you think would be most likely to cause a memory leak? Saves got progressively slower all day up until the point they started freezing the game. Now even though they don't totally freeze the game, I'm given an error code and the game won't save outright
(https://files.catbox.moe/qvstgw.png)
The reason I say the highlighted mods is the ones not highlighted weren't active when the error took place.
I understand that this is a very broad question but I'm looking for any help I can get as I now have to throw away my first successful run at Starsector which I'd been playing all day since I'd gotten off of work. Having to troubleshoot this via process of elimination would take me two weeks because I'd have to turn off a mod and play for ten hours straight to see if the game freezes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Neuromute on August 17, 2019, 01:59:24 AM
Is this the right place to ask for help with making a mod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vagrant on August 17, 2019, 06:45:22 AM
So I'm working on a total conversion that currently is only scoped to include missions. I would like to replace weapon_data.csv so that vanilla weapons don't show up in the refit screen. I was able to replace a handful of other files already without issue, but there seems to be somewhere still trying to load vanilla data and causing a crash during initial startup.

I've replaced:
mission_list.csv, title_screen_variants.csv, sim_opponents.csv, which i thought would be the only places that potentially load ship/variant/weapon data initially (ie before starting campaign generation), but i'm still getting a crash relating to a missing variants.

Am i being naive here? Is the vanilla data more ingrained than i realize or am I missing an obvious place (or option). Any input appreciated.


Edit: my hypothesis currently is that the code responsible for pause screen variants is responsible but i'm not sure where exactly that is... hoping it's not obvious!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 17, 2019, 09:11:16 AM
Is there anyway to modify the class SectorProcGen? In particular the generate() method?
I want more stars and a less random and more evenly distributed map.

Yes, you need to provide an alternate version of it and point to it from your mods' settings.json - see vanilla settings.json and its "plugins" section.

Out of these highlighted mods, which do you think would be most likely to cause a memory leak?

Hi - you might have better luck posting this in the modded support board, here (http://fractalsoftworks.com/forum/index.php?board=14.0), I think it'll be more likely to be seen by someone that might know.


Is this the right place to ask for help with making a mod?

I guess it depends - if it's a quick-ish question (i.e. not "how do I make a mod"), then yeah. Otherwise, a new thread is probably a better place.


So I'm working on a total conversion that currently is only scoped to include missions. I would like to replace weapon_data.csv so that vanilla weapons don't show up in the refit screen. I was able to replace a handful of other files already without issue, but there seems to be somewhere still trying to load vanilla data and causing a crash during initial startup.

I've replaced:
mission_list.csv, title_screen_variants.csv, sim_opponents.csv, which i thought would be the only places that potentially load ship/variant/weapon data initially (ie before starting campaign generation), but i'm still getting a crash relating to a missing variants.

Am i being naive here? Is the vanilla data more ingrained than i realize or am I missing an obvious place (or option). Any input appreciated.


Edit: my hypothesis currently is that the code responsible for pause screen variants is responsible but i'm not sure where exactly that is... hoping it's not obvious!

I'm not actually 100% sure, depends on the error you're getting. You could also add the SYSTEM hint to weapons etc to make them not show up in the refit screen, that seems like it'll be easier than to try to rip them completely out of the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vagrant on August 17, 2019, 09:36:29 AM
I'm not actually 100% sure, depends on the error you're getting. You could also add the SYSTEM hint to weapons etc to make them not show up in the refit screen, that seems like it'll be easier than to try to rip them completely out of the game.

That's a good idea! I'll try it.

On a similar line of thinking, are parts of the main menu easily accessible if I wanted to disable/remove them? As mentioned, i'm only using 'missions' so ideally i'd want to get rid of 'continue', 'new game' 'load game', or at least keep the player from accessing them. If not, i can live with it!

Thanks for all the help so far!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 17, 2019, 09:50:24 AM
The main menu is not modable like that, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 17, 2019, 08:39:36 PM
If a Beam weapon has more than 1 barrel, is the CSV's listed damage split between the number of Beams, or does each Beam do the stated damage?  What about Flux cost?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 17, 2019, 09:21:35 PM
IIRC both are totals for all the barrels combined.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on August 17, 2019, 10:41:46 PM
When working with generating fleets using FleetFactoryV3, how are combat points spent? Like does a battleship cost it's fleet points or is it a set cost for each ship class, like a Capital Ship costs 8 or something?

Also if I wanted to modify every fleet being created by the game, would I do it my adding something at the end of createFleet(), like adding a buff or just adding modifiers to mutableshipstatsapi for each member of the newly generated fleet? (Never mind, this did in fact work)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 18, 2019, 08:15:53 AM
When working with generating fleets using FleetFactoryV3, how are combat points spent? Like does a battleship cost it's fleet points or is it a set cost for each ship class, like a Capital Ship costs 8 or something?

It uses fleet points, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on August 18, 2019, 01:03:31 PM
anyone know where is value for a pay for  exploration(scan derelict) missions? I mean for a reward
i want to lower it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 18, 2019, 01:12:14 PM
Hardcoded in the intel, I'm afraid. So: moddable, but not easily, as you'd have to replace the code that generates that intel.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kelaris on August 18, 2019, 11:37:22 PM
Where would I start looking if I wanted to change the quantity/variety of different weapons, fighters, and ships available at markets?

I've been poking at things in com.fs.starfarer.api.impl.campaign.submarkets (BaseSubmarketplugin, BlackMarketPlugin, MilitarySubmarketPlugin, and OpenMarketPlugin) without successfully changing anything, as far as I can tell. I'm not sure if I'm digging in the wrong place, or if I've made some mistake in packaging my mod. First time messing with Starsector modding and I'm a complete novice with java, so any mishap is possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on August 19, 2019, 06:56:10 AM
Hardcoded in the intel, I'm afraid.

Why Alex? Whyyyyy?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2019, 08:30:38 AM
Where would I start looking if I wanted to change the quantity/variety of different weapons, fighters, and ships available at markets?

I've been poking at things in com.fs.starfarer.api.impl.campaign.submarkets (BaseSubmarketplugin, BlackMarketPlugin, MilitarySubmarketPlugin, and OpenMarketPlugin) without successfully changing anything, as far as I can tell. I'm not sure if I'm digging in the wrong place, or if I've made some mistake in packaging my mod. First time messing with Starsector modding and I'm a complete novice with java, so any mishap is possible.

That's where you'd mess with it, yeah. I'd suggest trying to do something drastic (such as say always clearing the cargo in the updateBeforePlayerInteraction method) just to make sure your code is running and actually doing *something*. Or printing stuff or running with a debugger etc...

Why Alex? Whyyyyy?

:(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 19, 2019, 03:21:53 PM
Soooo... what controls Travel Drive, exactly?

I changed it a bit, and the results were... odd.  What I want:  setting Retreat activates the Travel Drive after X seconds of being unable to accelerate / decelerate.  Then the ships get to zip off the battlefield.  That... kind of works.  But somewhere along the way, I broke the Travel-Drive-Onto-Battlefield.

Seems that it expects to be a toggled System and it's turned on at the start of play... but it's not clear at all where the toggles are controlled from.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2019, 03:26:20 PM
It's toggled from core code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 19, 2019, 03:47:23 PM
Okie doke; I'll try and work around that then :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nights on August 19, 2019, 10:57:23 PM
Is it possible to change the reputation gains from mission?
Been trying to find out for quite a bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 20, 2019, 03:16:59 AM
Question I haven't been able to figure out.

So I have code for creating fleets and assigments, the problem is actually triggering that code. Since I don't need that during sectorgen, like most mods that add remnant-like enemies do, but rather periodically.

Basically, every 30-60 days check to see if the number of fleets with tag "X" is less than Y, and if it is, spawn more fleets. There can also be other checks (for example, number of alien motherships still active limits the amount of fleets to spawn), but those are easy to add.

how do I make that periodical check? From where do I call it?

Can I use CoreCampaignPluginImpl.onNewGameAfterTimePass()  .. or maybe  EveryFrameScript?
What the most efficient way to do it?

I'm a Java scrub and I'm cobbling together code from studying what other mods did, but none actually covers the specific case I'm considering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 20, 2019, 07:25:08 AM
Is it possible to change the reputation gains from mission?
Been trying to find out for quite a bit.

Not very easily - you'd have to change the code for that mission and then change the intel creator for that mission to create your version of the mission instead of the vanilla one. This probably means setting up an IDE and digging into the game's internals a fair bit.

Question I haven't been able to figure out.

So I have code for creating fleets and assigments, the problem is actually triggering that code. Since I don't need that during sectorgen, like most mods that add remnant-like enemies do, but rather periodically.

Basically, every 30-60 days check to see if the number of fleets with tag "X" is less than Y, and if it is, spawn more fleets. There can also be other checks (for example, number of alien motherships still active limits the amount of fleets to spawn), but those are easy to add.

how do I make that periodical check? From where do I call it?

Can I use CoreCampaignPluginImpl.onNewGameAfterTimePass()  .. or maybe  EveryFrameScript?
What the most efficient way to do it?

I'm a Java scrub and I'm cobbling together code from studying what other mods did, but none actually covers the specific case I'm considering.

An EveryFrameScript with an IntervalUtil to keep track of the interval seems like the way to go here. Probably use Global.getSector().addScript() to add it.

See: MilitaryBase.advance() for an example using IntervalUtil (the tracker variable). It's not an EveryFrameScript, but that portion of the code is the same.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nights on August 20, 2019, 08:35:30 AM
Is it possible to change the reputation gains from mission?
Been trying to find out for quite a bit.

Not very easily - you'd have to change the code for that mission and then change the intel creator for that mission to create your version of the mission instead of the vanilla one. This probably means setting up an IDE and digging into the game's internals a fair bit.



Thanks for the reply! Was hoping is was an easy change cause the reward was always +5 rep!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 20, 2019, 05:38:21 PM
I copied the Mining industry, but my industry doesn't produce any ore/etc. Everything else works as expected. Am I just going to have to define all the supply of ore/etc. myself?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 20, 2019, 05:48:26 PM
Yeah, I think so. Looking at the ResourceDepositsCondition code, it's not really set up to handle multiple industries producing resources from the same kinds of deposits. In fact, it's even got a hack in it to support Aquaculture working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on August 21, 2019, 12:11:27 AM
Is any of the base AI accessible or is the only way to modify AI to write new code and use ShipAIPlugin.Advance() ?  There's some simple tweaks I'd like to make.

If it's all done through Advance() , how would I go about finding the core methods of ship controls and such to write a new AI, and how would I overwrite parts of the base AI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 21, 2019, 02:34:38 PM
Well, I tried to implement ore production, but something has gone wrong. I have the code below in my apply() method. The top log call reports that the market does in fact have ore_moderate and the bottom log call reports oreSupply has a value of 1, as expected, but the industry produces no ore.

Spoiler
Code: java
        int oreSupply = 0;
        int rareSupply = 0;
        int volatilesSupply = 0;
        int organicsSupply = 0;

        org.apache.log4j.Logger logger = Global.getLogger(Roider_Dives.class);

        for (MarketConditionAPI c : market.getConditions()) {
            logger.info("asddssd" + c.getId());

            switch (c.getId()) {
                case (Conditions.ORE_ULTRARICH): oreSupply++;
                case (Conditions.ORE_RICH): oreSupply++;
                case (Conditions.ORE_ABUNDANT): oreSupply++;
                case (Conditions.ORE_MODERATE): oreSupply++;
                case (Conditions.ORE_SPARSE): break;

                case (Conditions.ORGANICS_PLENTIFUL): organicsSupply++;
                case (Conditions.ORGANICS_ABUNDANT): organicsSupply++;
                case (Conditions.ORGANICS_COMMON): organicsSupply++;
                case (Conditions.ORGANICS_TRACE): break;


                // Reduced supply for rare ores and volatiles
                case (Conditions.RARE_ORE_ULTRARICH): rareSupply++;
                case (Conditions.RARE_ORE_RICH): rareSupply++;
                case (Conditions.RARE_ORE_ABUNDANT): break;
                case (Conditions.RARE_ORE_MODERATE): break;
                case (Conditions.RARE_ORE_SPARSE): break;

                case (Conditions.VOLATILES_PLENTIFUL): volatilesSupply++;
                case (Conditions.VOLATILES_ABUNDANT): break;
                case (Conditions.VOLATILES_DIFFUSE): break;
                case (Conditions.VOLATILES_TRACE): break;
            }
        }

        logger.info("asddssd ore " + oreSupply);
        logger.info("asddssd " + rareSupply);
        logger.info("asddssd " + volatilesSupply);
        logger.info("asddssd " + organicsSupply);

        supply(Commodities.ORE, oreSupply);
        supply(Commodities.RARE_ORE, rareSupply);
        supply(Commodities.VOLATILES, volatilesSupply);
        supply(Commodities.ORGANICS, organicsSupply);
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2019, 02:44:54 PM
Is any of the base AI accessible or is the only way to modify AI to write new code and use ShipAIPlugin.Advance() ?  There's some simple tweaks I'd like to make.

If it's all done through Advance() , how would I go about finding the core methods of ship controls and such to write a new AI, and how would I overwrite parts of the base AI?

It's not accessible, no. It's a tangled ball of core code that would be way too much of a project to try to extract into mod-land, unfortunately.

So it's an all-or-nothing deal, with the exception of ship systems, which have modular AIs.

For controlling ships: see ShipAPI.giveCommand().

Well, I tried to implement ore production, but something has gone wrong. I have the code below in my apply() method. The top log call reports that the market does in fact have ore_moderate and the bottom log call reports oreSupply has a value of 1, as expected, but the industry produces no ore.

I'd suggest calling the supply() method that has a String id as the first parameter. Probably something else is supplying 0 units with the default ID that the supply() method you're calling uses, and that overrides whatever you're doing. Not 100% sure, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 21, 2019, 02:59:47 PM
That works, thanks! Though, now I have to code descriptions *shakes fist*
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 21, 2019, 09:38:15 PM
So, maybe a dumb question, but... I don't understand EventPlugins.

I've created a copy of part of the NearbyEventPlugin thingy. How do I go about adding it to the EventManager? I only see options to start or prime an event, but I just want to add it on a new game so it stays there and spawns distress calls.  ???

EDIT: Actually, what are the advantages of using an EventPlugin over an EveryFrameScript? It looks like the NearbyEventPlugin distress call bit in particular tracks its own timeout, etc, in an IntervalUtil and the advance() method, just like it would as an EveryFrameScript, so...

EDIT EDIT: While I'm here and asking questions: How would I go about getting the actual ShipAPI/FleetMemberAPI created as a CustomCampaignEntityAPI derelict? I need to add a custom hullmod to it, no matter what hull it is - so i can't just use a custom variant/hull that always has it - is my goal here. I have a sinking feeling it's not actually created until the player interacts with it, but I'm sure there's a way around that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hoon on August 22, 2019, 10:42:35 AM
How does one use applyEffectsToFighterSpawnedByShip with xxxx.getMutableStats? I spent the entire day yesterday trying to make a simple hullmod that adds 25% more armor to fighters but no matter what I try it seems like I just can't seem to understand how anything works with applyEffectsToFighterSpawnedByShip
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 22, 2019, 01:18:46 PM
@Varya: I'm afraid I don't have much experience with all that. I might get the chance to look into it later though.

@MrHoon:
That should be as simple as this:
Code
    @Override
    public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
        fighter.getMutableStats().getArmorBonus().modifyPercent(id, 25);
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 22, 2019, 01:36:42 PM
So, maybe a dumb question, but... I don't understand EventPlugins.

I've created a copy of part of the NearbyEventPlugin thingy. How do I go about adding it to the EventManager? I only see options to start or prime an event, but I just want to add it on a new game so it stays there and spawns distress calls.  ???

EDIT: Actually, what are the advantages of using an EventPlugin over an EveryFrameScript? It looks like the NearbyEventPlugin distress call bit in particular tracks its own timeout, etc, in an IntervalUtil and the advance() method, just like it would as an EveryFrameScript, so...

Yeah, just use an EFS - the NearbyEventsEvent is an event only for historical reasons. It used to be required/handy to send out reports, but since the intel system is completely different, "Events" have lost their purpose, code-wise.

EDIT EDIT: While I'm here and asking questions: How would I go about getting the actual ShipAPI/FleetMemberAPI created as a CustomCampaignEntityAPI derelict? I need to add a custom hullmod to it, no matter what hull it is - so i can't just use a custom variant/hull that always has it - is my goal here. I have a sinking feeling it's not actually created until the player interacts with it, but I'm sure there's a way around that.

DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
plugin.getData().ship <- this is a com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.ShipRecoverySpecial. PerShipData

It could be based on a variantId (i.e. ship.variantId != null), or it may be based on a variant (i.e. ship.variant != null). If there's a variant, you can change it however you like.

If it's based on a variantId, you'll need to set the variant first (to... whatever variant you want, really), but that should also work.


@Varya: I'm afraid I don't have much experience with all that. I might get the chance to look into it later though.

(Thank you for helping out here, btw! Much appreciated.)


@MrHoon:
That should be as simple as this:
Code
    @Override
    public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
        fighter.getMutableStats().getArmorBonus().modifyPercent(id, 25);
    }

Possibly worth noting: the hullmod needs to be on the carrier, *not* on the fighter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hoon on August 22, 2019, 02:04:21 PM
Thank you guys so much! I didnt realize it had to be fighter.getMutableStats() and I kept doing ship.getMutableStats()

edit

So i tried this and I'm not sure its working?

This is the part of the code I'm working with
Code
public class hhe_FighterPlating extends BaseHullMod {
///
public static final float FIGHTER_ARMOR = 25f;
///
    @Override
public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
fighter.getMutableStats().getArmorBonus().modifyPercent(id, FIGHTER_ARMOR);
}
}


For testing purpose, I changed the FIGHTER_ARMOR = 25f to 5000f , but my fighters are still dying at the same speed as if they didn't have this hull.

Ive been testing this in both run simulation inside a fresh save and the benchmark tester, same results. Is there something else I need to add into the code? (aside from the string)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 22, 2019, 02:55:44 PM
It could be based on a variantId (i.e. ship.variantId != null), or it may be based on a variant (i.e. ship.variant != null). If there's a variant, you can change it however you like.

If it's based on a variantId, you'll need to set the variant first (to... whatever variant you want, really), but that should also work.

Thanks so much! I think I can puzzle it out from here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 22, 2019, 03:50:48 PM
Ive been testing this in both run simulation inside a fresh save and the benchmark tester, same results. Is there something else I need to add into the code? (aside from the string)
Is that all of the code? If so, it looks like you're missing your package and import lines. It's not strictly necessary, but you'll want to override getDescriptionParam as well. If that's not the problem... Is the hullmod showing up on the carrier? What's your hull_mods.csv look like? Are you sure it points to hhe_FighterPlating correctly?

(Thank you for helping out here, btw! Much appreciated.)
No problem! I figure trying to help with the easier problems in this thread is a way to help compensate for the time you've spent answering all my questions  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 22, 2019, 04:26:59 PM
No problem! I figure trying to help with the easier problems in this thread is a way to help compensate for the time you've spent answering all my questions  :)

;D <3
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 22, 2019, 04:32:51 PM
Quick followup question!

Code: java
            DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
            PerShipData shipData = plugin.getData().ship;
            this.variant = shipData.variant;
            if (this.variant == null) {
                this.variant = Global.getSettings().getVariant(shipData.variantId);
            }
            this.variant = this.variant.clone(); // THIS LINE RIGHT HERE
           
            this.variant.addPermaMod("vayra_ghost_ship");

Is this .clone() line necessary to avoid messing up all hound_Assaults across the sector, or does Global.getSettings().getVariant(shipData.variantId) return a unique instance that I can mess with as much as I want?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 22, 2019, 04:35:49 PM
Is this .clone() line necessary to avoid messing up all hound_Assaults across the sector,

Correct!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hoon on August 22, 2019, 06:25:40 PM
Ive been testing this in both run simulation inside a fresh save and the benchmark tester, same results. Is there something else I need to add into the code? (aside from the string)
Is that all of the code? If so, it looks like you're missing your package and import lines. It's not strictly necessary, but you'll want to override getDescriptionParam as well. If that's not the problem... Is the hullmod showing up on the carrier? What's your hull_mods.csv look like? Are you sure it points to hhe_FighterPlating correctly?

(Thank you for helping out here, btw! Much appreciated.)
No problem! I figure trying to help with the easier problems in this thread is a way to help compensate for the time you've spent answering all my questions  :)

forgot about the import codes whoops

Code
package data.hullmods.scripts;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

I didn't bother doing the description part yet because I wanted to see the mod actually working.

Normally if i messup in the import, I get an error message when i start the mod. Is it possible Im importing the wrong things?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 22, 2019, 10:10:35 PM
Whoops, got one more.

Code: java
            DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
            PerShipData shipData = plugin.getData().ship;
            this.variant = shipData.variant;
            if (this.variant == null) {
                this.variant = Global.getSettings().getVariant(shipData.variantId);
            }
            shipData.variantId = null;
            this.variant = this.variant.clone();
So this creates a ShipVariantAPI. All good so far. Note the shipData.variantId = null; because it looks like ShipRecoverySpecial prefers variantId over variant, heh.

This, in ShipRecoverySpecial
Code: java
		FleetMemberAPI member = null;
if (shipData.variantId != null) {
member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, shipData.variantId);
} else {
member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, shipData.variant);
}
creates a FleetMemberAPI, and sets its variant to that ShipVariantAPI as long as it doesn't have a .variantId. Am I right in assuming the ShipVariantAPI we created with .clone() above is the same instance as this new FleetMemberAPI will have, and will be unique to that FleetMemberAPI since it's a clone created in the process of generating it, and I can therefore store data in the hullmod with the ShipVariantAPI as a key? Or does .createFleetMember() clone the variant again?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 22, 2019, 11:06:01 PM
Is it possible Im importing the wrong things?
It looks to me like you've got all your bases covered as far as imports are concerned. My guess at this point is that there's something wrong with your hull_mods.csv file. If you want to zip up your mod and send it to me I'd be happy to take a look.

@Varya: This stretches the limits of my knowledge a bit (hopefully Alex will correct me if I'm wrong), but...
Looking through decompiled code of createFleetMember, I see that it assigns the instance of the variant you pass it, so it looks to me like it should be the same key. Of course, it's always possible that it's changed later. If you want to make sure, you should be able to check for instance equality like this:
Code
if(if(member.getVariant() == shipData.variant)) {
    // Notify you somehow
}
clone() creates a new instance, which is the method of comparison used by HashMaps for objects that don't override equals() and hashCode(), so each clone should work as a unique key, even if they all have the same values.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bowman on August 23, 2019, 12:31:15 AM
So, I did a search but.. not much came up. Hopefully I didn't just miss a post entirely.

Is there a way to check if a ship is phased? This is a built-in hullmod so it isn't an issue between "does the ship have phase or shield", instead it's simply "is it currently using its phase cloak". Without this if-statement the rest of the code seems to work fine but, with it, it doesn't activate even when phased. Are phase systems not considered shields for the ShieldAPI and thus returning null? Is there a different API I should be using? Maybe I'm just using the API wrong?(I really don't know java so it's probably the case)
I saw a phasecloakstats but that seemed like it was the phase jump ship system or something else.

Code
public void advanceInCombat (ShipAPI ship, float amount) {
ShieldAPI cloak = ship.getShield();

if (cloak != null && cloak.isOn()) {

//lines im ommitting because they're otherwise functional and it would just take up forumspace
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 23, 2019, 01:01:14 AM
Are phase systems not considered shields for the ShieldAPI and thus returning null?
You guessed it.
Code
ship.getPhaseCloak().isActive()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bowman on August 23, 2019, 01:23:00 AM
@Sundog that did it, thank you :)

now I just need to sprite a new ship for it..
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 23, 2019, 01:40:26 AM
No problem! I look forward to seeing what you come up with  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 23, 2019, 02:49:56 AM
How does economyIntervalnGameDays affect patrols? I noticed that it may have something to do with battles lost.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on August 23, 2019, 06:25:51 AM
How are buffs to fighters handled? Right now I'm giving a combat buff to all ships within a fleet using .getFleetData().getMembersListCopy(), which is working for the ships but not the fighters. I've looked at the fighter-specific skills, which led me to the skill effect type but no reference as to how it's affecting fighters.

Also where are derelict ships created after combat (the ones floating through space), and where is ship recovery handled?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hoon on August 23, 2019, 08:33:20 AM
Is it possible Im importing the wrong things?
It looks to me like you've got all your bases covered as far as imports are concerned. My guess at this point is that there's something wrong with your hull_mods.csv file. If you want to zip up your mod and send it to me I'd be happy to take a look.

@Varya: This stretches the limits of my knowledge a bit (hopefully Alex will correct me if I'm wrong), but...
Looking through decompiled code of createFleetMember, I see that it assigns the instance of the variant you pass it, so it looks to me like it should be the same key. Of course, it's always possible that it's changed later. If you want to make sure, you should be able to check for instance equality like this:
Code
if(if(member.getVariant() == shipData.variant)) {
    // Notify you somehow
}
clone() creates a new instance, which is the method of comparison used by HashMaps for objects that don't override equals() and hashCode(), so each clone should work as a unique key, even if they all have the same values.

sure thing, here is the file. I've tried everything and at this point its just a simple mistake i missed

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zer0 on August 23, 2019, 08:38:56 AM
Hello!

Recently I have been working on a mod that adds an Industry which effects kick in after a cycle. For that, I made two separate buildings:

When I went to test it, I noticed the left-click (or right-click, I forgot) menu wasn't really what I wanted. For example, when it reaches (2) it says "downgrade to (1)..." but I wish for it to say something else. I had gone digging and haven't found anything regarding said menu or its options. Also, I wanted to have the option "cancel downgrade" added when going from (2) to (1) (or after the upgrade to (2) is cancelled) but I had similar luck and have found nothing that I could use.

My question is how would it be possible (if at all) to rename a context menu option (right/left click menu on a Building), or even perhaps remove, change behaviour or add a new option.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 23, 2019, 09:54:52 AM
... and I can therefore store data in the hullmod with the ShipVariantAPI as a key

There's only one instance of each HullModEffect *per application session*, and it doesn't go into the savefile, at any rate. I'd say as a general rule, just don't do it period. E.G. if the variant - or whatever data you store keyed off it - references the Sector somewhere down the line, bam, that's a Sector-sized memory leak when you load a game.

If you need to store stuff long-term, use Global.getSector().getMemory() or Global.getSector().getPersistentData(). It's about the same, really, as far as which to use; persistentData is just a straightforward map.


How does economyIntervalnGameDays affect patrols? I noticed that it may have something to do with battles lost.

It used to affect their spawn rate but doesn't anymore. See: averagePatrolSpawnInterval

(You might be looking at some older PatrolFleetManager* classes which are no longer used...)


How are buffs to fighters handled? Right now I'm giving a combat buff to all ships within a fleet using .getFleetData().getMembersListCopy(), which is working for the ships but not the fighters. I've looked at the fighter-specific skills, which led me to the skill effect type but no reference as to how it's affecting fighters.

Fighters don't exist in the campaign in the same way that ships do, so if you're going to buff them, it needs to happen in combat. Probably better to do this for ships, too - what you're doing might be alright, but it's just easier to do something with long-term effects if it's not managed properly. (See: BuffManagerAPI, TempBuff etc...)

For example, using .getFleetData().getMembersListCopy() would only work if you're using that to apply Buffs, not modify stats directly. If you're already doing that, though, and it expires (or doesn't) in the way that you want, you're probably fine.

Also where are derelict ships created after combat (the ones floating through space), and where is ship recovery handled?

See: CoreScript.generateOrAddToDebrisFieldFromBattle()

Also see: ShipRecoverySpecial and SalvageSpecialInteraction


Hello!

Hi!

My question is how would it be possible (if at all) to rename a context menu option (right/left click menu on a Building), or even perhaps remove, change behaviour or add a new option.

Ahh, these really aren't configurable, the upgrading/downgrading works along a pretty set pattern. You might be able to do something with the 2nd building being "upgradeable" to the first, though - then it'd take time to "downgrade" (via an upgrade) so it'd probably be closer to what you want.

But "it takes time to shut down", I can't see how to make work, offhand. Just in general, that menu isn't very configurable, aside from being able to take custom special items.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zer0 on August 23, 2019, 10:36:37 AM
My question is how would it be possible (if at all) to rename a context menu option (right/left click menu on a Building), or even perhaps remove, change behaviour or add a new option.

Ahh, these really aren't configurable, the upgrading/downgrading works along a pretty set pattern. You might be able to do something with the 2nd building being "upgradeable" to the first, though - then it'd take time to "downgrade" (via an upgrade) so it'd probably be closer to what you want.

But "it takes time to shut down", I can't see how to make work, offhand. Just in general, that menu isn't very configurable, aside from being able to take custom special items.

Dang, no luck with the menu.
Fortunately, I did manage to do what I wanted to do with the delayed shutdown/effects in a kinda hacky way, but if it works it works!

Anyway, thank you  ;D!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 23, 2019, 10:53:11 AM
Stupid question that I know was already answered, but I cannot find it in the thread.

For burst weapon, damage per shot = total damage of the burst?
So a 3 round burst weapon with 300 daamge_per_shot means 100 damage per shot in reality?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 23, 2019, 10:53:55 AM
It used to affect their spawn rate but doesn't anymore. See: averagePatrolSpawnInterval

(You might be looking at some older PatrolFleetManager* classes which are no longer used...)

I see, thank you. One more thing. I know that sound is muted when you can't see the source. I increased zoom distance a bit and when i pan the camera a bit off the center of my ship, due to long range weapons, there is no sound despite the source being in the frame (closer to the edges but still).

Really a minor thing, but i'm wondering if there is a way to adjust it. Did take a glance at the code but figured i might just ask, since i understand that not everything is moddable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 23, 2019, 11:04:05 AM
Stupid question that I know was already answered, but I cannot find it in the thread.

For burst weapon, damage per shot = total damage of the burst?
So a 3 round burst weapon with 300 daamge_per_shot means 100 damage per shot in reality?

Per shot is per shot, not per burst. (Edit: to be 100% clear, in your example, it'd be 900 damage per burst.)

(The only sort-of-exception here is multi-barreled beams where the damage per second is the total for all barrels.)


I see, thank you. One more thing. I know that sound is muted when you can't see the source. I increased zoom distance a bit and when i pan the camera a bit off the center of my ship, due to long range weapons, there is no sound despite the source being in the frame (closer to the edges but still).

Really a minor thing, but i'm wondering if there is a way to adjust it. Did take a glance at the code but figured i might just ask, since i understand that not everything is moddable.

Right, yeah, that's another thing that's not moddable - sound playback is based on the distance of the sound from the center of your view, and if it's too far (based on a hardcoded value), it just doesn't play at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 23, 2019, 11:17:30 AM
Right, yeah, that's another thing that's not moddable - sound playback is based on the distance of the sound from the center of your view, and if it's too far (based on a hardcoded value), it just doesn't play at all.

Okay. So i guess one way to compensate would be to reduce the max zoom and free the camera pan a bit. Would that be moddable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on August 23, 2019, 11:25:08 AM
So then I should make sure - what is the buff timer counting? game updates/frames, game months, or something else? I have my buffs set to an exorbitant number so they hopefully never expire.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 23, 2019, 11:57:16 AM
Right, yeah, that's another thing that's not moddable - sound playback is based on the distance of the sound from the center of your view, and if it's too far (based on a hardcoded value), it just doesn't play at all.

Okay. So i guess one way to compensate would be to reduce the max zoom and free the camera pan a bit. Would that be moddable?

Yeah, mods have extensive viewport control, see: ViewportAPI, CombatEngineAPI.getViewport(), etc. Will take a bunch of code and thought, though, I wouldn't call creating something here that works well and feels good to use "easy".


So then I should make sure - what is the buff timer counting? game updates/frames, game months, or something else? I have my buffs set to an exorbitant number so they hopefully never expire.

That ought to be fine, probably. As long as you're not accidentally applying them multiple times with different ids, that sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 23, 2019, 12:37:47 PM
Alright. Like i said, it's small matter. Thanks for the answers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Imp0815 on August 23, 2019, 04:01:01 PM
Hi everybody,

i playing with the idea to implement a new Building. A Dockyard. On paper it sounds simple.
You build it and it Repairs(Removes) one D-Mod from a Ship every X(30?) Days. Also it halves the Supply cost of repairing your ships on the planet.
A more elaborate approach would be to open a menu to select a ship to repair. But this seems not possible with my knowledge.
An easy approach would be to just let a script select a random ship from my Storage.
So i would go with the second approach.

As i understood so far, i need to add a new building in the industries.csv and add the script in the "plugin" part like data/scrips/mydockyard. Is that correct? Or do i really need to build a plugin?

If i need to build a plugin, i already searched the API and found some stuff like the StoragePlugin.java but no sight of getting or selecting a occupied slot in the storage and all the buildings under com\fs\starfarer\api\impl\campaign\econ\impl but i did not find any interactions between the industries and the storage. But there should be a function that handles the "Use Storage on Shorated" button.

I'm not very good in java that maybe a(the) problem.

Can somebody please point me in the right direction for my endeavours?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 23, 2019, 04:50:01 PM
... and I can therefore store data in the hullmod with the ShipVariantAPI as a key

There's only one instance of each HullModEffect *per application session*, and it doesn't go into the savefile, at any rate. I'd say as a general rule, just don't do it period. E.G. if the variant - or whatever data you store keyed off it - references the Sector somewhere down the line, bam, that's a Sector-sized memory leak when you load a game.

If you need to store stuff long-term, use Global.getSector().getMemory() or Global.getSector().getPersistentData(). It's about the same, really, as far as which to use; persistentData is just a straightforward map.

Oop. Good tip. I would want the info to persist through saves anyway, so that's double bad. But if I can store data in the memory or persistentData and key it off the ShipVariantAPI then we're all good. :)

E: On that topic, actually: What is the most persistent ship-related object to tie a dynamic campaign-level thingy that needs to be stored to? Will its ShipVariantAPI ever be changed, should I tie it to the FleetMemberAPI, etc?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 23, 2019, 05:32:40 PM
sure thing, here is the file. I've tried everything and at this point its just a simple mistake i missed
Actually, I don't think you missed anything. I got your hullmod to work by using getArmorDamageTakenMult instead of getArmorBonus or getHullBonus (both of which should work afaik).

@Alex: This might be something you want to look into. I may have missed something, but it looks like hull bonus, armor bonus, and presumably other mutable stats are never actual applied to fighters. My theory is that, for fighters, you removed the application of any mutable stats not used by vanilla as an optimization. If that's the case, perhaps there should be a MutableFighterStats interface that only exposes the limited functionality.

@Imp0815: You might want to take a look at how buildings are added by this recent WIP mod (http://fractalsoftworks.com/forum/index.php?topic=16155.0), which is the only one I'm aware of that does such a thing. I can't speak to it's quality, but it should give you a good idea of how that kind of thing is put together.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 23, 2019, 06:12:06 PM
E: On that topic, actually: What is the most persistent ship-related object to tie a dynamic campaign-level thingy that needs to be stored to? Will its ShipVariantAPI ever be changed, should I tie it to the FleetMemberAPI, etc?

Probably FleetMemberAPI.getId(), if you can get access to it in all the relevant places.


@Alex: This might be something you want to look into. I may have missed something, but it looks like hull bonus, armor bonus, and presumably other mutable stats are never actual applied to fighters. My theory is that, for fighters, you removed the application of any mutable stats not used by vanilla as an optimization. If that's the case, perhaps there should be a MutableFighterStats interface that only exposes the limited functionality.

Aha - what happens here is the applyEffectsToFighterSpawnedByShip() method is called after the fighter is created (hence, the ShipAPI fighter being passed in). This means that stats that are fixed at creation time - notably, armor and hull - are already set at that point. So, if one wants to modify the fighter's armor, the way to do that would be to change the damage taken by armor instead of changing the armor value. Sorry I didn't catch this earlier!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 23, 2019, 08:47:06 PM
Oh, ok. That makes sense. It's a very understandable oversight considering applyEffectsToFighterSpawnedByShip() isn't even used by vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 23, 2019, 08:54:22 PM
(It's actually used by DefectiveManufactory, but iirc that's the only vanilla use case!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 23, 2019, 09:09:19 PM
Currently giving a market the NO_DECIV_KEY memory flag also makes it not die from saturation bombardment when size <= 4 (even though the dialog text claims it's destroyed).
Could this be changed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on August 23, 2019, 10:06:32 PM
Hey all.

Right now I have a script that spawns fleets at specific entities. If the entity is not found, it crashes the game. This is a pretty stupid question, but what I want to do is kill the script if the particular entity can't be found, without crashing the game. I'm not sure how to handle this problem, or even what the 'kill' command is to begin with. Could anyone help me out please?

Code:
Code
package data.campaign.fleets;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager;
import com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3;
import com.fs.starfarer.api.impl.campaign.fleets.FleetParamsV3;
import com.fs.starfarer.api.impl.campaign.ids.Abilities;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
import com.fs.starfarer.api.util.WeightedRandomPicker;
import org.lazywizard.lazylib.MathUtils;

import java.util.Random;

public class MessFleetManager extends BaseLimitedFleetManager {
public static int MESS_MAX_FLEETS = 12;

@Override
protected int getMaxFleets() {
return MESS_MAX_FLEETS;
}

@Override
protected CampaignFleetAPI spawnFleet() {

SectorEntityToken spawnEntityMess = Get_Messy();
if (spawnEntityMess == null) {
return null;
}

float combat = MathUtils.getRandomNumberInRange(1, MathUtils.getRandomNumberInRange(10,
MathUtils.getRandomNumberInRange(
100, 150)));

String fleetType;
if (combat < 10) {
fleetType = FleetTypes.PATROL_SMALL;
} else if (combat < 50) {
fleetType = FleetTypes.PATROL_MEDIUM;
} else {
fleetType = FleetTypes.PATROL_LARGE;
}

MarketAPI messmarket = Global.getFactory().createMarket(String.valueOf((new Random()).nextLong()),
String.valueOf((new Random()).nextLong()), 5);

FleetParamsV3 params = new FleetParamsV3(
null, // market
spawnEntityMess.getLocation(), // location
"mess", // fleet's faction, if different from above, which is also used for source market picking
1.5f,
fleetType,
combat, // combatPts
0f, // freighterPts
0f, // tankerPts
0f, // transportPts
0f, // linerPts
0f, // utilityPts
0 // qualityBonus
);

LocationAPI location = spawnEntityMess.getContainingLocation();  // a star system, or hyperspace
CampaignFleetAPI fleet = FleetFactoryV3.createFleet(params);
location.addEntity(fleet);// adds our new fleet into the containing location
fleet.setLocation(spawnEntityMess.getLocation().x, spawnEntityMess.getLocation().y);// positions fleet on top of the spawn entity

if ((fleet == null) || fleet.isEmpty()) {
return null;
}


fleet.removeAbility(Abilities.EMERGENCY_BURN);
fleet.removeAbility(Abilities.SENSOR_BURST);
fleet.removeAbility(Abilities.GO_DARK);

// to make sure they attack the player on sight when player's transponder is off
fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_SAW_PLAYER_WITH_TRANSPONDER_ON, true);
fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_FLEET, true);

fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_MAKE_AGGRESSIVE, true);
fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_NO_JUMP, true);

fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, spawnEntityMess, 3f + (float) Math.random() * 2f);
if ((float) Math.random() > 0.75f) {
fleet.addAssignment(FleetAssignment.RAID_SYSTEM, spawnEntityMess, 250,
"raiding around the " + spawnEntityMess.getName() + " star system");
} else {
fleet.addAssignment(FleetAssignment.RAID_SYSTEM, spawnEntityMess, 500,
"raiding the " + spawnEntityMess.getName() + " star system");
}
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, spawnEntityMess, 20,
"returning to " + spawnEntityMess.getName());
fleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, spawnEntityMess, 2f + 2f * (float) Math.random(),
"orbiting " + spawnEntityMess.getName());

return fleet;
}
protected SectorEntityToken Get_Messy() {
WeightedRandomPicker<SectorEntityToken> picker = new WeightedRandomPicker<SectorEntityToken>();
for (StarSystemAPI system : Global.getSector().getStarSystems()) {
float weight = 0f;
if (system.getName().equals("Opuntia")) continue;
float w = 11f;
if (w > weight) weight = w;

for (SectorEntityToken entity : system.getAllEntities()) {
if (entity.getId().equals("mess_station1")) {
picker.add(entity, weight);
}
}
}
return picker.pick();
}
}

*Edit: De-spoilered, as this was causing some people issues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: weedlock on August 24, 2019, 02:10:02 AM
I'm a little bored of the existing player flags, and I was trying to mess around with adding more. I added a flag and a crest to the directory in core/graphics, and added some new lines to player.faction. All very cool, but is there a way to do this with a mod file so its easier to distribute? From what I read only .csv's and .json's can be merged by the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Imp0815 on August 24, 2019, 02:58:42 AM
I'm a little bored of the existing player flags, and I was trying to mess around with adding more. I added a flag and a crest to the directory in core/graphics, and added some new lines to player.faction. All very cool, but is there a way to do this with a mod file so its easier to distribute? From what I read only .csv's and .json's can be merged by the game.

Yes you just need to make a folder in the mods folder and copy the core folder structure with all the folders and files you edited.

For Example:
Starsector\mods\yourmod\graphics\factions\custom
To add new flags.
and
Starsector\mods\yourmod\data\world\factions\player.faction
to overwrite the original faction file.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SwissArmyKnife on August 24, 2019, 03:28:44 AM
I'm trying to take the large cannon from Black Rock Driveyards, Solenoid, and turn it into a big old Diable flavored beam cannon. This would be easy enough but I want to retain it's animations, with it opening up on start up, freezing on say frame 4 during firing, then progressing to the end on cooldown. I'm in the weeds since beam weapons .wpn file works a little differently than projectile .wpn files do.

The sprites are easy enough but I'm unsure how the animation is handled. The original Solenoid .wpn file had lines for numFrames and framerate, and it's animtype set to MUZZLE_FLASH. Can beam weapons have muzzle flash, let alone sprite based animations? I couldn't find a vanilla example, the most indepth those got were recoil or glow effects.

I'm also not really sure what the everyFrameEffect and .java file do. I again based mine off the original Solenoid and guessed what the file was doing.

Sprites (Still need to do the turret version I know):
Spoiler
(https://i.imgur.com/Rk5EhDG.jpg)
[close]

.wpn
Spoiler
Code
{
"id":"diableavionics_eldos",  # this id must match what's in the spreadsheet
"specClass":"beam",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":1200,
"turretSprite":"graphics/da/weapons/eldos/eldos_turret00.png",
"hardpointSprite":"graphics/da/weapons/eldos/eldos_hpbarrel00.png",
"numFrames":24,
"frameRate":15,
"visualRecoil":0.0,  # the gun sprites are only used if this is non-0
"renderHints":[RENDER_BARREL_BELOW],
"turretOffsets":[30, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[50, 0],
"hardpointAngleOffsets":[0],
"barrelMode":"ALTERNATING", # or LINKED.  whether barrels fire at the same time or alternate.
"animationType":"MUZZLE_FLASH",  # NONE, GLOW, MUZZLE_FLASH, SMOKE
"muzzleFlashSpec":{"length":45.0,   # only used if animationType = MUZZLE_FLASH
   "spread":6.0,
   "particleSizeMin":1.0,
   "particleSizeRange":60.0,
   "particleDuration":1.25,
   "particleCount":63,
   "particleColor":[135,155,170,125]},
"fireSoundOne":"diableavionics_eldos_start",
"fireSoundTwo":"diableavionics_eldos_loop",
    "everyFrameEffect":"data.scripts.weapons.EldosAnimation",
}
[close]

EldosAnimation.java
Spoiler
Code
package data.scripts.weapons;

public class EldosAnimation extends BaseAnimateOnFireEffect {

    public EldosAnimation() {
        super(); // doesn't actually do anything
        setFramesPerSecond(15);
        pauseOnFrame(4);
    }
}
[close]

Thanks!

Update: Figured out most of the above by copying some stuff from Neutrino Corps Phase Cannon. Only issue now is the java file crashes Starsector on load with:
Spoiler
Code
java.lang.RuntimeException: Error compiling [data.scripts.weapons.EldosAnimation]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.weapons.EldosAnimation
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
[close]

And here's the java file.
Spoiler
Code
// By Deathfly
package data.scripts.weapons;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;

public class EldosAnimation implements EveryFrameWeaponEffectPlugin {

    private final float validFrames = 13;
//    private final float animeMAXchargelvl = 0.8f;
    private float chargeLevel = 0;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        AnimationAPI anime = weapon.getAnimation();
       
        if (anime == null){
            return;
        }
        if (!weapon.isFiring()) {
            chargeLevel = 0;
            anime.setFrameRate(-12);
            if (anime.getFrame() == 0) {
                anime.setFrameRate(0);
            }
        } else {
            if (weapon.getChargeLevel() >= chargeLevel) {
                chargeLevel = weapon.getChargeLevel();
                if (anime.getFrame() < validFrames) {
                    anime.setFrameRate(12);
                } else {
                    anime.setFrameRate(0);
                    anime.setFrame(13);
                }
            } else {
                chargeLevel = weapon.getChargeLevel();
                if (anime.getFrame() > 0) {
                    anime.setFrameRate(-12);
                } else {
                    anime.setFrameRate(0);
                    anime.setFrame(0);
                }
            }
            if (weapon.getShip().getFluxTracker().isOverloadedOrVenting()){
                weapon.setRemainingCooldownTo(weapon.getCooldown());
            }
        }
    }
}
[close]

I figured it was because the default compiler runs JDK 6 and I need JDK 7 but all the IDE guides I found were massively out of date. Tried IntelliJ IDEA and couldn't for the life of me get it to actually compile the damn jar file. Giving up until tomorrow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Imp0815 on August 24, 2019, 05:29:58 AM

I'm also not really sure what the everyFrameEffect and .java file do. I again based mine off the original Solenoid and guessed what the file was doing.


I think everything in their fires every frame.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Melissia on August 24, 2019, 09:56:26 AM
Is there a simple way to change the normal map size and star count, and have more star systems and such to explore?  I admit to being new to modding this game, though I have owned it and played it off and on for a long time now (since may 2013 in fact!).  I at least figured out how to install preexisting mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2019, 11:01:27 AM
Currently giving a market the NO_DECIV_KEY memory flag also makes it not die from saturation bombardment when size <= 4 (even though the dialog text claims it's destroyed).
Could this be changed?

Fixed!


Right now I have a script that spawns fleets at specific entities. If the entity is not found, it crashes the game. This is a pretty stupid question, but what I want to do is kill the script if the particular entity can't be found, without crashing the game. I'm not sure how to handle this problem, or even what the 'kill' command is to begin with. Could anyone help me out please?

Generally you want to check something like "if (entity == null) return null" or some such, but it depends on exactly where and with what error.

I'm a little bored of the existing player flags, and I was trying to mess around with adding more. I added a flag and a crest to the directory in core/graphics, and added some new lines to player.faction. All very cool, but is there a way to do this with a mod file so its easier to distribute? From what I read only .csv's and .json's can be merged by the game.

The .faction are json files under the hood and are treated as such as far as merging, so it should be fine.


@SwissArmyKnife: not actually sure offhand what's going on. Might be another error message somewhere earlier in the log? This sort of thing might happen if your script is doing something Janino (the compiler the game uses for loose scripts) doesn't support, or if the class doesn't have a default constructor, but none of that seems to be the problem in your code.


Is there a simple way to change the normal map size and star count, and have more star systems and such to explore?  I admit to being new to modding this game, though I have owned it and played it off and on for a long time now (since may 2013 in fact!).  I at least figured out how to install preexisting mods.

Hi - take a look here:

http://fractalsoftworks.com/forum/index.php?topic=16127.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Melissia on August 24, 2019, 11:04:56 AM
Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SwissArmyKnife on August 24, 2019, 02:15:54 PM

@SwissArmyKnife: not actually sure offhand what's going on. Might be another error message somewhere earlier in the log? This sort of thing might happen if your script is doing something Janino (the compiler the game uses for loose scripts) doesn't support, or if the class doesn't have a default constructor, but none of that seems to be the problem in your code.


Thanks for taking a look at it. This may be a dumb question but I couldn't find a good answer anywhere and it's making me think the solution is simpler than it seems.

If I want to add a .java file to an existing mod's .jar file. For instance adding my new guns animation .java file to DiableAvionics  .jar file. How do I do that? Do I need to use something like netbeans to package and compile the whole thing again from src?

Do I even need to do that in the first place?

Update: Figured it out! Not ideally but it works which is good enough for a small personal mod. Ended up putting the java file in Diable's data/scripts/weapons instead of trying to add into into it's jar file.

Now my only issue is getting it to animate properly. Right now it's just cycling through the frames over and over. I need it to pause on frame 5 during firing but I'm not sure how to do that. I have no real idea what I'm doing so I looked at a bunch of different guns and couldn't find one that did the above.

I assumed that  if (!weapon.isFiring()) would dicate what it was doing while firing but adding animeSetFrame(5); in there just locks it to frame 5 in it's resting state. Firing animation still cycles through all 13 on a loop.

Here's the anim code again.
Spoiler
Code
// By Deathfly
package data.scripts.weapons;

import com.fs.starfarer.api.AnimationAPI;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.WeaponAPI;

public class EldosAnimation implements EveryFrameWeaponEffectPlugin {

    private final float validFrames = 13;
//    private final float animeMAXchargelvl = 0.8f;
    private float chargeLevel = 0;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        AnimationAPI anime = weapon.getAnimation();
       
        if (anime == null){
            return;
        }
        if (!weapon.isFiring()) {
            chargeLevel = 0;
            anime.setFrameRate(-12);
            if (anime.getFrame() == 0) {
                anime.setFrameRate(0);
            }
        } else {
            if (weapon.getChargeLevel() >= chargeLevel) {
                chargeLevel = weapon.getChargeLevel();
                if (anime.getFrame() < validFrames) {
                    anime.setFrameRate(12);
                } else {
                    anime.setFrameRate(0);
                    anime.setFrame(13);
                }
            } else {
                chargeLevel = weapon.getChargeLevel();
                if (anime.getFrame() > 0) {
                    anime.setFrameRate(-12);
                } else {
                    anime.setFrameRate(0);
                    anime.setFrame(0);
                }
            }
            if (weapon.getShip().getFluxTracker().isOverloadedOrVenting()){
                weapon.setRemainingCooldownTo(weapon.getCooldown());
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 24, 2019, 03:06:48 PM
Do I need to use something like netbeans to package and compile the whole thing again from src?
That would work. An IDE can make your life a lot easier. .jar files don't contain .java files, so no, you can't simply add a .java to a .jar. Jars contain .class files, which are the compiled versions of the java source.

Do I even need to do that in the first place?
I don't think so. A loose script should work unless it contains something Janino doesn't support, which I think is the case here. You might try making sure that all values assigned to floats are followed by an f (e.g. 42f instead of 42). I'm pretty sure Janino has a hard time dealing with int/float value mismatches.
Code
    private final float validFrames = 13;
//    private final float animeMAXchargelvl = 0.8f;
    private float chargeLevel = 0;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on August 24, 2019, 08:49:12 PM
Thanks for the reply Alex!

I did put in a check for that, with Get_Messy being the method to find the entity;

Code
		
SectorEntityToken spawnEntityMess = Get_Messy();
if (spawnEntityMess == null) {
return null;
}

However the problem persists. Am I doing it in the wrong area?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2019, 08:51:29 PM
@King Alfonzo: I don't know! Take a look at the exception, and it should give you a line number, that's where you should look in your script. If you post the exception, I (or someone else here) can help you interpret it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SwissArmyKnife on August 24, 2019, 10:39:10 PM
I don't think so. A loose script should work unless it contains something Janino doesn't support, which I think is the case here. You might try making sure that all values assigned to floats are followed by an f (e.g. 42f instead of 42). I'm pretty sure Janino has a hard time dealing with int/float value mismatches.
Code
    private final float validFrames = 13;
//    private final float animeMAXchargelvl = 0.8f;
    private float chargeLevel = 0;

You were completely right, loose script worked fine and janino compiled fine. Starsector launches etc. I just don't know what I'm doing with java scripting and copying existing scripts has only gotten me so far.

Once again I think I'm overcomplicating this. I want the anim to start, play until it gets to say frame 5 where the barrel is open and "hot" and pause while the beam is firing, then continue playing to the end when the gun charges down.

Here's where it's at now.
Spoiler
(https://i.postimg.cc/c1wC0m72/Sequence-02.gif)
[close]

Anyone able to help a complete noob out?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dgs6686 on August 25, 2019, 05:35:54 PM
Hi all, fairly new to the game and forums but I was considering making a mod to adjust / remove some of the skills available in the game... (particularly Electronic Warfare). I know there is a skills overhaul coming soon anyways but I just wanted to try my hand at this and see how modifying some of these affects combat.

I am fairly new to modding overall and only moderately fluent in Java but I figured this shouldn't be TOO difficult. I was wondering if anyone knew where I would start for something like this? I see the skills files under character/skills and I see the api calls that it appears to make but I'm not quite sure where to look after that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 25, 2019, 06:16:21 PM
The Skills are in starfarer.api\com\fs\starfarer\api\impl\campaign\skills.  To implement new ones, you'll need to create a directory (preferably in /scripts) and move one of the Skill java files there, change the reference in the .skill file, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 25, 2019, 09:50:44 PM
OK, here's a weird issue.  What would stop a given Weapon from being stocked / created at a Market?

I have a "weapon" that costs 0 OPs and does some Special Stuff. 

When I force it into a Market's inventory via a restocking-script, all is well.  When I don't, it doesn't generate, even though it's Known to the Faction involved and some Variants require it to be built.  It isn't being stocked and those Variants never show up in the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 26, 2019, 01:42:08 AM
What's the best way to record FleetMemberAPI in Persistent Data?
And how to check "FleetMemberAPI" is no longer exists and remove it from the hashmap?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 26, 2019, 03:55:50 AM
Where could i find the recovery chance for derelicts? Do the cases in pickDerelictCondition from DerelictShipEntityPlugin affect that chance or is it only for loadout, dmods, etc.?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 26, 2019, 08:58:54 AM
I made a whole pack of custom images/flags for the player faction (in graphics/factions/custom). How do I make them show up in-game? I don't see the vanilla images referenced in the setting.json
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 26, 2019, 09:59:51 AM
OK, here's a weird issue.  What would stop a given Weapon from being stocked / created at a Market?

I have a "weapon" that costs 0 OPs and does some Special Stuff. 

When I force it into a Market's inventory via a restocking-script, all is well.  When I don't, it doesn't generate, even though it's Known to the Faction involved and some Variants require it to be built.  It isn't being stocked and those Variants never show up in the game.

Hmm - looking at the code, that might happen if the tier is set too high for what the submarket allows.


What's the best way to record FleetMemberAPI in Persistent Data?
And how to check "FleetMemberAPI" is no longer exists and remove it from the hashmap?

You basically can't - a FleetMemberAPI could be in a fleet, in storage somewhere, or referenced from some other script, either from core or from another mod. So it's impossible to tell if it has "ceased to exist" or not. The best you could do is check the player's fleet and colony storage.

Where could i find the recovery chance for derelicts? Do the cases in pickDerelictCondition from DerelictShipEntityPlugin affect that chance or is it only for loadout, dmods, etc.?

Modifiers go here:
ship.getMutableStats().getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD)

(See ReinforcedBulkheads, for example)

And the base chance is in settings.json, "baseShipRecoveryChance" and "baseOwnShipRecoveryChance"

The number is a probability, i.e. >=1 is 100% chanc to recover.

I made a whole pack of custom images/flags for the player faction (in graphics/factions/custom). How do I make them show up in-game? I don't see the vanilla images referenced in the setting.json

They go into the player.faction file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 26, 2019, 10:22:38 AM
@Alex:  the Tier is set to 0.  This is supposed to be a "pretty common item" for the Factions that have it in their KnownWeapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 26, 2019, 10:24:19 AM
Hmm - try setting the OP to not 0, maybe? I'm not seeing anything that would cause that to not add the weapon but I seem to remember "0 op" being special in some way. Also make sure it's not SYSTEM etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 26, 2019, 10:40:33 AM
Not SYSTEM / DECORATIVE.

Zero OP may be the problem.  Ah well, making them 1 won't really break what they do...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on August 26, 2019, 10:59:01 AM
Confirmed:  0-OP weapons will not spawn in Markets.  Fixed, thank you, that was driving me nuts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 26, 2019, 12:09:43 PM
Modifiers go here:
ship.getMutableStats().getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD)

(See ReinforcedBulkheads, for example)

And the base chance is in settings.json, "baseShipRecoveryChance" and "baseOwnShipRecoveryChance"

The number is a probability, i.e. >=1 is 100% chanc to recover.

I actually did change the numbers in settings and reinforced bulkheads. Set them pretty low to see if it works (1%) chance and the random derelicts are still available for recovery pretty often. That's why I was wondering whether the baseShipRecoveryChance applies to them too or only to post-battle salvage. I think I remember finding a post a while ago about recovery being related to the ship being broken apart, although I don't know if this applies to battles only.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 26, 2019, 12:14:48 PM
Ah, right, what I said is post-battles only. The other stuff is actually not so easily moddable - each salvageable entity gets a "special" which is picked from a set of possibilities depending on the entity type. The specials range from "nothing" to "this ship is recoverable" (which is a possibility for ships, and for places where ships might be found in hangars etc, such as stations or ruins). The ratios of available specials in these cases are hardcoded in mod-accessible code, but actually replacing them would be a significant effort.

See:

com.fs.starfarer.api.impl.campaign.procgen.themes.SalvageSpecialAssigner

Looking at assignSpecialForBattleWreck(), for example (which is called for wrecks that spawn from fleets fighting each other), it looks like a 50/50 chance for recoverable or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 26, 2019, 12:35:35 PM
Alright , thanks. Maybe I will try to get down to it some time.

And one more thing while i'm at it. If i wanted to modify the battle creator plugin, would it be enough to just extend the base BattleCreatorPluginImpl or would i have to do it the way nexerelin does, by creating it's own plugin and seting it up via PluginPick<BattleCreationPlugin>? Did the former and I'm not really seing any changes, so that's why I'm wondering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 26, 2019, 12:41:07 PM
Right yes you need to do what Nex does here - otherwise your new plugin isn't being used by anything. Just extending a class doesn't really do anything aside from providing its functionality in your class; something has to create an object of your new class and use it. (In this case, the pickXXXPlugin method.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 26, 2019, 12:49:03 PM
Well, I was expecting as much. I was hoping for an easy way because I just want to increase the stand-off distance. Anyway, thank you very much.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 26, 2019, 12:57:36 PM
Getting this error if trying to start game without exerelin
Code
---------------------------
Starsector 0.9.1a-RC8
---------------------------
Fatal: Error compiling [data.scripts.SteelcladModPlugin]
Cause: File 'data/scripts/SteelcladModPlugin.java', Line 44, Column 44: Imported class "exerelin.campaign.SectorManager" could not be loaded
Check starsector.log for more info.

The odd bit is that I haven't changed my SteelcladModPlugin lately, and it worked without nex before
Every other mod I checked also has the same lines and basically the same code - all import exerelin.campaign.SectorManager;

Here is my file

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import exerelin.campaign.SectorManager;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.CampaignPlugin;

import com.fs.starfarer.api.impl.campaign.ids.Ranks;
import com.fs.starfarer.api.impl.campaign.ids.Skills;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.FullName.Gender;
import com.fs.starfarer.api.characters.PersonAPI;

import data.scripts.world.SteelcladGen;


public class SteelcladModPlugin extends BaseModPlugin {


    @Override
public void onApplicationLoad() throws ClassNotFoundException { 
           
        try {
            Global.getSettings().getScriptClassLoader().loadClass("org.lazywizard.lazylib.ModUtils");
        } catch (ClassNotFoundException ex) {
            String message = System.lineSeparator()
                    + System.lineSeparator() + "LazyLib is required to run at least one of the mods you have installed."
                    + System.lineSeparator() + System.lineSeparator()
                    + "You can download LazyLib at http://fractalsoftworks.com/forum/index.php?topic=5444"
                    + System.lineSeparator();
            throw new ClassNotFoundException(message);
        }         
    }

    @Override
    public void onNewGame() {
        initSC();
    }

    private static void initSC() {
        boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
        if (!haveNexerelin || SectorManager.getCorvusMode()){
            new SteelcladGen().generate(Global.getSector());
            // Exerelin not found so continue and run normal generation code
        }
    }

    private void updateConditionSpecs() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }


   @Override
    public void onNewGameAfterEconomyLoad() {
        MarketAPI market = Global.getSector().getEconomy().getMarket("avalon");
        if (market != null) {
            PersonAPI admin = Global.getFactory().createPerson();
            admin.setFaction("VNS");
            admin.setGender(Gender.MALE);
            admin.setPostId(Ranks.POST_FACTION_LEADER);
            admin.setRankId(Ranks.FACTION_LEADER);
            admin.getName().setFirst("Gabriel");
            admin.getName().setLast("Algar");
            admin.setPortraitSprite("graphics/portraits/prt_vns_algar.png");

            admin.getStats().setSkillLevel(Skills.FLEET_LOGISTICS, 3);
            admin.getStats().setSkillLevel(Skills.PLANETARY_OPERATIONS, 3);
            admin.getStats().setSkillLevel(Skills.INDUSTRIAL_PLANNING, 3);

            market.setAdmin(admin);
            market.getCommDirectory().addPerson(admin, 0);
            market.addPerson(admin);
        }
    }

}


About the only difference I can see is that my code is not in a .jar
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 27, 2019, 09:26:45 AM
How difficult would it be to modify deposit conditions modifiers. Considering I found them in the ResourceDepositCondition class, I suppose doing it in individual industry plugins is a no go?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 27, 2019, 10:21:34 AM
About the only difference I can see is that my code is not in a .jar

That's the issue - since your code is compiled at runtime, the exerelin script you import needs to "exist" at runtime. Which it doesn't. If you pre-compile your code with it as a library, then that's not an issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 27, 2019, 11:19:44 AM
So basically, by copying that SectorManager.java into my mod folder, it should work without Nex?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 27, 2019, 03:55:41 PM
How difficult would it be to modify deposit conditions modifiers. Considering I found them in the ResourceDepositCondition class, I suppose doing it in individual industry plugins is a no go?

You could do it there, or you could provide a different plugin for the conditions. It's hard to answer the question because there's a ton of different ways you could go about this and it all depends on what exactly you want to accomplish. It's all going to require code, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 27, 2019, 04:49:17 PM
I've been trying to pinpoint the cause of this crash (http://fractalsoftworks.com/forum/index.php?topic=15946.msg255553#msg255553) for a few days, since a few people (including me) initially thought it might be caused by starship legends. It seems to be caused by some error or omission in ship_data.csv. The stack trace makes me suspect that the crash occurs when ships with erroneous ship_data.csv entries are present at a market when the player interacts with it. So my question is; what missing or invalid entry could cause an NPE on line 48 of CRPluginImpl?
Code
	public void applyMaxCRCrewModifiers(FleetMemberAPI member) {
float maxCRBasedOnLevel = 0.7f;
------>         member.getStats().getMaxCombatReadiness().modifyFlat("crew skill bonus", maxCRBasedOnLevel, "Basic maintenance");

So basically, by copying that SectorManager.java into my mod folder, it should work without Nex?
SectorManager itself has other Nexerelin dependencies, so if you go that route you'll basically end up needing to bundle the entirety of Nex with your mod. If you can't reliably import SectorManager from a script, it sounds like the only option is to compile a jar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 27, 2019, 05:06:12 PM
I've been trying to pinpoint the cause of this crash (http://fractalsoftworks.com/forum/index.php?topic=15946.msg255553#msg255553) for a few days, since a few people (including me) initially thought it might be caused by starship legends. It seems to be caused by some error or omission in ship_data.csv. The stack trace makes me suspect that the crash occurs when ships with erroneous ship_data.csv entries are present at a market when the player interacts with it. So my question is; what missing or invalid entry could cause an NPE on line 48 of CRPluginImpl?
Code
	public void applyMaxCRCrewModifiers(FleetMemberAPI member) {
float maxCRBasedOnLevel = 0.7f;
------>         member.getStats().getMaxCombatReadiness().modifyFlat("crew skill bonus", maxCRBasedOnLevel, "Basic maintenance");

After looking at the code a fair bit: the only way I could see this happening is if something called member.setVariant(null, X, X); on one of the getCargo().getMothballedShips() of the submarket. That would cause the stats to be null and ... well, hmm. Testing that out produces a different crash, ugh. So I actually don't know, it's a weird one - doesn't make sense how it would happen. All the ways I can think of seem to crash earlier in other ways.

If there's a save where this is readily reproducible and you could upload the mod folder, I'd be happy to take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 27, 2019, 05:08:44 PM
Quote
So basically, by copying that SectorManager.java into my mod folder, it should work without Nex?
SectorManager itself has other Nexerelin dependencies, so if you go that route you'll basically end up needing to bundle the entirety of Nex with your mod. If you can't reliably import SectorManager from a script, it sounds like the only option is to compile a jar.
Could also use some other way to detect non-random sector mode; e.g. checking if Jangala or the Corvus system exist.

Next version of Nex might just set a flag in Sector memory.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 27, 2019, 05:17:49 PM
You could do it there, or you could provide a different plugin for the conditions. It's hard to answer the question because there's a ton of different ways you could go about this and it all depends on what exactly you want to accomplish. It's all going to require code, though.

I'm not going for anything in particular at this moment. I was looking trough the industry plugins and noticed that farming and mining don't have supply specified in their classes, and yet they produce commodities. Thought it might be located elsewhere or related to the said conditions class in some way. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 27, 2019, 05:20:20 PM
Ah - yeah, it's handled in the ResourceDepositsCondition, as you surmised.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 27, 2019, 05:47:51 PM
Thanks for the reply Alex!

I did put in a check for that, with Get_Messy being the method to find the entity;

Code
		
SectorEntityToken spawnEntityMess = Get_Messy();
if (spawnEntityMess == null) {
return null;
}

However the problem persists. Am I doing it in the wrong area?

You need to stop spawnFleet() from ever being called in the advance() method if the spawnEntity is null. Or ensure that Get_Messy() never returns null somehow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on August 27, 2019, 06:32:44 PM
After looking at the code a fair bit: the only way I could see this happening is if something called member.setVariant(null, X, X); on one of the getCargo().getMothballedShips() of the submarket. That would cause the stats to be null and ... well, hmm. Testing that out produces a different crash, ugh. So I actually don't know, it's a weird one - doesn't make sense how it would happen. All the ways I can think of seem to crash earlier in other ways.
Yeah, it's bizarre. I can't imagine anything that might prevent a ship from having stats, especially anything to do with ships_data.

If there's a save where this is readily reproducible and you could upload the mod folder, I'd be happy to take a look.
I'll see if I can get a hold of one. I haven't actually experienced this crash myself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 28, 2019, 05:38:36 AM
Does the local resources submarket not update for hidden markets? If so, is there a way to change this that isn't "add the things yourself in an EveryFrameScript"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 28, 2019, 06:01:43 AM
Quote
So basically, by copying that SectorManager.java into my mod folder, it should work without Nex?
SectorManager itself has other Nexerelin dependencies, so if you go that route you'll basically end up needing to bundle the entirety of Nex with your mod. If you can't reliably import SectorManager from a script, it sounds like the only option is to compile a jar.
Could also use some other way to detect non-random sector mode; e.g. checking if Jangala or the Corvus system exist.

Next version of Nex might just set a flag in Sector memory.

Or I can just ship 2 different version of the ModPlugin
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on August 28, 2019, 07:41:10 AM
I'm at my wit's end trying to figure out how to remove a buff from a FleetMemberAPI after it's been salvaged by a player. The buff applies a bonus to a bunch of stats in MutableStatsAPI through the buff's Apply(), and I've added a custom unapply() method to remove the buffs when called or the buff expires. I've tried adding BuffManagerAPI.removeBuff()/setting the duration to 0 to ShipRecoverySpecial, using the right buff ID, but it's not working. Is there an every-frame method in the campaign screen I can refer to the player's fleet then shove some remove buff methods into?

Is there something totally simple I'm missing that can easily remove the effects of buffs, or am I just failing to implement it being removed on salvage?

Or for what I'm doing, just changing a ship's MutableStatsAPI, would it be easier to modify them directly without using buffs? Are MutableStatsAPI's reset on a ship's destruction/recovery?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 28, 2019, 09:25:32 AM
Is it possible to get the monthly income total of a faction? Or is it tracked only for the player?

Also, getAvailable from the commodity tracker gets the max export or the total value? I'm want to sum up the total units of commodities produced by a faction. I found getTotalSupply in the CommodityStatTracker, but its' usage seems to be related to the demand in some way ( as in float demand = com.getDemand().getDemandValue(); -> float supply = demand; ->totalSupply += supply;) so I'm not sure if that's what I'm looking for. Nvm, figured it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 28, 2019, 09:36:04 AM
I'm at my wit's end trying to figure out how to remove a buff from a FleetMemberAPI after it's been salvaged by a player. The buff applies a bonus to a bunch of stats in MutableStatsAPI through the buff's Apply(), and I've added a custom unapply() method to remove the buffs when called or the buff expires. I've tried adding BuffManagerAPI.removeBuff()/setting the duration to 0 to ShipRecoverySpecial, using the right buff ID, but it's not working. Is there an every-frame method in the campaign screen I can refer to the player's fleet then shove some remove buff methods into?

Is there something totally simple I'm missing that can easily remove the effects of buffs, or am I just failing to implement it being removed on salvage?

Or for what I'm doing, just changing a ship's MutableStatsAPI, would it be easier to modify them directly without using buffs? Are MutableStatsAPI's reset on a ship's destruction/recovery?

You need to use a buff because the stats are not persistent just get recreated when needed, and the modifiers (from hullmods, captains, skills, buffs, etc) get applied at that point. If you're calling getBuffManager().removeBuff(), that should trigger a stats update, which would mean the stats get recreated without the effect of the removed buff.

It's hard to say exactly what might be going on without seeing a bit of code.


Is it possible to get the monthly income total of a faction? Or is it tracked only for the player?

Technically possible, but it's really only meant to be player-facing and AI colonies aren't balanced around that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 28, 2019, 09:44:18 AM
Technically possible, but it's really only meant to be player-facing and AI colonies aren't balanced around that.

Is int total = (int) (report.getRoot().totalIncome - report.getRoot().totalUpkeep); from public void doCustomProduction close to what I could use as the starting point of reference?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 28, 2019, 09:49:04 AM
No, that's just the player's monthly income report. You want market.getNetIncome() for whatever markets you're interested in. For getting the markets, see the code in Misc.getFactionMarkets().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 28, 2019, 09:56:11 AM
Okay. Thank you again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on August 28, 2019, 10:24:44 AM
That explanation about Removebuff() actually explained what was wrong with my implementation, thanks!

You're a legend for answering questions every day, man.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 28, 2019, 10:29:14 AM
Glad you got it working!

(And, ha, thank you :D)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on August 28, 2019, 11:57:41 AM
Is it possible to add fleet skills to AI fleets?
I know that some use some fleet skills(like Officer Management) but some are not used(like Safety Procedures).
I tried to add some of fleet buffs to some factions but it don't look like it working.

Anyone can help?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dgs6686 on August 28, 2019, 01:14:51 PM
The Skills are in starfarer.api\com\fs\starfarer\api\impl\campaign\skills.  To implement new ones, you'll need to create a directory (preferably in /scripts) and move one of the Skill java files there, change the reference in the .skill file, etc.

Thanks for the help! With a little digging and playing around I was able to get started on my some of my ideas. My first test was to try and combine 'Strike Commander' in to 'Missile Specialization', and then remove the 'Strike Commander' skill from the game. I am running in to 2 complications I was wondering if you or someone else might know how this is supposed to be done.

Firstly, It appears that the game is still reading the base-game skill info for 'Missile Specialization' and inputting the stats with my modified version (as seen in the attachment). As you can see for my test the only value I changed was 'Level 3: Missile damage' from 25% to 10%. However it is still reading the 25% from the base-game value and dumping it in extra with my modified stats.

Secondly, I can tell if I remove the 'Strike Commander' skill entry from skill_data.csv in the default sub-directory (starsector-core/data/character/skills) that it will no longer appear on the character screen as a learn-able skill. However I'm not sure how to remove this from showing from a mod standpoint. If I copy the skill_data.csv to my mod folder/data/character/skills and remove the 'Strike Commander' entry it appears to have no effect. I'm also not sure if this will prevent the AI / Officers from being able to learn this ability.

Edit: Also wanted to throw in that I tested this with harpoon MRM pod - 4x 750 damage harpoons hit a hammerhead shield for 1620 damage, which is equivalent to 2025 damage after dividing by .8 for the shield mitigation. Since harpoons deal 1/2 damage to shields, 4x 375 = 1500 * 1.35 (25 % + 10%) = 2025 so I confirmed that both the mod values and the standard values are being added.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: XDms on August 29, 2019, 08:58:38 AM
Hello, i would like to add a new commodity using an existing industry (Light Industry for example)
Is that possible (without breaking stuff) or do i need to create a new industry to produce the new commodity? Because I had a look at a few mods and seems that new commodities are created from new industries
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on August 29, 2019, 10:30:03 AM
How do I get my new combat plugin to work? I've got a class implementing EveryFrameCombatPlugin in a .jar in a new mod, with the jar being referenced in the modinfo file. I'm not sure how to get the game to read this plugin. Up until now for stuff like this I've been overwriting things in the game's API.jar in the core folder, which isn't exactly something I should be doing going forward. Which also leads me to another question, is it possible to get a mod to overwrite a .class file in the core .jar?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 29, 2019, 10:32:33 AM
Hello, i would like to add a new commodity using an existing industry (Light Industry for example)
Is that possible (without breaking stuff) or do i need to create a new industry to produce the new commodity? Because I had a look at a few mods and seems that new commodities are created from new industries

One way to do it is by making an extension of the original industry class and adding "supply(Commodities.(your commodity), (whichever number, it's usually size minus something);" in the public void apply override. Then you can go to the industries.csv and type in your class' file path in the plugins column for the respective industry. I suppose that wouldn't break anything :p.

Edit: Btw I'm not sure whether you have introduced the new commodity into the game yet. I haven't really done that myself, and if it requires more than edits to the commodities csv I may be of little help here.

 I also have a question. Is it possible to apply the percentage of the population progress towards new size to modify a value? I want to have a number scale with it. I reckon PopulationComposition getPopulation(); may have something to do with it but I'm not sure if it's applicable. I'm not really knowledgeable about Java, so forgive my recent torrent of questions :D.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 29, 2019, 11:38:57 AM
Is it possible to add fleet skills to AI fleets?
I know that some use some fleet skills(like Officer Management) but some are not used(like Safety Procedures).
I tried to add some of fleet buffs to some factions but it don't look like it working.

Anyone can help?

IIRC, all fleetwide skills from AI fleet commanders apply to their fleets. Some don't matter (i.e. fuel consumption or supply use modifiers) but that doesn't prevent the skills from being applied.


Hello, i would like to add a new commodity using an existing industry (Light Industry for example)
Is that possible (without breaking stuff) or do i need to create a new industry to produce the new commodity? Because I had a look at a few mods and seems that new commodities are created from new industries

It's possible and should be fairly straightforward, in as much as adding industries is, anyway.

Hello, i would like to add a new commodity using an existing industry (Light Industry for example)
Is that possible (without breaking stuff) or do i need to create a new industry to produce the new commodity? Because I had a look at a few mods and seems that new commodities are created from new industries
One way to do it is by making an extension of the original industry class and adding "supply(Commodities.(your commodity), (whichever number, it's usually size minus something);" in the public void apply override. Then you can go to the industries.csv and type in your class' file path in the plugins column for the respective industry. I suppose that wouldn't break anything :p.

Right on!


How do I get my new combat plugin to work? I've got a class implementing EveryFrameCombatPlugin in a .jar in a new mod, with the jar being referenced in the modinfo file. I'm not sure how to get the game to read this plugin. Up until now for stuff like this I've been overwriting things in the game's API.jar in the core folder, which isn't exactly something I should be doing going forward. Which also leads me to another question, is it possible to get a mod to overwrite a .class file in the core .jar?

Add the plugin to your "plugins" section in settings.json; the key you use doesn't matter as long as it's unique.

You can't overwrite .class files, generally you'll need to instead change wherever that class is being used/pointed to to use the other class instead. See: various CampaignPlugin.pickXXXPlugin methods, GenericPluginManagerAPI, etc.



I also have a question. Is it possible to apply the percentage of the population progress towards new size to modify a value? I want to have a number scale with it. I reckon PopulationComposition getPopulation(); may have something to do with it but I'm not sure if it's applicable. I'm not really knowledgeable about Java, so forgive my recent torrent of questions :D.

See: Misc.getMarketSizeProgress() for how to get the growth value.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on August 29, 2019, 12:01:09 PM
Thank you. It was actually right under my nose and i went looking elsewhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on August 29, 2019, 03:55:49 PM
Is there a tag to prevent blueprints from being obtainable via raiding?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 29, 2019, 08:33:31 PM
Yeah, "no_bp_drop".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 30, 2019, 06:37:25 AM
Should we change the thing where a ship being built by player while not having variants defined in default_ship_roles.json just stalls the build queue indefinitely? It's pretty confusing to users.
(Maybe let it go ahead and complete construction with no weapons)

I added it as a plugin to the plugins section, but it's getting an error about being unable to cast from modplugin to my combat plugin. I'm pretty sure it's because my plugin is a class implementing BaseEveryFrameCombatPlugin and not a class extending the ModPlugin class.

I've looked through a bunch of mods that are using classes implementing BaseEveryFrameCombatPlugins and I don't even see how they're calling the plugin. The only plugin they call is their own ModPlugin which makes no references to their combat plugins.
That error sounds like you accidentally specified your combat plugin in the mod info's mod plugin field, or vice-versa.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vagrant on August 30, 2019, 01:53:57 PM
Does anyone have experience with using hullmods to modify aspects of ship systems?

-I'm looking to create a single, modular shipsystem that can have additional effects and bonuses based on equipped hullmods. I'm comfortable enough doing the actual modifications to the system that I want, but I have no idea how to implement them so that they are applied only when an applicable hullmod is equipped.

-Alternatively, is changing a given ship's system to another system entirely, possible with a hullmod?

Any examples I could read through or parts of the API in particular I could look at would be helpful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 30, 2019, 04:14:02 PM
Should we change the thing where a ship being built by player while not having variants defined in default_ship_roles.json just stalls the build queue indefinitely? It's pretty confusing to users.
(Maybe let it go ahead and complete construction with no weapons)

Hmm - first time I'm hearing about it! So on the one hand, it probably shouldn't get stuck (fixed), but on the other hand, that seems like an error in the mod - all ships need to have corresponding entries in default_ship_roles if they have a blueprint, otherwise they won't don't show up in fleets once the blueprint is learned.


Does anyone have experience with using hullmods to modify aspects of ship systems?

-I'm looking to create a single, modular shipsystem that can have additional effects and bonuses based on equipped hullmods. I'm comfortable enough doing the actual modifications to the system that I want, but I have no idea how to implement them so that they are applied only when an applicable hullmod is equipped.

I don't have any examples handy, but you'd want to check - in the apply hullmod effects method - whether the ship's variant has the hullmod. Something like ship.getVariant().hasHullMod(String id) or similar.

-Alternatively, is changing a given ship's system to another system entirely, possible with a hullmod?

I don't think it's possible with a hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on August 30, 2019, 07:54:47 PM
Does anyone have experience with using hullmods to modify aspects of ship systems?

-I'm looking to create a single, modular shipsystem that can have additional effects and bonuses based on equipped hullmods. I'm comfortable enough doing the actual modifications to the system that I want, but I have no idea how to implement them so that they are applied only when an applicable hullmod is equipped.

I know Interstellar Imperium does this, you should check it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 30, 2019, 09:08:06 PM
Does the local resources submarket not update for hidden markets? If so, is there a way to change this that isn't "add the things yourself in an EveryFrameScript"?
Figured out my problem: local resources' getStockpileLimit() doesn't count commodity supply from flat mods. So I had to override that method in my local modification of LocalResourcesSubmarketPlugin.

New problem: How to I set a market's demand for a commodity to zero? I tried the following in EconomyUpdateListener.commodityUpdated()
Code: java
	CommodityOnMarketAPI com = market.getCommodityData(commodityId);
String modId = market.getId();

market.getDemand(com.getDemandClass()).getDemand().modifyMult(modId, 0);
com.getDemand().getDemand().modifyMult(modId, 0);
but the market's industries still generate their usual demand.

EDIT: Also, how often is EconomyUpdateListener.economyUpdated() called? I'm wondering if it's safe to use for a monthly upkeep-style cost or if I should use reportEconomyTick insead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on August 31, 2019, 02:45:33 AM
What exactly does    
"raidCooldownDays":1,
do?

I assume it's the minimal period between raids? All raids? How do I reduce pirate raids. They are attacking me every month.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArnaudB on August 31, 2019, 08:45:06 AM
What exactly does    
"raidCooldownDays":1,
do?

I assume it's the minimal period between raids? All raids? How do I reduce pirate raids. They are attacking me every month.
Nothing to do with pirates raid. It's when you raid/invade/disrupt with your fleet on a world. You need to wait one full day (24 hours) before you can make another.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on August 31, 2019, 10:15:14 AM
Is there a guide for Hullmods and Ship Systems? The Wiki tutorial doesn't have those yet
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 31, 2019, 10:45:02 AM
New problem: How to I set a market's demand for a commodity to zero? I tried the following in EconomyUpdateListener.commodityUpdated()
Code: java
	CommodityOnMarketAPI com = market.getCommodityData(commodityId);
String modId = market.getId();

market.getDemand(com.getDemandClass()).getDemand().modifyMult(modId, 0);
com.getDemand().getDemand().modifyMult(modId, 0);
but the market's industries still generate their usual demand.

Ah, yeah, you don't want to generally mess with that - this is only used for determining the player-facing prices of things. It operates in "cargo units", not "economy units", so just generally it's not what you're looking for.

CommodityOnMarketAPI.getMaxDemand() is what's used here, and that returns the maximum demand out of all the industries that have demand for the commodity.

So I think what would work is:
For each IndustryAPI, call getDemand(String commodityId); this returns a MutableCommodityQuantity.

This has a MutableStat quantity, which you could modifyMult(modId, 0). I *believe* this should work.


EDIT: Also, how often is EconomyUpdateListener.economyUpdated() called? I'm wondering if it's safe to use for a monthly upkeep-style cost or if I should use reportEconomyTick insead.

Yeah, you want to use EconomyTickListener. EconomyUpdateListener gets called any time the economy is synched up, such as say when the player visits a colony.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: XDms on September 01, 2019, 07:21:33 AM
Hello, i would like to understand how the FoodShortage event is triggered, can someone point me which files to look on? I did some "backward" study and from FoodShortageEvent.class i arrived to CampaignEventManager.class, yet I can't find which conditions/code increase or decrease the probability of this event happening
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 01, 2019, 08:42:21 AM
It's not - it's left over from way back but it's not hooked up to anything and the code wouldn't be functional if it was. Sorry :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 01, 2019, 11:57:02 AM
I find that in IntelPlugin, if I use large description, the whole background is black and not transparent.
So is there any way to make it transparent?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 01, 2019, 12:24:47 PM
I don't believe so, no. That's just how the intel screen is set up - the descriptions go over a black background.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 01, 2019, 08:34:15 PM
I don't believe so, no. That's just how the intel screen is set up - the descriptions go over a black background.
hmmm okay...I'm just want to know why the intel plugin which has small description has a transparent gap between the map and small description.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 01, 2019, 08:53:41 PM
Literally just because that's how the UI is coded to look :) I think it works better visually; I did try not having the gap/having that be black/etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Armithaig on September 01, 2019, 11:55:44 PM
Made a SHIP_WITH_MODULES, but the modules're "swaying" with passionate turns as if strapped on with space tape.
Any way to nail 'em down firmer?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on September 02, 2019, 04:19:46 AM
Is it possible to add a flat modifier to a building's upkeep that is not affected by multipliers (such as hazard)? From what I have checked, I suppose I would have to introduce a brand new mutable stat and factor it into the net income calculation alongside upkeep, if that's feasible to begin with as I think it could be hardcoded.

Edit: Nevermind, found a workaround  :).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2019, 08:18:00 AM
Made a SHIP_WITH_MODULES, but the modules're "swaying" with passionate turns as if strapped on with space tape.
Any way to nail 'em down firmer?


Hmm. I don't actually know what the issue might be. If the modules have a INDEPENDENT_ROTATION hint set, that would prevent their facing from being locked; that's the only thing that comes to mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Soñjer on September 02, 2019, 09:20:39 AM
How do I make my ships appear in markets ? No matter how many time I refresh, they don't seem to spawn. I have all the vanilla .factions files set up like this:

Code
{
  "knownShips":{
    "hulls":[
      "ship_a",
      "ship_b",
      "ship_b",
    ],
  },
  "shipsWhenImporting":{
      "ship_a",
      "ship_b",
      "ship_c",
  },
},

Do I need something else ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Armithaig on September 02, 2019, 12:52:12 PM
Do I need something else ?
Variants in /data/variants. Set the variant quality too high, won't appear on your regular backwater rimworld either.

Made a SHIP_WITH_MODULES, but the modules're "swaying" with passionate turns as if strapped on with space tape.
Any way to nail 'em down firmer?


Hmm. I don't actually know what the issue might be. If the modules have a INDEPENDENT_ROTATION hint set, that would prevent their facing from being locked; that's the only thing that comes to mind.
Captured me sliding 'round like Kubica at 50% speed. (https://streamable.com/ig5ke)
See if it fires any synapses, can make a post in (modded?) bug section with JSON/CSV data if it helps. No extraordinary hints, just SHIP_WITH_MODULES, CARRIER, UNBOARDABLE, HIDE_IN_CODEX.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2019, 01:09:07 PM
... weird.

Just to confirm, are those modules implemented as ships? Or are you using decorative weapons etc? The hints you'd want to look at would be for the module "ships", as far as INDEPENDENT_ROTATION.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Armithaig on September 02, 2019, 01:24:13 PM
They're ships, posted the basics here (http://fractalsoftworks.com/forum/index.php?topic=16403.0).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on September 02, 2019, 03:39:44 PM
I've also noticed modules on some of my faster ships swaying slightly with violent maneuvers; I'd also be interested in a fix.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2019, 03:50:31 PM
(Per that thread, fixed!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Soñjer on September 03, 2019, 03:47:22 AM
Do I need something else ?
Variants in /data/variants. Set the variant quality too high, won't appear on your regular backwater rimworld either.

Checked it, previously it was set to 0. Made it 1 and then removed the tag altogether, still doesn't show up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 03, 2019, 04:17:08 AM
If you haven't already done it, you also need to specify the variants in data/world/factions/default_ship_roles.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Soñjer on September 03, 2019, 07:15:58 AM
If you haven't already done it, you also need to specify the variants in data/world/factions/default_ship_roles.json.

It doesn't seem to be that either. Here's a dummy mod (https://www.dropbox.com/s/qim2na4pfedb3xf/test.7z?dl=0) that has the same structure, if that can help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 03, 2019, 08:47:10 AM
Ah! In your default_ship_roles, you've got:

"test_paragon":5,

The key needs to be the various variants, not the hull id.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on September 03, 2019, 08:54:58 AM
Is the recovery of lost player ships after combat handled in CoreScript and ShipRecoverySpecial? Trying to get player ships to be recovered with more Dmods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 03, 2019, 09:00:23 AM
Using playerFleet().getStats().getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION) I think might work if you set this to a negative value.

Otherwise, yeah, it's handled in ShipRecoverySpecial (for derelicts) and FleetEncounterContext (post-combat). For derelicts, you could directly modify the variant of the derelict; IIRC Vayra was asking about this specifically a few pages back in this thread...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vagrant on September 03, 2019, 10:13:20 AM
Does anyone have experience with using hullmods to modify aspects of ship systems?

-I'm looking to create a single, modular shipsystem that can have additional effects and bonuses based on equipped hullmods. I'm comfortable enough doing the actual modifications to the system that I want, but I have no idea how to implement them so that they are applied only when an applicable hullmod is equipped.

I know Interstellar Imperium does this, you should check it out.

This was super informative, thanks Alex and Vayra.

for anyone interested, got it working by adding:

if (ship.getVariant().hasHullMod(hullmod id))

to the apply function inside a Ship System stats script, with a bunch of cases for relevant hullmods. Really easy!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Soñjer on September 03, 2019, 10:19:01 AM
Ah! In your default_ship_roles, you've got:

"test_paragon":5,

The key needs to be the various variants, not the hull id.

This one's my bad, just forgot when copy pasting. Here's the mod updated (https://www.dropbox.com/s/v6eie35hye9tk40/test.7z?dl=0) (still not working)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NoFoodAfterMidnight on September 03, 2019, 12:29:10 PM
The way the DMod reduction is implemented with a random.nextint() I think it can cause errors if it's negative.

But the FleetEncounterContext is exactly what I was looking for, thanks! I'd been assuming that ShipRecoverySpecial handled post-combat recovery, but it's only post combat derelicts and ships contained in debris fields.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 03, 2019, 01:14:50 PM
But the FleetEncounterContext is exactly what I was looking for, thanks!
Just keep in mind that any time you override FleetEncounterContext it will create a conflict with any other mod that does the same, because there can be only one for any given encounter. These are the mods (that I'm aware of) that override vanilla's FleetInteractionDialogPluginImpl in order to assign their own FleetEncounterContext :
For ruthless sector, I bypassed this limitation by overriding the FleetInteractionDialogPlugins of other mods with a plugin of my own that extends any overriden plugin, thus preserving their functionality.
Code
public class CampaignPlugin extends BaseCampaignPlugin {
    @Override
    public PluginPick<InteractionDialogPlugin> pickInteractionDialogPlugin(SectorEntityToken interactionTarget) {
        try {
            if (interactionTarget instanceof CampaignFleetAPI) {
                InteractionDialogPlugin plugin;
                PickPriority priority = PickPriority.MOD_GENERAL;
                ModManagerAPI mm = Global.getSettings().getModManager();

                try {
                    if (mm.isModEnabled("swp") && interactionTarget.getFaction().getId().contentEquals("famous_bounty")) {
                        plugin = new SwpCompatibleFleetInteractionDialogPlugin();
                        priority = PickPriority.HIGHEST; // No other way to ensure compatibility, unfortunately
                    } else if (mm.isModEnabled("nexerelin")) {
                        plugin = new NexCompatibleFleetInteractionDialogPlugin();
                    } else if (mm.isModEnabled("THI") && TiandongModPlugin.useCustomFleetPlugin && anIdleMercFleetIsNearby()) {
                        plugin = new ThiCompatibleFleetInteractionDialogPlugin();
                        priority = PickPriority.MOD_SPECIFIC;
                    } else {
                        plugin = new FleetInteractionDialogPlugin();
                    }
                } catch (Exception e) {
                    plugin = new FleetInteractionDialogPlugin();
                    ModPlugin.reportCrash(e);
                }

                return new PluginPick<>(plugin, priority);
            }
        } catch (Exception e) { ModPlugin.reportCrash(e); }

        return null;
    }

    // Code removed for the sake of brevity
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: XDms on September 04, 2019, 03:39:33 AM
Thank you Salv and Alex for your replies :) I have a few more questions:
- Let's say I create a mod that add some new solar systems and planets; i guess the player need to start a new game to see/visit them, or he can also "load" them via console?
- Same question for a mod that adds new dialogs and options when the player visit the bar, for example a mod that implements new types of missions. Do he need to start a new game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 04, 2019, 08:55:22 AM
- Let's say I create a mod that add some new solar systems and planets; i guess the player need to start a new game to see/visit them, or he can also "load" them via console?

Depends on how you do it - generally, it'd require starting a new game, but it could be coded so that it can be added to an existing game, as well.

- Same question for a mod that adds new dialogs and options when the player visit the bar, for example a mod that implements new types of missions. Do he need to start a new game?

Generally those will not require starting a new game, unless the bar missions depend on something new being added to SectorGen, for example.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 04, 2019, 12:45:50 PM
Could a crash such as this one (http://fractalsoftworks.com/forum/index.php?topic=16182.0;topicseen) possibly be caused by an autofit goal variant that includes perma mods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 04, 2019, 01:17:59 PM
This looks like a "the variant of the ship is null" issue caused by Vayra's Ship Pack; same underlying issue as that other thread about it a bit back.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 04, 2019, 01:32:33 PM
Ok, thanks Alex. Sorry to bother you again about the same thing. It looked pretty different to me. Glad it's apparently not my fault!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 04, 2019, 01:37:48 PM
No worries! Yeah, it looked different to me, too - needed to look at the source code to make sense of it, and thankfully there was literally only way way it could NPE in that 3-line method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 04, 2019, 02:17:34 PM
Where is the script for Drive Field Stabilization (the Ox hullmod)? I can't find it in the vanilla files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 04, 2019, 02:46:40 PM
You can check hull_mods.csv to see what the hullmod's script; for this one it's com.fs.starfarer.api.impl.hullmods.DriveFieldStabilizer

The API's source code is in the starfarer.api.zip file. Changing it there would have no effect, btw, it's already compiled into a jar and is only provided for reference.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 04, 2019, 04:23:09 PM
You can check hull_mods.csv to see what the hullmod's script; for this one it's com.fs.starfarer.api.impl.hullmods.DriveFieldStabilizer

The API's source code is in the starfarer.api.zip file. Changing it there would have no effect, btw, it's already compiled into a jar and is only provided for reference.
Thanks

I want it for reference, i want to make a hullmod that does something similar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Innominandum on September 04, 2019, 04:36:09 PM
You can check hull_mods.csv to see what the hullmod's script; for this one it's com.fs.starfarer.api.impl.hullmods.DriveFieldStabilizer

The API's source code is in the starfarer.api.zip file. Changing it there would have no effect, btw, it's already compiled into a jar and is only provided for reference.
Thanks

I want it for reference, i want to make a hullmod that does something similar.
- 2 Burn + 50% Fuel Consumption ?
(http://i.kinja-img.com/gawker-media/image/upload/s--g8iy0IEu--/wk2lvmudr2rzzgthooeg.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 04, 2019, 04:57:33 PM

- 2 Burn + 50% Fuel Consumption ?

+4 burn actually, this is for my huge logistics ship, it will do the work of 4 Ox tugs in one huge ship

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 04, 2019, 05:02:57 PM
Quite new to the API, need a bit of help here

How would i turn this line from "Get the cost of these bombers and increase by BOMBER_COST_PERCENT" to "Get the cost of these bombers and increase by BOMBER_COST_PERCENT IF they are not drones (0 crew?) AND cost less than 5 OP"?

Code
stats.getDynamic().getMod(Stats.BOMBER_COST_MOD).modifyPercent(id, BOMBER_COST_PERCENT);

I don't know the syntax to add conditions here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 04, 2019, 05:21:53 PM
This should work: (Edit: not for what you're trying to do though)
Code
        if(fighter.getHullSpec().getMinCrew() > 0 && fighter.getHullSpec().getOrdnancePoints(null) < 5)
Edit: It looks like you're trying to adjust the ordnance point cost of bombers that meet those criteria. If so, I don't think there's a way to do it. The problem is that that stat modification needs to be applied to the carrier, not the bomber, and there's no way to pick and choose which bombers it applies to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 04, 2019, 05:58:09 PM
This should work: (Edit: not for what you're trying to do though)
Code
        if(fighter.getHullSpec().getMinCrew() > 0 && fighter.getHullSpec().getOrdnancePoints(null) < 5)
Edit: It looks like you're trying to adjust the ordnance point cost of bombers that meet those criteria. If so, I don't think there's a way to do it. The problem is that that stat modification needs to be applied to the carrier, not the bomber, and there's no way to pick and choose which bombers it applies to.

What i really want is to limit the ship to only be able to equip wings that are Drones and have very low OP (weak drones only), i figured making all other wings have a prohibitive cost would be a good solution. Guess not :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 04, 2019, 06:17:39 PM
Ah, ok. Sylphon RnD (http://fractalsoftworks.com/forum/index.php?topic=13524.0) does something similar to what you want, although the implementation is imperfect. If I remember correctly, it allows you to assign any fighter, but then removes it if it's not a drone.

I don't know exactly what you're trying to accomplish, but perhaps a better approach would be to discourage crewed fighters instead of outright disallowing them. For example, the hullmod could automate all crewed fighters, preventing crew casualties from fighter losses, but also reducing their effectiveness.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 04, 2019, 08:21:32 PM
Ah, ok. Sylphon RnD (http://fractalsoftworks.com/forum/index.php?topic=13524.0) does something similar to what you want, although the implementation is imperfect. If I remember correctly, it allows you to assign any fighter, but then removes it if it's not a drone.

I don't know exactly what you're trying to accomplish, but perhaps a better approach would be to discourage crewed fighters instead of outright disallowing them. For example, the hullmod could automate all crewed fighters, preventing crew casualties from fighter losses, but also reducing their effectiveness.

I have a ship that would be too strong if it could just put anything in the fighter bays, so i wanted to balance it this way, i will check the Sylphon RnD solution, thanks for the tip!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 05, 2019, 09:06:22 AM
What's the difference between ListenerManagerAPI and getAllListeners() in sectorAPI.
I found that if I add my listener by Global.getSector().addListener, listener manager seems won't contain that listener.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 05, 2019, 09:40:45 AM
What's the difference between ListenerManagerAPI and getAllListeners() in sectorAPI.
I found that if I add my listener by Global.getSector().addListener, listener manager seems won't contain that listener.

SectorAPI.getAllListeners() - and other methods, like addListener() etc - are for CampaignEventListener only.

SectorAPI.getListenerManager() is for... just about anything. E.G. mods can even add their own types of listeners that the core game is not explicitly aware of. See: com.fs.starfarer.api.campaign.listeners.ListenerUtil for how listeners added to ListenerManagerAPI are used.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 05, 2019, 09:57:06 AM
How could i make a ship system be usable in Phase and also force the ship out of phase? I got a glitch on my ship, it is a phase ship with a module that adds shields, and i can't manually end the phase while the module is active, so i want to make the ship system force the ship out of phase while giving a speed boost (based on plasma burn)

I tried adding "canUseWhileRightClickSystemOn":true, to the .system file, but it glitches the effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 05, 2019, 12:43:47 PM
I don't know if there's a way to do it without java, but have you tried using ship.getPhaseCloak().deactivate()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 05, 2019, 01:10:56 PM
I don't know if there's a way to do it without java, but have you tried using ship.getPhaseCloak().deactivate()?
Not yet because first i need to have the System work while phased, then i will try to figure out how to make it force the ship out of phase.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 05, 2019, 01:49:08 PM
Gotcha. The Doom's mine system works while phased, so it should be possible, but as far as I can tell the only thing different about it is "canUseWhileRightClickSystemOn":true, which you've already tried. My guess is that there's some difference between your ship system and mine strike that's preventing canUseWhileRightClickSystemOn from working properly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 05, 2019, 01:58:04 PM
Gotcha. The Doom's mine system works while phased, so it should be possible, but as far as I can tell the only thing different about it is "canUseWhileRightClickSystemOn":true, which you've already tried. My guess is that there's some difference between your ship system and mine strike that's preventing canUseWhileRightClickSystemOn from working properly.
Yeah, maybe i could try to change the system into something else compatible with canUseWhileRightClickSystemOn, but i gotta figure out what exactly and pray it works later...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 05, 2019, 05:42:20 PM
If i am getting errors like "Cannot determine simple type name "Color"" when importing java.awt.Color; does it mean i have to compile the scripts i am making? I never worked with scripting this way, so I am not sure why this stuff is not working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NBGO on September 06, 2019, 01:39:16 AM
So I want to edit certain mod's Hull Mods, mostly the ones that say "Requires a ship from [Mod]" and/or to edit the values within them.

Im looking into these Intelli whatever tutorials and it seems extremely complicated when I need to just edit one value in one (java) file.
Is there any way to do this much easier or would I have to look more into actual modding and compiling?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 06, 2019, 04:55:33 AM
Ah! In your default_ship_roles, you've got:

"test_paragon":5,

The key needs to be the various variants, not the hull id.

This one's my bad, just forgot when copy pasting. Here's the mod updated (https://www.dropbox.com/s/v6eie35hye9tk40/test.7z?dl=0) (still not working)
Just noticed the problem: the folder needs to be data/world, not data/worlds

(once you've done that, it'll crash on start because the shipsWhenImporting tables are incorrectly specified. Should have the hulls/tags structure, e.g.: )
Code: json
  "shipsWhenImporting":{
"hulls":[
      "test_paragon",
    ],
  },
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 08, 2019, 09:15:51 AM
Alex, it might be time to sticky this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Enganacious on September 09, 2019, 07:44:56 PM
I don't suppose anyone does like mod commissions?

I really just want a custom Aurora that replaces the 4x small synergy mounts in front with four flux shunt cannons off the Excelsior (SWP by Dark Rev) with the rest of the mounts made universal, and the max ordinance points largely increased. Maybe that and a dark red/purple paintjob.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 09, 2019, 07:49:32 PM
That should be a pretty easy thing to do (other than the paintjob) with SSEd.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 09, 2019, 07:53:07 PM
I don't suppose anyone does like mod commissions?

I really just want a custom Aurora that replaces the 4x small synergy mounts in front with four flux shunt cannons off the Excelsior (SWP by Dark Rev) with the rest of the mounts made universal, and the max ordinance points largely increased. Maybe that and a dark red/purple paintjob.

This might be, ah, relevant to your interests:

http://fractalsoftworks.com/forum/index.php?topic=16343.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Enganacious on September 09, 2019, 07:55:39 PM
I haven't the slightest as to how I'd yoink the flux shunt cannons from SWP into either some sort of fuddy-duddy built in weapon on the Aurora. Even the more simplistic thing of modding an existing weapon sprite to that leaves out the animations, stats, etc..

Also I just saw that Alex, if it included the rest of the ship money, I'd be posting the ubiquitous Fry meme.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 11:18:09 AM
I have a ship with a Module that has it's own shields & fortress shield system, my problem with it is that the module keeps the shield on with fortress shield up even when it could be safely venting behind the main ship's shields until both the module and the main ship are full of flux, i would like to alter the AI on the module so it follow 2 rules:

1. Do not use fortress shield if the main ship's defensive system (shield or phase) is up

2. If the main ship defensive system is up and the main ship has less than 35% flux and the module has more than 50% flux, do vent

I know how to write the code for those rules, but i don't know where to put it, i have no idea how to override/add more rules to the AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 10, 2019, 12:33:44 PM
Take a look at fastmissileracks.system. The relevant lines are commented out, but you should still be able to define a custom AI script. I know it was possible at one point, but there's a chance the method used here is out of date or something.
Code
{
"id":"fastmissileracks",
"type":"FAST_RELOAD",
"aiType":"FAST_RELOAD",
#"aiType":"CUSTOM",
#"aiScript":"data.shipsystems.scripts.ai.FastMissileRacksAI",

"weaponTypes":[MISSILE],
"minFractionToReload":0.5,

"useSound":"system_fast_missile_racks",
"outOfUsesSound":"gun_out_of_ammo",
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 12:38:55 PM
So, the way to do this would be a making custom system? I think i get how it would work. I will try later thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 10, 2019, 12:53:44 PM
No problem. And, yeah, unfortunately I don't think there's a good way to change a ship system's behavior short of creating a copy of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 10, 2019, 01:20:59 PM
I can confirm that the custom shipsystem AI does work, yes. I have some in my Kadur Remnant mod that you're welcome to use as a template if you like.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 02:49:41 PM
I can confirm that the custom shipsystem AI does work, yes. I have some in my Kadur Remnant mod that you're welcome to use as a template if you like.
Thanks man! I learn much faster when i can reverse-engineer something that already works. This really helps.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 04:07:11 PM
Does anyone have any idea where is the AI script for FORTRESS_SHIELD? I can find the stats script, but not the AI version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 10, 2019, 04:32:35 PM
Is there a way to override the current dialogue and force it into a ship recovery from within that dialog script?

that probably didn't make sense, so here's what I'm trying to do specifically (trimmed slightly for length):

1) Manager EveryFrameScript is added by ModPlugin, and under certain conditions adds Event EveryFrameScript instance and serves it a system (this part works fine, and I'm pretty sure isn't breaking the rest of it)

2) Event EveryFrameScript spawns a derelict, and assigns it some custom special interaction dialogue. That (the spawning and assigning) looks like this:

Code: java
    protected void spawnWreck(StarSystemAPI system) {
       
        WeightedRandomPicker<String> factions = SalvageSpecialAssigner.getNearbyFactions(null, system.getLocation(), 15f, 5f, 5f);
        String faction = factions.pick();
        String variantId = DerelictShipEntityPlugin.pickLargeVariantId(faction, new Random());
        ShipCondition condition = Math.random() > 0.5f ? ShipCondition.PRISTINE : ShipCondition.GOOD;
        DerelictShipEntityPlugin.DerelictShipData params = new DerelictShipEntityPlugin.DerelictShipData(new ShipRecoverySpecial.PerShipData(variantId, condition), false);
       
        params.durationDays = duration;
        entity = (CustomCampaignEntityAPI) BaseThemeGenerator.addSalvageEntity(system, Entities.WRECK, Factions.NEUTRAL, params);
        entity.addTag(Tags.EXPIRES);
       
        DerelictShipEntityPlugin plugin = new DerelictShipEntityPlugin();
        plugin.init(entity, params);
       
        Misc.setSalvageSpecial(entity, (Object) new VayraGhostShipSpecial.VayraGhostShipSpecialData((CustomCampaignEntityAPI) entity));
                   
        entity.setName("Derelict Ship (" + Global.getSettings().getVariant(variantId).getFullDesignationWithHullName() + ")");
    }

3) Here's where it gets complicated. The special interaction dialogue script contains this specialData subclass:

Code
    public static class VayraGhostShipSpecialData implements SalvageSpecialInteraction.SalvageSpecialData {

        public Danger danger;
        public Type type;
        public CustomCampaignEntityAPI entity;
        public ShipVariantAPI variant;

        public VayraGhostShipSpecialData(CustomCampaignEntityAPI entity) {

            this.entity = entity;
            DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
            PerShipData shipData = plugin.getData().ship;
            this.variant = shipData.variant;
            if (this.variant == null) {
                this.variant = Global.getSettings().getVariant(shipData.variantId);
            }
            shipData.variantId = null;
            this.variant = this.variant.clone();

            this.danger = DANGERS.pick();
            log.info("picked danger level " + this.danger);

            if (this.danger.equals(Danger.NONE)) {
                this.type = null;
                log.info("not picking a danger type");
            } else {
                this.type = TYPES.pick();
                log.info("picked danger type " + this.type);
            }
        }

        @Override
        public SalvageSpecialInteraction.SalvageSpecialPlugin createSpecialPlugin() {
            return new VayraGhostShipSpecial();
        }
    }

And does all this:

Code
    @Override
    public void optionSelected(String optionText, Object optionData) {

        if (CONFIRM.equals(optionData)) {
            (a whole bunch of stuff/other options go here)

        } else if (NEVER_AGAIN.equals(optionData)) {
            setDone(true);
            setShowAgain(false);
            setEndWithContinue(false);
        }

        if (recoverable) {
            SalvageSpecialAssigner.ShipRecoverySpecialCreator creator = new SalvageSpecialAssigner.ShipRecoverySpecialCreator(null, 0, 0, false, null, null);
            ShipRecoverySpecialData specialData = (ShipRecoverySpecialData) creator.createSpecial(entity, null);
            Misc.setSalvageSpecial(entity, specialData);
            ShipRecoverySpecial special = new ShipRecoverySpecial();
            special.init(dialog, specialData);
            setDone(true);
            setShowAgain(false);
        }
        }

Problem is, even if recoverable == true, the ship isn't recoverable - like I can't attach a new salvageSpecial to it from inside another salvageSpecial, or while another one is attached or something. :P

Presumably I'm doing something real dumb here, but I can't quite figure out what the "right" way to do this is. Any help would be much appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 10, 2019, 04:33:21 PM
Does anyone have any idea where is the AI script for FORTRESS_SHIELD? I can find the stats script, but not the AI version.

Pretty sure only one ShipSystemAI example is provided and it's a dummy script with nothing or almost nothing in it - that's why I volunteered my own scripts as templates.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 04:48:11 PM
Does anyone have any idea where is the AI script for FORTRESS_SHIELD? I can find the stats script, but not the AI version.

Pretty sure only one ShipSystemAI example is provided and it's a dummy script with nothing or almost nothing in it - that's why I volunteered my own scripts as templates.

Correct - the ship system AIs are generally in core code, like the rest of the ship AI. Extricating them from the internal dependencies would be ... troublesome.


@Vayra: this probably isn't the best thread for it because it's too involved, so might be better to have a separate thread for any follow-up. That said, the way you're creating the ship recovery special is missing some stuff. Here's an example creating one for a derelict:

ShipRecoverySpecialData data = new ShipRecoverySpecialData(null);
DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
data.addShip(plugin.getData().ship.clone());
Misc.setSalvageSpecial(entity, data);

The part you're missing is calling .addShip() for the ShipRecoverySpecialData.

The other issue is the flow of it - you're already in a "special" interaction, and when it ends, it'll unset the "special" data in the entity memory, since you've called setShowAgain(false). You want to call setShowAgain(true), so that it keeps the special data around (the code is assuming it's the old data, but it'll be the data you switched in using Misc.setSalvageSpecial.

However, even with that, I don't believe it'll chain to showing that special - it'll move on straight to salvage, per the sal_specialFinished rule. What you'll want to do is create another rule for the SalvageSpecialFinished trigger (and set a variable in entity memory from your "if (recoverable) {" block so you can tell when to use this rule), and have that rule "FireBest CheckSalvageSpecial" so that on finishing salvage, it loops back around to check for the special again, this time it being the newly-set ship recovery special.

Hope that makes sense!


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 10, 2019, 04:51:55 PM
Does anyone have any idea where is the AI script for FORTRESS_SHIELD? I can find the stats script, but not the AI version.

Pretty sure only one ShipSystemAI example is provided and it's a dummy script with nothing or almost nothing in it - that's why I volunteered my own scripts as templates.

Correct - the ship system AIs are generally in core code, like the rest of the ship AI. Extricating them from the internal dependencies would be ... troublesome.


@Vayra: this probably isn't the best thread for it because it's too involved, so might be better to have a separate thread for any follow-up. That said, the way you're creating the ship recovery special is missing some stuff. Here's an example creating one for a derelict:

ShipRecoverySpecialData data = new ShipRecoverySpecialData(null);
DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
data.addShip(plugin.getData().ship.clone());
Misc.setSalvageSpecial(entity, data);

The part you're missing is calling .addShip() for the ShipRecoverySpecialData.

The other issue is the flow of it - you're already in a "special" interaction, and when it ends, it'll unset the "special" data in the entity memory, since you've called setShowAgain(false). You want to call setShowAgain(true), so that it keeps the special data around (the code is assuming it's the old data, but it'll be the data you switched in using Misc.setSalvageSpecial.

However, even with that, I don't believe it'll chain to showing that special - it'll move on straight to salvage, per the sal_specialFinished rule. What you'll want to do is create another rule for the SalvageSpecialFinished trigger (and set a variable in entity memory from your "if (recoverable) {" block so you can tell when to use this rule), and have that rule "FireBest CheckSalvageSpecial" so that on finishing salvage, it loops back around to check for the special again, this time it being the newly-set ship recovery special.

Hope that makes sense!

Thanks! I'll try to work it out when I get home, and make a thread if (when, tbh) I run into any trouble.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 04:57:26 PM
Thanks! I'll try to work it out when I get home, and make a thread if (when, tbh) I run into any trouble.  ;D

A realist, I see :)

(Edit: if for some reason I don't respond in that thread in some kind of reasonable time, ping me - probably means I got sidetracked and forgot to check for it.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 05:19:51 PM
Does anyone have any idea where is the AI script for FORTRESS_SHIELD? I can find the stats script, but not the AI version.

Pretty sure only one ShipSystemAI example is provided and it's a dummy script with nothing or almost nothing in it - that's why I volunteered my own scripts as templates.

I am studying your code, but i would like to know what exactly is in the fortress shield AI since I am implementing a slightly different version of it.

Also guys how do i get the parent module of a module in a ship?

ship.getParentStation() is returning null, my ship does have SHIP_WITH_MODULES tag and all.

Edit to make things clear

This is the ship
Code
Rottweiler,edshipyard_rottweiler,Heavy Cruiser,ED Shipyard,fortressshield,17,8000,1500,10000,9000,450,175,,30,20,10,12,12,2250,FRONT,,150,0.6,0.6,,,200,300,150,150,5,30,8,175000,4,12,540,0.25,28,28,SHIP_WITH_MODULES,rare_bp,,0.4,2,3,404

This is the module
Code
,edshipyard_leonberger_midplate,Shield Module,,module_fortressshield,1,2000,1200,7400,5000,250,24,,0,0,0,10,10,600,FRONT,,90,0.1,1,,,0,0,0,0,1,0,,75000,,1,840,0.25,0,0,"UNBOARDABLE, HIDE_IN_CODEX",,,0.5,2,3,2100

I am editing the module_fortressshield, so that the module don't use it while the parent shield is on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 05:22:03 PM
Also guys how do i get the parent module of a module in a ship?

ship.getParentStation() is returning null, my ship does have SHIP_WITH_MODULES tag and all.

getParentStation() should really do the job, afaik stations and SHIP_WITH_MODULES aren't treated differently there. If it's not, hmm - maybe you're calling it on the wrong ship or some such?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 05:25:04 PM

getParentStation() should really do the job, afaik stations and SHIP_WITH_MODULES aren't treated differently there. If it's not, hmm - maybe you're calling it on the wrong ship or some such?

this is my init, this is called on the module AI (module_fortressshield)

Code
public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
        this.ship = ship;
        this.flags = flags;
        this.system = system;
        this.engine = engine;

        parent = ship.getParentStation();
        if(parent != null) { // <- if i remove this i get a crash on this line (nullpointer)
        parentFlags = parent.getAIFlags();// <-- code never gets here when i test
        }       
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 05:28:08 PM
Ah - it's probably null at this point since the module is just being created and hadn't been added to the parent ship yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 05:30:52 PM
Ah - it's probably null at this point since the module is just being created and hadn't been added to the parent ship yet.
Oh, i see, so i should make it look for a parent during the activate loop then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 05:48:06 PM
Right, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 05:49:57 PM
I'd actually probably take a different approach to this - keep the fortress shield AI, and do the stuff you need to do in an EveryFrameCombatPlugin or in a EveryFrameWeaponEffectPlugin on a custom hidden weapon on your ship. That way the default fortress shield AI can work normally and you can force it to be off by toggling the shield off as needed and by blocking the TOGGLE_SHIELD_OR_PHASE_CLOAK command.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 05:55:58 PM
I'd actually probably take a different approach to this - keep the fortress shield AI, and do the stuff you need to do in an EveryFrameCombatPlugin or in a EveryFrameWeaponEffectPlugin on a custom hidden weapon on your ship. That way the default fortress shield AI can work normally and you can force it to be off by toggling the shield off as needed and by blocking the TOGGLE_SHIELD_OR_PHASE_CLOAK command.

I see, nice work around.

How do i force the AI to vent? Just letting the flux go down is too slow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 05:59:38 PM
See:

http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipAPI.html

Search for "giveCommand" in particular.

Edit: link for the full javadoc: http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 10, 2019, 06:12:50 PM
See:

http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipAPI.html

Search for "giveCommand" in particular.

Edit: link for the full javadoc: http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html
thanks it worked, now the module won't waste flux anymore keeping the system up all the time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 06:17:45 PM
Nice, glad you got it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 10, 2019, 07:14:33 PM
Working on making a support ship that boosts and lowers sensor strength and profile respectively, across the fleet. It also boosts the fleet's burn level, which I already have done. I know this has to be done via hullmod. Are there any particular scripts and thus variables that I can import to the hullmod so it can subsequently apply its effects?

Edit for clarification: I'm browsing the API folder's contents. I already have the fleet burn bonus aspect included. But, I dunno what to do about sensor strength and profile for the fleet as a whole.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 10, 2019, 08:10:19 PM
I've been working on making starship legends add traits to enemy fleets, like this:
Spoiler
(https://i.imgur.com/Xu3E9Tn.jpg)
[close]
So far everything is working fine for normal fleets and salvage encounters, but for stations and planets I'm having a lot of trouble accessing the main enemy commander of the combined opposing fleet. Is there a decent way to do that that I'm missing?

Working on making a support ship that boosts and lowers sensor strength and profile respectively, across the fleet. It also boosts the fleet's burn level, which I already have done. I know this has to be done via hullmod. Are there any particular scripts and thus variables that I can import to the hullmod so it can subsequently apply its effects?

Edit for clarification: I'm browsing the API folder's contents. I already have the fleet burn bonus aspect included. But, I dunno what to do about sensor strength and profile for the fleet as a whole.
You'll probably want to use something like this:
Code
myFleet.getStats().getSensorRangeMod().modifyPercent("my_hullmod_id", 50f, "My Hullmod Name");
myFleet.getStats().getDetectedRangeMod().modifyPercent("my_hullmod_id", 50f, "My Hullmod Name");
However, the trouble you're likely to run into is accessing the correct fleet, since that information isn't provided by the hullmod methods.
Edit: Possibly not true! See comments below.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 10, 2019, 08:36:27 PM
Thanks! I'll try to work it out when I get home, and make a thread if (when, tbh) I run into any trouble.  ;D

A realist, I see :)

(Edit: if for some reason I don't respond in that thread in some kind of reasonable time, ping me - probably means I got sidetracked and forgot to check for it.)

Posted! I was able to get part of it working, but...  :-\

Thread here: http://fractalsoftworks.com/forum/index.php?topic=16536.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 08:56:27 PM
I've been working on making starship legends add traits to enemy fleets, like this:
Spoiler
(https://i.imgur.com/Xu3E9Tn.jpg)
[close]
So far everything is working fine for normal fleets and salvage encounters, but for stations and planets I'm having a lot of trouble accessing the main enemy commander of the combined opposing fleet. Is there a decent way to do that that I'm missing?

It's kind of hard to answer that question since I don't know where you're trying to do that. Generally, though, you'd want the traits to only apply to the commander of the fleet the ship is originally from, not the "main" commander of the opposing fleet? The "main" commander would just be whoever commands the fleet you're directly interacting with, and they only matter for dialog. And possibly command points, I don't quite remember. But all ship stat bonuses from skills etc are based on that ship's fleet commander.

I can see how that doesn't play nicely with wanting to print out the bonuses like this in the case of combined fleets, but you also wouldn't want, say, the bonuses to go away depending on whether you interact with the enemy fleet directly or if it joins to protect some other minor fleet.

(IIRC FleetMemberAPI should have getFleetCommanderForStats() in it, if you're not already using that...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 10, 2019, 09:01:36 PM
However, the trouble you're likely to run into is accessing the correct fleet, since that information isn't provided by the hullmod methods.

Is this true? I have this snippet in a hullmod that seems to work...

Code: java
    @Override
    public void advanceInCampaign(FleetMemberAPI member, float amount) {
        CampaignFleetAPI fleet = member.getFleetData() == null ? null : member.getFleetData().getFleet();
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 10, 2019, 09:09:17 PM
The issue is this'll return the fleet you're interacting with when other fleets join the fight, not the actual fleet the joined ships came from.

I've actually added a member.getFleetDataForStats() method to the API due to needing to properly access the original fleet from skills in a similar situation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 10, 2019, 09:56:41 PM
I'm surprised that wouldn't work. In all honesty, I completely forgot about advanceInCampaign...

Generally, though, you'd want the traits to only apply to the commander of the fleet the ship is originally from, not the "main" commander of the opposing fleet? The "main" commander would just be whoever commands the fleet you're directly interacting with, and they only matter for dialog. And possibly command points, I don't quite remember. But all ship stat bonuses from skills etc are based on that ship's fleet commander.
Ok, gotcha. I was under the false impressions that when fleets join forces against you that the highest level commander was the one that got the star and counted for stat bonuses. I guess that complicates things a bit for me, as I'll have to search through each fleet to find the commander with the highest level (which is all I'm concerned with in this case).

I can see how that doesn't play nicely with wanting to print out the bonuses like this in the case of combined fleets, but you also wouldn't want, say, the bonuses to go away depending on whether you interact with the enemy fleet directly or if it joins to protect some other minor fleet.
Yup. This is why I want the highest level commander. There can only be one set of traits for a battle in order to reduce spam and to prevent the problem of people not knowing which ships have which set of traits during battle. If the highest level commander is chosen, then there's potential inconsistency, but at least people couldn't game it by interacting with the weaker commander.

(IIRC FleetMemberAPI should have getFleetCommanderForStats() in it, if you're not already using that...)
In the case of stations and planets as interaction targets, I'm having trouble definitively determining which fleets the player is interacting with, let alone fleet members. Normally I would get that from the BattleAPI, but I can't find a way to access it in this case.

It's kind of hard to answer that question since I don't know where you're trying to do that
I'm trying to do it here:
Code
public class SL_ShowMarketDefenses extends BaseCommandPlugin {
    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
        if (new MarketCMD().execute(ruleId, dialog, params, memoryMap)) {
            // This is where I need to find the highest level enemy commander that the player is engaged with
            return true;
        } else return false;
    }
}
Which is called by overriding marketHostileSel in rules.cmv
I couldn't think of any other way to print what I needed to at the right time.
The problem I'm having stems from the fact that the FIDP, encounter context, and battleAPI variables are all declared locally in MarketCMD.execute()
I'm really hoping there's a better way to do this than copying and editing MarketCMD, but I guess that will work if it's the only way.
Thanks for the help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArnaudB on September 11, 2019, 01:39:01 PM
Hello,

I am trying to increase the markets stockpiles and production. I am tired of needing to clean out entire systems markets to store up on fuel or commodity, so I've looked into tweaking things.

I assume you need to change those:
Code
	"economyIterPerMonth":10,
"economyMinDemandForPricing":100,
"economyMinStockpileForPricing":100,
"economyNoDemandPriceMult":0.5,
"economyGreedFraction":0.25,

What do I change to get bigger stacks in the market without causing ridiculous amount of excess everywhere? Would just changing EconomyIterPerMonth and StockpileMaxMonths be enough?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 11, 2019, 03:14:14 PM
Generally, though, you'd want the traits to only apply to the commander of the fleet the ship is originally from, not the "main" commander of the opposing fleet? The "main" commander would just be whoever commands the fleet you're directly interacting with, and they only matter for dialog. And possibly command points, I don't quite remember. But all ship stat bonuses from skills etc are based on that ship's fleet commander.
Ok, gotcha. I was under the false impressions that when fleets join forces against you that the highest level commander was the one that got the star and counted for stat bonuses. I guess that complicates things a bit for me, as I'll have to search through each fleet to find the commander with the highest level (which is all I'm concerned with in this case).

Looking at it, it's actually the commander of the fleet with the most FP, btw.


In the case of stations and planets as interaction targets, I'm having trouble definitively determining which fleets the player is interacting with, let alone fleet members. Normally I would get that from the BattleAPI, but I can't find a way to access it in this case.

It's kind of hard to answer that question since I don't know where you're trying to do that
I'm trying to do it here:
Code
public class SL_ShowMarketDefenses extends BaseCommandPlugin {
    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
        if (new MarketCMD().execute(ruleId, dialog, params, memoryMap)) {
            // This is where I need to find the highest level enemy commander that the player is engaged with
            return true;
        } else return false;
    }
}
Which is called by overriding marketHostileSel in rules.cmv
I couldn't think of any other way to print what I needed to at the right time.
The problem I'm having stems from the fact that the FIDP, encounter context, and battleAPI variables are all declared locally in MarketCMD.execute()
I'm really hoping there's a better way to do this than copying and editing MarketCMD, but I guess that will work if it's the only way.
Thanks for the help!

Yeah, extending MarketCMD and overriding showDefenses() sounds like your best bet. As you noted, that data only exists locally in that method...


Hello,

I am trying to increase the markets stockpiles and production.

What you probably want to do is edit commodities.csv and increase the econUnit column, since that directly affects how many cargo units of commodities correspond to an "economy unit".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 11, 2019, 03:19:07 PM
Yeah, extending MarketCMD and overriding showDefenses() sounds like your best bet. As you noted, that data only exists locally in that method...
Ok, that's what I'll do then. Thank you Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 11, 2019, 04:40:35 PM
How do i know if a weapon is Point Defense or Anti-Fighter?
I want to make a hullmod that blocks any non-PD non-AF weapon to be equipped while buffing the range of PD weapons.

I am looking at the WeaponAPI and i can't find it.

-edit-

I think i found, PrimaryRoleStr right?
Now to figure out how to force any that don't match it to unequip... or forbid equipping in first place...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 11, 2019, 05:31:46 PM
I can't figure out a way to remove or disable the weapons, right now I am trying this

Code
for (WeaponAPI weapon : weapons) {        	
   String role = weapon.getSpec().getPrimaryRoleStr();
   if(role.contains("Point Defense") || role.contains("Anti Fighter")) {
       continue;
   }
   weapon.disable();// <-- this is crashing (nullpointer)
}

I get a crash with this one when i swap a PD weapon with a non-PD weapon
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 11, 2019, 06:13:33 PM
Now to figure out how to force any that don't match it to unequip... or forbid equipping in first place...
I know this isn't the advice you want, but I think you're going about this the wrong way. Starsector has no built-in mechanism for preventing the fitting of weapons, hullmods, or fighters, and trying force it to work that way will inevitably lead to issues that are all but impossible to resolve. A far more practical and user-friendly approach would be to discourage certain weapons by penalizing their usage somehow. I'm telling you this for the sake of your own time. I'm glad you're pushing the limits of what the engine can do with your mod, but you need to be realistic as well.

Code
weapon.disable();// <-- this is crashing (nullpointer)
My guess is that you're calling disable() in a context in which it's not supported (e.g. in the refit screen instead of during battle). Otherwise, I have no idea why disable() would throw a NPE
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 11, 2019, 06:37:59 PM
Oh so disable was combat only, i see.

Thanks for the advice Sundog, but i figured out a solution, i tested it plenty and didn't get any issues, it is similar to the one used by Sylphon RnD drone only hullmod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArnaudB on September 12, 2019, 01:51:49 AM
What you probably want to do is edit commodities.csv and increase the econUnit column, since that directly affects how many cargo units of commodities correspond to an "economy unit".
Thank you, I found the file and made the edits. I do have to make the change for every mod right? That's what I am doing right now.

On a related note, I tried to search on the forum but found no answer. I'm sure it came up last year or so though. I mostly played on randomly-generated sectors and I never see the lobsters although I get trade missions for them. Similarly I the Hazard Mining Incorporated mod is supposed to add a number of exotic resources but none of their market seems to make them whenever I generate a sector. Is there something to do to fix this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 12, 2019, 06:33:56 AM
Is it possible to make a fighter that delivers ammo to other ships?
It would have to move up to an ally, do an animation in there, the ally would get a bit of ammo restocked and then the fighter would return to the carrier. How could this be implemented?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 12, 2019, 09:03:02 AM
Is it possible to make a fighter that delivers ammo to other ships?
It would have to move up to an ally, do an animation in there, the ally would get a bit of ammo restocked and then the fighter would return to the carrier. How could this be implemented?

sort of like maintenance / repair drone but for ammo, interesting idea
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 12, 2019, 09:05:38 AM
Is it possible to make a fighter that delivers ammo to other ships?
It would have to move up to an ally, do an animation in there, the ally would get a bit of ammo restocked and then the fighter would return to the carrier. How could this be implemented?

Probably, yeah, though it seems like a lot of effort. I'd imagine you'd have to write a bunch of scripts for the fighter AI and the actual effect. The fighter AI is where you'd take care of the landing/return/etc. I realize that's a bit vague, but in my defense, so is the question :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 12, 2019, 10:45:40 AM

Probably, yeah, though it seems like a lot of effort. I'd imagine you'd have to write a bunch of scripts for the fighter AI and the actual effect. The fighter AI is where you'd take care of the landing/return/etc. I realize that's a bit vague, but in my defense, so is the question :)

If it is possible i wanna try, how much of the fighter behavior can be overwritten?


sort of like maintenance / repair drone but for ammo, interesting idea

Is there a mod that already does something similar? I could reverse-engineer it.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 12, 2019, 10:47:16 AM
If it is possible i wanna try, how much of the fighter behavior can be overwritten?

To the best of my knowledge, 100%, but I'm not sure if anyone has tried modding in a fully-functional fighter AI, so some things may be broken, and you'll be treading on relatively unexplored ground.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 12, 2019, 11:18:04 AM
so, there were/are mods where fighters were overriden in such way?

e.g. theirs weapon have negative value of damage effect (vs shield or hull , weapons or engines)
combined with ability target and attack friendly ship instead of enemy
thus as result they regenerate shield, hull and weapon/engine too ? ;)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 12, 2019, 11:57:45 AM
so, there were/are mods where fighters were overriden in such way?

e.g. theirs weapon have negative value of damage effect (vs shield or hull , weapons or engines)
combined with ability target and attack friendly ship instead of enemy
thus as result they regenerate shield, hull and weapon/engine too ? ;)
if i can't make them deliver ammo i might try to make repair drones
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 12, 2019, 01:46:51 PM

after observing mods like e.g. nexerelin to override starting choices from the other smaller mods start options

i want to ask question if there there is way to make it modular / expanding ?
so one may combine those starting options alongside (ofc only if they compatible)

variety of selection in the start options would be very nice

now if that isn't possible to do via modding then i guess i would need to repost it into suggestions
(tho i bet someone else already suggested it in past)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on September 12, 2019, 02:06:13 PM
Hello
I made a ship, it works in sim battle, it shows up in codex variants, it is part of midline blueprints, it shows up in fleet doctrine and custom production BUT when I order its construction, the month its due to be completed report says its delivered to chosen market, but it doesnt spawn there. additionally, entire month of production capabilities is deducted from my funds, even though it should take only a couple of thousands to finish the job. the ship doesnt disappear from production list, and money is further withdrawn every consecutive month, each one reporting production complete.
I have no clue where to look for a solution? I used esteemed Vayra's tutorial, files seem ok, hull, variants, IDs too... 
thanks 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 12, 2019, 02:08:21 PM
IIRC this can happen if it doesn't have an entry in default_ship_roles.json. Fixed for next release, btw, but generally ships that can be made from blueprints ought to have entries there, otherwise they can't be used by faction fleets, including the player's faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 12, 2019, 02:17:35 PM
Is it possible to make a fighter that delivers ammo to other ships?
It would have to move up to an ally, do an animation in there, the ally would get a bit of ammo restocked and then the fighter would return to the carrier. How could this be implemented?
You might want to take a look at the faction mod I made long ago, called ICE (http://fractalsoftworks.com/forum/index.php?topic=7625.0). It's woefully out of date and you'll need starsector version 0.65.2a to run it, but it had repair drones that would refill ammo, repair armor, and recover peak-performance time.

@Dwarden: I'm pretty sure starting options are modular, and that Nexerelin overrides other starting options intentionally, since it changes so much that those options might not be work well with it. I would suggest asking about that in the Nexerelin thread.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 12, 2019, 02:23:31 PM
thanks @sundog, i wasn't sure about it being modular
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 12, 2019, 04:00:59 PM
You might want to take a look at the faction mod I made long ago, called ICE (http://fractalsoftworks.com/forum/index.php?topic=7625.0). It's woefully out of date and you'll need starsector version 0.65.2a to run it, but it had repair drones that would refill ammo, repair armor, and recover peak-performance time.

Ohhh juicy, time for some reverse-engineering! Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 12, 2019, 06:03:14 PM
No problem! I hope you find it helpful  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 12, 2019, 06:52:52 PM
No problem! I hope you find it helpful  :)
I did a quick glance, still haven't had the time to deep dive and try to recreate the drones.

Right now I am trying to figure a way to make a special built-in weapon for one of my ships, then i gotta do more playtest more for balance and release a new version before figuring out the drones.

BTW Your ships are awesome, it is such a waste to see them left behind like that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 12, 2019, 09:52:51 PM
BTW Your ships are awesome, it is such a waste to see them left behind like that.
Yeah, it's a shame, but bringing ICE up to a level of quality that I would consider acceptable would take more work than I originally put into it. If you want to take it over you're more than welcome. You seem to have the skill set for it. There's an up-to-date Chinese version of it somewhere, so it might even be fairly simple create a working copy of it by translating that back into English.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bowman on September 12, 2019, 10:36:11 PM
Is it possible to change the maximum engagement range of a fighter wing or is that stat un-alterable? I was going to simply look at Defective Manufactory since I figured it would do at least half of what I'm trying to do but it seems to be built into the game rather than out in the normal hullmods folder- I assume I'd have to decompile it or something but I've never tried to edit a .jar so I've no idea.

A search showed another discussion about fighters that highlighted SpawnedFighter actually referring to *after* the fighter is spawned, in combat, so armor values are set. Given this, is it possible to alter those values before the fighter even spawns or is the only way to do so afterwards?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 13, 2019, 05:22:19 AM
BTW Your ships are awesome, it is such a waste to see them left behind like that.
Yeah, it's a shame, but bringing ICE up to a level of quality that I would consider acceptable would take more work than I originally put into it. If you want to take it over you're more than welcome. You seem to have the skill set for it. There's an up-to-date Chinese version of it somewhere, so it might even be fairly simple create a working copy of it by translating that back into English.
If i run out of ideas for my weird ships it would be a nice new project, but the TODO list for my mod is growing faster than i can implement it since I am pretty slow at coding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 13, 2019, 05:52:27 AM
@Ed: Very understandable!

@bowman: You can view starsector's (API implementation related) source by unzipping \Starsector\starsector-core\starsector.api.zip. It sounds like you're looking for Malfunctioning Comms rather than Defective Manufactory. Normally hullmod classes that are in the jar ara compiled for a reason (Janino has all sorts of limitations), but in this case you shouldn't need to do anything like that in order to do what you want:
Code
stats.getFighterWingRange().modifyMult(id, 1f - ENGAGEMENT_REDUCTION * effect);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WeSpeakScots on September 13, 2019, 07:34:38 AM
I'm a CS student interested in developing a small mod for Starsector to help learn Java and wanted to know if it was at least a feasible idea. I want to be able to use a secondary display to view in-game information. I understand that trying to extend the game's interface across multiple displays would be a big task, so my plan was to SSH into the desktop running the game and use a text-based "GUI" interface in the shell which could display additional information outside of the normal HUD (available missions from the intel tab maybe).

Perhaps this terminal-based application could be expanded with multiple pages and even the ability to accept inputs and manage inventories. Does this sound like something worth investigating?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on September 13, 2019, 09:16:06 AM
IIRC this can happen if it doesn't have an entry in default_ship_roles.json. (...)

Yes, that I skipped, thinking its not necessary if the ship is for my use only for now. Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2019, 09:23:55 AM
Normally hullmod classes that are in the jar ara compiled for a reason (Janino has all sorts of limitations)

Just to expand on that a bit, when stuff is precomplied into a jar, it reduces the load time of the game. If there are *a lot* of loose scripts, that can really increase the load time - the compiling happens on another thread, so a relatively small number of scripts has no impact on load time, but the compiling can fairly easily take longer than all the other loading stuff combined, making it actually increase the loading time a lot. An example that comes to mind is the original Ironclads mod.


I'm a CS student interested in developing a small mod for Starsector to help learn Java and wanted to know if it was at least a feasible idea. I want to be able to use a secondary display to view in-game information. I understand that trying to extend the game's interface across multiple displays would be a big task, so my plan was to SSH into the desktop running the game and use a text-based "GUI" interface in the shell which could display additional information outside of the normal HUD (available missions from the intel tab maybe).

Perhaps this terminal-based application could be expanded with multiple pages and even the ability to accept inputs and manage inventories. Does this sound like something worth investigating?

Hi! Hmm. I think where you might run into trouble would be communicating between the game and this separate process. You'd need a mod to run on the game-side, naturally, but the game's classloader blocks most of the stuff in java.io for some basic safety/security reasons. So you'd probably need to communicate using various methods in SettingsAPI that let you read/write stuff in the saves/common folder (i.e. readTextFileFromCommon, deleteTextFileFromCommon, etc).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 13, 2019, 10:14:29 AM
I'm a CS student interested in developing a small mod for Starsector to help learn Java and wanted to know if it was at least a feasible idea. I want to be able to use a secondary display to view in-game information. I understand that trying to extend the game's interface across multiple displays would be a big task, so my plan was to SSH into the desktop running the game and use a text-based "GUI" interface in the shell which could display additional information outside of the normal HUD (available missions from the intel tab maybe).

Perhaps this terminal-based application could be expanded with multiple pages and even the ability to accept inputs and manage inventories. Does this sound like something worth investigating?
I think using modding to study language is much harder, because not only you have to understand the language itself, but also all the APIs and systems used by the game, i would suggest making a standalone java application instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on September 13, 2019, 11:25:07 AM
Does the hull frequency in a faction file need to be a integer? Can I put 0.5 as a value? How is the frequency calculated? If I want ships from a blueprint set (rsf_bp4) to be really rare, will the below be OK?

    "hullFrequency":{
        "tags":{"rsf_bp1":8,"rsf_bp2":4,"rsf_bp3":2, "rsf_bp4":1
        },
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 13, 2019, 04:14:23 PM
I am trying to make a MIRV style missile, there was no problem when i added the first part of it (main gun and main missile), but when i added the second stage weapon and missile something went wrong, looks like there is a problem with the projectile of the second stage, but i can't figure out what, I am triple checking the ids and can't find out what is wrong.

This crash happens right as the game begins loading
Code
5959 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.loading.specs.N.setProjectileSpec(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.WeaponSpecLoader.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.?O0000(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

What could be the problem here? The stack trace is not giving me many tips.

--- edit ---

found out, typed "KPF_" instead of "KFP_", i guess i should have named everything "Kinetic_Field_Projector_" instead
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SHAD0Wdump on September 13, 2019, 11:27:56 PM
I'm looking to re-create the pre-nerf terminator drone, back when it was an absolute nightmare. But I can't remember exactly what it had.

 I think it had phase cloak, phase skimmer, and an ion pulser, but I'm not sure about that, let alone the stats or any potential special AI treatment.

 I'd try getting an old version of starsector to take a look myself, but my internet situation is stuck on mobile and I really need to ration out my hotspot usage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on September 14, 2019, 12:08:40 AM
Does the hull frequency in a faction file need to be a integer? Can I put 0.5 as a value? How is the frequency calculated? If I want ships from a blueprint set (rsf_bp4) to be really rare, will the below be OK?

    "hullFrequency":{
        "tags":{"rsf_bp1":8,"rsf_bp2":4,"rsf_bp3":2, "rsf_bp4":1
        },

Yes, it takes fractions. If this is a faction that doesn't have access to other ships, what you posted should work too though.


I'm looking to re-create the pre-nerf terminator drone, back when it was an absolute nightmare. But I can't remember exactly what it had.

 I think it had phase cloak, phase skimmer, and an ion pulser, but I'm not sure about that, let alone the stats or any potential special AI treatment.

 I'd try getting an old version of starsector to take a look myself, but my internet situation is stuck on mobile and I really need to ration out my hotspot usage.

No phase skimmer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 14, 2019, 12:49:49 AM
Is there a way to disable the storage submarket monthly fee for a particular market/storage?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2019, 09:50:24 AM
Is there a way to disable the storage submarket monthly fee for a particular market/storage?

Indirectly, I think so - if you add an EconomyTickListener to getListenerManager(), and then find the storage node in the monthly report and adjust it accordingly (i.e. by figuring out the storage fee you want to exclude and subtracting it from that node's "upkeep", I think that should do it.

You'd want to do it in reportEconomyTick() (and subtract a tenth of the fee each time, i.e. whatever was added during this tick), since reportEconomyMonthEnd() in EconomyTickListener actually gets called *after* the monthly report is generated and applied. (Which, this ordering seems bad, and isn't intentional, but that's how it currently is.)

See CoreScript.reportEconomyTick() (search for "storageFraction") to see exactly how the fee is calculated so you can subtract it.

You could also get around the fee entirely using market.setPlayerOwned(true) but that's... probably not a great idea. IIRC there are a few unhandled cases for a "non-player-faction-market-that's-player-owned". Plus the player would be able to build on it etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SHAD0Wdump on September 14, 2019, 01:04:07 PM
I'm looking to re-create the pre-nerf terminator drone, back when it was an absolute nightmare. But I can't remember exactly what it had.

 I think it had phase cloak, phase skimmer, and an ion pulser, but I'm not sure about that, let alone the stats or any potential special AI treatment.

 I'd try getting an old version of starsector to take a look myself, but my internet situation is stuck on mobile and I really need to ration out my hotspot usage.

No phase skimmer.
Ah ok, I guess it was just so fidgetty that it gave that impression
 Anyone know if the current stats are similar? Obviously not the phase cloak stats.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 14, 2019, 05:58:54 PM
Is there any mod that uses EveryFrameCombatPlugin or EveryFrameWeaponEffectPlugin to change the AI behaviour of a single ship? I want to see an example.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 15, 2019, 02:35:51 AM
If I wanted a fleet created by a RouteFleetSpawner to go straight to its destination instead of chasing down random enemy fleets, how would I do it? Is there a part of RouteFleetAssignmentAI that I should change?

You'd probably want to override addLocalAssignment, addStartingAssignment, addTravelAssignment, and addEndingAssignment to ... basically do the same thing they're doing, but using one of the DELIVER_* assignments to move them around - which makes a fleet move somewhere and not chase unless the enemy fleet overlaps.

Could also set $isTradeFleet to true in the fleet's memory, but that may have some undesired side effects.

Let me make a note to add another flag that does this w/o flagging it as a trader, since this seems to come up a fair bit.
This didn't seem to be working for me; my invasion fleet kept blundering around the system instead of heading to its objective.
I found out that this was because the MilitaryResponseScript was butting in and giving it PATROL_SYSTEM and GO_TO_LOCATION assignments.

So: Can I just remove the MEMORY_KEY_WAR_FLEET from the fleet to make it not do this? Will this have any undesired effects on autoresolved battles or anything like that?
(What does it even do, anyway? I copied it because the punitive expedition and Hegemony inspection fleets use it.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HeroMcBadGuy on September 15, 2019, 04:09:59 AM
I want to create Blueprints for Ship Hulls already in the game, but havent really found much usefull information on it.
Where do I find the Blueprints in the Starsector files/How can I add new ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on September 15, 2019, 04:51:09 AM
>Starsector 0.9.1a RC6\starsector-core\data\campaign\special_items.csv
to make specific blueprint set
>Starsector 0.9.1a RC6\starsector-core\data\hulls\ship_data.csv\
need change ships hull to new set
rare_bp is as I belive setup for single ship blueprint


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on September 15, 2019, 04:58:02 AM
So, I'm trying to make a new industry that produces a defective Hermes every month. I want it to work like tech-mining - you get a production report every 1st of the month and have items delivered to your preferred planet.

So far I have: (disclaimer, zero programming experience incoming)

Code
    @Override
    public CargoAPI generateCargoForGatheringPoint(java.util.Random random) {
           
            CargoAPI finds = Global.getFactory().createCargo(true);
            if (finds != null) {
                finds.addMothballedShip(FleetMemberType.SHIP, "hermes_d_Hull", null);
                /* finds.initMothballedShips("player"); */
                finds.addCommodity(Commodities.SUPPLIES, 5);
                finds.addFuel(5);
            }

return finds;
    }
This does produce supplies and fuel the way it should, but no ship ever appears. Neither the production report, nor the storage of the targeted planet have it. Uncommenting the init line doesn't change anything (what does it even do?).
What am I doing wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HeroMcBadGuy on September 15, 2019, 06:13:28 AM
>Starsector 0.9.1a RC6\starsector-core\data\campaign\special_items.csv
to make specific blueprint set
>Starsector 0.9.1a RC6\starsector-core\data\hulls\ship_data.csv\
need change ships hull to new set
rare_bp is as I belive setup for single ship blueprint

so if I added this line to the special_items.csv :

x Blueprint Package,x_package,package_bp,,40000,1000,1,graphics/icons/cargo/blueprint_hightech.png,ui_chip_pickup,ui_bp_package_drop,com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,hightech_bp,"Enables heavy industry to construct the x ship hulls and fighter LPCs from the x Fleet.",290

and i change the tag from the shiphulls/fighters I want in the package in the ship_data.csv to:
x_package
That would be all I need to do?
Also if ships already have tags, how can you give them multiple tags?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on September 15, 2019, 06:34:59 AM
probably should work
hightech_bp at the end - you probably need to change it x_package_bp
Quote
Also if ships already have tags, how can you give them multiple tags?
no idea
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HeroMcBadGuy on September 15, 2019, 06:53:15 AM
probably should work
hightech_bp at the end - you probably need to change it x_package_bp
Quote
Also if ships already have tags, how can you give them multiple tags?
no idea
Sadly it doesnt work

For context now, I tried to create a [REDACTED] Blueprint package.
With commands i can spawn in the package, but it is empty, and "all Blueprints in package are already known"
I checked under the doctrine&blueprints section, no [REDACTED] Bluprints.
Not the fighters, and not the shiphulls
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 15, 2019, 07:04:22 AM
Does anyone know how to use EveryFrameCombatPlugin or EveryFrameWeaponEffectPlugin to alter the AI of a ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2019, 10:12:04 AM
This didn't seem to be working for me; my invasion fleet kept blundering around the system instead of heading to its objective.
I found out that this was because the MilitaryResponseScript was butting in and giving it PATROL_SYSTEM and GO_TO_LOCATION assignments.

So: Can I just remove the MEMORY_KEY_WAR_FLEET from the fleet to make it not do this? Will this have any undesired effects on autoresolved battles or anything like that?
(What does it even do, anyway? I copied it because the punitive expedition and Hegemony inspection fleets use it.)

You could set FLEET_NO_MILITARY_RESPONSE in the fleet. MEMORY_KEY_WAR_FLEET makes it behave like a combat fleet without the additional things a patrol does (such as, say, stopping transponder-off players, iirc).

For a bit more info, see MiltiaryResponseScript.couldRespond(CampaignFleetAPI fleet) and isTemporarilyNotResponding


probably should work
hightech_bp at the end - you probably need to change it x_package_bp
Quote
Also if ships already have tags, how can you give them multiple tags?
no idea
Sadly it doesnt work

For context now, I tried to create a [REDACTED] Blueprint package.
With commands i can spawn in the package, but it is empty, and "all Blueprints in package are already known"
I checked under the doctrine&blueprints section, no [REDACTED] Bluprints.
Not the fighters, and not the shiphulls

This should indeed work.

Remnant Blueprint Package,rem_package,"package_bp, no_drop",,1000000,1000,1,graphics/icons/cargo/blueprint_basic.png,ui_chip_pickup,ui_bp_package_drop,
com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,remnant,Remnant blueprints.,270
https://imgur.com/a/p832ogH

To get an icon to show, add one to settings.json in "blueprint_packages".

As far as adding tags - you could either provide overrides for all the ships involved using ship_data.csv (not great because it's incompatible with other mods doing anything similar), or add them using code, in ModPlugin.onApplicationLoad(), using Global.getSettings().getAllShipHullSpecs(). The latter is what I'd do here.


So, I'm trying to make a new industry that produces a defective Hermes every month. I want it to work like tech-mining - you get a production report every 1st of the month and have items delivered to your preferred planet.

So far I have: (disclaimer, zero programming experience incoming)

Code
    @Override
    public CargoAPI generateCargoForGatheringPoint(java.util.Random random) {
           
            CargoAPI finds = Global.getFactory().createCargo(true);
            if (finds != null) {
                finds.addMothballedShip(FleetMemberType.SHIP, "hermes_d_Hull", null);
                /* finds.initMothballedShips("player"); */
                finds.addCommodity(Commodities.SUPPLIES, 5);
                finds.addFuel(5);
            }

return finds;
    }
This does produce supplies and fuel the way it should, but no ship ever appears. Neither the production report, nor the storage of the targeted planet have it. Uncommenting the init line doesn't change anything (what does it even do?).
What am I doing wrong?

Ahh, it looks like you're doing everything right, but the game actually doesn't handle ships being added this way - custom production works entirely differently, and this bit is set up to only handle cargo. Added that capability to it, but in the meantime, I think you could actually add the ship directly to the gathering point's cargo. To get the market, you'd do:

MarketAPI target = Global.getSector().getPlayerFaction().getProduction().getGatheringPoint()

Then you'd need to get whatever submarket you wanted to add the ship to. So something like:
CargoAPI targetCargo = Misc.getStorageCargo(target).

Remember to check that target and targetCargo aren't null before trying to use them/get the submarkets/etc.


Does anyone know how to use EveryFrameCombatPlugin or EveryFrameWeaponEffectPlugin to alter the AI of a ship?

I'm not sure if there's a good example in the modiverse; if there is then hopefully someone will chime in. (Please don't double-post, btw...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 15, 2019, 11:53:36 AM
i remember seeing someone posting that he managed to generate random/procedural 'bonus' into inner of star systems (planets / objects etc.)

is there any sample of it ? like it would be nice to be able get additional stuff like

asteroid fields, rings, nebulas or similar elements within the systems (some can be quite sparse and empty)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 15, 2019, 02:37:06 PM
Work has stuttered on my custom hullmod for my support ship mod, and due to anxiety I've held off on asking here again for help, since I suspect my issues are basic AF and I generally don't know Java. The error from the end of the .log is as follows:
Quote
34137 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.hullmods.SignalSong]
java.lang.RuntimeException: Error compiling [data.hullmods.SignalSong]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.SignalSong'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.hullmods.SignalSong' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more
As a rather Java-ignorant person, how might I go about solving this? I've included the link to the hullmod script, which is here: https://pastebin.com/KhzQtGWi (https://pastebin.com/KhzQtGWi)
I modified the DriveFieldStabilizer hullmod file to create this, and also dug around in the API's .zip. Help would be appreciated, and I'm sorry for asking about something probably so simple.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2019, 03:00:27 PM
Work has stuttered on my custom hullmod for my support ship mod, and due to anxiety I've held off on asking here again for help, since I suspect my issues are basic AF and I generally don't know Java. The error from the end of the .log is as follows:
Quote
34137 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.hullmods.SignalSong]
java.lang.RuntimeException: Error compiling [data.hullmods.SignalSong]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.SignalSong'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.hullmods.SignalSong' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more
As a rather Java-ignorant person, how might I go about solving this? I've included the link to the hullmod script, which is here: https://pastebin.com/KhzQtGWi (https://pastebin.com/KhzQtGWi)
I modified the DriveFieldStabilizer hullmod file to create this, and also dug around in the API's .zip. Help would be appreciated, and I'm sorry for asking about something probably so simple.

So this is actually, I think, Janino (the 3rd party compiler Starsector uses to compile loose scripts) being really obstinate about what it will and won't compile.

I suspect that changing this:
public static final float BURN_BONUS = 4;

To this:
public static final float BURN_BONUS = 4f;

Will do the job. What you have *should* work, but, Janino.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 15, 2019, 03:03:30 PM
Work has stuttered on my custom hullmod for my support ship mod, and due to anxiety I've held off on asking here again for help, since I suspect my issues are basic AF and I generally don't know Java. The error from the end of the .log is as follows:
(error)
As a rather Java-ignorant person, how might I go about solving this? I've included the link to the hullmod script, which is here: https://pastebin.com/KhzQtGWi (https://pastebin.com/KhzQtGWi)
I modified the DriveFieldStabilizer hullmod file to create this, and also dug around in the API's .zip. Help would be appreciated, and I'm sorry for asking about something probably so simple.
Which IDE are you using to compile? Maybe there is a problem in the build path.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2019, 03:08:19 PM
Oh, actually, yes, that's another issue!

The first line in your code says:
package com.fs.starfarer.api.impl.hullmods;

It ought to say:
package data.hullmods;

Since apparently (based on the compilation error) that's where the file is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 15, 2019, 03:16:07 PM
Oh! Wow, I really can't believe I missed that. Thank you!

Edit: It compiles properly, and now it's crashing because of the following, which is way too long to just post as a quote in an edit to a comment: https://pastebin.com/mxKCedgd (https://pastebin.com/mxKCedgd)
The core issue is myFleet not being a variable or type, so I'll have to keep digging around in the API for what I CAN call to refer to a fleet with a ship using the hullmod in it, provided such a way exists. Hints or tips would be appreciated. And, to end this edit off, thank you Ed and Alex for your assistance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 15, 2019, 05:07:21 PM
I'll have to keep digging around in the API for what I CAN call to refer to a fleet with a ship using the hullmod in it, provided such a way exists.
Would this work for your purposes?
Code
public class MyHullMod extends BaseHullMod {
    @Override
    public void advanceInCampaign(FleetMemberAPI member, float amount) {
        member.getFleetData().getFleet()
    }

    // ...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 15, 2019, 05:08:28 PM
Since i can't figure out the previous question I am trying a different approach

I am trying to add this code to the AI of my ship (Rottweiler)

[rottweiler_AI.java]:
Code
@Override
    public void advance(float amount) {   
    tracker.advance(amount);

        if (tracker.intervalElapsed()) {
            if (ship.getFluxTracker().isOverloadedOrVenting()) {
                return;
            }           
            if (module != null) {
            if (module.getShield() != null && module.getShield().isOn()) {
                if ((module.getFluxLevel() <= 0.5f && ship.getFluxLevel() >= 0.5f) || ship.getHardFluxLevel() >= 0.8f) {
                ship.giveCommand(ShipCommand.VENT_FLUX, null, 0);
                    }
                    return;
                }
            }                       
        }
        return;
    }

I am trying this through the Plugin Pick

[ED_modPlugin.java]:
Code
@Override
    public PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship) {
    switch (ship.getId()) {
        case ROTTWEILR_ID:
            return new PluginPick<ShipAIPlugin>(new rottweiler_AI(ship), CampaignPlugin.PickPriority.HIGHEST);
        default:
    }
    return null;
    }

(edit) btw i use a switch here because i expect to replace other AIs later, so i already made it like this.

But nothing happens, the ship acts like usual and ignores the Override, also is this supposed to completely replace the normal ship AI? because i would like to ADD this code to the AI instead of replace (which would cause the ship to stop moving and attacking/etc...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 15, 2019, 05:19:19 PM
Unfortunately, it didn't work, Sundog. Here's the end of the log:
Quote
java.lang.RuntimeException: Error compiling [data.hullmods.SignalSong]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.SignalSong'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/SignalSong.java', Line 13, Column 40: Expression "member.getFleetData().getFleet()" is not a type
   at org.codehaus.janino.Java$Located.throwCompileException(Java.java:111)
   at org.codehaus.janino.Java$Atom.toTypeOrCompileException(Java.java:2687)
   at org.codehaus.janino.Parser.parseBlockStatement(Parser.java:1157)
   at org.codehaus.janino.Parser.parseBlockStatements(Parser.java:1085)
   at org.codehaus.janino.Parser.parseMethodDeclarationRest(Parser.java:938)
   at org.codehaus.janino.Parser.parseClassBodyDeclaration(Parser.java:565)
   at org.codehaus.janino.Parser.parseClassBody(Parser.java:515)
   at org.codehaus.janino.Parser.parseClassDeclarationRest(Parser.java:481)
   at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:269)
   at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:168)
   at org.codehaus.janino.JavaSourceIClassLoader.findCompilationUnit(JavaSourceIClassLoader.java:203)
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:146)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 15, 2019, 05:21:50 PM
Are you using raw java files or compiling them into a jar? Even if you are making something simple it is always better to make a jar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 15, 2019, 05:22:49 PM
Raw java. I'll go ahead and compile it into a jar!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 15, 2019, 05:25:24 PM
Raw java. I'll go ahead and compile it into a jar!
I recommend using Eclipse, the guide is a bit outdated, but works, i did it this way, also get java 7 instead of the most current one

http://fractalsoftworks.com/forum/index.php?topic=4344.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 15, 2019, 06:03:29 PM
Welp. Eclipse literally won't launch, and I was unable to download Java 7.
(https://i.imgur.com/uv3tm4m.png)
So there goes compiling it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 15, 2019, 06:10:55 PM
Welp. Eclipse literally won't launch, and I was unable to download Java 7.
[image]
So there goes compiling it.
Looks like your Eclipse can't find your Java JDK, you need to point out manually
https://stackoverflow.com/questions/13635563/setting-jdk-in-eclipse
-edit-
oh yeah if you can't run eclipse you can't change the path, silly me, do it by the eclipse.ini (same folder as the executable)
https://stackoverflow.com/questions/23174265/how-to-specify-jdk-path-in-eclipse-ini-on-windows-8-when-path-contains-space
Get the JDK here (Java SE Development Kit 7u80)
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 15, 2019, 07:59:27 PM
Code
switch (ship.getId()) {
ship.getId() will return a unique identifier for that ship instance, not the hull type. You'll want to use ship.getHullSpec().getHullId()

Unfortunately, it didn't work, Sundog.
It looks like that might just be because you need a semicolon at the end of the line I gave you. Not sure though. I also second Ed's suggestion about using an IDE. I like IntelliJ.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 15, 2019, 08:35:26 PM
Oh that explains why getId didn't work, but in the end it was not the correct solution for what i wanted, i managed to get the actual hullID after studying the code from the Imperium's Titan missile and managed to replace the AI, but what i needed was just adding a few lines of code to an existing default AI, not fully replacing it, so i gave up on this method.
In the end i changed the AI by making a custom ship system.

At leeast now I get why getId() doesn't work, it was not the first time i had problems with it, thanks Sundog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HeroMcBadGuy on September 16, 2019, 04:07:29 AM
Remnant Blueprint Package,rem_package,"package_bp, no_drop",,1000000,1000,1,graphics/icons/cargo/blueprint_basic.png,ui_chip_pickup,ui_bp_package_drop,
com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin,remnant,Remnant blueprints.,270
https://imgur.com/a/p832ogH

To get an icon to show, add one to settings.json in "blueprint_packages".

As far as adding tags - you could either provide overrides for all the ships involved using ship_data.csv (not great because it's incompatible with other mods doing anything similar), or add them using code, in ModPlugin.onApplicationLoad(), using Global.getSettings().getAllShipHullSpecs(). The latter is what I'd do here.

while changing the tags of the remnant ships to match the blueprint didn´t work ,
writing the bluprint id to match the ships worked... strange

either way thanks for the help Sarissofoi and Alex
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 16, 2019, 01:39:07 PM
Right. I should clarify, I'm using Microsoft Visual Studio 2017 to work on the mod, as I have it already set up from a college coding class. I'll look online for ways to compile the mod as a jar in VS, and also your suggested methods. As for the semicolons, adding them didn't solve the issue either - still getting the same crash error in the log.
Quote
37174 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.hullmods.SignalSong]
java.lang.RuntimeException: Error compiling [data.hullmods.SignalSong]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.SignalSong'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/SignalSong.java', Line 13, Column 40: Expression "member.getFleetData().getFleet()" is not a type
   at org.codehaus.janino.Java$Located.throwCompileException(Java.java:111)
   at org.codehaus.janino.Java$Atom.toTypeOrCompileException(Java.java:2687)
   at org.codehaus.janino.Parser.parseBlockStatement(Parser.java:1157)
   at org.codehaus.janino.Parser.parseBlockStatements(Parser.java:1085)
   at org.codehaus.janino.Parser.parseMethodDeclarationRest(Parser.java:938)
   at org.codehaus.janino.Parser.parseClassBodyDeclaration(Parser.java:565)
   at org.codehaus.janino.Parser.parseClassBody(Parser.java:515)
   at org.codehaus.janino.Parser.parseClassDeclarationRest(Parser.java:481)
   at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:269)
   at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:168)
   at org.codehaus.janino.JavaSourceIClassLoader.findCompilationUnit(JavaSourceIClassLoader.java:203)
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:146)
   ... 7 more
I'm sorry to keep bothering you all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 16, 2019, 01:54:20 PM
No worries. Maybe post the code you're trying to run? I'm not sure exactly what that error is trying to say. That line shouldn't cause janino any trouble, so my guess is that there's a syntax error somewhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 16, 2019, 02:01:28 PM
Sure thing.
Quote
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.fleet.MutableFleetStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class SignalSong extends BaseHullMod {

   @Override
    public void advanceInCampaign(FleetMemberAPI member, float amount) {
        member.getFleetData().getFleet()
    };

   public static final float BURN_BONUS = 4f;
   
   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
      stats.getDynamic().getMod(Stats.FLEET_BURN_BONUS).modifyFlat(id, BURN_BONUS)
   };
   

   public void applyEffectsBeforeShipCreation(HullSize hullsize, MutableFleetStatsAPI stats, String id) {
      getStats().getSensorStrengthMod().modifyPercent("viennasignal", 150f, "Signal Song");
      getStats().getSensorProfileMod().modifyPercent("viennasignal", 50f, "Signal Song");
      getStats().getSensorRangeMod().modifyPercent("viennasignal", 150f, "Signal Song");
      getStats().getDetectedRangeMod().modifyPercent("viennasignal", 50f, "Signal Song");
   };
   
   public String getDescriptionParam(int index, HullSize hullSize) {
      if (index == 0) return "" + (int) BURN_BONUS;
      return null;
   }

}
It's a hullmod for a support ship that's supposed to boost the fleet burn level, sensor strength, and sensor range, while decreasing the fleet sensor profile and detection range. It doesn't help that I'm new to modding Starsector outside of using Deathfly's update to the ship editor and basic weaponry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 16, 2019, 02:20:57 PM
Looks like you've got a few misplaced semicolons. For example,
Code
   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
      stats.getDynamic().getMod(Stats.FLEET_BURN_BONUS).modifyFlat(id, BURN_BONUS)
   };
should look like this:
Code
   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
      stats.getDynamic().getMod(Stats.FLEET_BURN_BONUS).modifyFlat(id, BURN_BONUS);
   }

The line I gave you here:
Code
member.getFleetData().getFleet()
Has the same problem with a missing semicolon, but it also doesn't do anything on it's own. I was just showing you how to access the information you requested.

Your IDE should be able to point all this out to you, and, as far as I know, VS doesn't support Java at all. It might be possible to force it to with extensions, but that would likely be both more difficult and less effective than using an IDE with native support.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 16, 2019, 02:25:02 PM
Right! Thank you! I really appreciate all your help, and again, sorry to ask about this stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 16, 2019, 02:37:46 PM
Sure, no problem! And really, don't worry about it. No one learns this stuff without doing their fair share of fumbling.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 16, 2019, 02:42:24 PM
Well. That would do it when it comes to issues understanding things. I had the C++ development kit installed for VS, not the universal one that includes Javascript, and subsequently allows extensions for Java itself. That should make my life significantly easier.

Edit: Installing Visual Studio Code instead since VS itself isn't able to do Java, whereas VSC has extensions for Java itself. I can actually work now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 16, 2019, 04:22:13 PM
I got it all working, and fixed it all! Thank you all so much!

Edit: Mod works relatively. However, when pressing 'f' to modify the fleet AFTER adding the support ship causes the game to crash. Link to the end of the log here: https://pastebin.com/ebX8nWVH (https://pastebin.com/ebX8nWVH)
And a link to the hullmod file here: https://pastebin.com/Rkt4izJZ (https://pastebin.com/Rkt4izJZ)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Justedd233 on September 16, 2019, 05:37:46 PM
I have a quick two-part question about adding things to a Vanilla playthrough without disturbing my save.

#1: Is it possible to add, or replace, a flag for the player custom faction without disturbing my save?

#2: Is it possible to add custom variants of Vanilla ships (the Eagle, for example) with a different skin? Purely a cosmetic change for just my fleet. Again, without disturbing my existing save game.

I apologize if this question has been explained before, but I specifically need to know if it'll work with my existing save.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 16, 2019, 06:33:41 PM
I got it all working, and fixed it all! Thank you all so much!

Edit: Mod works relatively. However, when pressing 'f' to modify the fleet AFTER adding the support ship causes the game to crash. Link to the end of the log here: https://pastebin.com/ebX8nWVH (https://pastebin.com/ebX8nWVH)
And a link to the hullmod file here: https://pastebin.com/Rkt4izJZ (https://pastebin.com/Rkt4izJZ)

Code
member.getFleetData().getFleet().getStats().getSensorStrengthMod().modifyPercent("viennasignal", 50f, "Signal Song");
Looks like this line is the problem, something in there is null, do a null check on both "viennasignal" and "Signal Song"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Taitou on September 16, 2019, 07:04:09 PM
Solved it. Just commented out the @Override.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArnaudB on September 17, 2019, 02:04:32 AM
I haven't found an answer to my problem and nobody saw or responded to my query the last time, I'll try again.

Does somebody know how to make exotic resources appears in randomized generated sectors? In the default sector exotic resources like Volturn or liquids from Hazard Mining Incorporated appear, but never in randomized. Is there some way to make them appear during sector generation, or even after?

Alternatively, I'd settle for some way of getting rid of trade missions asking me for goods that aren't produced anywhere in the sector.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 17, 2019, 05:12:24 AM
I haven't found an answer to my problem and nobody saw or responded to my query the last time, I'll try again.

Does somebody know how to make exotic resources appears in randomized generated sectors? In the default sector exotic resources like Volturn or liquids from Hazard Mining Incorporated appear, but never in randomized. Is there some way to make them appear during sector generation, or even after?

Alternatively, I'd settle for some way of getting rid of trade missions asking me for goods that aren't produced anywhere in the sector.
Random sector unusual commodities rely on Nexerelin to code them to appear (or the originating mod to do some hacks to make them appear, but that's not recommended unless the modder knows what they're doing).
- Lobsters will be produced if a water world is populated by the generator at start, but there's no guarantee there'll be one available for this.
- HMI stuff isn't handled at present.

Making the procurement mission not ask for commodities that nobody produces could be done in Nex. (Although would that break Scy's intel data chips? I'd have to check.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mar Sara on September 17, 2019, 11:25:16 AM
Anyone happen to know what memory keys prevent new intell during the tutorial? I've looked over the files in the api, but can't seem to find it.  I'm trying to add an event that temporarily cuts off a system from hyperspace and spawns a [REDACTED] fleet that must be killed to reconnect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2019, 11:29:21 AM
See:
public static boolean isTutorialInProgress() {
   return Global.getSector().getMemoryWithoutUpdate().contains(CampaignTutorialScript.USE_TUTORIAL_RESPAWN);
}

Not great for what you want, though, since it has other side effects. But you wouldn't be getting intel unless there's a comm relay in the system, or it's "get anywhere" (such as an update about a punitive expedition) intel. So it might make more sense to turn off any comm relay(s) in system to stop new intel, I think, via:

relay.getMemoryWithoutUpdate().set(MemFlags.OBJECTIVE_NON_FUNCTIONAL, true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mar Sara on September 17, 2019, 04:57:01 PM
Ah, I see. Well, I was planning to set the relays to nonfunctional  anyway, I'll just have to check frequently to make sure the player didn't try to pull a fast one and deconstruct / reconstruct to bypass it. Thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 17, 2019, 06:04:05 PM
What is it about the person bounty fleets that keeps them from being purged/deflated when the player is not in the same system? I'm trying to add a fleet to a distant system, but it seems to be disappearing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2019, 06:07:57 PM
They're not created from a "route", so they don't disappear for that reason. Also, possibly:

fleet.getAI().addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, hideoutLocation, 1000000f, null);

If a fleet runs out of assignments,  depending on what its assignment AI is (if any), it may go somewhere random and despawn; I'm not actually 100% sure offhand.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on September 17, 2019, 06:14:30 PM
Ok, thanks Alex. I just went to copy the code I use to create the assignments so I could post it here and I realized I was using the wrong market in some places, so I'll see if fixing that makes them stop disappearing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 17, 2019, 08:29:40 PM
So, a while ago I asked for assistance with setting up a custom fleet inflater to be able to control the rate at which certain fighters might spawn in the campaign, at which point I sort of quickly kludged together a sort of mashup of the weapon and fighter picking sections to try and deal with the problem. However, after extensive testing (including figuring out that I had forgotten to include the plugin pick at one point, a problem since resolved) I'm not sure it's working.

Ultimately this functionality is a lot more abstract than what I normally work with, so I figured I might as well ask to get some eyes on my kludged together uh... solution and see, well, what's what.

E: Apparently spoilers and code don't work together? While it seems to be working fine for me, I'll despoilerize this so everyone can read it. Sorry bout the mess.

Code: java
    public static float getFighterProbability(FighterWingSpecAPI spec) {
        if (spec.getId().contains("ms_shikome")) {
            return 0.005f;
        }
       
        return 1f;
    }

    @Override
    public void inflate(CampaignFleetAPI fleet) {
        ...
       
            fighters = new ArrayList<>();
            for (String cat : fighterCategories) {
                for (String wingId : faction.getKnownFighters()) {
                    FighterWingSpecAPI spec = Global.getSettings().getFighterWingSpec(wingId);
                    float p = getFighterProbability(spec);                   
                    if (this.p.allWeapons != null && this.p.allWeapons) {
                        p = 1f;
                    }

                    if (random.nextFloat() >= p) continue;

                    int num = 4;

                    if (this.p.allWeapons != null && this.p.allWeapons) {
                        num = 100;
                    }
               
                    List<AvailableFighter> priority = priorityFighters.get(cat);
               
                    boolean madePriorityPicks = false;
                    if (priority != null) {
                        if (this.p.allWeapons != null && this.p.allWeapons) {
                            num = 100;
                        }
                   
                        Set<Integer> picks = makePicks(num, priority.size(), random);
                        for (Integer index : picks) {
                            AvailableFighter f = priority.get(index);
                            fighters.add(f);
                            madePriorityPicks = true;
                        }
                    }
               
                    if (!madePriorityPicks) {
                        if (this.p.allWeapons != null && this.p.allWeapons) {
                            num = 100;
                        }
                   
                        List<AvailableFighter> nonPriority = nonPriorityFighters.get(cat);
                        Set<Integer> picks = makePicks(num, nonPriority.size(), random);
                        for (Integer index : picks) {
                            AvailableFighter f = nonPriority.get(index);
                            fighters.add(f);
                        }
                    }
                }
            }
       
        ...
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superbob on September 18, 2019, 06:29:09 PM
I am trying to modify some of the skill effects. So far, I have:

copied the skill *.java files into a fresh directory
tweaked their numbers in notepad++
changed the first line of them to read: package skillmod.campaign.skills
opened them as a project in netbeans
added starsector.api.jar as a library
clean and build in netbeans
copied the resulting skillmod.jar into the folder /mods/skillmod/jars
copied the corresponding  *.skill files into the /mods/skillmod/data/character/skills folder, changed some text to "script":"skillmod.campaign.skills.****" where appropriate
in the mod_info.json file, added lines for the corresponding .skill file in the replace list

Most of this I got from the netbean tutorial, or from looking at Darloths skill rework mod as an example

The result is that when I try to start playing with this mod, I get a message:
Fatal: skillmod/campaign/skills/FleetLogistics$Level1B: unsupported major.minor version 56.0
Check starsector.log for more info

I tried remaking the mod without the Fleet Logistics skill, but the same message popped up with a different skill listed as the culprit.

I am not familiar with java, and I would appreciate any help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 18, 2019, 08:02:24 PM
@MShadowy: nothing jumps out at me as being wrong. I'm assuming you've tried spawning a ton of fleets to verify whether this is working or not? If not, I'd give that a go.

The result is that when I try to start playing with this mod, I get a message:
Fatal: skillmod/campaign/skills/FleetLogistics$Level1B: unsupported major.minor version 56.0

This error means that the jar you've compiled is for a different (higher) version of Java than the game runs. Set your compile target to jre7/Java 7/whatever Netbeans calls it; you might need to download and install Java 7 if it's not already on your system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superbob on September 19, 2019, 05:19:31 AM
This error means that the jar you've compiled is for a different (higher) version of Java than the game runs. Set your compile target to jre7/Java 7/whatever Netbeans calls it; you might need to download and install Java 7 if it's not already on your system.

Thank you for this, but it leads to a new difficulty:

I am following the instructions here: https://netbeans.org/kb/73/java/javase-jdk7.html (https://netbeans.org/kb/73/java/javase-jdk7.html)
I was able to download JDK7 here: https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html (https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html)
When I try to add it to netbeans, it is able to find the platform source (src.zip), but there is red text at the bottom, "Cannot detect and install the selected platform. The java or javac may not be executable."

I suspect the issue may be that the next field asking for the platform javadoc is empty. The instructions that I am following say that that line should either be a url, or a javadoc jar that I download. Unfortunately, the links to both on that page are broken, and googling isn't turning up anything that works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2019, 07:41:12 AM
Hmm - did you actually install jdk7? If so, can you try going to its bin/ folder and running the java executable? Probably from command line so you can see if it comes back with anything weird.

I'm not real familiar with netbeans; in eclipse you just point it to the folder it's installed in and it's good to go. I'd imagine it's the same for netbeans, so it sounds like something may have gone wrong with the install? Not sure, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on September 19, 2019, 08:10:04 AM
I've done a fair amount of testing on it, but there a number of instances where multiple Shikomes would spawn in the same fleet, and their rate of appearance still appeared higher than I was hoping. I'm not sure if this was the code not producing the desired effect or if it was just RNG streaks, however, thus the question.

If it looks like it should be working though, then in all probability I just need to set up better logic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2019, 08:35:22 AM
With the logic as-is, you could get multiple fighters of that type on the same carrier, since the "is it available" roll happens once per ship, not once per fighter bay. You could - for this fighter - set the quantity (via AvailableFighter.setQuantity()) to 1 to prevent that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jamuro on September 19, 2019, 09:07:18 AM
Is it somehow possible to create tooltips in the intel section with the tooltipmakerui?

i am creating custom intel events that i use to track and present a lot of data ... so far the storing and retrieving of my custom data works but for presentation purposes i realy need to find a way to create tooltips of any sort.

how honestly doesn't matter at this point ... idealy it would be linked to a highlighted text from an addPara() but an image/icon would work too
if that isn't possible ... is there a way to make a popup with it's own panel/tooltipmakerapi object that a button can open maybe?

or maybe can buttons add/remove addPara() lines on the fly? to make a button that shows/hides an extended description?


Edit:
While not ideal, it looks like buttons could in theory be used to toggle the content of certain addPara() commands.
Sadly the button itself does not force an update of the ui elements ... so chnges are only visible after closing/reopening the intel screen.

In case all other options mentioned above turn out to not be feasible, is there a way to force the ui to refresh?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2019, 12:54:04 PM
Added a note about being able to add tooltips - yeah, it doesn't look like it's currently possible.

To update the UI:
public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
   ui.updateUIForItem(this);
}

Btw - if you have a ton of info you need to show, and maybe don't necessarily care about the map, "createLargeDescription()" may be worth a look, since it'll use the "map + right side" area instead of just "right side". If you do that, make sure to override hasLargeDescription() to return true or it won't be shown.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jamuro on September 19, 2019, 01:27:32 PM
Thank you Alex

the ui refreshing now works great (and i don't have to keep using the robot class to simulate the intel screen opening and closing)  ;D


i am currently adding placeholder tooltip areas that get filled via button presses.
Not as shiny as i wanted but it will probably get the job done.

And yeah i am already using the largeDescription.
I mostly want to make sure i relay the majority of the information in a compact format, with the option to get much more detailed information on demand.


Anyways ... it seems i already got another question ^^

How do i chain multiple ui elements without causing a linebreak between each of them (i want them to show up next to each other, not below)

My current goal/example is that i want to add an image and a ToolTipMakerAPI filled with multiple paragraphs (which is why i don't think i can use addImageWithText) to show up side by side.

I tried creating a ToolTipMakerAPI as wrapper, added the image and a CustomPanelAPI which in turn got the ToolTipMakerAPI that had the paragraphs of text in it, added.
Sadly it didn't go as i expected and ended up below each other again.


Spoiler
Code
            TooltipMakerAPI pictureAndTraitsSection = panel.createUIElement(width, yPictureAndTraitsSection+100, false);
            pictureAndTraitsSection.addImage(officer.getPortraitSprite(), 0);

            CustomPanelAPI officerDetailsAndTraits = panel.createCustomPanel(width-128, yPictureAndTraitsSection, null);

            TooltipMakerAPI officerDetails = officerDetailsAndTraits.createUIElement(width-128, 50, false);
            officerDetails.addPara("Name: "+officer.getNameString(), 0, Misc.getTextColor(), Misc.getHighlightColor(), "Name:");
            officerDetails.addPara("Gender: "+officer.getGender(), 0, Misc.getTextColor(), Misc.getHighlightColor(), "Gender:");
            officerDetails.addPara("Faction: "+officer.getFaction(), 0, officer.getFaction().getColor(), Misc.getHighlightColor(), "Faction:");
            officerDetailsAndTraits.addUIElement(officerDetails).inTL(0, 0);

            pictureAndTraitsSection.addCustom(officerDetailsAndTraits, 0);
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2019, 01:46:28 PM
the ui refreshing now works great (and i don't have to keep using the robot class to simulate the intel screen opening and closing)  ;D

(Ha, nice!)

My current goal/example is that i want to add an image and a ToolTipMakerAPI filled with multiple paragraphs (which is why i don't think i can use addImageWithText) to show up side by side.

I tried creating a ToolTipMakerAPI as wrapper, added the image and a CustomPanelAPI which in turn got the ToolTipMakerAPI that had the paragraphs of text in it, added.
Sadly it didn't go as i expected and ended up below each other again.

I think what you want to do here is to add the text-with-paragraphs element to the panel - and then place it where you want, using its getPosition() method (or what the add() method returns), instead of adding it to the tooltip.

I.E. something like:
panel.add(tooltipMakerWithParas).inTL(100, 10);

That would add the element in the top left ("TL"), 100 pixels to the right and 10 down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jamuro on September 19, 2019, 01:53:32 PM
oh thanks again for the quick reply.

so panels inTL() position is not limited to the scope of it's own width/height?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2019, 02:06:05 PM
It'll probably get clipped if it's inside a scroller. But for the large description, the panel is the whole area, so you should be fine regardless, I think?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jamuro on September 19, 2019, 08:07:39 PM
is it possible that the call to buttonPressConfirmed from a button click doesn't get passed on trough multiple nested layers?

i have a button, that when added to a tooltipmakerapi that is bound to the topmost CustomPanelAPI works flawlessly.
But the second i add it to my target location ... a tooltipmakerapi several layers deep it stops working.


in case someone wants to take a look, this is the method that creates the nested version of the buttons.
the same button (minus the getDescription part) taken and bound to the top layered toolkitapi works fine.

Spoiler
Code
    private TooltipMakerAPI renderOfficerTraitsPositive(CustomPanelAPI panel, float width, float height){
        TooltipMakerAPI officerPositiveTraits = panel.createUIElement(width, height, false);
        officerPositiveTraits.addSectionHeading("  Advancements", Alignment.LMID, 2);
        ArrayList<officerFlavourOfficerCustomTraits> traits = this.officerExtension.getPositiveTraits();

        float yPad = 30;
        for(int i = 0; i < traits.size(); i++){

            officerFlavourOfficerCustomTraits trait = traits.get(i);
            CustomPanelAPI traitFieldPanel = panel.createCustomPanel(width, 25, null);

            TooltipMakerAPI officerPositiveTraitNameField = traitFieldPanel.createUIElement(width-5, 20, false);
            officerPositiveTraitNameField.addPara("*  "+trait.getName(), 0, Misc.getTextColor(), Misc.getHighlightColor(), "*");
            traitFieldPanel.addUIElement(officerPositiveTraitNameField).inTL(5, 2);

            TooltipMakerAPI officerPositiveTraitNameToolTipButtonField = traitFieldPanel.createUIElement(28, 20, false);
            officerPositiveTraitNameToolTipButtonField.addButton("?", new ArrayList<String>(Arrays.asList("tooltip_traits", "test"+trait.getDescription())), 16, 18, 0);

            traitFieldPanel.addUIElement(officerPositiveTraitNameToolTipButtonField).inTR(0, 0);

            officerPositiveTraits.addCustom(traitFieldPanel, 0).getPosition().inTL(0,30+i*yPad);

        }

        return officerPositiveTraits;
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 19, 2019, 08:11:39 PM
Can someone explain to me the different types of weapon mounts? The wiki just says "pretty self explanatory" which, while correct, doesn't help at all when it comes to things like "What's Hybrid a hybrid of? Missile and Ballistic? Ballistic and Energy? Is Hybrid it's own type?"

EDIT: Apparently I'm blind when I'm tired, although there really shouldn't be an entirely unrelated paragraph between "here are the types" and "go here to see what the types mean."
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2019, 08:26:56 PM
is it possible that the call to buttonPressConfirmed from a button click doesn't get passed on trough multiple nested layers?

i have a button, that when added to a tooltipmakerapi that is bound to the topmost CustomPanelAPI works flawlessly.
But the second i add it to my target location ... a tooltipmakerapi several layers deep it stops working.


in case someone wants to take a look, this is the method that creates the nested version of the buttons.
the same button (minus the getDescription part) taken and bound to the top layered toolkitapi works fine.

Ahh, yes, looks like if you call createUIElement() on a CustomPanelAPI that was created using createCustomPanel() - rather than the one that's passed into createLargeDescription() - that won't have the proper button listener.

Fixed that up; in the meantime you could probably get away with using the top-level panel to createUIElement() from and then add the created TMAPI to another panel. The only issue you'd run into is if that TMAPI needed a scrollbar; otherwise it should be fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jamuro on September 19, 2019, 08:49:17 PM
hmm i think i understand what you are meaning ... but if i do createUIElement() on the top level CustomPanelAPI and then try to add it to the panel that is in the right location i get a null pointer exception.

i tried doing a call for both panels too and depending on the order i either get the null pointer crash or the buttons don't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2019, 08:55:08 PM
Looking again, yeah, that would indeed NPE - apologies. Looks like the only workaround at this point is to add them to the topmost panel, as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jamuro on September 19, 2019, 09:07:17 PM
yeah that seems to be working ... i might have to redo the page so it just uses one CustomPanelAPI, or at least keep it in mind for future ones.
honestly it probably is less work and easier to add elements that way anyways.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on September 20, 2019, 11:22:52 AM
How could I go about making the assembly stage of a raid fleet spawn from multiple markets with dynamicly assigned fleet points? I managed to do it to an extent by making an addStage loop for the faction's markets, but that seemed to just queue the stages making the whole process excessively long. After some expermenting I think I also managed to fix that, but then the travel stage would be aborted, maybe due to the setAbortFP value being met for some reason. Is there a way to make it work smoothly or is it too much of a hassle? I've tried messing with the stage classes too but I'm not that acquainted with the whole fleet generation process yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buff Skeleton on September 20, 2019, 11:26:16 AM
I've tooled around in the game files and searched the forums, but haven't found much on this:

Can you change the color overlay in combat for allies? I find the light orange color waaaaay too similar to the orange-red look of enemies, and I've definitely obliterated allies by accident a few times :V

Ideally I'd make allies blue and wreckage gray in the combat UI so it's crystal-clear what's what. Thanks for any pointers!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 11:41:51 AM
How could I go about making the assembly stage of a raid fleet spawn from multiple markets with dynamicly assigned fleet points? I managed to do it to an extent by making an addStage loop for the faction's markets, but that seemed to just queue the stages making the whole process excessively long. After some expermenting I think I also managed to fix that, but then the travel stage would be aborted, maybe due to the setAbortFP value being met for some reason. Is there a way to make it work smoothly or is it too much of a hassle? I've tried messing with the stage classes too but I'm not that acquainted with the whole fleet generation process yet.

There's some limited support for it via AssembleStage.addSource() but I'm not sure how well it works since the base game doesn't use multiple sources.


I've tooled around in the game files and searched the forums, but haven't found much on this:

Can you change the color overlay in combat for allies? I find the light orange color waaaaay too similar to the orange-red look of enemies, and I've definitely obliterated allies by accident a few times :V

Ideally I'd make allies blue and wreckage gray in the combat UI so it's crystal-clear what's what. Thanks for any pointers!

See: data/config/settings.json, "yellowTextColor" - that's the color used for the ally overlay.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Buff Skeleton on September 20, 2019, 11:55:13 AM
See: data/config/settings.json, "yellowTextColor" - that's the color used for the ally overlay.

Superb, thanks a bunch!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on September 20, 2019, 12:05:14 PM
There's some limited support for it via AssembleStage.addSource() but I'm not sure how well it works since the base game doesn't use multiple sources.

I did notice that but I'm not sure how much FP is assigned to each source with this. My goal is to make it scale based on, for instance, market size. Like I said, I've had some success but the raid is aborted when the raid leaves the assembly stage. The condition for the loop I implemented is that there's a FP treshold for the main source market, and when exceeded, new stages are added from other markets. I mention this because if there's only the main source fleet, the raid is not aborted in the travel stage. The aditional fleets must somehow be the culprit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 12:14:37 PM
You mentioned using addStage, though, not addSource - just to make sure this point is clear, since I also mixed those up on my initial reading of your post :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on September 20, 2019, 12:33:33 PM
Yea i did mention addStage, being the main output of the loop. A new assembly stage is defined for it too, with AddSource, SetSpawnFp, SetAbortFp, and all that. Anyway, this is just an experiment of mine. Had an idea and tried to see if I could implement it :P.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 12:37:29 PM
Just in case: yeah, what I'm saying is to try calling addSource multiple times on the same stage. IIRC it should alternate sources when spawning fleets, though it might still use the first source for fleet size multipliers. If you're already doing that, apologies; just isn't 100% clear if you are or if we're talking past each other a bit :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on September 20, 2019, 12:54:55 PM
Yea, sorry for the confusion. Maybe i will simply show the code to clarify what i have :P

AssembleStage assembleMain = new AssembleStage(this, gather);
      assembleMain.addSource(from);
      assembleMain.setSpawnFP(mainfp);
      assembleMain.setAbortFP(mainfp * successMult);



      float totalfp = mainfp;
      if (totalfp < fp) {
         for (MarketAPI market : RebFactionData.getMarketsForFaction(from.getFactionId(), true)) {
            float needed = fp - totalfp;
            float auxiliaryfp = (getPowerForMarket(market)) / (getPowerProjectionforDominance(from.getFactionId()))  * fp;
            if (auxiliaryfp > needed) auxiliaryfp = needed;

            RebAuxiliaryAssembleStage assemble = new RebAuxiliaryAssembleStage(this, gather);
            
               if (market.getId().equals(from.getId())) continue;

               assemble.addSource(market);
               assemble.setSpawnFP(auxiliaryfp);
               assemble.setAbortFP(auxiliaryfp * successMult);


               addStage(assemble);
               log.info("Auxiliary fleet in " + market.getName() + ", at fp" + assemble.getSpawnFP());
               sources.add(assemble);
               totalfp += auxiliaryfp;
               if (totalfp >= fp) {
                  
                  break;
               }
            
         }
      }
      addStage(assembleMain);
      sources.add(assembleMain);
      log.info ("Main fleet in " + from.getName() + ", at fp" + mainfp);
TravelStage travelToGather = new TravelStage(this, gather, RouteLocationCalculator.findJumpPointToUse(getFactionForUIColors(), gather), false);
      travelToGather.setAbortFP(totalfp * successMult);
      addStage(travelToGather);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 12:56:21 PM
Yeah see you're adding multiple assemble stages. Try just assembleMain.addSource() and don't create/add other assemble stages; the raid is not going to work with multiple assemble stages.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on September 20, 2019, 12:58:25 PM
How will defining setSpawnFP in the loop turn out in the end? This is the main thing I'm focusing on. Jus adding markets is simple enough with addSource. I suppose it wont assign that value to the source but rather the whole assembly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 01:03:04 PM
Ah, ok - you'd probably need to write your own assemble stage code from scratch, then. It'll just use a single spawnFP value and spawn alternating fleets from the colonies. IIRC you'll still need to extend AssembleStage and override a bunch of methods or RaidIntel wouldn't work (and you'd need to re-write that too).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on September 20, 2019, 01:07:13 PM
I figured that as well in the end. That's why I wanted to ask, to make sure. Anyway, thanks for the help :).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 01:08:46 PM
Yep! Sorry about the confusion :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: goduranus on September 20, 2019, 01:21:14 PM
Is there a way to make factions' ships not deviate from the .variant file? For instance I made a railgun Enforcer, but I see that design  in Sindrian fleets and railguns were replaced with Heavy Autocannons, even though Sindria knows the railgun blueprint.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SomeDegenerate on September 20, 2019, 02:09:31 PM
Hello all,

I recently ran into a small amount of frustration in-game (hint: it involves colonies and comm relays) and, because my OCD micromanagement knows no bounds, I thought, "Hey, I know some Java. I've never made a mod before in any program, I'm more than a little rusty, and my Eclipse setup is on my old computer, but how hard could it be?"

Almost a week, several hours of crawling through the documentation, and a not-insignificant amount of coffee later, I've run into another problem juuuuuust before what I could call a pre-alpha is ready. Which brings me to my question: what's the method for removing a SectorEntityToken/CustomEntity? I can get the ID, location, what have you, but I cannot, for the life of me, figure out how to actually remove it.

Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 02:21:43 PM
Hi! That'd be LocationAPI.removeEntity().

So you might do something like:

if (entity.getContainingLocation() != null) {
    entity.getContainingLocation().removeEntity(entity);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SomeDegenerate on September 20, 2019, 02:32:11 PM
Hi! That'd be LocationAPI.removeEntity().

So you might do something like:

if (entity.getContainingLocation() != null) {
    entity.getContainingLocation().removeEntity(entity);
}

Thanks, I appreciate it. Off to figuring out what's broken and fixing it XP
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 02:36:37 PM
Good luck :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 20, 2019, 02:43:51 PM
When i use IntervalUtil(float minInterval, float maxInterval) to make timers, would the interval for one second be 1.0f? Also if i set min and max interval the same and call the check every frame is  it granted that it will not miss the interval or should i put a bit of space between min and max?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2019, 02:53:09 PM
That depends on what you pass in to IntervalUtil.advance(). An interval of 1.0f will elapse after the sum total of the "amount" parameter to that method reaches 1.0f. So if you pass in seconds, it'll be seconds, if you pass in days, it'll be days.

It's safe to have min and max be the same value, but in that case it'd be simpler to just track an "elapsed" time directly. Something like:

elapsed += amount;
if (elapsed >= 1f) {
  elapsed -= 1f;
  // do thing
}

The point of IntervalUtil is to randomize when something happens, often to help avoid certain tasks syncing up and hitting the same frame too much. If you're not using it to randomize, it'll work, but it's a bit overkill.

(You can view the source of IntervalUtil, btw; it's in the api.zip.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 20, 2019, 02:57:17 PM
 Thanks Alex, it is clear now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SomeDegenerate on September 20, 2019, 03:32:41 PM
Right, so I've managed to muck something up. As I try to reference getEntityById([RelayID]) from LocationAPI, I get an error that the method getEntityById() is undefined for type [MyClassName]. Then when I try to refer to it statically via LocationAPI.getEntityById(), I get a "cannot make a static reference to a non-static method" error - so I'm at a bit of a loss. I've had no trouble importing methods from other packages - though upon second look it seems that all the methods I've needed have been a part of the package I'm already operating in.

For reference, my class extends BaseIndustry as I'm trying to create a new Planetary Structure. I can paste my code here if that helps.

Thanks!


Never mind. I forgot Java was Object Oriented there for a second. Solved the problem by, y'know, creating a LocationAPI variable from which I could call the getEntityById function.

It's been a long day, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 20, 2019, 06:03:09 PM
How do i turn off all weapons from a ship or module for X amount of time?
Do disable() breaks the weapon or just turns it off? and what do i use to bring it back? I can't find any enable() method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on September 21, 2019, 03:08:36 PM
Previous solved question:
Spoiler
Would it be possible to directly set the .skin of a ship?

To outline the idea i want to be able to, by installing a hullmod on a ship (the central "core"), enable or disable weapon slots on the ship in question. I know a way of enabling or disabling weapon slots is by using the removeWeaponSlots in a .skin file which nicely allows you to keep a weapon slot active only for a certain .skin. The problem here however is that i don't see any good ways (if any at all) to directly interact with these parts of the ship in the API. I was looking for how the "restore ship" function in the hangar did its job but was unable to find it anywhere in the API, which i found a little strange.

So, in essence: Is there any way of setting the skin of a ship with the intent to enable or disable weapon slots? (In the refit view)
[close]

New question:
Is there any good way to, in the refit screen, refund or return a weapon in a specific slot? Changing the hull of a ship when weapons are mounted leads to some funny things happening (namely crashes) and i'd love to be able to return a weapon to the player or the store without costing the player extra money/giving them free weapons. I've been looking into both the stripWeapons function and the player market transaction APIs for some ideas on what to do, but both of these are rabbit holes so deep i hardly know where to begin.

In addition to this question i'm wondering if there is a way of forcing the refit screen to update, such as it does when you restore a ship. I thought maybe i could simulate an R keypress which would reopen the refit screen, but this does not seem to be working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 21, 2019, 04:31:08 PM
Could someone guide me through adding a custom start?
I'd tried copying and modifying one of Vayra's to get used to it all, but when I try to launch it I get:
Code
Fatal: java.lang.RuntimeEception: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd

Cause: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd
EDIT: Attached the whole thing, if that helps.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 21, 2019, 06:49:32 PM
I want to make a Custom Defensive Ship System that will be a strong EMP, similar to the vanilla EMP system, but can be disabled and enabled at anytime like a shield.

In the wiki it says:

Quote
Alternate defense systems

It is possible to create a custom shield replacement (right-click activated) by extending the functionality of the phase cloak implementation. Phase cloak works by setting the Ship Data CSV shield type field to "PHASE" and designating the ship system ID "phasecloak" in the defense id field. This causes the ship system phasecloak to be activated on right-click. Different, custom ship systems can also be designated in the Ship Data CSV defense id field instead of phasecloak
This explains what to put in the "defense id" field, but what do i put in "shield type" field?

Quote
Special consideration needs to be taken for the AI for the ship system as it is not treated as the ship system by parts of the engine. For example an AI that activates the ship system will activate whatever is set as that ship's system, as opposed to the ship system which is replacing the shield
So i don't need to design a custom AI and the ship will activate the system in any situation it would activate a shield? Sounds good for what i have in mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 21, 2019, 07:10:50 PM
Could someone guide me through adding a custom start?
I'd tried copying and modifying one of Vayra's to get used to it all, but when I try to launch it I get:
Code
Fatal: java.lang.RuntimeEception: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd

Cause: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd
Typo in the NGCYunruStrangerStartScript class name: "Stanger"

In the wiki it says:

Quote
Alternate defense systems

It is possible to create a custom shield replacement (right-click activated) by extending the functionality of the phase cloak implementation. Phase cloak works by setting the Ship Data CSV shield type field to "PHASE" and designating the ship system ID "phasecloak" in the defense id field. This causes the ship system phasecloak to be activated on right-click. Different, custom ship systems can also be designated in the Ship Data CSV defense id field instead of phasecloak
This explains what to put in the "defense id" field, but what do i put in "shield type" field?
It tells you to enter PHASE as shield type
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 21, 2019, 07:15:38 PM
Typo in the NGCYunruStrangerStartScript class name: "Stanger"
Feel so dumb.
Update: Fixed typo, but still get the error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 21, 2019, 08:28:21 PM
Is DO_NOT_CONSERVE still an active weapon tag for missiles? And what, specifically, does it do when combined with STRIKE?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 22, 2019, 06:52:24 AM

It tells you to enter PHASE as shield type
Ok, thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2019, 10:14:11 AM
How do i turn off all weapons from a ship or module for X amount of time?
Do disable() breaks the weapon or just turns it off? and what do i use to bring it back? I can't find any enable() method.

I think repair() would do it, as far as turning it back on. And, yeah, disable "breaks" it the way combat damage would.


New question:
Is there any good way to, in the refit screen, refund or return a weapon in a specific slot? Changing the hull of a ship when weapons are mounted leads to some funny things happening (namely crashes) and i'd love to be able to return a weapon to the player or the store without costing the player extra money/giving them free weapons. I've been looking into both the stripWeapons function and the player market transaction APIs for some ideas on what to do, but both of these are rabbit holes so deep i hardly know where to begin.

In addition to this question i'm wondering if there is a way of forcing the refit screen to update, such as it does when you restore a ship. I thought maybe i could simulate an R keypress which would reopen the refit screen, but this does not seem to be working.

I don't think so? At least, nothing that I can think of in the API. There may be some creative workarounds, but that'd be more a question for someone other than me.

Is DO_NOT_CONSERVE still an active weapon tag for missiles? And what, specifically, does it do when combined with STRIKE?

Pretty sure it is, yeah. STRIKE would make it not be used vs frigates and... whatever else it generally goes. DO_NOT_CONSERVE would just make it fire regardless of how much ammo is left, i.e. it wouldn't save HE missiles for when the target is vulnerable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 22, 2019, 10:25:44 AM
Here's the content of the thing it can't find, if that helps:
Code
package com.fs.starfarer.api.impl.campaign.rulecmd;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.rules.MemKeys;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.characters.CharacterCreationData;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import com.fs.starfarer.api.util.Misc;
import java.util.List;
import java.util.Map;

// YoU kNow, Really i don't Understand what i'm doing

public class NGCYunruStrangerStartScript extends BaseCommandPlugin {

    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
        if (dialog == null) {
            return false;
        }
        CharacterCreationData data = (CharacterCreationData) memoryMap.get(MemKeys.LOCAL).get("$characterData");

        data.addScript(new Script() {
            @Override
            public void run() {
                String pirateId = Factions.PIRATES;
                String ludicID = Factions.LUDIC_PATH;
                FactionAPI player = Global.getSector().getFaction(Factions.PLAYER);
                player.setRelationship(pirateId, RepLevel.SUSPICIOUS);
                player.setRelationship(ludicId, RepLevel.SUSPICIOUS);
                for (FactionAPI other : Global.getSector().getAllFactions()) {
                    if (other.getRelationship(player)>-1) {
                        player.setRelationship(other.getId(), Rep.Level.SUSPICIOUS);
                    }
                }
            }
        });
        return true;
    }
}
(And yes, I noticed I have 1 too few d's on Luddic >.< )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 22, 2019, 11:49:59 AM
Pretty sure it is, yeah. STRIKE would make it not be used vs frigates and... whatever else it generally goes. DO_NOT_CONSERVE would just make it fire regardless of how much ammo is left, i.e. it wouldn't save HE missiles for when the target is vulnerable.

Hm, ok that's what I thought.

I am having issues with the AI being very unwilling to use Reapers in particular. To clarify why this doesn't make sense to me: Reapers regenerate and do not cost flux to fire so they are completely expendable and should always be fired when in range. I have a phase battleship, in particular, armed with the ability to fire 8 Reapers at once.

When it is given an "Eliminate" command on another enemy capital, the AI doesn't ever fire the Reapers even though at least 4 of them are turreted.

When I personally fly the battleship, I get within range and unleash all torpedoes. The enemy capital DIES. In the AI hands, if the battleship wins even at all it often has less than a third of its hull remaining.

Any ideas on what I am doing wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2019, 12:06:18 PM
Hmm - maybe try putting some of them in a linked group? If you have a bunch of one-shot small weapons on a battleship, it's possible that it would prefer another weapon group for manual fire due to it having too much "weight" in weapons. A weapon being STRIKE (and missile) adds weight, but that might not be enough to overcome, say, a group of 3-4 large ballistics.

An ALWAYS_PANIC hint on the ship is also an option. As is removing STRIKE from the Reaper and/or adding USE_VS_FRIGATES.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 22, 2019, 12:37:41 PM
Ill try some of those tags, but I've already tried Linked vs Alternating groups and the reapers are in two separate groups of 4 medium in one group and 2 large in another. I didn't combine them because turrets and hardpoints in the same group have weird behavior sometimes. Maybe I'll try that too
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2019, 01:17:33 PM
Ah - if it's 4 medium Typhoons in the same group then that (the weights stuff) is likely not the issue. USE_VS_FRIGATES would also have it have more tolerance for enemy lateral movement (i.e. it's not trying to be as accurate - hitting with a torpedo from a moving ship vs another moving ship can be tricky), so that might make it fire (and miss) more.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 22, 2019, 02:04:28 PM
I forgot PANIC_FIRE makes them use torps vs fighters too much so that's out.

I had considered the movement issue and maybe I am miscalculating there so I will try USE_VS_FRIGATES. The thing is, that capital shouldn't be able to outmaneuver the torps and when I personally fly the ship I launch everything directly at the enemy ship (no target leading) at close to maximum range and the majority of them hit without issue- barring PD.
----

Separate question, does the UNBOARDABLE tag for a ship also mean it will not be sold in faction markets? Or just that it can't be recovered after a battle through loot?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2019, 02:19:12 PM
Just post-combat and derelict recovery.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 22, 2019, 02:45:10 PM
Excellent thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on September 22, 2019, 04:39:46 PM
New question:
Is there any good way to, in the refit screen, refund or return a weapon in a specific slot? Changing the hull of a ship when weapons are mounted leads to some funny things happening (namely crashes) and i'd love to be able to return a weapon to the player or the store without costing the player extra money/giving them free weapons. I've been looking into both the stripWeapons function and the player market transaction APIs for some ideas on what to do, but both of these are rabbit holes so deep i hardly know where to begin.

In addition to this question i'm wondering if there is a way of forcing the refit screen to update, such as it does when you restore a ship. I thought maybe i could simulate an R keypress which would reopen the refit screen, but this does not seem to be working.

I don't think so? At least, nothing that I can think of in the API. There may be some creative workarounds, but that'd be more a question for someone other than me.

That's quite unfortunate... The inability to strip a ship i can work around (put the weapon in the player inventory, they'll still be paying for it) however the inability to update the refit screen is pretty damning. Is there really no way in the accessible API to force the refit screen through an update (i'm calling it an update because i presume the refit screen saves a copy of your fleet whenever a transaction goes through or you open it)? What triggers updates in the first place?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 22, 2019, 04:45:56 PM
How to make a custom engine flame? I want to make mine light purple.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 22, 2019, 04:48:36 PM
Ah - if it's 4 medium Typhoons in the same group then that (the weights stuff) is likely not the issue. USE_VS_FRIGATES would also have it have more tolerance for enemy lateral movement (i.e. it's not trying to be as accurate - hitting with a torpedo from a moving ship vs another moving ship can be tricky), so that might make it fire (and miss) more.

Actually seems to make the problem worse. There was scattered torpedo fire previously (but not nearly clip optimal as DO_NOT_CONSERVE would suggest) but now the weapons are literally never utilized under the same conditions:( This is for phase ships in particular, btw. I'll run a similar test with non-phase ships and compare and post an update here.)

I can probably provide videos if that would help. I'll try and work on that too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2019, 05:12:01 PM
One other option would be to change the weapon type to ballistic, I think - may or may not be reasonable depending on exactly what you're doing here, of course. Could try setting ammo really high and see if that does something, too. E.G. Locusts etc seem to have no issue firing at stuff.

How to make a custom engine flame? I want to make mine light purple.

See: data/config/engine_styles.json. Then you can refer to the style from your .ship file.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 22, 2019, 05:14:48 PM
Thanks again Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2019, 05:16:13 PM
Yep!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 22, 2019, 07:02:36 PM
Thanks i'll try additional ammo too because the large variant has more ammo and seems to operate better- especially when turreted.

See: data/config/engine_styles.json. Then you can refer to the style from your .ship file.

I was also going to ask about this (same color too actually, haha) so thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 22, 2019, 09:55:29 PM
Could try setting ammo really high and see if that does something, too. E.G. Locusts etc seem to have no issue firing at stuff.

Ok, so more feedback here. The problem was 2 things coming together to create a "no fire ever" situation for the AI.

Increasing the ammo from 2 to 8 seemed to help considerably. This makes me think that the DO_NOT_CONSERVE tag is a little misleading because with low base ammo the AI still wants to conserve one or two missiles. Maybe a separate tag for that would help? For some missiles I want the complete alpha strike because it has the most chance of getting through the PD screen or capitalizing the most on an overload, etc.

Second: Unlike energy or ballistic weapons, missile hardpoints don't swivel their firing projectory for hardpoints with increased arcs. This means that any weapon hardpoint projectories that could include missile weapons have to tilt their axis to converge to a point as close to maximum range (hard to balance as you'd imagine if rockets and torps have varying max ranges) as possible in order for the AI to fire those weapons. Adding tags like GUIDED_POOR (merely better... still not optimal unfortunately) or DO_NOT_AIM (100% fine) help if the missile can track, but if the missile is a rocket or torp it has to converge its projectory to be fired or be included in an alternating weapon group. The problem with the second solution is the AI still isn't very efficient with that setting atm:

For instance, the medium reaper with 2 max ammo put into hardpoints set to alternating fire with two total weapons in the group can't even fire enough to reduce the max clip of 2 down to 0 even with a 67 reload time on the missile.

Setting the ammo to 8 leaves the average clip size to around 5 to 6. So not optimal considering the DO_NOT_CONSERVE tag for sure.

Setting the ammo to 8 and making the hardpoint projectory converge around max range for the weapon fixes the problem and the AI empties the clip and kills the enemy vessel.

In this case, its the difference between the vessel losing horribly or, alternatively, if the behavior is accounted for, alpha striking the (weaker) opponent and winning with a supreme victory itself.
------------------------

Ok, now all of that said, the above fix is irrelevant for phase vessels. Phase vessels are very unwilling to use strike weapons in general. I had to change a tier 3 dps weapon with minimal flux build up to not use the STRIKE,USE_VS_FRIGATES tag combination in order for that weapon to ever even be fired by the phase battleship at all (Its a large energy weapon).

The long range strike beams (also large energy strike weapons) are fired more often, but at about 1/3 effectiveness over their actual cooldown, reducing weapon effectiveness by the converse amount. This is while the phase battleship hovers at ~15% to 20% max flux, so it's not that its unable to fire the weapon in case that was the concern.

Torps- almost no matter what I do- are either fired at 1/3 effectiveness in the best case scenario where the large weapon with 12 ammo converges to a point for AI hardpoints to fire, or at worst case scenario the group of 4 turret Reapers with 8 max ammo are never fired at all- even within range with either STRIKE,DO_NOT_CONSERVE or STRIKE,USE_VS_FRIGATES,DO_NOT_CONSERVE tags set.

I hope this helps. Let me know if you need more testing to help further narrow this down!

*EDIT*

I tried some more tests for phase ships and it definitely seems linked to their threat evaluation. The phase battleship is much more likely to use large hardpoint (with a high max ammo) torps against cruisers it can easily outgun. It still won't use turreted medium torps against them unless they overload or are already mostly beaten. The DO_NOT_CONSERVE tag doesn't seem to affect the behavior here.

Against a battlecarrier roughly equal in combat strength, it refuses to use torps unless at half health or more. It will also use them (again very sub-optimal to actual reload times) against overloaded ships at equal strength.

If I pilot the vessel myself and use the torpedoes optimal to reload times, the fight is fairly easy in all cases.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on September 23, 2019, 02:28:16 AM
What does the 8/6/5/4% in ship_data.csv mean?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on September 23, 2019, 06:38:13 AM
What does the 8/6/5/4% in ship_data.csv mean?
It is an old "memory note" of sorts: it has no in-game effects, but refers to the standard proportions of flux dissipation vs. capacity for the ship classes: 8% of capacity as dissipation for frigates, 6% for destroyers etc.

Values in the column are (in vanilla, at least) generally the capacity a ship "would have" if it was balanced exactly against this benchmark, without being adjusted up or down slightly for the different individual hulls.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 23, 2019, 06:18:41 PM
@Morrokain: hmm, interesting. Fixed a few places where DO_NOT_CONSERVE was not being respected - that helps a lot. My test case was a Falcon (P) with 2x linked turret and 2x linked hardpoint Typhoons, no expanded missile racks - vs a stock Hammerhead. With the fixes - and the temporary addition of DO_NOT_CONSERVE to Typhoons - it's pretty happy to nuke it.

It doesn't care whether the firing ship is a phase ship, though, so that's odd. It also shouldn't be any more likely to fire torpedoes when the enemy hull gets lower; if anything it might be less likely to. In a few places there's a random element so it's just more likely you'll see it fire as the battle goes on; possibly that's what's being observed here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 23, 2019, 06:42:20 PM
@alex

i took 'quick' look at some Xenoargh's scrips to notice interesting bit in his ShipPhysics.java

Code
public static ExecutorService shipPhysicsCommonExecutor = Executors.newFixedThreadPool(4);

fast glimpse at starsector core reveals it seems the default value is 2, plus it seems hard-coded
so he double the amount of threads used for his new AI physics

i was wondering if it would be possible to change the amount of threads in similar way for default
as it might be handy nowadays when we can finally use 8-32 cores CPUs

yet i'm not sure if it's changeable value
then it's half-question (if someone can mod it) or half-suggestion (so it's configurable option into future)

thanks in advance for your time (to answer/consider this)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 23, 2019, 06:50:24 PM
The game's main loop is single-threaded, so I'm not sure what you mean.

I don't think xenoargh's stuff is thread-safe; I wouldn't go down the road of trying to emulate it - it's just asking for obscure, hard-to-debug issues, and the API is generally not thread safe, so it'd be... let's say "difficult" to try to work around.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 23, 2019, 07:39:23 PM
@Alex
Great glad to help! (regarding DO_NOT_CONSERVE).

Regarding Phase ships:

I don't think so as far as the random element is concerned. I feel this way because the behavior is consistent and noticeably different, but I don't think it's a missile specific thing linked to DO_NOT_CONSERVE either.

It may be mod related so I need to do some tests on Vanilla, but I'm pretty sure its linked the the phase AI's threat evaluation in that it doesn't feel like it has the time or possibly flux to fire many weapon groups that aren't on autofire and ends up not firing them at all for some reason. It occasionally fires a group, but prefers (against equal strength opponents as a reminder, not when it feels stronger) to remain in phase as much as possible- presumably because it values not taking damage above dealing damage. That's the only thing I can think of right now because a player can cycle through 3 weapon groups like that before the phase cooldown is done (considering one is flux free and the other is maybe 10% when the AI only has 10% of their max currently in use.) and still phase away after the burst has done serious damage to the enemy.

(So, essentially the behavior I'm seeing affects all strike weapons including energy and ballistic and seems specifically tied to how phase AI handles the STRIKE tag)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 23, 2019, 07:40:22 PM
thanks @alex, hopefully in 'distant' future there will be more 'safe' threading possible
especially with the mainstream hardware progress toward multicore counts
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 23, 2019, 08:09:48 PM
Do anyone know how to make a visual effect that resembles something like a soundwave? (yes, i know no sound in void, yada yada), i want for a system that increases in combat radar range, i did try the Graphics lib wave, but i can only make it look like my ship is being pulled into a blackhole instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 23, 2019, 08:23:53 PM
It also shouldn't be any more likely to fire torpedoes when the enemy hull gets lower; if anything it might be less likely to.

Oops didn't catch this, I meant it fires it more often when the player ship under AI control's hull gets lower, not the enemy ship. Sorry I was definitely being unclear there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 23, 2019, 08:30:02 PM
@Alex
Great glad to help! (regarding DO_NOT_CONSERVE).

Yeah, thank you for that! That's some mighty impressive investigative work :)

Regarding Phase ships:

I don't think so as far as the random element is concerned. I feel this way because the behavior is consistent and noticeably different, but I don't think it's a missile specific thing linked to DO_NOT_CONSERVE either.

It may be mod related so I need to do some tests on Vanilla, but I'm pretty sure its linked the the phase AI's threat evaluation in that it doesn't feel like it has the time or possibly flux to fire many weapon groups that aren't on autofire and ends up not firing them at all for some reason. It occasionally fires a group, but prefers (against equal strength opponents as a reminder, not when it feels stronger) to remain in phase as much as possible- presumably because it values not taking damage above dealing damage. That's the only thing I can think of right now because a player can cycle through 3 weapon groups like that before the phase cooldown is done (considering one is flux free and the other is maybe 10% when the AI only has 10% of their max currently in use.) and still phase away after the burst has done serious damage to the enemy.

(So, essentially the behavior I'm seeing affects all strike weapons including energy and ballistic and seems specifically tied to how phase AI handles the STRIKE tag)

Ah, hmm. Right - I think it's probably that; the AI isn't aware enough of high-level concept to know stuff like "I should burst everything possible now while phase cloak is on cooldown". And it's not super fast as far as switching between weapon groups - and it likes to be careful aiming dumbfire missiles and torpedoes - so that wouldn't play nice with having a 2-second window.

Phase ships *do* get more aggressive as their peak time runs down, btw; basically they estimate how much damage they're likely to take if they unphase (dps of the various weapons that can be brought to bear, combined with their armor, dps damage types, phase cooldown duration), and the threshold for how much they're willing to take goes up as peak time (and then CR) goes down. So it's not to do with their weapons, but with how willing they are to unphase given the firepower they'll face when they do.

Hmm. There are definitely some issues with how willing phase ships are to engage/how well they do it when they come out of phase. Hopefully I'll get a chance to look at it at some point.


thanks @alex, hopefully in 'distant' future there will be more 'safe' threading possible
especially with the mainstream hardware progress toward multicore counts

Honestly, probably not :) I don't see trying to make the codebase thread-safe (complicated, time-consuming, error-prone, etc), and it feels like optimizing for a high core count is not optimizing for the right case, anyway - it seems like you'd want your optimizations to help on the low end, not on the high end.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 23, 2019, 08:57:51 PM
Yeah, thank you for that! That's some mighty impressive investigative work :)

 ;D

Quote
...how much damage they're likely to take if they unphase (dps of the various weapons that can be brought to bear, combined with their armor, dps damage types, phase cooldown duration), ... So it's not to do with their weapons, but with how willing they are to unphase given the firepower they'll face when they do.

Ah ok, you know what, I recently lowered phase ship armor slightly and I began noticing it more at that time. From that description this may be part of it too then:

Strike weapons have high alpha strike and very low sustained dps (tooltip wise) in my mod compared to assault weapons, so if the phase AI is considering dps and not burst dps then it may "undervalue" those weapons from a "should I engage now?" standpoint. Do you remember if it includes burst dps in this calculation?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: goduranus on September 23, 2019, 09:02:10 PM
Ah, hmm. Right - I think it's probably that; the AI isn't aware enough of high-level concept to know stuff like "I should burst everything possible now while phase cloak is on cooldown". And it's not super fast as far as switching between weapon groups - and it likes to be careful aiming dumbfire missiles and torpedoes - so that wouldn't play nice with having a 2-second window.

Aha I loaded them with Atropos torpedoes and the AI suddenly does much much better with them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 23, 2019, 09:03:33 PM
Strike weapons have high alpha strike and very low sustained dps (tooltip wise) in my mod compared to assault weapons, so if the phase AI is considering dps and not burst dps then it may "undervalue" those weapons from a "should I engage now?" standpoint. Do you remember if it includes burst dps in this calculation?

To be clear, it's looking at *enemy* ship dps, and, yeah, iirc it considers burst. It's not looking at its own dps.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 23, 2019, 09:28:21 PM
^ I see and good to know. Well then that's probably not doing anything to affect the behavior. Yeah, must be multiple strike groups contributing to at least a part of it. I'll rebalance around a single strike weapon group and see if that improves overall combat performance.

Aha I loaded them with Atropos torpedoes and the AI suddenly does much much better with them.

Agreed. The tracking and related GUIDED_POOR tag seem to help make phase ships more comfortable launching torps. It's probably the dumbfire consideration Alex was talking about not finding what it needs for acceptable trajectory within the two second phase cooldown window before rephasing overrides weapon firing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on September 24, 2019, 12:50:43 AM
thanks @alex, hopefully in 'distant' future there will be more 'safe' threading possible
especially with the mainstream hardware progress toward multicore counts
Honestly, probably not :) I don't see trying to make the codebase thread-safe (complicated, time-consuming, error-prone, etc),
and it feels like optimizing for a high core count is not optimizing for the right case,
anyway - it seems like you'd want your optimizations to help on the low end, not on the high end.

actually i talk all the ends, 4 to 8 cores is now low-end ...
mainstream is 12 to 16 and highend is 16 to 64

anyway i get the complexity of rewriting singlethreaded stuff into multithreaded
but if there are portions which could be, then go for it, better to use some of that than none

hardware-wise single-threaded performance will not grow as fast anymore (some % inbetween generations)
and there is no change indicated anywhere on horizont, while core count will keep some steady increases tho

all those complex battles with tons of various crafts or complex economy wise etc. it all screams for threading
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 24, 2019, 05:19:36 PM
What getDParentHull() in ShipHullSpecAPI does? I see it being used in some mods when getting the hull id
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 24, 2019, 07:51:54 PM
How do i make my ships show up in the main menu? (not the codex, i mean in the main menu background randomly flying)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 24, 2019, 09:03:20 PM
How do i make my ships show up in the main menu? (not the codex, i mean in the main menu background randomly flying)

data/config/title_screen_variants.csv is the file that handles this.

The entries are .variant file ids.

P.S: Note that the file merges so if you want to completely replace the background ships you would have to add the file from your mod in the replace array section of the mod_info file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 25, 2019, 12:21:52 AM
Phase vessels are very unwilling to use strike weapons in general.

Eating my words a little here, but I want to say this only seems truly noticeable on a one-vs-one situation with the AI. I have tried a few fleet simulations with my phase ship faction and the flanking/numerical superiority factor is key towards making the AI more aggressive and therefore more overwhelming.

I gave the phase battleship the Phase Jumper (displacer) ship system and it seemed to make the vessel much more willing to use STRIKE tag weapons in a fleet scenario. That simple change makes the battleship scarier in a fleet setting and the only faction I have beat it with so far is Tri-Tachyon with both a Fire Support Paragon battleship and Strike Astral carrier to keep it at bay.

Mobility seems to be the number one factor in this case and that makes sense to me. Adding the mobility of the Phase Jumper allows the battleship to choose its strike and defensive retreat more carefully rather than relying on phase to avoid damage. It can phase in and unleash full strike potential up until it needs to jump away and does so admirably under AI control.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 25, 2019, 05:35:49 AM
How do i make my ships show up in the main menu? (not the codex, i mean in the main menu background randomly flying)

data/config/title_screen_variants.csv is the file that handles this.

The entries are .variant file ids.

P.S: Note that the file merges so if you want to completely replace the background ships you would have to add the file from your mod in the replace array section of the mod_info file.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 25, 2019, 06:45:13 AM
data/config/title_screen_variants.csv is the file that handles this.

The entries are .variant file ids.

P.S: Note that the file merges so if you want to completely replace the background ships you would have to add the file from your mod in the replace array section of the mod_info file.

It worked, but there is a small problem, modular ships appear without the modules, even with the modules showing up in the codex, is there a way to fix this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 25, 2019, 06:47:30 AM
Idle question: How is the quality of ships the player manufactures for their own use calculated? Does it use the quality of the gathering point market?

The specific case was: I had a player character with no colonies, set Hegemony's Tigra City to player-owned (market.setPlayerOwned(true)), and built a heavy industry on it, then made some ships. None of the ships had D-mods, regardless of whether I had only the base Heavy Industry or an Orbital Works with pristine nanoforge.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2019, 09:10:41 AM
It worked, but there is a small problem, modular ships appear without the modules, even with the modules showing up in the codex, is there a way to fix this?

Ah, that looks like a bug; fixed it up just now. There's *probably* a way to script around it but it would be fairly involved.

Idle question: How is the quality of ships the player manufactures for their own use calculated? Does it use the quality of the gathering point market?

The specific case was: I had a player character with no colonies, set Hegemony's Tigra City to player-owned (market.setPlayerOwned(true)), and built a heavy industry on it, then made some ships. None of the ships had D-mods, regardless of whether I had only the base Heavy Industry or an Orbital Works with pristine nanoforge.

Per CoreScript.doCustomProduction(), it looks for the highest production quality at a player-owned market, and then assumes that the ship quality doctrine setting is maxed (since the player would otherwise need to game it by maxing it prior to the end of the month).

Code
float quality = 0f;
for (MarketAPI market : Global.getSector().getEconomy().getMarketsCopy()) {
if (!market.isPlayerOwned()) continue;
quality = Math.max(quality, ShipQuality.getShipQuality(market, Factions.PLAYER));
}
quality -= Global.getSector().getFaction(Factions.PLAYER).getDoctrine().getShipQualityContribution();
quality += 4f * Global.getSettings().getFloat("doctrineFleetQualityPerPoint");

Note that the production quality at the market - via ShipQuality.getShipQuality(market, Factions.PLAYER) - does consider what faction the production is for, meaning the player's and not the market faction's ship quality doctrine gets used, and the consequently cancelled out and replaced with the maxed ship quality doctrine bonus.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 25, 2019, 10:28:55 AM
Thanks Alex, will the fix be up next release or is it up already?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2019, 11:39:08 AM
Next release, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on September 25, 2019, 01:39:41 PM
Is it possible to make a script that reads through all loaded entities, namely weapons, checks for a certain parameter (if its a missile weapon), then for those weapons adds/edits calculated values (reload time and amount based on burst size). I like the idea of very slowly replenishing missiles, and editing individual mods after each update doesnt seem plausible.
I didnt make any mods for starsector yet, this question is my feasibility study.
thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 25, 2019, 01:41:34 PM
Simple answer:  sure.  You can manually replenish ammo for missile weapons via script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 25, 2019, 02:02:09 PM
Next release, sorry!
No prob

Also is it possible to make a hullmod that changes core aspects of weapons slots? I wanna make a series of hullmods that converts energy -> missile -> ballistic or changes a medium weapon slot of specific type into smaller, but universal turrets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 25, 2019, 08:28:59 PM
Help here please, i have been trying to make a custom defensive system, but i can't get it to work, as soon as i press the right click it plays the activation sound, but nothing happens, here the
system
Code
"id":"wurg_emp",
    "type":"STAT_MOD",
    "aiType":"CUSTOM",

"aiScript":"data.scripts.shipsystems.ai.WurgEmpAI",

    "statsScript":"data.scripts.shipsystems.WurgEmpStats",

    "phaseHighlight":"_glow1",
    "phaseDiffuse":"_glow2",

"effectColor1":[255,255,255,145],
"effectColor2":[255,255,255,180],

"useSound":"system_phase_cloak_activate",
    "outOfUsesSound":"system_phase_cloak_deactivate",

-edit-
Found the problem, the type must be "PHASE_CLOAK" instead of "CUSTOM"

Now i just need to figure out a way to make the system easy to disable... the problem is that I am using a modular ship and type:PHASE_CLOAK systems cannot be disabled in ships with modules without venting
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 25, 2019, 09:05:31 PM
By the way, does anyone know how to mimic the cool glow effect of phase cloak? I have the glow sprites ready, but i don't know how to do it in the script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 26, 2019, 02:38:05 AM
Is it possible to add custom blueprints?

EDIT: Believe I worked it out. I hope :P

EDIT 2: Are the [REDACTED] Fighters hardcoded to not be buildable by the player?
I added a blueprint for them, they're listed on it, but upon learning it, they're not listed.

EDIT 3: Ah, I added them as ships, not fighters.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArnaudB on September 26, 2019, 05:06:45 AM
I have been trying to find which piece of codes generate cryosleeper to make more appear in the sector, but I couldn't find the relevant pieces, even with Notepad++ search across the entire starsector folder.

I found the Salvage_Gen entities and I went looking around procgen, but I can't find where it's supposed to say it'll create two cryosleeper on sector generation.

Any clue?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on September 26, 2019, 07:50:50 AM
Using the ship editor and im wandering what the difference between lauch bay and lauch port is?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 26, 2019, 08:31:45 AM
Using the ship editor and im wandering what the difference between lauch bay and lauch port is?
One's additional points at which to spawn fighters for the same wing. So the first wing equipped would spawn at bays and ports 1, while the second would spawn at bays and ports 2. As far as I know, anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2019, 08:53:56 AM
By the way, does anyone know how to mimic the cool glow effect of phase cloak? I have the glow sprites ready, but i don't know how to do it in the script.

You could probably do something very similar using ShipAPI.addAfterimage(); make sure to pass in "true" for the "additive" parameter as that's what makes it glowy.

I have been trying to find which piece of codes generate cryosleeper to make more appear in the sector, but I couldn't find the relevant pieces, even with Notepad++ search across the entire starsector folder.

I found the Salvage_Gen entities and I went looking around procgen, but I can't find where it's supposed to say it'll create two cryosleeper on sector generation.

Any clue?

See: DerelictThemeGenerator; search for "cryo" in the file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 26, 2019, 09:35:50 AM
You could probably do something very similar using ShipAPI.addAfterimage(); make sure to pass in "true" for the "additive" parameter as that's what makes it glowy.

But this would use the ship's base sprite right? i made a special glow sprite like a phase glow sprite to use in this effect, is there any way to set the sprite to be used in the afterimage or in jitter effects?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2019, 09:44:01 AM
Ah, right, duh. Sorry, wasn't thinking that through.

Since you have the PHASE_CLOAK ship system type, though, the glow sprites should be rendered while the system is active, based on these:
"phaseHighlight":"_glow1",
"phaseDiffuse":"_glow2",

So they need to be named <ship_sprite_name_>_glow1.png etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 26, 2019, 10:28:19 AM
Ah, right, duh. Sorry, wasn't thinking that through.

Since you have the PHASE_CLOAK ship system type, though, the glow sprites should be rendered while the system is active, based on these:
"phaseHighlight":"_glow1",
"phaseDiffuse":"_glow2",

So they need to be named <ship_sprite_name_>_glow1.png etc.
Nope, it doesn't show them, I am pretty sure i gave them with right name and all
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 26, 2019, 10:54:36 AM
Are there other variables that influence the phase effect? i did remove

Code
"effectColor1":[255,255,255,145],
"effectColor2":[255,255,255,180],

before when i was trying to figure why it was not activating, i will put it back and see if it works

-edit-

nope, still no effect, here the system

Code
{
"id":"wurg_sensor",
"type":"PHASE_CLOAK",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.WurgSensorAI",

"statsScript":"data.scripts.shipsystems.WurgSensorStats",

"phaseHighlight":"_glow1",
"phaseDiffuse":"_glow2",

"effectColor1":[255,255,255,145],
"effectColor2":[255,255,255,180],

"useSound":"wurg_activate",
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2019, 12:07:10 PM
The way to go here would probably be to start with a copy of the phase cloak system, make sure *that* shows the glows, and then change it one step at a time until you see what breaks it. Offhand, I'm not seeing why it wouldn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 26, 2019, 02:14:33 PM
The way to go here would probably be to start with a copy of the phase cloak system, make sure *that* shows the glows, and then change it one step at a time until you see what breaks it. Offhand, I'm not seeing why it wouldn't work.
I made some tests, and by elimination i figured it is something in the script, i did analyse the cloak script in the impl folder, but i can't find where it tells the game to shine the glow effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2019, 02:41:13 PM
I made some tests, and by elimination i figured it is something in the script, i did analyse the cloak script in the impl folder, but i can't find where it tells the game to shine the glow effect.

IIRC it doesn't; it seems more likely that somehow, something in your script is making it not do the glow effect. I'd suggest the same kind of thing as far as figuring it out - copy, test, modify, repeat, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 26, 2019, 03:57:27 PM
I made some tests, and by elimination i figured it is something in the script, i did analyse the cloak script in the impl folder, but i can't find where it tells the game to shine the glow effect.

IIRC it doesn't; it seems more likely that somehow, something in your script is making it not do the glow effect. I'd suggest the same kind of thing as far as figuring it out - copy, test, modify, repeat, etc.
I found the problem, i was missing this
Code
ship.setPhased(true);

But now the ship gets a bit weird, the sprite goes on top of the modules while it is phased, phasing is REEEEEEALLY not made for ships with modules
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 26, 2019, 04:37:49 PM
Here how it looks

(https://i.imgur.com/7T2nZOb.png)

The ship appears on top of the modules while the system is on
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2019, 04:53:12 PM
Hmm, I think you might need to setPhased() the modules from your script? I don't know if phase ships with modules are ultimately workable or not, though.

Depending on the visuals you want, it might be easier to achieve this using decorative "weapons" - type:"DECORATIVE" slots on the hull, and weapons. See: blinker_red.wpn for an example, used by the vanilla Buffalo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 26, 2019, 04:56:15 PM
Hmm, I think you might need to setPhased() the modules from your script? I don't know if phase ships with modules are ultimately workable or not, though.

Depending on the visuals you want, it might be easier to achieve this using decorative "weapons" - type:"DECORATIVE" slots on the hull, and weapons. See: blinker_red.wpn for an example, used by the vanilla Buffalo.
Yep, I am going for the deco route
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 27, 2019, 09:31:22 AM
In the .proj file there is the collision class, i was looking for more details on this, but there is nothing in the wiki, what each of those mean?

collisionClass
RAY
RAY_FIGHTER
PROJECTILE_NO_FF
PROJECTILE_FF
PROJECTILE_FIGHTER
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 27, 2019, 10:18:28 AM
_FF and _NO_FF mean whether the projectile can hit friendlies ("friendly fire") or not.

_FIGHTER is when it's launched by a fighter, i.e. it'll pass over friendlies even if it's otherwise capable of friendly fire. I don't remember offhand if _FIGHTER is equivalent to _NO_FF or if there is a subtle difference.

RAY is used for both beam weapons and some regular projectile weapons. The main difference is that RAY-type projectiles will hit all along their length, while PROJECTILE type will only hit with the front-ish part (and not the trail), so RAY is useful for smaller, faster projectiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 27, 2019, 10:32:13 AM
_FF and _NO_FF mean whether the projectile can hit friendlies ("friendly fire") or not.

_FIGHTER is when it's launched by a fighter, i.e. it'll pass over friendlies even if it's otherwise capable of friendly fire. I don't remember offhand if _FIGHTER is equivalent to _NO_FF or if there is a subtle difference.

RAY is used for both beam weapons and some regular projectile weapons. The main difference is that RAY-type projectiles will hit all along their length, while PROJECTILE type will only hit with the front-ish part (and not the trail), so RAY is useful for smaller, faster projectiles.

I see, so if i use PROJECTILE_NO_FF the projectile will pass through allies without damaging them? Wonderful, i can think uses for this, does this work on beams? Having a big beam that ignores allies would be nice

Also i saw this tag on a beam
"pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF]
This is what kinds of entities it can pierce through right? How do i make it pierce enemy ships?

One more question (sorry Alex), if i have a beam that can pierce enemy ships, how many times will it damage the enemy armor/hull in one go? Would it be safe to use or it would damage the enemy way too many times per frame?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 27, 2019, 11:45:45 AM
For beams you'd need to use:

"collisionClass":RAY_FIGHTER

As there's no RAY_NO_FF

Also i saw this tag on a beam
"pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF]
This is what kinds of entities it can pierce through right? How do i make it pierce enemy ships?

One more question (sorry Alex), if i have a beam that can pierce enemy ships, how many times will it damage the enemy armor/hull in one go? Would it be safe to use or it would damage the enemy way too many times per frame?

See: com.fs.starfarer.api.combat.CollisionClass for all possible values here. For ships, it's SHIP. So yes you could make it pierce a ship, but it's kind of dodgy - it would deal damage at the normal point of impact, and would visually just pass over the ship. It's ok for fighters since they're small and it's not noticeable, but for ships I don't think it'd look too good.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 27, 2019, 12:02:15 PM
For beams you'd need to use:

"collisionClass":RAY_FIGHTER

As there's no RAY_NO_FF

See: com.fs.starfarer.api.combat.CollisionClass for all possible values here. For ships, it's SHIP. So yes you could make it pierce a ship, but it's kind of dodgy - it would deal damage at the normal point of impact, and would visually just pass over the ship. It's ok for fighters since they're small and it's not noticeable, but for ships I don't think it'd look too good.

I see, i will just make it pierce asteroids then, thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on September 27, 2019, 12:47:10 PM
Hi everyone. I have a few questions when it comes to the Market of Starsector. Please understand I do not have a lick of coding experience so, please don't be too judgemental.

SPECIFIC SLOTTING VALUES
My first question about Starsector, is it seems that the amount of ships that can go into the market slots is infinite, so why are only a few ships (ex: 15 ships for Military Market) available at a time. [Not super curious, just wondering if there is a value that can be changed to fill up more slots for greater military market diversity.]
My real question, is there a way that I can make a certain ship hull an absolute guarantee to spawn in at least one military slot every month. If it is, i would love to know.

SHIP MARKET SPECIFICATION
So, I noticed that ships in the military market can require that you have a commission and be cooperative with the faction in order to gain access. Love it! What i don't understand is how the declaration is made. Is it in default_ship_roles.json? If so, which lines ensure that ship hull requires commission and cooperation. I want to make sure certain hulls are not freely accessible without them.

LAST ONE! FLEET SPAWNING
Is there a way to make a specific fleet spawn in a star system? I would love to have at least one fleet of my custom design for the Sol system if possible. If not, I understand and won't fret over it.

Thanks to anyone who can answer my questions, specifically the first one. There will be more questions later but I won't bother y'all for at least a day or two about them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: goduranus on September 27, 2019, 08:50:09 PM
Does anyone have a ready made paintjob of Pirate Harbinger, or is there a mod with Pirate Harbinger?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 27, 2019, 09:37:22 PM
sup, FS!
so i've been told that builtInModules is a thing.
as in, it is possible to set up station modules in a .ship file instead of a .variant
does anyone have any solid info on how it's supposed to work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 27, 2019, 09:46:06 PM
sup, FS!
so i've been told that builtInModules is a thing.
as in, it is possible to set up station modules in a .ship file instead of a .variant
does anyone have any solid info on how it's supposed to work?
last time i checked the raw hull will come out with modules even if they are not built in as long as the variant has them
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 27, 2019, 11:47:36 PM
last time i checked the raw hull will come out with modules even if they are not built in as long as the variant has them
but that will kinda defeat the purpose, no?
i mean, same could be said for weapons too and we still have the ability to make them built-in
the problem is that different variants can have different modules, which will cause serious problems when those modules are controlled by scripts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: syna on September 28, 2019, 05:57:58 AM
Is it possible to add more ship names to the ship_names.json? When I tried I got an outofbound error. So am I messing up something or is there a cap on the number of names in there?

Another question: Is it possible to add a hullmod to the .csv without it linking to a script file? I wanted to make an energy variant of my ballistic hull, change a few stats in the .ship file, and explain it with a cosmetic hullmod. But again I am getting errors when i tried it. Am I messing something up or does the game expect a value for the script field?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 28, 2019, 07:02:33 AM
I am getting a weird crash on the AI of my custom ship system

Code
63392 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: wurg_sensor]
java.lang.RuntimeException: wurg_sensor]
at com.fs.starfarer.loading.specs.M.createSystemAI(Unknown Source)
at com.fs.starfarer.combat.ai.BasicShipAI.<init>(Unknown Source)
at com.fs.starfarer.combat.ai.BasicShipAI.<init>(Unknown Source)
at com.fs.starfarer.launcher.ModManager.pickShipAIPlugin(Unknown Source)
at com.fs.starfarer.combat.CombatFleetManager.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatFleetManager.?00000(Unknown Source)
at com.fs.starfarer.combat.CombatFleetManager.deploy(Unknown Source)
at com.fs.starfarer.ui.impl.B.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.I.?00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.fs.starfarer.combat.systems.O00O cannot be cast to com.fs.starfarer.combat.systems.N
at com.fs.starfarer.combat.ai.system.OOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.<init>(Unknown Source)
... 17 more

This is the system
Code
"id":"wurg_sensor",
"type":"STAT_MOD",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.WurgSensorAI",

"statsScript":"data.scripts.shipsystems.WurgSensorStats",

"useSound":"wurg_activate",

Seems like it has something to do with my implementation of ShipSystemAIScript, but i have no idea what is wrong, i even commented all the code, here the WurgSensorAI

https://pastebin.com/GFRGaEMz

-edit-

Could it have something to do with me using other custom system? The defensive system is a drone spawner
Code
Wurgandal,edshipyard_wurgandal,Behemoth Drednaught,ED Shipyard,wurg_sensor,50,35000,1500,35000,15000,750,228,,15,10,5,3,1,6000,PHASE,wurg_drones,,,,,,1500,4000,2500,800,40,20,5,50000000,3,12,720,0.25,120,120,"SHIP_WITH_MODULES,UNBOARDABLE",,,0.4,2,4,500

Yep, it has something to do with my second system, the drones

Code
"id":"wurg_drones",
"type":"DRONE_LAUNCHER",
"aiType":"DRONE_LAUNCHER_PD",

"droneVariant":"edshipyard_wurgdrone_variant",

"allowFreeRoam":false,

"launchSpeed":300,
"launchDelay":2,
"maxDrones":3,
"droneBehavior":[
{"droneIndex":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],
"defaultFacing":"AWAY_FROM_SHIP", # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
"faceEnemy":true,
"holdRoamRange":1200,
"freeRoamRange":1200,
"targetPriority":[FIGHTER, SHIP, MISSILE, SHIP_TARGET], # also SHIP_TARGET to prefer targeting the mothership's target
"initialOrbitAngle":0,
"orbitRadius":600, # plus ship radius
"orbitDir":1, # -1 or 1
"orbitSpeed":100, # pixels/second
},
],

"useSound":"drone_launch",
"outOfUsesSound":"gun_out_of_ammo",

"aiHints":{
}

This is so disappointing because if you control the ship manually everything works, the crash only happens if the AI takes command... I guess i will have to split the drones into another module...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 28, 2019, 10:45:44 AM
I've had some problems with auto-fit pointed out with my mod, and I'd like to address them.

Basically, when the code for selecting a Variant runs, how does it pick an auto-fit?  The criteria it appears to be using are something like:

1.  Is it within OP budget?
2.  Something mysterious / undocumented regarding the weapon / Hull Mod tags.
3.  Whimsy.

The results are that occasionally we're seeing what should be terrifying ships that fall apart faster than a wet paper bag, amongst other things.

Sooooo... what I'd like, frankly, is:

1.  Auto-fit picks a stock Variant and installs all of its Hull Mods 100% of the time.  Hull Mods being subject to whimsy is especially problematic; they're usually set for specific circumstances.
2.  Auto-fit picks stock Variants more often than not, because the whimsy usually doesn't work.
3.  Auto-fit leaves certain weapons that are part of a stock Variant alone.  I have some "weapons" that Do Stuff; the auto-fit algo isn't making decent use of them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 28, 2019, 11:14:32 AM
Since i can't have my drones as a defensive system i made an extra module and put the system in there, it has default station drone AI, how do i command it to retrieve the drones when i want to fire my big beam of death so the drones don't spin around and get blasted by my own weapon?

I did try getSystem().deactivate() and useSystem(), but the module AI puts the drones back up instantly
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2019, 11:18:03 AM
 ::)
sup, FS!
so i've been told that builtInModules is a thing.
as in, it is possible to set up station modules in a .ship file instead of a .variant
does anyone have any solid info on how it's supposed to work?

You've been told wrong :)


last time i checked the raw hull will come out with modules even if they are not built in as long as the variant has them
but that will kinda defeat the purpose, no?
i mean, same could be said for weapons too and we still have the ability to make them built-in
the problem is that different variants can have different modules, which will cause serious problems when those modules are controlled by scripts.

The game doesn't really support that; the expectation is that the modules are the same base type in every variant of the ship-with-modules.


Is it possible to add more ship names to the ship_names.json? When I tried I got an outofbound error. So am I messing up something or is there a cap on the number of names in there?

Yep, it's possible - sounds like you've got a typo somewhere, something like a missing comma or bracket or some such.

Another question: Is it possible to add a hullmod to the .csv without it linking to a script file? I wanted to make an energy variant of my ballistic hull, change a few stats in the .ship file, and explain it with a cosmetic hullmod. But again I am getting errors when i tried it. Am I messing something up or does the game expect a value for the script field?

You need to specify a script, but it doesn't need to do anything. So you could I think just point it to:

com.fs.starfarer.api.combat.BaseHullMod

And that would do the job.


I am getting a weird crash on the AI of my custom ship system

The core DRONE_LAUNCHER_PD ai expects the ship system it works with to be a drone launcher ship system; it doesn't support being used as a right-click system. You could write a custom AI for the drones, however, the same way you've got one for your other system.

Since i can't have my drones as a defensive system i made an extra module and put the system in there, it has default station drone AI, how do i command it to retrieve the drones when i want to fire my big beam of death so the drones don't spin around and get blasted by my own weapon?

I did try getSystem().deactivate() and useSystem(), but the module AI puts the drones back up instantly

It's a bit odd that your big beam of death is hitting friendly fighters to begin with - personally, I'd set it to a collision class that doesn't do that. But that aside, right, custom AI would be the way to go imo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 28, 2019, 11:29:47 AM
I removed the fighter tags from my beam because i think it must hit allies too to be balanced, like how the Imperium Titan nuke is only balanced because it has the potential to hurt you more than the enemy

I suppose custom AI for the module is the best way then, i have to remember how i did it last time i tried to replace a ship's AI
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2019, 11:50:59 AM
Ah, I meant a custom AI for the ship system; you wouldn't need to have it in a separate module then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 28, 2019, 01:30:07 PM
Ah, I meant a custom AI for the ship system; you wouldn't need to have it in a separate module then.
Oh, so as long as the AI of the defensive right click system is custom then it will work? damn i don't believe i didn't try that, gonna test as soon as i finish work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2019, 01:41:36 PM
Yep, it should.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 28, 2019, 03:40:27 PM
Yep, it should.
It works! HAHAHAHA!
I overcame the no right click on modular ships glitch HAHAHAHAHA!
STATION DRONES ARE NOT A REAL TOGGLE SO I CAN ACTIVATE AND DEACTIVATE EVEN WITH THE GLITCH HAHAHAHA!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 28, 2019, 05:45:27 PM
Ah problem! How do i activate the right click system by script? I can't use setPhased(true) and it is not a shield, also useSystem() will use the main ship system not the right click one, and ShipSystemAPI has deactivate(), but not activate()

Also seems like ship.getDeployedDrones() is not getting the drones, i always get null out of it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2019, 06:11:04 PM
You'd have to use ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK)

... and, yeah, looks like getDeployedDrones() also assumes its a regular and not right-click system, so you'd need to iterate over all the ships in the engine, and check what their .getAIFlags() has for AIFlags.DRONE_MOTHERSHIP - it should be the mothership for drones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 28, 2019, 06:48:29 PM
You'd have to use ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK)

... and, yeah, looks like getDeployedDrones() also assumes its a regular and not right-click system, so you'd need to iterate over all the ships in the engine, and check what their .getAIFlags() has for AIFlags.DRONE_MOTHERSHIP - it should be the mothership for drones.
Works! Thanks again Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on September 30, 2019, 11:08:19 AM
In the ship_data.csv file there are coloms that say "8/6/5/4%" and "range" what do these represent?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 30, 2019, 11:51:11 AM
In the ship_data.csv file there are coloms that say "8/6/5/4%" and "range" what do these represent?
"8/6/5/4%" is not really used, i don't remember what it does, just leave whatever value in there.
"range" is the fuel range of the ship, in light years, divide "fuel" by "fuel/ly" to get the value, i don't know what happens if you use a different value that doesn't match your fuel and fuel/ly values.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2019, 11:57:18 AM
Right - both of these aren't actually used; in the spreadsheet I've got, they're set up to be populated using a formula, so that say I can see at a glance what the "range" of a ship is.

The 8/6/5/4% thing is meant for base flux capacity vs flux dissipation, based on hull size. I.E. a "typical" frigate ought to have its dissipation be 8% of its capacity. Most ships actually don't match this; it's just there as a baseline so for example if a ship's dissipation is better than this then it's either more expensive or is subpar in other areas.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on September 30, 2019, 12:22:01 PM
Thanks for the info! Didn't wanna mess with something without knowing what they did.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 30, 2019, 05:37:38 PM
Question on fireSoundOne on Beams.  It doesn't appear to play when we fire; it's just fireSoundTwo, looped.

Are there special circumstances?  PD Laser has laser_intro as fireSoundOne, PD Burst just has fireSoundOne, PhaseBeam has fireSoundOne commented out.  What are the rules for these?  I used to have cool Laser Intros, but they just don't appear to work now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2019, 08:57:50 PM
fireSoundOne plays when the beam fires initially; after that - if the beam continues to fire - it loops fireSoundTwo. Or, rather, it'll start playing both at the same time, but the volume of fireSoundTwo is modified by the current brightness level of the beam.

You can observe this by firing, say, repeatedly firing the PD Laser.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on September 30, 2019, 11:15:02 PM
Weird.  Can't hear fireSoundOne at all.  Maybe it needs the volume turned up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 01, 2019, 10:08:43 AM
Why might this happen?
Spoiler
(https://i.imgur.com/Xe7tQTf.jpg)

I'm trying to imitate how ShipRecoverySpecial handles ship recovery, except directly from an InteractionDialogPlugin (using ShipRecoverySpecial  properly doesn't seem to support my needs). Everything is working the way I want it to, except for this one bug. The biggest deviation from the ShipRecoverySpecial implementation is that I've removed all references to the ShipRecoverySpecialData instance (data), but I don't see how that could cause this issue. Here's how I'm calling showFleetMemberRecoveryDialog:

Code
public class SalvageFamousDerelictDialogPlugin implements InteractionDialogPlugin {
    public static final String RECOVER = "recover";

    InteractionDialogAPI dialog;
    FamousDerelictIntel intel;

    final SectorEntityToken derelict;
    final Random random;
    final CampaignFleetAPI playerFleet;
    final List shipList = new LinkedList();

    public SalvageFamousDerelictDialogPlugin(SectorEntityToken derelict) {
        this.derelict = derelict;
        this.random = new Random(derelict.toString().hashCode());
        this.playerFleet = Global.getSector().getPlayerFleet();
    }

    @Override
    public void init(InteractionDialogAPI dialog) {
        this.dialog = dialog;

        intel = (FamousDerelictIntel)derelict.getMemory().get(FamousDerelictIntel.MEMORY_KEY);

        intel.showRecoveryDescription(dialog.getTextPanel());
        prepareMember(intel.ship, intel.wreckData); /* Copied from ShipRecoverySpecial */
        shipList.add(intel.ship); /* shipList is fed to dialog.showFleetMemberRecoveryDialog */
        intel.ship.updateStats(); /* Just in case */

        dialog.getVisualPanel().showFleetMemberInfo(intel.ship, true);

        dialog.getOptionPanel().clearOptions();
        dialog.getOptionPanel().addOption("Consider ship recovery", RECOVER);
        dialog.getOptionPanel().addOption("Not now", LEAVE);
        dialog.getOptionPanel().setShortcut(LEAVE, Keyboard.KEY_ESCAPE, false, false, false, true);
    }

    @Override
    public void optionSelected(String optionText, Object optionData) {
        switch ((String)optionData) {
            case RECOVER:
                final CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
                dialog.showFleetMemberRecoveryDialog("Select ships to recover", shipList, new FleetMemberPickerListener() {
                    public void pickedFleetMembers(List<FleetMemberAPI> selected) {
                        if (selected.isEmpty()) return;

                        for (FleetMemberAPI member : selected) {
                            int index = shipList.indexOf(member);
                            if (index >= 0) {
                                /* ShipRecoverySpecial.PerShipData shipData = data.ships.get(index);
                                   data.ships.remove(index); */
                                shipList.remove(index);

                                float minHull = playerFleet.getStats().getDynamic().getValue(Stats.RECOVERED_HULL_MIN, 0f);
                                float maxHull = playerFleet.getStats().getDynamic().getValue(Stats.RECOVERED_HULL_MAX, 0f);
                                float minCR = playerFleet.getStats().getDynamic().getValue(Stats.RECOVERED_CR_MIN, 0f);
                                float maxCR = playerFleet.getStats().getDynamic().getValue(Stats.RECOVERED_CR_MAX, 0f);

                                float hull = (float) Math.random() * (maxHull - minHull) + minHull;
                                hull = Math.max(hull, member.getStatus().getHullFraction());
                                member.getStatus().setHullFraction(hull);

                                float cr = (float) Math.random() * (maxCR - minCR) + minCR;
                                member.getRepairTracker().setCR(cr);

                                playerFleet.getFleetData().addFleetMember(member);
                            }

                            dialog.getPlugin().optionSelected(null, RECOVERY_FINISHED);
                        }
                    }
                    public void cancelledFleetMemberPicking() { }
                });
                break;

            /* Other cases */
        }
    }

    /* Irrelevant stuff, including the copy of prepareMember and its supporting functions */
}

Thanks in advance for any help!
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2019, 10:46:42 AM
Hmm. With the caveat that I didn't really look at the code (brain currently mush, argh insomnia) - is the FleetMember mothballed? And/or does it have repairs suspended? (via getRepairTracker() etc)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 01, 2019, 11:23:23 AM
I tried calling all four combinations of these right before prepareMember:

Code
intel.ship.getRepairTracker().setSuspendRepairs(true / false);
intel.ship.getRepairTracker().setMothballed(true / false);
Whether or not repairs were suspended didn't seem to make a difference.
When mothballed crew required also showed 0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2019, 12:10:09 PM
Is it possible that the fleet member is already fully repaired and at full CR? I mean, that's supposed to be set in prepareMember(), but... hmm.

Maybe try not calling:
intel.ship.updateStats();
?

This is weird and nothing jumps out at me as being wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 01, 2019, 12:53:08 PM
Separate question, does the UNBOARDABLE tag for a ship also mean it will not be sold in faction markets? Or just that it can't be recovered after a battle through loot?

Just post-combat and derelict recovery.

Might want to take a look at this if you get a free moment. It doesn't seem to work all the time. Unless it just means you can never actually recover it but it still spawns as a derelict. (My mistake if so)

hulls entry for the ship:
Code
Doom (Ad),doom_adamantine,Phase Cruiser,Adamantine Consortium,temporalshell,12,18000,2000,25000,18000,1600,210,,80,140,110,40,50,1200,PHASE,phasecloak,,,,0.075,0.025,50,100,120,150,3,50,8,200000,8,8,500,0.25,12,5,"UNBOARDABLE, HIDE_IN_CODEX","ultra_rare_bp, consortium_bp, no_autofit",,0.6,2,3,13

Pics
Spoiler
(https://i.imgur.com/ekMrNpw.png)
(https://i.imgur.com/tGQ0VfO.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 01, 2019, 01:04:16 PM
I tried setting CR to 0 on my own as part of trying to troubleshoot this before I realized it was already done inside of prepareMember. Calling updateStats was something else I tried in an attempt to fix this. Maybe updateStats prevented one of your suggestions from working? I dunno. Anyway, I'll try to find things that might be off about the member's state. Thanks for pointing me in a plausible direction. I was running out of ideas...

Unless it just means you can never actually recover it but it still spawns as a derelict.
I'm pretty sure that is how UNBOARDABLE is supposed to work. Maybe "unrecoverable" would be more accurate, but it's not a player-facing word so eh
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2019, 02:23:23 PM
I tried setting CR to 0 on my own as part of trying to troubleshoot this before I realized it was already done inside of prepareMember. Calling updateStats was something else I tried in an attempt to fix this. Maybe updateStats prevented one of your suggestions from working? I dunno. Anyway, I'll try to find things that might be off about the member's state. Thanks for pointing me in a plausible direction. I was running out of ideas...

If you get stumped and can put a minimal mod together to reproduce this, I can take a look.

Unless it just means you can never actually recover it but it still spawns as a derelict.
I'm pretty sure that is how UNBOARDABLE is supposed to work. Maybe "unrecoverable" would be more accurate, but it's not a player-facing word so eh

Yeah, they can still spawn as derelicts; see: various droneships in vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 01, 2019, 03:07:31 PM
If you get stumped and can put a minimal mod together to reproduce this, I can take a look.
Well, thanks! You're too helpful. Don't you have a game to work on? :P
I might just end up doing that. I've spent a lot more time than I'd like trying to figure this out, but I'm probably just overlooking something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 01, 2019, 03:15:41 PM
My ships aren't being built per their Variant specifications, even if no_autofit is set. 

They're spawning with empty weapon slots; where the Variant uses my mod's weapons, they're not installed. 

If the Variant calls for Vanilla weapons, all is fine.

What can cause this to happen?  I have a Blueprint Package defined for my Faction in special_items.csv, the ships and weapons are all functional and are listed in default_ship_roles / the Faction's files in KnownWeapons, etc., etc.

IIRC, this wasn't happening when the Blueprint Package for the weapons was set to hightech_bp; I'll test that out now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2019, 03:21:23 PM
Weapons need the right tags to work with autofit; that's probably it.


Well, thanks! You're too helpful. Don't you have a game to work on? :P
/quote]

:D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 01, 2019, 03:28:18 PM
I've just tested, and nope, setting the weapons to base_dp didn't fix it, either. 

It's like the weapons aren't getting loaded by whatever code is supposed to be aware of their existence when creating new ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 01, 2019, 03:31:42 PM
Unless it just means you can never actually recover it but it still spawns as a derelict.
I'm pretty sure that is how UNBOARDABLE is supposed to work. Maybe "unrecoverable" would be more accurate, but it's not a player-facing word so eh

Yeah, they can still spawn as derelicts; see: various droneships in vanilla.

Ok awesome, thanks for the clarification both of you and sorry for the false alarm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 01, 2019, 04:16:47 PM
Aaaaaa how do i make my custom hullmods not appear in blueprints?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 01, 2019, 04:36:05 PM
Setting "hidden" to true in your hull_mods.csv should do the trick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 01, 2019, 05:54:58 PM
@Alex:  I found it, finally!

So... basically, not setting missile8, strike0, etc., etc., in the tags is the cause of this problem.  Put them in, and voila, problem was solved.

These are obviously used by the autofit code, but they really aren't documented; at some point it might be a good idea to explain how they work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 01, 2019, 06:05:14 PM
Setting "hidden" to true in your hull_mods.csv should do the trick.
Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2019, 06:05:30 PM
Weapons need the right tags to work with autofit; that's probably it.

Ah, I guess you didn't see my response :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 02, 2019, 07:35:31 AM
I am trying to make a custom Fighter AI, but I am having trouble, is there any mod that has custom fighters so i can check how it was done?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: worldwidewizard on October 02, 2019, 08:14:48 AM
One time I saw my AI-controlled Odyssey go full BOOSTO FIYA into an enemy frigate and smash it to pieces. Luddic Path ships occasionally do this as well, but not regularly. Is there a way to make the ship AI do this as a tactic? Say, if I mounted a ram to the front of a ship, how could I make the AI regularly use it aside from assigning it a "reckless" officer?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 02, 2019, 12:04:05 PM
I am trying to make a custom Fighter AI, but I am having trouble, is there any mod that has custom fighters so i can check how it was done?

(I don't know, personally.)

One time I saw my AI-controlled Odyssey go full BOOSTO FIYA into an enemy frigate and smash it to pieces. Luddic Path ships occasionally do this as well, but not regularly. Is there a way to make the ship AI do this as a tactic? Say, if I mounted a ram to the front of a ship, how could I make the AI regularly use it aside from assigning it a "reckless" officer?

You'd have to write a custom ship system AI that would basically detect when activating the system would result in a ramming action and use it then. Actually making the ship actively seek out ramming opportunities would be much more complicated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 02, 2019, 12:04:13 PM
Is there a way to check if a ship or weapon has a blueprint? (Not a specific blueprint, just any tag ending in _bp.)

For context, I'm working on something that'll add "common" blueprints. Like rare blueprints, but only for things that A) have blueprints, B) don't have no drop, and C) don't have rare_bp. I'm hoping for a way to exclude things that don't have package or rare blueprints without having to relist everything, as that would make it... quite incompatible.

Also, does anyone know where the code for generating a rare_bp lies?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 02, 2019, 02:03:39 PM
Is there a way to check if a ship or weapon has a blueprint? (Not a specific blueprint, just any tag ending in _bp.)
I don't know if there's a convenient API method for it, but if worse comes to worse you could always iterate over the ship/weapon spec's tags to see if any end in "_bp"

Also, does anyone know where the code for generating a rare_bp lies?
Not sure if this answers your question, but the only occurrence of "rare_bp" in the API is when it's assigned to com.fs.starfarer.api.impl.campaign.ids.Items.TAG_RARE_BP. There are no usages of that field referenced in the API, so I suspect all of that stuff is handled by obfuscated code. Hopefully someone will correct me if that's not the case. (edit: It's not. rare_bp is referenced in some loose files, such as drop_groups.csv)

I'm pretty sure Vesperon Combine (http://fractalsoftworks.com/forum/index.php?topic=14915.0) adds new ways to obtain blueprints. You might find it useful for reference.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 02, 2019, 02:13:03 PM
Quote
I am trying to make a custom Fighter AI, but I am having trouble, is there any mod that has custom fighters so i can check how it was done?
Fighter AIs are basically Ship AIs (with various caveats, depending on what Vanilla features you wish to support).  The only extant full AI replacement mod is mine (https://www.nexusmods.com/starsector/mods/33), so far as I'm aware.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 02, 2019, 02:31:44 PM
Not sure if this answers your question, but the only occurrence of "rare_bp" in the API is when it's assigned to com.fs.starfarer.api.impl.campaign.ids.Items.TAG_RARE_BP. There are no usages of that field referenced in the API, so I suspect all of that stuff is handled by obfuscated code. Hopefully someone will correct me if that's not the case.
I know drop_groups.csv has:
Code
#item_:{tags:[single_bp], p:{tags:[rare_bp]}}
item_ship_bp:{tags:[rare_bp, !no_drop]}
item_weapon_bp:{tags:[rare_bp, !no_drop]}
item_fighter_bp:{tags:[rare_bp, !no_drop]}
item_:{tags:[package_bp, !no_drop]}
But I'm not sure how it distinguishes between ship weapon and fighter, and how that'd affect adding new ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 02, 2019, 02:32:27 PM
Quote
I am trying to make a custom Fighter AI, but I am having trouble, is there any mod that has custom fighters so i can check how it was done?
Fighter AIs are basically Ship AIs (with various caveats, depending on what Vanilla features you wish to support).  The only extant full AI replacement mod is mine (https://www.nexusmods.com/starsector/mods/33), so far as I'm aware.
Oh juicy, thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 02, 2019, 04:03:55 PM
Is there a way to have a ship start battle with fewer than the full number of charges for its ship system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 02, 2019, 04:34:50 PM
I know drop_groups.csv has:
Code
#item_:{tags:[single_bp], p:{tags:[rare_bp]}}
item_ship_bp:{tags:[rare_bp, !no_drop]}
item_weapon_bp:{tags:[rare_bp, !no_drop]}
item_fighter_bp:{tags:[rare_bp, !no_drop]}
item_:{tags:[package_bp, !no_drop]}
Ah, good point. I should've known something like that wouldn't be obfuscated. I'll edit my post to cross out that misleading suggestion.


Is there a way to have a ship start battle with fewer than the full number of charges for its ship system?
I think you'll probably end up having to manually set the number of charges when the ship is deployed:
Code
ship.getSystem().setAmmo(3);
I'm not aware of any non-awkward way to access ships the moment they're deployed though (@Alex: hint-hint, wink-wink)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 02, 2019, 06:56:18 PM
Dang, thanks. Do you know any awkward ways to do it? From some amateurish poking around, it seems I can't get a valid ShipAPI from a MutableShipStatsAPI at all.

EDIT: Nevermind, I figured it out :) and it wasn't even that awkward.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on October 02, 2019, 08:01:02 PM
Im currently in a campaign rn with a mod im working on and im wondering if i add a ship to it will it show up naturally in the campaign after a lil bit or nah?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: worldwidewizard on October 02, 2019, 08:34:05 PM
You'd have to write a custom ship system AI that would basically detect when activating the system would result in a ramming action and use it then. Actually making the ship actively seek out ramming opportunities would be much more complicated.
That sounds like a challenge :D Please bear with me because I'm really new to this, but where would I find the files that deal with ship system AI or ship AI in general? Up until now I've resorted to digging through the APIs and .java files for references and it's all been incredibly overwhelming.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 03, 2019, 01:59:18 AM
Quick update, adding:
Code
item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_weapon_bp:{tags:[single_bp, !rare_bp, !no_drop]}

item_fighter_bp:{tags:[single_bp, !rare_bp, !no_drop]}

item_ship_bp:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}
Works, but it also grabs things like D mod variants (which when learnt don't give anything) and presumably stuff like the Domain ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 03, 2019, 07:58:05 AM
Request: Can PlayerRelatedPirateBaseManager be made to ignore isHidden() player markets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 03, 2019, 10:18:23 AM
Im currently in a campaign rn with a mod im working on and im wondering if i add a ship to it will it show up naturally in the campaign after a lil bit or nah?
I think it will, as far as i know only planets/systems won't be added if you enable their mods midway through the campaign
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 03, 2019, 10:20:28 AM
Is there a way to prevent specific messages, like "Incoming vessel" for a particular ship, from appearing during battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2019, 01:14:58 PM
Im currently in a campaign rn with a mod im working on and im wondering if i add a ship to it will it show up naturally in the campaign after a lil bit or nah?

I believe so, provided it's added to the .faction/has variants/is added default ship roles.



That sounds like a challenge :D Please bear with me because I'm really new to this, but where would I find the files that deal with ship system AI or ship AI in general? Up until now I've resorted to digging through the APIs and .java files for references and it's all been incredibly overwhelming.

For a quick example of a ship system AI, see:
data.shipsystems.scripts.ai.FastMissileRacksAI
It's just there as an example. To specify your own AI for a system you'd add this to the .system file:
"aiScript":"data.shipsystems.scripts.ai.FastMissileRacksAI",

For ship AI, that's in core code and not directly visible. It's also massively more complex.

Quick update, adding:
Code
item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_weapon_bp:{tags:[single_bp, !rare_bp, !no_drop]}

item_fighter_bp:{tags:[single_bp, !rare_bp, !no_drop]}

item_ship_bp:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}

item_:{tags:[single_bp, !rare_bp, !no_drop]}
Works, but it also grabs things like D mod variants (which when learnt don't give anything) and presumably stuff like the Domain ships.

Yeah, it's just... difficult. What you really want is, probably, to add a new tag to stuff - possibly via code. If you're doing a combination of "not this" and "not that", it seems really likely to pick up some unintended stuff, especially when mods are factored in.


Request: Can PlayerRelatedPirateBaseManager be made to ignore isHidden() player markets?

... sure, why not? Done.


Is there a way to prevent specific messages, like "Incoming vessel" for a particular ship, from appearing during battle?

You can use CombatFleetManagerAPI.setSuppressDeploymentMessages()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 03, 2019, 01:46:57 PM
Yeah, it's just... difficult. What you really want is, probably, to add a new tag to stuff - possibly via code. If you're doing a combination of "not this" and "not that", it seems really likely to pick up some unintended stuff, especially when mods are factored in.
That's what I was afraid of. Is there a way to dynamically read and write tags?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2019, 02:33:33 PM
Yeah, ShipHullSpecAPI.getTags()/addTag()/etc; likewise for weapon and fighter specs, iirc. You'd need to do it onApplicationStart(), more than likely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 03, 2019, 02:48:49 PM
Thanks!

I hate to infringe, but I'd hesitate to even call myself a scriptkid.
If a script were to check for, say, "pirate_bp", what would that look like?

From my limited understanding getTags would result in a string? How would I parse that for specific tags?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2019, 03:00:10 PM
Per this:
http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipHullSpecAPI.html#getTags()

It returns a Set<String>

So it'd look like: spec.getTags().contains("pirate_bp")
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 03, 2019, 03:03:56 PM
Amazing, thanks!
Shows how little I know of java :P
So something like this?
Code
if (spec.getTags().contains("_bp") && !spec.getTags().contains("rare_bp")) {spec.addTag("common_bp")};
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2019, 03:49:13 PM
spec.getTags().contains("_bp")

That wouldn't work - you might want to check out the javadoc for Set:
https://docs.oracle.com/javase/7/docs/api/java/util/Set.html

contains() just checks if the whole string is in the set, not parts of it. To do what you're doing you'd need to iterate over the set's element and check each one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 03, 2019, 04:08:23 PM
spec.getTags().contains("_bp")

That wouldn't work - you might want to check out the javadoc for Set:
https://docs.oracle.com/javase/7/docs/api/java/util/Set.html

contains() just checks if the whole string is in the set, not parts of it. To do what you're doing you'd need to iterate over the set's element and check each one.
Okay, thanks (yet) again!
At worst I can just check for blueprint packs that I know of. That's a bit more work than I'd hoped, but at least it's trivial work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 03, 2019, 05:30:01 PM
to check if two ships are in the same team i use "ship1.getOwner() == ship2.getOwner()" right?
Also what is the difference between .isHulk() and .isAlive() aren't they the same (but return the opposite boolean)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2019, 06:35:08 PM
to check if two ships are in the same team i use "ship1.getOwner() == ship2.getOwner()" right?

Yeah. Of note: hulks/neutral ships have owner == 100.

Also what is the difference between .isHulk() and .isAlive() aren't they the same (but return the opposite boolean)?

isHulk() is when the ship is disabled. isAlive() also checks that it exists in the combat engine; i.e. a ship that was removed via a script but was never destroyed would be isHulk() == false AND isAlive() == false. So isAlive() is more stringent/reliable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 03, 2019, 06:48:09 PM
Thanks for clarifying
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 03, 2019, 06:50:55 PM
Yep!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 03, 2019, 11:39:07 PM
Which integer represents which side in CombatEntityAPI.getOwner()? Is it 0, 1, -100 for player, opponent, neutral?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2019, 08:23:48 AM
0 = player/ally, 1 = enemy, 100 = neutral.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: outdated on October 04, 2019, 02:05:50 PM
Can you stick a hullmod on a fighter and would ground support hullmod work, or does a fighter effectively not exist before it's carrier is deployed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 04, 2019, 04:12:17 PM
does a fighter effectively not exist before it's carrier is deployed?
I'm afraid that is the case, yeah. If you want fighters to confer ground-support-like bonuses, you're probably better off not involving hullmods.

If you get stumped and can put a minimal mod together to reproduce this, I can take a look.
I decided to take you up on this. Mini-mod is attached. It shows a recovery dialog any time reportShownInteractionDialog is called. The recovery dialog works without issue if I feed it the player flagship, but not a newly created one, so I must be failing to properly initialize the ship. However, I can't find anything that ShipRecoverySpecial is doing that I'm not, so I don't know what I'm missing. Again, thanks for the help!

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2019, 05:03:11 PM
Aha!

See the last couple of lines here:

Code
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;

Random rand = new Random();

ship.setOwner(1);
ship.getStatus().setRandom(rand);
ship.getStatus().setHullFraction(0.1f);
ship.getRepairTracker().setCR(0f);

ShipVariantAPI variant = ship.getVariant();
variant = variant.clone();
variant.setOriginalVariant(null);

int dModsAlready = DModManager.getNumDMods(variant);
int dmods = Math.max(0, 5 - dModsAlready);
DModManager.setDHull(variant);
ship.setVariant(variant, false, true);

DModManager.addDMods(ship, true, dmods, rand);

float retain = 0.5f;
FleetEncounterContext.prepareShipForRecovery(ship, false, false, retain, retain, rand);
ship.getVariant().autoGenerateWeaponGroups();
           
CampaignFleetAPI recoverable = Global.getFactory().createEmptyFleet(Factions.NEUTRAL, FleetTypes.PATROL_SMALL, true);
recoverable.getFleetData().addFleetMember(ship);

Looks like you need to add the FleetMemberAPI to a faked-up AI fleet - otherwise, it's considered to have no crew and thus zero recovery rate. ShipRecoverySpecial does this but your code wasn't; tried the above change and it works.

Thank you for making this easy to test - especially having the code in loose scripts was really handy to be able to verify the change actually working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 04, 2019, 06:58:41 PM
Ah, excellent. Thank you! I thought those lines were irrelevant since the fleet instance is only used locally for something unrelated. I didn't consider what the fleet might be doing to the ship once added.

Thank you for making this easy to test - especially having the code in loose scripts was really handy to be able to verify the change actually working.
Heh. You saved me a great deal of time by taking a look at this. The least I could do is make it easier for you to help me  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2019, 07:08:02 PM
Glad that's sorted, sorry it turned out to be so arcane! I was scratching my head for a bit when I saw the "normal" recovery FleetMember referring to a "neutral small patrol" :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: captinjoehenry on October 04, 2019, 07:15:12 PM
How do I add a military market to an non player market?  I'm asking as there are no independent military markets in game that I can find and I feel like there really probably should be one so I'm wondering how I can add one in. 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 04, 2019, 07:35:18 PM
Glad that's sorted, sorry it turned out to be so arcane!
Heh. No worries. If it weren't something arcane I'd be kicking myself for missing it  :)

How do I add a military market to an non player market?  I'm asking as there are no independent military markets in game that I can find and I feel like there really probably should be one so I'm wondering how I can add one in. 
I don't know how to do that off the top of my head, but you should visit Nortia in Askonia, which has a size 4 independent military market. Not sure if there are others.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 04, 2019, 07:40:50 PM
I updated a mod that adds some ships (prv Starworks, specifically). Now, in my existing save, the list
Code: java
List<ShipVariantAPI> targets = Global.getSector().getAutofitVariants().getTargetVariants(ship.getHullId());
can contain entries that are null, for some of the ships in the updated mod.
The null entries don't appear to exist in a new game.

How do I make the null variants go away?

How do I add a military market to an non player market?  I'm asking as there are no independent military markets in game that I can find and I feel like there really probably should be one so I'm wondering how I can add one in. 
To add a military market one-time in current game: Console while docked at the planet/station, then undock and redock
Code
runcode Global.getSector().getCampaignUI().getCurrentInteractionDialog().getInteractionTarget().getMarket().addSubmarket("generic_military")
To apply this to every future game, open [starsector-core]/data/campaign/econ/<systemname>.json and add a "militarybase" to the industries table of the relevant planet or station.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2019, 08:18:07 PM
I updated a mod that adds some ships (prv Starworks, specifically). Now, in my existing save, the list
Code: java
List<ShipVariantAPI> targets = Global.getSector().getAutofitVariants().getTargetVariants(ship.getHullId());
can contain entries that are null, for some of the ships in the updated mod.
The null entries don't appear to exist in a new game.

How do I make the null variants go away?

I don't think you can - looking at the code, if they're null, it's a stock variant that's no longer present. But this is a more generally troublesome condition - i.e. if there's a fleet that has one of these, or a derelict that's based on one of them, etc, those could all crash the game at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 05, 2019, 12:29:25 AM
How would I just detect when the player fleet undocks from a market or docks into a market then deduct him a $1 credit every time for each ship in his fleet he tries to dock and undock?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on October 05, 2019, 10:18:56 AM
q, is there way how simply change the star-system grid max-size (for me it seems it's 26k x 26k ) ?

for custom (new) star-system ofc
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 05, 2019, 11:43:57 AM
How would I just detect when the player fleet undocks from a market or docks into a market then deduct him a $1 credit every time for each ship in his fleet he tries to dock and undock?

See: CampaignEventListener.reportPlayerOpenedMarket() and SectorAPI.addListener()

q, is there way how simply change the star-system grid max-size (for me it seems it's 26k x 26k ) ?

<checks> looks like that's suuuuper hardcoded, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 05, 2019, 12:27:27 PM
Does plugin_params accept a list?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on October 05, 2019, 01:00:24 PM
What does the yag "no_drop" mean? Like it doesn't drop in combat salvage?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 05, 2019, 01:01:38 PM
What does the yag "no_drop" mean? Like it doesn't drop in combat salvage?
It won't drop ever, as far as I know.
It's used for things like the XIV package, where you can only ever get rare drops of individual blueprints from it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 05, 2019, 01:10:13 PM
Does plugin_params accept a list?

It can be an arbitrary string, iirc - depends on what the plugin is coded to do with it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on October 05, 2019, 01:12:22 PM
Yet another question in my quest for custom blueprints, what does "plugin_params" mean?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 05, 2019, 01:17:03 PM
It can be an arbitrary string, iirc - depends on what the plugin is coded to do with it.
In this case I'm looking at com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin for the special_items.csv

EDIT: Follow up question, how exactly does drop_groups determine what it's dropping? Looking at it, I'd guess ID from entries like item_synchrotron, but then there's entries that are just item_:

What I'm looking to do is create a universal blueprint (let's say it has an id of common_package) and then drop individual non-rare blueprints from that. Would item_common_package:{tags:[single_bp, !rare_bp, !no_drop]} work?

Yet another question in my quest for custom blueprints, what does "plugin_params" mean?
In the way you'd be using it, it's what tag (or hopefully, tags) can define something as part of the package.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on October 05, 2019, 01:26:57 PM
q, is there way how simply change the star-system grid max-size (for me it seems it's 26k x 26k ) ?

<checks> looks like that's suuuuper hardcoded, sorry!


oh noes, my system is up to 40k units and i need some more  :o ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 05, 2019, 02:00:26 PM
In this case I'm looking at com.fs.starfarer.api.campaign.impl.items.MultiBlueprintItemPlugin for the special_items.csv

Code
public class MultiBlueprintItemPlugin extends BaseSpecialItemPlugin implements BlueprintProviderItem {


protected Set<String> tags = new LinkedHashSet<String>();
@Override
public void init(CargoStackAPI stack) {
super.init(stack);

String param = spec.getParams();
if (!param.isEmpty()) {
for (String tag : param.split(",")) {
tag = tag.trim();
if (tag.isEmpty()) continue;
tags.add(tag);
}
}
}

So, looks like it supports a comma-separated list.

EDIT: Follow up question, how exactly does drop_groups determine what it's dropping? Looking at it, I'd guess ID from entries like item_synchrotron, but then there's entries that are just item_:

What I'm looking to do is create a universal blueprint (let's say it has an id of common_package) and then drop individual non-rare blueprints from that. Would item_common_package:{tags:[single_bp, !rare_bp, !no_drop]} work?

See: Salvage Generation and Drop Groups (http://fractalsoftworks.com/forum/index.php?topic=15244.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 05, 2019, 02:20:45 PM
See: Salvage Generation and Drop Groups (http://fractalsoftworks.com/forum/index.php?topic=15244.0)
Thanks. From what I'm getting from that, my idea wouldn't work, but I can just add a single_bp drop for each existing package, e.g. item_:{tags:[single_bp], p:{tags:[lowtech_bp, !rare_bp, !no_drop]]}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on October 05, 2019, 10:48:13 PM
I added all my ships into a blueprint group so they can be found together and now they arent spawning in the world anymore, did that effect it or somthing unrelated? And if it did how do i keep them in a Blueprint group with them still spawning?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: goduranus on October 05, 2019, 11:06:33 PM
How do I remove items from the .faction/.variant files?

Say for example, I want to remove fighter_doctrine from Tri-Tachyons fleet commander skills. Adding items look easy, I don't know how to remove items yet.
      "commanderSkills":[
         "ship_design",
         "electronic_warfare",
         "fighter_doctrine",
         "officer_management",
         "coordinated_maneuvers",
      ],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 06, 2019, 07:47:48 AM
How do i print something into the log to test my stuff?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 06, 2019, 10:22:50 AM
I added all my ships into a blueprint group so they can be found together and now they arent spawning in the world anymore, did that effect it or somthing unrelated? And if it did how do i keep them in a Blueprint group with them still spawning?

Could you be more specific? I am not sure what you're asking. Where are you expecting them to spawn, how are you verifying that they don't, how is the blueprint package set up, etc?

How do I remove items from the .faction/.variant files?

Say for example, I want to remove fighter_doctrine from Tri-Tachyons fleet commander skills. Adding items look easy, I don't know how to remove items yet.
      "commanderSkills":[
         "ship_design",
         "electronic_warfare",
         "fighter_doctrine",
         "officer_management",
         "coordinated_maneuvers",
      ],


To remove them, you have to use code; the file-merging generally doesn't support removing things from a list.

Faction.getDoctrine().getCommanderSkills().remove(<skill id>)

Well, you could actually do it with the .faction file, but you'd have to have your mod replace it with your copy rather than change it, and that doesn't play nice with other mods.

How do i print something into the log to test my stuff?

public static Logger log = Global.getLogger(<YourClassName>.class);

log.error()/log.info()/etc

See: OfficerManagerEvent for an example.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on October 06, 2019, 12:01:48 PM
Oh my bad, i mean in ship_data.csv i changed the tag colom near the end that specifies what blueprints they can be learned from into a custom one so my own mod ships can be found together, they usually spawn all around the markets and factions and are present at the start but as soon as i did that they no longer show up except through console commands and codex.
Sorry im very new at this lol
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 06, 2019, 12:23:10 PM
Ah, so you mean your ships are not showing up, not their blueprints? Because blueprints wouldn't normally show up on markets.

This might be if tags you had before, other factions were set up to use ships with those tags, so had access to them, but after you changed the tags, they no longer do. Hard to say for sure, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ydrials on October 06, 2019, 01:24:20 PM
I have found something in the rules.csv regarding Customs inspections and tolls/fines, with the help of "SafariJohn's Rules Tool". I've tried changing stuff and testing it in the game without success, and I'm pretty sure nothing of that is currently in the game, at all. It's under "customs inspection" in the rules.csv. Is there any way to use, test or play the game with this? Having more consequences to smuggling would be pretty cool imo
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 06, 2019, 01:49:37 PM
Yes, you can extend and overwrite rules.csv, but it sounds like you might need to do more than that in order to do what you want. Some pages about rules.csv editing:
http://fractalsoftworks.com/forum/index.php?topic=8355.0
https://docs.google.com/document/d/1aBZlAKqF0o4AknIcENQSfLvYJHseMtzQb01_CLjKZU4/pub?embedded=true
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on October 06, 2019, 03:24:53 PM
Ah, so you mean your ships are not showing up, not their blueprints? Because blueprints wouldn't normally show up on markets.

This might be if tags you had before, other factions were set up to use ships with those tags, so had access to them, but after you changed the tags, they no longer do. Hard to say for sure, though.

Yep! Digged around and that was the problem, reverted them back to regular bps, just gotta leave em like that till i add a proper faction to use them it seems, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ydrials on October 07, 2019, 04:27:06 AM
Yes, you can extend and overwrite rules.csv, but it sounds like you might need to do more than that in order to do what you want. Some pages about rules.csv editing:
http://fractalsoftworks.com/forum/index.php?topic=8355.0
https://docs.google.com/document/d/1aBZlAKqF0o4AknIcENQSfLvYJHseMtzQb01_CLjKZU4/pub?embedded=true

It looks like most dialog screens are triggered by "greetingDefaultTurnOnT" (which I presume is what kicks in when you turn on your transponder while in contact with something else), which is only triggered by "greetingDefaultTOffWeaker" and "greetingDefaultTOffNormal". Maybe putting stuff this way was a way to temporarily disable some content for later?

My question is, what runs when a patrol fleet contacts you for a cargo inspection? I'm very curious about why this whole customs thing is in the rules.csv but apparently not present in the game itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 07, 2019, 11:44:33 PM
How do I find out the dps duration of a beam?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 08, 2019, 08:01:54 AM
My question is, what runs when a patrol fleet contacts you for a cargo inspection? I'm very curious about why this whole customs thing is in the rules.csv but apparently not present in the game itself.

I... don't quite remember. I think it might be commented out in rules.csv? If the rule id starts with #, that rule isn't loaded.

How do I find out the dps duration of a beam?

What do you mean, exactly? What's the context?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 08, 2019, 01:16:25 PM
What do you mean, exactly? What's the context?
Sorry I wasn't clear - by DPS duration I mean what is returned from beam.getDamage().getDpsDuration(). What about the weapon files determines it - is it beam speed?

I noticed the Tachyon Lance and Ion Beam effect plugins had similar structure, but different values for fireInterval, and I'm trying to figure out how you came up with those values so I can apply correctly to any given beam.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 08, 2019, 01:48:10 PM
Ah - beams deal damage in "ticks" instead of every frame, for performance reasons. IIRC one beam tick is 0.1 seconds. So dps duration should be right around that every time, though it might not be exact.

The fireInterval duration in the TL/IB plugins was set based on how often I wanted the arc effects to proc. So, it's not directly related to dps duration - dps duration is only used to keep track of time passing. Does this make sense? If not, I can definitely clarify.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on October 08, 2019, 02:42:42 PM
Is there any existing (I don't think there is) or in-progress work to make writing campaign missions/quests/stories/bar events/whatever you call them easier to write?
(gonna call them quests to differentiate from the non-campaign missions)

Right now, there is a lot of learning overhead involved in creating a story-type quest for the player (eg a fetch quest). Maybe there's a csv way I'm unaware of, but you need to know how to make a BarEventCreator, a BarEvent, probably some intel, and how to add all of these into the game via a LifecyclePlugin or similar. Also, Java or Kotlin.

I've spent a bit of time modding Endless Sky and the dev uses text files  (https://github.com/endless-sky/endless-sky/blob/master/data/hai%20missions.txt)with a YAML-like syntax for declaring quests. There are inherent differences between Starsector and Endless Sky, of course, such as procedural generation, but I think that quests could benefit from a more concise, declarative, layman syntax than they have currently.

Would this be a reasonable thing to try to work on, or is there already something in the works? Especially hoping to hear from Alex if Starsector itself is going to have a quest framework update.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 08, 2019, 03:14:47 PM
Does this make sense?
Yes, this entirely the info I was looking for, thanks a lot! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 08, 2019, 05:45:04 PM
I want to make a weapon with custom animation controlled by the ship system, i don't want the player to be able to use them manually
I am using BUILT-IN slots, should i switch to SYSTEM slots? How do i set the weapon in a SYSTEM slot?
Should i limit the firing of the gun by adding ammo and setting to 0 on the system script? Or is there a more elegant way to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 08, 2019, 07:17:41 PM
Is there any existing (I don't think there is) or in-progress work to make writing campaign missions/quests/stories/bar events/whatever you call them easier to write?
(gonna call them quests to differentiate from the non-campaign missions)

Right now, there is a lot of learning overhead involved in creating a story-type quest for the player (eg a fetch quest). Maybe there's a csv way I'm unaware of, but you need to know how to make a BarEventCreator, a BarEvent, probably some intel, and how to add all of these into the game via a LifecyclePlugin or similar. Also, Java or Kotlin.

I've spent a bit of time modding Endless Sky and the dev uses text files  (https://github.com/endless-sky/endless-sky/blob/master/data/hai%20missions.txt)with a YAML-like syntax for declaring quests. There are inherent differences between Starsector and Endless Sky, of course, such as procedural generation, but I think that quests could benefit from a more concise, declarative, layman syntax than they have currently.

Would this be a reasonable thing to try to work on, or is there already something in the works? Especially hoping to hear from Alex if Starsector itself is going to have a quest framework update.

Hi! Not that I'm aware of, but I could be unaware of something that's in-progress.

Generally speaking, I agree with your sentiment, btw. It's just a difficult thing to do because the scope of what missions might allow is fairly undefined right now, and a declarative approach would cut it down. Figuring out just how to cut it down requires figuring out the scope more exactly, so... well. Basically, the current approach is a bit more labor-intensive and requires more knowledge of how stuff works under the hood, but it's also more flexible.

To answer your question, I'm not 100% sure whether there'd be a framework update or not. For bar events and such, I'm fairly happy with how they're set up - it requires some knowledge of how things work, but it's not terribly labor-intensitve. Other stuff... well, just not 100% sure, but I'd lean towards the "probably not going to" option. At least, I don't see restructuring it - at most, it'd be adding some data-driven/declarative layers on top. Which is what you're talking about doing, and which is, I think, a great idea.

I want to make a weapon with custom animation controlled by the ship system, i don't want the player to be able to use them manually
I am using BUILT-IN slots, should i switch to SYSTEM slots? How do i set the weapon in a SYSTEM slot?
Should i limit the firing of the gun by adding ammo and setting to 0 on the system script? Or is there a more elegant way to do this?

IIRC you can just put a weapon into a system slot the way you would put it into a BUILT_IN slot. I think. If it was in a SYSTEM slot, I don't believe the player would be able to select or fire it or aim it, so its control *should* be up to the system script. I may be mistaken on any of the points here, however.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: goduranus on October 09, 2019, 02:57:58 AM
Thanks.
Also, should setting autofitRandomizeProbability to 0 cause the faction ship designs to strictly stick to the .variant file? I made a few carrier variants with Thunders but in game the Hegemony replaces them with Gladius' and Broadswords. I've made sure the Hegemony knows Thunder blueprints in this case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 09, 2019, 05:06:25 AM
IIRC you can just put a weapon into a system slot the way you would put it into a BUILT_IN slot. I think. If it was in a SYSTEM slot, I don't believe the player would be able to select or fire it or aim it, so its control *should* be up to the system script. I may be mistaken on any of the points here, however.
What is the functional difference between Decoration and System weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 09, 2019, 09:46:16 AM
Also, should setting autofitRandomizeProbability to 0 cause the faction ship designs to strictly stick to the .variant file? I made a few carrier variants with Thunders but in game the Hegemony replaces them with Gladius' and Broadswords. I've made sure the Hegemony knows Thunder blueprints in this case.

No, autofitRandomizeProbability is the probability from more significantly deviating from the goal variants, so it'll still deviate, it just won't randomize quite so much.


IIRC you can just put a weapon into a system slot the way you would put it into a BUILT_IN slot. I think. If it was in a SYSTEM slot, I don't believe the player would be able to select or fire it or aim it, so its control *should* be up to the system script. I may be mistaken on any of the points here, however.
What is the functional difference between Decoration and System weapons?

Not much of one currently IIRC; for SYSTEM it'll include their flux use in the refit screen's weapon flux use I believe; I'm not sure there's anything else or not. There well could be, especially to do with campaign-level rendering - i.e. it might render decorative weapons but not system ones (or regular fitted ones) on the ships you see in the campaign.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 09, 2019, 01:14:27 PM
Is there any way to change the range bonus for a single specific weapon? For example, to negate a range bonus/penalty from hull mods on a built in weapon, or to dynamically change its range with a ship system without affecting other weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 09, 2019, 01:39:05 PM
The only way right now would be if the built-in weapon is a type unique to that ship - i.e. the weapon is energy type, no other slots allow energy weapons, and the hullmod boosts the range of energy weapons.

In the next release, it'll be possible for arbitrary weapons without this type of restriction, via a WeaponRangeModifier that will be able to be added to ShipAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 09, 2019, 01:44:16 PM
Okay, that's good news on the upcoming :) another question: do missiles have weight? If so, is it relative to any of their .csv stats?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 09, 2019, 01:47:23 PM
You mean for flamed-out missiles colliding with things, right? IIRC it's the "impact" value from the csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 09, 2019, 09:47:57 PM
Unless it just means you can never actually recover it but it still spawns as a derelict.
I'm pretty sure that is how UNBOARDABLE is supposed to work. Maybe "unrecoverable" would be more accurate, but it's not a player-facing word so eh

So after further testing, yes, this is misleading. It apparently also means that you cannot, as the player, recover any ship with this tag even if you purchase it and give it the Reinforced Bulkheads hullmod to ensure recovery post combat. I was trying to use this to lock out high tech vessels from easy salvage through post faction battle derelicts- not make them unusable for the player.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 10, 2019, 06:14:30 AM
Is there an easy way to tell if there is an enemy inside of the arc of a gun? Need to make custom weapon AI
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 10, 2019, 07:11:20 AM
How do you get a mod thread moved to the mods section?
I know, know I read it, but hell if I can find where.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 10, 2019, 10:00:54 AM
Is there an easy way to tell if there is an enemy inside of the arc of a gun? Need to make custom weapon AI
LazyLib has WeaponUtils.isWithinArc(CombatEntityAPI entity, WeaponAPI weapon)

How do you get a mod thread moved to the mods section?
I know, know I read it, but hell if I can find where.
Ask a moderator

@Alex: Concerning the above, perhaps it would be a good idea to have a pinned thread just for such requests? It seems to be a common source of confusion. At times I've been unsure about the best way to go about it myself. A pinned thread could be monitored by all moderators, and anyone who sees the thread's title would know how to get a mod thread moved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 10, 2019, 10:03:43 AM
So after further testing, yes, this is misleading. It apparently also means that you cannot, as the player, recover any ship with this tag even if you purchase it and give it the Reinforced Bulkheads hullmod to ensure recovery post combat. I was trying to use this to lock out high tech vessels from easy salvage through post faction battle derelicts- not make them unusable for the player.  :P

Could you have your hullmod do:
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, 0f);
When it's not in the player's fleet?

Is there an easy way to tell if there is an enemy inside of the arc of a gun? Need to make custom weapon AI

See: Misc.isInArc() methods. IIRC LazyLib also has some utilities for this sort of thing.

@Alex: Concerning the above, perhaps it would be a good idea to have a pinned thread just for such requests? It seems to be a common source of confusion. At times I've been unsure about the best way to go about it myself. A pinned thread could be monitored by all moderators, and anyone who sees the thread's title would know how to get a mod thread moved.

Hmm, not a bad idea. Would probably entail cleaning up some of the stickies, though, wouldn't want to just add more as there's already a bunch...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 10, 2019, 10:18:14 AM
So after further testing, yes, this is misleading. It apparently also means that you cannot, as the player, recover any ship with this tag even if you purchase it and give it the Reinforced Bulkheads hullmod to ensure recovery post combat. I was trying to use this to lock out high tech vessels from easy salvage through post faction battle derelicts- not make them unusable for the player.  :P

Could you have your hullmod do:
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, 0f);
When it's not in the player's fleet?

Gotcha so (just to make sure I understand what you are saying) I remove the tag, then implement a similar behavior through a custom hullmod into the ships I want to remove from derelict salvage, and the hullmod itself can filter whether or not the ship is player owned so it wouldn't affect their ability to recover the ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 10, 2019, 10:50:24 AM
Yeah, exactly. I'm not sure what other constraints you have so maybe this wouldn't cover everything? But as far as the "recoverable/not recoverable" behaviors, seems like this should do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 10, 2019, 10:59:56 AM
Yeah, exactly. I'm not sure what other constraints you have so maybe this wouldn't cover everything? But as far as the "recoverable/not recoverable" behaviors, seems like this should do it.

Thanks I'll try it out. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 10, 2019, 02:22:53 PM
Can you effect Rarity (from the ship_data.csv file) through a skin file by chance?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 10, 2019, 02:28:06 PM
Negative.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Display_name on October 10, 2019, 06:59:48 PM
I tried setting MaxShipsInAIFleet to 8 in StarSector-Core, because I want smaller battles (My system have difficulty handling the biggest battles).
I tarted a new game but I am still seeing massive fleets.
I am missing something?

I thought maybe a mod overrode it, but my only suspect (Nexerelin) did not have the line MaxShipsInAIFleet in its settings file.
Other mods I have is Black Rock Drive Yards, DiableAvionics, Interstellar Imperium, JP_RC, and SCY.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 11, 2019, 04:41:07 AM
Silly question - you can al blueprint pacakges and they game will drop them, but I've yet to see the game drop a singular ship/weapon package (e.g. Falcon cruiser) from my mod.
These aren't defined anywhere as far as I can see, but are generated automatically...right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 11, 2019, 06:30:34 AM
When a missile flames out, what are its % chances of exploding vs bouncing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 11, 2019, 07:23:23 AM
Silly question - you can al blueprint pacakges and they game will drop them, but I've yet to see the game drop a singular ship/weapon package (e.g. Falcon cruiser) from my mod.
These aren't defined anywhere as far as I can see, but are generated automatically...right?
Blueprint drops are defined in /data/campaign/procgen/drop_groups.csv
Unless you added the ship to an existing pack, or gave it the rare_bp tag, you'll have to add new entries.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2019, 09:12:47 AM
I tried setting MaxShipsInAIFleet to 8 in StarSector-Core, because I want smaller battles (My system have difficulty handling the biggest battles).
I tarted a new game but I am still seeing massive fleets.
I am missing something?

I thought maybe a mod overrode it, but my only suspect (Nexerelin) did not have the line MaxShipsInAIFleet in its settings file.
Other mods I have is Black Rock Drive Yards, DiableAvionics, Interstellar Imperium, JP_RC, and SCY.

It's "maxShipsInAIFleet" (starts with lowercase 'm'); beyond that, I'm not sure what the issue might be. It's possible Nexerelin doesn't make use of that setting, since it' up to whatever spawns fleets to respect it.


When a missile flames out, what are its % chances of exploding vs bouncing?

50/50, non-configurable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on October 11, 2019, 09:26:06 AM
Hello! First time post, wrapping my head around modding and rules after a long absence from java.

Got what should be a simple rules query for someone.

I'm making a person with a custom post, adding him to a comm directory and creating a conversation with him.  Unfortunately I cannot determine the correct conditions to use to have a conversation with a person of a specific rank / post.

Looking at existing rules led me on the path of using $personRank or $Rank/$local.rank and comparing it like so:

$rank = = citizen

And then starting a rule based interaction

But no combination of this works at all, and no-one else has done this, so I clearly do not understand this system.  What approach should I take? do I need to bite the bullet and compile a JAR with my own script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2019, 09:58:00 AM
Is the trigger you're using PickGreeting?

Also, == not = = but I'm assuming that was a typo in the post not in your rules.csv.

If you run the game in dev mode, you can open a comm link with the person and there'll be a "dump memory" option. This prints the "memory" to the text panel, and should let you know exactly what the values are you can check for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on October 11, 2019, 10:52:24 AM
Is the trigger you're using PickGreeting?

Also, == not = = but I'm assuming that was a typo in the post not in your rules.csv.

If you run the game in dev mode, you can open a comm link with the person and there'll be a "dump memory" option. This prints the "memory" to the text panel, and should let you know exactly what the values are you can check for.

Correct on all three. problem solved, thank you for your help!

I apparently was formatting score related stuff badly or something, and forgetting about case-sensitivity after dismissing it as the problem.  "$rank == Citizen score:50" does exactly what I need and starts a conversation from PickGreeting.  Now to try and make some campaign content.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 11, 2019, 04:55:34 PM
How do i get the weapon group number for a weapon? (to use the FIRE command)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2019, 05:02:57 PM
The fire command fires the currently selected group, btw.

To answer the question, though: you can get the weapon groups via ShipAPI.getWeaponGroupsCopy() and then find which group the weapon is in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 11, 2019, 07:49:47 PM
How, roughly, is rank determined? Is it related to post? (Pointing to an API file is fine if that is easier)

Could be my faction files, but I am seeing citizens with really high military ranks when they ideally just shouldn't have one (Or should have "Citizen" set as the lowest rank that should probably always get set for that particular post)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on October 12, 2019, 03:58:16 AM
How, roughly, is rank determined? Is it related to post? (Pointing to an API file is fine if that is easier)

Could be my faction files, but I am seeing citizens with really high military ranks when they ideally just shouldn't have one (Or should have "Citizen" set as the lowest rank that should probably always get set for that particular post)

I'll chime in on this as I spent a good day or so staring blankly at these things:

Spoiler
Apologies in advance for how wrong I may be.  Case sensitivity probably applies.

Both Rank and Post can be set to whatever string you want - the faction file feeds out the faction-specific version of that rank or post string.  They can both be whatever you want really, but I couldn't tell you how much default interaction is coded based on what they are, and I think you need an entry in the faction file to display a rank/post correctly.

The Ranks.java in the API just returns a preset string, so:

mainContact.setRankId(Ranks.CITIZEN);  Ranks.java returns the string "citizen"
mainContact.setRankId("citizen"); makes the same thing

mainContact.setPostId(Ranks.POST_BASE_COMMANDER); Ranks.java returns the string "baseCommander"
mainContact.setPostId("baseCommander"); makes the same thing

The faction file just works with that:

   "ranks":{
      "ranks":{
         "citizen":{"name":"Citizen"},
      },
      "posts":{
         "baseCommander":{"name":"Base Commander"},
      },
   },

So you can end up with a Citizen / Base Commander.

I currently have my contact appearing as "That Dude" and "Chief Man Thing"

Code:
                mainContact.setRankId("magicman");
                mainContact.setPostId("fleetmanager");

Faction file:

   "ranks":{
   
         "ranks":{
            "magicman":{"name":"This Dude"},
         },
   
         "posts":{
            "fleetmanager":{"name":"Chief man thing"},
         },
         
   },

I have been making an entire custom dialogue for this person and have had no issues.  I assume its fine to make whatever you want as long as you are happy to program/rule.csv all the interactions yourself.

[close]



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2019, 10:46:01 AM
Yep! To expand on that, rank isn't "determined" in any way, rather it's just set to whatever it's set to whenever a person is created, so it depends entirely on the code that creates the person in question. So - hard to answer that question in a general way without knowing more details, i.e. where the person is created.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 12, 2019, 11:09:13 AM
@Cabbs @Alex

Thanks! I suppose the best thing for me to do in this case would be to give all the ranks and posts names such that weird immersion breaking combinations like:

Post: Grand Baron

Rank: Servant

Isn't possible. :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on October 12, 2019, 12:13:34 PM
I've got a question regarding an unsused piece of code I've found to be just what I need. It's the one in RemnantThemeGenerator in addBattlestations List:

//            MarketAPI market = Global.getFactory().createMarket("station_market_" + fleet.getId(), fleet.getName(), 0);
//            market.setPrimaryEntity(fleet);
//            market.setFactionId(fleet.getFaction().getId());
//            market.addCondition(Conditions.ABANDONED_STATION);
//            market.addSubmarket(Submarkets.SUBMARKET_STORAGE);
//            ((StoragePlugin)market.getSubmarket(Submarkets.SUBMARKET_STORAGE).getPlugin()).setPlayerPaidToUnlock(true);
//            fleet.setMarket(market);

I wanted to make an expedition intel targeting the battlestation (which is classified as a fleet) but the expedition and raid classes revolve around markets as targets, so I would probably have to rewrite it all from the ground up. Assigning a market to the station would make things so much easier, and I did try but there's a problem with the guarding ordos spawning empty and despawning instantly in a loop. Is it possible to make it work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2019, 12:37:31 PM
I've got a question regarding an unsused piece of code I've found to be just what I need. It's the one in RemnantThemeGenerator in addBattlestations List:

//            MarketAPI market = Global.getFactory().createMarket("station_market_" + fleet.getId(), fleet.getName(), 0);
//            market.setPrimaryEntity(fleet);
//            market.setFactionId(fleet.getFaction().getId());
//            market.addCondition(Conditions.ABANDONED_STATION);
//            market.addSubmarket(Submarkets.SUBMARKET_STORAGE);
//            ((StoragePlugin)market.getSubmarket(Submarkets.SUBMARKET_STORAGE).getPlugin()).setPlayerPaidToUnlock(true);
//            fleet.setMarket(market);

I wanted to make an expedition intel targeting the battlestation (which is classified as a fleet) but the expedition and raid classes revolve around markets as targets, so I would probably have to rewrite it all from the ground up. Assigning a market to the station would make things so much easier, and I did try but there's a problem with the guarding ordos spawning empty and despawning instantly in a loop. Is it possible to make it work?

I'd suggest checking out com.fs.starfarer.api.impl.campaign.intel.bases.PirateBaseIntel, since that creates a market-with-a-station that looks like a stand-alone station. The remnant stuff you're looking at is fairly old and if I had to do it again I'd probably use the market approach.

Thanks! I suppose the best thing for me to do in this case would be to give all the ranks and posts names such that weird immersion breaking combinations like:

Post: Grand Baron

Rank: Servant

Isn't possible. :P

It sounds a bit backwards - "post" is an assignment, so "Servant" would be a reasonable post, while rank is a military rank, so "Grand Baron" would be a reasonable rank. And, heck, that even makes the combination of "rank: Grand Baron, post: Servant" make sense/feel like maybe there's a story behind it, rather than just looking totally wrong :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on October 12, 2019, 12:53:38 PM
I'd suggest checking out com.fs.starfarer.api.impl.campaign.intel.bases.PirateBaseIntel, since that creates a market-with-a-station that looks like a stand-alone station. The remnant stuff you're looking at is fairly old and if I had to do it again I'd probably use the market approach.

Will do, although I'm still unsure about the patrols. Pirate and Pather bases spawn them from the military base industry I assume, while the remnant station has a separate script. I guess I could make a unique industry and remove the script or something, but there are 3 classes that are involved in the battlestation fleets, namely RemnantSeededFleetManager, RemnantAssignmentAI and RemnantStationFleetManager. I don't want to mess with it too much, so that's why I'm wondering why the script buggs out. Ultimately, I could just make the station have a much stronger finite contingent of ordos and ignore the whole respawning business.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2019, 02:21:35 PM
Ah, ok, I see. You could probably stick with that approach, yeah, and just create a fake market with the station set as its primary entity; would take some experimenting to see if it works, though.

Edit: as far as creating the market, PirateBaseIntel should still be a useful point of reference, I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 12, 2019, 03:40:31 PM
Thanks! I suppose the best thing for me to do in this case would be to give all the ranks and posts names such that weird immersion breaking combinations like:

Post: Grand Baron

Rank: Servant

Isn't possible. :P

It sounds a bit backwards - "post" is an assignment, so "Servant" would be a reasonable post, while rank is a military rank, so "Grand Baron" would be a reasonable rank. And, heck, that even makes the combination of "rank: Grand Baron, post: Servant" make sense/feel like maybe there's a story behind it, rather than just looking totally wrong :)

Whoops yep that was off the top of my head in the actual file those are reversed haha. I can see what you mean as far the story portion of it, but not in this particular faction (evil faction). If you are servant as a post you would never be a Baron, let alone a Grand Baron, and a anyone who went from any other post to Servant would lose their military rank altogether (it is essentially slavery in this case since they are a vampire faction).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 13, 2019, 06:54:52 AM
I need help here, I am trying to make a quite unique system

I want to make hologram ships, the way i plan to make those is from using the station drone system with the drones being big fighters with the same sprite as the mothership, the problem comes from when they get hit, i want to have the holograms either vanish or glitch out (jittering/variations in the sprite alpha/afterimages) when hit, but I am not sure on how to make those work.

1: Vanish
There are two possible ways to do this one, by retracting the drone instantly like the ship system that teleports fighters back to the ship or by killing it, either way, i am afraid this could cause nullpointers by having the ship vanishing when something is selecting/tracking it/etc...
1 a) Retracting: I haven't checked yet, but i suspect the source code from recall device will not work on these drones, also they are not the ship main system they will be the defensive system.
2 b) Destroying: I would need a way to kill and make the ship vanish without leaving anything behind, nor exploding and in a way it is safe as to not cause nullpointers from anything selecting it

2: Glitching
This is more simple, the player can see the visual effects and notice this is a hologram, but the AI would need a way to figure out this is not a real target and ignore it, is there a way to make the AI completely ignore a ship temporarily?

Either solution is fine, but i need help to reach any of them here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 13, 2019, 09:59:57 AM
Should be fine as far as vanish; no worry of NPEs there - anything targeting it will have its own reference so you wouldn't be able to set that to null even if you tried. Might look at how phase skimmer type systems work - a "jitter" effect to teleport out (and then just disappear) might be neat.

As far as making the AI ignore it: you couldn't do it per-ship, that I can think of, but either of ship.setOwner(100) and setting the ship's stats.getHullDamageTakenMult() to 0 should do the job globally.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 13, 2019, 10:10:41 AM
Should be fine as far as vanish; no worry of NPEs there - anything targeting it will have its own reference so you wouldn't be able to set that to null even if you tried. Might look at how phase skimmer type systems work - a "jitter" effect to teleport out (and then just disappear) might be neat.

As far as making the AI ignore it: you couldn't do it per-ship, that I can think of, but either of ship.setOwner(100) and setting the ship's stats.getHullDamageTakenMult() to 0 should do the job globally.
Thanks, i will try it tonight
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TysonMcnuggets on October 13, 2019, 12:05:47 PM
Hey guys, I am trying to update the old Battlestar Galactica Mod and I am running into a roadblock with an error that is preventing the game from loading. I've deleted all of the old shipsystems from all of the ships that I am trying to update and have re-done them all in the ship editor. I did the same with the variants and the weapons. I tried removing all references to the CEC_Z12 weapon from the mod files to see if that was the issue but it just had the same error. Any solutions? Thanks in advance.

Spoiler
2267 [Thread-4] INFO  com.fs.starfarer.loading.WeaponSpecLoader  - Loading weapon [data\weapons\CEC_Z12.wpn]
2268 [Thread-7] INFO  com.fs.starfarer.loading.scripts.new  - Loading class: data.scripts.world.systems.AlGebbar
2268 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\BattleStar Galactica Update (data\weapons\CEC_Z12.wpn)]
2271 [Thread-7] INFO  com.fs.starfarer.loading.scripts.new  - Loading class: data.scripts.world.systems.Arcadia
2275 [Thread-7] INFO  com.fs.starfarer.loading.scripts.new  - Loading class: data.scripts.world.systems.Askonia
2282 [Thread-7] INFO  com.fs.starfarer.loading.scripts.new  - Loading class: data.scripts.world.systems.Aztlan
2288 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.loading.specs.N.setProjectileSpec(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.WeaponSpecLoader.Ò00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ÒO0000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
2289 [Thread-7] INFO  com.fs.starfarer.loading.scripts.new  - Loading class: data.scripts.world.systems.Canaan
2293 [Thread-7] INFO  com.fs.starfarer.loading.scripts.new  - Loading class: data.scripts.world.systems.Duzahk
[close]

EDIT: Just figured it out, forgot to copy over the proj file from the old mod. While I am here does anyone know how I can put the mod ships into the simulator so I can pit them against each other?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 13, 2019, 01:29:47 PM
Quote
97339 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Archean Order TC v1.3.4 (data\campaign\econ/mordreath.json)]
98718 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.IllegalArgumentException: n must be positive
java.lang.IllegalArgumentException: n must be positive
   at java.util.Random.nextInt(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.intel.BaseEventManager.updateMax(BaseEventManager.java:37)
   at com.fs.starfarer.api.impl.campaign.intel.BaseEventManager.<init>(BaseEventManager.java:29)
   at com.fs.starfarer.api.impl.campaign.intel.PersonBountyManager.<init>(PersonBountyManager.java:16)
   at com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl.addScriptsIfNeeded(CoreLifecyclePluginImpl.java:421)
   at com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl.onNewGameAfterEconom yLoad(CoreLifecyclePluginImpl.java:662)
   at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.N.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.I.0000(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

A player of my mod is getting this error on sector generation and I cannot reproduce it. I took a look at the file before the crash and I don't see anything obvious so maybe this error is unrelated?

I don't override BaseEventManager so I am not sure why there would be a negative value there being passed into Random.nextInt
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 13, 2019, 01:37:35 PM
This will happen if, in settings.json, "minPersonBounties" is set higher than "maxPersonBounties".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 13, 2019, 06:39:01 PM
This will happen if, in settings.json, "minPersonBounties" is set higher than "maxPersonBounties".

Ah yeah that makes sense, thanks. My mod only overrides the maxPersonBounties setting so any player custom modifying the core setting for both might inadvertently have that issue. I'll see if that is the case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 13, 2019, 07:47:29 PM
How do i remove the red molten metal from the ship sprite? Since I a trying to make a hologram i need to have it go back to pristine hull status after glitching out (or at least mimic the status of the real ship)
Also how do i make the hologram vanish without leaving a hulk when the main ship is destroyed and the hologram goes with it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 14, 2019, 12:13:39 AM
Hi all, I've got this block of code implemented in EveryFrameScript:
Code: java
    public void applyCRPerDayChanges() {   
        for (FleetMemberAPI member : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
            String source = "sl_crpd";
            if (!member.getStats().getBaseCRRecoveryRatePercentPerDay().getMultMods().containsKey("sl_crpd")) {
                if (member.isFrigate()) {
                    member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_FRIGATE);
                }
                else if (member.isDestroyer()) {
                    member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_DESTROYER);
                }
                else if (member.isCruiser()) {
                    member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_CRUISER);
                }
                else if (member.isCapital()) {
                    member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_CAPITAL);
                }
            }
        }
    }
Basically it adjusts the CR%/day of every ship in the player fleet. It works fine, but these changes are unsurprisingly not reflected in the UI. I was wondering if there is a way to reflect these changes in the the stats screen or the mouseover details, ideally without changing the entire implementation into a hull mod. Any thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 14, 2019, 09:28:12 AM
How do i remove the red molten metal from the ship sprite?
I asked the same thing years ago for ICE, and back then there wasn't a way. That may have changed, but you might consider making all projectiles pass through the illusory ships instead. Not sure what the best CollisionClass would be for that. Perhaps:
Code: java
ship.setCollisionClass(CollisionClass.NONE);

Also how do i make the hologram vanish without leaving a hulk when the main ship is destroyed and the hologram goes with it?
Have you tried:
Code
Global.getCombatEngine().removeEntity(myIllusoryShip);

I was wondering if there is a way to reflect these changes in the the stats screen or the mouseover details, ideally without changing the entire implementation into a hull mod.
Pretty sure you just need to add a description of the effect as a third argument for modifyMult, like this:
Code: java
member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_FRIGATE, "reason for modifier");
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 14, 2019, 10:01:43 AM
How do i remove the red molten metal from the ship sprite?
I asked the same thing years ago for ICE, and back then there wasn't a way. That may have changed, but you might consider making all projectiles pass through the illusory ships instead. Not sure what the best CollisionClass would be for that. Perhaps:
Code: java
ship.setCollisionClass(CollisionClass.NONE);

Also how do i make the hologram vanish without leaving a hulk when the main ship is destroyed and the hologram goes with it?
Have you tried:
Code
Global.getCombatEngine().removeEntity(myIllusoryShip);

But with collisionclass NONE will the NPCs even attempt to hit the illusions? The objective of those little guys is to keep the enemy weapons busy

Oh i didn't search "remove" i was looking for "destroy" instead, thanks

I will try those when i finish work
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 14, 2019, 10:10:19 AM
How do i remove the red molten metal from the ship sprite?
I asked the same thing years ago for ICE, and back then there wasn't a way. That may have changed, but you might consider making all projectiles pass through the illusory ships instead. Not sure what the best CollisionClass would be for that. Perhaps:
Code: java
ship.setCollisionClass(CollisionClass.NONE);

Hmm, one possible option for this: respawn the hologram?

I was wondering if there is a way to reflect these changes in the the stats screen or the mouseover details, ideally without changing the entire implementation into a hull mod.
Pretty sure you just need to add a description of the effect as a third argument for modifyMult, like this:
Code: java
member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_FRIGATE, "reason for modifier");

That's part of it, but also: ship stats modifiers get cleaned out and recomputed fairly frequently. E.G. for the player fleet it'll happen any time you open the fleet screen, hover over a fleet or ship related tooltip, etc. This means that changing them directly in a script like this is not a good idea - the changes will never be reflected in the UI, and may be overwritten and not used at key moments.

What you want to do is look at FleetMemberAPI.getBuffManager(), and at com.fs.starfarer.api.impl.campaign.terrain.CRRecoveryBuff. EmergencyBurnAbility has an example using this to stop CR recovery temporarily.

The buffs from a BuffManager get applied at the right times and so will be seen in the UI and will actually work properly all the time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 14, 2019, 10:27:28 AM

Hmm, one possible option for this: respawn the hologram?

How? order the drone to land()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 14, 2019, 11:05:07 AM
I meant just removing it and spawning a replacement, but, yeah, if you're using a drone launcher system, that doesn't seem ideal/workable...

Another option would be to have the drone's visuals be handled using a decorative weapon instead of the actual ship sprite. By default, decorative weapons don't show damage decals, so you'd be good there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 14, 2019, 01:36:44 PM
I was wondering if there is a way to reflect these changes in the the stats screen or the mouseover details, ideally without changing the entire implementation into a hull mod.
Pretty sure you just need to add a description of the effect as a third argument for modifyMult, like this:
Code: java
member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_FRIGATE, "reason for modifier");

Pretty sure you just need to add a description of the effect as a third argument for modifyMult, like this:
Code: java
member.getStats().getBaseCRRecoveryRatePercentPerDay().modifyMult("sl_crpd", CR_MULT_FRIGATE, "reason for modifier");

That's part of it, but also: ship stats modifiers get cleaned out and recomputed fairly frequently. E.G. for the player fleet it'll happen any time you open the fleet screen, hover over a fleet or ship related tooltip, etc. This means that changing them directly in a script like this is not a good idea - the changes will never be reflected in the UI, and may be overwritten and not used at key moments.

What you want to do is look at FleetMemberAPI.getBuffManager(), and at com.fs.starfarer.api.impl.campaign.terrain.CRRecoveryBuff. EmergencyBurnAbility has an example using this to stop CR recovery temporarily.

The buffs from a BuffManager get applied at the right times and so will be seen in the UI and will actually work properly all the time.
Thank you both. I'll mess around with it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 14, 2019, 07:20:26 PM
One of my hullmods if causing a serious duplication glitch, the hullmod limits LPCs to be equipped to 8 OP or less and no crew (drone only), it seems like the game can make a variant and equip invalid LPCs ignoring the hullmod removal, but not ignoring the code that places the LPC back into the inventory

Code
if (ship.getVariant().getWing(i).getVariant().getHullSpec().getMinCrew() > 0 || ship.getVariant().getWing(i).getOpCost(ship.getMutableStats()) > 8) {
            String LPC = ship.getVariant().getWingId(i);
            ship.getVariant().setWingId(i ,null); //this is ignored
            if(ship.getVariant().getWing(i) == null) { //i even added this check!
            if (Global.getSector() != null) {
                        if (Global.getSector().getPlayerFleet() != null) {
                            Global.getSector().getPlayerFleet().getCargo().addFighters(LPC, 1); //this always go through
                        }
                    }
            }
               
                shouldSoundError = true;
}

How to reproduce:
1. Get a ship that has the hullmod (like a Corgi).
2. Open variants
3. Left-click the preset
4. It should add some kind of crewed wing to the variant it made
5. Left-click the preset multiple times

I have no idea how to fix it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 14, 2019, 08:45:09 PM
I would guess the line isn't being ignored, but overwritten by the autofit process.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 15, 2019, 02:39:08 AM
What determines what colour a weapon mount cover is?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 15, 2019, 07:18:16 AM
I would guess the line isn't being ignored, but overwritten by the autofit process.
Seems like my only choice is to allow it to be equipped and give harsh penalities during combat instead....
Hullmods are called during combat right? how do i check it? Looking if the Global.combatengine != null?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on October 15, 2019, 10:06:52 AM
if there is a way to change settings in game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 15, 2019, 10:48:40 AM
What determines what colour a weapon mount cover is?

It's automatically calculated based on the colors of the ship sprite, and can be overridden using "coversColor" in .ship and .skin files.

I would guess the line isn't being ignored, but overwritten by the autofit process.
Seems like my only choice is to allow it to be equipped and give harsh penalities during combat instead....
Hullmods are called during combat right? how do i check it? Looking if the Global.combatengine != null?

See: HullModEffect.advanceInCombat(). Also you can apply effects in HullModEffect.applyEffectsAfterShipCreation().

if there is a way to change settings in game?

If you mean settings.json-type settings, then mostly (aside from dev mode) no, I don't believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 15, 2019, 11:09:14 AM
See: HullModEffect.advanceInCombat(). Also you can apply effects in HullModEffect.applyEffectsAfterShipCreation().

I see, i can change how my hullmods work then, instead of using a workaround to unequip stuff i will make guns malfuncion during combat and fighters... could just explode i guess?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cerberus00 on October 15, 2019, 04:09:41 PM
I'm very new to modding and I have no java experience, but I'm willing to learn and would like to work on a special faction that raids and has dormant fleets in debris fields. Is this feasible? I've tried looking for tutorials on making special factions that don't have homes or bases but it doesn't seem like there's much out there. Anyone have suggestions on where to find some instruction on it? Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 15, 2019, 06:28:48 PM
There is only one instance of each hullmod right? so you can't use variables outside the methods since all ships that have a hullmod would share the same value right?

Also is there a problem in assigning stat modifications in applyEffectsAfterShipCreation instead of applyEffectsBeforeShipCreation? Since i have to redo the check when the player equips something
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 15, 2019, 06:56:44 PM
There is only one instance of each hullmod right? so you can't use variables outside the methods since all ships that have a hullmod would share the same value right?

Correct. If in the campaign, you can store stuff in Global.getSector().getPersistentData().

Also is there a problem in assigning stat modifications in applyEffectsAfterShipCreation instead of applyEffectsBeforeShipCreation? Since i have to redo the check when the player equips something

I'm not exactly sure what you mean. You could do either, I suppose; some stats don't take effect when changed in applyEffectsAfterShipCreation - namely, max armor and hull values; iirc everything else (or almost?) will work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 15, 2019, 07:23:28 PM
There is only one instance of each hullmod right? so you can't use variables outside the methods since all ships that have a hullmod would share the same value right?

Correct. If in the campaign, you can store stuff in Global.getSector().getPersistentData().

Also is there a problem in assigning stat modifications in applyEffectsAfterShipCreation instead of applyEffectsBeforeShipCreation? Since i have to redo the check when the player equips something

I'm not exactly sure what you mean. You could do either, I suppose; some stats don't take effect when changed in applyEffectsAfterShipCreation - namely, max armor and hull values; iirc everything else (or almost?) will work.

Thanks!

Reworked my hullmod, no more duplication exploits!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 16, 2019, 12:47:52 PM
I tried out:

Code

"engineSlotChanges":{
   "0":{
"style":"CUSTOM",
"styleId":"COBRA_BOMBER",
},
   "1":{
"style":"CUSTOM",
"styleId":"COBRA_BOMBER",
},
},


And it crashes with a nullpointer. Is this possible using a skin file? I may have my syntax wrong but it matches the way weapons are changed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 16, 2019, 12:54:41 PM
Ahh, engineSlotChanges apparently doesn't use "styleId" - so, just "style":"COBRA_BOMBER" should work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 16, 2019, 01:23:07 PM
Ahh, engineSlotChanges apparently doesn't use "styleId" - so, just "style":"COBRA_BOMBER" should work.

Just tried it and yes it does! Thanks. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on October 16, 2019, 02:40:23 PM
What are the requirements for a module to not count towards station survival, like the high-tech station's shield module?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 16, 2019, 07:18:48 PM
Is it possible for the next version of Starsector to incorporate a print code? To record something of vital importance and easier debugging? Having it get debugged in starsector.log is hard to read when you include in other mods and the game itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on October 17, 2019, 02:03:55 AM
i do know that selling blueprint to blackmarket will result into Pirates after 90+ days to start utilize related designs

the question is, how enable it for other faction(s)?

like selling to the 'military' market type shall yield similar effect, if 'enabled' for that faction

(also if someone already uses that for theirs custom modded faction, please say)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 17, 2019, 09:23:51 AM
What are the requirements for a module to not count towards station survival, like the high-tech station's shield module?

See: Misc.isActiveModule().

(Zero OP, no weapon groups, no fighter wings.)

Is it possible for the next version of Starsector to incorporate a print code? To record something of vital importance and easier debugging? Having it get debugged in starsector.log is hard to read when you include in other mods and the game itself.

I'm not sure what you're asking. Where would it print? If you want to print to console (which may work if you run the game from the command line/using the .bat file, you could use System.out.println() and that might work, but the logs print to console as well in that case.

You could also add a unique string to your logging output and do some combination of tail -f and grep etc to only show those lines, probably...


i do know that selling blueprint to blackmarket will result into Pirates after 90+ days to start utilize related designs

the question is, how enable it for other faction(s)?

like selling to the 'military' market type shall yield similar effect, if 'enabled' for that faction

(also if someone already uses that for theirs custom modded faction, please say)

See: com.fs.starfarer.api.impl.campaign.CoreScript.reportPlayerMarketTransaction(). At the end of that method is a commented out section that does this, which you can use as a starting point for adding similar/equivalent code. Whatever class does this needs to extend BaseCampaignEventListener and call super(true) in its constructor to register the listener.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 17, 2019, 04:10:02 PM
How do i add my ships to the Prism high end vendor without having a faction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on October 17, 2019, 08:53:38 PM
Two quick questions:

I'm sure this is a very straightforward thing to do, but how does one add a condition to a market with an industry, and then remove the condition if the industry is removed?

Further, I have a hullmod that I don't want to be bought or sold as a reward. I've poked through everything, and while industry and ship blueprints can be given no_sell and no_drop, that doesn't appear to exist for hullmods. Is there a way around this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 18, 2019, 05:42:20 AM
I'm very new to modding and I have no java experience, but I'm willing to learn and would like to work on a special faction that raids and has dormant fleets in debris fields. Is this feasible? I've tried looking for tutorials on making special factions that don't have homes or bases but it doesn't seem like there's much out there. Anyone have suggestions on where to find some instruction on it? Thanks.
You'll probably want to look at different gameplay features in the modiverse that each do a different bit of what you want.
e.g. for hidden that spawn when the player enters the star system, you could use a LimitedFleetManager (of which vanilla's PirateFleetManager and LuddicPathFleetManager are examples). Nexerelin's Remnant raids spawn without a source market, although raid code in general is pretty complex.

How do i add my ships to the Prism high end vendor without having a faction?
For the Nexerelin version, it'll will automatically work if your ships are added to an already-registered faction (e.g. one of the vanilla factions).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2019, 09:14:17 AM
I'm sure this is a very straightforward thing to do, but how does one add a condition to a market with an industry, and then remove the condition if the industry is removed?

Two basic approaches: one is to add the condition in the Industry.apply() method and remove it in unapply(). The condition would have to be resistant to being added and removed many times, though, i.e. it shouldn't store data in data members etc, as Industry.unapply() gets called pretty often and not just when the industry is removed.

Another would be to add it in Industry.apply(), if it's not already present, and then remove it in the condition's advance() method, if you detect that the market no longer has an industry.

Either way, you'll want to:
String conditionId = market.addCondition(...) to add it, and

market.removeSpecificCondition(conditionId) to remove it. Or, if you're removing it in the condition's advance method:
market.removeSpecificCondition(condition.getIdForPluginModifications());

(See: RecentUnrest for an example of this.)



Further, I have a hullmod that I don't want to be bought or sold as a reward. I've poked through everything, and while industry and ship blueprints can be given no_sell and no_drop, that doesn't appear to exist for hullmods. Is there a way around this?

Set hidden to true in hull_mods.csv. (If hiddenEverywhere is set to true, it won't show up in the refit screen, btw; regular "hidden" just makes it not dropped/sold/installable).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 18, 2019, 02:32:24 PM
Can I override the max FP settings in missions without overriding the MissionAPI class? I can't seem to get it above 150 and I want it to be 250 to test performance improvements (roughly) without having to invest a ton of time in a campaign
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2019, 02:37:23 PM
Wouldn't changing battleSize accomplish this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 18, 2019, 02:45:58 PM
Wouldn't changing battleSize accomplish this?

You mean the settings file entry? No that doesn't seem to have an effect unless my settings file entries are out of date (possible).

Or is that a variable in the mission class I missed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2019, 02:49:18 PM
I mean in the gameplay settings menu - the settings entries set the min/max/default values for the slider.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 18, 2019, 03:28:37 PM
I mean in the gameplay settings menu - the settings entries set the min/max/default values for the slider.

Ok got it. But the default setting should be 220 in that case if I set that in the settings file, right? I'll do some investigating and get back to you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2019, 05:06:49 PM
The default value in the settings.json file only factors in if you're running the game on that PC for the first time, I believe.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 18, 2019, 07:31:38 PM
The default value in the settings.json file only factors in if you're running the game on that PC for the first time, I believe.

Oh ok that makes sense. I'm sure I have changed it since then. I wasn't sure if this also included the first time a new mod was installed or what it would actually override as far as player-specific selections go.

If the mod sets the maximum or minimum lower than the current setting, does that affect things?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2019, 08:07:39 PM
Not actually 100% sure what happens if the maximum is set to below the currently-selected value :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 18, 2019, 09:05:17 PM
Not actually 100% sure what happens if the maximum is set to below the currently-selected value :)

It adjusts the currently-selected value to the defined max. Just tried it out to verify. Nice! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 19, 2019, 02:51:24 AM
So, I have a weird issue with reportPlayerOpenedMarket and the listener would fire up every time the player landed anywhere that a market dialog can be opened. It seemed weird that it would just deduct credits for landing on an abandoned station or market, how would I remedy this by making sure the market is not unowned?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 19, 2019, 08:41:49 AM
Something like:
if (!market.getFaction().isNeutral())

Or thereabouts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 19, 2019, 10:31:50 AM
When using:

Code

stats.getEntity().getOwner()


If I want to check whether the player is the owner I would check for it being 0, right? And AI is 1?

So to filer out all non-player owned ships I would use:

Code

if (stats.getEntity().getOwner() != 0) {
     stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, RECOVER_CHANCE);
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 19, 2019, 10:47:14 AM
Why would this:
Code
if (result.size() < 4 && knownSkillCount < maxSkillsPerOfficer) {
            for (String id : result) {
                nonMaxedSkills.remove(id);
            }
            /*
            if (!nonMaxedSkills.isEmpty()) {
                String pick = nonMaxedSkills.pickAndRemove().toString();
                knownSkills.remove(pick);
                result.add(pick);

            }
            */
            for(int i = 0; i < (skillsAmount-skillCount-1); i++){
                String pick = nonMaxedSkills.pickAndRemove().toString();
                knownSkills.remove(pick);
                result.add(pick);
                skillCount =+1;
            }
        }
        log.info("Officer's skill list.");

produce this:
Code
1671189 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at data.scripts.OfficerLevelupPluginImplMod.pickLevelupSkills(OfficerLevelupPluginImplMod.java:148)
at com.fs.starfarer.rpg.OfficerData.makeSkillPicks(Unknown Source)
at com.fs.starfarer.rpg.OfficerData.levelUp(Unknown Source)
at com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent.createOfficer(OfficerManagerEvent.java:381)
at com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent.createOfficer(OfficerManagerEvent.java:346)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficers(FleetFactoryV3.java:866)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.createFleet(FleetFactoryV3.java:375)
at com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantStationFleetManager.spawnFleet(RemnantStationFleetManager.java:63)
at com.fs.starfarer.api.impl.campaign.fleets.SourceBasedFleetManager.advance(SourceBasedFleetManager.java:121)
at com.fs.starfarer.campaign.BaseLocation.advanceEvenIfPaused(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Line 148 is "String pick = nonMaxedSkills.pickAndRemove().toString();"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 19, 2019, 11:57:40 AM
Can a ship module have its own modules?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 19, 2019, 01:28:30 PM
@Morrokain: Yeah, that's all correct. getOwner() can sometimes return values other than 0 and 1, but I don't recall why. You might want to consider using getOriginalOwner instead, as it is possible for entities to switch sides.

@Crimson Sky Gaurdian: The only way I can think of for that to happen is if you fed nonMaxedSkills a null

@Sinosauropteryx: Black magic!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 19, 2019, 01:51:03 PM
@Morrokain: Yeah, that's all correct. getOwner() can sometimes return values other than 0 and 1, but I don't recall why. You might want to consider using getOriginalOwner instead, as it is possible for entities to switch sides.

Thanks for the tip, will do!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on October 19, 2019, 01:57:05 PM
I'm working on a terraforming mod. I'm using the following code to remove a frozen planet and replace it with a water planet:
Code
String newPlanetType = "water";
CampaignPlanet oldPlanet = (CampaignPlanet)this.market.getPrimaryEntity();
CampaignPlanet newPlanet = null;
newPlanet = new CampaignPlanet(oldPlanet.getId(), oldPlanet.getName(), newPlanetType, oldPlanet.getRadius(), oldPlanet.getLocation().x, oldPlanet.getLocation().y, (CampaignEntity)oldPlanet.getLightSource());
newPlanet.setContainingLocation(oldPlanet.getContainingLocation());
newPlanet.setOrbit(oldPlanet.getOrbit());
newPlanet.setMarket(this.market);
newPlanet.setMemory(oldPlanet.getMemory());
newPlanet.setFaction(oldPlanet.getFaction());

this.market.getStarSystem().removeEntity(oldPlanet);
this.market.getStarSystem().addEntity(newPlanet);

this.market.setPrimaryEntity(newPlanet);
But if I try to get the planet type ID with the following code, it still returns "frozen" despite the oldPlanet SectorEntityToken having been removed and the newPlanet set as the primary entity.
Code
this.market.getPlanetEntity().getTypeId()
This prevents farming/aquaculture from working properly on the market as it gets the planet type ID to determine which variant to use. I think this may happen because objects cannot be removed from the connectedEntities LinkedHashSet in the Market class. When getPlanetEntity() iterates through connectedEntities, it will always return the first item placed on the list (the old frozen planet PlanetAPI) even though newPlanet is now the primary entity.

Whether or not I'm correct about why this occurs, is there any change I can make to my code so farming/aquaculture will correctly identify the new planet type? Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 19, 2019, 02:33:57 PM
When getPlanetEntity() iterates through connectedEntities, it will always return the first item placed on the list (the old frozen planet PlanetAPI) even though newPlanet is now the primary entity.
After taking a look, that seems very likely to me. I noticed that getConnectedEntities returns the field itself, rather than a copy, so you should be able to remove the old planet from the set.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on October 19, 2019, 04:48:58 PM
After taking a look, that seems very likely to me. I noticed that getConnectedEntities returns the field itself, rather than a copy, so you should be able to remove the old planet from the set.
This solved the problem. Thanks for your help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 19, 2019, 08:20:47 PM
No problem. Glad that did the trick  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 19, 2019, 08:34:39 PM
Could you have your hullmod do:
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, 0f);
When it's not in the player's fleet?

I tried this. Unfortunately, it doesn't work. It may work after player combat salvage (haven't seen an example otherwise yet), but not on derelicts spawning after NPC fleets engage in a battle. I recovered an Astral derelict within 5 minutes of a new game in Hybrasil due to Archean Order and Tri-Tachyon skirmishes even though it has the hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 19, 2019, 08:59:14 PM
CampaignPlanet oldPlanet = (CampaignPlanet)this.market.getPrimaryEntity();
CampaignPlanet newPlanet = null;
newPlanet = new CampaignPlanet(oldPlanet.getId(), oldPlanet.getName(), newPlanetType, oldPlanet.getRadius(),

(I'd highly recommend not doing this since you're using core code directly rather than using API stuff. You're relying on code that could change or stop working in the way you'd expect. Plus, just generally, if the API doesn't cut it for something, I'd much rather see a suggestion/request for improving it than a workaround like that.)

I tried this. Unfortunately, it doesn't work. It may work after player combat salvage (haven't seen an example otherwise yet), but not on derelicts spawning after NPC fleets engage in a battle. I recovered an Astral derelict within 5 minutes of a new game in Hybrasil due to Archean Order and Tri-Tachyon skirmishes even though it has the hullmod.

Ahh, hmm, yeah, I wasn't thinking about that, you're right. I suppose you *could* probably clear out the "recoverable" salvage special on nearby derelicts as needed with a script, even if that's a bit of an inelegant approach.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 19, 2019, 10:40:18 PM
When does an orbital station get autofitted, and which code handles this?

I've just noticed that e.g. Jangala's station has a different loadout each time a new game is started, but those in a couple of mods (which add markets in the code rather than using the economy JSONs) have a constant loadout, which is retained even after the station is killed.
Campaign plugin's pickFleetInflater also doesn't seem to be called for stations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2019, 09:07:47 AM
Hmm - iirc, pickFleetInflater() does get called for it, and it's autofitted at the usual times. A bit of inflater configuration (provided it's the DefaultFleetInflater) is done in OrbitalStation.applyCRToStation() - it ensures all weapons are available.

... and, hmm, I think there's actually a bug there - it'll only make all weapons available if the station has already been inflated. This might explain Jangala ending up with different weapons - or, rather, since the player spawns next to it, it'll inflate for the first time, which will not have DefaultFleetInflaterParams.allWeapons == true.

Then again, it seems like faction stations should also have the same issue, since they would inflate for the first time when the player is nearby. So, not quite sure what's going on as far as that specifically. Possibly for some of the factions, given the autofit tags and weapon tiers, there just isn't much/any variety in possible station fits?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on October 20, 2019, 05:17:30 PM
is there simple way how via scripting/mod prevent / omit loading of any and all music (especially to stop building it's playlist) ?
this would cover both vanilla and every active mod

note: 33% of all mods size is music and it has notable effect on loading times
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2019, 05:27:38 PM
Music is not loaded until it starts playing and is actually streamed from disk when it plays, so it has zero impact on loading times. So, uh, a good news/bad news type of situation :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dwarden on October 20, 2019, 06:49:40 PM
Music is not loaded until it starts playing and is actually streamed from disk when it plays, so it has zero impact on loading times. So, uh, a good news/bad news type of situation :)

Spoiler
50109 [pool-4-thread-1] INFO  sound.OOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOO  - Creating music buffer #1
50111 [pool-4-thread-2] INFO  sound.OOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOO  - Creating music buffer #2
...
59468 [Thread-4] INFO  sound.oo0O  - Creating streaming player for music with id [RSF - Tsuna Awakens.ogg]
59473 [Thread-4] INFO  sound.oo0O  - Cleaning up music with id [RSF - Tsuna Awakens.ogg]
[close]

this is with music disabled, on load
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 20, 2019, 07:09:47 PM
It's checking that the music files actually exists; the process takes a few milliseconds per track at most and does not involve actually loading the file.

As you can see from the log there it took around 5 ms (59473 minus 59468); that's actually a bit higher than I'd expect though it depends on your HDD etc - for reference, on my PC, this process takes about 40 ms for all of vanilla's music. Even if it took 5 ms per, it'd take 200 tracks to add a second onto game's the load time.

It's not possible to load the music ahead of time. It would take too much memory and too much time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 20, 2019, 09:09:39 PM
Ahh, hmm, yeah, I wasn't thinking about that, you're right. I suppose you *could* probably clear out the "recoverable" salvage special on nearby derelicts as needed with a script, even if that's a bit of an inelegant approach.

Could I make the hullmod do the inverse and set the recovery rate average for the player only and check for things that make that number 100? (might be more things than I think and would likely be update volatile, though)

Then add the UNBOARDABLE tag?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 21, 2019, 12:10:05 AM
I've got a ship with modules, and it seems to work fine in the simulator, except when I call it as a reinforcement, it shows up without its modules. Is there something simple I'm missing that would make it do that?

EDIT: Disregard, I figured it out. It was not set as a SHIP_WITH_MODULES
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SomeDegenerate on October 21, 2019, 08:25:09 AM
How do I get the game to read my industries.csv, and are there any conditions (i.e. an empty field in the csv) that would make the game disregard the industries inside? Is that something that happens automatically, or is there some initialization I need to do in the mod plugin?

To build off of that - how do I make an industry buildable? Even when overriding and setting isHidden() to return false and isAvailabletoBuild() to true, my industry still won't show up. I'm currently testing to generate a planet with the industry to verify that the industry exists in the first place.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 21, 2019, 12:32:54 PM
Is there a way to dynamically change the render order of modules? Or can it only be changed in the .variant file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 21, 2019, 05:04:53 PM
How do I get the game to read my industries.csv, and are there any conditions (i.e. an empty field in the csv) that would make the game disregard the industries inside? Is that something that happens automatically, or is there some initialization I need to do in the mod plugin?

As long as it's in the right folder, it should be read/merged with the core file automatically.

To build off of that - how do I make an industry buildable? Even when overriding and setting isHidden() to return false and isAvailabletoBuild() to true, my industry still won't show up. I'm currently testing to generate a planet with the industry to verify that the industry exists in the first place.

Hmm - make sure it's not an upgrade of something else, but aside from that, it sounds like you've got it covered. Maybe make a copy of an industry with no requirements - both as far as the code and the csv row - and start from that? Light Industry (among others) should make a good starting point.

Is there a way to dynamically change the render order of modules? Or can it only be changed in the .variant file?

Changing the hull size might work - larger hull sizes are rendered below smaller ones - but it might have some side effects like more powerful explosions. Removing the module from the engine and re-adding it might also work; iirc the ones added last are rendered on top, but I could be wrong about that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 21, 2019, 07:24:04 PM
How do I make a black hole have the correct hazard rather than a corona?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 21, 2019, 07:28:22 PM
Check star_gen_data.csv - iirc the solar wind there has a negative direction?

Also see: StarSystemGenerator.setBlackHoleIfBlackHole() - that adds the event horizon terrain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 22, 2019, 12:46:01 AM
I haz a qustion. Or two.

Do the title_scrren_variants and mission_list get overwriten instead of appended? Because unless I manually add missions and ships from other mods into my mod files, they don't appear.


Second is beam waepons. They confuse me. Balancing other weapons is easy. Beam weapons act weird since their actual behavior and damage output/consumption and nigh impossible to predict.
You can make a beam that fires as long as you keep your fire bottun pressed, a beam that fires for a set duration, or a pulsed beam. But actually getting the numbers to get those effect is a whole lot of guesswork.
Furthermore, once you DO get the numbers right, then calculating damage/flux becomes a mystery.

What would be nice is to have a more detailed explanation with example value sets to get each of the desired effects, with explanations on how to calculate damage/flux in each case
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on October 22, 2019, 01:37:42 AM
Code
	"replace":["data/missions/mission_list.csv", "data/config/title_screen_variants.csv"],
I see that in your mod_info.json TrashMan. Remnants of that mod once being a total conversion, which honestly maybe it still should be.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 22, 2019, 03:48:54 AM
Code
	"replace":["data/missions/mission_list.csv", "data/config/title_screen_variants.csv"],
I see that in your mod_info.json TrashMan. Remnants of that mod once being a total conversion, which honestly maybe it still should be.

Bloody effin hell, that was supposed to be commented out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on October 22, 2019, 05:25:05 AM
So I've recently run into a sudden case of "all that code that worked just weeks ago is suddenly not". In particular this seems to be affecting ships with a modified timeMult. I've been able to fix most of my issues but there's one that just eludes me.

TimeMult seems to break the vanilla fortress shield in that it no longer autodeploys the shield when activating. I also had a custom system that used to force deploy the shield which also fails to do so while a time mult is active, leading to the system just going on cooldown immediately again. All the systems involved are SHIELD_MODs and use the vanilla fortress shield AI

Used this code to force the shield active (which I recall working just fine, even under timemult, when I made it):
Code
if (ship.getShield() != null) {
            //That shield is going up
            if (ship.getShield().isOff()) {
                ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK, null, 0);
            }

            //And it's staying like that
            if (ship.getShield().isOn()) {
                ship.blockCommandForOneFrame(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK);
                ship.blockCommandForOneFrame(ShipCommand.VENT_FLUX);
            }
        }

Any insight would be appreciated cause it's driving me nuts
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 22, 2019, 07:26:44 AM
Where is what a faction considers legal goods located?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 22, 2019, 07:51:40 AM
Second is beam waepons. They confuse me. Balancing other weapons is easy. Beam weapons act weird since their actual behavior and damage output/consumption and nigh impossible to predict.
You can make a beam that fires as long as you keep your fire bottun pressed, a beam that fires for a set duration, or a pulsed beam. But actually getting the numbers to get those effect is a whole lot of guesswork.
Furthermore, once you DO get the numbers right, then calculating damage/flux becomes a mystery.

What would be nice is to have a more detailed explanation with example value sets to get each of the desired effects, with explanations on how to calculate damage/flux in each case

Basic beams just fire continuously dealing set damage for a set flux cost.

For burst beams it's a calculation based on 1/3rd of the stated DPS during chargeup and chargedown (since beam damage is based on a square of their brightness, i.e. a beam that's halfway faded in deals 25% damage) plus full dps during the "burst" duration.

For multi-barrel beam weapons, the stated DPS from the csv is distributed evenly among all the barrels, iirc.

The actual calculated numbers in the tooltip, btw, so that should make it easier to fine-tune. You can also press F8 while in combat in devmode to reload all the stats/combat-related csvs; might have to switch away and back to the ship in the refit screen to have it take effect, btw...

Where is what a faction considers legal goods located?

.faction file -> "illegalCommodities"

So I've recently run into a sudden case of "all that code that worked just weeks ago is suddenly not". In particular this seems to be affecting ships with a modified timeMult. I've been able to fix most of my issues but there's one that just eludes me.

It's really hard to say - the code seems fine at first (and second) glance and seems like it should hold up at a higher timeMult. All I can suggest is trying to think of what actually changed that caused things to stop working, since, again, the code you've posted seems fine to me. We could both be missing something, though...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 22, 2019, 08:41:05 AM
I can't seem to get String switch statements to work. The .jar compiles fine, but during SS loading, I get the following error:

Code
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/KT_SinuousBody.java', Line 102, Column 15: Assignment conversion not possible from type "java.lang.String" to type "int"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
at org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:9071)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1344)
at org.codehaus.janino.UnitCompiler.access$1700(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$4.visitSwitchStatement(UnitCompiler.java:942)
at org.codehaus.janino.Java$SwitchStatement.accept(Java.java:2402)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
... 5 more

from the following test block:

Code
        switch ("a"){
            default: break;
        }

This is confusing because I know other mods use String switch blocks without issue. My IDE is telling me I'm using JDK 11. Where did I go wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 22, 2019, 08:56:22 AM
Your script looks like it's being compiled by Janino (the compiler the game uses to compile loose scripts) and not your IDE, and Janino doesn't support it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 22, 2019, 09:03:32 AM
Oh, I see. Is that normal/default behaviour? Did the other modders who used String switches use some trick to compile with something other than Janino? Or did I just set something up wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 22, 2019, 09:21:55 AM
They'd compile their code into a jar file using the IDE, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 22, 2019, 09:25:09 AM
Ok - thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 22, 2019, 09:35:49 AM
Make sure you set your compile target for java 7, by the way - if you compile for a later version, Starsector will not be able to load the jar and you'll get an exception about a major/minor version mismatch...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 22, 2019, 07:55:49 PM
Check star_gen_data.csv - iirc the solar wind there has a negative direction?

Also see: StarSystemGenerator.setBlackHoleIfBlackHole() - that adds the event horizon terrain.

Thanks! Worked like a charm. Xanathos just got a lot more dangerous.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 22, 2019, 11:08:34 PM
How can I tell whether the player's ship is on autopilot?
Edit: Disregard, found it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 23, 2019, 12:15:12 AM
OK, how to get the plant description text to show?

I'm not talking about the general planet description you get when you hover with your mouse over a planet, but the one that appears when you land, next to the big image. I can get custom market and bar decriptions to work, but I can't find where or how the planet decriptions are. They don't seem to be in the rules.cvs nor in the descriptions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on October 23, 2019, 02:34:46 AM
OK, how to get the plant description text to show?

I'm not talking about the general planet description you get when you hover with your mouse over a planet, but the one that appears when you land, next to the big image. I can get custom market and bar decriptions to work, but I can't find where or how the planet decriptions are. They don't seem to be in the rules.cvs nor in the descriptions.

I think you want the text3 column in descriptions.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on October 23, 2019, 02:46:45 AM
Why do derelicts (the automated defenses) seem to ignore the changes to weapon range I made in the .csv? I've tried changing it to various levels and it appears to always be the default somehow.

Edit: I've checked the variants in the dev mode. In simulation, the range is correct. It seems only the ships generated in the campaign are the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 23, 2019, 04:01:06 AM
Just to check something - weapons hardpoints on the ship can be named whatever one wants, right? They don't have to the in the W0001 format? I can name it FrontGun01?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 23, 2019, 08:43:32 AM
Why do derelicts (the automated defenses) seem to ignore the changes to weapon range I made in the .csv? I've tried changing it to various levels and it appears to always be the default somehow.

Edit: I've checked the variants in the dev mode. In simulation, the range is correct. It seems only the ships generated in the campaign are the problem.

That ... doesn't actually seem possible. If the ranges are correct in the simulation, that means the game picked up your changes to weapon range, and that means that the only range it knows for the weapon is the changed range, the original range effectively doesn't even exist anywhere at that point.

Is it possible that the specific derelict you're looking at has Safety Overrides? That'll reduce the range to something that feels same-y almost regardless of changes.

Just to check something - weapons hardpoints on the ship can be named whatever one wants, right? They don't have to the in the W0001 format? I can name it FrontGun01?

I believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on October 23, 2019, 09:14:49 AM
Is it possible that the specific derelict you're looking at has Safety Overrides? That'll reduce the range to something that feels same-y almost regardless of changes.

I checked to make sure it wasn't related to any dmods, hullmods or ship systems. All derelict ships were affected, regardless of hullmods. From what I've observed, range and missile flight time are ignored, while I think projectile speed may be ok. Though this could be random, since range also varies from weapon to weapon. For example, dual mg has the 'default' low range while plasma cannon seems to have been affected by the change.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 23, 2019, 10:05:58 AM
If you have multiple mods being loaded, you might run into a situation where only some of the weapons are affected by your changes if the other mods also change the same weapons. Nothing else comes to mind, though; as I said earlier, if you're seeing the changes in simulator, they're loaded properly and across the board, so something else must be accounting for whatever you're seeing with non-simulator derelicts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 23, 2019, 10:41:36 AM
Why do derelicts (the automated defenses) seem to ignore the changes to weapon range I made in the .csv?

Are you running Ruthless Sector by any chance? They (derelicts specifically) are set to have increased range in campaign battles to increase the challenge.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 23, 2019, 11:03:21 AM
Are you running Ruthless Sector by any chance? They (derelicts specifically) are set to have increased range in campaign battles to increase the challenge.
I was wondering if that's the case too. That would explain the difference between sim and campaign, as ruthless sector only applies the bonuses  for probe/survey/mother ship encounters. I don't see how ruthless sector could negate CSV changes though. The bonuses it adds are applied in the same way as hullmods.
Code: java
stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).modifyFlat(ECM_ID, bonus);
stats.getBallisticWeaponRangeBonus().modifyMult(ECM_ID, ModPlugin.RANGE_MULT_FOR_AUTOMATED_DEFENSES);
stats.getEnergyWeaponRangeBonus().modifyMult(ECM_ID, ModPlugin.RANGE_MULT_FOR_AUTOMATED_DEFENSES);
stats.getMissileWeaponRangeBonus().modifyMult(ECM_ID, ModPlugin.RANGE_MULT_FOR_AUTOMATED_DEFENSES);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on October 23, 2019, 11:05:00 AM
Indeed I am. I've actually just checked if the problem occurs in vanilla and it doesn't. Interestingly enough, cryosleeper's defense is not affected and works just fine.

Edit: Disabled Ruthless Sector and the range is as it should be :P. It was my screwup. For some reason the range multiplier in the ruthless sector config was at 0.2. I don't know what brainfart led me to set it as such. Sorry for the confusion.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 23, 2019, 11:20:29 AM
Ah, glad that's sorted out then. You had me worried there for a sec
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 23, 2019, 05:08:07 PM
Hi, I'm a newbie modder trying to get into scripting but I am getting an error at the very first line of my first mod plugin saying:

"type com.thoughtworks.xstream.XStream cannot be resolved"

I followed this Eclipse modding tutorial to get this far:

https://fractalsoftworks.com/forum/index.php?topic=4344.0 (https://fractalsoftworks.com/forum/index.php?topic=4344.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 24, 2019, 09:36:39 AM
Does the Monofilament Tow Cable hullmod work, or is it a deprecated remnant?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 24, 2019, 09:47:15 AM
Hi, I'm a newbie modder trying to get into scripting but I am getting an error at the very first line of my first mod plugin saying:

"type com.thoughtworks.xstream.XStream cannot be resolved"

Hmm - probably missing an import statement? Classes from other packages need to be imported before they can be used.

Something like:
import com.thoughtworks.xstream.XStream;

At the beginning of your file.

Does the Monofilament Tow Cable hullmod work, or is it a deprecated remnant?

You can check this by searching for it in hull_mods.csv, then, if it's there, checking for the hullmod being used in any hulls or variants.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 24, 2019, 09:55:01 AM
Is there any reason why .getMassWithModules() wouldn't realize when the ship's modules died? I can't get the method to report a decrease in mass after losing a module, it only returns the original mass of the ship + all its modules, even if some or all modules are dead. Other module ships I've tested have working .getMassWithModules() results. I can't for the life of me figure out why.

EDIT: Some further testing, seems the return of .getMassWithModules() is dependent on whether or not the destroyed modules break apart or not. The number still isn't correct, but seems to subtract a greater amount of the dead module's mass from the total if the module has broken into more pieces. This finding is making me doubt whether it was actually working on other module ships too. Could the method itself be bugged?

EDIT2: If I had to guess, the method considers the heaviest piece of each dead module to be still attached to the mothership. So a module that doesn't break at all contributes its total mass, and one that breaks into, say, 8 pieces will contribute a little over 1/8 of its mass. At least that's what the numbers I'm getting suggest.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 24, 2019, 10:23:09 AM
You can check this by searching for it in hull_mods.csv, then, if it's there, checking for the hullmod being used in any hulls or variants.
It's not in use by any hulls or variants, and by it's description it a more limited version of what the Ox gets.
I'm just wondering if it's functional-but-replaced, if it never worked, or if it has stopped working since it was phased out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 24, 2019, 12:37:54 PM
Question: Can a station module have modules of it's own?

Because I have a station who's core has 2 DefenseModules and 2 extnetions modules, and the Defense modules have 3 armor modules each - Defnse adn extension moduels appear, but not the armor modules
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 24, 2019, 12:47:43 PM
Is there any reason why .getMassWithModules() wouldn't realize when the ship's modules died? I can't get the method to report a decrease in mass after losing a module, it only returns the original mass of the ship + all its modules, even if some or all modules are dead. Other module ships I've tested have working .getMassWithModules() results. I can't for the life of me figure out why.

EDIT: Some further testing, seems the return of .getMassWithModules() is dependent on whether or not the destroyed modules break apart or not. The number still isn't correct, but seems to subtract a greater amount of the dead module's mass from the total if the module has broken into more pieces. This finding is making me doubt whether it was actually working on other module ships too. Could the method itself be bugged?

EDIT2: If I had to guess, the method considers the heaviest piece of each dead module to be still attached to the mothership. So a module that doesn't break at all contributes its total mass, and one that breaks into, say, 8 pieces will contribute a little over 1/8 of its mass. At least that's what the numbers I'm getting suggest.

Ahh - looks like it's a bug, actually; getMassWithModules() counts all modules regardless of whether they've been destroyed or not. As you noted, when a module breaks into pieces, it'll only count the weight of the piece that's counted as the "original" ship. Fixed!

Not sure why/how that'd ever work for you in the first place, though, that's a bit confusing.

It's not in use by any hulls or variants, and by it's description it a more limited version of what the Ox gets.
I'm just wondering if it's functional-but-replaced, if it never worked, or if it has stopped working since it was phased out.

Ah, I see! It used to work at some point, but it's pretty processor-intensive and just in general overcomplicated code because it was trying to do something that was tricky to do right. I'm not sure if it would work now or if some things have changed that would make it not work.

Question: Can a station module have modules of it's own?

Because I have a station who's core has 2 DefenseModules and 2 extnetions modules, and the Defense modules have 3 armor modules each - Defnse adn extension moduels appear, but not the armor modules

Right - modules can't have their own modules, all modules have to be specified in the station itself.

Of note: if an armor module (i.e. with no weapons/OP/fighters) has a collision bounds overlap with another module, and the other module gets detached, then the armor module will also get detached. This is a way to simulate a hierarchy of sorts, and this is why vanilla armor module collision bounds have "spikes" in them that extend into the modules they protect.

Otherwise, you'd get a module detaching, its armor modules not detaching, and then it awkwardly trying to collide "through" the armor modules.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 24, 2019, 01:03:50 PM
Not sure why/how that'd ever work for you in the first place, though, that's a bit confusing.
I'm not sure what you mean exactly, but my initial testing on the Cathedral from Ship and Weapon Pack showed the ship getting lighter as modules were destroyed. It was never really working, just fractions of each module being removed from the total as they broke up. Setting all pieces to breakProb = 0 confirmed it was in fact not working. (The other ship I was testing was breakProb = 0 to begin with.) Glad this is known about and being fixed now :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 24, 2019, 01:15:35 PM
Ah, I see - makes sense now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 24, 2019, 02:42:25 PM
Hmm - probably missing an import statement? Classes from other packages need to be imported before they can be used.

Something like:
import com.thoughtworks.xstream.XStream;

At the beginning of your file.

When I added that line, it only added another error beside it saying

Code
The import com.thoughtworks.xstream.XStream cannot be resolved

I also noticed something when I tried to remove some imports to find out which one was causing it, and it turned out to be 'BaseModPlugin'. When I removed that one line, the error on the first line disappeared, although several errors appeared farther down into the file...

Oh, and the full error I got was actually:

Code
The type com.thoughtworks.xstream.XStream cannot be resolved. It is indirectly referenced from required .class files

But none of the code I have so far uses XStream.

Just in case it might be related, apart from the libraries the Eclipse tutorial said to include, I've also imported MagicLib, Lazy Lib and Graphics Lib.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 24, 2019, 03:20:55 PM
Not really a question but not sure where else to post this. Thank you very much for the addition of custom data to the weapon tooltips that came with the .9 update! It took me a while to get to it but now that I am there it's very flexible!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 24, 2019, 03:38:38 PM
How does one get loose .java files to become .class files?
I believe Starsector has it's own compiler or something?
(Please tell me I don't have to wade through either not-dumbed-down-enough tutorials or the internet in search of Java SDK 7)

Edit: And while I'm here, will this loop do what I think/hope it will? (Namely, testing if every entry between 0 and YunruCurrentCount is true)
Code
			if ((for (int i = 0; i < YunruCurrentCount; i++)  {
YunruCount[i] == true})) {
YunruCanBuild = true;
break;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BringerofBabies on October 24, 2019, 04:50:30 PM
How does one get loose .java files to become .class files?
I believe Starsector has it's own compiler or something?
(Please tell me I don't have to wade through either not-dumbed-down-enough tutorials or the internet in search of Java SDK 7)

Edit: And while I'm here, will this loop do what I think/hope it will? (Namely, testing if every entry between 0 and YunruCurrentCount is true)
Code
			if ((for (int i = 0; i < YunruCurrentCount; i++)  {
YunruCount[i] == true})) {
YunruCanBuild = true;
break;
}

Fairly certain, based on everyone else's comments, that Starsector does not have its own compiler. I haven't ever used Java, but unless it is radically different from everything else under the sun, for loops aren't expressions that output a value, so that loop wouldn't work inside the if test. I think you want something like
Code
			for (int i = 0; i < YunruCurrentCount; i++)  {
        if (YunruCount[i] != true) {
                                    break;
                                }
                                else if (i == YunruCurrentCount - 1) {
    YunruCanBuild = true;
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 24, 2019, 05:40:02 PM
Spoiler
Hmm - probably missing an import statement? Classes from other packages need to be imported before they can be used.

Something like:
import com.thoughtworks.xstream.XStream;

At the beginning of your file.

When I added that line, it only added another error beside it saying

Code
The import com.thoughtworks.xstream.XStream cannot be resolved

I also noticed something when I tried to remove some imports to find out which one was causing it, and it turned out to be 'BaseModPlugin'. When I removed that one line, the error on the first line disappeared, although several errors appeared farther down into the file...

Oh, and the full error I got was actually:

Code
The type com.thoughtworks.xstream.XStream cannot be resolved. It is indirectly referenced from required .class files

But none of the code I have so far uses XStream.

Just in case it might be related, apart from the libraries the Eclipse tutorial said to include, I've also imported MagicLib, Lazy Lib and Graphics Lib.
[close]

Ahh, I'm sorry - this probably isn't the best thread for these kinds of questions, which likely entail a back-and-forth, and is not really about Starsector-specific things as such. Plus the thread moves kind of fast. I think you're more likely to get help by posting this in a separate thread; it'll be a lot easier.

(FWIW, these errors sound like some jars not having been added to your project's build path in whatever IDE you're using.)

Not really a question but not sure where else to post this. Thank you very much for the addition of custom data to the weapon tooltips that came with the .9 update! It took me a while to get to it but now that I am there it's very flexible!

Thank you!

How does one get loose .java files to become .class files?
I believe Starsector has it's own compiler or something?

Stuff under data/scripts and below that will be compiled on startup using the Janino 3rd party compiler. It's got some limitations and it's a bit slow.

(Please tell me I don't have to wade through either not-dumbed-down-enough tutorials or the internet in search of Java SDK 7)

I'd highly recommend that if you're at all serious about having code in your mods. It's better all-around, both as far as just using an IDE and as far as having more capabilities and having a shorter startup time when you run the game (since stuff will be pre-compiled by you into a jar.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 24, 2019, 06:02:52 PM
Okay now I'm getting a weird error.
Code
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.FarmingMult'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.FarmingMult' does not declare a class with the same name
Which'd be normal if not for the fact that thing starts
Code
public class FarmingMult extends BaseIndustry implements MarketImmigrationModifier {
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 24, 2019, 06:20:45 PM
Missing package declaration maybe?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 24, 2019, 06:25:54 PM
Probably, I still have it at
package com.fs.starfarer.api.impl.campaign.econ.impl;
No idea what it should be for a loose script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 24, 2019, 06:41:01 PM
In this case it should be:
Code: java
package data.scripts;
The package name corresponds to the file location.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 24, 2019, 10:10:49 PM

Ahh, I'm sorry - this probably isn't the best thread for these kinds of questions, which likely entail a back-and-forth, and is not really about Starsector-specific things as such. Plus the thread moves kind of fast. I think you're more likely to get help by posting this in a separate thread; it'll be a lot easier.

(FWIW, these errors sound like some jars not having been added to your project's build path in whatever IDE you're using.)

Okay, I'll do so. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 25, 2019, 03:07:15 AM
In this case it should be:
Code: java
package data.scripts;
The package name corresponds to the file location.
Thanks, that worked.

EDIT: Okay, here's a confusing one:
Code
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/FarmingMult.java', Line 91, Column 20: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"

But line 91 is vanilla code:
Code
			String commodity = ResourceDepositsCondition.COMMODITY.get(mc.getId());
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 25, 2019, 11:37:33 AM
So, I know variants with modules will not install the modules' hullmods when using autofit on the refit screen, instead replacing them with caps/vents. Do variants spawned in enemy fleets have the same problem?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 25, 2019, 03:43:18 PM
But line 91 is vanilla code:
Code
			String commodity = ResourceDepositsCondition.COMMODITY.get(mc.getId());

What file is that from in vanilla api? What is mc defined as, has it been properly initialized and what does getId() return? A String I assume?

It's weird because get() from ResourceDepositsCondition in this case returns a String, not an Object, according to IntelliJ. So there shouldn't even be a conversion being attempted there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 25, 2019, 03:47:28 PM
What file is that from in vanilla api?
api\impl\campaign\econ\impl\farming.java
Quote
It's weird because get() from ResourceDepositsCondition in this case returns a String, not an Object, according to IntelliJ. So there shouldn't even be a conversion being attempted there.
It's almost enough to make me set up my IntelliJ, but getting Java 7, and finding a good tutorial for actually setting it up...
Yeah, I'll pass :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 25, 2019, 05:36:27 PM
How do i check if a ship is in autopilot again?

Code
ship.getAIFlags() != null

right? I need to make sure my code only works if the player ship is in Autopilot or its fully AI controlled

-edit-

Nevermind it was
Code
getShipAI() != null

thanks to Lazywizard
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 25, 2019, 06:01:50 PM
So, I know variants with modules will not install the modules' hullmods when using autofit on the refit screen, instead replacing them with caps/vents. Do variants spawned in enemy fleets have the same problem?

(If this is indeed a problem I'd imagine it affects both, but I'm not aware of it either way...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 25, 2019, 07:25:09 PM
I have a system that marks a target and after a while it swaps places with the target, i just noticed there is a problem with the system, since two ships with this system can mark the same target at the same time which would result in quite the mess, i was thinking of possible solutions for this.

The best solution  i thought would be using a stats "buff" with a special name that the second ship using the system would check before marking the target for swapping, so only the first ship would end up marking the target, as a bonus since this is a rescue system i would like the buff to grant a bit of damage reduction until it gets swapped, but I am afraid of possible exploits cancelling the system and keeping the buff. So questions:

How do i check for a specific active stats modification ID?
Is there a way to give a stats modification with a timer? or would the buff remain in the target forever until the swap system removed it manually with unmodify?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on October 25, 2019, 08:00:41 PM
I feel as though I'm doing something stupid, but I've run into a bit of a problem.

The idea is go to custom entity -> trigger a series of events to occur in rules.csv, similar to the RedPlanet event chain. However, when I go to the entity, instead of triggering the rules.csv event chain, it's under the impression the entity is a research station, and when you break it down, it doesn't give salvage. Am I missing a key feature? The rules.csv looks for a tag, which the station is tagged with, and should go through the event chain. But for some reason it refuses to do this.

Could someone tell me if I'm missing something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 25, 2019, 10:22:09 PM
How do i check for a specific active stats modification ID?
If I understand your question correctly, you might try something like this:
Code
stats.getArmorDamageTakenMult().getFlatMods().containsKey("key_to_check_for")
Of course, you might need to use getMultMods or getPercentMods instead of getFlatMods, depending on how you apply the buff.
I don't know of anything within the API for temporary applying a buff.

Could someone tell me if I'm missing something?
I can't think of anything likely off the top of my head, but then I'm not exactly a rules.csv guru. It might be a good idea to post the relevant rules.csv rows so people can take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 26, 2019, 05:23:17 AM
How do i check for a specific active stats modification ID?
If I understand your question correctly, you might try something like this:
Code
stats.getArmorDamageTakenMult().getFlatMods().containsKey("key_to_check_for")
Of course, you might need to use getMultMods or getPercentMods instead of getFlatMods, depending on how you apply the buff.
I don't know of anything within the API for temporary applying a buff.
Oh i see you have to check the type of statmod and get all mods of that type, i thought there would be some kind of getAllActiveMods() for the ship, now i understand, thanks.
If there are no temporary buffs i will have to take some anti exploit measures then
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 26, 2019, 04:30:17 PM
How do I make missiles stop exploding once they flame out? I notice there's maybe some random chance of them still detonating if they hit a ship past their fuel range - how do I make them always collide like inert objects past this point? Oh, and I don't mean all missiles, just a certain missile I'm trying to make.

Also, is there a way to spawn junk hulks into the game? Like if the missile explodes, it leaves its carcass lying around. Or bits and pieces of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 26, 2019, 06:45:48 PM
How do I make missiles stop exploding once they flame out? I notice there's maybe some random chance of them still detonating if they hit a ship past their fuel range - how do I make them always collide like inert objects past this point? Oh, and I don't mean all missiles, just a certain missile I'm trying to make.
I don't know if there's anything in the .proj file for preventing missiles from exploding once they flame out, but you might be able to make that work with this:
Code
myMissile.setArmedWhileFizzling(false);
Also, is there a way to spawn junk hulks into the game? Like if the missile explodes, it leaves its carcass lying around. Or bits and pieces of it.
I'm not sure about this one. It depends on exactly what you want to do. If you want the pieces to have collision physics you'd probably have to resort to crazy hacks, but creating a few particle effects when it's destroyed would probably be pretty simple.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 26, 2019, 06:58:37 PM
So, when Global.getSector().doHyperspaceTransition() is used, is there a way to set (or at least get) the amount of time between calling the function and the actual location transition? At first I thought it was constant, but it seems to vary quite a bit based on fleet size.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on October 26, 2019, 09:30:00 PM
Could someone tell me if I'm missing something?
I can't think of anything likely off the top of my head, but then I'm not exactly a rules.csv guru. It might be a good idea to post the relevant rules.csv rows so people can take a look.

Here's the section of rules.csv (https://bitbucket.org/King_Alfonzo/i-will-make-sindria-great-again/downloads/rules.csv) I'm using, and here's the salvage file (https://bitbucket.org/King_Alfonzo/i-will-make-sindria-great-again/downloads/HMINightmareStation.java) that's used in the event.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 27, 2019, 03:09:56 AM
If I wanted to multiply the supply and production of an industry, what should I call?

Also where is what conditions an industry needs determined?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on October 27, 2019, 05:03:00 AM
If I wanted to multiply the supply and production of an industry, what should I call?

Also where is what conditions an industry needs determined?

Supply and Demand of an industry is derived from the industry itself. In mods it's usually in the compiled part of the mod, in src->data->campaign -> econ -> industries. In Vanilla, it's in the starfarer.api folder, in com ->fs -> starfarer -> api -> impl -> campaign -> econ -> impl.

As for conditions, I'm afraid I'm not sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RAYhill on October 27, 2019, 05:34:30 AM
edited
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 27, 2019, 06:07:05 AM
How can you set a child module to be rendered on top of weapons? For example, a block of armor that rests atop a weapon and only reveals it when it is removed, like SCY's Nemean Lion. When I clamped some station modules on my ship, they always get rendered under the weapons...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2019, 10:25:15 AM
@Sundog: thank you for helping out here!

Could someone tell me if I'm missing something?
I can't think of anything likely off the top of my head, but then I'm not exactly a rules.csv guru. It might be a good idea to post the relevant rules.csv rows so people can take a look.

Here's the section of rules.csv (https://bitbucket.org/King_Alfonzo/i-will-make-sindria-great-again/downloads/rules.csv) I'm using, and here's the salvage file (https://bitbucket.org/King_Alfonzo/i-will-make-sindria-great-again/downloads/HMINightmareStation.java) that's used in the event.

If you run the game in dev mode, the log will show a lot of stuff regarding which rule is picked and why, so I'd recommend looking at that.

Also where is what conditions an industry needs determined?

See: Industry.isAvailableToBuild(). Farming and Mining (and some other ones) have implementations that could be useful for reference.

How can you set a child module to be rendered on top of weapons? For example, a block of armor that rests atop a weapon and only reveals it when it is removed, like SCY's Nemean Lion. When I clamped some station modules on my ship, they always get rendered under the weapons...

I'm not sure how this is done in SCY, hmm. Possibly decorative weapons are involved? But, again, not sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 27, 2019, 12:39:25 PM
Also where is what conditions an industry needs determined?

See: Industry.isAvailableToBuild(). Farming and Mining (and some other ones) have implementations that could be useful for reference.
I was hoping that wouldn't be the answer.
I have multiple mining industries, and they all share this code:
Code
	@Override
public boolean isAvailableToBuild() {
if (!super.isAvailableToBuild()) return false;

boolean YunruIsPossible = false;
boolean YunruCanBuild = false;
boolean[] YunruCount = {true, false, false, false, false, false};
int YunruCurrentCount = 0;

if (getSpec().hasTag(YunruNewTags.TAG_1) == true) YunruCurrentCount = 1; // What's the highest count mine to exist?
if (getSpec().hasTag(YunruNewTags.TAG_2) == true) YunruCurrentCount = 2;
if (getSpec().hasTag(YunruNewTags.TAG_3) == true) YunruCurrentCount = 3;
if (getSpec().hasTag(YunruNewTags.TAG_4) == true) YunruCurrentCount = 4;
if (getSpec().hasTag(YunruNewTags.TAG_5) == true) YunruCurrentCount = 5;
if (getSpec().hasTag(YunruNewTags.TAG_6) == true) YunruCurrentCount = 6;

if (getSpec().hasTag(YunruNewTags.TAG_1) == true) {
for (MarketConditionAPI mc : market.getConditions()) {
String commodity = ResourceDepositsCondition.COMMODITY.get(mc.getId());
if (commodity != null) {
String industry = ResourceDepositsCondition.INDUSTRY.get(commodity);
if (Industries.MINING.equals(industry)) YunruIsPossible = true;
}
}
} else YunruIsPossible = true; // No need to check further mines, since the first is needed to build them and it already checked

if (YunruIsPossible = true) {
for (Industry ind : market.getIndustries()) {
if (ind.getSpec().hasTag(Industries.MINING) && ind.getSpec().hasTag(YunruNewTags.TAG_1)) {
YunruCount[1] = true; // Mine 1 exists
}
if (ind.getSpec().hasTag(Industries.MINING) && ind.getSpec().hasTag(YunruNewTags.TAG_2)) {
YunruCount[2] = true; // Mine 2 exists
}
if (ind.getSpec().hasTag(Industries.MINING) && ind.getSpec().hasTag(YunruNewTags.TAG_3)) {
YunruCount[3] = true; // Mine 3 exists
}
if (ind.getSpec().hasTag(Industries.MINING) && ind.getSpec().hasTag(YunruNewTags.TAG_4)) {
YunruCount[4] = true; // Mine 4 exists
}
if (ind.getSpec().hasTag(Industries.MINING) && ind.getSpec().hasTag(YunruNewTags.TAG_5)) {
YunruCount[5] = true; // Mine 5 exists
}
for (int i = 0; i < YunruCurrentCount; i++)  { // Checks all previous mines to this one
if (YunruCount[i] != true) {
break; // If any previous mines don't exist, can't be built
}
else if (i == YunruCurrentCount - 1) {
YunruCanBuild = true;
}
}
}
}
return YunruCanBuild;
}
But only the first is ever available to build, and a second added through something like console commands doesn't produce anything.
What am I missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 27, 2019, 02:46:57 PM
How can you set a child module to be rendered on top of weapons? For example, a block of armor that rests atop a weapon and only reveals it when it is removed, like SCY's Nemean Lion. When I clamped some station modules on my ship, they always get rendered under the weapons...
Have you tried reordering the weapon slots in the .ship file? Maybe if the station slot was put above all the other weapons, it'll be rendered on top.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 27, 2019, 04:24:08 PM
Have you tried reordering the weapon slots in the .ship file? Maybe if the station slot was put above all the other weapons, it'll be rendered on top.
Yeah, I tried this but no dice... I also tried looking at the lion's animation code, but I can't seem to find what I need. I'll probably just revisit it later.

EDIT: Going by what Alex said, I took a look at the lion's sprite files and what do you know, it turns out it also uses a decorative weapon with the exact same sprite and position as the armor modules. It then uses that to cover the weapons (moving both the station and the decor at once). Ingenious.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 28, 2019, 02:36:22 PM
I'm making a faction planet, and I have most things set up: faction, system, planet, markets, patrols. There's one thing I can't seem to find, which is, how do I set the planet to be the faction's home planet? Specifically, if I start a new game in Nexerelin, how do I start spawned at that planet, and not out in hyperspace?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 29, 2019, 06:17:44 AM
I'm making a faction planet, and I have most things set up: faction, system, planet, markets, patrols. There's one thing I can't seem to find, which is, how do I set the planet to be the faction's home planet? Specifically, if I start a new game in Nexerelin, how do I start spawned at that planet, and not out in hyperspace?
data/config/exerelin/corvus_spawnpoints.csv (DME and possibly some other mods have an example)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 29, 2019, 08:02:42 AM
What is the best way to remove the AI of a module? I want to make shield modules manually controlled by the main ship system, but since the modules have their own AI they keep toggling their shields by themselves.

I tried making a dummyAI with no methods implemented, but i get nullpointers this way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 29, 2019, 09:03:31 AM
Hmm - have you tried ship.setShipAI(null) on the module? Otherwise: seeing what you did and what the exception is could help figure it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 29, 2019, 09:57:11 AM
Hmm - have you tried ship.setShipAI(null) on the module? Otherwise: seeing what you did and what the exception is could help figure it out.
I just set the module shipAi null as you suggested, by the main ship system, and got the same error

Code
98852 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.Ship$ShipAIWrapper.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

It doesn't tell me where exactly the problem is

-edit-

problem was the AiFlags being null

Code
public edshipyard_Dummy_AI() {
        AIFlages = new ShipwideAIFlags();
}

this fixed it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 29, 2019, 10:03:51 AM
Ahh, right, never mind, that won't work. But a dummy plugin implementing ShipAIPlugin should work, I believe, as long as its getConfig() and getAIFlags() methods return not-null.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 29, 2019, 10:12:26 AM
Ahh, right, never mind, that won't work. But a dummy plugin implementing ShipAIPlugin should work, I believe, as long as its getConfig() and getAIFlags() methods return not-null.
Yep made the dummy and it works now,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 30, 2019, 05:48:02 AM
Is there a way to alter vanilla plugins?
Specifically I want blueprint packages to give individual blueprints instead, but a new plugin means it doesn't work unless the package calls the new plugin instead (which is problematic with mods).

Failing that, is there a way to (effectively) do a search and replace on which plugin a blueprint calls?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on October 30, 2019, 06:50:01 AM
A really dumb question, especially since I've been modding for a moment now...

In hull.csv, what is the "8/6/5/4%" column for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 30, 2019, 09:13:00 AM
A really dumb question, especially since I've been modding for a moment now...

In hull.csv, what is the "8/6/5/4%" column for?
It's there to provide info while ship designing, similar to the "range" section near fuel. If I understand right, Alex had it set up on his spreadsheet to autofill based on the ship size and flux dissipation, to give a vague goal on flux capacity. A normal (frigate/destroyer/cruiser/capital) will have its dissipation be (8/6/5/4%) of its capacity. So for example, if a frigate had 80 dissipation, its "8%" column would be 80 / 0.08, or 1000, which you could use for the flux capacity stat if you wanted the ship to have a capacity:dissipation ratio in the normal range, or you can raise or lower the capacity to make a ship more or less efficient at dissipation compared to capacity. The column doesn't actually change the ship's stats, so you can leave it blank.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 30, 2019, 11:02:30 AM
How can I find out if a fleet is in emergency burn? I want to make a ship that increases its own max burn during emergency burns, is that possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 30, 2019, 11:40:03 AM
@Sundog: thank you for helping out here!
Or trying to, at least  ::)

Specifically I want blueprint packages to give individual blueprints instead, but a new plugin means it doesn't work unless the package calls the new plugin instead (which is problematic with mods).

Failing that, is there a way to (effectively) do a search and replace on which plugin a blueprint calls?
I'm not sure about any of that, but I think a better approach might be to remove/disable all blueprint packages and replace them with standalone blueprints. Of course, that might not work for what you're trying to do.

How can I find out if a fleet is in emergency burn? I want to make a ship that increases its own max burn during emergency burns, is that possible?
Neat idea. Maybe try something like this:
Code
    @Override
    public void advanceInCampaign(FleetMemberAPI member, float amount) {
        if(member.getFleetData().getFleet().getAbility(Abilities.EMERGENCY_BURN).isActive()) {
            member.getStats().getDynamic().getMod(Stats.FLEET_BURN_BONUS).modifyFlat("my_hullmod_id", 1);
        }
    }
Not sure if that'll work, and of course it needs a bunch of null checks.
By the way, you're making some pretty crazy stuff! I hope you keep it up  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on October 30, 2019, 12:56:16 PM
Maybe try something like this:
It works! I only had to change "isActive" to "isActiveOrInProgress," I suppose because emergency burn isn't a toggle.
Quote
I hope you keep it up  :)
Thanks, I will.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 30, 2019, 06:47:55 PM
Or trying to, at least  ::)

Oh, definitely succeeding :D

Only thing I'd suggest for this:

member.getFleetData().getFleet().getAbility(Abilities.EMERGENCY_BURN)

Is checking that getAbility() doesn't return null. Some fleets may not have the Emergency Burn ability - iirc remnant fleets, the player's fleet early in the tutorial, some other enemy fleets - and in that case getAbility() will return null.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on October 30, 2019, 10:45:50 PM
If you run the game in dev mode, the log will show a lot of stuff regarding which rule is picked and why, so I'd recommend looking at that.

So I've just done this several times with several tweaks and it's still not making sense. Here's the breakdown of the outputs that occur.
Spoiler
(https://i.imgur.com/hm7nGkr.png)
(https://i.imgur.com/VV6CFOl.png)
(https://i.imgur.com/1g1Fi8J.png)
[close]

The fact that the custom dialogue I have for this station isn't showing up is pretty indicative that the game thinks this is something else, despite this thing being tagged and id'd in the original HMINightmare class file. Could it possibly have something to do with the custom_entities entry?

Code
		"hmi_station_nightmare":{
"defaultName":"Kiel Research Station", # used if name=null in addCustomEntity()
"defaultRadius":45, # used if radius<0 in addCustomEntity()
"nameInText":"Kiel research station",
"shortName":"station",
"customDescriptionId":"station_research_remnant",
"interactionImage":"graphics/illustrations/orbital_construction.jpg",
"icon":"graphics/icons/station0.png",
"iconWidth":20,
"iconHeight":20,
"sprite":"graphics/stations/station_side00.png",
"spriteWidth":40,
"spriteHeight":40,
"renderShadow":true,
"useLightColor":true,
"showInCampaign":true,
"showIconOnMap":true,
"showNameOnMap":false,
"scaleNameWithZoom":false,
"scaleIconWithZoom":true,
"tags":["has_interaction_dialog", "salvageable"],
"layers":[STATIONS], # what layer(s) to render in. See CampaignEngineLayers.java for possible values
},

Sorry for being a bother.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 31, 2019, 02:02:06 AM
Is there a way to reliably adjust maxShipsInAIFleet within the game, i.e. outside of directly editing settings.json? I threw the following piece of code together based very loosely on this means of adjusting maxIndustries (https://fractalsoftworks.com/forum/index.php?topic=15511.0):
Code: java
    public void AdjustMaxAIShips() {
        for (FactionAPI faction : Global.getSector().getAllFactions()) {
            FactionDoctrineAPI doctrine = faction.getDoctrine();
            if (doctrine.getNumShips() > HighestNumShips) {
                HighestNumShips = doctrine.getNumShips();
            }
        }
        int OverMax = (int) Math.floor((HighestNumShips-5)/2);
       
        int maxShipsInAIFleet = Global.getSettings().getInt("maxShipsInAIFleet");
        maxShipsInAIFleet = 30 + OverMax;
    }
I didn't really expect it to work, but I was surprised to find that it did work for stuff like Mining Fleets, Mercantile Convoys and some specific Hegemony Patrols (https://i.imgur.com/ysIrVNq.png), but it had no effect on more regular appearing fleets like Fast Pickets and wasn't reliable regardless. I'm expecting that in order to reliably change this for all fleets I'd have to actually modify FleetFactoryV3, but I'm hoping that this might be avoidable. Is this possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 31, 2019, 07:54:03 AM
I am trying to make a hullmod that adds the cargo capacity of the ship modules to the main ship, but it is not working, what I am doing wrong here?

Code
 @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
    if(ship != null) {
    MutableShipStatsAPI stats = ship.getMutableStats();
    List<ShipAPI> modules = ship.getChildModulesCopy();
    if(stats != null && modules != null && !modules.isEmpty()) {
    float cargo = 0;
    for(ShipAPI m : modules) {
    cargo += m.getHullSpec().getCargo();
    }
    stats.getCargoMod().modifyFlat("ED_trainlocomotive", cargo);
    }
    }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 31, 2019, 10:27:41 AM
If you run the game in dev mode, the log will show a lot of stuff regarding which rule is picked and why, so I'd recommend looking at that.

So I've just done this several times with several tweaks and it's still not making sense. Here's the breakdown of the outputs that occur.

Ahh, I mean starsector.log, not the on-screen output in the game.

Is there a way to reliably adjust maxShipsInAIFleet within the game, i.e. outside of directly editing settings.json? I threw the following piece of code together based very loosely on this means of adjusting maxIndustries (https://fractalsoftworks.com/forum/index.php?topic=15511.0):

Hmm, not really, no - the way it works for maxIndustries is... very situational. I did make some changes to SettingsAPI that makes it doable in the next release, though.

int maxShipsInAIFleet = Global.getSettings().getInt("maxShipsInAIFleet");
maxShipsInAIFleet = 30 + OverMax;

This doesn't actually do anything - "int maxShipsInAIFleet" is a local variable that is assigned the value returned by the getInt() method; changing it will not influence anything outside the method you're in.


I am trying to make a hullmod that adds the cargo capacity of the ship modules to the main ship, but it is not working, what I am doing wrong here?

That's just not going to work - ship modules don't have corresponding FleetMemberAPIs/stats/etc in the campaign. They only exist as variants, along with damage tracking. So, it's just functionally impossible to do what you're trying to do, their hullmods will never be applied in the campaign.

Further:
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
   
This method only gets called in combat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 31, 2019, 10:41:22 AM
That's just not going to work - ship modules don't have corresponding FleetMemberAPIs/stats/etc in the campaign. They only exist as variants, along with damage tracking. So, it's just functionally impossible to do what you're trying to do, their hullmods will never be applied in the campaign.

Further:
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
   
This method only gets called in combat.
Correct me if I'm wrong, but it could be simulated through use of tags though?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 31, 2019, 10:54:25 AM
Correct me if I'm wrong, but it could be simulated through use of tags though?

I'm not sure what you mean?


It could probably be done with a hidden hullmod on the main ship's body going through and checking the variants, though, or some such... ah, maybe I've misread the original question - if the hullmod is not intended to apply to the modules, then that part of it isn't a problem, and just the use of applyEffectsAfterShipCreation is the issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hoakin Blackforge on October 31, 2019, 11:06:44 AM
What mods do i need for save editing? There is some stuff i want to test out. But im not sure what mods i have to download.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 31, 2019, 12:50:42 PM
Are there API hooks to modify the list of portraits available to the player faction during the campaign (such as through using a rule command)?

I want to have a script that locks out all but the commissioned faction's portraits when taking on a commission (this will be optional) and reverting back to the settings list when resigning a commission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 31, 2019, 01:37:45 PM
What mods do i need for save editing? There is some stuff i want to test out. But im not sure what mods i have to download.
No mods are required, but it sounds like you might be looking for Console Commands (http://fractalsoftworks.com/forum/index.php?topic=4106.0). You can edit save files directly with any plaintext editor. Notepad++ (https://notepad-plus-plus.org/downloads/) is popular, free, lightweight, and extensible.

Are there API hooks to modify the list of portraits available to the player faction during the campaign (such as through using a rule command)?

I want to have a script that locks out all but the commissioned faction's portraits when taking on a commission (this will be optional) and reverting back to the settings list when resigning a commission.
Code: java
WeightedRandomPicker<String> portriatIDs = Global.getSector().getFaction(Factions.PLAYER).getPortraits(FullName.Gender.ANY);
From there, you should be able to modify portraitIDs any way you like.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 31, 2019, 02:45:00 PM

That's just not going to work - ship modules don't have corresponding FleetMemberAPIs/stats/etc in the campaign. They only exist as variants, along with damage tracking. So, it's just functionally impossible to do what you're trying to do, their hullmods will never be applied in the campaign.

Further:
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
   
This method only gets called in combat.
My objective would be having a modular ship and allow the player to swap any modules by some kind of dialogue option in a special station and have those modules change how the main ship operates, can that be done?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 31, 2019, 02:58:35 PM
Code: java
WeightedRandomPicker<String> portriatIDs = Global.getSector().getFaction(Factions.PLAYER).getPortraits(FullName.Gender.ANY);
From there, you should be able to modify portraitIDs any way you like.

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 31, 2019, 03:12:30 PM
Is there a way to reliably adjust maxShipsInAIFleet within the game, i.e. outside of directly editing settings.json? I threw the following piece of code together based very loosely on this means of adjusting maxIndustries (https://fractalsoftworks.com/forum/index.php?topic=15511.0):

Hmm, not really, no - the way it works for maxIndustries is... very situational. I did make some changes to SettingsAPI that makes it doable in the next release, though.

int maxShipsInAIFleet = Global.getSettings().getInt("maxShipsInAIFleet");
maxShipsInAIFleet = 30 + OverMax;

This doesn't actually do anything - "int maxShipsInAIFleet" is a local variable that is assigned the value returned by the getInt() method; changing it will not influence anything outside the method you're in.
Well, something more to look forward to in the next version of Starsector!

Yeah, I really doubted that it was affecting anything, but in my brief tests I was seeing fleets that go over the max and I wasn't sure what was responsible. It seems that if you set a faction's NumShips doctrine high enough, some fleets are not affected by the fleep cap. Thanks for your answer!

EDIT: Alternatively, is there some way in the API to reload settings.json? I know you can turn on DevMode -> Simulator -> Press F8, but I don't think that's something to be done while actually playing the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: oiltanker on October 31, 2019, 03:17:38 PM
I am that type of guy that likes program logic more than text rule sets.
How do I create a salvage interaction upon selecting an option in InteractionDialogPlugin implementation?

Code example:
Code
@Override
public void optionSelected(OptionId option, String optionText) {
if (option == OptionId.INIT) {
dialogInit();
} else if ...
} else if (option == OptionId.CONFIRM_DECONSTRUCT) {
String locationType = null;
...

replaceEntity(playerFleet.getStarSystem(), target, locationType, Factions.NEUTRAL);
// TODO: Get some resources back through salvage                                                < ---- ---- ----
leaveDialog();
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on October 31, 2019, 07:36:20 PM
Is there a good way to determine if a distant fleet would want to attack the player fleet if the two were close to each other? Failure to account for third parties wouldn't be a problem. Neither would only working for ModularFleetAIs. I thought this would do the trick, but I'm still getting false positives:
Code
npcFleet.getAI().pickEncounterOption(null, playerFleet, true) == CampaignFleetAIAPI.EncounterOption.ENGAGE

My objective would be having a modular ship and allow the player to swap any modules by some kind of dialogue option in a special station and have those modules change how the main ship operates, can that be done?
I hope so! The biggest obstacle would be changing the hull ID of module slots at runtime. Variants expose getStationModules(), which I think returns a map with slot IDs as keys and hull IDs as values. I don't know if it would work, but you might try overwriting those values. After that, you could add a hullmod to the core ship that checks which modules are installed to decide which effects to apply.

Thank you!
No problem  :)

How do I create a salvage interaction upon selecting an option in InteractionDialogPlugin implementation?
That depends on what you're trying to do. "Salvage interaction" is extremely ambiguous. You might try taking a look at some of the classes in com.fs.starfarer.api.impl.campaign.rulecmd.salvage
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 31, 2019, 07:59:13 PM
My objective would be having a modular ship and allow the player to swap any modules by some kind of dialogue option in a special station and have those modules change how the main ship operates, can that be done?
I hope so! The biggest obstacle would be changing the hull ID of module slots at runtime. Variants expose getStationModules(), which I think returns a map with slot IDs as keys and hull IDs as values. I don't know if it would work, but you might try overwriting those values. After that, you could add a hullmod to the core ship that checks which modules are installed to decide which effects to apply.
Right now I am already having trouble getting the second part "checks which modules are installed to decide which effects to apply." to work, i can't use applyEffectBefore creation and neither applyEffectAfter so i don't know how to proceed. Tomorrow i will try using advanceInCampaign instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 31, 2019, 08:46:50 PM
Code: java
WeightedRandomPicker<String> portriatIDs = Global.getSector().getFaction(Factions.PLAYER).getPortraits(FullName.Gender.ANY);
From there, you should be able to modify portraitIDs any way you like.

Right, yeah! But - use Gender.MALE and Gender.FEMALE - I don't think "ANY" will work here.

My objective would be having a modular ship and allow the player to swap any modules by some kind of dialogue option in a special station and have those modules change how the main ship operates, can that be done?

Hmm - maybe? I think you might have some problems if the player, say, saves off an autofit goal variant and then tries to apply it to a ship that has a different set of modules. That, I think, would likely cause a crash. But just as far as the effects you're talking about, that sounds doable with some built-in hullmods in the main body of the ship. In general, I'm not sure if this is 100% doable and/or will work smoothly, iirc some stuff assumes the module hull types don't change so it's... going against the grain, at best.

i can't use applyEffectBefore creation

Hmm, why not? I'd expect that's the one you'd want to use, it being the one that gets called in the campaign...


EDIT: Alternatively, is there some way in the API to reload settings.json? I know you can turn on DevMode -> Simulator -> Press F8, but I don't think that's something to be done while actually playing the game.

There isn't, no - some of the settings wouldn't take effect and it'd be a bit of a mess without a decent amount of code to help it along...




I am that type of guy that likes program logic more than text rule sets.
How do I create a salvage interaction upon selecting an option in InteractionDialogPlugin implementation?

Code example:
Code
@Override
public void optionSelected(OptionId option, String optionText) {
if (option == OptionId.INIT) {
dialogInit();
} else if ...
} else if (option == OptionId.CONFIRM_DECONSTRUCT) {
String locationType = null;
...

replaceEntity(playerFleet.getStarSystem(), target, locationType, Factions.NEUTRAL);
// TODO: Get some resources back through salvage                                                < ---- ---- ----
leaveDialog();
}
}


Something like:

dialog.setInteractionTarget(entity);
RuleBasedInteractionDialogPluginImpl plugin = new RuleBasedInteractionDialogPluginImpl("OpenInteractionDialog");
dialog.setPlugin(plugin);
plugin.init(dialog);

Would switch the dialog to another target ("entity") and fire off the initial interaction within the same dialog. Of course, that would use the rules specified in rules.csv for that interaction. If you want to avoid using rules.csv entirely, you'd have to re-code the salvage interaction from scratch, since the vanilla one is implemented using rules.csv.


Is there a good way to determine if a distant fleet would want to attack the player fleet if the two were close to each other? Failure to account for third parties wouldn't be a problem. Neither would only working for ModularFleetAIs. I thought this would do the trick, but I'm still getting false positives:
Code
npcFleet.getAI().pickEncounterOption(null, playerFleet, true) == CampaignFleetAIAPI.EncounterOption.ENGAGE

That should work, actually; it's the method the fleets use when deciding to pursue or run away under the hood, too. The results *are* cached for 3 seconds, btw, so maybe that accounts for some discepancies?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 31, 2019, 09:05:57 PM
Code: java
WeightedRandomPicker<String> portriatIDs = Global.getSector().getFaction(Factions.PLAYER).getPortraits(FullName.Gender.ANY);
From there, you should be able to modify portraitIDs any way you like.

Right, yeah! But - use Gender.MALE and Gender.FEMALE - I don't think "ANY" will work here.


Thanks for the clarification! :)- I am working on getting this into the next update alongside faction-specific blueprints based upon commission status.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 31, 2019, 09:36:21 PM

i can't use applyEffectBefore creation

Hmm, why not? I'd expect that's the one you'd want to use, it being the one that gets called in the campaign...

Do the modules exist during applyEffectBefore? Aren't they added on after the ship is created? Also how to get the ship through stats again?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: oiltanker on November 01, 2019, 03:37:32 AM
Is there a way to open a faction setup dialog (as when starting the first colony) inside InteractionDialogPrlugin implementation?
Is it possible to prompt player input string (like when prompting for a colony name) in same circumstances?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 01, 2019, 05:04:14 AM

So I've just done this several times with several tweaks and it's still not making sense. Here's the breakdown of the outputs that occur.

Ahh, I mean starsector.log, not the on-screen output in the game.

Thanks for that. I figured out the problem was the game was not acknowledging the $tag, and changed it appropriately. Now I've run into two problems.

The first is a nullPointerException soft lock on salvaging. This is because I'm trying to use-
Code
salvage.addSpecial(new SpecialItemData("hullmod", "hmi_subliminal"), 1);
-to add a hullmod blueprint of a hullmod. However, the game doesn't recognise it. I think it's because 'hullmod' isn't the right term for what I'm trying to add. What is the correct classification for a hullmod blueprint?

The second is the actual defender fleet. I have no idea how to do this. I was under the impression I could use DefenderPluginOverride in the system gen file to get what I want, but it's clear the system I have set up doesn't acknowledge the defenders and skips straight to the salvage. I've looked at SalvageGenFromSeed, and I can't make heads or tales of it due to SalvageDefenderModificationPluginImpl being buried inside it, meaning I'm unsure what to extend. Could anyone help me with this please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 01, 2019, 06:54:48 AM
I have a rather simple hullmod that doubles energy weapon damage (side question: do beams count as energy weapons? I ask because they have their own entry) but increases flux by 1.5x.

It works fine, but how do I get the changes to be displayed in the refit screen (as currently it only shows the base damage and base flux)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 01, 2019, 05:43:09 PM
Really need help getting the modules during advanceInCampaignor applyEffectsBeforeShipCreation, nothing i do work, i don't even get a crash, just nothing happens, here my current attempt

Code
public void advanceInCampaign(FleetMemberAPI member, float amount) {
    super.advanceInCampaign(member, amount);
    MutableShipStatsAPI stats = member.getStats();
    if(stats != null && stats.getEntity() instanceof ShipAPI) {
    ShipAPI ship = (ShipAPI) stats.getEntity();
    if(ship != null) {
    List<ShipAPI> modules = ship.getChildModulesCopy();
        float cargo = 0;
            if(modules != null) {
            for(ShipAPI m : modules) {
            //todo check the type of wagon
            cargo += 1000f;
            }
            }
            stats.getCargoMod().modifyFlat("trainCargoBonus", cargo);
    }   
    }   
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2019, 06:02:57 PM
Is there a way to open a faction setup dialog (as when starting the first colony) inside InteractionDialogPrlugin implementation?
Is it possible to prompt player input string (like when prompting for a colony name) in same circumstances?

See: CampaignUIAPI.showPlayerFactionConfigDialog()

The first is a nullPointerException soft lock on salvaging. This is because I'm trying to use-
Code
salvage.addSpecial(new SpecialItemData("hullmod", "hmi_subliminal"), 1);
-to add a hullmod blueprint of a hullmod. However, the game doesn't recognise it. I think it's because 'hullmod' isn't the right term for what I'm trying to add. What is the correct classification for a hullmod blueprint?

See: special_items.csv for the correct ID. (It's "modspec")


The second is the actual defender fleet. I have no idea how to do this. I was under the impression I could use DefenderPluginOverride in the system gen file to get what I want, but it's clear the system I have set up doesn't acknowledge the defenders and skips straight to the salvage. I've looked at SalvageGenFromSeed, and I can't make heads or tales of it due to SalvageDefenderModificationPluginImpl being buried inside it, meaning I'm unsure what to extend. Could anyone help me with this please?

Putting a DefenderDataOverride into the entity's memory under the MemFlags.SALVAGE_DEFENDER_OVERRIDE key /should/ work.  If your custom entity has also got an entry in salvage_entity_gen_data.csv, you could set the defender info there.


I have a rather simple hullmod that doubles energy weapon damage (side question: do beams count as energy weapons? I ask because they have their own entry) but increases flux by 1.5x.

It's based on the weapon type, so beams count (or don't) based on that.

It works fine, but how do I get the changes to be displayed in the refit screen (as currently it only shows the base damage and base flux)?

If you mean the weapon tooltip, that'll only show the base stats. If you mean the flux generation of the weapon groups, IIRC that should reflect changes but I'm not 100% sure. If it doesn't, then you can't.


Really need help getting the modules during advanceInCampaignor applyEffectsBeforeShipCreation, nothing i do work, i don't even get a crash, just nothing happens, here my current attempt

Don't try to get ShipAPIs, those don't exist at that point. You want variants; see: FleetMemberAPI.getVariant().getModuleVariant() and a bunch of other related methods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 01, 2019, 06:49:28 PM
Don't try to get ShipAPIs, those don't exist at that point. You want variants; see: FleetMemberAPI.getVariant().getModuleVariant() and a bunch of other related methods.
Yeah this limits a lot what i wanted to do, but at least it works for now, thanks.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 01, 2019, 09:49:09 PM
See: special_items.csv for the correct ID. (It's "modspec")

Thanks for that! Works perfectly in that regard. However, now something stranger is happening - the station doesn't demolish once it's been salvaged. I tried to add 'SalvageEntity demolish' after 'HMINightmareStation genNightmareLoot' (the script that determines what the station drops) but that didn't work. I tried to find in the files where this occurs, but I'm unsure whether 'demolish' is just a command for when you shoot a salvage entity and turn it into a debris field, or if it's run immediately after salvaging to generate the debris field.

Putting a DefenderDataOverride into the entity's memory under the MemFlags.SALVAGE_DEFENDER_OVERRIDE key /should/ work.  If your custom entity has also got an entry in salvage_entity_gen_data.csv, you could set the defender info there.

No dice I'm afraid. Putting DefenderOverride doesn't work, and putting it in the salvage_entity_gan_data doesn't work either. According to the log it goes from the initial step of finding hmi_nightmarestationOpenDialog (OpenInteractionDialog), like it should, and then for some bizarre reason skips straight to hmi_nightmarestationContinueDefenders (BeginSalvage). According to the rule checks, hmi_nightmarestationdefender_Desc (TriggerAutomatedDefenses) is not even searched for. hmi_nightmarestationOpenDialog (OpenInteractionDialog) uses "SalvageGenFromSeed/ShowDefaultVisual/FireBest SalvageCheckHostile" as the script - is this incorrect?

EDIT: Even worse, it appears now every single time I salvage something, it uses hmi_nightmarestationContinueDefenders as the default BeginSalvage option. This is getting increasingly bizarre.

Many thanks for the help thus far.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 02, 2019, 12:05:23 AM
How can I check if a mine has exploded? For example, if I wanted to trigger an effect upon a mine's detonation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bcbc2425 on November 02, 2019, 12:37:33 AM
so, ive seen somewhere that you can modify the max ships. i need this for purely scientific reasons. more stupid capital ship spam? no no, its just science!
also is there a way to prehaps modify the ship point cap above the 500 in game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on November 02, 2019, 03:51:02 AM
so, ive seen somewhere that you can modify the max ships. i need this for purely scientific reasons. more stupid capital ship spam? no no, its just science!
also is there a way to prehaps modify the ship point cap above the 500 in game?
These are all options you edit in Starsector/starsector-core/data/config/settings.json:
"maxShipsInFleet":30, adjusts the number of ships that you can having in your fleet.
"maxShipsInAIFleet":30, adjusts the number of ships that AI can have in their fleet (be mindful when editing this that it will significantly alter the sorts of fleets generated by the game).
"maxBattleSize":500, adjusts the ship point cap. If you increase it, I believe this will change the slider in-game which you can then alter to suit your purposes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 02, 2019, 05:48:23 AM
Someone explain this to me, I get this error:
Code
27061 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.ai.sc_retro_ai]
java.lang.RuntimeException: Error compiling [data.scripts.ai.sc_retro_ai]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.ai.sc_retro_ai'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.ai.sc_retro_ai' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more



Even though my ai java file start with

Code
public class sc_retro_ai implements ShipSystemAIScript {

????
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 02, 2019, 05:51:02 AM
Does it also have "package data.scripts.ai" or whatever it is at the top?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 02, 2019, 09:49:17 AM
Code
package data.shipsystems.scripts.ai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.FluxTrackerAPI;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import com.fs.starfarer.api.util.IntervalUtil;
import data.scripts.util.Utils;
import java.util.List;
import org.lazywizard.lazylib.CollectionUtils;
import org.lazywizard.lazylib.CollisionUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 02, 2019, 09:54:22 AM
Where is the file itself?
The error is that it can't find the file at "data.scripts.ai.sc_retro_ai", but the package line indicates the file is at "data.shipsystems.scripts.ai"

If it's at data.shipsystems.scripts.ai, then you've a reference elsewhere (probably a .csv) that you need to fix, otherwise if it's in data.scripts.ai, then change the first line to "data.scripts.ai".

...

I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 02, 2019, 09:57:27 AM
I think I may be ***..one typo in the Utils.java class name..that might have been it. Will test now
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 02, 2019, 10:28:01 AM
How can I check if a mine has exploded? For example, if I wanted to trigger an effect upon a mine's detonation.

IIRC you'd need to track the mines from frame to frame and then possibly check if there's a DamagingProjectileAPI from its explosion to confirm it actually exploded, there's no callback to say "mine has exploded".


However, now something stranger is happening - the station doesn't demolish once it's been salvaged. I tried to add 'SalvageEntity demolish' after 'HMINightmareStation genNightmareLoot' (the script that determines what the station drops) but that didn't work. I tried to find in the files where this occurs, but I'm unsure whether 'demolish' is just a command for when you shoot a salvage entity and turn it into a debris field, or if it's run immediately after salvaging to generate the debris field.

Yeah, demolish() is left over from when that was an option, but should have still worked, in theory.

SalvageEntity performSalvage - which should be getting called during normal salvage? - will spawn a debris field and fade out/remove the entity.

Does your entity have the "salvageable" tag?

Basically the things you're doing sound like they should work and that they don't work makes it seem like there's something going wrong in the details that are not in your post, if that makes sense.


No dice I'm afraid. Putting DefenderOverride doesn't work, and putting it in the salvage_entity_gan_data doesn't work either. According to the log it goes from the initial step of finding hmi_nightmarestationOpenDialog (OpenInteractionDialog), like it should, and then for some bizarre reason skips straight to hmi_nightmarestationContinueDefenders (BeginSalvage). According to the rule checks, hmi_nightmarestationdefender_Desc (TriggerAutomatedDefenses) is not even searched for. hmi_nightmarestationOpenDialog (OpenInteractionDialog) uses "SalvageGenFromSeed/ShowDefaultVisual/FireBest SalvageCheckHostile" as the script - is this incorrect?

Hmm - the "bizarre reason" should also be detailed in the log, no? If a rule that you're expecting isn't being searched for, that means that its trigger is not the trigger that was fired.

In your DefenderDataOverride, did you set probDefenders? It defaults to 0. I guess you must have, since the constructors all require it, but I'd make sure you're not passing in 0 for that. That'd be one reason for TriggerAutomatedDefenses not being fired.


EDIT: Even worse, it appears now every single time I salvage something, it uses hmi_nightmarestationContinueDefenders as the default BeginSalvage option. This is getting increasingly bizarre.

Again, the reasons for that should be in the log. If multiple rules match the trigger and conditions, and have the same number of conditions, then one will be picked randomly. You can add a " score:100" (or some other number) to individual conditions to disambiguate in cases like this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 02, 2019, 11:00:26 AM
Two part question:
A - Is there a way to check if a player has a skill or not?
B - Am I overthinking this? I want to add a hullmod that reduces the negative effect of D-Mods by 15%. However, as far as I can tell Safety Procedures halves the impact rather than reducing it by 50%. I could just go with it, but then it would break the trend of "benefits add together, negatives multiply."
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: oiltanker on November 02, 2019, 02:51:10 PM
It was told to me that through invoking rule-based interaction plugin from simple InteractionDialogPlugin, but is possible to do other way around?
Is it possible to invoke e.g. a class, or a different plugin to execute a Java code?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on November 02, 2019, 05:55:03 PM
If the player lays in a course for a planet in another system, is there a way to get the SectorEntityToken for that planet? getInteractionTarget() in CampaignFleetAPI gets a jump point in this case, not the destination planet in the other system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 02, 2019, 08:25:31 PM
Yeah, demolish() is left over from when that was an option, but should have still worked, in theory.

SalvageEntity performSalvage - which should be getting called during normal salvage? - will spawn a debris field and fade out/remove the entity.

Does your entity have the "salvageable" tag?

Basically the things you're doing sound like they should work and that they don't work makes it seem like there's something going wrong in the details that are not in your post, if that makes sense.

It does make sense that I'm doing something wrong, it just doesn't make sense as to what has gone wrong.

Here is the relevant section from custom_entities for the station, which has always had the 'salvageable' tag:
Code
		"hmi_station_nightmare":{
"defaultName":"Kiel Research Station", # used if name=null in addCustomEntity()
"defaultRadius":45, # used if radius<0 in addCustomEntity()
"nameInText":"Kiel research station",
"shortName":"station",
"customDescriptionId":"station_research_remnant",
"interactionImage":"graphics/illustrations/orbital_construction.jpg",
"icon":"graphics/icons/station0.png",
"iconWidth":20,
"iconHeight":20,
"sprite":"graphics/stations/station_side00.png",
"spriteWidth":40,
"spriteHeight":40,
"renderShadow":true,
"useLightColor":true,
"showInCampaign":true,
"showIconOnMap":true,
"showNameOnMap":false,
"scaleNameWithZoom":false,
"scaleIconWithZoom":true,
"tags":["has_interaction_dialog", "salvageable"],
"layers":[STATIONS], # what layer(s) to render in. See CampaignEngineLayers.java for possible values
},

Adding SalvageEntity performSalvage to genLootNightmare demolishes the station as it should, but it opens up two salvage windows simultaneously, only one of which you can access. Adding SalvageEntity demolish closes the salvage window as soon as it opens and forms the debris field. I'm unsure if I should somehow add a demolish function to genLootNightmare to run after the entity has been salvaged? After the genNightmareLoot is executed, there's nothing else showing up in the log.

Hmm - the "bizarre reason" should also be detailed in the log, no? If a rule that you're expecting isn't being searched for, that means that its trigger is not the trigger that was fired.

In your DefenderDataOverride, did you set probDefenders? It defaults to 0. I guess you must have, since the constructors all require it, but I'd make sure you're not passing in 0 for that. That'd be one reason for TriggerAutomatedDefenses not being fired.

Here is the entry in salvage_entity_gen_data, which has always had probDefenders at 1:

Code
hmi_station_nightmare,1,1000,DISCOVERABLE,2200,1000,3000,,,,hmi_nightmare,1,1,200,500,8,,,

In the log, it says that the entity is missing $hasDefenders, so it goes straight to sal_explore.
EDIT: Found the problem! I forgot to add the boss ship variant to default_roles. So when the game tried to find defenders, it couldn't, as there were no ships to select. This caused the entity to lose $hasDefenders, and thus why it was never called. Checking this by changing the faction from the dummy hmi_nightmare faction to remnant caused Remnants to spawn as the defending fleet.

Again, the reasons for that should be in the log. If multiple rules match the trigger and conditions, and have the same number of conditions, then one will be picked randomly. You can add a " score:100" (or some other number) to individual conditions to disambiguate in cases like this.

According to the log, it checks if the tag "hmi_nightmarestationtag" exists. Which it then thinks it does and uses the tag-specific salvage option, regardless if the tag is present on the entity or not. I'm unsure if it was changing the format from tag == $hmi_nightmarestationtag to $tag:hmi_nightmarestationtag fixed the problem, or removing hmi_nightmarestationtag from data/campaignid/hmi_tags.json did the trick.

Thank you so much for the help so far.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on November 02, 2019, 11:32:30 PM
Hiya, I'm trying to increase the size of the fleets found in Remnant-controlled systems. I thought the correct function to call was FleetFactoryV3.addFleetPoints(), but I'm less sure now as it doesn't seem to have an effect no matter what I try. My (slightly sanitized) function is:
Code: java
    public void ManualUpdateFP(CampaignFleetAPI fleet) {

        Random random = new Random();
        int combatPoints = 9;
        String FleetType = FleetTypes.PATROL_SMALL;;
        FactionDoctrineAPI doctrine = fleet.getFaction().getDoctrine();

        MarketAPI market = Global.getFactory().createMarket("fake", "fake", 5);
            market.getStability().modifyFlat("fake", 10000);
            market.setFactionId("remnant");
            SectorEntityToken token = Global.getSector().getHyperspace().createToken(0, 0);
            market.setPrimaryEntity(token);
            market.getStats().getDynamic().getMod(Stats.FLEET_QUALITY_MOD).modifyFlat("fake", BASE_QUALITY_WHEN_NO_MARKET);
            market.getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).modifyFlat("fake", 1f);
       
        FleetParamsV3 params = new FleetParamsV3(
            market,
            fleet.getLocation(),
            fleet.getFaction().getId(),
            1f,
            FleetType,
            combatPoints, // combatPts
            0f, // freighterPts
            0f, // tankerPts
            0f, // transportPts
            0f, // linerPts
            0f, // utilityPts
            0f // qualityMod
        );
        params.officerNumberBonus = doctrine.getOfficerQuality() / 5 * doctrine.getNumShips();
        params.random = random;
       
        float warships = (float) doctrine.getWarships();
        float carriers = (float) doctrine.getCarriers();
        float phase = (float) doctrine.getPhaseShips();
        float NumShipsMult = Math.max(0,doctrine.getNumShips()-5);

        float fp = NumShipsMult * combatPoints/2;
        log.info("Fleet Bonus FP is: " + fp);
        float leftOverFP = fp;
        if ((warships-1)/4 * fp > 45) {
            leftOverFP = FleetFactoryV3.addFleetPoints(fleet, random, ((warships-1)/4 * fp), params, SizeFilterMode.SMALL_IS_DESTROYER,
                ShipRoles.COMBAT_MEDIUM, ShipRoles.COMBAT_LARGE, ShipRoles.COMBAT_CAPITAL);
            log.info("Added " + ((warships-1)/4*fp-leftOverFP) + " FP in large warships to " + fleet);
        } else {
            leftOverFP = FleetFactoryV3.addFleetPoints(fleet, random, ((warships-1)/4 * fp), params, SizeFilterMode.SMALL_IS_FRIGATE,
                ShipRoles.COMBAT_SMALL, ShipRoles.COMBAT_MEDIUM, ShipRoles.COMBAT_LARGE);
            log.info("Added " + ((warships-1)/4*fp-leftOverFP) + " FP in warships to " + fleet);
        }
        leftOverFP = FleetFactoryV3.addFleetPoints(fleet, random, ((carriers-1)/4 * fp), params, SizeFilterMode.SMALL_IS_FRIGATE,
            ShipRoles.COMBAT_SMALL, ShipRoles.COMBAT_MEDIUM, ShipRoles.COMBAT_LARGE);
        log.info("Added " + ((carriers-1)/4*fp-leftOverFP) + " FP in carriers to " + fleet);
    }
It's set only to fire once per fleet when inside a system with the tag "theme_remnant", and it doesn't crash or anything: the log says (example for one fleet):
Code
55736 [Thread-4] INFO  data.scripts.DoctrineEvolution  - Fleet Bonus FP is: 117.0
55736 [Thread-4] INFO  data.scripts.DoctrineEvolution  - Added 87.0 FP in large warships to com.fs.starfarer.campaign.fleet.CampaignFleet@394c5891Remnant sub-ordo
55737 [Thread-4] INFO  data.scripts.DoctrineEvolution  - Added 29.0 FP in carriers to com.fs.starfarer.campaign.fleet.CampaignFleet@394c5891Remnant sub-ordo
55737 [Thread-4] INFO  data.scripts.ApplyRCSWChanges  - Manually updating FP for com.fs.starfarer.campaign.fleet.CampaignFleet@434ab4faRemnant fragment
So something is happening under the hood. But the fleets don't actually have any ships added, and their FP remains the same. From what I understand the function chain follows something like:
addFleetPoints() -> addShips() -> addToFleet() -> addToFleet() -> fleet.getFleetData().addFleetMember()
which is the desired outcome, so I'm unsure what exactly isn't working.

(Sorry if I've totally misread the code.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vayra on November 03, 2019, 01:38:38 AM
2 quick questions:

1) ShipAPI has a .getCaptain() and a .getOriginalCaptain() - is there an accessible way to switch the captain in combat through the API?
2) Related, is there a way to forcibly eject the player from command of a ship in combat through the API? EDIT: Figured this one out - you can spawn a command shuttle and use engine.setPlayerShipExternal(ShipAPI ship) to transfer command to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on November 03, 2019, 06:14:36 AM
MutableStats Question! I'm out of ideas.

I'm trying to modify Explosive damage taken by armour, but of course I can only see stats.getKineticArmorDamageTakenMult that I presume was used for the Advanced Countermeasures skill bonus.  There's no obvious and easy 'HighExplosive' version in MutableStat. 

Kinetic is the only one with an armor damage taken modifier, so I can't compensate other damage types to balance out how I want.  Am I missing a technique or will I have to mix up my hullmod a bit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 03, 2019, 06:41:56 AM
OK, it was not that typo. Seems me and Java just do NOT get along. Even when I copy something from another mod.


EDIT:
Another question: I have this peace of code in my ModPlugin:

   @Override
    public void onNewGameAfterEconomyLoad() {
        MarketAPI market = Global.getSector().getEconomy().getMarket("avalon");
        if (market != null) {
            PersonAPI admin = Global.getFactory().createPerson();
            admin.setFaction("VNS");
            admin.setGender(Gender.MALE);
            admin.setPostId(Ranks.POST_FACTION_LEADER);
            admin.setRankId(Ranks.FACTION_LEADER);
            admin.getName().setFirst("Gabriel");
            admin.getName().setLast("Algar");
            admin.setPortraitSprite("graphics/portraits/prt_vns_algar.png");

            admin.getStats().setSkillLevel(Skills.FLEET_LOGISTICS, 3);
            admin.getStats().setSkillLevel(Skills.PLANETARY_OPERATIONS, 3);
            admin.getStats().setSkillLevel(Skills.INDUSTRIAL_PLANNING, 3);

            market.setAdmin(admin);
            market.getCommDirectory().addPerson(admin, 0);
            market.addPerson(admin);
        }
    }


It works and does add the person in question, but not the portrait. Path is OK, name is OK, but I keep getting a blank portrait in-game
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 03, 2019, 10:18:59 AM
It does make sense that I'm doing something wrong, it just doesn't make sense as to what has gone wrong.

...

Adding SalvageEntity performSalvage to genLootNightmare demolishes the station as it should, but it opens up two salvage windows simultaneously, only one of which you can access. Adding SalvageEntity demolish closes the salvage window as soon as it opens and forms the debris field. I'm unsure if I should somehow add a demolish function to genLootNightmare to run after the entity has been salvaged? After the genNightmareLoot is executed, there's nothing else showing up in the log.

This sounds like genLootNightmare is showing a salvage window in addition to performSalvage also showing a salvage window. You can't really combine the two like this. You could however add your own drop_groups (see: http://fractalsoftworks.com/forum/index.php?topic=15244.0) and then performSalvage would pick from that. Depending on how intricate the salvage generation you want is, that might work.

Otherwise, BaseSalvageSpecial.setExtraSalvage() is also an option, to add specific cargo that would be picked up by performSalvage.

Hiya, I'm trying to increase the size of the fleets found in Remnant-controlled systems. I thought the correct function to call was FleetFactoryV3.addFleetPoints(), but I'm less sure now as it doesn't seem to have an effect no matter what I try. My (slightly sanitized) function is:


int combatPoints = 9;

Hmm - 9 seems low? That's fleet points, so that wouldn't be enough for much of a change.

Offhand, nothing else strikes be as being wrong, but it's kind of a lot to pore over so I might've missed something.


1) ShipAPI has a .getCaptain() and a .getOriginalCaptain() - is there an accessible way to switch the captain in combat through the API?

Oh, oops, .setCaptain() wasn't in the API. ... alright. Added it in, not that that's any help right now.


MutableStats Question! I'm out of ideas.

I'm trying to modify Explosive damage taken by armour, but of course I can only see stats.getKineticArmorDamageTakenMult that I presume was used for the Advanced Countermeasures skill bonus.  There's no obvious and easy 'HighExplosive' version in MutableStat. 

Kinetic is the only one with an armor damage taken modifier, so I can't compensate other damage types to balance out how I want.  Am I missing a technique or will I have to mix up my hullmod a bit?

Yeah, I'm afraid I just hacked getKineticArmorDamageTakenMult() in real quick when I was adding that skill. Apologies :)

(Re: your profile picture: *thumbs up*)


It works and does add the person in question, but not the portrait. Path is OK, name is OK, but I keep getting a blank portrait in-game

Make sure the portrait is actually being loaded by the game, i.e. it's in a .faction file somewhere or in the "graphics" section of settings.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 03, 2019, 10:23:46 AM
Yeah, I struggled with getting a hullmod to show up on the list for ages before just trying something from my Red Alert 2 days and just sticking it on a dummy ship.

It seems somethings have to be tricked into being loaded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on November 03, 2019, 10:37:24 AM
OK, it was not that typo. Seems me and Java just do NOT get along. Even when I copy something from another mod.


EDIT:
Another question: I have this peace of code in my ModPlugin:

Spoiler
   @Override
    public void onNewGameAfterEconomyLoad() {
        MarketAPI market = Global.getSector().getEconomy().getMarket("avalon");
        if (market != null) {
            PersonAPI admin = Global.getFactory().createPerson();
            admin.setFaction("VNS");
            admin.setGender(Gender.MALE);
            admin.setPostId(Ranks.POST_FACTION_LEADER);
            admin.setRankId(Ranks.FACTION_LEADER);
            admin.getName().setFirst("Gabriel");
            admin.getName().setLast("Algar");
            admin.setPortraitSprite("graphics/portraits/prt_vns_algar.png");

            admin.getStats().setSkillLevel(Skills.FLEET_LOGISTICS, 3);
            admin.getStats().setSkillLevel(Skills.PLANETARY_OPERATIONS, 3);
            admin.getStats().setSkillLevel(Skills.INDUSTRIAL_PLANNING, 3);

            market.setAdmin(admin);
            market.getCommDirectory().addPerson(admin, 0);
            market.addPerson(admin);
        }
    }


It works and does add the person in question, but not the portrait. Path is OK, name is OK, but I keep getting a blank portrait in-game
[close]

Have you added the portrait to the Male Portrait section of your faction file? If the path and file are correct the portrait will still be blank if its not in there.  Its the only thing that could do this as far as I know.

EDIT: too slowwwww. Thanks for answering Alex, i'll think of something else!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on November 03, 2019, 01:52:12 PM
Hiya, I'm trying to increase the size of the fleets found in Remnant-controlled systems. I thought the correct function to call was FleetFactoryV3.addFleetPoints(), but I'm less sure now as it doesn't seem to have an effect no matter what I try. My (slightly sanitized) function is:


int combatPoints = 9;

Hmm - 9 seems low? That's fleet points, so that wouldn't be enough for much of a change.

Offhand, nothing else strikes be as being wrong, but it's kind of a lot to pore over so I might've missed something.
I'd still expect it to maybe add a lumen or something, though updating it to a larger number doesn't fix the problem either. In any case, thanks for giving it a look through; my only guess is that it's missing something present in FleetFactoryV3.createFleet() - maybe the profilerBegin or setting the FleetInflater?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 03, 2019, 04:48:48 PM
I'm not sure - maybe start by trying fleet.getFleetData().addFleetMember(<variant id>) to see if that works, just to narrow down where the issue is?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 03, 2019, 05:06:13 PM
Is this too much work for the engine in game or am I running into an infinite while loop and I'm not realizing it?

I get a heap crash when running this rule command:

Code
package archeus.rulecmd;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.characters.FullName;
import com.fs.starfarer.api.impl.campaign.rulecmd.BaseCommandPlugin;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;

import java.util.List;
import java.util.Map;

/**
 * By Morrokain
 *
 *  Parameters: Accepts "ALL" or a faction ID which it will use to obtain that faction's portraits.
 */
public class SetPlayerPortraits extends BaseCommandPlugin {

    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
       
        String faction = params.get(0).getString(memoryMap);

        WeightedRandomPicker<String> factionMalePortraitIDs = new WeightedRandomPicker<>();
        WeightedRandomPicker<String> factionFemalePortraitIDs = new WeightedRandomPicker<>();

        if (!faction.equalsIgnoreCase("all")) {
            factionMalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.MALE);
            factionFemalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.FEMALE);
        } else {
            List<FactionAPI> allFactions = Global.getSector().getAllFactions();
            String nextFaction;

            while (allFactions.iterator().hasNext()) {
                nextFaction = allFactions.iterator().next().getId();

                if (!nextFaction.equalsIgnoreCase("remnant") && !nextFaction.equalsIgnoreCase("pirates")
                        && !nextFaction.equalsIgnoreCase("sleeper") && !nextFaction.equalsIgnoreCase("scavengers")
                        && !nextFaction.equalsIgnoreCase("poor") && !nextFaction.equalsIgnoreCase("derelict")
                        && !nextFaction.equalsIgnoreCase("luddic_path") && !nextFaction.equalsIgnoreCase("player")
                        && !nextFaction.equalsIgnoreCase("neutral")) {

                    factionMalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.MALE));
                    factionFemalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.FEMALE));
                }
            }
        }

        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).clear();
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).clear();
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).addAll(factionMalePortraitIDs);
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).addAll(factionFemalePortraitIDs);
        return true;
    }

}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 03, 2019, 05:31:18 PM
This seems like a fairly trivial amount of work, so it's probably something else. Seeing the actual error would help, as might seeing more of the method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 03, 2019, 06:05:27 PM
This seems like a fairly trivial amount of work, so it's probably something else. Seeing the actual error would help, as might seeing more of the method.

Good to know, I just didn't know if assigning a bunch of WeightedRandomPicker<String> to each other would cause slowdown for some reason. I updated the original post with the entire rule command including imports.

The error is just a crash of the Java Binary Platform or a generic heap error after the engine stops responding for a long time. I am trying to get more specifics but its just been unresponsive for minutes. I'll update when I have more.

"Java(TM) Platform SE binary is not responding. If you close the program, you might lose information."
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 03, 2019, 06:38:52 PM
This sounds like genLootNightmare is showing a salvage window in addition to performSalvage also showing a salvage window. You can't really combine the two like this. You could however add your own drop_groups (see: http://fractalsoftworks.com/forum/index.php?topic=15244.0) and then performSalvage would pick from that. Depending on how intricate the salvage generation you want is, that might work.

I transitioned over to using drop_groups and salvage_gen_data and it works perfectly now! Many thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 03, 2019, 07:09:36 PM
"Java(TM) Platform SE binary is not responding. If you close the program, you might lose information."

That sounds like an infinite loop, possibly. If the faction is not "all", then this:

factionMalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.MALE);

followed later on by this:

Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).addAll(factionMalePortraitIDs);

Could potentially do that? If faction was == "player". Though I'd actually expect it to throw a ConcurrentModificationException instead. Well, I don't know! In your shoes I'd start commenting out parts of it strategically to narrow down what exactly causes the issue to occur.

I transitioned over to using drop_groups and salvage_gen_data and it works perfectly now! Many thanks Alex!

Niiiice, glad you got it working! And you're very welcome.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 03, 2019, 07:59:26 PM
"Java(TM) Platform SE binary is not responding. If you close the program, you might lose information."

That sounds like an infinite loop, possibly. If the faction is not "all", then this:

factionMalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.MALE);

followed later on by this:

Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).addAll(factionMalePortraitIDs);

Could potentially do that? If faction was == "player". Though I'd actually expect it to throw a ConcurrentModificationException instead. Well, I don't know! In your shoes I'd start commenting out parts of it strategically to narrow down what exactly causes the issue to occur.

*Edit* Well when I pass in a valid faction Id it works so that part is fine doesn't cause the problem at least, I haven't actually built a colony and tested the functionality though. Its when I pass in "all" that the infinite loop occurs. Maybe I'm misunderstanding something about iterator()? It think its definitely the while loop though. I'll have to look at it more.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 03, 2019, 08:25:29 PM
Oh, whoops:
nextFaction = allFactions.iterator().next().getId();

Right. You want something like:
Iterator<FactionAPI> iter = allFactions.iterator()

And then use iter inside the loop. The way you've got it now is creating a new iterator every time which starts iterating over the list from the beginning.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 03, 2019, 09:50:03 PM
Just a quick, although I think a deceptively difficult question: How would one prevent a ship from dropping supplies, fuel, heavy machinery and metals post-battle?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 03, 2019, 09:56:04 PM
Oh duh I should have caught that. ;D

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 04, 2019, 02:55:53 AM
Make sure the portrait is actually being loaded by the game, i.e. it's in a .faction file somewhere or in the "graphics" section of settings.json.

That was it. I didn't want the portrait to be selectable, so it wasn't in the faction files.
Putting it in settings.json did the trick
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 04, 2019, 03:29:04 AM
Can animated turrets work if the base is animated, not the barrels?

I'm trying to make a vertical launch system missile tubes with animated hatches - I made it static by setting turn speed of 0, but it only works if it isn't animated. If it's animated, I keep getting errors about not being able to find 01.png.
The frames of the animations are all properly named and referenced (weapons/animated/vlms/vlms00.png)
Right now, all hatches open at once.

I don't know if anything can be added to simplify things? Right now, it doesn't seem to be possible to make a workable launcher like that without a lot of custom java code.
Also, there's a limit of 4 fire points ATM, right? So there's no point in making more than 4 launch tubes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 04, 2019, 04:31:47 AM
Can animated turrets work if the base is animated, not the barrels?

I'm trying to make a vertical launch system missile tubes with animated hatches - I made it static by setting turn speed of 0, but it only works if it isn't animated. If it's animated, I keep getting errors about not being able to find 01.png.
The frames of the animations are all properly named and referenced (weapons/animated/vlms/vlms00.png)
Right now, all hatches open at once.

I don't know if anything can be added to simplify things? Right now, it doesn't seem to be possible to make a workable launcher like that without a lot of custom java code.
Also, there's a limit of 4 fire points ATM, right? So there's no point in making more than 4 launch tubes?
Have you considered just having invisible barrels?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 04, 2019, 09:17:24 AM
Just a quick, although I think a deceptively difficult question: How would one prevent a ship from dropping supplies, fuel, heavy machinery and metals post-battle?

Short of replacing FleetEncounterContext, I don't think there's a way - it's based on the FP cost of the ship.


Have you considered just having invisible barrels?

Also, if you don't specify a barrel sprite, it's not going to render barrels at all...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 04, 2019, 03:04:12 PM
So my attempt to modify dmod impact with a hullmod just... doesn't seem to work?
Not sure what I'm doing wrong:
Code
extends BaseHullMod {

public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
stats.getDynamic().getStat(Stats.DMOD_EFFECT_MULT).modifyMult(id, 0.85f);
}

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

EDIT: Also tried without the unapply line, still no change.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 04, 2019, 03:08:15 PM
So my attempt to modify dmod impact with a hullmod just... doesn't seem to work?
Apply and unapply, aren't those exclusive to ship systems? For hullmods you'd want applyEffectsBefore/AfterShipCreation and advanceInCombat
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 04, 2019, 03:12:40 PM
Apply and unapply, aren't those exclusive to ship systems? For hullmods you'd want applyEffectsBefore/AfterShipCreation and advanceInCombat
No idea, they were in the Safety Procedures file, so I doubt it.
Which of the three would you suggest?

Edit: Tried both before and after, no dice.

Edit 2: I also realise now that even if it did work, it'd probably apply to the entire fleet, rather than the one ship :/

Edit 3: Ah, found out why it wasn't working. DMOD_EFFECT_MULT is a final variable, so can't be modified.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 04, 2019, 04:18:20 PM
Just a quick, although I think a deceptively difficult question: How would one prevent a ship from dropping supplies, fuel, heavy machinery and metals post-battle?

Short of replacing FleetEncounterContext, I don't think there's a way - it's based on the FP cost of the ship.

Alright, thanks for that. I've tweaked the situation so after the battle and you salvage the station, you don't get basic commodities, just specials, with the junk representing the station.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 04, 2019, 04:58:56 PM
So my attempt to modify dmod impact with a hullmod just... doesn't seem to work?
Apply and unapply, aren't those exclusive to ship systems? For hullmods you'd want applyEffectsBefore/AfterShipCreation and advanceInCombat

Correct. The apply/unapply methods would just never be called in this situation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 04, 2019, 06:38:41 PM
I'm missing something somewhere, because as far as I can tell this code should work?
Code
	public void applyEffectsBeforeShipCreation(MutableShipStatsAPI stats, ShipAPI ship, HullSize hullSize, String id, float level) {
if (ship.getVariant().hasHullMod("degraded_engines")) {
stats.getMaxSpeed().modifyMult(id, 1.15f);
stats.getAcceleration().modifyMult(id, 1.15f);
stats.getDeceleration().modifyMult(id, 1.15f);
stats.getTurnAcceleration().modifyMult(id, 1.15f);
stats.getMaxTurnRate().modifyMult(id, 1.15f);
stats.getSensorProfile().modifyMult(id, 0.85f);
}
Also tested with applyEffectsAfterShipCreation, to no avail.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 04, 2019, 06:49:23 PM
Check your method signature carefully. The easiest thing to do is to look at the base class and copy from there. I'd also really suggest reading up on inheritance in Java so you can figure this out on a conceptual level - once you have that understanding, these kinds of problems won't come up nearly as often, and in the long (or, heck, probably short) run it'll save you time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 04, 2019, 07:22:47 PM
Hmm... Is there a way around it then?
It seems I can only check the hullmods in applyAfter, but I can only apply the changes I want in applyBefore.

Possibly MutableShipStatsAPI stats = ship.getMutableStats(); in applyEffectsAfter?

Edit: Tested it, mixed results. The info box you get when you hover over the question mark doesn't change, but the brief info on the refit screen does.
Is there some way to get those displays to display correctly (of note, it also effects the "jumping to hyperspace will cost X fuel" message, and the sensor range and detection displays)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on November 04, 2019, 11:17:11 PM
Is there any sort of shorthand method to render a visual copy of a ship like how addAfterimage does? Working on some custom afterimage visuals, but currently I'm just rendering the ship's sprite which looks fine mostly, but has some issues like obviously empty weapon mounts.

(https://media.discordapp.net/attachments/310517733458706442/641164589467172865/unknown.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 05, 2019, 12:11:52 AM
Can animated turrets work if the base is animated, not the barrels?

I'm trying to make a vertical launch system missile tubes with animated hatches - I made it static by setting turn speed of 0, but it only works if it isn't animated. If it's animated, I keep getting errors about not being able to find 01.png.
The frames of the animations are all properly named and referenced (weapons/animated/vlms/vlms00.png)
Right now, all hatches open at once.

I don't know if anything can be added to simplify things? Right now, it doesn't seem to be possible to make a workable launcher like that without a lot of custom java code.
Also, there's a limit of 4 fire points ATM, right? So there's no point in making more than 4 launch tubes?
Have you considered just having invisible barrels?

Already doing that. My weapon is basically 6 turret base images (vmls00 to vmls05), but the game just derps on load when I set it to be animated. Other animated weapons work normaly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Server_Corgi on November 05, 2019, 03:01:44 AM
Is there any mod or method to add blueprints of ships without blueprints in the base game into the game?

Sorry if that seems confusing, but I just want to be able to produce Legion XIV's with my own production.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hrothgar on November 05, 2019, 03:18:07 AM
Is there any sort of shorthand method to render a visual copy of a ship like how addAfterimage does? Working on some custom afterimage visuals, but currently I'm just rendering the ship's sprite which looks fine mostly, but has some issues like obviously empty weapon mounts.

(https://media.discordapp.net/attachments/310517733458706442/641164589467172865/unknown.png)

I guess making a ship with fixed loadout of weapons, like Nomad ones is eventually way to go.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 05, 2019, 08:00:59 AM
Is there any sort of shorthand method to render a visual copy of a ship like how addAfterimage does? Working on some custom afterimage visuals, but currently I'm just rendering the ship's sprite which looks fine mostly, but has some issues like obviously empty weapon mounts.

ShipAPI.setCopyLocation(Vector2f loc, float copyAlpha, float copyFacing);

Used in vanilla by phase skimmer and the like; sounds like it should work for you unless you need more than one copy, in which case, SoL.


Is there any mod or method to add blueprints of ships without blueprints in the base game into the game?

Sorry if that seems confusing, but I just want to be able to produce Legion XIV's with my own production.

Hmm - if you have the Console Commands mod, something like:
RunCode Global.getSector().getPlayerFaction().addKnownShip("legion_xiv", false);

Should do the job. To be clear, it won't add a blueprint chip to your cargo (which would be doable with another command), but should just make it known by your faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 05, 2019, 08:04:12 AM
Also note that without an entry in default ship roles you'll never actually build the legion, AFAIK.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 05, 2019, 08:07:11 AM
Ah, that's a really good point, forgot about that - thank you!

So, yeah, would also need to edit data/world/factions/default_ship_roles.json, find the "carrierLarge" section, and add:

"legion_xiv_Elite":10,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on November 06, 2019, 05:10:01 AM
Is there a method to make a faction not receive any reputation changes from trade?

Context: I have a non-faction that only exists as the owner of a single submarket on an independent planet  and is otherwise not present as a faction. The market offers access to special ships associate with said faction, but trade with said market will still give reputations gains towards said faction, which can be somewhat confusing to users since the faction otherwise doesn't actually exist in any way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2019, 07:40:17 AM
Is there a method to make a faction not receive any reputation changes from trade?

Context: I have a non-faction that only exists as the owner of a single submarket on an independent planet  and is otherwise not present as a faction. The market offers access to special ships associate with said faction, but trade with said market will still give reputations gains towards said faction, which can be somewhat confusing to users since the faction otherwise doesn't actually exist in any way.

Hmm... looking at RepTrackerEvent, the main option would be to have submarket.isParticipatesInEconomy() return false. That would have the side effect of profitable trades there not granting XP either, though, and possibly some other (minor, I think?) effects; haven't dug through it exhaustively.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on November 06, 2019, 07:34:55 PM
And another while I'm at it:

Any way to get the offset of a ship's center from the center of its sprite via script? Have noticed that my custom afterimages are rendering well behind some ships as they have centers off mass further back. (Onslaught comes to mind)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2019, 08:25:35 PM
Probably something based on ship.getSpriteAPI().getCenterX()/getCenterY(). The Atlas is a good test ship, too, since it's suuuper pronounced there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 12:05:39 AM
What is the file that deals with annulling a commission after hostile engagement?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on November 07, 2019, 02:31:30 AM
Probably something based on ship.getSpriteAPI().getCenterX()/getCenterY(). The Atlas is a good test ship, too, since it's suuuper pronounced there.

Wasn't aware those returned the offset center's coordinates. Thanks. After a bunch of fiddling I got the whole thing working.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2019, 09:21:57 AM
What is the file that deals with annulling a commission after hostile engagement?

FactionCommissionIntel:

Code
@Override
public void advanceMission(float amount) {
float days = Global.getSector().getClock().convertToDays(amount);

RepLevel level = faction.getRelToPlayer().getLevel();
if (!level.isAtWorst(RepLevel.NEUTRAL)) {
setMissionResult(new MissionResult(-1, null));
setMissionState(MissionState.COMPLETED);
endMission();
sendUpdateIfPlayerHasIntel(missionResult, false);
} else {
makeRepChanges(null);
}
}

And then a couple of places check missionResult.payment < 0 to determine it's an annullment.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 12:27:58 PM
Hmm. Ok, so here's my dilemma:

I have a rules entry that checks whether a player has a commission with the faction and then, if they do, gives a dialogue option for commission-giving npcs to also set the player faction's portraits to that faction's portraits (immersion feature).

The first time this happens you get some rep (usually just for npc but I think if you take a commission at "welcoming" it might bump faction rep too) since its a show of loyalty, but you can always change your mind and go back to "stock" player portraits in your faction by talking to any commission-giving npc again and choosing the appropriate dialogue to change your mind. This doesn't reduce rep, but if you change your mind again and choose that faction's portraits, they are less impressed and rep isn't affected.

That's the context of what I am trying to do and it all works except:

When you lose your commission from hostile action or rep loss of any kind if will remove the dialogue option from the npc but obviously won't run the rule command to change the player faction's portraits back to stock. So it would lock the player into whatever their choice is until they can get a commission back so the dialogue shows up again. That's obviously not ideal.

Potential solutions:

1) So I could just make the "change back" dialogue always populate if your portraits are locked no matter if you have a commission or not, but that doesn't really make sense from a logical standpoint since if they were mad enough to annul your commission they certainly aren't going to keep sending you officers until you kindly ask them not to.  :P

2) Or I can figure out how to run the rule command each time the commission is annulled. The optimal solution for immersion.

Sorry it took so long to get here, but I really wanted the context to be fleshed out.

Important Part:
If I created a class that extended FactionCommissionIntel and overrides methods like createResignedCommissionResult() or endMission(InteractionDialogAPI dialog) and just added in the rule command to it I wonder if that would work.

Any potential ideas from anyone?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2019, 01:03:54 PM
Another possible solution: have a script check, maybe even every frame, whether the player had the commission but no longer does (if this is a quick check, doing it every frame is no problem) and if so <do thing>.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 01:11:57 PM
Another possible solution: have a script check, maybe even every frame, whether the player had the commission but no longer does (if this is a quick check, doing it every frame is no problem) and if so <do thing>.

It would check for a boolean assigned to player memory to be true and then check if the player has a commission. That's pretty quick right? Any examples of EveryFrameScript being implemented? I've actually never written one and I tend to avoid them whenever possible because until my last update my mod already had ample performance issues as it was haha.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2019, 01:40:15 PM
com.fs.starfarer.api.impl.campaign.TOffAlarm is probably a pretty reasonable example.

It uses an IntervalUtil to only do its checks now and again (instead of every frame), which is the approach the game generally takes to reduce performance impact. In your case, the check is so simple it's probably not worth the extra hassle of using an interval tracker.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 01:44:40 PM
Thanks Ill take a look!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 03:44:03 PM
In your case, the check is so simple it's probably not worth the extra hassle of using an interval tracker.

Well I thought about this a little more and since this is faction specific I overstated the simplicity of the check at least a little bit. It has to check for the player memory boolean for each faction since the memory flag is faction specific. So in this sense it might be O(n^2) instead of O(n). Maybe I should implement the interval tracker.

A question about that:

Code

private IntervalUtil tracker = new IntervalUtil(0.05f, 0.1f);

float days = Global.getSector().getClock().convertToDays(amount);
tracker.advance(days);

if (tracker.intervalElapsed()) {
notifyNearby();
}

... impl notifyNearby() etc


Does this mean it performs the check every in game day? And it does this by converting the passed in variable "amount" to the sector clock's definition of days? So it could, in theory, be converted to in game months or cycles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 07, 2019, 03:47:38 PM
Well I thought about this a little more and since this is faction specific I overstated the simplicity of the check at least a little bit. It has to check for the player memory boolean for each faction since the memory flag is faction specific. So in this sense it might be O(n^2) instead of O(n). Maybe I should implement the interval tracker.
Why a boolean?
If you assigned each faction an integer, you'd only have to check whether the integer has changed, rather than checking every boolean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 06:22:15 PM
Well I thought about this a little more and since this is faction specific I overstated the simplicity of the check at least a little bit. It has to check for the player memory boolean for each faction since the memory flag is faction specific. So in this sense it might be O(n^2) instead of O(n). Maybe I should implement the interval tracker.
Why a boolean?
If you assigned each faction an integer, you'd only have to check whether the integer has changed, rather than checking every boolean.

Unless I'm misunderstanding something, that would require 12 separate EveryFrameScripts which defeats the purpose. What I mean is: Since faction portraits are faction specific, I have to iterate over each faction to check for that faction's lock. Its still the same processing speed regardless if I'm checking a boolean or an int the only thing that reduces the task's workload would be having a "not" check rather than a "positive" check afaik. Please correct me if not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 07, 2019, 06:28:00 PM
What I meant was surely you don't have to check which faction the player switched too each frame, just whether the player switched.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 07:46:28 PM
What I meant was surely you don't have to check which faction the player switched too each frame, just whether the player switched.

Oh gotcha I understand now! I am being too general and not explaining the technical implementation. The player locks portraits based on the faction in question before the encounter that would trigger the EveryFrameScript even begins. So the check isn't for whether the player switched factions at all, but whether they:

A) Have locked player portraits on a specific faction. This is the boolean which is faction specific because it also serves as the flag to populate the dialogue to reverse back to all portraits. So because the rule that checks each flag offers faction specific dialogue to reverse it and relies on a unique faction-based check to fire the rule- it must inherently remain unique as well.

 - To your point, however, I see now another player variable- set as an int being set to 0 or 1- indicating a general all-purpose lock/not lock to player portraits- would very well serve the same function since you can't have more than one commission and so theoretically you couldn't have more than one faction's portraits locked to the player's when checking the EveryFrameScript. However:

B) No longer has a commission with that specific faction when the assumption is they originally did have one before.

- This is harder to get around since I would therefore have to determine the origin faction to check for an active commission with that faction. That is where the faction specific boolean comes into play. Unless I can just check for player.hasCommission() in general without determining faction (not sure honestly), I wouldn't be able to use the above all-purpose player variable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2019, 07:48:16 PM
Misc.getCommissionFactionId() != null

To check whether the player currently has a commission or not.

See also:
Misc.getCommissionFaction()
Misc.getCommissionIntel()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 07:53:12 PM
Misc.getCommissionFactionId() != null

To check whether the player currently has a commission or not.

See also:
Misc.getCommissionFaction()
Misc.getCommissionIntel()

Great! That will be optimal and remain at O(n) performance. :) Thanks to you both.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 07, 2019, 08:49:24 PM
Here is what I have. I'll admit that I'm still not 100% familiarized with how the EveryFrameScript works, but I tried to implement the interval tracker because nothing explicit- other than the EveryFrameScript extension itself and the "advance()" method that seems to be utilized by default- indicates that it will actually be run every frame. I kept it as close the the original implementation of TOffAlarm as possible for now. If I have that portion incorrect I can remove it, but if not then I may as well keep it since this script doesn't need to be ran every frame. It could be ran every 7 days and still be within believable immersion parameters.

Does this need to link to a settings entry, mod plugin or a rule to run every frame? Or do I just need to include this in the correct jar for implementation? Thank you for any help.

Code

package archeus.campaign.everyframescripts;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.util.Misc;
import archeus.rulecmd.SetPlayerPortraits;

import java.util.ArrayList;
import java.util.List;

public class CheckCommissionForPortraitLocks implements EveryFrameScript {
private IntervalUtil tracker = new IntervalUtil(0.05f, 0.1f);

public CheckCommissionForPortraitLocks() {
if (Global.getSector().getPlayerPerson().getMemory().getBoolean("$player.FactionOnlyPortraitsEnabled") && Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}

public void advance(float amount) {
float days = Global.getSector().getClock().convertToDays(amount);
tracker.advance(days);


if (tracker.intervalElapsed()) {
if (Global.getSector().getPlayerPerson().getMemory().getBoolean("$player.FactionOnlyPortraitsEnabled") && Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}
}


public void resetPlayerPortraits() {
SetPlayerPortraits portraits = new SetPlayerPortraits();

List<Misc.Token> params = new ArrayList<Misc.Token>();
Misc.Token token = new Misc.Token("all", null);
params.add(0, token);
portraits.execute(null, null, params, null);

Global.getSector().getPlayerPerson().getMemory().set("$player.FactionOnlyPortraitsEnabled", false);
}

public boolean isDone() {
return true;
}

public boolean runWhilePaused() {
return false;
}
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Green Ghost on November 08, 2019, 01:39:34 AM
Not sure if this is the right thread for it but, Is there way to affect the gender ratio for captains/administrators? Im using portrait mods with most of them being female so most of the males get the same faces, any way i can make most characters spawn as female?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SomeDegenerate on November 08, 2019, 08:01:21 AM
How does the game fetch the tooltip for an industry? I'm running into a null pointer exception whenever I mouse over my industry; it appears I've missed something to tell the game how to make the tooltip or have left some field blank somewhere.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 08, 2019, 05:31:08 PM
Does this need to link to a settings entry, mod plugin or a rule to run every frame? Or do I just need to include this in the correct jar for implementation? Thank you for any help.

Something like;

if (!Global.getSector().hasScript(CheckCommissionForPortraitLocks.class)) {
    Global.getSector().addScript(new CheckCommissionForPortraitLocks());
}

Somewhere in ModPlugin; say in onNewGameAfterEconomyLoad().


Not sure if this is the right thread for it but, Is there way to affect the gender ratio for captains/administrators? Im using portrait mods with most of them being female so most of the males get the same faces, any way i can make most characters spawn as female?

Currently hardcoded to 50/50, sorry!

How does the game fetch the tooltip for an industry? I'm running into a null pointer exception whenever I mouse over my industry; it appears I've missed something to tell the game how to make the tooltip or have left some field blank somewhere.

Thanks!

See: BaseIndustry.createTooltip(). The exception's stack trace should also be fairly helpful in figuring out exactly what went wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 08, 2019, 05:58:51 PM
Not sure if this is the right thread for it but, Is there way to affect the gender ratio for captains/administrators? Im using portrait mods with most of them being female so most of the males get the same faces, any way i can make most characters spawn as female?

Currently hardcoded to 50/50, sorry!

Related to this, would there be some way to 'hack' the strings such that I could replace all instances of he/him with she/her for a specific faction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 08, 2019, 06:09:35 PM
I don't *think* so. Some of the strings are generated using CoreRuleTokenReplacementGeneratorImpl (and so could probably be overridden), but a number aren't. The easiest thing to do would probably be to have a script that replaces male captains/fleet commanders/etc with female - say, in a custom fleet inflater, or something else depending on the circumstances.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 09, 2019, 02:25:16 AM
Does this need to link to a settings entry, mod plugin or a rule to run every frame? Or do I just need to include this in the correct jar for implementation? Thank you for any help.

Something like;

if (!Global.getSector().hasScript(CheckCommissionForPortraitLocks.class)) {
    Global.getSector().addScript(new CheckCommissionForPortraitLocks());
}

Somewhere in ModPlugin; say in onNewGameAfterEconomyLoad().

Not sure if my script isn't working or not running. It certainly isn't performing the intended behavior though. Can I leave all but the params portion of execute() null for a rule command?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 09, 2019, 07:26:28 AM
The answer depends on the rule command - and you can look at the rule command's code to see if it uses a particular parameter or not, and whether it checks for it being null.

One quick way of making sure your script is running is to add something like:
if (true) {
    throw new RuntimeException("Yep, it's running");
}

Or some such... or you could send some output to the log and tail the log; that'd be a bit less extreme :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 09, 2019, 11:53:51 AM
The answer depends on the rule command - and you can look at the rule command's code to see if it uses a particular parameter or not, and whether it checks for it being null.

One quick way of making sure your script is running is to add something like:
if (true) {
    throw new RuntimeException("Yep, it's running");
}

Or some such... or you could send some output to the log and tail the log; that'd be a bit less extreme :)

The script is running in general. I have confirmed that. It throws the exception before I even get out of the campaign load if I change the trigger to be "just not having a commission".

I have narrowed it down between last night and today to:

Code

boolean bool = Global.getSector().getPlayerPerson().getMemory().getBoolean("$FactionOnlyPortraitsEnabled")


Doesn't work. If I have a boolean in memory such as $player.FactionOnlyPortraitsEnabled set to true, how do I pull that into the script?

I know how to do it in a rule when I have access to Map<String, MemoryAPI> memoryMap from the rule itself.

*edit* I've also tried Global.getSector().getPlayerPerson().getMemory().getBoolean("$player.FactionOnlyPortraitsEnabled").

Similarly through the same control where it just checks for having a commission or not (so I know for sure it is running but won't throw an exception):
Code

Global.getSector().getPlayerPerson().getMemory().set("$FactionOnlyPortraitsEnabled", false, 0);

Also doesn't seem to populate any variables into memory.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 09, 2019, 12:20:38 PM
1) Use getMemoryWithoutUpdate() - getMemory() runs a bunch of code to populate the memory with 0-second expiring, temporary values that you don't need here. Generally like 99% of the time you want getMemoryWithoutUpdate(), not getMemory().

2) The last parameter to the .set method is the expiration; pass in -1 for no expiration. Right now it looks like you're passing in 0 which causes the value to expire immediately. The expiration value is in campaign days.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 09, 2019, 12:37:59 PM
1) Use getMemoryWithoutUpdate() - getMemory() runs a bunch of code to populate the memory with 0-second expiring, temporary values that you don't need here. Generally like 99% of the time you want getMemoryWithoutUpdate(), not getMemory().

2) The last parameter to the .set method is the expiration; pass in -1 for no expiration. Right now it looks like you're passing in 0 which causes the value to expire immediately. The expiration value is in campaign days.

Thanks I changed it to getMemoryWithoutUpdate().

Here is the full script now:

Code
package archeus.campaign.everyframescripts;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.util.Misc;
import archeus.rulecmd.SetPlayerPortraits;

import java.util.ArrayList;
import java.util.List;

public class CheckCommissionForPortraitLocks implements EveryFrameScript {
private IntervalUtil tracker = new IntervalUtil(0.05f, 0.1f);

public CheckCommissionForPortraitLocks() {
//Global.getSector().getPlayerPerson().getMemoryWithoutUpdate().getBoolean("$FactionOnlyPortraitsEnabled") &&
if (Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}

public void advance(float amount) {
float days = Global.getSector().getClock().convertToDays(amount);
tracker.advance(days);


if (tracker.intervalElapsed()) {
if (Global.getSector().getPlayerPerson().getMemoryWithoutUpdate().getBoolean("$FactionOnlyPortraitsEnabled") && Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}
}

public void resetPlayerPortraits() {
SetPlayerPortraits portraits = new SetPlayerPortraits();

List<Misc.Token> params = new ArrayList<Misc.Token>();
Misc.Token token = new Misc.Token("all", null);
params.add(0, token);
portraits.execute(null, null, params, null);

Global.getSector().getPlayerPerson().getMemoryWithoutUpdate().set("$FactionOnlyPortraitsEnabled", false, -1);

//throw new RuntimeException("Yep, it's running");
}

public boolean isDone() {
return true;
}

public boolean runWhilePaused() {
return false;
}
}

Unfortunately, even when I annul my commission it doesn't populate anything into memory. When I add the memory check and the runtime exception that have been commented out, the runtime exception never fires because it never finds the boolean in memory. Even though I've confirmed its there:

Spoiler
(https://i.imgur.com/KrsUjIm.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 09, 2019, 03:39:03 PM
Is there a way I can make a ship retreat via code? Like if they reach a certain CR or Hull point value, I could override their existing order?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on November 10, 2019, 05:29:12 AM
Is flux generation from engaging wings modifiable or is it harcoded? I'm wondering if I could make a fast carrier that gets the zero flux speed bonus even with the engage order on. I couldn't find any reference to this upkeep in the api.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 10, 2019, 08:28:24 AM
@Morrokain: Are you certain your script is being run? I'm not certain exactly how it functions, but I'm pretty sure returning true for isDone() tells the engine that it's not necessary to run your script anymore.

Is there a way I can make a ship retreat via code? Like if they reach a certain CR or Hull point value, I could override their existing order?
There sure is:
Code: java
            boolean retreatDirectly = true;
            ship.setRetreating(true, retreatDirectly);

Is flux generation from engaging wings modifiable or is it harcoded? I'm wondering if I could make a fast carrier that gets the zero flux speed bonus even with the engage order on. I couldn't find any reference to this upkeep in the api.
I don't see anything for that either, but it might be possible to get the desired behavior by adjusting stats.getZeroFluxMinimumFluxLevel()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 10, 2019, 10:00:13 AM
@Morrokain: Are you certain your script is being run? I'm not certain exactly how it functions, but I'm pretty sure returning true for isDone() tells the engine that it's not necessary to run your script anymore.

Oh, I missed that, but, yeah, the script as-ise would get removed either immediately or after running for one frame.

Is flux generation from engaging wings modifiable or is it harcoded? I'm wondering if I could make a fast carrier that gets the zero flux speed bonus even with the engage order on. I couldn't find any reference to this upkeep in the api.
I don't see anything for that either, but it might be possible to get the desired behavior by adjusting stats.getZeroFluxMinimumFluxLevel()

It's actually set to a (Helmsmanship.ZERO_FLUX_LEVEL * 0.01) fraction of the ship's max flux, plus triple the dissipation rate. So setting the getZeroFluxMinimumFluxLevel to something reliably above that would do the job, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on November 10, 2019, 10:07:22 AM
Where can i find what determines a star systems location?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 10, 2019, 10:25:14 AM
data/campaign/starmap.json

Alternatively, you can do:
system.getLocation().set(x, y);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 10, 2019, 11:01:27 AM
@Morrokain: Are you certain your script is being run? I'm not certain exactly how it functions, but I'm pretty sure returning true for isDone() tells the engine that it's not necessary to run your script anymore.

Oh, I missed that, but, yeah, the script as-ise would get removed either immediately or after running for one frame.

Oh! Ok got it. Can I just remove that whole portion? Or should I return false?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on November 10, 2019, 11:01:56 AM
data/campaign/starmap.json

Alternatively, you can do:
system.getLocation().set(x, y);

cool thanks! so would i be able to just slap it in my mod and type in my custom system or would there be another step?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Salv on November 10, 2019, 11:42:14 AM
It's actually set to a (Helmsmanship.ZERO_FLUX_LEVEL * 0.01) fraction of the ship's max flux, plus triple the dissipation rate. So setting the getZeroFluxMinimumFluxLevel to something reliably above that would do the job, yeah.

I considered doing something like this, but I suppose it would also affect shields and weapons when fighters are regrouped. Is there a particular flag or something I could use that checks whether the carrier has the engage order on? Maybe I could try making an EveryFrame script that applies and unapplies a getZeroFluxMinimumFluxLevel modifier.

Edit: One more thing. The upkeep you mentioned is per wing or constant regardless of the number of wings on the ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 10, 2019, 12:01:06 PM
I set the isDone() return to false, but still no luck actually populating anything to memory. The RuntimeException does fire if I take away the memory check (like before) but if I comment that out and just leave the portion that is supposed to attach a variable to the player's memory it never shows up.

I even directly referenced TutorialMissionEvent and set the PersonAPI to protected like it is there.

Are there any examples I can reference where a memory variable is attached to the player rather than an entity PersonAPI?

I know it at least gets to this code:

Code

player = Global.getSector().getPlayerPerson();
        player.getMemoryWithoutUpdate().set("$PortraitsEnabled", false);


But that particular code doesn't seem to work while under EveryFrameScript.

I don't understand what I could be doing wrong. :( It seems rather straightforward on the surface.

Full script:
Code

package archeus.campaign.everyframescripts;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.util.Misc;
import archeus.rulecmd.SetPlayerPortraits;

import java.util.ArrayList;
import java.util.List;

public class CheckCommissionForPortraitLocks implements EveryFrameScript {
private IntervalUtil tracker = new IntervalUtil(0.05f, 0.1f);

    protected PersonAPI player;

public CheckCommissionForPortraitLocks() {
//player.getMemoryWithoutUpdate().is("$FactionOnlyPortraitsEnabled", true) &&
        player = Global.getSector().getPlayerPerson();
if (Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}

public void advance(float amount) {
float days = Global.getSector().getClock().convertToDays(amount);
tracker.advance(days);
player = Global.getSector().getPlayerPerson();

//Global.getSector().getPlayerPerson().getMemoryWithoutUpdate().getBoolean("$player.FactionOnlyPortraitsEnabled")
if (tracker.intervalElapsed()) {
if (player.getMemoryWithoutUpdate().is("$FactionOnlyPortraitsEnabled", false) && Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}
}

public void resetPlayerPortraits() {
        SetPlayerPortraits portraits = new SetPlayerPortraits();

List<Misc.Token> params = new ArrayList<Misc.Token>();
Misc.Token token = new Misc.Token("all", null);
params.add(0, token);
portraits.execute(null, null, params, null);

        player = Global.getSector().getPlayerPerson();
        player.getMemoryWithoutUpdate().set("$PortraitsEnabled", false);

        //throw new RuntimeException("Yep, it's running");
}

public boolean isDone() {
return false;
}

public boolean runWhilePaused() {
return false;
}
}


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 10, 2019, 12:07:10 PM
Return false, yeah. That method is part of the EveryFrameScript interface so you have to implement it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 10, 2019, 01:49:12 PM
There sure is:
Code: java
            boolean retreatDirectly = true;
            ship.setRetreating(true, retreatDirectly);
I tried this code, but it doesn't seem to work, either in simulation or a real battle... I posted a new thread for this problem here with a bit more detail on what's going on:

https://fractalsoftworks.com/forum/index.php?topic=17206.0 (https://fractalsoftworks.com/forum/index.php?topic=17206.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaykat on November 11, 2019, 01:35:59 PM
How do I change the description of some ships/weapons in a mod? I know I gotta change the descriptions.csv and when I copied my changes into the folder it worked fine but then it reverted itself the next time I played .-. is there something else I gotta mess with to make it permanent?

Edit: Oh, it's not mine btw, I just wanna make a few corrections to some spelling in another
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2019, 01:43:27 PM
It shouldn't revert itself if it's just csv changes, that's strange. Unless, say, you update the mod, or you had the file open in multiple places and somehow ended up saving an unmodified version later, or something like that.

What you're doing sounds like it should work, so I'd give it another shot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaykat on November 12, 2019, 12:53:06 AM
...somehow ended up saving an unmodified version later, or something like that.

omg of course that is exactly what i freaking did too >_<

lol thanks for the answer anyway!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 12, 2019, 06:29:39 AM
Is it possible to write custom values for damage, DPS, etc in a weapon's codex? For example, if a gun added a bunch of projectiles through a script, can I get the stat block to represent that?

Also, is there a way to find out how close a weapon is to finishing its next reload? For example, if I wanted to trigger something when a weapon is 50% finished reloading the shot it's reloading.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 12, 2019, 07:59:20 AM
omg of course that is exactly what i freaking did too >_<

Happens to the best of us :)

Is it possible to write custom values for damage, DPS, etc in a weapon's codex? For example, if a gun added a bunch of projectiles through a script, can I get the stat block to represent that?

Not stat blocks, specifically, but you can add custom text with highlights, like vanilla does for some weapons (Devastator, Sabot, Ion Cannon, etc). See

customPrimary   customPrimaryHL   customAncillary   customAncillaryHL

In weapon_data.csv. The *ancillary ones are for text after the second block of data.

Also, is there a way to find out how close a weapon is to finishing its next reload? For example, if I wanted to trigger something when a weapon is 50% finished reloading the shot it's reloading.

Hmm - WeaponAPI.getCooldown()/getCooldownRemaining()? Or are those insufficient?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on November 12, 2019, 08:38:20 AM
I've got a custom submarket, extending MilitarySubmarketPlugin, that's mostly working, but it seems to update its ships and weapons stock every time I reopen the market, instead of the default once a month. I think the problem is that okToUpdateShipsAndWeapons() from BaseSubmarketPlugin is always returning true, but I don't know why. What kind of snag am I running into here?

Abbreviated:
Spoiler
Code
[... omitted ...]

public class prv_labmarket extends MilitarySubmarketPlugin {

[... omitted ...]

@Override
public void updateCargoPrePlayerInteraction() {
float seconds = Global.getSector().getClock().convertToSeconds(sinceLastCargoUpdate);
addAndRemoveStockpiledResources(seconds, false, true, true);
sinceLastCargoUpdate = 0f;

if (okToUpdateShipsAndWeapons()) {
sinceSWUpdate = 0f;

WeightedRandomPicker<String> factionPicker = new WeightedRandomPicker<String>();

String owner = market.getFactionId();
List<FactionAPI> factions = Global.getSector().getAllFactions();
for(FactionAPI faction : factions){
if(faction.getRelationshipLevel(owner).isAtWorst(ALLY_THRESHOLD)){
factionPicker.add(faction.getId(),10f);
}
}
if (factionPicker.isEmpty()) {
factionPicker.add(owner);
}

pruneWeapons(0f);
addWeaponsMintier(WEAPON_COUNT_NATIVE, Math.round(WEAPON_COUNT_NATIVE * 1.5f) , 3,2, submarket.getFaction().getId());
addWeaponsMintier(WEAPON_COUNT_ALLY, Math.round(WEAPON_COUNT_ALLY * 1.5f) , 3,2, factionPicker);
addFightersMintier(WING_COUNT, Math.round(WING_COUNT * 1.5f), 3,2, market.getFactionId());
addHullModsMintier(4, 2,itemGenRandom.nextInt(HULLMOD_COUNT));

if(Math.random() < GOODYCHANCE){
addGoodies(0,3);
}

float stability = market.getStabilityValue();
float sMult = Math.max(0.1f, stability / 10f);
getCargo().getMothballedShips().clear();
addShips(submarket.getFaction().getId(),
  50f * sMult, // combat
  15f * sMult, // freighter
  10f * sMult, // tanker
  20f * sMult, // transport
  10f * sMult, // liner
  10f * sMult, // utilityPts
  null, // qualityOverride
  sMult, // qualityMod
  null,
  null);
}

getCargo().sort();
}

[... omitted ...]

}
[close]

Full class:
Spoiler
Code
package campaign.submarkets;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.impl.campaign.fleets.DefaultFleetInflater;
import com.fs.starfarer.api.impl.campaign.ids.Items;
import com.fs.starfarer.api.impl.campaign.submarkets.MilitarySubmarketPlugin;
import com.fs.starfarer.api.loading.FighterWingSpecAPI;
import com.fs.starfarer.api.loading.HullModSpecAPI;
import com.fs.starfarer.api.loading.WeaponSpecAPI;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;

import java.util.List;

public class prv_labmarket extends MilitarySubmarketPlugin {

private static final int WEAPON_COUNT_NATIVE = 3; // n to 1.5 n
private static final int WEAPON_COUNT_ALLY = 3; // n to 1.5 n
private static final int WING_COUNT = 3; // n to 1.5 n
private static final int HULLMOD_COUNT = 3; // 0 to n-1
private static final float GOODYCHANCE = 0.33f;
private static final RepLevel ALLY_THRESHOLD = RepLevel.WELCOMING; // +25

@Override
public String getName() {
return Misc.ucFirst(submarket.getFaction().getPersonNamePrefix()) + "\n" + "R&D";
}

@Override
protected boolean requiresCommission(RepLevel req) {
return false;
}

@Override
public void updateCargoPrePlayerInteraction() {
float seconds = Global.getSector().getClock().convertToSeconds(sinceLastCargoUpdate);
addAndRemoveStockpiledResources(seconds, false, true, true);
sinceLastCargoUpdate = 0f;

if (okToUpdateShipsAndWeapons()) {
sinceSWUpdate = 0f;

WeightedRandomPicker<String> factionPicker = new WeightedRandomPicker<String>();

String owner = market.getFactionId();
List<FactionAPI> factions = Global.getSector().getAllFactions();
for(FactionAPI faction : factions){
if(faction.getRelationshipLevel(owner).isAtWorst(ALLY_THRESHOLD)){
factionPicker.add(faction.getId(),10f);
}
}
if (factionPicker.isEmpty()) {
factionPicker.add(owner);
}

pruneWeapons(0f);
addWeaponsMintier(WEAPON_COUNT_NATIVE, Math.round(WEAPON_COUNT_NATIVE * 1.5f) , 3,2, submarket.getFaction().getId());
addWeaponsMintier(WEAPON_COUNT_ALLY, Math.round(WEAPON_COUNT_ALLY * 1.5f) , 3,2, factionPicker);
addFightersMintier(WING_COUNT, Math.round(WING_COUNT * 1.5f), 3,2, market.getFactionId());
addHullModsMintier(4, 2,itemGenRandom.nextInt(HULLMOD_COUNT));

if(Math.random() < GOODYCHANCE){
addGoodies(0,3);
}

float stability = market.getStabilityValue();
float sMult = Math.max(0.1f, stability / 10f);
getCargo().getMothballedShips().clear();
addShips(submarket.getFaction().getId(),
  50f * sMult, // combat
  15f * sMult, // freighter
  10f * sMult, // tanker
  20f * sMult, // transport
  10f * sMult, // liner
  10f * sMult, // utilityPts
  null, // qualityOverride
  sMult, // qualityMod
  null,
  null);
}

getCargo().sort();
}

protected void addGoodies(int min, int max){
int num = min + itemGenRandom.nextInt(max - min + 1);
WeightedRandomPicker<WeaponSpecAPI> picker = new WeightedRandomPicker<WeaponSpecAPI>(itemGenRandom);
for (String id : Global.getSector().getAllWeaponIds()) {
WeaponSpecAPI spec = Global.getSettings().getWeaponSpec(id);
float p = 1f;
if (spec.getTags().contains("prv_lab_bp")) {
picker.add(spec, p);
}
}

for (int i = 0; i < num && !picker.isEmpty(); i++) {
WeaponSpecAPI spec = picker.pick();

int count = 1;

CargoAPI cargo = submarket.getCargo();
cargo.addWeapons(spec.getWeaponId(), count);
}
}

protected void addWeaponsMintier(int min, int max, int maxTier, int minTier, WeightedRandomPicker<String> factionPicker) {
int num = min + itemGenRandom.nextInt(max - min + 1);
for (int i = 0; i < num; i++) {
String factionId = factionPicker.pick();
addWeaponsMintier(1, 1, maxTier, minTier, factionId);
}

}

protected void addWeaponsMintier(int min, int max, int maxTier, int minTier, String factionId) {
if (factionId == null) factionId = market.getFactionId();

int num = min + itemGenRandom.nextInt(max - min + 1);
float quality = Misc.getShipQuality(market, factionId);

FactionAPI faction = Global.getSector().getFaction(factionId);

WeightedRandomPicker<WeaponSpecAPI> picker = new WeightedRandomPicker<WeaponSpecAPI>(itemGenRandom);
for (String id : faction.getKnownWeapons()) {
WeaponSpecAPI spec = Global.getSettings().getWeaponSpec(id);
if (spec.getTier() > maxTier) continue;
if (spec.getTier() < minTier) continue;

float p = DefaultFleetInflater.getTierProbability(spec.getTier(), quality);
p = 1f;
picker.add(spec, p);
}

for (int i = 0; i < num && !picker.isEmpty(); i++) {
WeaponSpecAPI spec = picker.pick();

int count = 2;
switch (spec.getSize()) {
case LARGE: count = 2; break;
case MEDIUM: count = 4; break;
case SMALL: count = 8; break;
}

count = count + itemGenRandom.nextInt(count + 1) - count/2;

CargoAPI cargo = submarket.getCargo();
cargo.addWeapons(spec.getWeaponId(), count);
}
}

protected void addFightersMintier(int min, int max, int maxTier, int minTier, String factionId) {
if (factionId == null) factionId = market.getFactionId();

int num = min + itemGenRandom.nextInt(max - min + 1);
float quality = Misc.getShipQuality(market, factionId);

FactionAPI faction = Global.getSector().getFaction(factionId);

WeightedRandomPicker<FighterWingSpecAPI> picker = new WeightedRandomPicker<FighterWingSpecAPI>(itemGenRandom);
for (String id : faction.getKnownFighters()) {
FighterWingSpecAPI spec = Global.getSettings().getFighterWingSpec(id);
if (spec.getTier() > maxTier) continue;
if (spec.getTier() < minTier) continue;

float p = DefaultFleetInflater.getTierProbability(spec.getTier(), quality);
picker.add(spec, p);
}

for (int i = 0; i < num && !picker.isEmpty(); i++) {
FighterWingSpecAPI spec = picker.pick();

int count = 2;
switch (spec.getRole()) {
case ASSAULT: count = 2; break;
case BOMBER: count = 2; break;
case INTERCEPTOR: count = 4; break;
case FIGHTER: count = 3; break;
case SUPPORT: count = 2; break;
}

count = count + itemGenRandom.nextInt(count + 1) - count/2;

CargoAPI cargo = submarket.getCargo();
cargo.addItems(CargoAPI.CargoItemType.FIGHTER_CHIP, spec.getId(), count);
}
}

protected void addHullModsMintier(int maxTier, int minTier, int num) {

CargoAPI cargo = getCargo();
for (CargoStackAPI stack : cargo.getStacksCopy()) {
//if (stack.isModSpecStack()) {
if (stack.isSpecialStack() && stack.getSpecialDataIfSpecial().getId().equals(Items.MODSPEC)){
cargo.removeStack(stack);
}
}

WeightedRandomPicker<HullModSpecAPI> picker = new WeightedRandomPicker<HullModSpecAPI>(itemGenRandom);
for (String id : submarket.getFaction().getKnownHullMods()) {
//if (Global.getSector().getCharacterData().knowsHullMod(id)) continue;
HullModSpecAPI spec = Global.getSettings().getHullModSpec(id);
if (spec.isHidden()) continue;
if (spec.isAlwaysUnlocked()) continue;
if (spec.getTier() > maxTier) continue;
if (spec.getTier() < minTier) continue;
picker.add(spec, spec.getRarity());
}

for (int i = 0; i < num; i++) {
HullModSpecAPI pick = picker.pickAndRemove();
if (pick == null) continue;

String id = pick.getId();
if (cargoAlreadyHasMod(id)) continue;

if (Global.getSector().getPlayerFaction().knowsHullMod(id)) continue;

//cargo.addItems(CargoItemType.MOD_SPEC, id, 1);

cargo.addItems(CargoAPI.CargoItemType.SPECIAL, new SpecialItemData(Items.MODSPEC, id), 1);
}

}
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 12, 2019, 09:01:02 AM
I'm not actually seeing anything wrong in your code, looks good to me, including setting sinceSWUpdate = 0f; when you actually do update. Are you running in an IDE? If so I'd suggest trying to run it with a debugger if possible, or at least add some logging. Just looking at the code, nothing jumps out as a problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 12, 2019, 09:06:07 AM
Not stat blocks, specifically, but you can add custom text with highlights, like vanilla does for some weapons (Devastator, Sabot, Ion Cannon, etc).
Okay, cool.

Quote
Hmm - WeaponAPI.getCooldown()/getCooldownRemaining()? Or are those insufficient?
Those return the cooldown of the weapon (chargedown column in .csv), not the reload progress of the ammo. Come to think of it, though, I can time it manually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 12, 2019, 09:20:44 AM
Ahh, apologies, I didn't catch that was what you meant. Yeah, currently that's not directly exposed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on November 12, 2019, 10:59:25 AM
I'm not actually seeing anything wrong in your code, looks good to me, including setting sinceSWUpdate = 0f; when you actually do update. Are you running in an IDE? If so I'd suggest trying to run it with a debugger if possible, or at least add some logging. Just looking at the code, nothing jumps out as a problem.

I figured it out - this is a problem with how I'm applying the industry that adds the submarket. Every time I was entering the screen the industry was getting Unapplied and then Applied again, refreshing the stock. At least, I think that's what's going on, since commenting out the unapply code fixed the refreshing.

Speaking of submarket-adding industries, does anyone know of any intercompatability problems associated with them? Right now I can have four+storage on a market, (Open, Lab, Military, Black), which seems to work fine but I'm wondering how that interacts with other mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 12, 2019, 12:42:47 PM
I got a problem with my custom fighter AI for my drones, i only noticed recently that ship.beginLandingAnimation(carrier); does not remove the ship (fighter) and i have to call the land() manually
I know how to get the list of bays from the carrier
Code
List<FighterLaunchBayAPI> bays = carrier.getLaunchBaysCopy();
, but how do i get the right bay for the fighter, do i just pick a random one? Also how does it work with ships that get converted hangars and do not have bays naturally?

-edit-
Found it:
Code
ship.getWing().getSource().getLandingLocation(ship)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on November 12, 2019, 12:52:33 PM
I have a question of mod/rules compatibility - Is it sensible for me to replace the default vanilla "marketOptionCommDir" rule with an identical rule that contains an additional FireAll for my own rule/script, as a means of integrating a simple mod? This works fine with Nex, for reference.

Simply put I am adding an NPC based on current colony industry, and simply executing a couple of boolean checks every time the player opens the Comms Directory seems to be the least technical/simplest way of managing whether the NPC should be present. 

I do not want to try and program additional behaviour for when you manually build industry or remove it, lose a market etc, as I assume this would open up more compatibility problems and be difficult for my tiny java brain.

Is this idea bonkers? or is it possible to have a new script slot in and execute with the 'OpenCommDirectory' script without replacing anything?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 12, 2019, 02:55:36 PM
How do i get the Peak Performance duration of a ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 12, 2019, 03:41:37 PM
How can I affect the likelihood that items with a certain tag will show up in a given market, without changing their availability to the faction that owns it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 12, 2019, 03:42:13 PM
How can I check if the current ship is being piloted by the player?

How do i get the Peak Performance duration of a ship?
You can get it via getPeakCRDuration() from a ship's mutable stats:

e.g.
   
Code
 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
       stats.getPeakCRDuration();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 12, 2019, 03:48:36 PM
How can I check if the current ship is being piloted by the player?

How do i get the Peak Performance duration of a ship?
You can get it via getPeakCRDuration() from a ship's mutable stats:

e.g.
   
Code
 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
       stats.getPeakCRDuration();
How do i convert the StatBonus to float?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 12, 2019, 03:54:34 PM
How do i convert the StatBonus to float?
I'm not sure if there's a function that calculates the full stat bonus but all of these functions return float

Code
        stats.getPeakCRDuration().getFlatBonus(source).value;
        stats.getPeakCRDuration().getMultBonus(source).value;
        stats.getPeakCRDuration().getPercentBonus(source).value;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 12, 2019, 07:21:22 PM
I figured it out - this is a problem with how I'm applying the industry that adds the submarket. Every time I was entering the screen the industry was getting Unapplied and then Applied again, refreshing the stock. At least, I think that's what's going on, since commenting out the unapply code fixed the refreshing.

Ahh yes, the Open Market added by Commerce has/had the same problem. I don't remember if it's fixed in 0.9.1a or just in my dev build, though, but, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 13, 2019, 10:03:59 PM
How can I check if the current ship is being piloted by the player?
Pretty sure you can use ship.getShipAI() == null for this
http://fractalsoftworks.com/forum/index.php?topic=5061.msg269533#msg269533

How do i get the Peak Performance duration of a ship?
I think this might be a simpler and potentially more reliable way to do it:
Code
ship.getMutableStats().getPeakCRDuration().computeEffective(ship.getHullSpec().getNoCRLossTime())
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 14, 2019, 04:29:27 AM
What's the best way to implement a shipsystem taking a chunk (or rapidly increasing loss of) CR?

MutableShipStats has a few entires I tried playing with, but no actual CR loss seems to occur.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Innominandum on November 14, 2019, 09:49:43 AM
Where would one go, if one wanted to have a look under the hood in regards to AI combat profiles, like the standard ship combat behaviour and the Officers traits overriding them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 14, 2019, 10:19:02 AM
Where would one go, if one wanted to have a look under the hood in regards to AI combat profiles, like the standard ship combat behaviour and the Officers traits overriding them?

It's all in core code, so unfortunately there isn't anything exposed you could really look at.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 14, 2019, 03:52:01 PM
What's the best way to implement a shipsystem taking a chunk (or rapidly increasing loss of) CR?

MutableShipStats has a few entires I tried playing with, but no actual CR loss seems to occur.
Without knowing what you're trying to do it's hard to guess what the best way to implement it is, but as a last resort you can always brute-force it with ship.setCurrentCR()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 14, 2019, 06:55:05 PM
I am not sure if i already asked this before, but is there a way to tell nearby enemy AI "hey i gonna do something dangerous, stay away from me"? I wanna make a self-destruct system. But want to make sure the AI can react to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 15, 2019, 04:52:24 AM
What's the best way to implement a shipsystem taking a chunk (or rapidly increasing loss of) CR?

MutableShipStats has a few entires I tried playing with, but no actual CR loss seems to occur.
Without knowing what you're trying to do it's hard to guess what the best way to implement it is, but as a last resort you can always brute-force it with ship.setCurrentCR()

Either ship taking a big CR hit on shipsystem activation OR a ship having a greatly increased CR drain while it's active.I tired the second one, but it doesn't look like CR is decreasing at all. Or does it only affect a ship after Peak time?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 15, 2019, 05:27:46 AM
What's the best way to implement a shipsystem taking a chunk (or rapidly increasing loss of) CR?

MutableShipStats has a few entires I tried playing with, but no actual CR loss seems to occur.
Without knowing what you're trying to do it's hard to guess what the best way to implement it is, but as a last resort you can always brute-force it with ship.setCurrentCR()

Either ship taking a big CR hit on shipsystem activation OR a ship having a greatly increased CR drain while it's active.I tired the second one, but it doesn't look like CR is decreasing at all. Or does it only affect a ship after Peak time?

Check the code for my Wurgandal Tyrant's Maw, I do CR reduction in there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 15, 2019, 09:49:21 AM
I am not sure if i already asked this before, but is there a way to tell nearby enemy AI "hey i gonna do something dangerous, stay away from me"? I wanna make a self-destruct system. But want to make sure the AI can react to it.

Hmm. The only thing that comes to mind is deploying a fake enemy fleet member, keeping its position on your ship, and putting an "Avoid" order on it. Might have some side effects, not really sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 15, 2019, 12:29:36 PM
hey, API question: in http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/CombatFleetManagerAPI.html

 getTaskManager(boolean ally)

what does that boolean flag do? I'm trying to debug the Edith escort script

[edit] Aaaand as soon as I post I remember to search here and not just google. let me just leave this here...
I think you want:
combatFleetManagerAPI.getTaskManager(false)

Passing true there gives you the task managed for allied forces (for an ongoing battle), not the player's.


[More edits!] Ah darn, but now I'm confused again. According to the above, the following line:

Code
engine.getFleetManager(FleetSide.PLAYER).getTaskManager(true).setPreventFullRetreat(true);

Would only set the allied fleet to the players to no retreat, but the players could still retreat? Because that is not the behavior I see in mission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 15, 2019, 02:34:20 PM
That's correct, yeah. At least, unless I'm missing something obvious. So if that's not working, that seems like it might be a bug.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 15, 2019, 10:16:14 PM
Thanks! The bit that I was working on is working now, even though I'm still not 100% on that boolean.

The code snippet I posted seems to be working for the player ships, but there could also be something else going on; I didn't do a complete search.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on November 16, 2019, 05:14:55 AM
So I've brought this up before, but after messing with the code on multiple occasions it seems that having a modified time mult on a ship is still somehow blocking the shield deploy command of both the fortress shield AI and any manually coded such commands in the ship system code. So, unless I missed something at this point, I think this might be a vanilla bug of sorts. I even tried suspending the time mult during system activation, but clearly the mult remains active on the first frame of the system activation, resulting in the code not executing properly and the system shutting off immediately as there's no shield.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2019, 12:04:03 PM
Dug into this, and, right, you're right! Fixed this on my end. (It's... complicated. The fast-time stuff has some, ah, interesting code.)

As far as what you might do, hmm. The only thing that comes to mind is using ship.getShield().toggleOn() somewhere - that should work, fast-time or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 16, 2019, 03:36:16 PM
so I'm trying to set up one of the industrial structures I'd created with a variable upgrade path, basically so that when the player chooses to do an upgrade they can select which particular structure they want to upgrade to. checking the vanilla industries this looks like it's handled by the tags in the industries.csv, specifically parent_item and sub_item, and was wondering if anyone had some insight in how to get these to work; the best I've managed so far is to get it not crash when trying to do an upgrade (the selected structure literally upgrades into itself.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2019, 05:12:14 PM
These only work for the initial industry selection, i.e. how for orbital stations you pick which kind to build. It's not set up to handle multiple possible upgrades to choose from; among other things, there's no UI for that.

Probably the closest thing you could do is have multiple installable items and have the industry change behavior depending on which you install. I think you should be able to set it up - using an InstallableIndustryItemPlugin - so that the item is consumed when used, and that once you do it once, the options to install/uninstall an item don't show up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on November 17, 2019, 04:46:34 AM
Dug into this, and, right, you're right! Fixed this on my end. (It's... complicated. The fast-time stuff has some, ah, interesting code.)

As far as what you might do, hmm. The only thing that comes to mind is using ship.getShield().toggleOn() somewhere - that should work, fast-time or not.

Heh. Leave it to a modder like me who uses the fast time stuff more than they should to find the bugs with those. Anyhow, that method seems to work so hurray and thanks o7
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 17, 2019, 09:41:53 AM
Glad that did it, and thanks for bringing it up again!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 18, 2019, 02:50:44 PM
Well... I seem to have messed something up considerably haha.

This thread has the reported error and I'm not seeing this in my campaign, so I'm wondering at the details of how this could even happen?:

https://fractalsoftworks.com/forum/index.php?topic=17278.0 (https://fractalsoftworks.com/forum/index.php?topic=17278.0)

Brief summary:

It was fine until I noticed that some of the planets were broken. The supply and demand column was completely empty in the colony info, so it sold no resources and had very low stability due to food shortages. There was also no administrator or people on the comm list. This affected Askonia, Maysura, Cannan, and Corvus, but the new faction planets were completely unaffected.

The glitch affected port Tse, mairaath, lost astropolis, volturn, askonia, crour, Asher, gilled, umbra, nortia, jangle, and asharu. Sorry about the confusion over which markets were affected.

My market implementation:

95% - JSON files under:

"data\campaign\econ"

Available here:
https://www.dropbox.com/sh/ekmxcujb6lhg6v1/AABCAh9aTuTtMjB7w22gvxZla?dl=0 (https://www.dropbox.com/sh/ekmxcujb6lhg6v1/AABCAh9aTuTtMjB7w22gvxZla?dl=0)

5% Java in the jar for a market in Eldrus that acts very similar to Derinkyu station in that it is linked to the TutorialEvent.

Code
        SectorEntityToken eldrus = system.getEntityById("eldrus");

        eldrus.getMarket().addIndustry("spaceport");
        eldrus.getMarket().addIndustry("mining");
        eldrus.getMarket().addIndustry("grounddefenses");
        eldrus.getMarket().addIndustry("patrolhq");
        eldrus.getMarket().addIndustry("waystation");

        PersonAPI stationCommander = Global.getSector().getFaction("archean_order").createRandomPerson();
        stationCommander.setPostId("baseCommander");
        stationCommander.setRankId("groundGeneral");
        eldrus.getMarket().getCommDirectory().addPerson(stationCommander);
        eldrus.setActivePerson(stationCommander);

        PersonAPI portmaster = Global.getSector().getFaction("archean_order").createRandomPerson();
        portmaster.setPostId("portmaster");
        portmaster.setRankId("groundCaptain");
        eldrus.getMarket().getCommDirectory().addPerson(portmaster);

        PersonAPI supplyManager = Global.getSector().getFaction("archean_order").createRandomPerson();
        supplyManager.setPostId("supplyOfficer");
        supplyManager.setRankId("groundLieutenant");
        eldrus.getMarket().getCommDirectory().addPerson(supplyManager);

        PersonAPI administrator = Global.getSector().getFaction("archean_order").createRandomPerson();
        administrator.setPostId("administrator");
        administrator.setRankId("citizen");
        eldrus.getMarket().getCommDirectory().addPerson(administrator);

        Global.getSector().getEconomy().addMarket(eldrus.getMarket(), false);

With these replaced:

Code
         "data\\campaign\\econ/aztlan.json",
         "data\\campaign\\econ/arcadia.json",
         "data\\campaign\\econ/askonia.json",
         "data\\campaign\\econ/eos.json",
         "data\\campaign\\econ/isirah.json",
         "data\\campaign\\econ/canaan.json",
         "data\\campaign\\econ/algebbar.json",
         "data\\campaign\\econ/kumarikandam.json",
         "data\\campaign\\econ/magec.json",
         "data\\campaign\\econ/naraka.json",
         "data\\campaign\\econ/valhalla.json",
         "data\\campaign\\econ/samarra.json",
         "data\\campaign\\econ/mayasura.json",
         "data\\campaign\\econ/thule.json",
         "data\\campaign\\econ/tyle.json",
         "data\\campaign\\econ/yma.json",
         "data\\campaign\\econ/zagan.json",
         "data\\campaign\\econ/corvus.json",

Any nudges in the right direction greatly appreciated! I'm looking into this more later tonight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 18, 2019, 08:25:36 PM
Is there a way to force the AI to just set a weapon (or weapon group) to autofire and not operate it manually? Like a weapon tag, maybe? Setting ships to autopilot makes the AI take over the autofire stuff and does a bad job of manually controlling the weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 19, 2019, 08:17:02 AM
@Morrokain: are all the .json files in your mod_info.json "replace" section? "markets" is an array so if not you'll end up with those being appended to the core files and who even knows what'll happen then.

Is there a way to force the AI to just set a weapon (or weapon group) to autofire and not operate it manually?

You could have a script turn autofire on for that group every frame. It may flicker off for a frame when the AI decides to turn it off but functionally this should be about the same as it being permanently on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 19, 2019, 10:09:55 AM
@Morrokain: are all the .json files in your mod_info.json "replace" section? "markets" is an array so if not you'll end up with those being appended to the core files and who even knows what'll happen then.

Yes they are replaced. See the bottom of my post for the code snippet of the replace array in case I messed something up there.

I had originally thought it was another one of those operating-system-specific deliminator issues like from .9 but the really weird thing is that it only affects some markets according to the report rather than all markets defined in the file. You'd think it would be universal to the markets if it wasn't being replaced and all of them were being appended.

It works fine for me though so I'm kind of at a loss as to how to proceed with troubleshooting.  :-\

I'll try a few more things to reproduce it a bit later.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Armithaig on November 19, 2019, 10:24:52 AM
Blocking ship fire in a ShipSystemStatsScript.apply() appears ineffectual whichever way'm cutting it except the deprecated USE_SELECTED_GROUP command.
Assume'd be because the scripts're advanced after weapons are, but might be out on a bicycle tourney.

Idea was to both dodge the screen clipping status effect list ya get from blocking most ship control (Maybe 3-state enums in csv instead of bool, e.g. DEFAULT|DISABLE|HIDDEN) and have weapons fire only blocked during a specific portion.

*cough* pardon the russian
Code
class SomeSystemStats : BaseShipSystemScript() {
    override fun apply(stats: MutableShipStatsAPI, id: String, state: State, effect: Float) {
        ship.blockCommandForOneFrame(ShipCommand.FIRE)
        ship.isHoldFireOneFrame = true
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 19, 2019, 10:28:21 AM
Yes they are replaced. See the bottom of my post for the code snippet of the replace array in case I messed something up there.

I had originally thought it was another one of those operating-system-specific deliminator issues like from .9 but the really weird thing is that it only affects some markets according to the report rather than all markets defined in the file. You'd think it would be universal to the markets if it wasn't being replaced and all of them were being appended.

It works fine for me though so I'm kind of at a loss as to how to proceed with troubleshooting.  :-\

I'll try a few more things to reproduce it a bit later.

Ah, my bad, missed that. ... really not sure, then, sorry!

Blocking ship fire in a ShipSystemStatsScript.apply() appears ineffectual whichever way'm cutting it except the deprecated USE_SELECTED_GROUP command.
Assume'd be because the scripts're advanced after weapons are, but might be out on a bicycle tourney.

Idea was to both dodge the screen clipping status effect list ya get from blocking most ship control (Maybe 3-state enums in csv instead of bool, e.g. DEFAULT|DISABLE|HIDDEN) and have weapons fire only blocked during a specific portion.

*cough* pardon the russian
Code
class SomeSystemStats : BaseShipSystemScript() {
    override fun apply(stats: MutableShipStatsAPI, id: String, state: State, effect: Float) {
        ship.blockCommandForOneFrame(ShipCommand.FIRE)
        ship.isHoldFireOneFrame = true
    }
}

The .FIRE command is just LMB-equivalent and won't stop autofire, perhaps this is the issue? You could also try calling setHoldFireOneFrame() which should prevent autofire for one frame as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Armithaig on November 19, 2019, 10:38:32 AM
Ah my bad about the russian, the ship.isHoldFireOneFrame = true is some syntactical kotlin glue for ship.setHoldFireOneFrame(true);
Will make an effort to convert things to java in the future.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 19, 2019, 10:45:13 AM
Aha. That's... interesting, to say the least. Especially considering there's no "isHoldFireOneFrame" member variable in that class.

I don't have a lot of confidence in that actually working, but then I'm not familiar with kotlin. But basically I can't really help out much here if there's a layer of code and compilation here that I don't understand and that isn't officially supported and, for all I know, something could be going wrong in that layer, if that makes sense.

Also, I'm not sure what the problem is; "appears ineffectual" isn't quite enough to go on :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Armithaig on November 19, 2019, 11:14:48 AM
Eh, sorry I talk weird. Since my IDE's set up for kotlin was doing what was convenient for me and not you, for that'll apologise.

Here's a working java example, mini-mod (https://gitlab.com/Armithaig/kiith-nabaal-shipyard/uploads/4b9a9f9b663edf0918a3f388cee83a98/SomeSystem.zip) and video (https://streamable.com/9h4gs) demonstration.
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.impl.combat.BaseShipSystemScript;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipCommand;

public class SomeSystemStats extends BaseShipSystemScript {

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
ShipAPI ship = (ShipAPI)stats.getEntity();
       
ship.blockCommandForOneFrame(ShipCommand.FIRE);
ship.setHoldFireOneFrame(true);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("i should be holding fire", false);
}
return null;
}
}

EDIT: Thanks legend!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 19, 2019, 11:41:35 AM
Ah, I see - thank you for the example. Fixed on my end, for now you'll need to use the deprecated USE_SELECTED_GROUP, though might want to block both for good measure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on November 19, 2019, 12:38:17 PM
How robust is modding for characters at the moment?

To elaborate, I mean for individuals on stations and NPC fleet commanders.

Are persistent NPC fleet commanders possible at the moment? As most fleets eventually return to their planet of origin, is that commander deleted from the game as well when that occurs?

I was wondering if it were possible to create real "rival" commanders with level cap akin to the player but not sure if it's even possible
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 19, 2019, 05:57:48 PM
Yes they are replaced. See the bottom of my post for the code snippet of the replace array in case I messed something up there.

I had originally thought it was another one of those operating-system-specific deliminator issues like from .9 but the really weird thing is that it only affects some markets according to the report rather than all markets defined in the file. You'd think it would be universal to the markets if it wasn't being replaced and all of them were being appended.

It works fine for me though so I'm kind of at a loss as to how to proceed with troubleshooting.  :-\

I'll try a few more things to reproduce it a bit later.

Ah, my bad, missed that. ... really not sure, then, sorry!

No worries thanks for looking!  :)

I figured it out, I think! It does indeed seem to be an operating system-specific error with the replace array path deliminator like I encountered in .9.

I took out the replace section for the markets and I was able to reproduce the error so that is what is happening on the technical level- the duplicate market entries cause the economy of those markets to completely collapse because the replacement of the JSON files isn't occurring.

I am counseling the user to try a different path deliminator in order to see if that solves it. I will give more info here, if that is desirable, to determine the exact details of what operating system has this behavior and what path deliminator works for it.

Hopefully this will help everyone else encountering this as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 19, 2019, 06:02:01 PM
I am counseling the user to try a different path deliminator in order to see if that solves it. I will give more info here, if that is desirable, to determine the exact details of what operating system has this behavior and what path deliminator works for it.

Hopefully this will help everyone else encountering this as well.

Yeah, please let me know! I *thought* this was supposed to be fixed for 0.9.1a, hmm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: scarface on November 19, 2019, 06:25:40 PM
Hi, i made a new ship. several in a row in fact. and none are being attacked by enemy ships. why? i always redid the entire thing and it fixed itself, doesnt work anymore. any ideas?

edit:solved. i always accidentally clicked on vast bulk hullmod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 19, 2019, 06:38:08 PM
My best guess is there's something wrong with the collision bounds or collision radius of your ships. Those are the only two things I can think of that tell other ships when they should and shouldn't shoot at your ships.

I was wondering if it were possible to create real "rival" commanders with level cap akin to the player but not sure if it's even possible
I'm not sure about the specifics you mentioned, but I'm pretty sure you can create, edit, and assign fleet commanders, so you should be able to override any vanilla behavior related to fleet commanders that you need to change. However It might get pretty complicated if you need to change too much.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 19, 2019, 09:56:03 PM
Okay, after several attempts at making the fleet inflater work for controlling the Shikome numbers, I switched tactics and approached this from the angle of just stripping out and replacing the excessive Shikomes. With a good deal of help from Vayra and Sundog we've now gotten a sort of working script?

So, first off this strips out the Shikomes. But it's behaving weirdly, and only strips them out after you directly interact with the fleet. It's not really clear why this should be happening; since it's semi-functional we can roll with this, but it is obviously less than ideal. Any insight would be greatly appreciated.
Code: java
package data.campaign.fleets;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.combat.ShipVariantAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.util.List;

public class MS_fleetFighterFinagler implements EveryFrameScript {
    /////////////////////////////// CONFIG ///////////////////////////////
    private static final String FIND_ID = "ms_shikome";
    private static final String REPLACE_ID = "ms_skinwalker";
    private static final int FP_THRESHOLD = 6661312; // allowed one shikome per this many FP (not allowed any if not over threshold)
    private final IntervalUtil timer = new IntervalUtil(2f, 5f); // min, max in seconds for check (you want this to run pretty often, but not every frame)
    /////////////////////////////// CONFIG ///////////////////////////////

    private static final String FIND_WING = FIND_ID + "_wing";
    private static final String REPLACE_WING = REPLACE_ID + "_wing";
   
    @Override
    public boolean isDone() {
        return false;
    }

    @Override
    public boolean runWhilePaused() {
        return false;
    }

    @Override
    public void advance(float amount) {
       
        // advance the timer
        timer.advance(amount);
        // if the timer's not over, just give up and try again later
        if (!timer.intervalElapsed()) {
            return;
        }

        // loop through all the fleets around
        for (CampaignFleetAPI fleet : Global.getSector().getCurrentLocation().getFleets()) {

            // there are a whole host of reasons we might not care about checking a given fleet
            if (fleet == null
                    || !fleet.isInflated()
                    || !fleet.isPlayerFleet()
                    || !fleet.isAlive()
                    || fleet.isEmpty()
                    || fleet.isExpired()
                    || fleet.isDespawning()
                    || fleet.getFleetData() == null
                    || fleet.getFleetData().getMembersInPriorityOrder() == null
                    || fleet.getFleetData().getMembersInPriorityOrder().isEmpty()
                    || fleet.getFaction() == null
                    || fleet.getFaction().getKnownFighters() == null
                    || fleet.getFaction().getKnownFighters().isEmpty()
                    || !fleet.getFaction().getKnownFighters().contains(FIND_WING)) {
                continue;
            }

            // setup some variables
            int fp = fleet.getFleetPoints();
            int allowed = fp / FP_THRESHOLD;
            int count = 0; // per fleet

            // loop through all the members of this fleet
            List<FleetMemberAPI> members = fleet.getFleetData().getMembersInPriorityOrder();
            for (FleetMemberAPI member : members) {
               
                // grab the ship variant
                ShipVariantAPI variant = member.getVariant();
                if (variant == null) {
                    continue; // if the ship doesn't have a variant, idfk just skip it
                }
               
                // loop through all its flight decks
                for (int i = 0; i <= member.getNumFlightDecks(); i++) {
                   
                    // count shikome wings
                    if (FIND_WING.equals(variant.getWingId(i))) {
                        count++;
                       
                        // if we have too many shikome wings, replace this one with a skinwalker wing
                        if (count > allowed) {
                            member.getVariant().setWingId(i, REPLACE_WING);
                        }
                       
                    }
                   
                }
            }
        }
    }
}

Thanks again for any help. Cheers!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 19, 2019, 11:22:19 PM
But it's behaving weirdly, and only strips them out after you directly interact with the fleet.
Behaving weirdly how? I suspect that fleets normally won't inflate until you interact with them directly, which means they won't be stripped of Shikomes until the earliest timer elapse after inflation. That could lead to, for example, hovering over a fleet and seeing its shikomes transform to skinwalkers in the fleet tooltip after a brief delay. I was thinking about this problem earlier, and I think I might've thought of a solution (assuming my guess about what's causing the problem in the first place is correct). Instead of periodically iterating over the nearby fleets in the player's current location, it might be possible to run your code at the exact frame (or maybe the next frame) when the fleet inflates. I'm pretty sure CampaignPlugin.pickFleetInflater() is called each time a fleet is inflated, so if you override that you can add the inflated fleet to a collection to be modified shortly thereafter. In fact, I think I might be able to solve a similar inflation-related display bug in ruthless sector this way, so I'll let you know if it works for me.

Edit: Well, that doesn't seem to work, unfortunately. It seems like inflaters are picked for fleets when they respawn rather than when they inflate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 20, 2019, 01:28:52 AM
How to check if one month has passsed (a monthly check for a script to fire)?

I know it should extend EveryFrameScript but how to track (roughly) a month. By counting frames? Can I use the same method as the monthly stipend (if I can find it, don't know where it is in the code)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on November 20, 2019, 02:55:49 AM
How to check if one month has passsed (a monthly check for a script to fire)?

I know it should extend EveryFrameScript but how to track (roughly) a month. By counting frames? Can I use the same method as the monthly stipend (if I can find it, don't know where it is in the code)?
For example: after implementing EveryFrameScript:
Code
static float months = 0;

@Override
public void advance(float amount) {
    months += Global.getSector().getClock().convertToMonths(amount);
    if (months > 1) {
        /*
        YOUR CODE HERE
        */
        months = 0;
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 20, 2019, 03:26:18 AM
Are persistent NPC fleet commanders possible at the moment? As most fleets eventually return to their planet of origin, is that commander deleted from the game as well when that occurs?

I was wondering if it were possible to create real "rival" commanders with level cap akin to the player but not sure if it's even possible
A mod can store an officer in its own data. When creating a new fleet for that officer, you can just replace the the automatically generated fleet commander/flagship officer with your saved officer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 20, 2019, 05:41:36 AM
Is it possible to change the default empty weapon slot mount sprite of a ship through hullmod? would need to be something that works on all ships, not just mine, so no deco weapons workarounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 20, 2019, 05:55:01 AM
Behaving weirdly how? I suspect that fleets normally won't inflate until you interact with them directly, which means they won't be stripped of Shikomes until the earliest timer elapse after inflation. That could lead to, for example, hovering over a fleet and seeing its shikomes transform to skinwalkers in the fleet tooltip after a brief delay. I was thinking about this problem earlier, and I think I might've thought of a solution (assuming my guess about what's causing the problem in the first place is correct). Instead of periodically iterating over the nearby fleets in the player's current location, it might be possible to run your code at the exact frame (or maybe the next frame) when the fleet inflates. I'm pretty sure CampaignPlugin.pickFleetInflater() is called each time a fleet is inflated, so if you override that you can add the inflated fleet to a collection to be modified shortly thereafter. In fact, I think I might be able to solve a similar inflation-related display bug in ruthless sector this way, so I'll let you know if it works for me.

Edit: Well, that doesn't seem to work, unfortunately. It seems like inflaters are picked for fleets when they respawn rather than when they inflate.

Ah well; I appreciate you taking the time to help. Guess it's gonna be something to think on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2019, 10:02:42 AM
Is it possible to change the default empty weapon slot mount sprite of a ship through hullmod? would need to be something that works on all ships, not just mine, so no deco weapons workarounds.

I don't believe so. The slot cover sprites are set in the hullstyle, while the actual mount sprites (which I suspect you're *not* referring to) are baked into the hull sprite.


Behaving weirdly how? I suspect that fleets normally won't inflate until you interact with them directly, which means they won't be stripped of Shikomes until the earliest timer elapse after inflation. That could lead to, for example, hovering over a fleet and seeing its shikomes transform to skinwalkers in the fleet tooltip after a brief delay. I was thinking about this problem earlier, and I think I might've thought of a solution (assuming my guess about what's causing the problem in the first place is correct). Instead of periodically iterating over the nearby fleets in the player's current location, it might be possible to run your code at the exact frame (or maybe the next frame) when the fleet inflates. I'm pretty sure CampaignPlugin.pickFleetInflater() is called each time a fleet is inflated, so if you override that you can add the inflated fleet to a collection to be modified shortly thereafter. In fact, I think I might be able to solve a similar inflation-related display bug in ruthless sector this way, so I'll let you know if it works for me.

Edit: Well, that doesn't seem to work, unfortunately. It seems like inflaters are picked for fleets when they respawn rather than when they inflate.

Ah well; I appreciate you taking the time to help. Guess it's gonna be something to think on.

A possible solution: calling .inflateIfNeeded() on nearby fleets that need this done?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: senhe on November 20, 2019, 03:33:16 PM
Hey all, love Starsector and I'd like to start making a couple mods for it.

What I'd like to do is make the 'Take All' looting option only loot up to your cargo/fuel limit, prioritizing supplies or high-value commodities.

I've skimmed the Starsector API, but I'm not sure if what I want to do is possible.

Appreciate any pointers in the right direction!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 20, 2019, 04:20:06 PM
How to check if one month has passsed (a monthly check for a script to fire)?

I know it should extend EveryFrameScript but how to track (roughly) a month. By counting frames? Can I use the same method as the monthly stipend (if I can find it, don't know where it is in the code)?
For example: after implementing EveryFrameScript:
Code
static float months = 0;

@Override
public void advance(float amount) {
    months += Global.getSector().getClock().convertToMonths(amount);
    if (months > 1) {
        /*
        YOUR CODE HERE
        */
        months = 0;
    }
}
"months" probably shouldn't be static. That would make it so it stays the same even if you reload or load a different save. Another option is to override BaseCampaignEventListener.reportEconomyMonthEnd()

A possible solution: calling .inflateIfNeeded() on nearby fleets that need this done?
Right, that should solve the problem, and I might end up doing that for ruthless sector, but that approach isn't ideal since it would undermine the purpose of the inflation system if used on too many fleets. Maybe I'm overestimating the memory impact of fleet inflation?

Hey all, love Starsector and I'd like to start making a couple mods for it.

What I'd like to do is make the 'Take All' looting option only loot up to your cargo/fuel limit, prioritizing supplies or high-value commodities.

I've skimmed the Starsector API, but I'm not sure if what I want to do is possible.

Appreciate any pointers in the right direction!
Have you checked out the new Transfer All Items (http://fractalsoftworks.com/forum/index.php?topic=17210) mod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2019, 04:47:29 PM
Right, that should solve the problem, and I might end up doing that for ruthless sector, but that approach isn't ideal since it would undermine the purpose of the inflation system if used on too many fleets. Maybe I'm overestimating the memory impact of fleet inflation?

If it's only fleets that are in the same location and near the player and of that faction, it should be alright. I mean, as you say, it's undermining it, but probably not by a huge amount. If we're talking like 20 big fleets, though, that would probably be more impactful, both in terms of memory use and savefile size.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 20, 2019, 05:01:19 PM
I'm learning how to mess with variants in code and am a bit confused. The following code does add a ship to the player fleet, but the changes to the variant (just a few methods chosen at random as tests) aren't taking effect. Anyone know the correct method for changing variants? Do you need to construct a brand new VariantAPI object with all the changes and do a replace?

Code: java
FleetMemberAPI customFleetMember = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "hammerhead_Overdriven");
               
customFleetMember.getVariant().clearHullMods();
customFleetMember.getVariant().setVariantDisplayName("MW 2");

playerFleet.getFleetData().addFleetMember(customFleetMember);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2019, 05:17:57 PM
That's a bit strange, I'm not sure why the changes wouldn't show up.

That said, what you're doing would, I believe, change *all* hammerhead_Overdriven variants in the game.

What you want is roughly something like:

Code: java
ShipVariantAPI copy = customFleetMember.getVariant().clone();
copy.setSource(VariantSource.REFIT);

/* make your changes to the variant here */

customFleetMember.setVariant(copy, false, false);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 20, 2019, 05:18:27 PM
How to use spawnDamagingExplosion? I made a DamagingExplosionSpec, but no matter what values i use it doesn't deal any damage, is it the collision? i tried Ship, Fighter, Ray and some others, nothing works (the explosion is caused by a fighter)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 20, 2019, 05:28:43 PM
I'm learning how to mess with variants in code and am a bit confused. The following code does add a ship to the player fleet, but the changes to the variant (just a few methods chosen at random as tests) aren't taking effect. Anyone know the correct method for changing variants? Do you need to construct a brand new VariantAPI object with all the changes and do a replace?
Pretty sure that would work for a custom variant, but stock variants are strange. Replacing them with a new variant will indeed allow you to make changes. For example, this code snippet from com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddStandardStartingScript.adjustS tartingHulls()
Code: java
		for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
ShipVariantAPI v = member.getVariant().clone();
v.setSource(VariantSource.REFIT);
v.setHullVariantId(Misc.genUID());
member.setVariant(v, false, false);
@Alex: *shakes fist for beating me to it*

If it's only fleets that are in the same location and near the player and of that faction, it should be alright. I mean, as you say, it's undermining it, but probably not by a huge amount. If we're talking like 20 big fleets, though, that would probably be more impactful, both in terms of memory use and savefile size.
Hmm... right. I hadn't considered that in MShadowy's case only SHI fleets would need to be inflated, which should drastically cut down on the need for it. Still might not be worth it for ruthless sector though, as that would need to inflate each fleet the player might hover the mouse over.

How to use spawnDamagingExplosion? I made a DamagingExplosionSpec, but no matter what values i use it doesn't deal any damage, is it the collision? i tried Ship, Fighter, Ray and some others, nothing works (the explosion is caused by a fighter)
Nothing jumps out at me as a likely cause. Maybe post the code you use to call the method?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 20, 2019, 05:34:47 PM

Nothing jumps out at me as a likely cause. Maybe post the code you use to call the method?

Code
DamagingExplosionSpec explosion = new DamagingExplosionSpec(1, 600, 300, 20000, 5000, CollisionClass.SHIP, CollisionClass.FIGHTER, 10, 50, 1, 100, new Color(255, 175, 50, 175), new Color(255, 175, 50, 255));
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation());

This is being called by the ship system of a drone with Fighter collision (dunno if important)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 20, 2019, 05:48:41 PM
That's a bit strange, I'm not sure why the changes wouldn't show up.

That said, what you're doing would, I believe, change *all* hammerhead_Overdriven variants in the game.

What you want is roughly something like:

Code: java
ShipVariantAPI copy = customFleetMember.getVariant().clone();
copy.setSource(VariantSource.REFIT);

/* make your changes to the variant here */

customFleetMember.setVariant(copy, false, false);

Thanks! (And also thanks to Sundog!) That clears up quite a bit about whats going on.

I'm guessing VariantSource.REFIT is needed to inform the game engine of what created the variant and refit is an appropriate enum for code based changes.

One more question, what do the arguments [boolean withRefit, boolean withStatsUpdate] do? I'm planning on eventually swapping modules via code outside of combat, if it makes any difference to what I need to know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2019, 05:51:10 PM
withRefit makes it apply a CR penalty for an in-space refit. withStatsUpdate forces a fleet member stats update which you generally don't need to do. It'll happen automatically anyway, whenever the player opens the fleet screen and... any number of things, really.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 20, 2019, 05:54:10 PM
I am counseling the user to try a different path deliminator in order to see if that solves it. I will give more info here, if that is desirable, to determine the exact details of what operating system has this behavior and what path deliminator works for it.

Hopefully this will help everyone else encountering this as well.

Yeah, please let me know! I *thought* this was supposed to be fixed for 0.9.1a, hmm.

Weeelllp, unfortunately I think this info might be lost for the moment.  :(

I received confirmation that one of my potential examples fixed the issue, but no further information was given so I don't know the operating system or which proposed fix worked. Reporting the issue was a first post for the account, so there is a chance that the user won't be on the forums any longer to see the question about what, exactly, worked for them. I'll update if this turns out to not be the case.

Silver lining:

Considering how the error occurred in .9 (from what I remember), I can say with a bit of confidence that I think the issue was mostly fixed with 0.9.1a. I don't receive any reports of random nullpointers from ship files failing to be replaced, for instance, and if this were the case then the user who reported this error would never have made it to the campaign in the first place to see the market error.

This leads me to deduce that the file type still having this issue is specifically JSON files. I hope that can narrow it down at least.

*edit* The solutions are in the thread btw. I'll repost that here too for convenience. Bottom of the first page:

https://fractalsoftworks.com/forum/index.php?topic=17278.0 (https://fractalsoftworks.com/forum/index.php?topic=17278.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 20, 2019, 06:01:11 PM
The explosion seems to be working now, but i can't tell for sure because it gives me this crash now

Code
138540 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamage(Unknown Source)
at com.fs.starfarer.combat.E.A.O0OO.super(Unknown Source)
at com.fs.starfarer.combat.E.A.super(Unknown Source)
at com.fs.starfarer.combat.E.A.super(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 20, 2019, 06:04:38 PM
Thanks!

@Ed I think this came up in another thread just recently: http://fractalsoftworks.com/forum/index.php?topic=17262.0

From that I think you need to call spec.setDamageType()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 20, 2019, 06:26:17 PM
The explosion seems to be working now
Did you get it to work by changing
Code
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation());
to
Code
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation(), true);
?

As a courtesy to anyone searching for solutions to the same problem, it's generally a good idea to explain the solution to your question in cases like this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 20, 2019, 06:57:41 PM
The explosion seems to be working now
Did you get it to work by changing
Code
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation());
to
Code
engine.spawnDamagingExplosion(explosion, ship, ship.getLocation(), true);
?

As a courtesy to anyone searching for solutions to the same problem, it's generally a good idea to explain the solution to your question in cases like this.
nope, i changed the collison class to projectile_ff, i didn't share the solution because it either just do the visuals and no damage or it crashes, so it actually doesn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 20, 2019, 07:02:27 PM
Ah, ok. Makes sense. Thanks for clarifying.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 21, 2019, 04:20:19 AM
Thanks!

@Ed I think this came up in another thread just recently: http://fractalsoftworks.com/forum/index.php?topic=17262.0

From that I think you need to call spec.setDamageType()
That was it.
Code
explosion.setDamageType(DamageType.HIGH_EXPLOSIVE);
Thanks it works now.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 21, 2019, 11:55:13 AM
Yeah, please let me know! I *thought* this was supposed to be fixed for 0.9.1a, hmm.

  :)

Hey! Sorry I couldn't respond for while.

I used the first set of code that you told me to replace the original game code with. As for the computer, I'm running the game on Mac with applications.

Please let me know if you need more details

So as an example:

Code
         "data\\campaign\\econ\\aztlan.json",

-is required to replace Aztlan on a Mac, while for Windows I use:

Code
         "data\\campaign\\econ/aztlan.json",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2019, 12:45:27 PM
Ahh, alright, that makes sense! Well, sort of, anyway. But the first way also works on windows, correct?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 21, 2019, 01:25:41 PM
It seems to, yes! I'll make that my default implementation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 21, 2019, 03:59:39 PM
Is it possible to set a projectile's (or missile's) speed/max speed via code? I'd like to make a weapon whose projectiles travel at different speeds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 21, 2019, 06:10:47 PM
Is it possible to set a projectile's (or missile's) speed/max speed via code? I'd like to make a weapon whose projectiles travel at different speeds.

As I was typing this I think I found a better way for your purpose, which is here, but I'm leaving a more complicated and versatile method below.

I think what you can do is, in an everyFrameScript:
1) get each ship (ShipAPI) and go through their weapons (WeaponAPI)
2) for the weapons you want,

[Edit] It may be possible to do this using an EveryFrameWeaponEffectPlugin rather than an EveryFramePlugin. That would improve performance dramatically by not needing to loop through every weapon, as it would only apply to weapons that have it.

1) use an EveryFrameWeaponEffectPlugin tied to the weapons in question
2) in that plugin call and copy (important!) the mutableShipStats using  weapon.getDamage().getStats().clone()       [Edit see note below]
3) grab and modify the projectile speed stat according to whatever logic you want. To do so you'll need an ID code for the script, and call getProjectileSpeedMult().modifyPercent(id, amount) on the mutableShipStats cloned object. Since you are probably changing this again, you may need to call unmodiyPercent(id) before you change again, but I'm honestly not sure how MutableStats work and if it is smart enough to override changes from the same ID or not. You probably don't want to do this every frame, but at some interval that makes sense for the weapon, and only when the weapon if firing (weapon.isFiring() will tell you).
4) set the stats of the weapon using .getDamage().setStats(cloned stats)

Now I haven't tested this at all, so it could fail horribly, but this would be how I would try. And I really hope creating so many clones of MutableShipStatsAPI doesn't cause a memory leak. And that doing all this cloning and resetting to potentially lots of weapons doesn't cost too much performance.

The cloning is important because I'm fairly sure the MutableShipStatsAPI instance is being used by the whole ship, so if you just modify it then every weapon on the ship will be modified. Of course, if under the hood WeaponAPI.getDamage().setStats() is setting the MutableShipStatsAPI for the whole ship instead of just for the weapon, then the method I've outlined above will still completely fail. As I said, I haven't tried :)

[Another Edit] And thinking further, by the above logic you should only need to clone once, as after that the WeaponAPI should have its own instance of MutableShipStatsAPI (if this works at all). So the cloning step I mentioned above only needs to happen once. Doing it if a tag is false and then setting the tag to true would hopefully speed up performance by quite a bit.



This is the more complicated, but more powerful, method that I thought of first. Its almost guaranteed to be able to work, but is much worse performance wise:

You can dynamically change the speed of any projectile in combat, though the API is a bit deceptive about it. In an every frame script you can use the combat engines' .getProjectiles method to get all the projectiles. Then you can sort through the projectiles, get the ones you want, and call getVelocity. There is no "set velocity", which is what I would expect, but because getVelocity returns the velocity object (Vector2f) you can then edit its values, in your case probably with .scale() .

Its a pain to have to sort through every projectile every frame, but by adding a tag to projectiles whose speed you've set, and skipping any projectile with that tag early, you may be able to keep performance acceptable.

An example of this method can be found in the gravityfield system from Blackrock Driveyards mod, filename GravityField.java. Do ask permission if you are copying code wholesale.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 21, 2019, 06:30:22 PM
As I was typing this I think I found a better way for your purpose, which is here, but I'm leaving a more complicated and versatile method below....
I'll give it a try!

But on that same note, is it also possible to change a weapon's engine and contrail color? And lastly, (and I know it sounds that I might as well be making a totally different weapon, but please bear with me...) the projectile/missile sprite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 21, 2019, 06:44:48 PM
As I was typing this I think I found a better way for your purpose, which is here, but I'm leaving a more complicated and versatile method below....
I'll give it a try!

But on that same note, is it also possible to change a weapon's engine and contrail color? And lastly, (and I know it sounds that I might as well be making a totally different weapon, but please bear with me...) the projectile/missile sprite?

For those two, check out Trailer Moments! https://fractalsoftworks.com/forum/index.php?topic=14047.0

I think it has comprehensive ways to do that built in.

I also think Junk Pirates has a weapon that fires off different missiles (ScrapJet Missile launcher maybe?) at random... that might be another place to look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 21, 2019, 07:00:23 PM
I would like for this custom player market of mine for the various vanilla Industries to not show up when the "Add Industry or Structure" button is pressed (I've made them unable to be built, but they still entries).

I think I can do this by modifying and replacing BaseIndustry, in particular by changing showWhenUnavailable to something like

Code: java
public boolean showWhenUnavailable() {

if {market.hasTag("Ids.NO_BASE_INDUSTRIES")} return false;

return true;
}

And then all the default industries that inherit this method won't show for any of my markets tagged in this way. However, its not particularly friendly for other mods to do things this way, and some industries like Cryorevival would also need to be overridden because they have a custom implementation of this method, which would stop any other mods from modifying those industries. I guess this could be done as a mini-library mod, and then any mod that wanted to use custom industries could include it and tag their markets, but thats kind of a pain.

Anyhow, my question is: is there a better way of making the default industries not show?

[Edit] Oh, uhh, it seems that that file can't be replaced? Or the replace tag isn't working? Does anyone know how I'd do that? I had thought it would just be
Code
"replace":["com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry.class"]
in mod_info.json (and the class in my own jar with the same structure) but that does not work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 21, 2019, 07:30:20 PM
For those two, check out Trailer Moments! https://fractalsoftworks.com/forum/index.php?topic=14047.0

I think it has comprehensive ways to do that built in.

I also think Junk Pirates has a weapon that fires off different missiles (ScrapJet Missile launcher maybe?) at random... that might be another place to look.
Thank you very much! I think I've found what I'm looking for!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2019, 08:33:25 PM
Anyhow, my question is: is there a better way of making the default industries not show?

[Edit] Oh, uhh, it seems that that file can't be replaced? Or the replace tag isn't working? Does anyone know how I'd do that? I had thought it would just be
Code
"replace":["com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry.class"]
in mod_info.json (and the class in my own jar with the same structure) but that does not work.

Yeah, you can't replace class files like this; it's inside a jar and outside the realm of what the replace stuff can do. To answer your question, I'm not sure there's any way to do that - the decision is per-industry rather than per-market.

Or, well, you *could* extend every industry class with a subclass that has that showWhenUnavailable() code, and then provide an industries.csv file that points at the replacement classes, but that would not play nice with mods that add industries, as those wouldn't be modified...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 21, 2019, 09:01:22 PM
Whoops! Thanks for the info and the workaround; its just a UI issue so I think unless I do a total conversion I'll leave the files alone to be more mod friendly.

I don't suppose this could be modified for future versions by adding a no base industries tag or API call for markets? A few other people expressed interest when we were talking about it for thing like special faction colonies that would have different structures, or colonize-able stations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2019, 10:48:08 AM
Hmm, seems fairly trivial, so: sure!

Code
	public boolean isAvailableToBuild() {
if (market.hasTag(Tags.MARKET_NO_INDUSTRIES_ALLOWED)) return false;
return market.hasIndustry(Industries.POPULATION) && !getId().equals(Industries.POPULATION);
}

public boolean showWhenUnavailable() {
if (market.hasTag(Tags.MARKET_NO_INDUSTRIES_ALLOWED)) return false;
return true;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 22, 2019, 11:14:43 AM
Thanks so much! That will help clean up the UI on a lot of modded industry stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 22, 2019, 09:46:38 PM
How can I get the weapon spec (or any data structure where I can pull the weapon's display name) from just it's ID?

Also, how are the events in rules.csv ordered? I'm currently trying to make an alternate PickGreeting if the character has given a quest (i.e. waiting for the player to bring the required stuff), but when I added the line to accept the delivery, it doesn't seem to be called at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 22, 2019, 10:28:08 PM
How can I get the weapon spec (or any data structure where I can pull the weapon's display name) from just it's ID?
Code: java
Global.getSettings().getWeaponSpec("my_weapon_id").getWeaponName()
Not sure about your rules.csv question. Maybe the condition score of your rule isn't higher than the default?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 22, 2019, 10:59:44 PM
Code: java
Global.getSettings().getWeaponSpec("my_weapon_id").getWeaponName()
Not sure about your rules.csv question. Maybe the condition score of your rule isn't higher than the default?
Thanks for the weapon code!

Sorry, I'm not quite sure how to explain what's going wrong either since I'm just fumbling around with the file at the moment... I tried adding some to the two conditions that should change (bottom two), but when I added the tag, it seems they both get ignored instead and the default (top 3) conversation is picked... Below is the relevant slice of my rule.csv.

mvt_rinaGreetingIfPlayerIsStrangerPickGreeting$yrxp_isRinaShowPersonVisual0:cutCommLink:"No, it's nothing."
mvt_rinaGreetingIfPlayerIsCommissioned
PickGreeting$yrxp_isRina
$faction.id == yrxp
$faction.friendlyToPlayer
ShowPersonVisual
CallEvent $mvt_eventRef prepare
$talkedTo = true
0:mvt_yrxp_job:Ask if she has a job for you.
1:mvt_mivit_questline1:Ask if something is bothering her
2:cutCommLink:"No, it's nothing."
mvt_rinaGreetingTalkedToPickGreeting$yrxp_isRina
$faction.id == yrxp
$faction.friendlyToPlayer
$talkedTo
ShowPersonVisual
CallEvent $mvt_eventRef prepare
0:mvt_yrxp_job:Ask if she has a job for you.
1:mvt_mivit_questline1:Ask if something is bothering her
2:cutCommLink:"No, it's nothing."
mvt_rinaGreetingTalkedToWithQuestPickGreeting$tag:RinaFetchQuestDeliver score:100
$yrxp_isRina
$faction.id == yrxp
$faction.friendlyToPlayer
$talkedTo
!CallEvent $rna_eventRef canTakeQuest
ShowPersonVisual
CallEvent $mvt_eventRef prepare
0:cutCommLink:"No, not yet."
rna_deliverJobPickGreeting$tag:RinaFetchQuestDeliver score:1000
$yrxp_isRina
$faction.id == yrxp
$faction.friendlyToPlayer
$talkedTo
CallEvent rina_fetchQuest_eventRef deliverQuest
ShowPersonVisual
EndConversation

So when the fetch quest begins I want the game to prioritize checking the rna_deliverJob over mvt_rinaGreetingTalkedToWithQuest, which is the alternate greeting for when a quest is underway but not complete. But it seems it only ever want to display mvt_rinaGreetingTalkedToWithQuest.

Oh, and as mentioned above, when I added the $tag:RinaFetchQuestDeliver score:1000 line in the conditions, it seems they both got ignored and the game instead displayed mvt_rinaGreetingTalkedTo
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 23, 2019, 01:54:29 AM
Tags are used for sector entity properties, e.g. $tag:station = true for orbital stations. I'm not sure persons even have them.
When/how are you setting the tag? Maybe your check needs to look at the entity rather than the person, e.g. $entity.tag:RinaFetchQuestDeliver
(but this is bad since a market can have more than one entity, you probably want to use market memory instead)

There doesn't seem to be a listener for "player founded a colony". If so, could we get one?

Oh, yep - let me add a PlayerColonizationListener. There; done.
In the same vein, is there a listener for a market decivilizing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 23, 2019, 02:32:08 AM
Code
119282 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.fleet.CargoData.initMothballedShips(Unknown Source)
at com.fs.starfarer.campaign.CustomCampaignEntity.<init>(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
at data.scripts.world.systems.FPE_danube.generate(FPE_danube.java:68)
at data.scripts.world.FPE_gen.generate(FPE_gen.java:17)
at data.scripts.FPE_modPlugin.initFPE(FPE_modPlugin.java:16)
at data.scripts.FPE_modPlugin.onNewGame(FPE_modPlugin.java:26)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.N.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Keep running into this error, and I'm not sure why. Here's line 68 of the system generation file, but I'm not seeing what's causing the crash.

Code
		SectorEntityToken danube_relay = system.addCustomEntity("fpe_danube_relay", // unique id
"Danube Relay", // name - if null, defaultName from custom_entities.json will be used
"comm_relay_makeshift", // type of object, defined in custom_entities.json
"FPE"); // faction
danube_relay.setCircularOrbitPointingDown(star, 300, 6000, 700);

Could anyone help me please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on November 23, 2019, 03:08:06 AM
If I wanted to play a campaign with a much smaller sector and just a few systems with many planets/moons/bases

How would I go about creating such a sector? Is it even possible while using mods? (Nexerelin and all factions I could find from forum)

I'm looking for a small sector where systems are close together (closer than 20 days flight) with maybe 15-20 systems.

each system having enough objects (Planets/Moons/Bases) to fit the factions.

Is that even possible without heavy coding? (my knowledge is basically limited to modifying .json, not writing my own)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 23, 2019, 11:14:34 AM
Code
119282 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.fleet.CargoData.initMothballedShips(Unknown Source)
at com.fs.starfarer.campaign.CustomCampaignEntity.<init>(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source)
at data.scripts.world.systems.FPE_danube.generate(FPE_danube.java:68)
at data.scripts.world.FPE_gen.generate(FPE_gen.java:17)
at data.scripts.FPE_modPlugin.initFPE(FPE_modPlugin.java:16)
at data.scripts.FPE_modPlugin.onNewGame(FPE_modPlugin.java:26)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.N.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Keep running into this error, and I'm not sure why. Here's line 68 of the system generation file, but I'm not seeing what's causing the crash.

Code
		SectorEntityToken danube_relay = system.addCustomEntity("fpe_danube_relay", // unique id
"Danube Relay", // name - if null, defaultName from custom_entities.json will be used
"comm_relay_makeshift", // type of object, defined in custom_entities.json
"FPE"); // faction
danube_relay.setCircularOrbitPointingDown(star, 300, 6000, 700);

Could anyone help me please?

Seems to me that "system" is coming up as null here for some reason.

Can you show me the line you use that instantiates that variable?

*Edit*

Hmm, took a look at my own code since the case where system coming up as null would be really weird if you are creating the system in the file.

Looks like it could be because you are using:

Code
danube_relay.setCircularOrbitPointingDown(star, 300, 6000, 700);

with a PlanetAPI instead of a SectorEntityToken like its method definition indicates it uses. "setCircularOrbit" on the other hand will accept a PlanetAPI.

Maybe try casting it like:

Code
danube_relay.setCircularOrbitPointingDown((SectorEntityToken) star, 300, 6000, 700);

Or I use:

Code
danube_relay.setCircularOrbitPointingDown(system.getEntityById("star_id"), 300, 6000, 700);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 23, 2019, 12:16:56 PM
@King Alfonzo see my edit above for a potential solution to your issue.

--------------
Also, how are the events in rules.csv ordered? I'm currently trying to make an alternate PickGreeting if the character has given a quest (i.e. waiting for the player to bring the required stuff), but when I added the line to accept the delivery, it doesn't seem to be called at all.

How are you are you providing the check for the quest? Simply adding a rule with the PickGreeting trigger will have it be a possible option when speaking with an npc unless you have added others with higher default scores, but whether or not you see it as an option is determined by the conditions you set and whether they are being recognized.

If would help to see the conditions you use and to ensure the rule has a unique name and is not an override of an existing one.

If I am misunderstanding the issue and its a rule command in the script section of the rule that is not working, link me the rule and any errors that show up when selecting the dialogue in game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 23, 2019, 12:19:18 PM
Sorry, I'm not quite sure how to explain what's going wrong either since I'm just fumbling around with the file at the moment... I tried adding some to the two conditions that should change (bottom two), but when I added the tag, it seems they both get ignored instead and the default (top 3) conversation is picked... Below is the relevant slice of my rule.csv.

So when the fetch quest begins I want the game to prioritize checking the rna_deliverJob over mvt_rinaGreetingTalkedToWithQuest, which is the alternate greeting for when a quest is underway but not complete. But it seems it only ever want to display mvt_rinaGreetingTalkedToWithQuest.

Oh, and as mentioned above, when I added the $tag:RinaFetchQuestDeliver score:1000 line in the conditions, it seems they both got ignored and the game instead displayed mvt_rinaGreetingTalkedTo

Take a look in starsector.log; when the game is run in devMode, it should have info about which rules are picked and why, which conditions matched/didn't match, and so on.

Offhand, I suspect that "RinaFetchQuestDeliver" is not actually a tag that your entity has - and, actually, you're talking to a PersonAPI at that point, so maybe the entity has that tag (added via, say, entity.addTag() or its definition in custom_entitis.json) but the person doesn't. But, right, the logfile will have the info you need, more than likely.


Tags are used for sector entity properties, e.g. $tag:station = true for orbital stations. I'm not sure persons even have them.
When/how are you setting the tag? Maybe your check needs to look at the entity rather than the person, e.g. $entity.tag:RinaFetchQuestDeliver
(but this is bad since a market can have more than one entity, you probably want to use market memory instead)

People do have tags, but, right, all good points otherwise.


In the same vein, is there a listener for a market decivilizing?

Added to my list!


            "FPE"); // faction

Could anyone help me please?

That exception there means the faction with that ID does not exist.


If I wanted to play a campaign with a much smaller sector and just a few systems with many planets/moons/bases

How would I go about creating such a sector? Is it even possible while using mods? (Nexerelin and all factions I could find from forum)

I'm looking for a small sector where systems are close together (closer than 20 days flight) with maybe 15-20 systems.

each system having enough objects (Planets/Moons/Bases) to fit the factions.

Is that even possible without heavy coding? (my knowledge is basically limited to modifying .json, not writing my own)

Some of this would require code - especially modifying core systems and what factions have what.

You could change the sector size in settings.json:
"sectorWidth":164000,
"sectorHeight":104000,

If it's small enough, it won't fit as many stars. There are some csvs (planet_gen_data.csv, star_gen_data.csv) that affect how many planets/moons etc there are and all that. But this is really a bigger discussion than this thread is great for. It's really best for more specific issues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on November 23, 2019, 01:10:00 PM
-Snip-
If I wanted to play a campaign with a much smaller sector and just a few systems with many planets/moons/bases

How would I go about creating such a sector? Is it even possible while using mods? (Nexerelin and all factions I could find from forum)

I'm looking for a small sector where systems are close together (closer than 20 days flight) with maybe 15-20 systems.

each system having enough objects (Planets/Moons/Bases) to fit the factions.

Is that even possible without heavy coding? (my knowledge is basically limited to modifying .json, not writing my own)

Some of this would require code - especially modifying core systems and what factions have what.

You could change the sector size in settings.json:
"sectorWidth":164000,
"sectorHeight":104000,

If it's small enough, it won't fit as many stars. There are some csvs (planet_gen_data.csv, star_gen_data.csv) that affect how many planets/moons etc there are and all that. But this is really a bigger discussion than this thread is great for. It's really best for more specific issues.

I figured as much, thanks :) I'll have to wait till a sector generation slider comes along in the updates *wink*
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 23, 2019, 04:48:50 PM
            "FPE"); // faction

Could anyone help me please?

That exception there means the faction with that ID does not exist.

Thanks for that! Completely forgot the faction id was in lower case.

EDIT: Dammit, now I've run into another problem.

Code
121093 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: org.json.JSONException: JSONArray[1] is not a number.
java.lang.RuntimeException: org.json.JSONException: JSONArray[1] is not a number.
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.N.dismiss(Unknown Source)
...
Caused by: org.json.JSONException: JSONArray[1] is not a number.
...

This problem appears to be probably caused by a mispelling in my economy file. I've been through the thing three times, essentially redoing some copypaste from industries.csv and market_conditions.csv, and I can't find where the problem is. While trying to debug, it appeared that the thing crashes regardless of what I remove from the file itself, so I'm not entirely sure exactly what part of the file causes the crash. The file is in the right format, the economy.json file points to this file correctly, and the entities exist in the compile code. Consequently I think I've made a basic hash of something. Could anyone lend me assistance please?

Link to the offending file here (https://bitbucket.org/King_Alfonzo/i-will-make-sindria-great-again/downloads/FPE_danube.json).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 24, 2019, 07:06:07 AM
More stupid questions - before I spawn a fleet that will raid/attack, I need a target system/market

How to get:
a) a valid random system with an asteroid field/ring
b) a valid random market

I know I can use a list of markets that will work for Corvus mode, but for random galaxy I need something else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 24, 2019, 10:38:48 AM
This problem appears to be probably caused by a mispelling in my economy file.
What leads you to believe that's the case? I didn't see anything wrong with it either, although it's certainly possible that we're both overlooking something. That error makes it look like there's something wrong with a list of numbers in a json file though, which your economy file doesn't (and afaik shouldn't) contain.

How to get:
a) a valid random system with an asteroid field/ring
b) a valid random market
Using these collections you should be able to fill a WeightedRandomPicker or other collection with systems or markets that meet your criteria:
Code: java
Global.getSector().getEconomy().getMarketsCopy();
Global.getSector().getStarSystems();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 24, 2019, 02:51:49 PM
How can I make the drones spawned by a shipsystem stop where they are spawned? I tried setting their acceleration to 0 while leaving a good deceleration, but the only thing that happens is they keep floating away in the direction of the mothership's velocity when they spawned...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 24, 2019, 03:33:05 PM
This problem appears to be probably caused by a mispelling in my economy file.
What leads you to believe that's the case? I didn't see anything wrong with it either, although it's certainly possible that we're both overlooking something. That error makes it look like there's something wrong with a list of numbers in a json file though, which your economy file doesn't (and afaik shouldn't) contain.

In the log the last thing to load is the economy file, and then the game crashes. Knowing my luck there's probably some hidden character in there causing me grief from copy-pasting from a csv.

Also I'm not sure that weighted picker for Trashman would get systems with rings in them, wouldn't you need to also determine if the system had a ring with asteroids?

How can I make the drones spawned by a shipsystem stop where they are spawned? I tried setting their acceleration to 0 while leaving a good deceleration, but the only thing that happens is they keep floating away in the direction of the mothership's velocity when they spawned...

For that you need to 'fix' where the drone is in the system rather than the drone's acceleration. I suggest you look up the beholder's shipsystem in Ship and Weapon Pack by DarkRevanant, which shows how the drones are placed. It should be simple to just set a lot of these values to 0 to get what you want.

Also you will want the drone to have a high acceleration and speed so that it'll consistently stay where it's supposed to, instead of trailing behind the ship if it ends up getting whacked at high speed.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 24, 2019, 03:53:45 PM
For that you need to 'fix' where the drone is in the system rather than the drone's acceleration. I suggest you look up the beholder's shipsystem in Ship and Weapon Pack by DarkRevanant, which shows how the drones are placed. It should be simple to just set a lot of these values to 0 to get what you want.

Also you will want the drone to have a high acceleration and speed so that it'll consistently stay where it's supposed to, instead of trailing behind the ship if it ends up getting whacked at high speed.
Ah, sorry, I meant that I want to drones to stay where they are spawned and not follow the ship or move anywhere at all. Like dropping mines or something similar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on November 24, 2019, 11:55:33 PM
Ah, sorry, I meant that I want to drones to stay where they are spawned and not follow the ship or move anywhere at all. Like dropping mines or something similar.

Then try speed 0, with acceleration and decelleration set to maximum, see if that does it.

I've redone my economy file by hand from the bottom up, and still no dice. I have no clue what has gone wrong. Here's a longer take of the log, maybe that might make things clearer?

Code
118171 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\DIABLEAVIONICS (data\campaign\econ/diableavionics_fob.json)]
118174 [Thread-4] INFO  com.fs.starfarer.campaign.econ.A  - Loading star system: diableavionics_outerTerminus.json
118181 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\DIABLEAVIONICS (data\campaign\econ/diableavionics_outerTerminus.json)]
118185 [Thread-4] INFO  com.fs.starfarer.campaign.econ.A  - Loading star system: FPE_danube.json
118188 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\FPE (data\campaign\econ/FPE_danube.json)]
118206 [Thread-8] INFO  sound.oo0O  - Cleaning up music with id [miscallenous_main_menu.ogg]
118688 [Thread-10] INFO  sound.oo0O  - Creating streaming player for music with id [miscallenous_main_menu.ogg]
118689 [Thread-10] INFO  sound.null  - Playing music with id [miscallenous_main_menu.ogg]
118963 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: org.json.JSONException: JSONArray[1] is not a number.
java.lang.RuntimeException: org.json.JSONException: JSONArray[1] is not a number.
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.N.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.json.JSONException: JSONArray[1] is not a number.
at org.json.JSONArray.getDouble(JSONArray.java:249)
at com.fs.starfarer.campaign.econ.A.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.A.o00000(Unknown Source)
... 14 more

Link to the file here, again. (https://bitbucket.org/King_Alfonzo/i-will-make-sindria-great-again/downloads/FPE_danube.json)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 25, 2019, 12:09:16 AM
Then try speed 0, with acceleration and decelleration set to maximum, see if that does it.
Unfortunately, it doesn't work. What seems to happen is that the drones snap into their orbits (and jittering quite a bit probably because I set their accel to 99999). Setting accel and decel at a reasonable 50 while setting top speed to 0 has no effect either - they just continue to follow their orbits as normal.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 25, 2019, 08:34:53 AM
Hmm, if that's all you need, maybe something like this in your ModPlugin implementation, to provide a custom drone AI that doesn't do anything except stop?

Code
	public PluginPick<ShipAIPlugin> pickDroneAI(final ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system) {
if (<not your drone>) return null;
return new PluginPick<ShipAIPlugin>(new ShipAIPlugin() {
ShipwideAIFlags flags = new ShipwideAIFlags();
public void forceCircumstanceEvaluation() {
}
public void advance(float amount) {
drone.giveCommand(ShipCommand.DECELERATE, null, 0);
}
public void setDoNotFireDelay(float amount) {

}
public boolean needsRefit() {
return false;
}
public ShipwideAIFlags getAIFlags() {
return flags;
}
public void cancelCurrentManeuver() {

}
public ShipAIConfig getConfig() {
return null;
}
}, PickPriority.MOD_SPECIFIC);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 25, 2019, 09:06:14 AM
How to get:
a) a valid random system with an asteroid field/ring
b) a valid random market
Using these collections you should be able to fill a WeightedRandomPicker or other collection with systems or markets that meet your criteria:
Code: java
Global.getSector().getEconomy().getMarketsCopy();
Global.getSector().getStarSystems();

I hate to ask for more spoonfeeding, but can you be more specific? Examples do more than a thousand words. Looking at Starfarer API doesn't help at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 25, 2019, 11:10:42 AM
Sure, so you'll probably want to do something like this:
Code: java
	static final Set<String> VALID_TERRAIN_FEATURES = new HashSet<>();
static {
VALID_TERRAIN_FEATURES.add(Terrain.ASTEROID_BELT);
VALID_TERRAIN_FEATURES.add(Terrain.RING);
}
StarSystemAPI chooseRandomRingSystem() {
Random random = new Random();
WeightedRandomPicker<StarSystemAPI> eligibleSystems = new WeightedRandomPicker<>(random);

for(StarSystemAPI system : Global.getSector().getStarSystems()) {
int validTerrainCount = 0;

for(CampaignTerrainAPI terrain : system.getTerrainCopy()) {
if(VALID_TERRAIN_FEATURES.contains(terrain.getType())) {
validTerrainCount += 1;
}
}

if(validTerrainCount > 0) {
eligibleSystems.add(system, validTerrainCount);
}
}

return eligibleSystems.pick(random);
}
I haven't tested this method, and I'm sure you'll need to make a lot of changes to get it working the way you want, but it should choose a random system with at least one belt or ring. The more belts or rings a system has, the more likely it will be chosen. You can do the same type of thing with markets. The difficult part about things like this is making sure you don't choose something you shouldn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on November 25, 2019, 12:02:03 PM
Thankings you muchly!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 25, 2019, 06:35:35 PM
Hmm, if that's all you need, maybe something like this in your ModPlugin implementation, to provide a custom drone AI that doesn't do anything except stop?

Code
	public PluginPick<ShipAIPlugin> pickDroneAI(final ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system) {
if (<not your drone>) return null;
return new PluginPick<ShipAIPlugin>(new ShipAIPlugin() {
ShipwideAIFlags flags = new ShipwideAIFlags();
public void forceCircumstanceEvaluation() {
}
public void advance(float amount) {
drone.giveCommand(ShipCommand.DECELERATE, null, 0);
}
public void setDoNotFireDelay(float amount) {

}
public boolean needsRefit() {
return false;
}
public ShipwideAIFlags getAIFlags() {
return flags;
}
public void cancelCurrentManeuver() {

}
public ShipAIConfig getConfig() {
return null;
}
}, PickPriority.MOD_SPECIFIC);
}
Thank you very much Alex, this worked perfectly!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 26, 2019, 08:18:02 AM
So if I were to do something crazy like this:
Code
    public void applyEffectsBeforeShipCreation(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats, String id) {
            stats.getHighExplosiveShieldDamageTakenMult().modifyMult(id, 4);
            stats.getKineticShieldDamageTakenMult().modifyMult(id, 0);
    }
How much awareness would the AI have that it should fire HE at that ship's shields rather than kinetic? I feel like the answer was "none" long ago, but I was hoping that might've changed.


Thankings you muchly!
No problem  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 26, 2019, 08:32:10 AM
Yeah, the answer is "none", unfortunately. It's aware of shield efficiency and base vs-shields damage type modifiers, but not modifiers to those modifiers. Even if it were, that'd be another step to something that's qualitatively different than a change by some smaller percentage. Autofiring weapons are not aware of either (since it's not the individual weapon's job to decide), and the ship AI will largely just let stuff autofire while it feels it has flux to burn. There are other considerations there, but none of them are damage type modifiers vs a particular target.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 26, 2019, 08:52:12 AM
Ok, gotcha. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nerzhull_AI on November 26, 2019, 02:50:37 PM
In vanilla settings.json, at plugins section, there's following lines:
Code
"newGameCreationEntryPoint":"data.scripts.world.SectorGen",
"newGameSectorProcGen":"com.fs.starfarer.api.impl.campaign.procgen.SectorProcGen",

My mod should override SectorProcGen and SectorGen. In mod's setting file i've put following lines:
Code
"plugins":{        
        "newGameSectorProcGen":"data.scripts.SectorProcGenMod",
        "newGameCreationEntryPoint":"data.scripts.world.SectorGenMod",
    },
It works for SectorProcGenMod, but doesn't for SectorGenMod. Why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 26, 2019, 04:18:39 PM
Are any other mods enabled? If multiple mods try to override a plugin this way the results are undefined (in practice, they depend on mod load order).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 26, 2019, 09:28:51 PM
How can you check if a ship currently has the zero flux boost? I'd check if flux == 0 but there are some boosts that make it not actually 0.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nerzhull_AI on November 27, 2019, 04:19:29 AM
Are any other mods enabled? If multiple mods try to override a plugin this way the results are undefined (in practice, they depend on mod load order).
There shouldn't be, but i'll double-check. Thanks for the advice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 27, 2019, 08:41:50 AM
How can you check if a ship currently has the zero flux boost? I'd check if flux == 0 but there are some boosts that make it not actually 0.
So I haven't tested it and there isn't any documentation to confirm that it does what I think it does, but this should do the trick:
Code: java
ship.getFluxTracker().isEngineBoostActive()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on November 27, 2019, 03:29:46 PM
Since ammo recharging is kind of a gimmick with a lot of Shadowyards weapons I've been planning on introducing a hullmod that boosts this recharge rate; unfortunately as I started trying to implement it it became clear that straightforward mechanisms for this don't seems to be present, at least not through MutableShipStats. It's already been requested through the API request thread but doesn't seem to have been implemented yet; as such I figured I may as well ask if anyone has any suggestions for an alternate implementation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 27, 2019, 06:02:24 PM
In the .proj files, what is the difference between the missileTypes "BOMB_WITH_SLOW" and "BOMB"?
Also how do i make the bombs not explode for the first few seconds? armingTime? or is there another tag that influences it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 27, 2019, 06:12:55 PM
Also how do i make the bombs not explode for the first few seconds? armingTime? or is there another tag that influences it?
I can attest that setting arming time makes bombs (and missiles) not explode. For example, this is the code I used to make my chainmine roller not explode ever:
Code
        missile.setArmingTime(999999f);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on November 27, 2019, 06:50:59 PM
Also how do i make the bombs not explode for the first few seconds? armingTime? or is there another tag that influences it?
I can attest that setting arming time makes bombs (and missiles) not explode. For example, this is the code I used to make my chainmine roller not explode ever:
Code
        missile.setArmingTime(999999f);
will collision with enemy ships trigger it? i want to make a projectile that spawns mines on impact, but the mines i spawn detonate instantly because they are also colliding with the target (right now my solution is to spawn them a bit before the target, but doesn't look nice)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on November 27, 2019, 10:32:33 PM
Back to variant questions! Is there anything special that needs to be done to set a module variant? The following code throws me no errors when called, but also does no changes:
Code: java
        //get variant and clone it for changes
        ShipVariantAPI variantClone = mothership.getVariant().clone();
        if (DEBUG) LOGGER.info("Insert: VariantClone name: " + variantClone.getDisplayName());
        variantClone.setSource(VariantSource.REFIT);//needed for saving correctly

        //check master copy of new module first, so we thrown error (return) before shifting
        ShipVariantAPI newModuleClone = Global.getSettings().getVariant(moduleID);//not a clone yet
        //if null, print error message and return
        if (newModuleClone == null) {
            if (DEBUG) LOGGER.info("Couldn't find module to get a master copy! ModuleID: " + moduleID);
            return;
        }
        //make it a clone!
        newModuleClone = newModuleClone.clone();

       //now add new one
        String slotID = IDs.MSLOT_PREFIX + String.valueOf(moduleIndex);
        if (DEBUG) LOGGER.info("Insert: Exitted loop, adding new module. slotID: " + slotID);
        if (DEBUG) LOGGER.info("newModuleDlone name: " + newModuleClone.getDisplayName());
        variantClone.setModuleVariant(slotID,newModuleClone);

        //variantClone done, set it
        mothership.setVariant(variantClone, false, false);

Debug messages are coming back as they should, and I double checked that the module slots in the .ship file are named correctly (in this case 'MS_0'). If it matters, the module slots are currently empty.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: craftomega on November 28, 2019, 12:45:14 PM
Is there any way to reduce the amount of faction rep you lose when you attack a fleet when your transponder is off?

Also when you defeat expeditions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on November 28, 2019, 03:49:34 PM
I tried adding some luxury commodities, but there seems to be a bug with the player selling them off to a different planet for a large price, but then being able to buy them for a lower price (effectively making an infinite money loop). I tried copying data from other mods that add commodities but it seems the error was not fixed. Am I missing something to prevent this?

Here is the data for the commodities - the values are copied off HMI's crystals, I believe (with minor edits).

(https://i.ibb.co/dbmGkvf/dbg1.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2019, 10:48:28 AM
will collision with enemy ships trigger it?

I won't, any impact during the arming time will make it collide with the ship and bounce around.

If it matters, the module slots are currently empty.

I'm fairly sure that's the issue. Didn't dig around in the code but I seem to remember that being a requirement - well, either that, or this may be a special case of "modules in the same slot must have the same hull id when the variant in the slot is changed".  Put another way, modules aren't *that* modular; different hulls can't be plugged in at will. Either way, it's definitely worth trying it starting out with the stock variant having empty modules in the slots.


Is there any way to reduce the amount of faction rep you lose when you attack a fleet when your transponder is off?

Also when you defeat expeditions?

For the former, you could provide your own implementation of a ReputationActionResponsePlugin using CampaignPlugin.pickReputationActionResponsePlugin().

For the latter, you can modify PunitiveExpeditionIntel.REP_PENALTY in your ModPlugin.onApplicationLoad() or some such.


I tried adding some luxury commodities, but there seems to be a bug with the player selling them off to a different planet for a large price, but then being able to buy them for a lower price (effectively making an infinite money loop). I tried copying data from other mods that add commodities but it seems the error was not fixed. Am I missing something to prevent this?

Nothing looks immediately wrong, hmm. I just tried it with lobsters at several markets (with/without luxury goods demand) and there as no issue, so probably something *is* missing but I'm not sure what.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 29, 2019, 03:54:54 PM
Hello is there a method to mess with the cycle date? Like maybe.. somewhere before 207...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2019, 04:13:52 PM
See CampaignClockAPI.getCal().set(...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 29, 2019, 04:22:37 PM
Since ammo recharging is kind of a gimmick with a lot of Shadowyards weapons I've been planning on introducing a hullmod that boosts this recharge rate; unfortunately as I started trying to implement it it became clear that straightforward mechanisms for this don't seems to be present, at least not through MutableShipStats. It's already been requested through the API request thread but doesn't seem to have been implemented yet; as such I figured I may as well ask if anyone has any suggestions for an alternate implementation.

I messed with this idea a while back. Long and short of it is I don't think that value is exposed anywhere. I am nowhere even close to the best coder on this forum though. Just figured I'd say I tried and met no success.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on November 29, 2019, 10:32:11 PM
does anyone know where i can get old starfarer releases - 0.34, 0.35 and the first alpha
blogpost download links are dead, they give me a 404 error
http://fractalsoftworks.com/tag/release/page/5/
i kinda want to look at old sprites and whatnot
to see where it all began.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on November 30, 2019, 06:57:07 AM
No idea where you could get versions that old. Oldest one I have is 0.6.2

Since ammo recharging is kind of a gimmick with a lot of Shadowyards weapons I've been planning on introducing a hullmod that boosts this recharge rate; unfortunately as I started trying to implement it it became clear that straightforward mechanisms for this don't seems to be present, at least not through MutableShipStats. It's already been requested through the API request thread but doesn't seem to have been implemented yet; as such I figured I may as well ask if anyone has any suggestions for an alternate implementation.
Well, you could always modify ammo manually with myWeapon.setAmmo(), but that might get complicated/bug-prone depending on what you want to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 02, 2019, 07:58:47 PM
How can I add custom combat messages on the textbox that appears at the top left of the screen during combat? I'd like to show event updates during a mission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 02, 2019, 08:43:01 PM
You can do that with the CombatUIAPI (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/CombatUIAPI.html), which can be accessed through the combat engine. e.g. Global.getCombatEngine().getCombatUI().addMessage()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 02, 2019, 08:57:11 PM
You can do that with the CombatUIAPI (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/CombatUIAPI.html), which can be accessed through the combat engine. e.g. Global.getCombatEngine().getCombatUI().addMessage()
Thanks for the quick reply! It worked!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on December 04, 2019, 12:17:25 PM
Can module weapon slots, image, etc be changed dynamically?

I've tried skin files and they also fail, so I think the answer is "no", unless I want to make actual .variant files for each combination of modules (which is impractical as there are hundreds).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 04, 2019, 12:57:38 PM
Yeah, as I remember, module slots are limited to the specific hull type that's in the original variant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on December 04, 2019, 04:59:21 PM
Ahh, darn! Thanks for confirming! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 05, 2019, 09:45:23 PM
Can't remember, is the standard recovery chance 50% or lower than that?


Actually, just want to make sure this does what I think it does because it would be difficult to test:

Code

    public static final float RECOVER_CHANCE = 0.75f;


public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

if (stats.getEntity() != null && stats.getEntity().getOwner() != 0) {
stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyMult(id, RECOVER_CHANCE);
}
}


Should reduce the chance to recover by 25% right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mipen on December 06, 2019, 03:55:18 AM
Is it possible to increase the number of blueprints that are dropped from ruins and salvaged structures?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 06, 2019, 03:41:00 PM
Should reduce the chance to recover by 25% right?

Correct!

Is it possible to increase the number of blueprints that are dropped from ruins and salvaged structures?

In theory, yes, but I think that'd involve providing your own copy of MarketCMD (and changing the relevant rules that call it), so it's a decent bit of work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 07, 2019, 03:17:44 PM
Is there a way to limit the use of specific LPCs via a hullmod? I've tried to go through the equipped fighters and then setting their stats by either one of

Code
           		ship.getVariant().getWing(i).setNumFighters(3);
            ship.getVariant().getWing(i).setOpCost(14);

But it seems this code changes the fighter spec for the entire game and not just the ship. I also can't go the converted hangar route because

Code
		stats.getDynamic().getMod(Stats.BOMBER_COST_MOD).modifyPercent(id, BOMBER_COST_PERCENT);
stats.getDynamic().getMod(Stats.FIGHTER_COST_MOD).modifyPercent(id, ALL_FIGHTER_COST_PERCENT);
stats.getDynamic().getMod(Stats.INTERCEPTOR_COST_MOD).modifyPercent(id, ALL_FIGHTER_COST_PERCENT);
stats.getDynamic().getMod(Stats.SUPPORT_COST_MOD).modifyPercent(id, ALL_FIGHTER_COST_PERCENT);

...these will affect a bunch of other ships.

Actually, would it be possible to add a custom category to these -> Stats.BOMBER_COST_MOD? And I could set the LPCs to that category and modify their costs this way.

Or if there's an easier method that I'm unaware of, I'd love to hear it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 07, 2019, 04:21:17 PM
Correct!

Thank you!  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 07, 2019, 07:18:19 PM
Is there a way to limit the use of specific LPCs via a hullmod?
I don't think there are any ideal ways to do so, but Ed was asking a similar question a while ago, so you might be interested in reading: http://fractalsoftworks.com/forum/index.php?topic=5061.msg261097#msg261097

Actually, would it be possible to add a custom category to these -> Stats.BOMBER_COST_MOD? And I could set the LPCs to that category and modify their costs this way.
Maybe. It would be really cool if it worked, but I expect the way those stats are applied is hard-coded in a way that doesn't take non-vanilla LPC categories into account. Still, it's worth a try.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 07, 2019, 09:50:21 PM
In the next release, there's FighterOPCostModifier (and one for weapons) that can be added via MutableShipStatsAPI.addListener() and allow for arbitrary OP cost modification based on the specific fighter passed in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 07, 2019, 10:02:53 PM
In the next release, there's FighterOPCostModifier (and one for weapons) that can be added via MutableShipStatsAPI.addListener() and allow for arbitrary OP cost modification based on the specific fighter passed in.
Ooh! This is great to hear! I guess I'll just hold out till then.

Edit:
And I actually have a different question now - is there a way to make a single fighter return to its mothership? I'm thinking of a hullmod that makes a fighter retreat if it suffers a certain amount of hull damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 08, 2019, 06:46:28 AM
If a route-spawned fleet takes losses in combat, is this reflected anywhere in the route data at all? Neither OptionalFleetData.fp nor OptionalFleetData.damage are being updated in my RouteFleetSpawner implementation.

What about when two hostile routes meet in a location while player isn't nearby, is any combat simulated between them (or with local non-abstracted fleets)?

(What I'm trying to do: a persistent route-based fleet that flies around joining raids against hostile systems, or defending against raids on friendly systems, or simply patrols friendly systems. If it takes enough losses, it goes to a faction-held market to replace lost ships with new ones. The route is never actually terminated unless its FP drops to zero, or certain (currently undetermined) conditions are met).

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2019, 10:08:12 AM
And I actually have a different question now - is there a way to make a single fighter return to its mothership? I'm thinking of a hullmod that makes a fighter retreat if it suffers a certain amount of hull damage.

See: FighterWingAPI.orderReturn(ShipAPI fighter)

If a route-spawned fleet takes losses in combat, is this reflected anywhere in the route data at all? Neither OptionalFleetData.fp nor OptionalFleetData.damage are being updated in my RouteFleetSpawner implementation.

It's not reflected anywhere. However, there is an OptionalFleetData.damage field - which is *only* used in WarSimScript.getFactionStrength(). So if one wanted to, one could have their route-spawned fleet store the level of damage (i.e. losses taken) in that value, use it when spawning (or re-spawning) the fleet, and its strength would vary accordingly for the various strength checks used for resolving not-near-the-player events.

I don't know if I'd recommend it, though - if you try to spawn a fleet using the same random seed but less fleet points, it'd likely end up being a very different fleet. Using the damage field would make more sense for fleets that have never actually spawned.

However, none of the vanilla fleets will use the damage field when spawning, so this would only work for routes where both the spawning and taking damage aspect of this is used. I.E. you couldn't hurt an existing patrol fleet route by setting its OptionalFleetData.damage - or, rather, it would affect it for strength checks, but not for when it was spawned due to being near the player.

What about when two hostile routes meet in a location while player isn't nearby, is any combat simulated between them (or with local non-abstracted fleets)?

No. Route fleets used for strength checks which can affect things like, say, the outcome of a raid, but don't actually affect the routes themselves.

(What I'm trying to do: a persistent route-based fleet that flies around joining raids against hostile systems, or defending against raids on friendly systems, or simply patrols friendly systems. If it takes enough losses, it goes to a faction-held market to replace lost ships with new ones. The route is never actually terminated unless its FP drops to zero, or certain (currently undetermined) conditions are met).

The "damage" field sounds like it'd work for your case, I think. Except for the part where if it despawns and respawns again, the ships would be different.

Btw, you should be able to force a route to end by setting the current segment to null and by clearing the segments, i.e.:

route.setCurrent(null);
route.getSegments().clear();

Should do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 08, 2019, 01:47:38 PM
FighterWingAPI.orderReturn(ShipAPI fighter)

Thanks for pointing this out, but I have a follow up question regarding this - is it possible to retrieve the FIghterWingAPI from the fighter and not the mothership? I would like the hullmod to be on the fighter, so it would take effect no matter which ship it is mounted.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2019, 02:16:35 PM
ShipAPI.getWing(), iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 08, 2019, 03:30:15 PM
ShipAPI.getWing(), iirc.
Again, thank you very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2019, 03:50:55 PM
No problem :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 09, 2019, 07:43:15 PM
Two questions:
1. Will Global.getSector().getCampaignUI().isFollowingDirectCommand() only return false when the autopilot for "lay in course" is active? Is there some other reliable way to find out if autopilot is on?
2. Is there a way to find out which key is bound to a command? Failing that, is there a way to tell when the player is slowing down their fleet even if they've rebound to something other than S?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 09, 2019, 08:17:01 PM
1) I think so, yes. If isFollowingDirectCommand() returns false, autopilot becomes suspended. So, if you check that
Global.getSector().getUIData().getCourseTarget() (I think this is in the current API? not 100% sure) and then check that it's not following a direct command, then autopilot is on.

2) Hmm - SettingsAPI.getControlStringForEnumName("GO_SLOW") will return the string.

In the next release, there'll be:

Misc.isSlowMoving(fleet)

Which returns true if a fleet is slow-moving, which is a "status" which is used for several things (avoiding collisions with asteroids, etc).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 09, 2019, 08:22:05 PM
Excellent. Thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 10, 2019, 02:24:00 AM
If a route-spawned fleet takes losses in combat, is this reflected anywhere in the route data at all? Neither OptionalFleetData.fp nor OptionalFleetData.damage are being updated in my RouteFleetSpawner implementation.

It's not reflected anywhere. However, there is an OptionalFleetData.damage field - which is *only* used in WarSimScript.getFactionStrength(). So if one wanted to, one could have their route-spawned fleet store the level of damage (i.e. losses taken) in that value, use it when spawning (or re-spawning) the fleet, and its strength would vary accordingly for the various strength checks used for resolving not-near-the-player events.

I don't know if I'd recommend it, though - if you try to spawn a fleet using the same random seed but less fleet points, it'd likely end up being a very different fleet. Using the damage field would make more sense for fleets that have never actually spawned.

However, none of the vanilla fleets will use the damage field when spawning, so this would only work for routes where both the spawning and taking damage aspect of this is used. I.E. you couldn't hurt an existing patrol fleet route by setting its OptionalFleetData.damage - or, rather, it would affect it for strength checks, but not for when it was spawned due to being near the player.

What about when two hostile routes meet in a location while player isn't nearby, is any combat simulated between them (or with local non-abstracted fleets)?

No. Route fleets used for strength checks which can affect things like, say, the outcome of a raid, but don't actually affect the routes themselves.
Thanks for clearing that up!
Although I have to say, not recording damage looks it leads to some obvious (albeit minor) issues. Two that come readily to mind (I've encountered at least one personally):
(Anyway, for my current use, I'm currently accepting the fact that the fleet composition can change wildly when recreated after taking damage.
If enough people notice it and get weirded out enough to mention it, I could make the fleets never despawn once spawned by the route manager, although I'm afraid that risks consuming a lot of memory and save file space given how many fleets the player might encounter and how big they'll be)


Other related question: I seem to recall debris and derelict ships being present in star systems with ongoing raids, when the player visits them. Is there some vanilla code that generates them, or am I just completely misremembering things?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2019, 03:03:44 PM
Thanks for clearing that up!
Although I have to say, not recording damage looks it leads to some obvious (albeit minor) issues. Two that come readily to mind (I've encountered at least one personally):
  • If the player intercepts a raid fleet short of its target and damages it, then flees elsewhere, one would expect the raid's autoresolve strength to be weakened as a result, but it isn't.
  • If the player encounters raid fleets returning to base after a failed raid, they'll be at full strength when one expects them not to be.

Fair! Not sure it's worth the complications, but, well, will keep that in mind. It's a bit of work to make everything record and respect the "damage" parameter and it just makes certain things that are already fairly messy (such as the aforementioned raids) messier.

Other related question: I seem to recall debris and derelict ships being present in star systems with ongoing raids, when the player visits them. Is there some vanilla code that generates them, or am I just completely misremembering things?

IIRC that's just from fights that happen after the fleets spawn-in due to the player approaching.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 12, 2019, 11:44:46 PM
Hmm, if that's all you need, maybe something like this in your ModPlugin implementation, to provide a custom drone AI that doesn't do anything except stop?

Code
	public PluginPick<ShipAIPlugin> pickDroneAI(final ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system) {
if (<not your drone>) return null;
return new PluginPick<ShipAIPlugin>(new ShipAIPlugin() {
ShipwideAIFlags flags = new ShipwideAIFlags();
public void forceCircumstanceEvaluation() {
}
public void advance(float amount) {
drone.giveCommand(ShipCommand.DECELERATE, null, 0);
}
public void setDoNotFireDelay(float amount) {

}
public boolean needsRefit() {
return false;
}
public ShipwideAIFlags getAIFlags() {
return flags;
}
public void cancelCurrentManeuver() {

}
public ShipAIConfig getConfig() {
return null;
}
}, PickPriority.MOD_SPECIFIC);
}
Thank you very much Alex, this worked perfectly!
Going back to this, I finally had some time to test it a bit and realized it made the drone really do nothing but stop. It doesn't even fire or track its target. All of that AI being a bit over my head, is it possible to retain all default AI functions and only override its movement?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 13, 2019, 09:05:51 AM
Hmm, not sure what else to suggest then, beyond expanding the custom AI to handle some basic firing. Keeping the standard drone AI means it'll move the way you don't want it to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on December 13, 2019, 12:03:55 PM
Hello, I haven't been modding Starsector since a very long time, and I'm stuck with some weapon script.
The goal is to make some gatlings spoolup to reach their maximal firerate, starting by firing at a fraction of the final deal.
I'm using Intellij and the compiler doesn't find any mistakes when compiling.
I end up with a error that I mainly see when I made typos in plugins or files names or IDs, but I checked everything multiple times without any succes at troubleshooting this.
Here's the log :
Spoiler
Code
40164 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException: data.scripts.weapons.SCQ_GatlingSpoolUp cannot be cast to com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin
java.lang.ClassCastException: data.scripts.weapons.SCQ_GatlingSpoolUp cannot be cast to com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin
at com.fs.starfarer.loading.specs.BaseWeaponSpec.getEveryFrameEffect(Unknown Source)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.O0oO.<init>(Unknown Source)
at com.fs.starfarer.loading.specs.oooo.super(Unknown Source)
at com.fs.starfarer.loading.specs.oooo.super(Unknown Source)
at com.fs.starfarer.coreui.refit.A.updateFromCurrentVariant(Unknown Source)
at com.fs.starfarer.coreui.refit.A.syncWithVariant(Unknown Source)
at com.fs.starfarer.coreui.refit.C.syncWithVariant(Unknown Source)
at com.fs.starfarer.coreui.refit.W.syncWithCurrentVariant(Unknown Source)
at com.fs.starfarer.coreui.refit.W.syncWithCurrentVariant(Unknown Source)
at com.fs.starfarer.coreui.refit.A.fitWeaponIfPossible(Unknown Source)
at com.fs.starfarer.coreui.refit.A.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.Oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
at com.fs.starfarer.coreui.refit.WeaponPickerDialog.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.k.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.oooO.new(Unknown Source)
at com.fs.starfarer.ui.oooO.processInput(Unknown Source)
at com.fs.starfarer.ui.k.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.e$Oo.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.e.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.O0OO.oooO.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.Oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInputImpl(Unknown Source)
at com.fs.starfarer.coreui.refit.WeaponPickerDialog.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.Oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.newui.J.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.interface.processInput(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.processInput(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

And this is my attempt at making this plugin :
Spoiler
Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.loading.WeaponSpecAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.MathUtils;
import org.lwjgl.util.vector.Vector2f;

public class SCQ_GatlingSpoolUp implements EveryFrameWeaponEffectPlugin {

    private CombatEngineAPI engine;
    private static final String DATA_KEY = "SCQ_Gatling";
    private static String weaponSound = "";
    private static String weaponProjectile = "";
    private static final String SMALL_SHOT_ID = "small_gatling_shot";
    private static final String MEDIUM_SHOT_ID = "medium_gatling_shot";
    private static final String LARGE_SHOT_ID = "large_gatling_shot";
    private float charge = 0f;
    private float modifier = 0f;
    private float startingDelay = 0f;
    private float delayDecrement = 0f;
    private float lastDelay = 0f;
    private float finalDelay = 0f;
    private float minSpread = 0;
    private float maxSpread = 0;
    private boolean runOnce = false;
    private IntervalUtil fireInterval;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        if (this.engine == null) {
            return;
        }
        if (this.engine.isPaused()) {

            return;
        }

        WeaponAPI.WeaponSize size = weapon.getSize();

        if (!runOnce) {
            runOnce = true;
            modifier = 1f;
            switch (size){
                case SMALL:
                    startingDelay = 30f;
                    delayDecrement = 3f;
                    finalDelay = 3f;
                    weaponSound = "small_gatling_fire";
                    weaponProjectile = SMALL_SHOT_ID;
                    minSpread = 2f;
                    maxSpread = 6f;
                    break;
                case MEDIUM:
                    startingDelay = 40f;
                    delayDecrement = 3f;
                    finalDelay = 4f;
                    weaponSound = "medium_gatling_fire";
                    weaponProjectile = MEDIUM_SHOT_ID;
                    minSpread = 2f;
                    maxSpread = 5f;
                    break;
                case LARGE:
                    startingDelay = 50f;
                    delayDecrement = 3f;
                    finalDelay = 5f;
                    weaponSound = "large_gatling_fire";
                    weaponProjectile = LARGE_SHOT_ID;
                    minSpread = 1.5f;
                    maxSpread = 4.5f;
                    break;
                default:
                    return;
            }
            fireInterval = new IntervalUtil(0f, startingDelay);
        }

        ShipAPI ship = weapon.getShip();
        if (ship != null) {
                modifier = ship.getMutableStats().getBallisticRoFMult().getModifiedValue();
            }

            charge = weapon.getChargeLevel();
            if (charge > 0f) {
                lastDelay = fireInterval.getMaxInterval();
                fireInterval.advance(amount);
                if (fireInterval.intervalElapsed()) {
                    float spread = MathUtils.getRandomNumberInRange(minSpread, maxSpread);
                    Global.getSoundPlayer().playSound(weaponSound, 1f, 1f, weapon.getLocation(), ship.getVelocity());
                    engine.spawnProjectile(
                            ship,
                            weapon,
                            weapon.getId(),
                            weaponProjectile,
                            weapon.getLocation(),
                            weapon.getArcFacing(),
                            new Vector2f(weapon.getProjectileSpeed(), spread));
                    if (lastDelay > (finalDelay * modifier)) {
                        lastDelay -= delayDecrement;
                    }
                    fireInterval = new IntervalUtil(0f, lastDelay);
                }
            } else {
                lastDelay = fireInterval.getMaxInterval();
                if (lastDelay < (finalDelay * modifier)) {
                    lastDelay += (delayDecrement * 1.5f);
                }
            }
        }
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 13, 2019, 12:15:13 PM
Nothing jumps out as being wrong (though I could be missing something), so my guess is "Janino doesn't like something about this so doesn't actually manage to compile it". Suggestions: add a default constructor to the class (helps sometimes), or (more recommended) compile this into a jar and provide that with your mod instead of having the game try to compile it on startup.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 13, 2019, 04:13:15 PM
Hmm, not sure what else to suggest then, beyond expanding the custom AI to handle some basic firing. Keeping the standard drone AI means it'll move the way you don't want it to.
Hmm... I see, is there a sort of code sample I could take a look at to implement aiming a weapon and firing it? I've never actually visited this corner of the API before...

And I have another, different question -  how does one give commands to single fighters (i.e. spawned via code using engine.getFleetManager(owner).spawnFleetMember())? I'm aware of how to give commands to bigger ships via fleetManager.getTaskManager(false), but am unsure if the same would work for commanding fighters.

Also, how would they behave once their ammo was depleted, if they were set as bombers? If there was a command to make them retreat, where would they go? Would their behavior be similar to fighters whose motherships had retreated? (i.e. they bunch up at your edge of the map)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 13, 2019, 06:13:39 PM
Code
	public void onApplicationLoad() throws Exception {
                boolean hasLazyLib = Global.getSettings().getModManager().isModEnabled("lw_lazylib");
                JSONObject tips = Global.getSettings().loadJSON( "tips.json" );
                JSONArray maxTips = tips.getJSONArray("tips");
                for (int i = 0; i < maxTips.length(); i++) {
                    System.out.println(i);
                    System.out.println(maxTips.get(i));
                }
}
I'm having trouble with trying to load tips.json from the strings folder. Is there not a method to retrieve this from or am I doing something wrong? I'd like to make a mod to add certain tips when a mod like LazyLib is enabled.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 14, 2019, 01:38:50 AM
Pretty sure you need the full subpath, i.e. "data/strings/tips.json"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on December 14, 2019, 03:45:50 AM
Quote
compile this into a jar and provide that with your mod instead of having the game try to compile it on startup.

It's actually a .jar file compiled by Intellij IDEA, but I'm pretty sure it's a dumb mistake since even when the plugin is "empty" (i.e nothing actually coded inside), the game crash when loading it.
I need to do some cleanup because the rest of the mod is somewhat of a mess before sending it, I made a lot of copy for the weapons using this plugin, and I tried to achieve the same effect with different methods (using a Beam and a BeamEffect instead of EveryFrameWeaponEffect, forcing the cooldown to arbitrary values after each real fire to change the firerate but without any more success. The only luck I had was at the beginning of the cooldown method, but the firerate was somewhat randomized by the script).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bopeepatehersheep on December 14, 2019, 11:26:45 PM
This isn't specifically a question about how to implement some mod idea or something of the like.

I'm wondering why there isn't a centralized thread that discusses mod balance (I've found a few threads discussing mod balance but they're old and nobody likes necros). I mean something mostly for users to look at and find out which mods are generally considered balanced in comparison with vanilla (by forum consensus of course - not any one person's opinion) and which are considered above vanilla balance (OP) or are balanced but play drastically different than vanilla.  If something of the nature already exists I'd love to know where.

I think it would be really nice to have a prominent thread where users discussed mod balance as there are so many mods that it really makes it quite a chore to personally test mods to find which ones are balanced and which are not.

I suppose it would also be a way for modders to find feedback on their mod (albeit inconveniently since it's not in their mod thread)

I've thought about making such a thread myself but my attention span is a little spotty and I also don't know if it's even a good idea. Also, thank you modders for all the amazing mods and Alex for the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 15, 2019, 10:34:25 AM
Hmm... I see, is there a sort of code sample I could take a look at to implement aiming a weapon and firing it? I've never actually visited this corner of the API before...

There's probably a mod that does this? Not sure exactly where to suggest looking, though.

And I have another, different question -  how does one give commands to single fighters (i.e. spawned via code using engine.getFleetManager(owner).spawnFleetMember())? I'm aware of how to give commands to bigger ships via fleetManager.getTaskManager(false), but am unsure if the same would work for commanding fighters.

Yeah, you can't do that, it wouldn't work. Unless they had a custom AI that was capable of carrying out commands.

Also, how would they behave once their ammo was depleted, if they were set as bombers? If there was a command to make them retreat, where would they go? Would their behavior be similar to fighters whose motherships had retreated? (i.e. they bunch up at your edge of the map)

I'm... not sure, actually. I think the typical drone AI would make them stick around unless the system was toggled to recall them. For drones, iirc the thinking is that this type of decision - when to recall drones vs when to leave them out - is up to the ship, not the drone.

Pretty sure you need the full subpath, i.e. "data/strings/tips.json"

Also I'm not sure how this would work as far as adding tips. At that point - at onApplicationLoad() - they're I think already loaded anyway. And even if they weren't, I don't think there's a way to dynamically remove them, is there? I could be forgetting one, though.



This isn't specifically a question about how to implement some mod idea or something of the like.

I'm wondering why there isn't a centralized thread that discusses mod balance ... I've thought about making such a thread myself but my attention span is a little spotty and I also don't know if it's even a good idea. Also, thank you modders for all the amazing mods and Alex for the game.

I don't know! But, in any case, thank you :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BringerofBabies on December 15, 2019, 04:19:40 PM
I think it would be really nice to have a prominent thread where users discussed mod balance as there are so many mods that it really makes it quite a chore to personally test mods to find which ones are balanced and which are not.

I suppose it would also be a way for modders to find feedback on their mod (albeit inconveniently since it's not in their mod thread)

I've thought about making such a thread myself but my attention span is a little spotty and I also don't know if it's even a good idea.

If it were focused on discussing balance of existing mods, I'd be wary of a thread like that becoming either accusatory or whiny (in the eyes of mod authors, at least). Instead, I'd suggest making a (quickly sprawling) thread about how anything and everything in vanilla is balanced, so that it can be a repository of information against which all mod authors can see balance targets in similar ships/fighters/weapons, as well as what works and doesn't work in terms of balancing particular types of things. Additionally, make it clear that mod authors are welcome to jump in with "I'm thinking of doing this - is there anything that I am missing that would make it OP/weak/not suited for the intended role?"
Of course, the major problem with a thread like that (beyond getting as many people involved/invested as possible) would be organizing the info and making it available - at some point you'd probably have to make the first post (or several, if post length is an issue) purely a table of contents for important topic summaries.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bopeepatehersheep on December 15, 2019, 08:30:45 PM
If it were focused on discussing balance of existing mods, I'd be wary of a thread like that becoming either accusatory or whiny (in the eyes of mod authors, at least). .....
yah, i'd be wary of this too.  i think in the original post that it would be good to lay down guidlelines on how to discuss mod balance - such as no personal attacks on mod authors, no offensive language or rude insinuations, general civility stuff, no discussion of transgressions mod authors have committed, no drama


Instead, I'd suggest making a (quickly sprawling) thread about how anything and everything in vanilla is balanced, so that it can be a repository of information against which all mod authors can see balance targets in similar ships/fighters/weapons, as well as what works and doesn't work in terms of balancing particular types of things. Additionally, make it clear that mod authors are welcome to jump in with "I'm thinking of doing this - is there anything that I am missing that would make it OP/weak/not suited for the intended role?"
this would be nice and ideal if some consensus on what balanced is could be reached (obviously trying to retain vanilla levels of power).  there already are modding guidelines by DarkRevenant on generally how to balance a mod by shoulds, shalls and should nots.  http://fractalsoftworks.com/forum/index.php?topic=9052.0

Of course, the major problem with a thread like that (beyond getting as many people involved/invested as possible) would be organizing the info and making it available - at some point you'd probably have to make the first post (or several, if post length is an issue) purely a table of contents for important topic summaries.

i agree that the post would need structure and it would need to generate attention to even be relevant
this is primarily the reason i haven't done it.  i'm not a very neat and organized person. my passion for something is bursty and then cold.  i would feel rather bad starting something up and then abandoning it simply cuz my interest has waned for a time. i'm also not a well-known forum name so i doubt a post i make would really garner much interest unless it were actually an interesting mod (maybe i'm just cynical).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on December 16, 2019, 12:27:59 AM
There's almost no way to have an effective meta-discussion of mod balance without heavy moderation. It's also kind of beside the point, because the sort of people who want to hear if a mod is balanced before or instead of trying it out aren't the kind of people who have reasonable balance standards (either because they think the game should be totally different or because they don't understand it well enough yet); otherwise, they'd simply download the mod and decide for themselves.

DR's list is a good one for modders, but non-modders frequently stumble on the basics of accurately identifying how the game works and which of his rules applies when, as well as how, because they've never tried to balance anything themselves. If one of us doesn't get it, it shows in our mods. If someone else doesn't get it, it certainly doesn't stop the rest of us from hearing it shouted at us for months or years.

It's already enough of a challenge just to get people to accurately ID what comes from what mod in bug reports or to get people to read tooltips and stat cards before offering an opinion. (One thing modders discuss a fair amount among ourselves is how flashy VFX can mislead people into thinking a weapon or ship is more powerful than it, in fact, is).

So I'd just recommend the method I use; 'do I like the look of the mod enough to try it?' and, after trying it 'do I enjoy the way this mod feels?' Those two usually tell me whether or not I like what a mod does to the game before any question of balance comes into it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on December 16, 2019, 04:26:45 AM
Another small question, while I'm trying to repair the previous script : I made a missile AI but I don't have any idea of the way I'm supposed to use it. How am I supposed to apply it on the missiles I want ?

Edit : I managed to find where I'm supposed to call the missile AI in ModPlugin, but it doesn't seems to work with this :
Code
@Override
    public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI ship) {
        switch (missile.getProjectileSpecId()) {
            case "NRT_chaos_lrm":
                return new PluginPick (new SCQ_ChaosMissileAI(missile, ship),CampaignPlugin.PickPriority.MOD_SPECIFIC);
            default:
        }
        return null;
    }
The missile just fly straight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 16, 2019, 04:48:45 AM
Yeah, you can't do that, it wouldn't work. Unless they had a custom AI that was capable of carrying out commands.
Ahh, looks like I'll have to put off some of my plans. Thanks for clearing that up, though! At least I know what way I need to progress!

Regarding the firing AI, I did find something that Tyrador Coalition did - giving the drones a default AI so they ignored the formation movement and, at the same time, they seemed to stop moving now when I set their top speed to 0!

Unfortunately, it seems they now also acquired 0-flux boost, which gave them some top speed despite setting it to 0. Thankfully, I was able to counter even that by simply giving them a hullmod that kept their shields permanently open. And so, after a long-winded road, I was able to arrive at my desired behavior!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Loken on December 16, 2019, 04:51:00 AM
Hello, i want to request an Mod but i cant find forum rules anywhere. (hope its not forbidden)

I want to edit one number in starfarer.api.zip/com/fs/starfarer/api/impl/campaign/intel/punitive/PunitiveExpeditionIntel.java

public class PunitiveExpeditionIntel extends RaidIntel implements RaidDelegate {

   public static final String BUTTON_AVERT = "BUTTON_CHANGE_ORDERS";
   public static float REP_PENALTY = 0.05f; WANT TO CHANGE THIS TO 0 OR 0.01

Raw edit does not work.
Someone said it can be done with this "modify PunitiveExpeditionIntel.REP_PENALTY in your ModPlugin.onApplicationLoad() or some such." but i have no idea how to actually mod.

Thanks for your attention.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on December 16, 2019, 01:23:19 PM
I am working on a SpecialItem that is supposed to be applicable to multiple industries, and hit a dead end with the class InstallableItemPlugin.

My issue is as follows:
The constructor defined in NameInstallableItemPlugin is specific to a single industry:
Code
private IndustryClass industry;

public ItemInstallableItemPlugin(IndustryClass industry) {
this.industry = industry; }
Which prohibits addition of the item in multiple industries. Adding Industry-specific versions of InstallableItemPlugin does not work, as ItemPlugin calls a method from InstallableItemPlugin.

Is there a way around this without making a specific SpecialItem for every industry?

There is a second issue with the UI not appearing, but that might be my mistake - is there anything not immediately obvious that needs doing so the install prompt appears on the colony management screen? - My code for this does not crash, but also does not work (progress!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on December 16, 2019, 01:36:36 PM
I may be mistaken, but shouldn't that work for any industry? The instantiating call will pass the specific industry its being added to through the constructor, and then the instance saves it. You can then check what type that saved industry is in later code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on December 16, 2019, 01:50:10 PM
That is correct, it works for every industry without a hitch, but I have to set the industry manually.
For instance, the NanoforgeInstallableItemPlugin is locked to HeavyIndustry:

Code
private HeavyIndustry industry;

public NanoforgeInstallableItemPlugin(HeavyIndustry industry) {
this.industry = industry;
}

If I try to get the Farming Industry to take a Nanoforge, it won't work cause the industry ID does not match.
Shadowy got around that limitation by making the Modular Fabricators in Shadowyards an extention of HeavyIndustry, which is not an option for me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 16, 2019, 02:16:33 PM
When I set a built-in LPC into some hulls that don't have fighter bays (outside the game) and then add converted hangar to them (in-game), the LPCs don't appear on the first (and only) fighter slot - I'm talking empty black box here- but when I try to click on them, it gives me the buzzing noise that happens when you click a built-in fighter LPC. Running a simulation on the ship does show that no fighter LPC was mounted.

Strangely enough, when I restart the game, the built-in LPCs do appear in that converted hangar slot, and everything is working as it should be. Is there a way around this issue without needing to restart?

Or, alternatively, is there a way to force-add a built-in LPC into a fighter bay via a hullmod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on December 16, 2019, 02:35:08 PM
Huh, I'll have to take a look when I get home tonight, I was playing with all this a while back. Is there any reason you can't use something like:

Code
private Industry industry;

public NanoforgeInstallableItemPlugin(Industry industry) {
this.industry = industry;
}

As all of the industries are implementations of the Industry interface? Apologies again if this is nonsensical, as Java isn't a usual language for me and I don't have an IDE here, but I thought that this exact use case was the stated purpose for Interfaces.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2019, 02:48:34 PM
Hello, i want to request an Mod but i cant find forum rules anywhere. (hope its not forbidden)

I want to edit one number in starfarer.api.zip/com/fs/starfarer/api/impl/campaign/intel/punitive/PunitiveExpeditionIntel.java

You'd need to do:
PunitiveExpeditionIntel.REP_PENALTY = 0.01f;
In your ModPlugin's onApplicationLoad(). Just changing the code in the src zip isn't going to do anything - the code is just provided for reference purposes.

@SirHartley: what Thaago said, yeah.


When I set a built-in LPC into some hulls that don't have fighter bays (outside the game) and then add converted hangar to them (in-game), the LPCs don't appear on the first (and only) fighter slot - I'm talking empty black box here- but when I try to click on them, it gives me the buzzing noise that happens when you click a built-in fighter LPC. Running a simulation on the ship does show that no fighter LPC was mounted.

Strangely enough, when I restart the game, the built-in LPCs do appear in that converted hangar slot, and everything is working as it should be. Is there a way around this issue without needing to restart?

Or, alternatively, is there a way to force-add a built-in LPC into a fighter bay via a hullmod?

Honestly, I'm not sure. The fact that a restart helps is pretty weird here, though; makes me wonder if you're accidentally messing with *hull* data (which changes it across the board for all ships of that type) and the application reload fixes it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 16, 2019, 03:41:32 PM
Honestly, I'm not sure. The fact that a restart helps is pretty weird here, though; makes me wonder if you're accidentally messing with *hull* data (which changes it across the board for all ships of that type) and the application reload fixes it.
Not really, I just added the built-in wing straight into the .ship file:

  "builtInWings": [
    "yrxp_drone_aux"
  ],

...while in ship_data.csv, I set its fighterBays to 0. And then the hullmod I made is just a copy of ConvertedHangar's +1 bays stat:

Code
stats.getNumFighterBays().modifyFlat(id, 1f);

At the moment, I think I could just keep it like this, since it does work the way I intended (apart from the restart requirement). If it's a bug that this even half-works, I hope you put it at the very bottom of your to-do list, haha!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 16, 2019, 04:30:47 PM
But... why? If the wing is built into the hull, why not give the hull one fighter bay in ship_data.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 16, 2019, 04:54:38 PM
But... why? If the wing is built into the hull, why not give the hull one fighter bay in ship_data.csv?
Ah, it's because I don't want the ship to have that wing without that hullmod. And if the ship has that hullmod, I don't want the player to be able to change the wing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2019, 09:42:45 AM
Ah, gotcha. ("Built-in wing on a ship with 0 fighter bays" is fundamentally an invalid state, so it's kind of a "however it works out, that's how it works out" situation, if that makes sense.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 17, 2019, 04:47:34 PM
Is there a way to get the size setting of the sector (small/normal) from anywhere? Is it stored in the sector's memory, for example?

Same question for the sector's age setting as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2019, 05:00:33 PM
Short of providing your own newGameSectorProcGen (to save this info), I don't think so - it doesn't look like that gets saved anywhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 17, 2019, 05:09:51 PM
I tried inserting a rule at InitNewGameChoices, where I can successfully detect the player's selections, but when I save them to sector memory it apparently gets wiped before ModPlugin.onNewGame() gets called.

I guess I'm going to have to do static variables and be very careful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2019, 05:17:21 PM
Right, yeah, at that point the Sector itself doesn't exist. Using statics to pass it along should be totally fine - as long as what you store in those are Strings, primitives, or enums (and other such), there's really no risk.

(Edit: nice work thinking of injecting a rule to detect this, btw.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 19, 2019, 02:53:17 PM
Is it possible to set a faction to use a specific hull and its variants but NOT let them sell it in their markets (open/military)?

Also, is there a way to set drones to not explode when their mothership dies?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2019, 09:16:16 PM
Is it possible to set a faction to use a specific hull and its variants but NOT let them sell it in their markets (open/military)?

Also, is there a way to set drones to not explode when their mothership dies?

Offhand, I don't think so for either. But perhaps someone with more experience in this area could chime in with a clever workaround.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 19, 2019, 11:09:59 PM
Offhand, I don't think so for either. But perhaps someone with more experience in this area could chime in with a clever workaround.
Hmm, I see. Well, the first one is kind of minor anyway. And as for the second, I've already made a workaround (replacing the spawned drones immediately with custom fighters with default AI), but as you can predict, they don't have that cool 'follow' behavior that drones have. But I can live with that.

And thanks for the quick reply!

EDIT: I have another question though, is there a way to flag ships as no-retreat? I seem to be getting some fatal errors when ships dynamically spawned in-combat retreat from the 'Full Retreat' command.

This is the aforementioned error, by the way, if it's of interest:

Code
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.ai.movement.maneuvers.RetreatManeuver.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.RetreatManeuver.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.oooO$o.super(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.oooO.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 20, 2019, 05:24:15 AM
Is it possible to set a faction to use a specific hull and its variants but NOT let them sell it in their markets (open/military)?

You could extend OpenSubmarketPlugin and MilitarySubmarketPlugin, explicitly block the ship there, and make your faction's markets use those instead of the vanilla versions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cathar on December 20, 2019, 12:37:48 PM
This is most likely an incredibly basic question but I couldn't really find an answer to this anywhere.

For personal use, I want to add some Pirate variants of some modded ships to the respective mods.
DISCLAIMER - no I will not release any edited mod sprites to the public for personal glory or whatever. If I actually get them to work I might offer the sprites to the respective mod authors as a gift to either use or throw away at their leasure. Please store the pitchforks and maybe help a modding noob out?

Started with a Nidhoggr(P) variant for the Nidhoggr from S.A.D.

Here's what I did:


Unfortunately, when I try to launch Starsector I get this error at the end of my log:
Spoiler
21507 [Thread-4] WARN  com.fs.starfarer.loading.ShipHullSpreadsheetLoader  - Ship hull [SAD_Niddhoggr_p] from ship_data.csv not found in store
22244 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.loading.ShipHullSpecLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.ÒO0000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

So I assume the game is having trouble finding all the info it needs to have the ship in there, but I can't tell what else I need to change for this to happen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 20, 2019, 03:06:50 PM
  • Copied SAD_Niddhoggr.ship in data\hulls and renamed the copy SAD_Nidhoggr_P - made no changes to this, didn't even open it with anything

You need to open SAD_Nidhoggr_P.ship and change its id field to match the one in ship_data.csv. May as well change the name field there while you're at it. You'll also need to add your ship to the default_ship_roles.json in world/factions and add it to the pirates faction's known ships. I think that's everything.

I strongly suggest moving all your stuff into your own minimod. Then you won't have to do a bunch of copying and editing whenever S.A.D. updates.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on December 20, 2019, 03:19:17 PM
I have some Hidden hullmods that are popping up for players anyways, how do i make sure they never appear unless they are built-in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cathar on December 20, 2019, 04:01:30 PM
  • Copied SAD_Niddhoggr.ship in data\hulls and renamed the copy SAD_Nidhoggr_P - made no changes to this, didn't even open it with anything

You need to open SAD_Nidhoggr_P.ship and change its id field to match the one in ship_data.csv. May as well change the name field there while you're at it. You'll also need to add your ship to the default_ship_roles.json in world/factions and add it to the pirates faction's known ships. I think that's everything.

I strongly suggest moving all your stuff into your own minimod. Then you won't have to do a bunch of copying and editing whenever S.A.D. updates.

Managed to change the .ship with Wordpad (amateur hour, I know). Unfortunately now it is giving me an error about the .variant, which I thought I had changed properly. Image of the error is attached.

Did I miss something?


Also I didn't add it to the pirate faction cause I only want it to be available to myself with console for now.

I hear you about the minimod. That can happen once I figure out all the things I actually need to have in my mod for things to function ^^



NEVERMIND, apparently some things in Starsector are case sensitive and some aren't. Once I changed a lower case p for an upper case P in the .variant it works now!

Thanks for the help!

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 20, 2019, 07:01:15 PM
I'm adding GUI sliders to a part of the new game dialog. But when I call the rules.csv row that's supposed to read their values, the sliders no longer exist (opts.hasSelector returns false). Even though I haven't left the dialog "page" where I added the sliders yet and the dialog option that calls said rule is in the same page as the sliders.
I have a working implementation of sliders elsewhere in my new game dialog, but can't tell why that one works and this doesn't.
Help plz

I have some Hidden hullmods that are popping up for players anyways, how do i make sure they never appear unless they are built-in?
Do you mean they're dropping as modspecs for players when they shouldn't? Add the "no_drop" and "no_drop_salvage" tags
(or make factions not know them, I guess)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 20, 2019, 07:06:39 PM
EDIT: I have another question though, is there a way to flag ships as no-retreat? I seem to be getting some fatal errors when ships dynamically spawned in-combat retreat from the 'Full Retreat' command.

This is the aforementioned error, by the way, if it's of interest:

Code
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.ai.movement.maneuvers.RetreatManeuver.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.RetreatManeuver.o00000(Unknown Source)

Hmm - I suspect this may be due to how you're adding the ship; if this was a universal problem I'd imagine a lot of other things that work in mods, wouldn't.


I'm adding GUI sliders to a part of the new game dialog. But when I call the rules.csv row that's supposed to read their values, the sliders no longer exist (opts.hasSelector returns false). Even though I haven't left the dialog "page" where I added the sliders yet and the dialog option that calls said rule is in the same page as the sliders.
I have a working implementation of sliders elsewhere in my new game dialog, but can't tell why that one works and this doesn't.
Help plz

Do your options add any other options somewhere along the way? That would cause the old (slider) options to get cleared out. Do any of the rule commands you run return true in their doesCommandAddOptions() method? That would also cause the options to get cleared out, even if the command doesn't actually add any.

Edit: on re-reading, it sounds like the options are not, in fact, getting cleared out, so probably never mind that. But on the other hand, looking at the code, it seems... let's say unlikely? ... that the getSelector() option would return false if the right parameter was passed in and the options were *not* cleared, since the map that holds the selectors is *only* cleared when the options are cleared.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 20, 2019, 10:14:08 PM
I'm adding GUI sliders to a part of the new game dialog. But when I call the rules.csv row that's supposed to read their values, the sliders no longer exist (opts.hasSelector returns false). Even though I haven't left the dialog "page" where I added the sliders yet and the dialog option that calls said rule is in the same page as the sliders.
I have a working implementation of sliders elsewhere in my new game dialog, but can't tell why that one works and this doesn't.
Help plz

Do your options add any other options somewhere along the way? That would cause the old (slider) options to get cleared out. Do any of the rule commands you run return true in their doesCommandAddOptions() method? That would also cause the options to get cleared out, even if the command doesn't actually add any.

Edit: on re-reading, it sounds like the options are not, in fact, getting cleared out, so probably never mind that. But on the other hand, looking at the code, it seems... let's say unlikely? ... that the getSelector() option would return false if the right parameter was passed in and the options were *not* cleared, since the map that holds the selectors is *only* cleared when the options are cleared.
Ahh, that was it. The row had a script column call to make the rulescmd read the sliders, but also had an options column entry to advance the dialog, which was indeed why it was being cleared out. (Sorry if I explained it wrong!)
Thanks, solved now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hoakin Blackforge on December 21, 2019, 03:35:26 AM
Hey, new to modding here, does graphicslib help to increase performance?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 21, 2019, 05:04:01 AM
For replacing CSV elements, do mods loaded later override ones loaded earlier, or the opposite?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 21, 2019, 09:34:36 AM
Hey, new to modding here, does graphicslib help to increase performance?
Not by default, but there might be some combination of settings that allow it to increase performance. It might be worth asking about in the graphicslib thread.

For replacing CSV elements, do mods loaded later override ones loaded earlier, or the opposite?
Pretty sure mods loaded later override ones loaded earlier. Although the official answer is "unspecified"
Mod Structure & File Merging (http://fractalsoftworks.com/forum/index.php?topic=5016.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on December 21, 2019, 11:00:05 AM
Hello!
I want to insert two new illustrations (for planet and station interaction) so I created the illustration folder in graphics, added the .jpeg, and added the following kid of line in the .java file of the system:
Quote
         NoraStation1.setInteractionImage("illustrations", "filgap_nora");
but I got the following error:

Quote
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Texture [filgap_bythinia] from category [illustrations] not found

Note sure what to do... I never had a similar problem with other icons or graphics. Do I need to give a full path in the java file?

Thank you for your help! And for the previous ones, and the previous ones...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheRiverNorth on December 21, 2019, 12:00:57 PM
Hey guys :)

I'm not sure if this fits in here, but I was looking around the fleet doctrine screen and was wondering if there was any way to edit it from the outside. I tried editing the campaign.xml and set my fleet's doctrine to all 5s to see what would happen, but it wouldn't let me save the file. Thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2019, 12:15:36 PM
Hello!
I want to insert two new illustrations (for planet and station interaction) so I created the illustration folder in graphics, added the .jpeg, and added the following kid of line in the .java file of the system:
Quote
         NoraStation1.setInteractionImage("illustrations", "filgap_nora");
but I got the following error:

Quote
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Texture [filgap_bythinia] from category [illustrations] not found

Note sure what to do... I never had a similar problem with other icons or graphics. Do I need to give a full path in the java file?

Thank you for your help! And for the previous ones, and the previous ones...

Did you add the illustration to the "illustrations" section in settings.json?

Hey guys :)

I'm not sure if this fits in here, but I was looking around the fleet doctrine screen and was wondering if there was any way to edit it from the outside. I tried editing the campaign.xml and set my fleet's doctrine to all 5s to see what would happen, but it wouldn't let me save the file. Thoughts?

Hi - you probably need to run whatever text editor you're using as admin, or change the file so it's not read-only, or move it to the desktop and edit there then move it back, or some other such. This is some kind of windows thing preventing you from editing the file for... some windows reason.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on December 21, 2019, 01:53:49 PM
Thanks a lot, everything is working fine now!
Have a merry Christmas!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 21, 2019, 09:56:32 PM
How to show dialog while I am in CARGO core tab :(
I have a special item that could right click and remove to get some blueprints, so I want to use "show loot" to interact with showloot listener.

Here is my code before which is not related to dialog.
Code: java
    @Override
    public void performRightClickAction() {
        LockBoxData data = LockBoxData.getData();
        if (data.isTotallyUnlocked()) {
            List<DropData> dropRandomList = new ArrayList<>();

            DropData drop = new DropData();
            drop.group = "ship_bp";
            drop.chances = 6;
            dropRandomList.add(drop);
            CargoAPI extra = SalvageEntity.generateSalvage(random, 1, 1, 1, null, dropRandomList);
            extra.addSpecial(new SpecialItemData(Items.SHIP_BP, "AL_doctor"), 1f);
            CargoAPI cargo = stack.getCargo();
            cargo.addAll(extra);
        }
    }
But if I click it in others[4], it will disappear after I switch to all[1] or [2], because the cargo is not the real cargo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheRiverNorth on December 22, 2019, 02:54:54 AM
Hey guys :)

I'm not sure if this fits in here, but I was looking around the fleet doctrine screen and was wondering if there was any way to edit it from the outside. I tried editing the campaign.xml and set my fleet's doctrine to all 5s to see what would happen, but it wouldn't let me save the file. Thoughts?

Hi - you probably need to run whatever text editor you're using as admin, or change the file so it's not read-only, or move it to the desktop and edit there then move it back, or some other such. This is some kind of windows thing preventing you from editing the file for... some windows reason.
Ah, yeah. That did the trick. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on December 22, 2019, 09:39:17 AM
To make sure, is the correct orientation for a graphicslib normal map XYZ inverted?

And if I want to auto-generate a whole bunch, is there a simpler method than the nvidia photoshop plugin? It seems to screw up when I try to use it with batch actions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 22, 2019, 10:37:54 AM
How to show dialog while I am in CARGO core tab :(
I have a special item that could right click and remove to get some blueprints, so I want to use "show loot" to interact with showloot listener.

Here is my code before which is not related to dialog.
Code: java
    @Override
    public void performRightClickAction() {
        LockBoxData data = LockBoxData.getData();
        if (data.isTotallyUnlocked()) {
            List<DropData> dropRandomList = new ArrayList<>();

            DropData drop = new DropData();
            drop.group = "ship_bp";
            drop.chances = 6;
            dropRandomList.add(drop);
            CargoAPI extra = SalvageEntity.generateSalvage(random, 1, 1, 1, null, dropRandomList);
            extra.addSpecial(new SpecialItemData(Items.SHIP_BP, "AL_doctor"), 1f);
            CargoAPI cargo = stack.getCargo();
            cargo.addAll(extra);
        }
    }
But if I click it in others[4], it will disappear after I switch to all[1] or [2], because the cargo is not the real cargo.

Hmm, I'm not sure I understand what you're trying to do. Why wouldn't it be the real cargo?

I'm not sure what you're trying to do, but have you considered using showCargoPickerDialog()? It might be a better fit, depending. That's what's used for handing in AI cores in vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 22, 2019, 01:59:21 PM
So I don't know if this is a dumb question, but how do I go about setting up an environment to create a new ship system?

I made the script easily enough. Starsector throws an error saying it can't compile it and closes. My assumption here is that it's because the .java file doesn't have a .class file to go with it..simple, right?

The hurdle I am facing is getting the damned thing to compile. it throws a billion errors and if I pull a copy of the API in the same directory, I get a million errors about lwjgl instead.

I'm sure im overlooking something simple. Right now the directory im working with looks like this:

myShipSystem.java
com(starfarer api)

Any help would be appreciated ):

edit:  nevermind, figured it out :). I needed to include lwjgl in the directory as well
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 22, 2019, 07:13:46 PM
How would I uhh determine if a code has a nanoforge or not for an ability I am creating

Code
getFleet().getCargo().getCommodityQuantity(Items.CORRUPTED_NANOFORGE)

seems to always return 0 despite i can add myself 1000 of these things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 22, 2019, 07:15:04 PM
Unlike AI cores, those aren't commodities. Try something like:

cargo.getQuantity(CargoItemType.SPECIAL, Items.CORRUPTED_NANOFORGE);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 22, 2019, 07:41:22 PM
Hmm, I'm not sure I understand what you're trying to do. Why wouldn't it be the real cargo?

I'm not sure what you're trying to do, but have you considered using showCargoPickerDialog()? It might be a better fit, depending. That's what's used for handing in AI cores in vanilla.
My first question is, how to call out an interaction dialog in performRightClickAction()

About the code:
If I clicked the item when players cargo is sorted(not all[1], but others[4] in core tab(i)), stack.getCargo() seems to return the sorted part cargo. Blueprints exists in other[4], but if I clicked other sort tabs, they disappeared.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 22, 2019, 09:50:56 PM
Unlike AI cores, those aren't commodities. Try something like:

cargo.getQuantity(CargoItemType.SPECIAL, Items.CORRUPTED_NANOFORGE);
ahhh that make sense
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2019, 09:32:49 AM
My first question is, how to call out an interaction dialog in performRightClickAction()

I'm not sure if it's possible or not. I'd try something like:
Global.getSector().getCampaignUI().showInteractionDialog(plugin, interactionTarget)

With a custom plugin, but I'm not sure if that'll work 100% or if that might cause problems depending on whether it's called from the in-flight cargo screen vs the at-a-colony cargo screen. I'd definitely test both cases since they're meaningfully different.

About the code:
If I clicked the item when players cargo is sorted(not all[1], but others[4] in core tab(i)), stack.getCargo() seems to return the sorted part cargo. Blueprints exists in other[4], but if I clicked other sort tabs, they disappeared.

Ah yes, you can't really rely on stack.getCargo(), it's ... I don't know if I'd say bugged, but it only works in a few very specific cases. I did actually change this to work reliably in the dev version, btw, since it was necessary for some vanilla features.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 23, 2019, 08:46:05 PM
I'm not sure if it's possible or not. I'd try something like:
Global.getSector().getCampaignUI().showInteractionDialog(plugin, interactionTarget)

With a custom plugin, but I'm not sure if that'll work 100% or if that might cause problems depending on whether it's called from the in-flight cargo screen vs the at-a-colony cargo screen. I'd definitely test both cases since they're meaningfully different.
That didn't work, I have tried it before.

Ah yes, you can't really rely on stack.getCargo(), it's ... I don't know if I'd say bugged, but it only works in a few very specific cases. I did actually change this to work reliably in the dev version, btw, since it was necessary for some vanilla features.
Okay...So I should just add these things to fleet cargo now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 24, 2019, 07:13:10 AM
Unlike AI cores, those aren't commodities. Try something like:

cargo.getQuantity(CargoItemType.SPECIAL, Items.CORRUPTED_NANOFORGE);

Upon testing the code above.

Code
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.fleet.FleetMemberViewAPI;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
import com.fs.starfarer.api.impl.campaign.abilities.BaseToggleAbility;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Items;
import com.fs.starfarer.api.ui.LabelAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.Misc;

    public boolean hazpristine() {
        if (getFleet().getCargo().getQuantity(CargoItemType.SPECIAL, Items.CORRUPTED_NANOFORGE) > 0)
            return true;
        return false;
    }
Seems to never return true.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2019, 10:27:07 AM
That didn't work, I have tried it before.

Then I don't *think* it's possible, hmm.

Okay...So I should just add these things to fleet cargo now.

Riight.


Upon testing the code above.

Code
    public boolean hazpristine() {
        if (getFleet().getCargo().getQuantity(CargoItemType.SPECIAL, Items.CORRUPTED_NANOFORGE) > 0)
            return true;
        return false;
    }
Seems to never return true.

Ah, my bad! It should be something like:

getFleet().getCargo().getQuantity(CargoItemType.SPECIAL, new SpecialItemData(Items.CORRUPTED_NANOFORGE, null))

If you're curious, the second parameter to the SpecialItemData constructor - the one that's null for this - would be the blueprint ID for blueprints.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 24, 2019, 12:07:40 PM
Ah, my bad! It should be something like:

getFleet().getCargo().getQuantity(CargoItemType.SPECIAL, new SpecialItemData(Items.CORRUPTED_NANOFORGE, null))

If you're curious, the second parameter to the SpecialItemData constructor - the one that's null for this - would be the blueprint ID for blueprints.
Cheers!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on December 25, 2019, 09:17:42 AM
When in combat near a planet, in background there is the planet visible, but its always small/distant. Is there a config somewhere I can edit to make it 2-3 times bigger?
thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on December 25, 2019, 06:36:24 PM
I'm trying to create an industry where the image can change based on market conditions (like farming/aquaculture, light industry, etc.). My code below throws a null exception if installedOnStation() is true:

Code
@Override
    public String getCurrentImage()
    {
        if(installedOnStation())
        {
            return (this.getSpec().getImageName()).replaceAll("mass_driver.png", "drone_control.jpg");
        }
        else
        {
            return this.getSpec().getImageName();
        }
    }
Same with this code:
Code
@Override
    public String getCurrentImage()
    {
        if(installedOnStation())
        {
            return Global.getSettings().getSpriteName("industry", "drone_control");
        }
        else
        {
            return this.getSpec().getImageName();
        }
    }

 Does anyone know how to get this to work? Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2019, 10:07:25 AM
When in combat near a planet, in background there is the planet visible, but its always small/distant. Is there a config somewhere I can edit to make it 2-3 times bigger?
thank you

It's not easily configurable, but the implementation is in BattleCreationPluginImpl, which you can provide a custom version of  in CampaignPlugin.pickBattleCreationPlugin. (The planets aren't bigger because it gets harder to see what's going on, btw...)

My code below throws a null exception if installedOnStation() is true:

Hmm - stack trace? If there's an exception, the stack trace is pretty much mandatory to look at in trying to figure it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on December 26, 2019, 10:51:17 AM
What does the "withJunkAndChatter" boolean argument officially do in the addMarket() method for EconomyAPI? I'm not sure I've figured it out and I'm still speculating...

Also, what does MarketAPI setHasSpaceport(true/false) do? Is it pre-0.9? Because now you just add a spaceport industry, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2019, 11:53:33 AM
What does the "withJunkAndChatter" boolean argument officially do in the addMarket() method for EconomyAPI? I'm not sure I've figured it out and I'm still speculating...

There's space-junk in orbit around populated planets/stations, and there's a "radio chatter" sound effect when approaching the market. This parameter being true automatically adds both.

Also, what does MarketAPI setHasSpaceport(true/false) do? Is it pre-0.9? Because now you just add a spaceport industry, right?

The spaceport industry sets hasSpaceport to true, and then other things that check to see if the market has a spaceport check that. It's both a faster check and not hardcoded to depend on the specific vanilla spaceport industry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on December 26, 2019, 01:31:35 PM
Thank you!

The spaceport industry sets hasSpaceport to true, and then other things that check to see if the market has a spaceport check that. It's both a faster check and not hardcoded to depend on the specific vanilla spaceport industry.

I see. This method will allow us to make our own custom spaceport industry/installations if we wanted to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2019, 01:58:56 PM
Yep, exactly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on December 26, 2019, 04:05:38 PM
Hmm - stack trace? If there's an exception, the stack trace is pretty much mandatory to look at in trying to figure it out.

Here's the stack trace. The industry illustration appears blank when I open the building menu, and the null exception occurs as soon as I click to build the industry. It seems the problem is that it can't find the image I'm trying to point it to - but I'm not sure where the code that tries to load the image is located. The decompiler seems to be having issues with the UI files. Any ideas? Thanks!

Spoiler
25180 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.ui.u.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.oOO0.o00000(Unknown Source)
   at com.fs.starfarer.ui.newnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.q.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.IndustryListPanel.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.intnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.campaign.ui.marketinfo.newsuper.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.campaign.ui.o0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.String.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.N.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.O0oO.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.render(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.render(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2019, 04:07:42 PM
Are you sure the image you're providing exists? And, right, it needs to be loaded; i.e. either directly referred to from the industries csv or added in the "graphics" section of settings.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 26, 2019, 04:30:55 PM
Also, are JPEGs supported by the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on December 26, 2019, 04:32:13 PM
Minor addition:

I don't think withJunkAndChatter=false is working. My colonies/planets/markets always have floating debris and comms sound effects even when I pass false to the method call.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2019, 04:44:44 PM
Also, are JPEGs supported by the game?

Yep! Situational due to lack of transparency, of course, but e.g. the backgrounds and illustrations are jpegs. Generally faster load times for larger images...


I don't think withJunkAndChatter=false is working. My colonies/planets/markets always have floating debris and comms sound effects even when I pass false to the method call.

It'll auto-add junk when you reload the game, and will also add chatter when you start a new game, so false there isn't saying "never ever add it", just "don't do it right now".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on December 26, 2019, 08:19:39 PM


I don't think withJunkAndChatter=false is working. My colonies/planets/markets always have floating debris and comms sound effects even when I pass false to the method call.

It'll auto-add junk when you reload the game, and will also add chatter when you start a new game, so false there isn't saying "never ever add it", just "don't do it right now".

Ah, so it's more to cut down on in-game fluff? Like if someone is dynamically creating colonies or for when players create colonies? Just curious what its practical use is...

If I'm adding a market in onNewGame() it might speed up initialization slightly by cutting down a redundant procedure???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2019, 08:25:27 PM
The use case is "the junk and chatter already exist, but the market isn't in the global economy". I think the only use of it in vanilla is when you finish the tutorial and Ancyra/Derinkuyu are added to the economy when the jump-points start working again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on December 27, 2019, 07:30:53 AM
added in the "graphics" section of settings.json.

I had no idea that section of the settings.json existed. Problem solved! Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 27, 2019, 09:53:58 AM
Glad you got it sorted out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 27, 2019, 06:08:48 PM
Is there a listener to check when a market changes hand (or is colonized from neutral to something that isn't neutral)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 28, 2019, 01:38:04 AM
Is there a way to make a ship "braver" without changing its loadout? I'm not really sure how the backend deals with it, but I made a modular ship where the core is almost unarmed and has 1 fighter bay. It, however, has three huge modules with tons of close range weapons. However, instead of brawling up-close, it seems to prefer to act like a dedicated carrier and move far outside the range of its weapons or, even its short-ranged fighters (despite having the CARRIER, COMBAT tag - this behavior happens even if I remove all tags).

EDIT: Also another question:

Is there a way to trigger a script in the middle of a campaign? My aim is to spawn some planets/stations after X years have passed using the same code in the SectorGeneratorPlugin I used to create the system in the first place.

Also on the same topic, I also wanted to add/delete industries - is this possible? I wanted to simulate long-term growth by adding/upgrading (delete then add) some buildings after X years have passed.

EDIT 2: Different question now:

I am having issues with issuing full retreat, but then the combat doesn't end even when there are no ships or fighters on my side anymore. Looking at other mods, they seem to have some plugins that take care of modules to solve this issue, however, when I tried porting it over to my files, it seems the function calls they use are deprecated...  Is there a workaround for this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 28, 2019, 01:48:39 AM
Is there a to disable abandoning of a specific (not-playerOwned) colony without changing its size?
EDIT: Never mind, the user appears to have been on dev mode.

Is there a listener to check when a market changes hand (or is colonized from neutral to something that isn't neutral)?
Colonization listener is coming in next Starsector version.

Market changing faction isn't a vanilla thing so there's no vanilla listener for it, but Nex has one here (https://bitbucket.org/Histidine/exerelin/src/master/jars/sources/ExerelinCore/exerelin/utilities/InvasionListener.java).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on December 28, 2019, 04:06:12 PM
Hi there !
I found why my game was crashing last time : Intellij wasn't compiling the jar where I wanted after an update. Strange but resolved.
On the other hand... :
Spoiler
Code
195040 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at data.scripts.weapons.SCQ_NRT_RevolverEffect.advance(SCQ_NRT_RevolverEffect.java:99)
at com.fs.starfarer.combat.entities.ship.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.O0oO.advance(Unknown Source)
at com.fs.starfarer.combat.systems.void.advanceLinked(Unknown Source)
at com.fs.starfarer.combat.systems.void.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
195195 [Thread-10] INFO  sound.public  - Creating streaming player for music with id [battle_ambience_01.ogg]
195195 [Thread-10] INFO  sound.H  - Playing music with id [battle_ambience_01.ogg]
[close]

This is the error I get, sometimes, when overloading enemy ships in the simulator / destroying enemy fighter wings. Looks right from the IDE perspective and work perfectly on unshielded targets.
The plugin :
Spoiler
Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.loading.MuzzleFlashSpec;
import org.lazywizard.lazylib.MathUtils;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;
import data.scripts.util.MagicRender;

import java.awt.*;
import java.util.List;

public class SCQ_NRT_RevolverEffect implements EveryFrameWeaponEffectPlugin {

    //effects
    private Color explosionColor = new Color(160, 105, 17, 100);
    private Color flashColor = new Color(216, 161, 39, 150);
    private final Color SMOKE1_COLOR = new Color(100, 100, 100, 130);
    private final Color SMOKE2_COLOR = new Color(75, 75, 75, 110);
    private final Color SMOKE3_COLOR = new Color(40, 40, 40, 60);

    private boolean runOnce = false,
                applyDamageBonus = false;
    private float burstSpread,
            burstRange,
            damageRange,
            modifier,
            baseBurstDamage,
            originWeaponDamage,
            barrelOffset,
            lastRoundBonusMult;
    private static final float MEDIUM_DAMAGE = 150f,
            LARGE_DAMAGE = 200f;
    private int barrelNumber;
    private Vector2f location,
                barrelLocation;
    private DamagingProjectileAPI proj; //The projectile itself
    private final IntervalUtil timer = new IntervalUtil(0.05f, 0.15f);
    private static WeaponAPI.WeaponSize weaponSize;
    private MuzzleFlashSpec originMuzzleFlash;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        if (weapon.getShip().getOriginalOwner() == -1 || weapon.getShip().isHulk()) {
            return;
        }
        if (!runOnce) {
            //originWeaponDamage = weapon.getDamage().getDamage();
            weaponSize = weapon.getSize();
            originMuzzleFlash = weapon.getMuzzleFlashSpec().clone();
            weapon.ensureClonedSpec();
            weapon.setMaxAmmo(weapon.getSpec().getMaxAmmo());
            switch (weaponSize) {
                case MEDIUM:
                    originWeaponDamage = MEDIUM_DAMAGE;
                    burstSpread = 30f;
                    burstRange = 90f;
                    damageRange = 80f;
                    baseBurstDamage = 30f;
                    barrelNumber = 1;
                    lastRoundBonusMult = 1.5f;
                    if (weapon.getSlot().isTurret()) {
                        barrelOffset = 24.0f;
                    } else barrelOffset = 30.0f;
                    break;
                case LARGE:
                    originWeaponDamage = LARGE_DAMAGE;
                    burstSpread = 35f;
                    burstRange = 120f;
                    damageRange = 100f;
                    baseBurstDamage = 50f;
                    barrelNumber = 2;
                    lastRoundBonusMult = 1.8f;
                    if (weapon.getSlot().isTurret()) {
                        barrelOffset = 32.0f;
                    } else barrelOffset = 38.0f;
                    break;
                default:
                    return;
            }
            runOnce = true;
        }
        barrelLocation = new Vector2f (weapon.getLocation().getX() + barrelOffset, weapon.getLocation().getY());
        VectorUtils.rotateAroundPivot(barrelLocation, weapon.getLocation(), weapon.getCurrAngle());
        if (weapon.getAmmo() <= barrelNumber && weapon.getCooldownRemaining() <= 0.05f && weapon.getChargeLevel() <= 0.05f) {
            applyDamageBonus = true;
        } else if (weapon.getAmmo() > barrelNumber) {
            applyDamageBonus = false;
        }
        if (applyDamageBonus) {
            modifier = lastRoundBonusMult;
            if (weapon.isFiring()) {
                List<DamagingProjectileAPI> projectiles = engine.getProjectiles();
                int size = projectiles.size();
                for (int i = 0; i < size; i++) {
                    proj = projectiles.get(i);
                    if (proj != null && proj.getWeapon().getId() == weapon.getSpec().getWeaponId() && proj.getElapsed() < 0.05f) {
                        proj.setDamageAmount(originWeaponDamage * modifier);
                    }
                }
            }
            weapon.getMuzzleFlashSpec().setParticleColor(new Color(220, 60, 20, 200));
            timer.advance(amount);
            if(timer.intervalElapsed() && MagicRender.screenCheck(0.1f, weapon.getLocation()) && weapon.getAmmo() > 0){
                engine.addHitParticle(
                        weapon.getLocation(),
                        weapon.getShip().getVelocity(),
                        MathUtils.getRandomNumberInRange(30, 50),
                        0.7f,
                        MathUtils.getRandomNumberInRange(0.2f, 0.35f),
                        new Color(220, 120, 40, 150)
                );
            }
        } else {
            modifier = 1f;
            weapon.getMuzzleFlashSpec().setParticleColor(originMuzzleFlash.getParticleColor());
            //muzzleFlash effects
            weapon.getMuzzleFlashSpec().setLength(originMuzzleFlash.getLength() * modifier);
            weapon.getMuzzleFlashSpec().setSpread(originMuzzleFlash.getSpread() * modifier);
            weapon.getMuzzleFlashSpec().setParticleCount((originMuzzleFlash.getParticleCount() * (int) (modifier * 10)) / 10);
        }
        if (weapon.isFiring()) {
            applyExplosion(amount, engine, weapon);
        }

    }
    private void applyExplosion(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        if (applyDamageBonus && weapon.isFiring()) {
            explosionColor = new Color(200, 53, 13, 150);
            flashColor = new Color(255, 75, 48, 200);
        } else if (!applyDamageBonus) {
            explosionColor = new Color(160, 105, 17, 100);
            flashColor = new Color(216, 161, 39, 150);
        }
        float random = ((float) barrelNumber + (float) Math.random() * 1 * modifier) / (4 - modifier);
        for (int j = 0; j <= random; j++) {
            location = MathUtils.getRandomPointInCone(barrelLocation, burstRange * modifier, weapon.getCurrAngle() - (burstSpread * modifier), weapon.getCurrAngle() + (burstSpread * modifier));
            //add an explosion effect at that point
            //void spawnExplosion(Vector2f loc, Vector2f vel, Color color, float size, float maxDuration);
            engine.addHitParticle(location,new Vector2f(), MathUtils.getRandomNumberInRange(12f * modifier, 25f * modifier),0.8f, 0.3f * modifier, explosionColor);
            engine.addHitParticle(location,new Vector2f(), MathUtils.getRandomNumberInRange(8f * modifier, 15f * modifier),0.5f, 0.1f * modifier, flashColor);
            //engine.spawnExplosion(location, new Vector2f(), explosionColor, MathUtils.getRandomNumberInRange(9f, 22f), 0.05f);
            //engine.spawnExplosion(location, new Vector2f(), flashColor, MathUtils.getRandomNumberInRange(6f, 15f), 0.05f);
            //public void addSmokeParticle(Vector2f loc, Vector2f vel, float size, float opacity, float duration, Color color);
            engine.addSmokeParticle(location, new Vector2f(), MathUtils.getRandomNumberInRange(7f * modifier, 14f * modifier), 0.1f, 0.50f * modifier, SMOKE3_COLOR);
            engine.addSmokeParticle(location, new Vector2f(), MathUtils.getRandomNumberInRange(6f * modifier, 12f * modifier), 0.1f, 0.25f * modifier, SMOKE2_COLOR);
            engine.addSmokeParticle(location, new Vector2f(), MathUtils.getRandomNumberInRange(5f * modifier, 10f * modifier), 0.1f, 0.12f * modifier, SMOKE1_COLOR);
        }
        List<MissileAPI> nearbyMissiles = CombatUtils.getMissilesWithinRange(location, damageRange * modifier); //damage nearby missiles
        if (!nearbyMissiles.isEmpty()) {
            for (MissileAPI missiles : nearbyMissiles) {
                engine.applyDamage(
                        missiles,
                        location,
                        baseBurstDamage * modifier,
                        DamageType.ENERGY,
                        0f,
                        false,
                        false,
                        weapon.getShip()
                );
            }
        }
        List<ShipAPI> nearbyShips = CombatUtils.getShipsWithinRange(location, damageRange * modifier); //damage nearby ships
        if (!nearbyShips.isEmpty()) {
            if (nearbyShips.contains(weapon.getShip())) {
                nearbyShips.remove(weapon.getShip());
            }
            for (CombatEntityAPI ship : nearbyShips) {
                engine.applyDamage(
                        ship,
                        location,
                        baseBurstDamage * modifier,
                        DamageType.ENERGY,
                        0f,
                        false,
                        false,
                        weapon.getShip()
                );
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 01, 2020, 10:26:12 AM
Is there a reliable way to get the burn level of the player fleet as displayed by the GUI? Both of these methods often return a number that's one higher than what the player sees:
Code: java
fleet.getCurrBurnLevel();
Misc.getBurnLevelForSpeed(fleet.getVelocity().length());

@Mongreal: I don't know why you're getting that NPE, but you could always just add more null checks to the conditional on line 99.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2020, 10:45:58 AM
Is there a reliable way to get the burn level of the player fleet as displayed by the GUI? Both of these methods often return a number that's one higher than what the player sees:
Code: java
fleet.getCurrBurnLevel();
Misc.getBurnLevelForSpeed(fleet.getVelocity().length());

Looking at the code, this is actually a bit confusing for me - there's stuff in there that I'm not sure *why* it's like that, but there's certainly a reason.

Misc.getBurnLevelForSpeed() takes the not-yet-rounded burn level, adds 0.01 to it, and then rounds it. fleet.getCurrBurnLevel() uses that method under the hood. But what's actually displayed in the player GUI is the rounded return value of Misc.getFractionalBurnLevelForSpeed().

I feel like the + 0.01f is some kind of horrible hack and would actually cause issues if left in - as you say, that'll cause the burn level to be 1 higher at times. Maybe I'll clean it up and see if anything pops loose as a result...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on January 01, 2020, 11:36:16 AM
How do you change the hyperspace map location of vanilla starsystems in a mod?

I tried adding starmap.json to /mods/myMod/data/campaign/ and overriding the settings there but it had no effect.

Is there a way to do this programmatically?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2020, 11:51:42 AM
Ah yeah, the starmap.json wouldn't work because the coordinates are an array and so it just appends to it.

Try system.getLocation().set(x, y) - I think that should work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 01, 2020, 12:06:22 PM
But what's actually displayed in the player GUI is the rounded return value of Misc.getFractionalBurnLevelForSpeed().
I'm still getting incorrect values using these:
Code: java
Misc.getRounded(Misc.getFractionalBurnLevelForSpeed(fleet.getVelocity().length())); // Sometimes too low
(int)Math.ceil(Misc.getFractionalBurnLevelForSpeed(fleet.getVelocity().length())); // Sometimes too high
Am I providing the incorrect argument?

I feel like the + 0.01f is some kind of horrible hack and would actually cause issues if left in - as you say, that'll cause the burn level to be 1 higher at times. Maybe I'll clean it up and see if anything pops loose as a result...
I'm seeing the discrepancy perhaps 25% of the time, so I don't think + 0.01f would account for it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2020, 12:14:50 PM
... ahh. It looks like it's also waiting for the number to change by more than 0.75 - iirc the goal being to avoid the number flickering between two values when, for whatever reason, the current speed is at a threshold.

But it seems like the number wouldn't stay incorrect for long, right? It would stabilize quickly? Basically the displayed value is a bit behind the "real" value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 01, 2020, 12:47:10 PM
... ahh. It looks like it's also waiting for the number to change by more than 0.75 - iirc the goal being to avoid the number flickering between two values when, for whatever reason, the current speed is at a threshold.
Ah, ok. Well maybe I can re-implement that behavior to get a matching number. It might be a good idea to add something like Misc.getDisplayedBurnLevelOfPlayerFleet() to the API though.

But it seems like the number wouldn't stay incorrect for long, right? It would stabilize quickly? Basically the displayed value is a bit behind the "real" value.
True, but this is for the tooltip of a campaign ability, so players are likely to see the discrepancy. Not a big deal, but it makes my mod seem a bit shoddy.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2020, 12:50:59 PM
Hmm, yeah, I see. Let me change it so that everything uses the "real" value for now (i.e. no +0.01f, no delay) and see how that does. The code is kind of old so it's possible the issues it's addressing no longer exist or matter quite as much.

Edit: and then if it turns out to still be necessary, I'd add the method to get at the UI value. Vanilla is actually using something similar - the "slow moving" fleet status is used for a few things - so it's subject to the same potential desync between the UI and the effects.

(If you're curious, "slow moving" is used to avoid some terrain penalties - asteroid impacts, storm strikes - and Go Dark / Active Sensor Burst lock the fleet into moving slowly for the duration - i.e. equivalent to holding 'S'. Which now limits it to half the base, unmodified burn level instead of lowering it to a fixed number. The Sensors skill also raises it, so it can compete with Navigation a bit better - sneak a lot faster, vs always travel a little faster, so it's less of an auto-pick... whew, that got onto a tangent.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 01, 2020, 01:45:28 PM
Hmm, yeah, I see. Let me change it so that everything uses the "real" value for now (i.e. no +0.01f, no delay) and see how that does.
Ok, cool. Yeah, that's probably a better way to go about it than adding a band-aid API method.

(If you're curious, "slow moving" is used to avoid some terrain penalties - asteroid impacts, storm strikes - and Go Dark / Active Sensor Burst lock the fleet into moving slowly for the duration - i.e. equivalent to holding 'S'. Which now limits it to half the base, unmodified burn level instead of lowering it to a fixed number. The Sensors skill also raises it, so it can compete with Navigation a bit better - sneak a lot faster, vs always travel a little faster, so it's less of an auto-pick... whew, that got onto a tangent.)
Those sound like good, clean changes!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on January 01, 2020, 03:41:50 PM
Ah yeah, the starmap.json wouldn't work because the coordinates are an array and so it just appends to it.

Try system.getLocation().set(x, y) - I think that should work.

I am still having no luck here. I've tried:
Code
@Override
public void onNewGameAfterProcGen() {
  SectorAPI sector = Global.getSector();
  StarSystemAPI system = sector.getStarSystem("Hybrasil");
  system.getLocation().set(0, -20000);
}
I've tried onNewGame() as well. I've also tried "hybrasil". I don't get any errors but I just can't move Hybrasil. I don't get any NPE's either. I have no idea what I'm doing wrong...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on January 01, 2020, 04:12:14 PM
I've never tried to do anything like that, but I know systems are represented by several instances of a few different classes (e.g. the system itself, the primary star, and the entity in hyperspace). It might be worth trying to move those around as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on January 01, 2020, 07:41:19 PM
I did. But I got errors from the game saying the methods weren't defined (for setting/getting hyperspace position). I think perhaps those methods are not declared public in the API. The API documentation was a little unclear on that. I know that setting the position as Alex described works when a system is first created as I've seen other mods do that in their initial star system generation code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2020, 08:46:47 PM
Gave it a closer look - you'll either need to wait a few seconds for it to work (until it's the turn of the star system to be updated, at which point its hyperspace anchor - i.e. star gravity well - coordinates will be updated to match the system's coordinates, or you can call this after setting the location:

sector.getHyperspace().updateAllOrbits();

And have it happen instantly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pqxl on January 02, 2020, 04:25:13 AM
How do I stopp the factions from sending Expeditions my way? I fumbled around in the data\world\factions\persean_league.faction file of a portrait Mod I use, but they still send them my way. The end of the file looks like this:
Spoiler
         ...
         "graphics/portraits/d1/f99.png",
         "graphics/portraits/d1/f100.png"
      ],
   },
      "custom":{
      "offersCommissions":true,
      "engagesInHostilities":true,
      "buysAICores":true,
      "AICoreValueMult":1,
      "AICoreRepMult":1,
      "buysSurveyData":true,
      "hostilityImpactOnGrowth":true,
      "caresAboutAtrocities":true,
      "punitiveExpeditionData":{
         "vsCompetitors":false,
         "vsFreePort":false,
         "canBombard":false,
         "territorial":true,
      },
   },
},
[close]
I changed the line:
Code
punitiveExpeditionData":{"vsCompetitors":true,
to false.
I dont have any other mods that could interfere with that file. The portraits show up. Do I have to make my own Mod for that?
Thank you for your time.
Edit: After Alex's post, I looked over it again and found a Typo. This works now. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 02, 2020, 08:02:10 AM
Is it possible to let Mod Info.json be able to use Replace for data files in the .jar that usually have the file path for com.fs.starfarer.api...?

My inquiry is that Better Colonies (https://fractalsoftworks.com/forum/index.php?topic=17103) is only able to replace vanilla Orbital Stations, but they're unable to replace the modded Orbital Stations from other factions because these stations still refer to com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java, and a good solution would be able to have the Mod Info.json replace com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java outright or tell it not to load in the core files so that my mod is able to seamlessly integrate with modded Orbital Station as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2020, 10:04:30 AM
How do I stopp the factions from sending Expeditions my way? I fumbled around in the data\world\factions\persean_league.faction file of a portrait Mod I use, but they still send them my way. The end of the file looks like this:
Spoiler
         ...
         "graphics/portraits/d1/f99.png",
         "graphics/portraits/d1/f100.png"
      ],
   },
      "custom":{
      "offersCommissions":true,
      "engagesInHostilities":true,
      "buysAICores":true,
      "AICoreValueMult":1,
      "AICoreRepMult":1,
      "buysSurveyData":true,
      "hostilityImpactOnGrowth":true,
      "caresAboutAtrocities":true,
      "punitiveExpeditionData":{
         "vsCompetitors":false,
         "vsFreePort":false,
         "canBombard":false,
         "territorial":true,
      },
   },
},
[close]
I changed the line:
Code
punitiveExpeditionData":{"vsCompetitors":true,
to false.
I dont have any other mods that could interfere with that file. The portraits show up. Do I have to make my own Mod for that?
Thank you for your time.

Hmm - I'm not sure, actually; offhand what you're doing seems like it should work.

Is it possible to let Mod Info.json be able to use Replace for data files in the .jar that usually have the file path for com.fs.starfarer.api...?

My inquiry is that Better Colonies (https://fractalsoftworks.com/forum/index.php?topic=17103) is only able to replace vanilla Orbital Stations, but they're unable to replace the modded Orbital Stations from other factions because these stations still refer to com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java, and a good solution would be able to have the Mod Info.json replace com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java outright or tell it not to load in the core files so that my mod is able to seamlessly integrate with modded Orbital Station as well.

It's not possible, no, and it's not something I could add with a reasonable amount of effort.

Even if it were possible, it'd really be asking for trouble, since generally speaking an extending class expects certain behavior from the base class, and if it doesn't get it, the bugs would be really weird and hard to pin down. I.E. say a station class from someone's mod appears broken, they get a bug report, and trying to sort out what's actually happened would be a nightmare.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on January 02, 2020, 11:45:01 AM
Gave it a closer look - you'll either need to wait a few seconds for it to work (until it's the turn of the star system to be updated, at which point its hyperspace anchor - i.e. star gravity well - coordinates will be updated to match the system's coordinates, or you can call this after setting the location:

sector.getHyperspace().updateAllOrbits();

And have it happen instantly.

I must still be missing something... do I have the wrong system id? Am I overriding the wrong method? Here's the entirety of my mod for a sanity check (sans imports):
Code
package data.scripts;
...
public class MyModPlugin extends BaseModPlugin {
  @Override
  public void onNewGameAfterProcGen() {
    SectorAPI sector = Global.getSector();
    StarSystemAPI system = sector.getStarSystem("Hybrasil");
    system.getLocation().set(0, -20000);
    sector.getHyperspace().updateAllOrbits();
  }
}

Please tell me there's something simple and obvious I'm missing. I'll keep experimenting with trial-and-error in the meantime. I've modified vanilla systems using onNewGame() before so I don't think I should even need to use onNewGameAfterProcGen(), but anyway neither one works. I tried waiting too so unless it's more a matter of minutes than seconds, that wasn't it either. And just to repeat again: the methods related to hyperspace position don't appear to be accessible, but correct me if I'm wrong.

Anyway, thanks for your help so far.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2020, 12:23:56 PM
Aha - put it in onNewGameAfterEconomyLoad(); as it turns out, loading the economy also reloads the starmap and sets the systems to the positions specified therein. This is a bug; fixed on my end just now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on January 02, 2020, 01:45:55 PM
Aha - put it in onNewGameAfterEconomyLoad(); as it turns out, loading the economy also reloads the starmap and sets the systems to the positions specified therein. This is a bug; fixed on my end just now.

Ok, I'll try
Code
onNewGameAfterEconomyLoad()
for now and make a note that it will be updated in a future version.
Thanks again!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2020, 01:48:01 PM
Yep!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on January 02, 2020, 02:18:04 PM
Here's a new question about the "knownShips" tag in the .faction files.

This is what's on the wiki page:
Quote
"knownShips" is the list of blueprints/ships the faction will produce from when they do have a Heavy Industry industry on the producing market. Including ship hulls in the 'hulls' list will allow the faction to produce those ships even when they fall outside of blueprints listed in the 'tags' list.

This is what the Hegemony have:
Code
  "knownShips":{
    "tags":["base_bp", "heg_aux_bp", "lowtech_bp", "midline_bp", "XIV_bp", "hegemony"],
    "hulls":[
      "atlas",
      "monitor",
      "prometheus",
      "legion",
      "onslaught",
      "gryphon",
      "eagle",
      "valkyrie",
    ],
  },

However, since the eagle and the legion are both part of "lowtech_bp" and "midline_bp" what is the nuance I'm missing? I know for a fact the Hegemony also spawn Falcons (part of the midline bp). So what is achieved by also listing hulls explicitly? Or is listing "eagle", "monitor", "legion", etc. purely redundant?

By contrast I know that if a ship isn't in a blue print package listed in the tags (eg "rare_bp") then you must list its hull explicitly. I'm just saying that's not the case here. So what gives?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2020, 03:19:55 PM
However, since the eagle and the legion are both part of "lowtech_bp" and "midline_bp"

They're not, those are both rare_bp, as is the Onslaught.

I know for a fact the Hegemony also spawn Falcons (part of the midline bp).

By contrast I know that if a ship isn't in a blue print package listed in the tags (eg "rare_bp") then you must list its hull explicitly.

Correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 03, 2020, 11:14:08 AM
I've been trying to duplicate a Lion's Guard HQ for a modded faction's guard, but this bug always seems to appear. The industries.csv seems to work. The PNG of the Industry seems to work, but the java, however, doesn't seem to work.
Code
301986 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.econ.impl.ShipQuality.getShipQuality(ShipQuality.java:143)
at com.fs.starfarer.api.util.Misc.getShipQuality(Misc.java:3471)
at com.fs.starfarer.api.impl.campaign.fleets.FleetParamsV3.updateQualityAndProducerFromSourceMarket(FleetParamsV3.java:144)
at com.fs.starfarer.api.impl.campaign.fleets.FleetParamsV3.init(FleetParamsV3.java:122)
at com.fs.starfarer.api.impl.campaign.fleets.FleetParamsV3.<init>(FleetParamsV3.java:83)
at com.fs.starfarer.api.impl.campaign.econ.impl.MayasuranGuardHQ.spawnFleet(MayasuranGuardHQ.java:297)
at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:614)
at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:572)
at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:126)
Line 143
Code
quality += Global.getSector().getFaction(factionId).getDoctrine().getShipQualityContribution();
Line 3471
Code
		return ShipQuality.getShipQuality(market, factionId);
Line 144
Code
this.quality = Misc.getShipQuality(source, factionId);
Line 122
Code
updateQualityAndProducerFromSourceMarket()
Line 83
Code
init(source, fleetType, factionId, combatPts, freighterPts, tankerPts, transportPts, linerPts, utilityPts, qualityMod);
Line 293-306
Code
		FleetParamsV3 params = new FleetParamsV3(
market,
null, // loc in hyper; don't need if have market
"mayasuran_guard",
route.getQualityOverride(), // quality override
fleetType,
combat, // combatPts
freighter, // freighterPts
tanker, // tankerPts
0f, // transportPts
0f, // linerPts
0f, // utilityPts
0f // qualityMod - since the Lion's Guard is in a different-faction market, counter that penalty
);
Line 614
Code
data.activeFleet = data.spawner.spawnFleet(data);
Line 572
Code
spawnAndDespawn();
Line 126
Code
RouteManager.getInstance().advance(amount);
I'm guessing it is the ship's quality? But I haven't had a clue to explain a fix. I've attached a .zip to see the code in question.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 03, 2020, 11:24:44 AM
Does this faction exist?

"mayasuran_guard"

And does it have a doctrine defined in the .faction file?

An NPE on this line:
quality += Global.getSector().getFaction(factionId).getDoctrine().getShipQualityContribution();

Means that either:
Global.getSector()
Returned null (very unlikely, other things would be super broken if this was the case)

OR
Global.getSector().getFaction(factionId)
Returned null (i.e. if the faction doesn't exist)

OR
Global.getSector().getFaction(factionId).getDoctrine()
Returned null (i.e. possibly if the doctrine wasn't defined)

For this exception, these are the only possibilities. E.G. if something went wrong *inside* any of the methods in that line, the stack trace would be different.

Thank you for the detailed post, btw. Makes it a lot easier to see what's going on!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 03, 2020, 01:01:09 PM
Does this faction exist?

"mayasuran_guard"

And does it have a doctrine defined in the .faction file?

An NPE on this line:
quality += Global.getSector().getFaction(factionId).getDoctrine().getShipQualityContribution();

Means that either:
Global.getSector()
Returned null (very unlikely, other things would be super broken if this was the case)

OR
Global.getSector().getFaction(factionId)
Returned null (i.e. if the faction doesn't exist)

OR
Global.getSector().getFaction(factionId).getDoctrine()
Returned null (i.e. possibly if the doctrine wasn't defined)

For this exception, these are the only possibilities. E.G. if something went wrong *inside* any of the methods in that line, the stack trace would be different.

Thank you for the detailed post, btw. Makes it a lot easier to see what's going on!
Code
{
id:"mayasuran_guard",
"color":[0,41,120,255],
"displayName":"Elite Mayasurian Guard",
"displayNameWithArticle":"the Elite Mayasurian Guard",
"logo":"graphics/factions/mayasura.png",
"showInIntelTab":false,
"shipNamePrefix":"EMGS",
"shipNameSources":{
"MERCANTILE":1,
"SPACE":1,
#"GENERAL":1,
},
"names":{
"modern":3,
"future":2,
"slammers":1,
},

# variantOverrides restricts hulls to listed variants and adjusts their probability
    "variantOverrides":{
    },

    # multiplier for how often hulls show up in the faction's fleets
    "hullFrequency":{
        "tags":{"mayasura_e_bp": 10, "mayasura_bp":9, "midline_bp":4},
        "hulls":{
            "MSS_Mokarran":10,
            "MSS_Javanicus_B":10,
"MSS_Arjuna":10,
"conquest":10,
"MSS_Pelican":10,

"falcon":10,
"heron":10,
            "MSS_Sarissa":10,
"eagle":10,
            "MSS_Winghead":10,
"gryphon":10,
            "MSS_Pilgrim":10,
"MSS_Patriot":10,
"MSS_Nebulosa":10,
"MSS_Moa":10,
"MSS_Excalibur":10,

            "MSS_Hammerhead":10,
"hammerhead":10,
            "MSS_Argentavis":10,
            "MSS_Sunder":10,
"sunder":10,
            "MSS_Stingray":10,
"drover":10,

"MSS_Tiburo":10,
            "MSS_Perryi_F":10,
"brawler":10,
"centurion":10,
            "MSS_Mako":10,
            "MSS_Nailer":10,
"vigilance":10,
"MSS_vigilance_m":10,
"MSS_vigilance_carrier":10,
        },
    },

    # ships the faction gets access to when importing S&W out-of-faction
    "shipsWhenImporting":{
        "tags":["base_bp", "midline_bp", "hightech_bp", "mayasura_bp"],
        "hulls":[
            "MSS_Mokarran",
            "MSS_Javanicus_B",
"MSS_Arjuna",
"MSS_Pelican",
"conquest",
"atlas",
"prometheus",

            "MSS_Sarissa",
            "MSS_Winghead",
            "MSS_Pilgrim",
"MSS_Patriot",
"MSS_Moa",
"MSS_Excalibur",
"MSS_Nebulosa",
"eagle",
"gryphon",
"heron",


            "MSS_Hammerhead",
            "MSS_Argentavis",
            "MSS_Sunder",
            "MSS_Stingray",
"MSS_Manta",
"valkyrie",


"MSS_Tiburo",
            "MSS_Perryi_F",
            "MSS_Mako",
            "MSS_Nailer",
"MSS_vigilance_m",
"MSS_vigilance_carrier",
        ],
    },

    "knownShips":{
        "tags":["mayasura_e_bp"],
        "hulls":[
        ],
    },

    # listing ships here will make the faction mostly use them even if other hulls become available
    "priorityShips":{
        "tags":["mayasura_e_bp"],
        "hulls":[
        ],
    },

    "knownFighters":{
        "tags":["base_bp", "mayasura_bp"],
        "fighters":[
"MSS_Crow",
"MSS_Tachi",
"MSS_Sipahi",
"MSS_Ferox",
"MSS_Crossbow",
"MSS_Stormbreaker",
"xyphos_wing",
"thunder_wing",
"claw_wing",
"hoplon_wing",
"trident_wing",
"longbow_wing",
        ],
    },

    "priorityFighters":{
        "tags":["midline_bp"],
        "fighters":[
"MSS_Crow",
"MSS_Tachi",
"MSS_Sipahi",
"MSS_Ferox",
"MSS_Crossbow",
        ],
    },


"knownWeapons":{
"tags":["base_bp", "lowtech_bp", "midline_bp", "missile_bp", "hightech_bp", "persean"],
"weapons":[
"MSS_Orchard",
"MSS_onocrotalus",
"MSS_rocketlauncher",
"MSS_ionlance",
"railgun",
"dualflak",
"heavymauler",
"hveldriver",
"gauss",
"mjolnir",
"sabotpod",
"phasecl",
"cyclone",
"hurricane",
"squall",
"locust",
"pdburst",
"amblaster",
"phasebeam",
"heavyblaster",
"heavyburst",
"ionpulser",
"ionbeam",
"plasma",
"guardian",
],
},
"priorityWeapons":{
"tags":[],
"weapons":[
"MSS_Orchard",
"MSS_onocrotalus",
"MSS_rocketlauncher",
"MSS_ionlance",
],
},
"knownHullMods":{
"tags":["base_bp", "persean"],
"hullMods":[
"advancedshieldemitter", # accelerated
"turretgyros",
"armoredweapons",
"augmentedengines",
"autorepair",
"converted_hangar",
"eccm",
"ecm",
"expanded_deck_crew",
"magazines",
"missleracks",
"extendedshieldemitter",
"frontemitter",
"frontshield",  # makeshift
"hardenedshieldemitter",
"heavyarmor",
"insulatedengine",
"targetingunit",
"nav_relay",
"adaptiveshields", # omni
"operations_center",
"recovery_shuttles",
"fluxbreakers",
"stabilizedshieldemitter",
"surveying_equipment",
"hiressensors",
"efficiency_overhaul",
],
},
"factionDoctrine":{
"warships":3,
"carriers":3,
"phaseShips":1,

"officerQuality":5,
"shipQuality":5,
"numShips":3,

"shipSize":3,

"aggression":2,

"combatFreighterProbability":0.5,      # instead of some portion of the freighters in a fleet
"combatFreighterCombatUseFraction":0.5, # as part of the normal combat lineup
"combatFreighterCombatUseFractionWhenPriority":1,   # as part of normal combat lineup, when marked as priority ship
"autofitRandomizeProbability":0.25,

"commanderSkillsShuffleProbability":0,
"commanderSkills":[
"officer_management",
],
},
"illegalCommodities":[
"drugs",
"organs",
"ai_cores",
],
"portraits":{
"standard_male":[
"graphics/portraits/portrait_league01.png",
"graphics/portraits/portrait_league02.png",
"graphics/portraits/portrait_league03.png",
"graphics/portraits/portrait_league06.png",
"graphics/portraits/portrait12.png",
"graphics/portraits/portrait13.png",
"graphics/portraits/portrait15.png",
"graphics/portraits/portrait17.png",
"graphics/portraits/portrait18.png",
"graphics/portraits/portrait20.png",
"graphics/portraits/portrait25.png",
"graphics/portraits/portrait26.png",
"graphics/portraits/portrait30.png",
"graphics/portraits/portrait31.png",
"graphics/portraits/portrait33.png",
"graphics/portraits/portrait35.png",
],
"standard_female":[
"graphics/portraits/portrait_league00.png",
"graphics/portraits/portrait_league04.png",
"graphics/portraits/portrait_league05.png",
"graphics/portraits/portrait_mercenary02.png",
"graphics/portraits/portrait_mercenary05.png",
"graphics/portraits/portrait14.png",
"graphics/portraits/portrait16.png",
"graphics/portraits/portrait21.png",
"graphics/portraits/portrait22.png",
"graphics/portraits/portrait27.png",
"graphics/portraits/portrait28.png",
"graphics/portraits/portrait29.png",
"graphics/portraits/portrait32.png",
"graphics/portraits/portrait34.png",
"graphics/portraits/portrait37.png",
"graphics/portraits/portrait39.png",
],
},
"fleetTypeNames":{
"patrolSmall":"Elite Mayasuran Company",
"patrolMedium":"Elite Mayasuran Battalion",
"patrolLarge":"Elite Mayasuran Division",
},
},
They should? The .faction file uses this. I'm not sure if the starsector.log should spit out some error if there were typos in the .faction file, but I'll check.

Edit: Okay the faction doesn't exist via console command that explains a lot now. I'll need to make an edit in .factions csv!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 03, 2020, 01:30:09 PM
Did you add it to factions.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 03, 2020, 03:04:14 PM
Did you add it to factions.csv?
Yup that fixed everything!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 03, 2020, 03:44:51 PM
Is it possible to let Mod Info.json be able to use Replace for data files in the .jar that usually have the file path for com.fs.starfarer.api...?

My inquiry is that Better Colonies (https://fractalsoftworks.com/forum/index.php?topic=17103) is only able to replace vanilla Orbital Stations, but they're unable to replace the modded Orbital Stations from other factions because these stations still refer to com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java, and a good solution would be able to have the Mod Info.json replace com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java outright or tell it not to load in the core files so that my mod is able to seamlessly integrate with modded Orbital Station as well.

Just a thought that occurred:

For each modded station type you wanted to merge with Better Colonies (https://fractalsoftworks.com/forum/index.php?topic=17103), could you add your own csv entries for each station industry copy from the mod in question and give it a unique industry id so it would merge with other mods industries.csv? That way, in that entry you can call your custom implementation of com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java

Then you can use a procedural script under onNewGameAfterEconomyLoad() to check for the original industry id from each station in the campaign and replace it with the industry id that will call your mod's OrbitalStation.java replacement.

However some friendly advice:

That kind of implementation requires you to copy other modders industries which to some modders could be considered intrusively changing their mod since other values in the industry entry might change in later updates of their mod that would have to be reflected into the copies of your industry entries with the unique id (each time it changes on their end).

So if wanting to do this, please get permission from the mod author for each mod you want to do this with and make sure they understand the full consequences of what that entails. It will create a soft dependency to maintain compatibility and prevent unintended inconsistency when the two mods are both present on a mod list.

That being said, you have my permission to do this with Archean Order stations and I'll try to remember to update you with any changes I make in the future to the industries.csv entries for my stations.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 03, 2020, 06:06:02 PM

Just a thought that occurred:

For each modded station type you wanted to merge with Better Colonies (https://fractalsoftworks.com/forum/index.php?topic=17103), could you add your own csv entries for each station industry copy from the mod in question and give it a unique industry id so it would merge with other mods industries.csv? That way, in that entry you can call your custom implementation of com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation.java

Then you can use a procedural script under onNewGameAfterEconomyLoad() to check for the original industry id from each station in the campaign and replace it with the industry id that will call your mod's OrbitalStation.java replacement.

However some friendly advice:

That kind of implementation requires you to copy other modders industries which to some modders could be considered intrusively changing their mod since other values in the industry entry might change in later updates of their mod that would have to be reflected into the copies of your industry entries with the unique id (each time it changes on their end).

So if wanting to do this, please get permission from the mod author for each mod you want to do this with and make sure they understand the full consequences of what that entails. It will create a soft dependency to maintain compatibility and prevent unintended inconsistency when the two mods are both present on a mod list.

That being said, you have my permission to do this with Archean Order stations and I'll try to remember to update you with any changes I make in the future to the industries.csv entries for my stations.  :)
I've originally considered it and that might work for past stations, but hypothetical if future stations were made, they would not inherit my changes.

As for Archean Order, I've considered making a separate version for Archean Order users.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 03, 2020, 09:09:43 PM
I've originally considered it and that might work for past stations, but hypothetical if future stations were made, they would not inherit my changes.

As for Archean Order, I've considered making a separate version for Archean Order users.

That is very generous of you!  ;D

Let me know if I can help with anything, and I will add a link and credit to Archean Order's main mod page. (Makes another mental note that much of the main page is really outdated and needs some work.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WadeStar on January 03, 2020, 09:30:39 PM
However, since the eagle and the legion are both part of "lowtech_bp" and "midline_bp"

They're not, those are both rare_bp, as is the Onslaught.

I know for a fact the Hegemony also spawn Falcons (part of the midline bp).


Well egg on my face! Thanks! I can't believe I didn't figure it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on January 03, 2020, 09:32:27 PM
I have a system with a hidden planet and hidden market. I want to add a second planet that is also hidden, owned by the same faction, and that can trade with the first planet (while both remain hidden from the main sector economy). So far, I have generated the planet, but I don't know how to get the two planets to trade. Is there a way to do this?

And a related question: the planet is hidden, but the system appears as having been explored on the map. How can I set it to start as unexplored?

And a third question: Is it possible to have my faction's data added to the Faction tab of the Intel screen, despite being a hidden market? If possible, I would like it to appear there when the faction is first encountered during a playthrough. But, failing that, I would like it to show up by default.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Razor98566 on January 04, 2020, 07:19:15 AM
Hello there,
right now I'm trying to add a faction to the campaign, while I am making progress I have hit a little wall. I have everything set up so far (the .faction, .gen and spawnpoint.java files) I'm getting an error on startup which tells me that the createFleet function from the Spawnpoint file isn't declared. I have been following this tutorial so I have no idea what I have to import to get that function.

Here are the error messages and my SpawnPoint.java file:
Spoiler
Code
java.lang.RuntimeException: Error compiling [data.scripts.world.ColSpawnPoint]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/world/ColSpawnPoint.java', Line 34, Column 56: A method named "createFleet" is not declared in any enclosing class nor any supertype, nor through a static import
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/world/ColSpawnPoint.java', Line 34, Column 56: A method named "createFleet" is not declared in any enclosing class nor any supertype, nor through a static import
Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

public class ColSpawnPoint extends BaseSpawnPoint {

   public ColSpawnPoint(SectorAPI sector, LocationAPI location, loat daysInterval, int maxFleets, SectorEntityToken anchor) {
      super(sector, location, daysInterval, maxFleets, anchor);
   }

   @Override
   protected CampaignFleetAPI spawnFleet() {
     
      String type = null; 
      float r = (float) Math.random();
      if (r > .8f) {
         type = "Scout";
      } else if (r > 0.45f) {
         type = "Security Detachment";
      } else if (r > 0.3f) {
         type = "Task Force";
      } else if (r > 0.15f) {
         type = "Strike Team";
      } else if (r > 0.05f) {
         type = "Security Detachment";
      } else {
         type = "Task Force";
      }
     
      CampaignFleetAPI fleet = getSector().createFleet("bsg_colonies", type);
      getLocation().spawnFleet(getAnchor(), 0, 0, fleet);
     
     
      if (type.equals("Scout") || type.equals("Security Detachment") || type.equals("Task Force") || type.equals("Strike Team")) {
         fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 10);
         fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN,  getAnchor(), 1000);
      } else {
         if ((float) Math.random() > 0.5f) {
            fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 30);
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
         } else {
            fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 20);
            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
         }
      }
     
      return fleet;
   }

}
[close]

Help would be greatly appreciated! ^^
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ActuallyUlysses on January 04, 2020, 09:47:53 AM
Hi,
so I am trying to figure out how game decides how shields look like.

I noticed that sometimes shields are stable + blue color and sometimes unstable + red-ish. I played around with changing shield upkeep and shield efficiency values and while I was able to make shield look unstable, I was not able to make them have that red-ish tint that you get if you use ie. makeshift shield emitter hullmod.

So... anyone knows how to get red tint? :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 04, 2020, 10:34:30 AM
I have a system with a hidden planet and hidden market. I want to add a second planet that is also hidden, owned by the same faction, and that can trade with the first planet (while both remain hidden from the main sector economy). So far, I have generated the planet, but I don't know how to get the two planets to trade. Is there a way to do this?

Call market.setEconGroup(<group id>) for both of those markets with the same parameter, and they should trade with each other (and other markets with the same econGroup, if any).

And a related question: the planet is hidden, but the system appears as having been explored on the map. How can I set it to start as unexplored?

Hmm - hidden pirate bases have markets but don't show up this way, so I'd suggest trying to see what's different about your case. They're defined in PirateBaseIntel.java

And a third question: Is it possible to have my faction's data added to the Faction tab of the Intel screen, despite being a hidden market? If possible, I would like it to appear there when the faction is first encountered during a playthrough. But, failing that, I would like it to show up by default.

That's unrelated to the markets in is controlled via:

"showInIntelTab":true (or false)

In the .faction file.


Hello there,
right now I'm trying to add a faction to the campaign, while I am making progress I have hit a little wall. I have everything set up so far (the .faction, .gen and spawnpoint.java files) I'm getting an error on startup which tells me that the createFleet function from the Spawnpoint file isn't declared. I have been following this tutorial so I have no idea what I have to import to get that function.

Here are the error messages and my SpawnPoint.java file:
...

Hmm. Well, BaseSpawnPoint is not a class that exists, so I suspect you're basing your code on some very, very old examples found somewhere? I'd suggest starting over fresh with something more recent, and probably setting up an IDE - in the long run, that'd save you time tracking down these sorts of issues.



Hi,
so I am trying to figure out how game decides how shields look like.

I noticed that sometimes shields are stable + blue color and sometimes unstable + red-ish. I played around with changing shield upkeep and shield efficiency values and while I was able to make shield look unstable, I was not able to make them have that red-ish tint that you get if you use ie. makeshift shield emitter hullmod.

So... anyone knows how to get red tint? :D

See: hull_styles.json; the shield color is among the things that's defined there. You'd want to create your own new hull style (probably based on copy-pasting an existing one, then tweaking the shield color/whatever else) and then set your ship to use it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ActuallyUlysses on January 04, 2020, 11:54:43 AM
See: hull_styles.json; the shield color is among the things that's defined there. You'd want to create your own new hull style (probably based on copy-pasting an existing one, then tweaking the shield color/whatever else) and then set your ship to use it.

Thanks for quick reply Alex :D

What I found after more research is that shield colors are determined by hull_styles.json, just like you said, and they need to be applied to ships via <hullname>.ship file of specific hull (ie. atlas.ship).

I had no idea about that second part, hence my confusion :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 04, 2020, 01:26:48 PM
Cool, glad you worked it out :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Razor98566 on January 04, 2020, 03:23:01 PM
Hello there,
right now I'm trying to add a faction to the campaign, while I am making progress I have hit a little wall. I have everything set up so far (the .faction, .gen and spawnpoint.java files) I'm getting an error on startup which tells me that the createFleet function from the Spawnpoint file isn't declared. I have been following this tutorial so I have no idea what I have to import to get that function.

Here are the error messages and my SpawnPoint.java file:
...

Hmm. Well, BaseSpawnPoint is not a class that exists, so I suspect you're basing your code on some very, very old examples found somewhere? I'd suggest starting over fresh with something more recent, and probably setting up an IDE - in the long run, that'd save you time tracking down these sorts of issues.

I have followed this tutorial (the only one I found, if there's a newer one pls let me know ^^): https://fractalsoftworks.com/forum/index.php?topic=1282.0 (https://fractalsoftworks.com/forum/index.php?topic=1282.0)

Might be a little outdated but I haven't found anything newer yet...

I thought about setting up my Intellij for starsector but thought it wasn't worth the effort, might do that tomorrow when I'm back at my pc :x
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 04, 2020, 03:38:39 PM
I'd like to re-ask my previous questions, I think they were (understandably) buried during the holiday break.

- Is there a way to make a ship "braver" without changing its loadout? I'm not really sure how the backend deals with it, but I made a modular ship where the core is almost unarmed and has 1 fighter bay. It, however, has three huge modules with tons of close range weapons. However, instead of brawling up-close, it seems to prefer to act like a dedicated carrier and move far outside the range of its weapons or, even its short-ranged fighters (despite having the CARRIER, COMBAT tag - this behavior happens even if I remove all tags).

- Is there a way to trigger a script at a certain date? My aim is to spawn some planets/stations after some years have passed using the same code in the SectorGeneratorPlugin I used to create the system in the first place.

- I am having issues with issuing full retreat, but then the combat doesn't end even when there are no ships or fighters on my side anymore. Looking at other mods, they seem to have some plugins that take care of modules to solve this issue, however, when I tried porting it over to my files, it seems the function calls they use are deprecated...  Is there a workaround for this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 04, 2020, 05:35:55 PM
And a related question: the planet is hidden, but the system appears as having been explored on the map. How can I set it to start as unexplored?

Hmm - hidden pirate bases have markets but don't show up this way, so I'd suggest trying to see what's different about your case. They're defined in PirateBaseIntel.java
See updateKnownPlanets() in CoreLifecyclePlugin (which is called after economy load)
You could only add the market to the star system after economy load (but try adding the market to the economy first without it having an entity, so it gets processed by the economy load code, e.g. having admins added to its comm board). Or manually undo the effects of updateKnownPlanets.

- Is there a way to trigger a script at a certain date? My aim is to spawn some planets/stations after some years have passed using the same code in the SectorGeneratorPlugin I used to create the system in the first place.
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.

Quote
- I am having issues with issuing full retreat, but then the combat doesn't end even when there are no ships or fighters on my side anymore. Looking at other mods, they seem to have some plugins that take care of modules to solve this issue, however, when I tried porting it over to my files, it seems the function calls they use are deprecated...  Is there a workaround for this?
The script for cleaning up the deployed fleet member list requires importing starfarer_obf.jar as a library. (It works by casting the API class CombatFleetManagerAPI to the core code class CombatFleetManager, in order to access and manipulate the deployed fleet member lists directly)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on January 04, 2020, 08:54:26 PM
Thanks, Alex and Histidine. I managed to get most of this working. But I'm still unsure about this part:
You could only add the market to the star system after economy load (but try adding the market to the economy first without it having an entity, so it gets processed by the economy load code, e.g. having admins added to its comm board).
How would I add a market after economy load? I'm pretty clueless about most campaign-layer stuff, or anything outside of combat really. Any examples I can look at?

Edit: Another question. I am trying to add an asteroid belt, and I can spawn the clickable asteroids themselves, but the dense-looking background asteroids that should make up the bulk of the visuals are not showing up. Is there a step I have to do besides system.AddAsteroidBelt()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 05, 2020, 05:58:37 AM
Thanks, Alex and Histidine. I managed to get most of this working. But I'm still unsure about this part:
You could only add the market to the star system after economy load (but try adding the market to the economy first without it having an entity, so it gets processed by the economy load code, e.g. having admins added to its comm board).
How would I add a market after economy load? I'm pretty clueless about most campaign-layer stuff, or anything outside of combat really. Any examples I can look at?
If you're adding the market in code (and I'm not sure hidden markets can be added through json), just call said code from mod plugin's onNewGameAfterEconomyLoad instead of onNewGame/onNewGameAfterProcgen. If you haven't added markets in code before, a bunch of mods have examples (e.g. see Underworld's Styx here (https://bitbucket.org/modmafia/underworld/src/89962a5fa57ae9cf4e1998302a3b5e6fbe2a83d6/src/data/scripts/world/underworld/UW_Styx.java#lines-238:258), here (https://bitbucket.org/modmafia/underworld/src/89962a5fa57ae9cf4e1998302a3b5e6fbe2a83d6/src/data/scripts/world/underworld/UW_Styx.java#lines-43:95)).

Edit: Another question. I am trying to add an asteroid belt, and I can spawn the clickable asteroids themselves, but the dense-looking background asteroids that should make up the bulk of the visuals are not showing up. Is there a step I have to do besides system.AddAsteroidBelt()?
Add a ring band or two on top of it; the vanilla systems in data/scripts/world have examples.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on January 05, 2020, 08:21:10 AM
Hi everyone,

I'm back again with yet another script error.
I tried to mess a bit with missile IA :
Spoiler
Code
package data.scripts.ai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CollisionClass;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.GuidedMissileAI;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipCommand;
import org.lazywizard.lazylib.MathUtils;
import java.awt.Color;
import java.util.List;

import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lwjgl.util.vector.Vector2f;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;
import data.scripts.util.MagicLensFlare;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.AIUtils;


public class SCQ_LongbowMissileAI implements MissileAIPlugin, GuidedMissileAI {

    private static final Color JITTER_COLOR = new Color(143, 169,255,75);
    private static final Color JITTER_UNDER_COLOR = new Color(123, 144,255,155);
   
    private CombatEngineAPI engine;
    public WeaponAPI weapon;
    private List<MissileAPI> missiles;
    private MissileAPI missile;
    private ShipAPI ship,
            launchingShip;
    private CombatEntityAPI target;
    private Vector2f targetLocation;
    private boolean runOnce = false;
    private String missileId = "LNC_waver_CN_mrm",
            missileTeleporterId = "LNC_longbow_waver_mrm_teleporter",
            teleportedMissileId = "LNC_waver_teleported";
    private float minTeleportRange = 1500.0f,
            jitterMinLevel = 20.0f,
            fluxIncrease = 200.0f,
            missileRange,
            teleportRange,
            targetRange,
            jitterLevel;

    //////////////////////
    //  DATA COLLECTING //
    //////////////////////

    public SCQ_LongbowMissileAI(MissileAPI missile, ShipAPI launchingShip) {
        this.missile = missile;
        this.ship = launchingShip;
        this.weapon = missile.getWeapon();
        missileRange = missile.getMaxFlightTime() * missile.getMaxSpeed();
        missileRange = MathUtils.clamp(missileRange, 2500f, 3000f);
        teleportRange = missile.getWeapon().getRange() - missileRange ;
        teleportRange = MathUtils.clamp(teleportRange, 7000f, 10000f);
        runOnce = false;
        if (engine != Global.getCombatEngine()) {
            engine = Global.getCombatEngine();
        }
    }
   
    //////////////////////
    //   MAIN AI LOOP   //
    //////////////////////
   
    @Override
    public void advance(float amount) {
        //skip the AI if the game is paused, the missile is engine-less or fading
        if (engine == null) { //  || engine.isPaused() || missile.isFading() || missile.isFizzling()
                return;
            }
        if(missile != null && (missile.isFizzling() || missile.isFading() || missile.getFlightTime() > missile.getMaxFlightTime())){
            // Vector2f loc, Vector2f vel, Color color, float size, float duration
            engine.spawnExplosion(missile.getLocation(), missile.getVelocity(), new Color(112, 198, 240,200), 15f, 8f);
            //public void applyDamage(CombatEntityAPI entity, Vector2f point, float damageAmount, DamageType damageType, float empAmount, boolean bypassShields, boolean dealsSoftFlux, Object source)
            engine.applyDamage(missile, missile.getLocation(), missile.getHitpoints() * 2, DamageType.FRAGMENTATION, 0, true, false, missile.getSource());
            engine.removeEntity(missile);
            return;
        }
        //variables
        if (targetLocation == null) {
            if (ship.getMouseTarget() != null || !MathUtils.isWithinRange(missile.getLocation(), ship.getMouseTarget(), minTeleportRange)) {
                targetLocation = ship.getMouseTarget();
            } else if (ship.getShipTarget() != null && ship.getShipTarget().getLocation() != null) {
                targetLocation = ship.getShipTarget().getLocation();
            } else if (missile != null && AIUtils.getNearestEnemy(missile) != null) {
                targetLocation = AIUtils.getNearestEnemy(missile).getLocation();
            }
            targetRange = Misc.getDistance(missile.getLocation(), targetLocation);
            if (targetLocation != null) {
                if (targetRange > teleportRange) {
                    float dir = Misc.getAngleInDegrees(missile.getLocation(), targetLocation);
                    targetLocation = Misc.getUnitVectorAtDegreeAngle(dir);
                    targetLocation.scale(teleportRange);
                    Vector2f.add(targetLocation, missile.getLocation(), targetLocation);
                }
                targetLocation = findClearLocation(missile, targetLocation);
            }
        }
        if (!runOnce) {
            if (ship.getCurrFlux() + fluxIncrease >= ship.getMaxFlux() || targetRange < minTeleportRange) {
                Global.getSoundPlayer().playSound("short_range_lauch", 0.8f, 1.2f, ship.getLocation(), new Vector2f(0, 0));
                runOnce = true;
                return;
            } else if (targetLocation != null) { // && (missileRange + teleportRange >= targetRange)
                Global.getSoundPlayer().playSound("system_phase_skimmer", 0.8f, 1.2f, ship.getLocation(), new Vector2f(0,0));
                ship.getFluxTracker().setCurrFlux(ship.getCurrFlux() + fluxIncrease);
                teleportOnce(amount, missile, targetLocation);
                jitterLevel = jitterMinLevel * 1 + (ship.getCurrFlux() / ship.getMaxFlux());
                missile.setJitter(missile, JITTER_COLOR, jitterLevel, 4, 0f, 0 + (ship).getCurrFlux() / ship.getMaxFlux());
                runOnce = true;
                engine.removeEntity(missile);
                return;
            }
        }
        if (targetLocation == null) {
            missile.giveCommand(ShipCommand.ACCELERATE);
        } else {
            float aimAngle = MathUtils.getShortestRotation(missile.getFacing(), VectorUtils.getAngle(missile.getLocation(), targetLocation));
            if (Math.abs(aimAngle) < 45.0f) {
                missile.giveCommand(ShipCommand.ACCELERATE);
            }
            if (aimAngle < 0f) {
                missile.giveCommand(ShipCommand.TURN_RIGHT);
            }
            if (aimAngle > 0f) {
                missile.giveCommand(ShipCommand.TURN_LEFT);
            }
        }
    }

    void teleportOnce(float amount, MissileAPI missile, Vector2f targetLocation){
        if(targetLocation != null) {
                Global.getSoundPlayer().playSound("system_phase_skimmer", 1.2f, 0.5f, missile.getLocation(), new Vector2f(0,0));
            /**for (int i = 0; i < 12; i++) {
                Vector2f cPoint = MathUtils.getRandomPointInCircle(targetLocation, 25f);
                engine.addHitParticle(cPoint, new Vector2f ((float) Math.random() * 0.5f, (float) Math.random() * 0.5f), jitterLevel, jitterLevel, 0.5f, JITTER_COLOR);
            }*/
            if (ship != null && weapon != null && weapon.getShip() == ship) {
                //engine.spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, String projSpecId, Vector2f point, float angle, Vector2f shipVelocity)
                engine.spawnProjectile(
                        null,
                        null,
                        missileTeleporterId,
                        teleportedMissileId,
                        targetLocation,
                        missile.getFacing(),
                        new Vector2f (0f, 0f) //new Vector2f(0,0)
                );
            } else return;
        } else return;
    }

    private Vector2f findClearLocation(MissileAPI missile, Vector2f dest) {
        if (isLocationClear(dest)) return dest;
        float incr = 50f;
        WeightedRandomPicker<Vector2f> tested = new WeightedRandomPicker<Vector2f>();
        for (float distIndex = 1; distIndex <= 32f; distIndex *= 2f) {
            float start = (float) Math.random() * 360f;
            for (float angle = start; angle < start + 360; angle += 60f) {
                Vector2f loc = Misc.getUnitVectorAtDegreeAngle(angle);
                loc.scale(incr * distIndex);
                Vector2f.add(dest, loc, loc);
                tested.add(loc);
                if (isLocationClear(loc)) {
                    return loc;
                }
            }
        }
        if (tested.isEmpty()) return dest; // shouldn't happen
        return tested.pick();
    }

    private boolean isLocationClear(Vector2f loc) {
        for (ShipAPI other : Global.getCombatEngine().getShips()) {
            if (other.isShuttlePod()) continue;
            if (other.isFighter()) continue;
            float dist = Misc.getDistance(loc, other.getLocation());
            float r = other.getCollisionRadius();
            //r = Math.min(r, Misc.getTargetingRadius(loc, other, false) + r * 0.25f);
            if (dist < r + minTeleportRange) {
                return false;
            }
        }
        for (CombatEntityAPI other : Global.getCombatEngine().getAsteroids()) {
            float dist = Misc.getDistance(loc, other.getLocation());
            if (dist < other.getCollisionRadius() + minTeleportRange) {
                return false;
            }
        }
        return true;
    }

    @Override
    public CombatEntityAPI getTarget() {
        return target;
    }

    @Override
    public void setTarget(CombatEntityAPI target) {
        this.target = target;
    }
   
    public void init(CombatEngineAPI engine) {}
}
[close]

And everything looks fine until one of the spawned missiles hit anything (ship, asteroid, shield, projectiles, other missiles, fighters, really anything), which give me a nullPointer...
Spoiler
Code
52777 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamageInner(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.applyDamage(Unknown Source)
at com.fs.starfarer.combat.class.super.O0OO.o00000(Unknown Source)
at com.fs.starfarer.combat.class.super.super(Unknown Source)
at com.fs.starfarer.combat.class.super.super(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]

My guess is that the engine doesn't know the source of the damage and can't apply it to the object hit. Doesn't work either if I'm using the missile's ship and weapon as source for the ShipAPI and WeaponAPI.
Any easy way to fix this ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 05, 2020, 11:35:19 AM
I'd like to re-ask my previous questions, I think they were (understandably) buried during the holiday break.

Ah, my bad, now I remember actually seeing these a while back.

- Is there a way to make a ship "braver" without changing its loadout? I'm not really sure how the backend deals with it, but I made a modular ship where the core is almost unarmed and has 1 fighter bay. It, however, has three huge modules with tons of close range weapons. However, instead of brawling up-close, it seems to prefer to act like a dedicated carrier and move far outside the range of its weapons or, even its short-ranged fighters (despite having the CARRIER, COMBAT tag - this behavior happens even if I remove all tags).

That's a bit strange actually - a SHIP_WITH_MODULES should treat itself as a normal combat ship despite not having weapons.

For setting a reckless personality on a ship without a captain, see CoreLifecyclePluginImpl.pickShipAI() - it does that for automated ships.


Hi everyone,

I'm back again with yet another script error.
I tried to mess a bit with missile IA :

...
And everything looks fine until one of the spawned missiles hit anything (ship, asteroid, shield, projectiles, other missiles, fighters, really anything), which give me a nullPointer...

...
My guess is that the engine doesn't know the source of the damage and can't apply it to the object hit. Doesn't work either if I'm using the missile's ship and weapon as source for the ShipAPI and WeaponAPI.
Any easy way to fix this ?

Hmm - it's kind of hard to tell what the issue actually is.

Does it still happen if you don't assign this AI to the missile and it hits something?

The code that actually spawns this missile could also be useful to see, if it's spawned with code and not fired from a weapon.

Another test would be to fire it from a weapon to see if that makes it work or not; that'd also narrow down the possibilities.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on January 05, 2020, 12:35:58 PM
Hmm - it's kind of hard to tell what the issue actually is.

Does it still happen if you don't assign this AI to the missile and it hits something?

The code that actually spawns this missile could also be useful to see, if it's spawned with code and not fired from a weapon.

Another test would be to fire it from a weapon to see if that makes it work or not; that'd also narrow down the possibilities.

It doesn't happen when this AI isn't used by the projectile, I made some mistakes with some new attempts and in some of them I forgot to remove the AI from the comments of the ModPlugin...

The missile itself is fired from a weapon, and the results (without taking into account the guidance stuff which sometimes come off "weird") are thoses outcomes :
The missile fly like any other missile and aim for the targetLocation ; Nothing crashes here.
The missile is fired by the weapon, the second missile is spawned using the AI, and then, the original missile is removed. The spawned missile flameout before hitting it's target and it doesn't matter if its hit it or not ; Nothing crashes either.
The missile is fired normaly, the second missile spawn in and the original one is removed, but this time, the spawned missile hit before the flameout ; The game crash and dump the log I sent.

I'm wondering if removing the missile that run the new AI doesn't messes with the spawned projectile, as the spawned projectile source si the same as the missile removed, does removing the original missile also make the source of the second invalid ?
I'm going to try "moving" the missile instead of spawning a new one and deleting the older one : Still work like a teleportation if I prevent any colliding while it's moving, right ?

Edit : Well, moving the projectile seems fine, problem solved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 05, 2020, 04:01:01 PM
If you haven't added markets in code before, a bunch of mods have examples (e.g. see Underworld's Styx here (https://bitbucket.org/modmafia/underworld/src/89962a5fa57ae9cf4e1998302a3b5e6fbe2a83d6/src/data/scripts/world/underworld/UW_Styx.java#lines-238:258), here (https://bitbucket.org/modmafia/underworld/src/89962a5fa57ae9cf4e1998302a3b5e6fbe2a83d6/src/data/scripts/world/underworld/UW_Styx.java#lines-43:95)).

There's actually an example in vanilla, too: data\scripts\world\systems\Galatia.java
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silveressa on January 07, 2020, 02:50:18 AM
Sorry if this is the wrong place to ask this but:

Where would I go to mod the tax rates?

I just want to lower the tax from 30 to 12% or so and seem to be unable to locate the actual value in the settings.json. Is it somewhere else or just under a different term than "tax rate?"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 07, 2020, 09:27:58 AM
Hmm - iirc that's set in data/campaign/econ/economy.json, the "defaultTariff" value. But individual factions can also override it via "tariffFraction" in the .faction file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silveressa on January 07, 2020, 06:15:40 PM
Hmm - iirc that's set in data/campaign/econ/economy.json, the "defaultTariff" value. But individual factions can also override it via "tariffFraction" in the .faction file.

Perfect thanks, much appreciated!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 12, 2020, 02:07:11 AM
For setting a reckless personality on a ship without a captain, see CoreLifecyclePluginImpl.pickShipAI() - it does that for automated ships.
Thank you very much! It seemed that the main problem I had was the singular weapon I had outfitted the ship with - which had very long range. For some reason, the AI insisted on flying just out of range of its own weapon, so, I gave it a shorter ranged weapon - a PD weapon, allowing the larger weapons of the modules it carried to fire at will. It was still a bit conservative at first, but then I gave it the reckless AI as you suggested and now it's facehugging like a champ! Just like how it should be!

If you don't mind, I do have another, minor question - is it possible to have a weapon appear in open markets (and black markets) without setting them to the primary bps? (i.e lowtech_bp, midline_bp, hightech_bp). I'm asking because I noticed the utility weapons I set to those bps are getting used by the AI autofit onto CPU ships - with disastrous results. And so I want to put them in a cage away from AI ships, but still allow the player to find them in markets so they could find and use them, themselves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 12, 2020, 05:59:30 PM
If you don't mind, I do have another, minor question - is it possible to have a weapon appear in open markets (and black markets) without setting them to the primary bps? (i.e lowtech_bp, midline_bp, hightech_bp). I'm asking because I noticed the utility weapons I set to those bps are getting used by the AI autofit onto CPU ships - with disastrous results. And so I want to put them in a cage away from AI ships, but still allow the player to find them in markets so they could find and use them, themselves.

Hmm, I'm not sure if it's easily possible - markets sell weapons the faction uses, that's kind of fundamentally how it's set up.

I *think* the way to do this would be to manually add them - as needed - in CampaignEventListener.reportPlayerOpenedMarketAndCargoUpdated(), but perhaps someone with more experience doing this sort of thing from the modding side can chime in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 12, 2020, 06:23:35 PM
Hmm, I'm not sure if it's easily possible - markets sell weapons the faction uses, that's kind of fundamentally how it's set up.
Ah, actually, what you said gave me an idea just now - if I make a sub-faction, and make a sub-market somewhere for that faction, and just set all of those utilities to a special weapon BP for that faction, then I could sell those that way, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 12, 2020, 06:56:08 PM
... yes! Nice. At least, it seems like that would work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on January 15, 2020, 07:49:06 PM
I'm trying to sort DamagingProjectileAPIs that are ProjectileSpawnType.BALLISTIC_AS_BEAM into material and immaterial, eg. railgun vs pulse laser. I figured a good way to do this was to go with the projectile's impact value, which is consistently 0 for pure energy weapons in vanilla and >0 for railguns et al.

The problem I'm running into is that afaict all fired BAB-rays have mass 0, and I can't get the base impact value through the WeaponSpecAPI of the firing weapon.

The only idea I've got for working around this is loading data from CSVs, which seems less than desirable. Any better methods I'm missing?

edit: I think I'll just go with also checking if weapontype is ENERGY for now. It's not perfect, but should work in most cases.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 15, 2020, 11:44:39 PM
I want to make a mod that presents the player with one-off events that result in different outcomes on the campaign layer based on the players choice.  I don't want to start too complex so I was thinking of doing it purely via text, but basically something that pops up in the intel menu like:

Quote
Faction 1 has  recently re-initiated hostilities with Faction 2. Faction 2 has accused Faction 1 of sparking this new conflict as a poorly veiled subtext to pursue their imperialistic policies.

Then the player would be given a few choices to react, like Condemning Faction 1 for a rep bonus or supporting faction 2 for some alternative reward.

Is there anything I can look at to get an idea of how I could implement something like this? Mechanically it doesn't sound too different from the Hegmoney inspection event, but i'm not 100% sure that would be a good reference point. If it is, however, where would I be able to find the code that it utilizies?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 16, 2020, 09:34:01 AM
@prav: sorry about taking a bit to respond; but, right, sounds like the way you're doing it now is better. Relying on the impact field was a bit dodgy, anyway.

I want to make a mod that presents the player with one-off events that result in different outcomes on the campaign layer based on the players choice.  I don't want to start too complex so I was thinking of doing it purely via text, but basically something that pops up in the intel menu like:

Quote
Faction 1 has  recently re-initiated hostilities with Faction 2. Faction 2 has accused Faction 1 of sparking this new conflict as a poorly veiled subtext to pursue their imperialistic policies.

Then the player would be given a few choices to react, like Condemning Faction 1 for a rep bonus or supporting faction 2 for some alternative reward.

Is there anything I can look at to get an idea of how I could implement something like this? Mechanically it doesn't sound too different from the Hegmoney inspection event, but i'm not 100% sure that would be a good reference point. If it is, however, where would I be able to find the code that it utilizies?

It's a good reference point, as long as you know to throw away most of the code. It's implemented here:

com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel

Basically you want:
1) An intel class - this defines the entry in the player's intel screen, and probably a button
2) A custom interaction dialog plugin, the dialog being shown when the button is pressed
3) Some code elsewhere that creates this new intel item and adds it to the player via Global.getSector().getIntelManager()

See: HegemonyInspectionIntel.buttonPressConfirmed() for an example of step 2.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 16, 2020, 03:58:05 PM
Quick question: I am having someone complain that trade is exploitable without a global check on missions or lucrative trades that locks future iterations of these events from occurring a second time for a certain duration.

Is this even possible using the API? I don't think so from what I know, but just wanted to confirm or get a location of where I can take a look and see if any changes are warranted there. I've not seen this as a problem myself, but I haven't played to such an extent that I can be absolutely sure and I want to do my due-diligence on this matter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 16, 2020, 04:39:49 PM
I'm not sure I understand the question. If it's about missions you've added, then you could add timeouts to those, or not, as you choose, right? So I'm probably missing something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 16, 2020, 05:13:37 PM
I'm not sure I understand the question. If it's about missions you've added, then you could add timeouts to those, or not, as you choose, right? So I'm probably missing something.

Nothing I've added that I know of. I'm still trying to determine whether the issue stemmed from missions or generic trade to pirate bases without a tariff. Their issue was gaining 500k credits in 10 minutes through exploitative trade upon a new game start. The description I have available is on the bottom of this page:

http://fractalsoftworks.com/forum/index.php?topic=13183.525 (http://fractalsoftworks.com/forum/index.php?topic=13183.525)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 16, 2020, 05:23:42 PM
Ahh, I see. There's some stuff I need to work out there - apparently Derinkuyu suffers from the same or a related issue on new game start, but you could remove procurement missions entirely by removing them from the generic mission manager on every game load:

GenericMissionManager manager = GenericMissionManager.getInstance();

And then iterate over manager.getCreators() to remove whatever you like. And then, possibly, replace it with your own version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 16, 2020, 05:49:59 PM
Ahh, I see. There's some stuff I need to work out there - apparently Derinkuyu suffers from the same or a related issue on new game start, but you could remove procurement missions entirely by removing them from the generic mission manager on every game load:

GenericMissionManager manager = GenericMissionManager.getInstance();

And then iterate over manager.getCreators() to remove whatever you like. And then, possibly, replace it with your own version.

Thanks for the information!  :)

I don't think I will go to that length most likely as it has the potential to break in future updates and be harder to maintain, but it's really awesome that this is possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Razor98566 on January 17, 2020, 11:10:36 AM
Hello there,
I'm currently following a tutorial (this one: http://fractalsoftworks.com/forum/index.php?topic=3877.0 (http://fractalsoftworks.com/forum/index.php?topic=3877.0)) to make my factions spawn on the map and do stuff.

Since this tutorial is a little old now there are a few things in my way. The functions "addOrbitalStation" and '"createFleet" are no longer available and now I'm wondering how I can circumvent this and make my code work.

Here's what's in my gen and spawnpoint files so far:
colGen.java:
Spoiler
Code
package data.scripts.world;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.procgen.SectorProcGen;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.campaign.Faction;
import com.fs.starfarer.api.EveryFrameScript;

@SuppressWarnings("unchecked")
public class colGen implements SectorGeneratorPlugin {

public void generate(SectorAPI sector) {
   
StarSystemAPI system = sector.getStarSystem("Corvus");

SectorEntityToken stock = system.getEntityByName("Abandoned Storage Facility");
   
SectorEntityToken token = system.createToken(0, 0);

SectorEntityToken caprica = system.addPlanet("bsg_caprica", token, "New Caprica", "Barren",5,  5, 20, 15);

                *this is where I would like to add the station*
                SectorEntityToken station1 = system.add
                *Can be ignored, I gotta fix ColSpawnPoint first xD*
system.addSpawnPoint(new ColSpawnPoint());

FactionAPI bsg_colonies = sector.getFaction("bsg_colonies");
bsg_colonies.setRelationship("hegemony", 1);
bsg_colonies.setRelationship("tritachyon", -1);
bsg_colonies.setRelationship("pirates", 0);
bsg_colonies.setRelationship("independent", 0);
bsg_colonies.setRelationship("bsg_cylons", -100);
bsg_colonies.setRelationship("player", 1);
}
}
[close]

ColSpawnPoint.java:
Spoiler
Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

import data.scripts.world.BaseSpawnPoint;

public class ColSpawnPoint extends BaseSpawnPoint {

public ColSpawnPoint(SectorAPI sector, LocationAPI location,
        float daysInterval, int maxFleets, SectorEntityToken anchor) {
        super(sector, location, daysInterval, maxFleets, anchor);
        }

@Override
protected CampaignFleetAPI spawnFleet() {
        //if ((float) Math.random() < 0.5f) return null;
        String type = null;
        float r = (float) Math.random();
        if (r > .6f) {
           type = "patrol";
        } else if (r > 0.25f) {
           type = "raid";
        } else if (r > 0.10f) {
           type = "attack";
        } else {
           type = "systemDefense";
        }

        //
        CampaignFleetAPI fleet = getSector().createFleet("bsg_colonies", type);
        getLocation().spawnFleet(getAnchor(), 0, 0, fleet);

        fleet.setPreferredResupplyLocation(getAnchor());
        if (type.equals("patrol") || type.equals("raid") || type.equals("attack")) {
           fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 10);
           fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
        } else {
           if ((float) Math.random() > 0.8f) {
              fleet.addAssignment(FleetAssignment.PATROL_SYSTEM, null, 30);
              fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
        } else {
              fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 20);
              fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
           }
        }
        return fleet;
   }
}
[close]

I'm using IntelliJ, just in case it matters ^^

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 17, 2020, 05:15:13 PM
That tutorial is 8 years old and can be assumed not to work.
You should look at a recent vanilla or mod example. Look in [starsector-core]\data\scripts\world\systems (Galatia.java for adding markets through code, other files for markets added with economy json files*)

*data/campaign/econ
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ottodeluxe on January 18, 2020, 06:13:33 AM
I didn't find anything after fiddling around a bit, and neither did I find an answer with the search function, so it's "ask someone who has a clue"-time:

I am trying to make a hull mod that buffs various aspects of a ship depending on the number of crew aboard. My problem is, I don't know how to get the current number of crew on a given ship to determine the bonus.
So far, I have tried to get the CrewFraction from the FleetMemberAPI, and multiplying the fraction by the minimum crew to get the total. However, my call to ship.getMember() always returns null. Is the FleetMemberAPI only available in combat? If so, is there any way to get the actual number of crew on a specific ship for use in a hull mod?

my idea in code:
Spoiler
   public float getCrew(ShipAPI ship) {
      FleetMemberAPI memberAPI = ship.getFleetMember();
      float crewFraction = memberAPI.getCrewFraction();
      float neededCrew = memberAPI.getMinCrew();
      float totalCrew = neededCrew * crewFraction;
      return totalCrew;
   }
[close]

My second guess is, that CrewCompositionAPI.getCrew() would also do what I want, but again, I have not found a way to access it.

edit: This does actually work, but seems to be a convoluted and not very fool-proof way. Duplicate names would cause a problem.

Spoiler
   public float getCrew(ShipAPI ship) {
      logger.info(ship);
      FleetMemberAPI memberAPI = ship.getFleetMember();
      logger.info("first try: " + memberAPI);
      List<FleetMemberAPI> ships = Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy();
      for (FleetMemberAPI fleetShip : ships){
         logger.info(fleetShip);
         if (fleetShip.getShipName().equals(ship.getName())) {
            memberAPI = fleetShip;
            logger.info("found match");
         }
      }
      logger.info("second try: " + memberAPI);
      currentMember = memberAPI;
      float crewFraction = memberAPI.getCrewFraction();
      float neededCrew = memberAPI.getMinCrew();
      float totalCrew = neededCrew * crewFraction;
      crew = totalCrew;
      return totalCrew;
   }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: scmp on January 18, 2020, 10:04:29 AM
I'm trying to make my first mod which just adds a new star system into the game. I'm running into two (probably related) problems.

This is the first.
Spoiler
(https://i.imgur.com/xRddZri.png)
[close]

and when I try to launch the game I get this error.
Spoiler
(https://i.imgur.com/TnBn9VI.png)
[close]

I've been googling to no avail. Any help please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on January 18, 2020, 10:10:00 AM
Hi!

1) You need to make sure that your package structure matches the file location in the source.

2) You need to have correct import statements in order for your code to recognize external classes (like the one's from starsector). I see you are using an IDE, though I don't know which one. In Netbeans imports can be done automatically once the starfarer api zip has been linked as a library.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 19, 2020, 01:33:12 AM
Is there a way to suppress a SectorEntityToken from using the drop groups normally defined for that entity type in salvage_entity_gen_data.csv?
(I'm specifying my own random drops in code)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on January 19, 2020, 06:38:23 AM
Hello
What parameter in weapon files decides whether beam is interrupted by passing missiles or goes through?
thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 19, 2020, 09:35:48 AM
I didn't find anything after fiddling around a bit, and neither did I find an answer with the search function, so it's "ask someone who has a clue"-time:

I am trying to make a hull mod that buffs various aspects of a ship depending on the number of crew aboard. My problem is, I don't know how to get the current number of crew on a given ship to determine the bonus.
So far, I have tried to get the CrewFraction from the FleetMemberAPI, and multiplying the fraction by the minimum crew to get the total. However, my call to ship.getMember() always returns null. Is the FleetMemberAPI only available in combat? If so, is there any way to get the actual number of crew on a specific ship for use in a hull mod?

It seems like if you used the second way, but instead of the name, used ship.getFleetMemberId(), that should work.


Is there a way to suppress a SectorEntityToken from using the drop groups normally defined for that entity type in salvage_entity_gen_data.csv?
(I'm specifying my own random drops in code)

Hmm - you could create a version of the sal_salvageOptionSelected rule that doesn't call "SalvageEntity performSalvage" and instead calls... whatever you like, to generate the salvage. See ScientistAICoreIntel.genLoot() for a quick example doing something similar, though it doesn't go the same exact route because the interaction flow there is not the standard salvage interaction.


Hello
What parameter in weapon files decides whether beam is interrupted by passing missiles or goes through?
thank you

See: hil.wpn for how that's defined, in particlar you're looking for "pierceSet".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jeffg10 on January 19, 2020, 12:49:36 PM
So, basically i took the "Tore Up Plenty" mod and tired to update it to no avail (presumably due to my lack of modding experience) BUT as a last effort i just took the OG file and updated the mod_info.jason and tup.version files to the current version and the mod seems to work properly? is this intended / normal behavior or is it due to the technically simple nature of the mod?

Edit: Missions work, but Campaign still crashes, press F
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 20, 2020, 07:20:50 PM
Is there a way for a hullmod check if there is a ship with a certain other hullmod within the player's fleet?

I want a hullmod to give different effects to a ship if there are other ships in the fleet with that other hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on January 21, 2020, 06:24:04 AM
Hello
What parameter in weapon files decides whether beam is interrupted by passing missiles or goes through?
thank you

See: hil.wpn for how that's defined, in particlar you're looking for "pierceSet".

There doesnt appear to be any difference in action between wpn file with full pierceSet defined and the one without it alltogether. I assumed pierceSet contains flags for objects that are supposed to be pierced through, was I wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 21, 2020, 08:46:06 AM
Is there a way for a hullmod check if there is a ship with a certain other hullmod within the player's fleet?

I want a hullmod to give different effects to a ship if there are other ships in the fleet with that other hullmod.

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).


There doesnt appear to be any difference in action between wpn file with full pierceSet defined and the one without it alltogether. I assumed pierceSet contains flags for objects that are supposed to be pierced through, was I wrong?

No, you're correct. I'm not sure what's not working out in your specific case but this works for the HIL mounted on a ship, so I'd start with that and try to figure out what the differences are.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature 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!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 21, 2020, 04:59:17 PM
- Sorry I messed up and pressed quote instead of modify -
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature 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);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature 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!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hoon 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 22, 2020, 09:27:48 AM
A lot of things could be, yeah :) But, let me add that since we're talking about it, might save someone a bit of trouble later.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on January 22, 2020, 09:54:22 AM
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.

Custom dialogs it is then! Thanks! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 22, 2020, 12:00:48 PM
(Actually, come to think of it, handling it as a new intel item might work more smoothly in terms of player experience, so it doesn't interrupt what they were doing. On the other hand, if it's something major, then a dialog popping up means they definitely won't miss it... could go either way, really.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on January 22, 2020, 02:22:16 PM
(Actually, come to think of it, handling it as a new intel item might work more smoothly in terms of player experience, so it doesn't interrupt what they were doing. On the other hand, if it's something major, then a dialog popping up means they definitely won't miss it... could go either way, really.)

(Well it is things blowing up because of a cursed lobster statue, so I think I'm going to interrupt the player with humorous events. :p Who knew that your second in command could trip over a statue and fall out of a torpedo tube?!)

On a related note: Rules.csv and scripts called from Rules.csv has access to a set of MemoryAPI's as determined by the MemKeys (global, local, etc etc). These can be accessed from arbitrary scripts by calling the right getMemory (withoutUpdate?), right?

For example, Memkeys.Global's memoryAPI is the same as Global.getSector().getMemoryWithoutUpdate()?

Or is there a different way for non-dialog scripts to access those memoryAPIs?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2020, 02:42:31 PM
That's exactly right, yeah.

Who knew that your second in command could trip over a statue and fall out of a torpedo tube?!)

:D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cloverstar on January 24, 2020, 05:51:17 AM
Hi! I'm trying to create a new structure and I want to script something that happens with the structure every time the size of the market increases or when it gets shutdown. As far as I can tell, there's nothing in the BaseIndustry class that is specifically implemented to do this. Would the best way be to just override advance() and check to see if the market size has changed from an internally stored variable? How does advance() actually work and how is it called? If I do just check the current size against an instance variable, do I have to guard against data races? How do I script something to happen when it gets shutdown?

Thanks in advance! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 10:05:49 AM
Hi! I'm trying to create a new structure and I want to script something that happens with the structure every time the size of the market increases or when it gets shutdown. As far as I can tell, there's nothing in the BaseIndustry class that is specifically implemented to do this. Would the best way be to just override advance() and check to see if the market size has changed from an internally stored variable? How does advance() actually work and how is it called? If I do just check the current size against an instance variable, do I have to guard against data races? How do I script something to happen when it gets shutdown?

Thanks in advance! :)

For being shut down: the Industry.notifyBeingRemoved() method gets called when that happens. If you override it, make sure to call super.notifyBeingRemoved() if you're extending the BaseIndustry class since that does some things (such as making sure installed AI cores don't disappear without a trace).

For changing size, yeah, what you're thinking about with advance() sounds reasonable. No need to worry about data races or anything multithreaded, everything relevant to this happens in the same thread.

Hi and welcome to the forum, btw :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cloverstar on January 24, 2020, 10:23:01 AM
Thank you! I've been playing tons and I'm looking forward to giving some back.

Also, can you talk about the specifics on how advance() is used? I presume it's not simply advancing by a month if days are being passed in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 10:28:43 AM
Generally an advance() method is called once per frame for the current location, and something like once per X frames in other locations, where X is 20-40 (I forget exactly what, and it's subject to being fine tuned).

The "float amount" parameter is the seconds elapsed during the previous frame, so assuming a stable 60 frames per second, it'd be something like 0.0166666 for the current location, and that times X for non-current locations.

To convert that to days, you'd do something like Global.getSector().getClock().convertToDays(amount).

Btw, there's javadoc here:
http://fractalsoftworks.com/forum/index.php?topic=7164.0

And if you haven't figured it out already, the api source is in starfarer.api.zip - especially handy if you're using an IDE, which would let you easily look at a fair bit of the code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 24, 2020, 12:22:37 PM
Where can I get a list of dialogue API stuff like GetHisOrHer() and GetHimselfOrHerself().

My IDE doesn't let me retrieve this as easy and I end up having to look back at source materials, but I'm sure there is more than these two.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 12:34:29 PM
Hmm? Could you clarify about what context you're working in here? What class has these methods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cloverstar on January 24, 2020, 12:56:11 PM
Generally an advance() method is called once per frame for the current location, and something like once per X frames in other locations, where X is 20-40 (I forget exactly what, and it's subject to being fine tuned).
The "float amount" parameter is the seconds elapsed during the previous frame, so assuming a stable 60 frames per second, it'd be something like 0.0166666 for the current location, and that times X for non-current locations.
To convert that to days, you'd do something like Global.getSector().getClock().convertToDays(amount).
Btw, there's javadoc here:
http://fractalsoftworks.com/forum/index.php?topic=7164.0
And if you haven't figured it out already, the api source is in starfarer.api.zip - especially handy if you're using an IDE, which would let you easily look at a fair bit of the code.

Oh it's the number of seconds for industries? I saw it was days for CoreImmigrationPluginImpl and I just assumed it was days lol
Is there a way for me to trigger monthly scripts? I feel like doing something like checking to see if the market size changes every second is super silly and might unnecessarily bog down performance.

And yea I have seen the javadoc but unless I'm missing something, it only has prototypes right? No descriptions? I tried to look up how advance worked and there wasn't anything about it. I've just been digging through the api to understand the structure with notepadd++ since I'm too lazy to actually set up the environment on eclipse lmao

Also, I'd just like to say how much I appreciate you for participating in the modding community so much and for making a game that allows actual Java injection, first I've seen!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 01:05:10 PM
Yeah, CoreImmigrationPluginImpl is like the one exception, IIRC because it's run by the economy which is just... different.

Is there a way for me to trigger monthly scripts? I feel like doing something like checking to see if the market size changes every second is super silly and might unnecessarily bog down performance.

See: IntervalUtil for something that allows you to effectively run things every <whatever period>. However, that'll actually require slightly *more* performance than just checking the size of a market against a saved integer, so I wouldn't recommend it for this. The performance cost of performing a trivial check like this is negligible.

And yea I have seen the javadoc but unless I'm missing something, it only has prototypes right? No descriptions? I tried to look up how advance worked and there wasn't anything about it. I've just been digging through the api to understand the structure with notepadd++ since I'm too lazy to actually set up the environment on eclipse lmao

Yeah, there's not a lot of comments there, but you can infer some stuff from the method names. I'd suggest setting up an environment - I totally get that it's a pain, but it'd save you time in the long run.

(For advance specifically, and anything related, if there's an "amount" parameter for time, it's seconds.)

Also, I'd just like to say how much I appreciate you for participating in the modding community so much and for making a game that allows actual Java injection, first I've seen!

Helps that the game is in Java, I suppose :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 24, 2020, 04:06:37 PM
How can I add a message to the left side ticker where new quests, intel, etc appear? I want to add a message like "earned 10000 credits" or something, but it isn't associated with a quest.

I was eyeing this code from a quest:
Quote
TextPanelAPI text = dialog.getTextPanel();
AddRemoveCommodity.addCreditsGainText(loanAmount, text);
However I don't know where to get the TextPanelAPI from. There is no "dialog" where I want to activate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 04:15:06 PM
See: com.fs.starfarer.api.impl.campaign.intel.MessageIntel and how it's used.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 24, 2020, 04:15:39 PM
Or Global.getSector().getCampaignUI().addMessage() for basic messages.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 04:18:33 PM
Oh yeah! (Fun fact: that uses MessageIntel under the hood, but, yeah, a nice shortcut for basic stuff.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 24, 2020, 04:42:06 PM
Hmm? Could you clarify about what context you're working in here? What class has these methods?
Mainly the bar missions and quests itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 04:45:39 PM
Then you'd want to check that class/its superclass(es) for additional methods of that nature, either in the javadoc or in the source.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 24, 2020, 04:59:37 PM
Or Global.getSector().getCampaignUI().addMessage() for basic messages.
Thank you very much!

Actually, I have another question, and though it's more lore related, I promise it's related to modding - Do Volturnian Lobsters have a spawning season? If so, around which month/s does it happen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 05:05:55 PM
That information is in a quantum uncertainty state, meaning that since it hasn't been necessary yet, it hasn't been decided.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 24, 2020, 05:22:52 PM
How to get accurate shield efficiency?
damage *= ship.getShield().getFluxPerPointOfDamage();
damage *= ship.getMutableStats().getShieldDamageTakenMult().getModifiedValue();
Is this right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 05:29:31 PM
Yeah, I think that's correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 24, 2020, 06:02:25 PM
That information is in a quantum uncertainty state, meaning that since it hasn't been necessary yet, it hasn't been decided.
Haha, in that case I have no choice but to formulate my own hypethesis!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2020, 06:02:50 PM
Indeed :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Panpiper on January 25, 2020, 06:15:20 AM
Is it possible to place encounters like defended Domain artifacts, and wandering patrols, etc., inside a hand built system? I'd like to add several such to the Sol system https://fractalsoftworks.com/forum/index.php?topic=17711.0 (https://fractalsoftworks.com/forum/index.php?topic=17711.0) made by Scmp. I don't have the first clue how to mod this game other than hacking from code examples. If it is possible, could someone point me to an example of someone else's code where they have done this successfully so I can learn (IE: blatantly steal code) from them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on January 25, 2020, 09:14:18 PM
Quick and probably stupid question for you Alex.
Code
	/**
* Whether it was spawned by a missile (or by other non-directly-by-weapon means).
* Needed for incoming damage evaluation AI to function properly in these cases.
* @param fromMissile
*/
void setFromMissile(boolean fromMissile);
Should setFromMissile *always* called? Even say on a missile that MIRVs into only a single missile not a spread of several, and the spawned shot does the same damage as the base missile so to speak?

Edit: Or any other weird splitting projectile or missile stuff, that isn't anything like exists in vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 25, 2020, 09:26:59 PM
That actually only needs to be set for ballistic projectiles/plasma shots. If a missile launches another missile, this method doesn't need to be called.

Edlt: and also for BALLISTIC_AS_BEAM shots.


Is it possible to place encounters like defended Domain artifacts, and wandering patrols, etc., inside a hand built system? I'd like to add several such to the Sol system https://fractalsoftworks.com/forum/index.php?topic=17711.0 (https://fractalsoftworks.com/forum/index.php?topic=17711.0) made by Scmp. I don't have the first clue how to mod this game other than hacking from code examples. If it is possible, could someone point me to an example of someone else's code where they have done this successfully so I can learn (IE: blatantly steal code) from them?

Take a look at data.scripts.world.systems.Galatia for an example of a probe being spawned.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 26, 2020, 01:07:56 AM
That actually only needs to be set for ballistic projectiles/plasma shots. If a missile launches another missile, this method doesn't need to be called.
Does it also apply to ballistic projectiles spawned from other projectiles?

My current interpretation is:
Use for
Don't use for
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cloverstar on January 26, 2020, 03:06:15 AM
What would be the best way to go about implementing a dynamic upkeep for a structure? I was thinking about calling applyIncomeAndUpkeep() and changing upkeep as I go but I'm not sure how to zero out the upkeep at the beginning of a new month. I've just been creating intel messages but it really clogs up your screen if you have multiple colonies lol
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2020, 08:05:42 AM
My current interpretation is:
Use for
  • Ballistic spawned from ballistic
  • Ballistic spawned from missile
Don't use for
  • Missile spawned from ballistic
  • Missile spawned from missile

It should just be:

But, fortunately, the effects are fairly minor regardless. IIRC It'll just make the AI take some extra care against these.


What would be the best way to go about implementing a dynamic upkeep for a structure? I was thinking about calling applyIncomeAndUpkeep() and changing upkeep as I go but I'm not sure how to zero out the upkeep at the beginning of a new month.

That should work fine, yeah. You don't need to reset anything - it's just a value, the code applying it to the monthly expenses looks at it and does whatever is appropriate. Unless I'm misunderstanding something about what you're asking...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 26, 2020, 08:39:36 AM
What would be the best way to go about implementing a dynamic upkeep for a structure? I was thinking about calling applyIncomeAndUpkeep() and changing upkeep as I go but I'm not sure how to zero out the upkeep at the beginning of a new month. I've just been creating intel messages but it really clogs up your screen if you have multiple colonies lol

Not sure your skill level, so I'll spell it out a bit. :)

You want to extend BaseIndustry and override applyIncomeAndUpkeep(). Copy BaseIndustry's applyIncomeAndUpkeep() method, understand what it is doing, then modify it to do what you want.

If you override apply(), make sure BaseIndustry's apply() method is getting called (i.e. your apply() has a super.apply() call in it), because it calls updateIncomeAndUpkeep() which calls applyIncomeAndUpkeep(). Otherwise you need to call applyIncomeAndUpkeep() yourself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cloverstar on January 26, 2020, 10:38:31 AM
That should work fine, yeah. You don't need to reset anything - it's just a value, the code applying it to the monthly expenses looks at it and does whatever is appropriate. Unless I'm misunderstanding something about what you're asking...

I'm trying to have a structure keep a running monthly tab and then apply the debt at the end of the month. Basically, during the month, add x credits n times to the tab, both of which can vary month to month. Then, charge the player at the end of the month for the total and zero out the tab. I'm probably just going to have to detect when the month changes through advance() with more instance variables huh
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2020, 10:46:54 AM
Ah - for adding an expense to the current month, see:

MonthlyReport report = SharedData.getData().getCurrentReport();

There is code using it in CoreScript.reportEconomyTick() for a more detailed example.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cloverstar on January 26, 2020, 12:28:43 PM
MonthlyReport report = SharedData.getData().getCurrentReport();

Thanks, it worked perfectly! Are the MonthlyReport and FDNode objects transient? Is it safe to retrieve them once for the industry and store it, or should I retrieve them every time I want to update the values? I noticed you did the latter.

Also, I followed your code to retrieve the node for a particular industry and created this monstrosity:
FDNode iNode = report.getNode(report.getNode(report.getNode(report.getNode(MonthlyReport.OUTPOSTS), market.getId()), "industries"), getId());
Is there any way to truncate or is it just a tree you have to traverse?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on January 26, 2020, 02:23:04 PM
Thank you for the clarification Alex!

But uh can you please consider rewriting that comment on setFromMissile in the API please? Right now it is supremely confusing, vague and doesn't even really say when to use it (and it is *really* specific when it should be used) and thus it is literally worthless than nothing at all. Heh, sorry that was crass but really.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2020, 02:28:34 PM
Adjusted the comment. And, hey, it made you ask the question, so it was better than nothing :)

Thanks, it worked perfectly! Are the MonthlyReport and FDNode objects transient? Is it safe to retrieve them once for the industry and store it, or should I retrieve them every time I want to update the values? I noticed you did the latter.

You should do the latter since the "current" report will change when the month ticks over.

("Transient", at least in terms of Starsector API stuff, generally means "does not end up in the savefile", btw, which isn't what we're talking abut here. I get what you mean, though, and it's not wrong to say it the way you did; just pointing out it could be a point of confusion at some later time.)

Also, I followed your code to retrieve the node for a particular industry and created this monstrosity:
FDNode iNode = report.getNode(report.getNode(report.getNode(report.getNode(MonthlyReport.OUTPOSTS), market.getId()), "industries"), getId());
Is there any way to truncate or is it just a tree you have to traverse?

It is a tree, but this construction looks wrong. getNode() returns an FDNode but takes a String as a parameter so you couldn't chain it like this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cloverstar on January 26, 2020, 02:43:15 PM
It is a tree, but this construction looks wrong. getNode() returns an FDNode but takes a String as a parameter so you couldn't chain it like this.

getNode() is overloaded! There's one that takes in an FDNode and is actually the one you use in CoreScript
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2020, 03:04:10 PM
Ah! Well in that case, yeah, that's probably workable :) I'd personally split it into a bunch of lines - and separate statements and variables for each node, just for clarity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 27, 2020, 12:04:15 PM
Quick question: Is there a tool that can find and replace a string in all the files in a chosen directory?

I think I used something like this a couple years ago to find a particularly elusive nullpointer from a removed weapon id, but i'm not sure if it can replace anything. I wanted to use it to change the id in every instance it's found in a variant file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 27, 2020, 12:06:49 PM
Hmm, your IDE of choice should support this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 27, 2020, 12:12:32 PM
Thanks! I had assumed that could only work for actual project files in the jar or the imported dependencies. I'll look into using it for the variants directory.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 27, 2020, 12:29:50 PM
(I was kind of assuming the variant files would be in a resource folder in your project.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 27, 2020, 01:57:29 PM
I think so, but it has been a long time since I messed with the project structure. I know the API and core files are.

*Edit* Oh wow yeah, that was actually super easy. I can edit mod files directly from the overall project (separate from jar) sub-directories in the IntelliJ 2017 community edition IDE- by directory- and easily find and replace strings for any of the mod files- no jar update or recompile from src required. That saves so much time it's crazy. For work assignments I used the current version of IntelliJ Ultimate and wasn't sure how many features were retained in the older versions- wasn't putting two and two together in this case.

I wasn't sure if I could save the changes to mod files specifically- I thought the dropdown under the project was mostly for reference only. So glad to know I'm wrong.  ;D

I think with a little work I can quite literally make full mod compatibility with factions mods- even possibly ones that edit vanilla files. Assuming no complications come up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on January 27, 2020, 05:37:45 PM
Sounds like you've got it sorted, but in case you find yourself unable to do it for some files: Notepad++ also has a directory wide (and recursive subdirectory) search/replace feature.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 27, 2020, 09:32:17 PM
Sounds like you've got it sorted, but in case you find yourself unable to do it for some files: Notepad++ also has a directory wide (and recursive subdirectory) search/replace feature.

Thanks for the added information.  :)

If I run into that I'll keep this tool in my back pocket.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 29, 2020, 05:15:22 AM
How can I run a continuous script throughout the campaign? I tried making an everyframe script that polls the current month every set inverval, but I don't know how to get it to run during the campaign layer...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 29, 2020, 08:22:22 AM
Hmm - Global.getSector().addScript() sounds like what you're looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 29, 2020, 03:13:05 PM
Hmm - Global.getSector().addScript() sounds like what you're looking for.
It certainly was, thank you very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on January 31, 2020, 01:15:51 PM
Is there a tag for weapon_data.csv that forces the AI to factor in stray debris when a (very) long-range sniper weapon is set to autofire?

I've already added the 'STRIKE' and 'USE_VS_FRIGATES' tags to ensure it doesn't waste its time targeting fighters, but is there one for the above?

Yes, I'm aware that such a weapon is far better being left in the player's control, but I'm experimenting with a sniper support frigate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2020, 01:26:32 PM
The AI considers it by default - well, it checks for disabled ships/pieces of them, anyway, but not (iirc) asteroids.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bellou on February 01, 2020, 09:19:13 AM
How can i edit the Shipdesign.java skill to give +20% ordnance point bonus? i tried changing the "public static final float OP_BONUS = 20f;" but its not working.

Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2020, 06:19:59 PM
Hi - you can't edit the file directly; the source is just provided for reference. Since the value here is "final", you can't change it from other code as well, so the only way to change it would be to implement a copy of this with your new values, and then point the skill to your new copy from skill_data.csv. Hope that makes sense!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bellou on February 01, 2020, 11:29:13 PM
Hi - you can't edit the file directly; the source is just provided for reference. Since the value here is "final", you can't change it from other code as well, so the only way to change it would be to implement a copy of this with your new values, and then point the skill to your new copy from skill_data.csv. Hope that makes sense!

I see thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on February 02, 2020, 10:13:30 PM
How can I trigger nearby patrols to inspect the player fleet? Also is there a reference I could look up to define something as illegal when the ship's player is inspected?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ThunderElemental on February 03, 2020, 04:16:43 AM
I'm trying to create a hullmod that either buffs the ship's torpedo-type missiles only, or forbids equipping missiles other than torpedoes, but I find myself stumped. Any advice on how (or if) this can be achieved?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on February 03, 2020, 05:10:24 AM
I'm trying to create a hullmod that either buffs the ship's torpedo-type missiles only, or forbids equipping missiles other than torpedoes, but I find myself stumped. Any advice on how (or if) this can be achieved?
There isn't, as far as I know, a "torpedo" classification. They're all missiles. I believe vanilla ones have the STRIKE tag, but other weapons have that too. But depending on what you want to buff or the effect you want to achieve, you can probably check by taking a list of all missiles in the map and seeing if they have "Torpedo" in their name, I guess.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on February 03, 2020, 07:42:55 AM
Is there a way to determine whether the battle is a regular battle or a fleet pursuit? Or more generally, where a given ship's retreat plane is? For example, if I want the AI to only activate a system when pointed in the direction of retreat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 03, 2020, 09:47:23 AM
I'm trying to create a hullmod that either buffs the ship's torpedo-type missiles only, or forbids equipping missiles other than torpedoes, but I find myself stumped. Any advice on how (or if) this can be achieved?
There isn't, as far as I know, a "torpedo" classification. They're all missiles. I believe vanilla ones have the STRIKE tag, but other weapons have that too. But depending on what you want to buff or the effect you want to achieve, you can probably check by taking a list of all missiles in the map and seeing if they have "Torpedo" in their name, I guess.

Right, yeah - unfortunately, the methods involved are not exposed, and if they were, there's no mechanism to buff certain weapons that selectively. In the next release, there'll be a "WeaponOPCostModifier" you can add to a ship's stats (generally via a built-in hullmod) that would be able to make fine-grained distinctions like this, though you'd *still* have to figure out in some way whether a weapon is a torpedo or not.


How can I trigger nearby patrols to inspect the player fleet? Also is there a reference I could look up to define something as illegal when the ship's player is inspected?

Just roughly, you'd give the patrol fleet an intercept assignment with whatever text override was appropriate. And... you'd have to do *something* to make it actually do a customs inspection - there are rules regarding this in rules.csv; I forget exactly what the trigger is, you can look at the tOffPatrolBeginNoTalk rule and the ones around there. As far as what's illegal, that would be defined in the faction's file. You could also re-rig the entire interacton via rules if you need something truly custom, if it's worth the effort.


Is there a way to determine whether the battle is a regular battle or a fleet pursuit? Or more generally, where a given ship's retreat plane is? For example, if I want the AI to only activate a system when pointed in the direction of retreat.

CombatFleetManagerAPI.getGoal() - then, based on that and the side (player or enemy) you're looking at, it's either up or down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 03, 2020, 01:50:42 PM
Okay, I'm at the end of my rope on this one.

I have a SHIP_WITH_MODULES that spawns as a neutral hull when deployed with one of the modules destroyed from a previous battle and not repaired yet. The trick is that it doesn't do that when using any other type of module, and the issue appears on other ships if their modules are replaced by the problematic ones.

So it definitely is an issue stemming for the modules, yet they both are identical line-by-line in any way but name (same fields, same hullmods, similar stats).

It just spawns like this
(https://i.imgur.com/mcKVHXG.png)
[close]

Any pointer to things that could trigger such behavior would be an immense help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 03, 2020, 02:21:26 PM
Hmm. Do both of those modules have >0 ordnance points, and weapons or fighter bays? If the game thinks one of the modules is an "armor" module and the other one isn't, that could trigger different behavior.

See:
Code
public static boolean isActiveModule(ShipAPI ship) {
boolean notActiveModule = ship.getVariant().getHullSpec().getOrdnancePoints(null) <= 0 &&
  ship.getVariant().getWeaponGroups().isEmpty() &&
  ship.getMutableStats().getNumFighterBays().getModifiedValue() <= 0;
return !notActiveModule;
}

If that returns different results for one module but not the other, it could have something to do with it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 03, 2020, 03:16:27 PM
HA! In this instance, the non buggy module had a built-in weapon, and the buggy one didn't.

So I tried to only destroy an armor module on a ship that had both armor and non armor modules and it worked fine. Then I tried to only put that same armor module in all slots and destroy one, and the bug showed up again.

It seems that having one or more destroyed modules on a ship that ONLY has pure armor modules is the trigger.

[edit] But adding 1 OP to one of the armor module seems to solve the issue, so that's a workaround in the meantime.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 03, 2020, 03:27:38 PM
[edit] But adding 1 OP to one of the armor module seems to solve the issue, so that's a workaround in the meantime.

On the plus side, this workaround allows players to see armor modules' stats in the refit screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on February 03, 2020, 03:38:05 PM
Couldn't find any good info on this:

Can skin files change a ship's tech and engine styles?

edit: Nevermind, stumbled into it eventually. The lack of documentation for skins is driving me mad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 03, 2020, 04:02:37 PM
HA! In this instance, the non buggy module had a built-in weapon, and the buggy one didn't.

So I tried to only destroy an armor module on a ship that had both armor and non armor modules and it worked fine. Then I tried to only put that same armor module in all slots and destroy one, and the bug showed up again.

It seems that having one or more destroyed modules on a ship that ONLY has pure armor modules is the trigger.

[edit] But adding 1 OP to one of the armor module seems to solve the issue, so that's a workaround in the meantime.

Ahh yes, that reminds me of what the issue was, exactly. I believe this is fixed for the next release.

Couldn't find any good info on this:

Can skin files change a ship's tech and engine styles?

edit: Nevermind, stumbled into it eventually. The lack of documentation for skins is driving me mad.

In lieu of that, here's the source for the method that loads skin files:

Spoiler
   private static void loadHullSkin(String path) throws IOException, JSONException {
      JSONObject json = LoadingUtils.getMergedJSON(path);
      
      String baseId = json.getString("baseHullId");
      String skinId = json.getString("skinHullId");
      
      if (ShipHullSpecStore.hasHullSpec(skinId)) return;
      
      if (StarfarerSettings.isRunningTC()) {
         if (!ShipHullSpecStore.hasHullSpec(baseId)) {
            log.info("Skipping skin [" + path + "], assuming it's a core skin not used in total conversion.");
            return;
         }
      }
      
      
      ShipHullSpec hullSpec = SpecStore.getSpec(ShipHullSpec.class, baseId).clone();
      int baseOP = hullSpec.getOrdnancePoints(null);
      
      hullSpec.getTags().clear();
      JSONArray tags = json.optJSONArray("tags");
      if (tags != null) {
         for (int i = 0; i < tags.length(); i++) {
            String tag = tags.getString(i);
            tag = tag.trim();
            if (tag.isEmpty()) continue;
            hullSpec.addTag(tag);
         }
      }
      
      
      hullSpec.setHullId(skinId);
      hullSpec.setBaseHullId(baseId);
      hullSpec.setShipFilePath(path);
      
      boolean compatible = true;
      
      if (json.has("coversColor")) {
         Color c = JSONUtils.getColor(json, "coversColor");
         hullSpec.setCoversColor(c);
      }
      
      if (json.has("spriteName")) {
         hullSpec.getSpriteSpec().setSpriteName(json.getString("spriteName"));
      }
      if (json.has("hullName")) {
         hullSpec.setHullName(json.getString("hullName"));
      }
      if (json.has("hullDesignation")) {
         hullSpec.setDesignation(json.getString("hullDesignation"));
      }
      if (json.has("manufacturer")) {
         hullSpec.setManufacturer(json.getString("manufacturer"));
      } else if (json.has("tech")) {
         hullSpec.setManufacturer(json.getString("tech"));
      }
      if (json.has("fleetPoints")) {
         hullSpec.setFleetPoints(json.getInt("fleetPoints"));
      } else if (json.has("fpMod")) {
         hullSpec.setFleetPoints(hullSpec.getFleetPoints() + json.getInt("fpMod"));
      }
      
      hullSpec.setRestoreToBase(json.optBoolean("restoreToBaseHull", false));
      
      if (json.has("fighterBays")) {
         hullSpec.setFighterBays(json.getInt("fighterBays"));
      }
      if (json.has("ordnancePoints")) {
         hullSpec.setOrdnancePoints(json.getInt("ordnancePoints"));
         if (baseOP != hullSpec.getOrdnancePoints(null)) {
            compatible = false;
         }
      }
      if (json.has("baseValue")) {
         hullSpec.setBaseValue(json.getInt("baseValue"));
      }
      
      if (json.has("baseValueMult")) {
         hullSpec.setBaseValue((int) (hullSpec.getBaseValue() * json.getDouble("baseValueMult")));
      }
      if (json.has("descriptionId")) {
         hullSpec.setDescriptionId(json.getString("descriptionId"));
      } else {
         hullSpec.setDescriptionId(baseId);
      }
      if (json.has("descriptionPrefix")) {
         String prefix = json.getString("descriptionPrefix");
         if (!prefix.endsWith(".")) prefix += ".";
         hullSpec.setDescriptionPrefix(prefix);
      } else {
         hullSpec.setDescriptionPrefix(null);
      }
      
      if (json.has("systemId")) {
         hullSpec.setShipSystemId(json.getString("systemId"));
      }
      
//      "removeWeaponSlots":[],
//      "removeEngineSlots":[],
      if (json.has("removeWeaponSlots")) {
         JSONArray arr = json.getJSONArray("removeWeaponSlots");
         for (int i = 0; i < arr.length(); i++) {
            String slotId = arr.getString(i);
            for (WeaponSlotSpec slot : hullSpec.getAllWeaponSlots()) {
               if (slot.getId().equals(slotId)) {
                  hullSpec.getAllWeaponSlots().remove(slot);
                  compatible = false;
                  break;
               }
            }
         }
      }
      if (json.has("removeEngineSlots")) {
         JSONArray arr = json.getJSONArray("removeEngineSlots");
         List<EngineSlotSpec> remove = new ArrayList<EngineSlotSpec>();
         for (int i = 0; i < arr.length(); i++) {
            int slotIndex = arr.getInt(i);
            if (slotIndex >= 0 && slotIndex < hullSpec.getEngineSlots().size()) {
               remove.add(hullSpec.getEngineSlots().get(slotIndex));
            }
         }
         hullSpec.getEngineSlots().removeAll(remove);
      }
      
//      "removeBuiltInMods":[],
//      "removeBuiltInWeapons":[],
      if (json.has("removeBuiltInMods")) {
         JSONArray arr = json.getJSONArray("removeBuiltInMods");
         for (int i = 0; i < arr.length(); i++) {
            String modId = arr.getString(i);
            hullSpec.getBuiltInMods().remove(modId);
            compatible = false;
         }
      }
      if (json.has("removeBuiltInWings")) {
         JSONArray arr = json.getJSONArray("removeBuiltInWings");
         for (int i = 0; i < arr.length(); i++) {
            String wingId = arr.getString(i);
            hullSpec.getBuiltInWings().remove(wingId);
            compatible = false;
         }
      }
      if (json.has("removeBuiltInWeapons")) {
         JSONArray arr = json.getJSONArray("removeBuiltInWeapons");
         for (int i = 0; i < arr.length(); i++) {
            String slotId = arr.getString(i);
            hullSpec.getBuiltInWeapons().remove(slotId);
            compatible = false;
         }
      }
      
//      "removeHints":[CIVILIAN],
//      "addHints":[],
      if (json.has("removeHints")) {
         JSONArray arr = json.getJSONArray("removeHints");
         for (int i = 0; i < arr.length(); i++) {
            ShipTypeHints hint = ShipTypeHints.valueOf(arr.getString(i));
            hullSpec.getHints().remove(hint);
         }
      }
      if (json.has("addHints")) {
         JSONArray arr = json.getJSONArray("addHints");
         for (int i = 0; i < arr.length(); i++) {
            ShipTypeHints hint = ShipTypeHints.valueOf(arr.getString(i));
            hullSpec.getHints().add(hint);
         }
      }
      
      
//      "builtInMods":["tow_cable"],
      if (json.has("builtInMods")) {
         JSONArray arr = json.getJSONArray("builtInMods");
         for (int i = 0; i < arr.length(); i++) {
            String modId = arr.getString(i);
            hullSpec.addBuiltInMod(modId);
            //compatible = false;
         }
      }
      
      if (json.has("builtInWings")) {
         JSONArray arr = json.getJSONArray("builtInWings");
         for (int i = 0; i < arr.length(); i++) {
            String wingId = arr.getString(i);
            hullSpec.addBuiltInWing(wingId);
            compatible = false;
         }
      }
      
//      "builtInWeapons":{
//          "WS 016":"tpc",
//          "WS 017":"tpc",
//       },
      if (json.has("builtInWeapons")) {
         JSONObject builtInWeapons = json.getJSONObject("builtInWeapons");
         if (JSONObject.getNames(builtInWeapons) != null) {
            for (String slotId : JSONObject.getNames(builtInWeapons)) {
               String weaponId = builtInWeapons.getString(slotId);
               hullSpec.addBuiltInWeapon(slotId, weaponId);
               compatible = false;
            }
         }
      }

//      "weaponSlotChanges":{
//         "WS 001":{
//            #"angle": 0,
//               #"arc": 210,
//               #"mount": "TURRET",
//               #"size": "SMALL",
//               "type": "BALLISTIC"
//         }   
//      },
      if (json.has("weaponSlotChanges")) {
         JSONObject changes = json.getJSONObject("weaponSlotChanges");
         if (JSONObject.getNames(changes) != null) {
            for (String slotId : JSONObject.getNames(changes)) {
               WeaponSlotSpec slot = hullSpec.getWeaponSlot(slotId);
               JSONObject data = changes.getJSONObject(slotId);
               if (data.has("angle")) {
                  slot.setAngle((float) data.getDouble("angle"));
               }
               if (data.has("arc")) {
                  slot.setArc((float) data.getDouble("arc"));
               }
//               JSONUtils.mapToEnum(weaponSlotSpecJson, "type", WeaponAPI.WeaponType.class, null),
//               JSONUtils.mapToEnum(weaponSlotSpecJson, "size", WeaponAPI.WeaponSize.class, null),
//               JSONUtils.mapToEnum(weaponSlotSpecJson, "mount", WeaponSlotType.class, null),
               if (data.has("mount")) {
                  slot.setSlotType(JSONUtils.mapToEnum(data, "mount", WeaponSlotType.class, null));
               }
               if (data.has("size")) {
                  slot.setSlotSize(JSONUtils.mapToEnum(data, "size", WeaponAPI.WeaponSize.class, null));
               }
               if (data.has("type")) {
                  slot.setWeaponType(JSONUtils.mapToEnum(data, "type", WeaponAPI.WeaponType.class, null));
               }
               compatible = false;
            }
         }
      }
      
//      "engineSlotChanges":{
//      "0":{
//         #"width": 0,
//          #"length": 210,
//          #"angle": 210,
//          #"style": "SMALL",
//      }   
//   },
      
      if (json.has("engineSlotChanges")) {
         JSONObject changes = json.getJSONObject("engineSlotChanges");
         if (JSONObject.getNames(changes) != null) {
            for (String slotId : JSONObject.getNames(changes)) {
               int index = Integer.parseInt(slotId);
               EngineSlotSpec slot = hullSpec.getEngineSlots().get(index);
               
               JSONObject data = changes.getJSONObject(slotId);
               if (data.has("style")) {
                  String style = data.getString("style");
                  CustomEngineData custom = SpecStore.getSpec(CustomEngineData.class, style);
                  slot.setStyle(Style.CUSTOM);
                  slot.setCustomData(custom);
               }
               if (data.has("width")) {
                  slot.setWidth((float) data.getDouble("width"));
               }
               if (data.has("length")) {
                  slot.setLength((float) data.getDouble("length"));
               }
               if (data.has("angle")) {
                  slot.setAngle((float) data.getDouble("angle"));
               }

            }
         }
      }
      
      hullSpec.setCompatibleWithBase(compatible);
      
      
      ShipHullSpecStore.putSpec(skinId, hullSpec);
      
      if (firstTime) {
         //if (!hullSpec.isDHull()) {
         //if (!hullSpec.isDHullOldMethod()) {
            ShipHullSpecLoader.addDHull(hullSpec);
         //}
         
         HullVariantSpec empty = new HullVariantSpec(skinId + "_Hull", hullSpec);
         if (hullSpec.getAllWeaponSlots().isEmpty()) {
            empty.setVariantDisplayName("Standard");
         } else {
            empty.setVariantDisplayName("Custom");
         }
         empty.setSource(VariantSource.HULL);
         ShipVariantStore.addVariant(empty);
      }
   }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 03, 2020, 04:47:59 PM
We can't change the hull's style?

Converted that code into an example.txt, attached. 8)

EDIT: put it on pastebin https://pastebin.com/GgRCn26p

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 04, 2020, 12:15:16 AM
While I'm working on it, is there an easy way to "buff" ships only for the campaign battle autoresolve plugin? I have a faction that is mostly balanced in real time battles, but get stomped virtually 100% of the time even with a 2:1 fleet-point advantage against vanilla factions.

I tried to have a hullmod that increases all damage deal and reduces all damage taken while on the campaign layer:
Code
member.getStats().getHullDamageTakenMult().modifyMult(ID, 0.1f);
member.getStats().getBallisticWeaponDamageMult().modifyPercent(ID, 1000);
member.getStats().getEnergyWeaponDamageMult().modifyPercent(ID, 1000);
member.getStats().getMissileWeaponDamageMult().modifyPercent(ID, 1000);
and tried to increase all damage to ships:
Code
member.getStats().getDamageToCapital().modifyPercent(ID, 1000);
member.getStats().getDamageToCruisers().modifyPercent(ID, 1000);
member.getStats().getDamageToDestroyers().modifyPercent(ID, 1000);
member.getStats().getDamageToFrigates().modifyPercent(ID, 1000);

but neither of these affected the results.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 04, 2020, 08:26:36 AM
The strength is based on the ship's fleet point value, with a component of that being assigned based on the fraction of spent ordnance points. ... and since that's not capped, if you were to set the OP used to, say, double the maximum (by perhaps assigning an ungodly number of vents or capacitors), that should increase the autoresolve strength substantially.

but get stomped virtually 100% of the time even with a 2:1 fleet-point advantage against vanilla factions.

Oh, wait, missed this part. Hmm. See: BattleAutoresolverPluginImpl.computeDataForMember() for reference. I wonder if the game is thinking those ships are civilian, for some reason, or that they can't be deployed for combat? I'd suggest trying to step through that method in a debugger (or setting up something similar on your end and printing out what gets computed); seems like something's going wrong there - if the FP value is higher, the ship should be that much better in autoresolve.

Ah - another possibility. If these are, say, SHIP_WITH_MODULES, and the actual hulls have a lot of unspent OP, that would reduce the strength a lot.



We can't change the hull's style?

Converted that code into an example.txt, attached. 8)

EDIT: put it on pastebin https://pastebin.com/GgRCn26p

Nice! (I guess not, hmm.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: scmp on February 04, 2020, 12:11:25 PM
Is there a way to render models outside of the game? I'm trying to get the rings for Saturn in my mod to look right, and having to open the game and start a new game every change is making it quite the effort.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on February 04, 2020, 07:30:53 PM
Just roughly, you'd give the patrol fleet an intercept assignment with whatever text override was appropriate. And... you'd have to do *something* to make it actually do a customs inspection - there are rules regarding this in rules.csv; I forget exactly what the trigger is, you can look at the tOffPatrolBeginNoTalk rule and the ones around there. As far as what's illegal, that would be defined in the faction's file. You could also re-rig the entire interacton via rules if you need something truly custom, if it's worth the effort.
Hmm... I was thinking of setting a hullmod to be illegal; but I don't think I've seen a field like that in the faction file...

I also have another question - how do I properly destroy a ship (code-wise) that I dynamically spawned in combat?

I am using a dummy ship which I search for during combat and then replace it with the correct variant of the ship I want. However, I find that this method seems to cause an error in battle, where it is impossible for me to retreat (all ships have retreated - all fighters destroyed, full retreat is on, but battle won't end). My suspicion is that some 'remnant' of these ships/fighters are the cause of this...

here is the replacer code
Code
	
private void resolveDroneReplace(ShipAPI ship) {

String variantID = SHIP_ID_PAIR.get(ship.getHullSpec().getBaseHullId());
        Vector2f location = new Vector2f(ship.getLocation());
        float angle = ship.getFacing();
        int owner = ship.getOwner();

if(variantID == null) {
return;
}

if(variantID.contentEquals("select_dronepod")) {
variantID = DRONEPOD_PICKER.pick();
}


   FleetMemberAPI shipMember;
   if(variantID.contentEquals(FIREBASE_ID)){
   shipMember = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variantID);
   }else {
   shipMember = Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, variantID);
   }
       
       

           
       shipMember.getRepairTracker().setCrashMothballed(false);
       shipMember.getRepairTracker().setMothballed(false);
       shipMember.getCrewComposition().addCrew(shipMember.getNeededCrew());
       shipMember.getRepairTracker().setCR(ship.getCurrentCR());
       shipMember.setOwner(owner);
       shipMember.setAlly(ship.isAlly());
       
       boolean suppress = engine.getFleetManager(owner).isSuppressDeploymentMessages();
       engine.getFleetManager(owner).setSuppressDeploymentMessages(true);
       ShipAPI newShip = engine.getFleetManager(owner).spawnFleetMember(shipMember, location, angle, 0f);
       newShip.setCollisionClass(CollisionClass.FIGHTER);

       shipMember.setShipName(newShip.getHullSpec().getHullName());

   float axis;
   float range;
       switch(variantID) {
  case FIREBASE_ID:
       axis = (float)Math.random()*360;
     range = 100f;
         
         Vector2f randomHeading = MathUtils.getPointOnCircumference(ZERO, range, axis);

            newShip.getVelocity().set(randomHeading);
            newShip.setFacing(axis);
break;
    case KONPEITO_GUNPOD_ID:
    case RINTEL_GUNPOD_ID:
    case CANNON_GUNPOD_ID:
    case INF_1DIV_ID:
    case INF_2DIV_ID:
    case INF_3DIV_ID:

            ShipAIConfig droneAI = new ShipAIConfig();
            droneAI.alwaysStrafeOffensively = true;
            droneAI.backingOffWhileNotVentingAllowed = false;
            droneAI.turnToFaceWithUndamagedArmor = true;
            droneAI.burnDriveIgnoreEnemies = false;
            droneAI.personalityOverride = "reckless";
   
            newShip.setShipAI(Global.getSettings().createDefaultShipAI(newShip, droneAI));

            newShip.getVelocity().set(ship.getVelocity());
break;
default:
           newShip.getVelocity().set(ship.getVelocity());
       }
       
       
       newShip.setAngularVelocity(ship.getAngularVelocity());
       
       for (ShipAPI child : newShip.getChildModulesCopy()) {
           child.setCollisionClass(CollisionClass.FIGHTER);
       }

       newShip.setInvalidTransferCommandTarget(true);
       engine.getFleetManager(owner).setSuppressDeploymentMessages(suppress);
       

       engine.removeEntity(ship);
}
[close]

Right now, I just use engine.removeEntity(ship); to destroy the dummy and let the spawned unit die on its own via normal combat. Perhaps I am not doing something I should be?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 04, 2020, 08:33:33 PM
Is there a way to render models outside of the game? I'm trying to get the rings for Saturn in my mod to look right, and having to open the game and start a new game every change is making it quite the effort.

You could set up a basic main class of your own with a render loop and so on, though that'd require probably doing more scaffolding work than is reasonable.

If you run the game's jvm in debug mode and connect to it from your IDE, it might be able to do hot code replace/hotswap/whatever your IDE calls it. Meaning you can - within certain limits - change the code, save, and it should be reflected in the already-running game. I'm not 100% sure if it's possible to set this up with the game as it is; it might require replacing the JRE the game comes with, with a JDK, and you might run into other problems. Not having done this myself - I just run the game from the IDE directly - I'm not certain if this can be made to work with the release version of the game or not.

Hmm... I was thinking of setting a hullmod to be illegal; but I don't think I've seen a field like that in the faction file...

For this, you'd need to write your own version of CargoScan.java, basically.

Right now, I just use engine.removeEntity(ship); to destroy the dummy and let the spawned unit die on its own via normal combat. Perhaps I am not doing something I should be?

Yeah - the corresponding DeployedFleetMemberAPI needs to be cleaned out of that side's CombatFleetManagerAPI, iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on February 04, 2020, 10:23:42 PM
Yeah - the corresponding DeployedFleetMemberAPI needs to be cleaned out of that side's CombatFleetManagerAPI, iirc.
Hmm... I couldn't seem to find a method in CombatFleetManagerAPI that removes a DeployedFleetMemberAPI, however there was a code that the module retreat cleaner used from CombatFleetManager:

Will this do the trick?

Code
       CombatFleetManager manager = (CombatFleetManager) engine.getFleetManager(ship.getOwner());
       
       manager.getDeployed().remove(manager.getDeployedFleetMember(ship));

EDIT: It did work, and it seems the retreating bug has been fixed! Thanks again, Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 05, 2020, 12:26:06 AM
The strength is based on the ship's fleet point value, with a component of that being assigned based on the fraction of spent ordnance points. ... and since that's not capped, if you were to set the OP used to, say, double the maximum (by perhaps assigning an ungodly number of vents or capacitors), that should increase the autoresolve strength substantially.

So I checked the autoresolve plugin results for those ships, and my super fast, super fragile, no-dissipation-all-vent ships come around one third of the ship strength of vanilla hulls for the getMemberStrength() calculation... Pretty bad.

I tested to add triple the max vents via script, and that technically works, but given the amount of possible ways such boosted ships could make it into the player's hands I'm a bit worried about using such blunt approach (not mentioning the myriad of UI weirdness). And as long as fleets use fleetpoints to get generated, I can't really play on that front either since it only leads to undersized fleets... Unless I also massively boost fleet sizes too but that comes with its own horde of issues and inconsistencies.

Would it be possible to add a ship_strength_multiplier mutable stat somewhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on February 05, 2020, 04:30:22 AM
How can I check from inside a hullmod if a ship belongs to the player? I've tried checking the owner, but it seems all ships in the campaign map have an owner of 0. I tried getting the fleet member, but ship.getFleetMember() always returns false, even for AI ships in the campaign. Finally, I tried removing the mod directly off the player's fleet list:

Code
for(FleetMemberAPI member: Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
   
    log.info("Removing mod from player fleet " + this.spec.getId());
member.getVariant().removeMod(this.spec.getId());
    }

...but it doesn't seem to remove the mod at all.

My only goal is to make a hullmod that only applies to AI ships and will be auto-removed if the player ever lays their hands on the ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 05, 2020, 07:15:19 AM
Is there a way to render models outside of the game? I'm trying to get the rings for Saturn in my mod to look right, and having to open the game and start a new game every change is making it quite the effort.

IIRC, when I was doing a big ring system I used GIMP and put each ring graphic on its own layer. The graphics are grouped in rings_X.PNGs in graphics/planets. I marked the center and edges of each ring with short lines. Then I could move them left/right until they looked how I wanted and use the distance tool to measure the offsets I needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2020, 08:32:11 AM
So I checked the autoresolve plugin results for those ships, and my super fast, super fragile, no-dissipation-all-vent ships come around one third of the ship strength of vanilla hulls for the getMemberStrength() calculation... Pretty bad.

But did you figure out *why*? It's still fundamentally based on fleet points multiplied by fraction of OP used (0.2 + 0.8 * op/max op), and also modified by any officer, and ship quality. The latter is either grabbed from the inflater, or, if that's not available, based on the d-mods the hull has. It's also modified by the hull. And by the current CR. I don't think just blanketly adding a multiplier would be a good solution, if their FP value is high, there's some other issue here.

(The "super fast, super fragile" etc really shouldn't factor in here at all.)


How can I check from inside a hullmod if a ship belongs to the player? I've tried checking the owner, but it seems all ships in the campaign map have an owner of 0. I tried getting the fleet member, but ship.getFleetMember() always returns false, even for AI ships in the campaign. Finally, I tried removing the mod directly off the player's fleet list:

Code
for(FleetMemberAPI member: Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
   
    log.info("Removing mod from player fleet " + this.spec.getId());
member.getVariant().removeMod(this.spec.getId());
    }

...but it doesn't seem to remove the mod at all.

My only goal is to make a hullmod that only applies to AI ships and will be auto-removed if the player ever lays their hands on the ship.

Hmm, I'm not sure. There may be a way to do it, and what you're doing in the pasted code seems like it should work, so it's hard to say why it wouldn't unless the mod is built into the hull, in which case removeMod() won't work, and you need to addSuppressedMod() instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 05, 2020, 11:00:53 AM
I want to prohibit installation of an AI core in an industry.

Is there a way to disable the menu option to install AI cores?
With special items this is possible by returning an empty list for getInstallableItems(), but I don't seem to have that option for AI cores.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2020, 11:56:04 AM
Not sure if it's in the currently-released version or if it's a more recent addition, but, you can (or will be able to) override:

public boolean canInstallAICores() {
   return true;
}

In BaseIndustry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 05, 2020, 12:26:34 PM
that's definitely an upcoming feature.
I take it there is no option for that in the current version then.

I'll just make it display a lot of red, angry messages if the player installs a core in the interim.
thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2020, 12:31:44 PM
Yeah, I probably wouldn't have added it if it was already possible, so "angry red messages" sounds like the way to go for the moment :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 05, 2020, 01:01:46 PM
But did you figure out *why*?
Those ships have very crappy dissipation (like, REALLY small) 2.0 efficiency shields, weak armor, weak hull, but very deep flux capacity and high top speed. All in all, bad for all the stats that matter to the autoresolve hull strength except for one. They end up around one third of a vanilla ship "hull strength" multiplier for the autoresolve plugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2020, 01:03:39 PM
Are we looking at something different? None of those stats matter for autoresolve. They used to way back, but now it's all based on FP. Unless I'm way, way mistaken about this somehow?

Edit: some of these *do* matter in terms of how much damage the ships suffer from autoreslove (good shields = less damage taken), but they don't affect the *strength* of the ships, or who wins a given engagement.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on February 05, 2020, 04:07:47 PM
Hmm, I'm not sure. There may be a way to do it, and what you're doing in the pasted code seems like it should work, so it's hard to say why it wouldn't unless the mod is built into the hull, in which case removeMod() won't work, and you need to addSuppressedMod() instead.
Actually, after some testing, it seems that the hullmod seems to get removed from my other ships when I deploy them in battle (simulation), with a strange exception: when I pull them up on the fleet viewer, the hullmods are still present and visible, even after repeated refresh of that page.

In addition, running a simulation on a ship (that shows the hullmods still present), shows that the mods still take effect (but only on that ship, strangely enough, when I deploy allied ships, they do not appear to have the mod in-simulation, but when I take a look at their page in [F] Fleet Viewer, the hullmods are still present on their page as well.)


EDIT: Ah, I should add, in case it might actually be relevant - these mods were added to the ship via its .variant file. So while designing these ships, I give them these hullmods by default (which strengthens them in AI hands), but when they are bought/salvaged by the player, the idea is to remove these buffs.

EDIT 2: I should mention that there is ONE instance where I was able to actually remove the mod from the ships, even the viewer - and that was via ShipAPI's getVariant (whereas the method I am using above is FleetMemberAPI.getVariant)

   
Code
 public void applyEffectsAfterShipCreation(ShipAPI ship, String id){    
    ship.getVariant().removeMod(this.spec.getId());
}

However, using this method, I am unable to verify if the ship is in the player's fleet because as mentioned earlier ship.getFleetMember() always returns null
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2020, 09:24:38 PM
What you probably want is to do it in:
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id);

And use stats.getFleetMember(). That will also in some cases return null - so check for it - but should return the fleet member for the fleet screen update etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on February 05, 2020, 09:30:21 PM
What you probably want is to do it in:
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id);

And use stats.getFleetMember(). That will also in some cases return null - so check for it - but should return the fleet member for the fleet screen update etc.
Hmm, it seems "MutableShipStatsAPI stats" doesn't have getFleetMember(), though. It does seem to have .getVariant(), but then I don't have a way to check if the ship belongs in the player's fleet...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 05, 2020, 11:39:51 PM
Are we looking at something different? None of those stats matter for autoresolve. They used to way back, but now it's all based on FP. Unless I'm way, way mistaken about this somehow?

Edit: some of these *do* matter in terms of how much damage the ships suffer from autoreslove (good shields = less damage taken), but they don't affect the *strength* of the ships, or who wins a given engagement.

I have been looking at
Code
protected FleetAutoresolveData computeDataForFleet(CampaignFleetAPI fleet)
and
Code
protected FleetMemberAutoresolveData computeDataForMember(FleetMemberAPI member)
and at least that part of the autoresolve has a "shield ratio" that looks at hull and shield, that result in a ratio around 0.5 for ships that have fragile hulls due to their reliance on boosted venting instead of passive dissipation.

I also have been looking at
Code
public static float getMemberStrength(FleetMemberAPI member, boolean withHull, boolean withQuality, boolean withCaptain)
output, and it is also very weak for those ships.

Here are some example.
My faction's best capital ship (that in part relies on modules though):
(https://i.imgur.com/NHN9V5V.jpg)

My faction's mainline cruiser:
(https://i.imgur.com/iKUszcT.jpg)

My faction's typical 200FP fleet:
(https://i.imgur.com/1rutpk6.jpg)

Compared to an Onslaught:
(https://i.imgur.com/WqEnzx9.jpg)

A Dominator:
(https://i.imgur.com/HgCndhz.jpg)

or a Mora:
(https://i.imgur.com/KqDsjxI.jpg)

Makes a typical 200FP Hegemony fleet come at:
(https://i.imgur.com/cg2AVlw.jpg)

And even cheating in the fleet doctrine as such
Code
    "factionDoctrine":{
        "warships":4,
        "carriers":3,
        "phaseShips":0,

        "officerQuality":5,
        "shipQuality":5,
        "numShips":5,

        "shipSize":4,
        "aggression":2,

Still produces weaker fleets, albeit less so: between 500 to 750 fleet strength versus 1000-1300 for the enemy, both 200FP fleets.

[edit] Boosting the fleetpoints a bit and setting the fleet doctrine to 10/10/10 does seems to put them in a right spot for the auto-resolve, but I don't like how it will affect the player battles with so many high level officers.

[edit2] It occurred to me that fleets that have a low "quality" multiplier get de-buffed twice because their ships usually have Dmods that also reduce the fleet strength. Maybe that's something worth checking out if it is working as intended.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alexzzz on February 06, 2020, 12:53:06 AM
Is there a way to render models outside of the game? I'm trying to get the rings for Saturn in my mod to look right, and having to open the game and start a new game every change is making it quite the effort.

You could try editing the save file.  That way you would just have to quit game -> edit save -> load game instead of starting a new game every time.  Haven't tried myself but it might work.

Just search for n="Saturn's Belt".  Its not too hard to see where all the parameters of the system.addRingBand are in the save file data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2020, 09:01:28 AM
I have been looking at
Code
protected FleetAutoresolveData computeDataForFleet(CampaignFleetAPI fleet)
and
Code
protected FleetMemberAutoresolveData computeDataForMember(FleetMemberAPI member)
and at least that part of the autoresolve has a "shield ratio" that looks at hull and shield, that result in a ratio around 0.5 for ships that have fragile hulls due to their reliance on boosted venting instead of passive dissipation.

Ok, we're looking at the same thing, so that's good. shieldRatio is just used to determine damage suffered, not the actual autoresolve combat strength. It's not a factor here and doesn't need to be looked at for this.

I also have been looking at
Code
public static float getMemberStrength(FleetMemberAPI member, boolean withHull, boolean withQuality, boolean withCaptain)
output, and it is also very weak for those ships.

I feel like we're talking past each other a bit here. What I've been trying to ask, all along, is: "Have you figured out why getMemberStrength() returns a lower value for your ships?" I've mentioned the various reasons why it might do so. Fundamentally its return value is based on the ship's fleet points and has nothing whatsoever to do with e.g. flux stats or speed or whatever. If it's returning a lower value than for another faction's ship with an equivalent FP value, then one of these reasons must be coming into play.

To reiterate, the possible things affecting the strength returned are:

- hull damage taken
- CR level
- Quality from inflater OR d-mods
- Officer level
- Unspent OP
- The ship being mothballed (0 strength no matter what else)
- The hull being a civilian hull (FleetMemberAPI.isCivilian() returns true; should always be false for SHIP_WITH_MODULES)

One of these things is dinging (or just not boosting) your ships' autoresolve strength compared to the stuff you're comparing them with.


[edit2] It occurred to me that fleets that have a low "quality" multiplier get de-buffed twice because their ships usually have Dmods that also reduce the fleet strength. Maybe that's something worth checking out if it is working as intended.

How so? getMemberStrength() only counts dmods if the quality multiplier is not available from an inflater, as kind of a proxy. Am I missing something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on February 06, 2020, 09:59:40 AM
Is there an easy way to find the radius of a ship's death explosion? Are they flat numbers based on hull size?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2020, 10:03:19 AM
Code
public static float getShipExplosionRadius(ShipAPI ship) {
float mult = ship.getMutableStats().getDynamic().getValue(Stats.EXPLOSION_RADIUS_MUT);
float radius = ship.getCollisionRadius() + Math.min(200f, ship.getCollisionRadius()) * mult;
return radius;
}

... let me actually add "float getShipExplosionRadius();" to ShipAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on February 06, 2020, 10:17:14 AM
Oh, that's nice and simple, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on February 08, 2020, 07:40:16 AM
Hello, I've been working on a shipsystem of the DRONE_LAUNCHER type, with a BaseEveryFrameCombatPlugin to modify the drones themselves. My question is whether I can modify the .system file JSON during combat using DroneLauncherShipSystemAPI droneSystem.getSpecJson() to modify the preferred position of the deployed drones? Normally the .system JSON specifies their angle but the DroneLauncherShipSystemAPI offers no way to change the position of the drones during combat. Thanks  :)

Example
ShipSystemAPI system = ship.getSystem();
List<ShipAPI> droneList = ship.getDeployedDrones();

            if (ship != null && system != null && system.getId().equals(SYSTEM_ID) && ship.isAlive()) {
                DroneLauncherShipSystemAPI droneSystem = (DroneLauncherShipSystemAPI) system;

                if (droneList != null) {
                    for (ShipAPI drone : droneList) {
                        int droneIndex = droneSystem.getIndex(drone);
                        if (isInFocusMode) {    //what happens if in focus mode and drones not recalled
                            if (droneIndex == 0 && !drone.getSystem().isActive()) {
                                drone.useSystem();
                            } else {
                                try {
                                    JSONArray droneBehaviorJSONArray = droneSystem.getSpecJson().getJSONArray("droneBehavior");
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2020, 08:29:04 AM
I don't think that'd work - iirc this method is provided so that other info that the game isn't directly aware of could be specified by mods. The stuff that's already in there I don't think keeps getting re-read from the json. And, even if it was, that json is shared between all instances of the system, so changing it for one ship would change it for every ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on February 08, 2020, 08:53:42 AM
I don't think that'd work - iirc this method is provided so that other info that the game isn't directly aware of could be specified by mods. The stuff that's already in there I don't think keeps getting re-read from the json. And, even if it was, that json is shared between all instances of the system, so changing it for one ship would change it for every ship.
That's a bummer, it did seem too sketchy to be useful. I guess I could have better luck with giveCommand? Thanks for the help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 08, 2020, 12:49:21 PM
2 quick things:

1) Am I correct in that there is no current API functionality to add or remove codex entries? I remember a suggestion for that a while back but wasn't sure if it was currently possible. (I'm trying to remove all vanilla file implementations based upon a settings flag. Right now, I just override the vanilla entries for weapons, for example, and add SYSTEM and replace any blueprint entries with "no drop, no salvage". It works fine but a settings flag might be easier for the nontechnical user. I'm still debating that in my head though)

2) Based on the above implementation with csv overrides, am I correct in assuming that another mod with the same csv id would take priority in merging? Or, more specifically, is there any way to give it priority?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2020, 01:31:55 PM
1) Am I correct in that there is no current API functionality to add or remove codex entries? I remember a suggestion for that a while back but wasn't sure if it was currently possible. (I'm trying to remove all vanilla file implementations based upon a settings flag. Right now, I just override the vanilla entries for weapons, for example, and add SYSTEM and replace any blueprint entries with "no drop, no salvage". It works fine but a settings flag might be easier for the nontechnical user. I'm still debating that in my head though)

Correct.

2) Based on the above implementation with csv overrides, am I correct in assuming that another mod with the same csv id would take priority in merging? Or, more specifically, is there any way to give it priority?

One will take priority based on the load order, but I always forget which one. I think it's the one loaded first? Not 100% sure, could be the opposite. The load order is in turn (IIRC) alphabetical.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 08, 2020, 02:28:36 PM
1) Am I correct in that there is no current API functionality to add or remove codex entries? I remember a suggestion for that a while back but wasn't sure if it was currently possible. (I'm trying to remove all vanilla file implementations based upon a settings flag. Right now, I just override the vanilla entries for weapons, for example, and add SYSTEM and replace any blueprint entries with "no drop, no salvage". It works fine but a settings flag might be easier for the nontechnical user. I'm still debating that in my head though)

Correct.

2) Based on the above implementation with csv overrides, am I correct in assuming that another mod with the same csv id would take priority in merging? Or, more specifically, is there any way to give it priority?

One will take priority based on the load order, but I always forget which one. I think it's the one loaded first? Not 100% sure, could be the opposite. The load order is in turn (IIRC) alphabetical.

Ah, ok thanks. That slightly complicates things (pretty sure I would mostly always take priority in that case) but I believe I can get around it by releasing two separate versions. One without csv overrides and one with them. That shouldn't be terribly difficult to maintain, I'd imagine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2020, 09:57:58 PM
You could always put a bunch of z's at the front of your mod's name, if it came to that :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 09, 2020, 11:28:07 AM
So I'm looking into modding in some of the changes I suggested here (http://fractalsoftworks.com/forum/index.php?topic=15305.msg247368#msg247368) and I have a few questions about feasibility:
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2020, 01:04:09 PM
  • Is there any way to programatically toggle the "turn to cursor" setting/behavior?

There isn't; let me add this to SettingsAPI:
void setAutoTurnMode(boolean autoTurnMode);
boolean isAutoTurnMode();


  • What's the best way to override the combat camera? I've had some success using the viewport, but it doesn't seem to affect space dust (the little gray spots in battle that have "fixed" locations).

Hmm. That should affect the space dust, and is indeed the way to go. It's how the game does it - via the ViewportAPI.set(float llx, float lly, float visibleWidth, float visibleHeight) method. Possibly there's some conflict between the game doing it every frame and your code overriding it? To make sure: you need to call viewport.setExternalControl(true) if you're going to control the viewport directly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 09, 2020, 01:28:46 PM
There isn't; let me add this to SettingsAPI:
void setAutoTurnMode(boolean autoTurnMode);
boolean isAutoTurnMode();
Thanks!

Hmm. That should affect the space dust, and is indeed the way to go. It's how the game does it - via the ViewportAPI.set(float llx, float lly, float visibleWidth, float visibleHeight) method. Possibly there's some conflict between the game doing it every frame and your code overriding it? To make sure: you need to call viewport.setExternalControl(true) if you're going to control the viewport directly.
Hmm... ok. I am calling setExternalControl, so I think you must be right about a conflict. Maybe I'm not manipulating the viewport at the correct time during the frame. I'll try moving my code to different override methods of my CombatPlugin.

Edit: No luck. Doesn't seem to matter where I put it  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2020, 01:55:04 PM
Hmm. Correct me if I'm wrong, but the mod used to run tournaments does this, right? It seems like it's got some custom viewport control. Does it also have this issue you're running into?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 09, 2020, 02:00:06 PM
Oh, that's a good point! I'm not sure, but I know DR knows a lot more about OpenGL than I do. I'll check that out. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 11, 2020, 10:06:24 AM
Is there way to change deployment behavior?

I want to make a "frigate" that launches from a ship with a launching bay, or if there are none present launch normally, is this possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2020, 10:24:44 AM
It's probably possible to script this but ... honestly, I'm not sure. You'd likely have to catch the frigate when it's deployed normally, and then simulate it launching from a ship. Hmm. I'm not sure the methods to scale it/have it a drop a shadow on the source ship/etc exist, actually. So: I'll revise this to *probably* not?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on February 11, 2020, 03:14:38 PM
Is there some AI override for the DRONE_LAUNCHER shipsystem? It's completely closed source and the DroneLauncherShipSystemAPI has no functionality for moving drones around (or other states like my post in the API suggestions thread). The image shows what I'm talking about, the drones are snapped every frame with the code below. The actual snapTo vector is just a point on circumference with a desired angle. As far as I can tell, the shipsystem script is trying to pull the drones back to their target location as defined in JSON. Free roam being on or off does not effect this.
(https://i.imgur.com/7SiqIu2.gif)

Spoiler
    private void snapTo(
            ShipAPI target,
            float magnitude, //==1f
            ShipAPI drone,
            Vector2f targetPosition
    ) {
        if (null == target) {
            return;
        }

        magnitude = MathUtils.clamp(magnitude, 0F, 1F);

        Vector2f locationDelta = Vector2f.sub(targetPosition, drone.getLocation(), new Vector2f());
        Vector2f velocityDelta = Vector2f.sub(target.getVelocity(), drone.getVelocity(), new Vector2f());
        float facingDelta = target.getFacing() - drone.getFacing();
        float angularVelocityDelta = target.getAngularVelocity() - drone.getAngularVelocity();

        drone.getLocation().x += locationDelta.x * magnitude;
        drone.getLocation().y += locationDelta.y * magnitude;
        drone.getVelocity().x += velocityDelta.x * magnitude;
        drone.getVelocity().y += velocityDelta.y * magnitude;
        drone.setFacing(drone.getFacing() + facingDelta * magnitude);
        drone.setAngularVelocity(drone.getAngularVelocity() + angularVelocityDelta * magnitude);
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2020, 03:20:42 PM
IIRC it's the drone AI doing this, not the ship system AI, so you could get whatever behavior you wanted by providing a custom one for your drones via ModPlugin.pickDroneAI().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on February 11, 2020, 03:25:54 PM
IIRC it's the drone AI doing this, not the ship system AI, so you could get whatever behavior you wanted by providing a custom one for your drones via ModPlugin.pickDroneAI().
Oh fantastic, cheers  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on February 11, 2020, 03:42:51 PM
Sorry to double post, but are there any considerations I need for the custom drone AI? Possible pitfalls, requirements etc. (Maybe even a peek at the source :DDD)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2020, 03:48:23 PM
No peek at the source, I'm afraid! But: the main thing to watch out for is, if you want the drones to obey the "return to mothership" order, you'll need to call something like the ship.beginLanding() (the method name might be wrong) or similar.

And of course figuring out what to shoot at and so on, and making use of the various object buckets to do so efficiently (see: CombatEngineAPI.getMissileGrid() etc). It's definitely an undertaking, though out of the possibilities - ships, fighters, and drones - the drone AI is *by far* the easiest.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 13, 2020, 08:19:58 AM
I'm back with a completely different, hopefully not stupid question.

I need to check if a star system is affected by a raid/pirate activity/inspection with the current fleet status.

There doesn't seem to be a flag or listener that tracks this, as far as I can see.
Is there a way to get that info?


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 13, 2020, 08:35:14 AM
Pirate activity: you can check the relevant market(s) for the condition.

Raid/inspection, hmm - I'd probably try to get intel of that class from Global.getSector().getIntelManager() and see if it's possible to tell from that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kirlrik on February 13, 2020, 10:22:37 AM
While troubleshooting, I found this thread (http://fractalsoftworks.com/forum/index.php?topic=16563.0) about missing portraits caused by too many portrait packs.

Anyone have further insight on the portrait limit? I spent an inordinate amount of time putting together a unique, nicely themed set for every modded faction I use. Hovering around 2000 portraits and getting a lot of missing ones, including whole factions. I'm confident this is not a filepath issue or anything, sadly. Tried upping RAM from 4g to 8g, but it made no difference. I can disable a few hundred at a time and suss out the limit, but I wanted to ask here first on the off chance there's some miracle solution.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 13, 2020, 10:50:56 AM
Hmm, I'm not aware of any such limit.

Are the "missing" portraits consistent? Are you able to reproduce this in vanilla + *just* a mod with the portraits and nothing else?

The game logs every texture that it loads (or, rather, after it loads one), so if you're able to identify which portraits aren't loading - which, if whole factions are affected, sounds doable - then you could check the log to see if it shows up there or not. The line would look like this:

15115 [Thread-3] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/portraits/portrait_hegemony15.png (using cast)

My initial guess would be that the portrait's png file is saved with the wrong settings (i.e. 8 bit or some such) and the game has trouble loading it, or something along these lines... though in that specific case, I think it'd actually error out on trying to load it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 13, 2020, 11:12:23 AM
IntelManager worked flawlessly, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kirlrik on February 13, 2020, 03:10:58 PM
Thanks for the detailed response on the missing portrait issue. One of the completely blank factions (FDS) was not loading in the .log, whereas one with about 20% missing (pirate) was. I put the new portraits in the core graphics/portraits folder instead of the mod I created, and edited the original .faction files instead of using extra ones as you do for altering existing factions with other mods. Seems like that fixed it. I also tried portraits in core and keeping the extra .faction files, but that didn't work. I guess it comes down to the extra .faction file not being added to the original one properly for whatever reason. It'll be a pain to update, and not being able to share it is a shame (even though it's just a mashup of other portrait mods), but oh well.

I understand why a faction mod like FDS might have some typo or alternate structure/code/whatever that my non-modder brain can't recognize, but the pirate case is beyond me. Every portrait was loading in the .log, so the extra .faction was working, yet something was breaking them... but only a few... truly mysterious. I'm 99% sure there was no blunder with the names or .faction files since I stuck to templates, bulk renaming, and text replacing. The only explanation I can think of is that the core portraits take priority when it comes to this hypothetical limit, and all I've done is make others not load instead. I'll update when I get around to switching everything over.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 13, 2020, 03:33:51 PM
Hmm, strange - if you can work up a minimal mod that reproduces this issue for a specific portrait, and tell me which portrait it doesn't work for, I'd be happy to take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on February 13, 2020, 09:10:30 PM
Would you entertain the notion of adding a render hook for the campaign map?

I personally don't know much about how difficult this would be to add, or how to utilize it, but my understanding is that it would allow MagicLib and GraphicsLib to adapt some of their effects for use on the campaign layer, which could be pretty awesome. The hyperjump mod comes to mind as one that could benefit, and (selfishly) having a warpy gate jump animation for my own mod.

Here's DarkRevenant's response on the subject when I asked whether it would be possible to use GraphicsLib on the campaign layer.
http://fractalsoftworks.com/forum/index.php?topic=10982.msg281656#msg281656
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 14, 2020, 03:47:27 PM
Honestly, it's not very likely. I'm not saying I won't ever do it, but it doesn't seem like the sort of thing I want to go messing with just now. Also: something similar may already be possible via a custom campaign entity, set to CampaignEngineLayers.TERRAIN_10 or .ABOVE. You'd effectively be able to render right under the UI since IIRC nothing uses TERRAIN_10.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on February 14, 2020, 03:54:30 PM
Honestly, it's not very likely. I'm not saying I won't ever do it, but it doesn't seem like the sort of thing I want to go messing with just now. Also: something similar may already be possible via a custom campaign entity, set to CampaignEngineLayers.TERRAIN_10 or .ABOVE. You'd effectively be able to render right under the UI since IIRC nothing uses TERRAIN_10.

Thanks for the answer, I'll pass it along, since while I understand the idea of layers, most of the implications are beyond me :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on February 17, 2020, 09:05:34 AM
I have been running into a problem recently... I am trying to play the game with a mod called Yuri Expedition.

But whenever I get to starting the game, it says this
Spoiler
580445 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: java.lang.RuntimeException: Market in yrxp_homeplate system refers to invalid entity yrxp_caparice_habitat_1
java.lang.RuntimeException: java.lang.RuntimeException: Market in yrxp_homeplate system refers to invalid entity yrxp_caparice_habitat_1
   at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.N.dismiss(Unknown Source)
   at com.fs.starfarer.ui.newui.o0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.dismiss(Unknown Source)
   at com.fs.starfarer.ui.newui.Objectsuper.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advance(Unknown Source)
   at com.fs.starfarer.ui.v.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advance(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Market in yrxp_homeplate system refers to invalid entity yrxp_caparice_habitat_1
   at com.fs.starfarer.campaign.econ.A.o00000(Unknown Source)
   at com.fs.starfarer.campaign.econ.A.o00000(Unknown Source)
[close]
And I dislike having to run Nexerelin because it removes the money making start Tutorial Start, along with all other starts from the mods I have installed. I have verified that this isn't happening because of mod incompatibility, but anymore than that I feel quite useless in trying to decipher.

Please help? :-[
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2020, 09:47:18 AM
Hi - hmm, this sounds like a bug in Yuri Expansion? It seems like a good idea to report it in that mod's thread.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on February 17, 2020, 10:03:31 AM
I did, but I didn't get resolved. I at the very least would like to know what went wrong... Because if I know, I can tell the Author. And if I tell the Author he/she will be able to fix it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2020, 10:07:22 AM
Ah, but the author is in the best position to figure out what the issue is. It sounds like a colony is configured to refer to the wrong (or a non-existent) planet, but I don't really know any more than that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on February 17, 2020, 10:40:13 AM
In that case I do have a new question. By removing a econ folder, how would it affect my game?
Would a faction's ships disappear, or not? Because I did get the mod to work, but only when I removed the Econ folder from the mod... I am so freaking lost!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2020, 11:00:51 AM
That'll probably make all of the mod faction's colonies disappear. So, that's one way to solve the problem, I suppose :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on February 17, 2020, 11:16:53 AM
Well, I suppose so... Just gotta wait for the modder response now!

Thanks, Alex. Even by letting me know what doesn't work you already helped out a whole lot!

What I think is really weird though, is that when I use Nexerelin, it all works out fine... But it also removes the customs starts and the Tutorial start.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 19, 2020, 12:52:33 PM
I am trying to add to the players ProductionBudget with an industry, regardless of planet ship hull output.

Since FactionProduction tallies exported ships per player planet, I added a new hidden size 1 market to the system and made a custom industry that applied the lower output between heavy industry and the custom industry on the target market to itself.

My issue is now that since the size 1 hidden colony must be player owned to be tallied, it shows up in the command menu and requires an administrator.

is there:
Either a way to add to the ProductionBudget directly, circumventing the whole market stuff -
or a way to hide the colony from player view, make it not require an admin, but still count as isPlayerOwned?

Thank you again for your continued help on this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 19, 2020, 02:22:26 PM
I'm not sure if this is in the current release or in-dev only, but, something like this:

Global.getSector().getPlayerStats().getDynamic().getMod(Stats.CUSTOM_PRODUCTION_MOD).modifyFlat(id, 10000);

Would increase the custom production credits by 10k per month. (If Stats.CUSTOM_PRODUCTION_MOD doesn't exist, then it'll be in the next release...)

Aside from that, I don't see a workaround - what you're doing makes sense, but has those repercussions that don't seem avoidable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 20, 2020, 12:02:57 AM
CUSTOM_PRODUCTION_MOD is not in the current release, sadly.

I think I'll just create a custom named AI core as admin and run a script to move it back to where it should be if the player assigns it to another market.
Doesn't solve the UI spam, but minimizes impact to actual gameplay.

Thank you, I look forward to the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on February 21, 2020, 10:47:36 AM
I've got a custom burst beam weapon I'd like to have be "convergeOnPoint":true. Problem is, it seems to go out to max range as soon as the beam enters chargedown, which I want to have be fairly lengthy.

Are there any options here besides giving up on converging, making some overly-involved script, or removing the chargedown portion of the beam?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2020, 11:56:19 AM
Hmm, I'm not actually quite sure what you're asking.

(The answer is probably "there aren't any workarounds", regardless, since how that works is a bit of a hack and used to just be hardcoded for the then-Guardian, now-Paladin PD weapon...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on February 21, 2020, 12:06:47 PM
(The answer is probably "there aren't any workarounds", regardless, since how that works is a bit of a hack and used to just be hardcoded for the then-Guardian, now-Paladin PD weapon...)

Probably not then, no. Thanks anyway.

edit: Just to illustrate, here's with converge off:
(https://i.imgur.com/GBM9vSq.gif)

and on:
(https://i.imgur.com/AKLIF6T.gif)

(The smattering is just an unrelated beameffect)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2020, 03:01:17 PM
Ah, I see what you mean, thank you! That's ... probably a bug. Not sure when/if I'll get to it, though, if we're being completely honest.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 21, 2020, 06:22:59 PM
You could fix this with scripting though Prav, messing with the offsets.

Edit: Though actually... Hm, that wouldn't work as I don't think is possible to reduce the range of a beam dynamically like would also need to be done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IraqiWalker on February 21, 2020, 10:24:19 PM
I tried looking around, but couldn't find anything yet (Maybe I haven't dug deep enough).
However, I followed the Intro to Modding walkthrough by Vayra, and when I try to launch my game with the mod I created (simple ship mod to test adding ships in) I get a crash instantly with the error "Fatal:null"
I'm guessing the cause is probably the mod_info.json file, but I compared to others and the main difference has been the lack of .jar files, which I'm not sure if I need or not considering I'm not using any special assets.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on February 22, 2020, 04:58:53 AM
I've seen a few mods that had no .jar files, and they are normally ship adds... What you could do is look at the mod Missing Ships. The only thing they do is add a few ships, and they have no .jar file at all.

They oughta help you see if there is anything missing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 22, 2020, 09:26:08 AM
if you check starsector.log, that should have a stack trace which - along with the few lines before it - might point in a more specific direction as far as what the issue is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IraqiWalker on February 22, 2020, 10:39:02 PM
I've seen a few mods that had no .jar files, and they are normally ship adds... What you could do is look at the mod Missing Ships. The only thing they do is add a few ships, and they have no .jar file at all.

They oughta help you see if there is anything missing.
I double checked, and it looks like my file is fine. Thanks for the recommendation.

if you check starsector.log, that should have a stack trace which - along with the few lines before it - might point in a more specific direction as far as what the issue is.

Looked through it, and after sifting through a LOT of text, I ran into this line:
37883 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading CSV data from [ABSOLUTE_AND_CWD: null]

I'm not sure why it's not seeing my csv file in the /mods/mymod/data/hulls folder.

Any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on February 23, 2020, 06:42:33 AM
It could be a pathing error in the CSV file itself... Do all your ships have the right IDs?

Because the problem could be that it can't find them with the names they have in the file itself.

Also, also, you could join the unofficial Discord. They have a few veteran modders there along with a channel dedicated to modding and scripting.
Spoiler
Invite code is TBhcFNh
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 23, 2020, 09:45:53 AM
Looked through it, and after sifting through a LOT of text, I ran into this line:
37883 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading CSV data from [ABSOLUTE_AND_CWD: null]

I'm not sure why it's not seeing my csv file in the /mods/mymod/data/hulls folder.

Any ideas?

What you want to do is 1) run the game and get a crash, then 2) open up the log file and go to the very end, then scroll up looking for the first (i.e. closest to the end of the file) error. That's going to be the one relevant to the crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 24, 2020, 06:22:51 AM
Does ImportantPeopleAPI actually do anything or is it just a management tool?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 24, 2020, 02:03:54 PM
Once again back with something that will probably be part of the next release,
I need to decrease build cost if an industry had a specific previous instance. something like:


Code
		if (previous instanceof industry_A) {
this.getBuildCost().reduce??
}
I'd need to do the same for build time.
Can't find a method to do that - do you have any ideas?


Found a workaround, upgrade to temp industry, remove if present and replace with required industry.
thank you nonetheless!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 24, 2020, 02:24:12 PM
Does ImportantPeopleAPI actually do anything or is it just a management tool?

It's a management tool for e.g. not giving multiple active procurement missions to the same person, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on February 24, 2020, 05:29:43 PM
Edit: Never mind, found out what the problem was!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: hyoukikyo on February 26, 2020, 01:26:37 AM
Hello,

I am new to the forum and i hope i am not breaking any standard protocol.

My question is that I could just never find a standard midline brawler in any of the markets.
I am able to find a tri-tachyon variant but never the standard one.

I tried editing by following the numbers and tags of a centurion because it is after all a fairly common midline ship that i see everywhere.

What happened though is that now I can see hegemony fleets using the standard midline brawler but it is still never in the markets.

Please help?

I have edited the following:
hegemony.faction
default_ship_roles

and i checked ship_data to see if they are different but centurion and brawler are practically the same.
i do not know what else to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 26, 2020, 08:07:55 AM
I am trying to figure out a concurrent modification error that happens only in an extremely specific set of circumstances, and am at my wits end with this.

The issue:
I have an industry that applies fleet listeners to all fleets in the system, tallies any FleetPoint loss, and adjusts output according to that.
It also creates a second market on the entity it is installed on, to enable production budget increase if Heavy Industry is present on the planet. The secondary market ("SalvageMarket") has an industry that gets the smallest produced amount of ship hulls on the primary market, and applies it to itself.
This SalvageMarket is created/removed depending on the presence of Heavy Industry.

All of the above works without a hitch.

The problem:
If HeavyIndustry is removed form a planet with an active SalvageMarket, the game crashes with a ConcurrentModificationError.

This is not caused by SalvageMarket removal directly - the game runs a few other methods from my class before crashing, even after SM is no longer present, and crashes once the removal triggers an economy update.

This does not happen in any other case - removing the ScrapYards is fine, up/downgrading...

Main Industry Class:
https://bitbucket.org/SirHartley/deconomics/src/master/deconomics_ScrapYard
Secondary:
https://bitbucket.org/SirHartley/deconomics/src/master/deconomics_AltHullProd

Crash info:
Code
46435 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.util.ConcurrentModificationException
java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
    at java.util.ArrayList$Itr.next(Unknown Source)
    at com.fs.starfarer.campaign.econ.reach.ReachEconomy.nextStep(Unknown Source)
    at com.fs.starfarer.campaign.econ.Economy.nextStep(Unknown Source)
    at com.fs.starfarer.campaign.econ.Economy.tripleStep(Unknown Source)
    at com.fs.starfarer.campaign.ui.marketinfo.IndustryListPanel.recreateOverview(Unknown Source)
    at com.fs.starfarer.campaign.ui.marketinfo.OO0o.dialogDismissed(Unknown Source)
    at com.fs.starfarer.ui.N.dismiss(Unknown Source)
    at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
    at com.fs.starfarer.ui.impl.K.actionPerformed(Unknown Source)
    at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
    at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
    at com.fs.starfarer.ui.I.processInput(Unknown Source)
    at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
    at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
    at com.fs.state.AppDriver.begin(Unknown Source)
    at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

do you have any idea what could cause this? I think it might be some check related either to the production budget or the presence of the market itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2020, 08:29:52 AM
Spoiler
Hello,

I am new to the forum and i hope i am not breaking any standard protocol.

My question is that I could just never find a standard midline brawler in any of the markets.
I am able to find a tri-tachyon variant but never the standard one.

I tried editing by following the numbers and tags of a centurion because it is after all a fairly common midline ship that i see everywhere.

What happened though is that now I can see hegemony fleets using the standard midline brawler but it is still never in the markets.

Please help?

I have edited the following:
hegemony.faction
default_ship_roles

and i checked ship_data to see if they are different but centurion and brawler are practically the same.
i do not know what else to do.
[close]

Hi - hmm. Hard to say exactly, but is it possible that the brawler is showing up on the military markets, just not on the open market? Or that you haven't waited long enough for the ships to refresh enough times? What you've done - without knowing the specifics - sounds like, at least conceptually, should have done the job.

I am trying to figure out a concurrent modification error that happens only in an extremely specific set of circumstances, and am at my wits end with this.
Spoiler
The issue:
I have an industry that applies fleet listeners to all fleets in the system, tallies any FleetPoint loss, and adjusts output according to that.
It also creates a second market on the entity it is installed on, to enable production budget increase if Heavy Industry is present on the planet. The secondary market ("SalvageMarket") has an industry that gets the smallest produced amount of ship hulls on the primary market, and applies it to itself.
This SalvageMarket is created/removed depending on the presence of Heavy Industry.

All of the above works without a hitch.

The problem:
If HeavyIndustry is removed form a planet with an active SalvageMarket, the game crashes with a ConcurrentModificationError.

This is not caused by SalvageMarket removal directly - the game runs a few other methods from my class before crashing, even after SM is no longer present, and crashes once the removal triggers an economy update.

This does not happen in any other case - removing the ScrapYards is fine, up/downgrading...

Main Industry Class:
https://bitbucket.org/SirHartley/deconomics/src/master/deconomics_ScrapYard
Secondary:
https://bitbucket.org/SirHartley/deconomics/src/master/deconomics_AltHullProd

Crash info:
Code
46435 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.util.ConcurrentModificationException
java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
    at java.util.ArrayList$Itr.next(Unknown Source)
    at com.fs.starfarer.campaign.econ.reach.ReachEconomy.nextStep(Unknown Source)
    at com.fs.starfarer.campaign.econ.Economy.nextStep(Unknown Source)
    at com.fs.starfarer.campaign.econ.Economy.tripleStep(Unknown Source)
    at com.fs.starfarer.campaign.ui.marketinfo.IndustryListPanel.recreateOverview(Unknown Source)
    at com.fs.starfarer.campaign.ui.marketinfo.OO0o.dialogDismissed(Unknown Source)
    at com.fs.starfarer.ui.N.dismiss(Unknown Source)
    at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
    at com.fs.starfarer.ui.impl.K.actionPerformed(Unknown Source)
    at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
    at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
    at com.fs.starfarer.ui.I.processInput(Unknown Source)
    at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
    at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
    at com.fs.state.AppDriver.begin(Unknown Source)
    at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
[close]
do you have any idea what could cause this? I think it might be some check related either to the production budget or the presence of the market itself.

This means that when you delete remove the SalvageMarket, you're doing this from a method that's called while the game is iterating over a list of markets, somewhere further up the stack. Once it gets back up the stack to the loop where it was iterating over the list, it'll try to go to the next element, see that the list has changed, and throw this exception. In practical terms, this means you'll need to defer market removal somehow, perhaps by adding an EveryFrameScript that does this instead of doing it in the apply()/unapply() methods.

(I've changed the economy code so this specific error should no longer happen, btw.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 26, 2020, 08:40:49 AM
Shouldn't there also be concurrency issues on market addition? Adding it works just fine, and is done within the same method.

Removal also works fine if triggered with the removal of the ScrapYard.
It really only causes that error if the heavy industry is removed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2020, 08:49:26 AM
It just depends on where it happens; apply()/unapply() get called from various places in the core code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 26, 2020, 09:00:02 AM
I see, I'll move market creation/removal out of that class and into a script.

Thank you for taking the time to answer this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2020, 09:14:04 AM
Yep! Good luck.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 26, 2020, 12:14:48 PM
Just letting you know, it worked flawlessly and I learned a lot about not putting all my eggs in one basket.
thanks again!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2020, 12:21:06 PM
Nice, glad you were able to figure it out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 26, 2020, 01:27:29 PM
Would this: (for wings definition in a variant file)

Code
  "wings": [
    "archean_wasp_wing",
    "archean_wasp_wing",
    "archean_xyphos_wing",
    "archean_dagger_wing",
  ]

As opposed to:

Code
  "wings": [
    "archean_wasp_wing",
    "archean_wasp_wing",
    "archean_xyphos_wing",
    "archean_dagger_wing"
  ]

Cause a nullpointer in combat main?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2020, 01:46:32 PM
The difference being one comma, right? No it would not; both ways should parse/load fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 26, 2020, 01:56:13 PM
Sometimes a new line, but no additional entries or anything. Thanks for ruling it out. Back to the drawing board.

(Mass replace of variants' wing ids with my IDE caused that error and I'm trying to retrace it to a formatting issue or a typo or something else I've missed, etc)

*EDIT* Yeah this is a lost cause.  :P

Sigh, I'm just going to purge the project to the last working version. That error is far too annoying to deal with to waste this much time on it. I've searched 200 files so far and the ids all match. It would have to be a fighter id mismatch for a variant- or a hull id or variant id mismatch for the skin files that some fighters use. I've triple checked all the skin files and ship files and their ids are correct. The csv's definitions match too, and I've gone through half of the variant files that actually have wing definitions. All built in wings are correct- and removing the descriptions file doesn't solve it so it's not a parsing issue with that either. I've even checked off the ids I've encountered in variants and- assuming mass replace actually works as intended upon all sub-directories (it seems to) then there is a correct example of each wing definition in at least one variant file- so you'd assume they would therefore all be correct.

It can't be an issue with something that's hardcoded (I've already accounted for the one place I do this myself in the tutorial) because all vanilla files should still be readable and intact. Now all I do for fighters (well if it worked) was add an override the csv entries for wing data and ship data. That should be it.  >:(

Whelp, I'm just going to have to slow down and replace one file and all its references at a time and then load the game for safety. That's what I was doing at first, but it takes forever to do it that way.

*EDIT2*

AHAH! Found it! It wasn't an incorrect id it was a missing one.  ::)

I checked the entire directory three times and I still missed one id reference by lacking a file implementation. I had to block implement prior backed-up changes to isolate it down to figure it out. Everything seems to work as intended now!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: hyoukikyo on February 27, 2020, 01:24:15 AM
Hello.

Thank you Alex. Your comment about the market specifics made me look into the variants next because luddic and tritach had their own brawlers in their own markets.

It was there that i found that the base game (at least the one that i have currently) does not have a standard/assault brawler variant.
It only has the luddic and tritach variants in the folder(I do not truly know if this mattered).
So what I did was just write a standard brawler variant and now it is working fine and well.
I do not think I fully understand the various specifics and how all the files affect each other yet but this has been very helpful to me to start with.

Thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 01, 2020, 06:33:41 PM
Hi guys,

So I was tooling around with another experiment of mine, and I found out you can make a "playable" fighter by making it a frigate, and then with script wizardry setting its hullsize and collisionclass to a fighter with everyframe as soon as they deploy.

It seems to work for the most part, i've only ran into a few bugs outside of some UI issue.
 
a.) Game crash when "fighter" retreats
Quote
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.movement.maneuvers.RetreatManeuver.o00000(Unknown Source)
   at com.fs.starfarer.combat.CombatState.controlPlayerShip(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Since AI is obfuscated ( or so i am told), I dont think there's anything I can do to fix this, so I thought...Instead of normal retreat, what about making it so that the player can fly to any ship on player side with a fighter bay, and "land" on it using beginLandingAnimation. Is there any method to lock the controls of the "fighter" and keep it anchored to the ship it landed on (to simulate it being inside the ship, if that makes sense) until calling "abortLanding()" by some arbitrary condition being satisified? I figure that I can maybe do this, and then set player ship to isRetreating if the carrier retreats? Do you think that would work?

Oh and one other question, how do ships priortize fighter threat level? I noticed sometimes they will actually attempt to fire all guns on it, and keep their distnace usually if its the only target, and otherwise kind of ignore it if there's something else around like a frigate/destroyer/etc..are there any factors that play into this beside the size of those targets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 02, 2020, 07:21:59 AM
Since AI is obfuscated ( or so i am told), I dont think there's anything I can do to fix this, so I thought...Instead of normal retreat, what about making it so that the player can fly to any ship on player side with a fighter bay, and "land" on it using beginLandingAnimation. Is there any method to lock the controls of the "fighter" and keep it anchored to the ship it landed on (to simulate it being inside the ship, if that makes sense) until calling "abortLanding()" by some arbitrary condition being satisified? I figure that I can maybe do this, and then set player ship to isRetreating if the carrier retreats? Do you think that would work?

That... might kind of work. I don't exactly remember, though. And if *that* ship retreated, the player "fighter" would still be left on the field somewhere in an unretreated and invisible state.

Oh and one other question, how do ships priortize fighter threat level? I noticed sometimes they will actually attempt to fire all guns on it, and keep their distnace usually if its the only target, and otherwise kind of ignore it if there's something else around like a frigate/destroyer/etc..are there any factors that play into this beside the size of those targets?

That's about right, yeah. Just in general "making a player-pilotable fighter" is really going against the grain, there will be issues that are hard or impossible to solve. It "works" only in the most basic sense of being able to control a fighter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaykat on March 03, 2020, 02:47:18 PM
Is there a way to have two different descriptions for landing on a planet, one when it isn't colonized and one when it is?

I am not a modder/coder in any capacity more than copy pasting things so simple explain do much good :X
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 03, 2020, 03:35:45 PM
You can change a planet's description from a simple EveryFrameScript.

I think you can just copy-paste the code below into a file called PlanetDescriptionUpdater.java (create a .txt file in data/scripts and rename it) and it will work (once modified for your ids and stuff), but I'm not sure I've ever actually done it that way. Might need to reference it in settings.json? IDK

Spoiler
package data.scripts;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;

public class PlanetDescriptionUpdater implements EveryFrameScript {
    private static final String SYSTEM = "yourSystemNameHere"; // Name of the star system
    private static final String PLANET = "yourPlanetIdHere"; // id (not name) of the planet
    private static final String DESC_COLONIZED = "yourDescriptionIdHere"; // id of your description in descriptions.csv
    private static final String DESC_EMPTY = "yourDescriptionIdHere"; // id of your description in descriptions.csv

    private boolean isColonized;

    private float interval;

    public PlanetDescriptionUpdater() {
        isColonized = false;

        interval = 0;
    }

    @Override
    public void advance(float amount) {
        float days = Global.getSector().getClock().convertToDays(amount);

        interval += days;

        if (interval < 1) return; // Only check once a day
        interval -= 1;

        StarSystemAPI system = Global.getSector().getStarSystem(SYSTEM);
        PlanetAPI planet = (PlanetAPI) system.getEntityById(PLANET);
        MarketAPI market = planet.getMarket();

        // If colony destroyed
        if (market.isPlanetConditionMarketOnly() && isColonized) {
            isColonized = false;

            planet.setCustomDescriptionId(DESC_EMPTY);
        } // If colonized
        else if (!market.isPlanetConditionMarketOnly() && !isColonized) {
            isColonized = true;

            planet.setCustomDescriptionId(DESC_COLONIZED);
        }

        // Otherwise do nothing.
    }

    @Override
    public boolean runWhilePaused() {
        return false;
    }

    @Override
    public boolean isDone() {
        return false;
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 03, 2020, 11:00:19 PM


That's about right, yeah. Just in general "making a player-pilotable fighter" is really going against the grain, there will be issues that are hard or impossible to solve. It "works" only in the most basic sense of being able to control a fighter.

Thanks Alex! Yeah,the more I think of it, there are just too many variables you'd have to factor for, even if I was able to get the base implementation working.  I'll shelve this idea for now
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pandora on March 04, 2020, 03:11:01 PM
What you could do is try and study the shuttle that carries the player from one ship to the other while in combat.That could probably give a few answers...
But it still wouldn't solve the problem with controlling it, huh...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on March 05, 2020, 08:27:41 AM
If I place a filepath in the replace section of a file_info.json I can replace a vanilla file

Can I do the same with a file that exist in another mod currently used? Meaning, can I replace the (for example) CustomFaction.faction file of Mod A With a Mod B CustomFaction.faction.

In the case where 2 or more mod try to replace the same file, what happens?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2020, 09:12:03 AM
What happens is mod-load-order dependent (which is in turn alphabetical based on mod name); I always forget if the first or last mod gets priority. I *think* you can "replace" a file provided by a mod, but I could be mistaken.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 05, 2020, 12:48:50 PM
I *think* you can "replace" a file provided by a mod, but I could be mistaken.

To confirm: You can't- at least with JSON files. I'm not sure about CSV or custom game files though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2020, 12:50:15 PM
Ah, ok - thank you for chiming in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 05, 2020, 05:32:45 PM
Is there any way to apply/ mimic the phase effect a phase ship has on the body to a decorative turret?
Basically, that glow of the phase coils when activated and then the visual "cooldown" effect where it gets all jittery while fading out.
the "phase coil" for the ship im using is on a deco turret  which moves, so I can't do it the normal way since in certain conditions the glow would be floating in the void. Hope this makes sense.

I thought this effect would be in the phasecloak script, but it seems to be triggered from the ship system file when you use    
#"phaseHighlight":"_glow1",
   #"phaseDiffuse":"_glow2",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2020, 08:06:08 PM
If it's a decorative turret - does the glow of the body render above it? If so then the glow could include whatever stuff it needed to for the turret. Not sure of the render order offhand, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kirin on March 08, 2020, 07:22:42 AM
is there a way to add anything to the ai core files? like add additional types or just change the ones in the game to be equal but very different, example of alpha cores being able to do management balance better than the others but gamma cores boost production far more but have increased need of resources?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 08, 2020, 09:36:54 AM
It's not impossible, but it's pretty complicated and may or may not be doable in a way that plays nice with other mods. You'd have to replace the BaseIndustry class, which means you'd also need to replace all the core industry classes that derive from it, but then industries added by other mods would not be affected, so... I guess for most mods it's "no", but a total conversion would have more freedom with these sorts of thing and could more reasonably do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kirin on March 09, 2020, 02:39:41 AM
damn, well is there a way to add flags then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2020, 09:07:09 AM
Hmm, I'm not sure what you mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 09, 2020, 04:36:09 PM
Trying to implement a custom drone AI with
Quote
@Override
    public PluginPick<ShipAIPlugin> pickDroneAI(ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system) {
        if (DEUCES_DRONE_CORONA_ID.contentEquals(drone.getHullSpec().getBaseHullId())) {
            return new PluginPick<ShipAIPlugin>(new SPE_droneCoronaDroneAI(), CampaignPlugin.PickPriority.MOD_SET);
        }
        return null;
    }

Where the AI script is completely empty
Quote
package data.scripts.ai;

import com.fs.starfarer.api.combat.*;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lwjgl.util.vector.Vector2f;

import java.util.List;

public class SPE_droneCoronaDroneAI implements ShipAIPlugin {

    //not relevant
    @Override
    public void setDoNotFireDelay(float amount) {
    }

    //called when AI activated on player ship
    @Override
    public void forceCircumstanceEvaluation() {
    }

    @Override
    public void advance(float amount) {
    }

    @Override
    public boolean needsRefit() {
        return false;
    }

    //not relevant
    @Override
    public ShipwideAIFlags getAIFlags() {
        return null;
    }

    //not relevant
    @Override
    public void cancelCurrentManeuver() {
    }

    //not relevant
    @Override
    public ShipAIConfig getConfig() {
        return null;
    }
}

For some reason, this always causes a nullpointer crash
31829 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.systems.N.Ò00000(Unknown Source)
   at com.fs.starfarer.combat.systems.N.advanceImpl(Unknown Source)
   at com.fs.starfarer.combat.systems.F.advance(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


What's wrong here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2020, 04:48:17 PM
Probably because your getAIFlags() and getConfig() methods are returning null; other stuff using this probably assumes that's not allowed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kirin on March 10, 2020, 02:14:10 AM
by add flags I mean add more flags from the selectable ones when you start a colony, like how I can add new commander images.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 10, 2020, 04:26:26 AM
by add flags I mean add more flags from the selectable ones when you start a colony, like how I can add new commander images.
There are a number of flag packs on the forum that you can inspect, e.g. Player Faction Flag Pack (http://fractalsoftworks.com/forum/index.php?topic=16309) and Historical Flags (http://fractalsoftworks.com/forum/index.php?topic=17470.msg275336#msg275336)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on March 10, 2020, 01:50:40 PM
there an easy way to have your portrait appear next to your flagship the way other officers do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 10, 2020, 04:06:43 PM
Thanks for the help earlier, I'm currently fine-tuning the drone movement, and I was wondering how the param of Ship.giveCommand(..., param, ...) works. I've only been setting the param as null, but the API mentions param - Generally a Vector2f with a "mouse" location. See ShipCommand.java for details., but as far as I can see ShipCommand.java doesn't have any comment on a mouse location. Does this mean that I can choose to make the e.g. accelerate command act in a certain direction instead of cardinally? The code below shows what I have. This is quite innacurate as the drones only move diagonally or straight, which causes them to overshoot, correct, then fly around amusingly. Thanks!
Spoiler
Code
//MOVE TO TARGET LOCATION
        float angleFromDroneToTargetLocation = VectorUtils.getAngleStrict(drone.getLocation(), movementTargetLocationOnShip);
        float angleRelativeToDrone = MathUtils.getShortestRotation(drone.getFacing(), angleFromDroneToTargetLocation);
        float distanceToTargetLocation = MathUtils.getDistance(drone.getLocation(), movementTargetLocationOnShip);

        //do large movement if over distance threshold
        if (distanceToTargetLocation >= roamRange) {
            //accelerate forwards or backwards
            if (90f > angleRelativeToDrone && angleRelativeToDrone > -90f) { //between 90 and -90 is an acute angle therefore in front
                drone.giveCommand(ShipCommand.ACCELERATE, null, 0);
                drone.giveCommand(ShipCommand.ACCELERATE, null, 0);
                drone.giveCommand(ShipCommand.ACCELERATE, null, 0);
            } else { //falls between 90 to 180 or -90 to -180, which should be obtuse and thus relatively behind
                drone.giveCommand(ShipCommand.ACCELERATE_BACKWARDS, null, 0);
            }

            //strafe left or right
            if (180f > angleRelativeToDrone && angleRelativeToDrone > 0f) { //between 0 and 180 (i.e. left)
                drone.giveCommand(ShipCommand.STRAFE_LEFT, null, 0);
            } else { //between 0 and -180 (i.e. right)
                drone.giveCommand(ShipCommand.STRAFE_RIGHT, null, 0);
            }
        } else {
            snapTo(ship, 0.1f, drone, movementTargetLocationOnShip);
        }

        //some fine tuning and deceleration
        if (distanceToTargetLocation <= roamRange * 2f) {
            drone.giveCommand(ShipCommand.DECELERATE, null, 0);

            if (tracker.intervalElapsed()) {
                //decelerate if close to target location or attempt to reverse thrust
                if (distanceToTargetLocation <= roamRange) {
                    drone.giveCommand(ShipCommand.DECELERATE, null, 0);
                    if (drone.getEngineController().isStrafingRight()) {
                        drone.giveCommand(ShipCommand.STRAFE_LEFT, null, 0);
                    }
                    if (drone.getEngineController().isStrafingLeft()) {
                        drone.giveCommand(ShipCommand.STRAFE_RIGHT, null, 0);
                    }
                    if (drone.getEngineController().isAccelerating()) {
                        drone.giveCommand(ShipCommand.ACCELERATE_BACKWARDS, null, 0);
                    }
                    if (drone.getEngineController().isAcceleratingBackwards()) {
                        drone.giveCommand(ShipCommand.ACCELERATE, null, 0);
                    }
                }
            }
        }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2020, 04:25:48 PM
there an easy way to have your portrait appear next to your flagship the way other officers do?

There isn't, I don't think.

Thanks for the help earlier, I'm currently fine-tuning the drone movement, and I was wondering how the param of Ship.giveCommand(..., param, ...) works. I've only been setting the param as null, but the API mentions param - Generally a Vector2f with a "mouse" location. See ShipCommand.java for details., but as far as I can see ShipCommand.java doesn't have any comment on a mouse location. Does this mean that I can choose to make the e.g. accelerate command act in a certain direction instead of cardinally? The code below shows what I have. This is quite innacurate as the drones only move diagonally or straight, which causes them to overshoot, correct, then fly around amusingly. Thanks!

"param" is for commands that need a mouse location, such as firing a weapon (missiles uses this for target-picking), using a ship system, or raising shields.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 10, 2020, 04:29:59 PM

Thanks for the help earlier, I'm currently fine-tuning the drone movement, and I was wondering how the param of Ship.giveCommand(..., param, ...) works. I've only been setting the param as null, but the API mentions param - Generally a Vector2f with a "mouse" location. See ShipCommand.java for details., but as far as I can see ShipCommand.java doesn't have any comment on a mouse location. Does this mean that I can choose to make the e.g. accelerate command act in a certain direction instead of cardinally? The code below shows what I have. This is quite innacurate as the drones only move diagonally or straight, which causes them to overshoot, correct, then fly around amusingly. Thanks!

"param" is for commands that need a mouse location, such as firing a weapon (missiles uses this for target-picking), using a ship system, or raising shields.

That's a bummer. Is there another way that I could increase the accuracy of the ship acceleration then? Does the source (which I am more or less trying to imitate in behaviour) liberally use intervalutil?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2020, 04:40:41 PM
For a drone, I'd suggest directly manipulating the velocity and or/location. You're going to have a tough time getting nice-looking movement otherwise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on March 10, 2020, 04:46:46 PM

There isn't, I don't think.


well, poop. a minor thing, i know... but it just feels wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 10, 2020, 04:47:06 PM
For a drone, I'd suggest directly manipulating the velocity and or/location. You're going to have a tough time getting nice-looking movement otherwise.
(https://i.imgur.com/7hfR7TH.gif)
Some of what I got up to, it was even worse with terminator-level speed  ;D. Thanks for the help, I'll start looking into that stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 11, 2020, 03:53:44 PM
Is there a way to get AI to move through a ship when collisions allow it to ?

That probably doesn't make a lot of sense, right now I have a ship using a custom right click system that is basically shares the property of being able to pass through ships, like phase. The AI type for the system is set to phase, and I set the ship's collisionclass to that of a fighter in a script to be able to pass through other ships while the system is active. Everything works for me, but this doesn't seem to work with AI - they will fly directly in front of the ship they're targetting and stop everytime, like there's an invisible wall stopping them from going any further. Any ideas what could be the cause of this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 11, 2020, 04:56:21 PM
Here is my update, (https://i.imgur.com/J8hLLWK.gif). This is working with ~80ish lines of code without any direct manipulation of velocity or location, only shipcommands, showing it is possible  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 11, 2020, 05:14:50 PM
Is there a way to get AI to move through a ship when collisions allow it to ?

That probably doesn't make a lot of sense, right now I have a ship using a custom right click system that is basically shares the property of being able to pass through ships, like phase. The AI type for the system is set to phase, and I set the ship's collisionclass to that of a fighter in a script to be able to pass through other ships while the system is active. Everything works for me, but this doesn't seem to work with AI - they will fly directly in front of the ship they're targetting and stop everytime, like there's an invisible wall stopping them from going any further. Any ideas what could be the cause of this?

The way to do that would probably be to temporarily override what the AI is doing to force it to move the way you want to at the specific time. E.G. the ship system could block all other commands and give the accelerate command every frame, or some such.

Here is my update, . This is working with ~80ish lines of code without any direct manipulation of velocity or location, only shipcommands, showing it is possible  ;D

Very nice! Glad you got it working, even including the landing-back-on-the-ship bits.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: H-Nighthawk on March 12, 2020, 12:19:52 PM
Ello, I am trying to figure out how to mod the skills, simple changes like increasing or decreasing the strength of them, but for the life of me I can't find the file that has their statistics. Is it even possible to mod them and if so which file are they in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 12, 2020, 12:31:41 PM
They are in starfarer.api.jar. You cannot modify them directly. You will have to create a mod and copy the classes you want to modify, then IIRC copy the relevant .skill files (from data/characters/skills) and point each class reference to your version of the class.

I don't think you have to compile the modified classes into a jar, but you may have to tell the game to replace the .skill files in you mod_info.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 12, 2020, 03:32:52 PM
Is station_small used for anything or is it just a test file? I've never encountered it but figured I'd ask to be sure before I remove it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: H-Nighthawk on March 12, 2020, 04:20:51 PM
They are in starfarer.api.jar. You cannot modify them directly. You will have to create a mod and copy the classes you want to modify, then IIRC copy the relevant .skill files (from data/characters/skills) and point each class reference to your version of the class.

I don't think you have to compile the modified classes into a jar, but you may have to tell the game to replace the .skill files in you mod_info.json.

Hmmm, this may be out of my mod league, not having any luck figuring it out, or it just may not be possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 12, 2020, 04:23:41 PM
Is station_small used for anything or is it just a test file? I've never encountered it but figured I'd ask to be sure before I remove it.

It's just for testing. I'm not sure if there are any hardcoded references to it in core code; I don't *think* so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 12, 2020, 06:17:22 PM
It's just for testing. I'm not sure if there are any hardcoded references to it in core code; I don't *think* so.

Thanks! If it was referenced (as long as it wasn't actually spawned anywhere) that shouldn't cause any weirdness afaik so I shouldn't need to override it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 13, 2020, 04:32:18 AM
(https://i.imgur.com/OkgohyV.png)
Can I override this message by getting the status key somehow? Would like to change this text since it is misleading with how I've changed the functionality of this system. Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2020, 12:36:55 PM
Hmm - I don't think so, no - sorry! I mean, you might try to write a custom version of the drone launcher system from the ground up - basically launching drones/maintaining its own state as needed - but the existing drone launcher system isn't that flexible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 13, 2020, 04:13:15 PM
Hmm - I don't think so, no - sorry! I mean, you might try to write a custom version of the drone launcher system from the ground up - basically launching drones/maintaining its own state as needed - but the existing drone launcher system isn't that flexible.
Yikes - well, I might as well go all out. Can I have some info on how the existing system launches drones onto the map? Is it as simple as spawning in the combat entity with a reversed velocity? Do I need to extend BaseShipSystemScript? How does it interface with the systems csv and/or json configuration?

EDIT: Nevermind, I found the obfuscated source so I'll use that as a guideline to implementing my ideas
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on March 14, 2020, 03:40:51 AM
Hey All,

I've run into a spot of bother. What I want to do is spawn a beacon in hyperspace over a system. The code I'm using is based off RemnantThemeGenerator, but hacked down to something that doesn't melt my brain. This is inserted near the beginning of my generator file for the system:

Code
        SectorEntityToken anchor = system.getHyperspaceAnchor();
        CustomCampaignEntityAPI beacon = Global.getSector().getHyperspace().addCustomEntity("messrem_beacon", "Warning Beacon", "HMI_RemMess_beacon", Factions.NEUTRAL);
        beacon.setCircularOrbitPointingDown(anchor, 100, 300, 65f);
        Color glowColor = new Color(250,55,0,255);
        Color pingColor = new Color(250,55,0,255);
        Misc.setWarningBeaconColors(beacon, glowColor, pingColor);

Using this causes the game to crash due to a nullpointerexception. According to the log and some checking, the null error is 'anchor'. I'm not sure exactly what is going wrong, as anchor is already defined. I'm not sure what I'm doing wrong, but I have a hunch it's something simple to do with how the anchor is implemented. May I ask for some help please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 14, 2020, 04:04:25 AM
Have you generated the hyperspace anchor?

EDIT: I see it allegedly generates one immediately. I would still call autogenerateHyperspaceJumpPoints() before I tried to do a hyperspace beacon around the system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 14, 2020, 05:17:32 PM
How do I link to a custom shipsystem script in the .system file? My one extends BaseShipSystemScript, and implements DroneLauncherShipSystemAPI, and as far I can tell there is no CUSTOM value for the 'type' key. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 14, 2020, 05:32:45 PM
I'd suggest using type:"STAT_MOD" since that doesn't do anything and lets your script have full control. The script can be specified via "statsScript".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 14, 2020, 09:59:58 PM
I'd suggest using type:"STAT_MOD" since that doesn't do anything and lets your script have full control. The script can be specified via "statsScript".

Thanks for the reply - although I have yet more questions. In my modplugin, I assign the drones their AI with pickDroneAI, which passes DroneLauncherShipSystemAPI. If the ship system is of the STAT_MOD type, won't this break it? Is there a workaround, like using pickShipAI instead? This is important since the drone AI relies on being able to get the current state of the system's orders enum (RECALL, DEPLOY and ATTACK) from the passed DroneLauncherShipSystemAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 14, 2020, 10:03:01 PM
If you're implementing your own, then there would be no DroneLauncherShipSystemAPI and no states - whatever you code up has to handle states etc. You would, I think, set the AI to what you need when manually spawning the drone.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 14, 2020, 10:22:34 PM
If you're implementing your own, then there would be no DroneLauncherShipSystemAPI and no states - whatever you code up has to handle states etc. You would, I think, set the AI to what you need when manually spawning the drone.

I see - oh well, thanks for the help :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on March 15, 2020, 01:01:18 AM
Have you generated the hyperspace anchor?

EDIT: I see it allegedly generates one immediately. I would still call autogenerateHyperspaceJumpPoints() before I tried to do a hyperspace beacon around the system.

Put the code after the autogenerate and it worked like a charm. Many thanks Safari!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 15, 2020, 01:25:34 AM
How do I associate the drone the shipsystems spawns with the mothership, so that when getDroneSource() is called on the drone, it returns the ShipAPI instance of the mothership? basic java, heh
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2020, 09:27:06 AM
One other thing you want to do that's subtle in its effects:

drone.getAIFlags().setFlag(AIFlags.DRONE_MOTHERSHIP, 20000f, mothership);

If this isn't done, things will work, but enemy AI will be more distracted by the drones than it should be.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zapper on March 15, 2020, 02:11:19 PM
Hi all, i am new to this game and have been playing for a few days now.
the only thing about this game that is bugging me is maintance supplys i do not like.
so i started looking for a way to change that. console command inf supply i tried first i do not like that because that to op.
 second thing i tried was editing the ship_data.csv file and edit the "AM"colum to all 0 this was oke until i got in a battle and could deploy every ship in my fleet including the AI becuase ZERO deployment cost followed by masive lag.
next atempt changing the skill fleet logistics second level modifier -25% maintance upkeep i want to change this to -95% and keep editing it untill its to my liking but here comes the my problem i can't get it to work i have spend the last 4 hours trying and you guys/girls are my last hope i have tried a lot but there is always a error apperently this is not a easy change value like i am use to in game like HOI4, Skyrim, EU4, AOE2, Factorio. could you give me some advice on how to continue
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 15, 2020, 03:14:24 PM
One other thing you want to do that's subtle in its effects:

drone.getAIFlags().setFlag(AIFlags.DRONE_MOTHERSHIP, 20000f, mothership);

If this isn't done, things will work, but enemy AI will be more distracted by the drones than it should be.

Do you mean
Code
ship.getAIFlags().setFlag(ShipwideAIFlags.AIFlags.DRONE_MOTHERSHIP, 20000.0f, (java.lang.Object)this.ship);
or per drone?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2020, 04:59:51 PM
Per drone, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2020, 05:02:02 PM
@Zapper: in a nutshell, you need to provide a version of the skill in your mod, and make sure your mod also has a skill_data.csv that points to your implementation of the skill.

It sounds like you're editing the source files from starfarer.api.zip - those are only provided for reference, so changing them directly won't do anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zapper on March 16, 2020, 03:22:34 AM
@Alex

i have downloaded this mod https://fractalsoftworks.com/forum/index.php?topic=14502.0 and that uses one .skill file in this structure "data\characters\skills" here it points to {"type":"ALL_SHIPS_IN_FLEET", "script":"skillrework.campaign.skills.AdvancedCountermeasures$Level1f"} this gets an error "unknown scoure" when i edit it to fleetlogistics
it also usess a jar file "jars/skillreworks.jar in this arcive are the class file "jars\SkillRework\campaign\skills" that have been edited to his liking.

i have looked @ the skill_data but dont know what i sould do with it as i'm not making a new skill just over writing and existing skill.

see below the error i'm getting
P.S i am using intelliJ to make the jar file flowing a guide on this forum.

9744 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [ma.campaign.skills.FleetLogistics$Level2]
java.lang.RuntimeException: Error compiling [ma.campaign.skills.FleetLogistics$Level2]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: ma.campaign.skills.FleetLogistics$Level2
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 16, 2020, 05:25:32 AM
Per drone, yeah.

Thanks - that works quite well :)

Another question though: how do I get the instance of the statsScript associated with a ship's system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fortyseven on March 16, 2020, 04:45:40 PM
Hi there is it possible when making a customised star system to position it randomly on the sector map?

      
Spoiler
//Star
      PlanetAPI star = system.initStar(
         "star",
         "star_yellow",
         800,
                        x
                        y   
         600);
[close]

So I would like the x and y coordinates to have random values say between -20000 to -10000 or 10000 to 20000 (I want to not have it spawn amongst the core worlds)

Is it possible to use (int)Math.random() for this? and how would you make the "or" argument?

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 16, 2020, 07:10:49 PM
Hi there is it possible when making a customised star system to position it randomly on the sector map?

      
Spoiler
//Star
      PlanetAPI star = system.initStar(
         "star",
         "star_yellow",
         800,
                        x
                        y   
         600);
[close]

So I would like the x and y coordinates to have random values say between -20000 to -10000 or 10000 to 20000 (I want to not have it spawn amongst the core worlds)

Is it possible to use (int)Math.random() for this? and how would you make the "or" argument?

Thank you!

Basic java, you just want to replace the numbers 800 and 600 with a randomX and randomY where
Code
int randomX;
        int randomY;
        do {
            randomX = ThreadLocalRandom.current().nextInt(-20000, 20000);
            randomY = ThreadLocalRandom.current().nextInt(-20000, 20000);
        } while (!(-10000 < randomX && randomX < 10000) && !(-10000 < randomY && randomY < 10000));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: fortyseven on March 17, 2020, 03:15:29 AM

Basic java, you just want to replace the numbers 800 and 600 with a randomX and randomY where
Code
int randomX;
        int randomY;
        do {
            randomX = ThreadLocalRandom.current().nextInt(-20000, 20000);
            randomY = ThreadLocalRandom.current().nextInt(-20000, 20000);
        } while (!(-10000 < randomX && randomX < 10000) && !(-10000 < randomY && randomY < 10000));

Hi tomatopaste, thanks for your reply! I appologise for my lack of java knowledge so you might need to help me a little more a long the way.

I tried to insert your code at x and y but I get a runtime exception due to a parsing error. This is the readout from the log file starting at the error.

Spoiler
25125 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.MyStarPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.MyStarPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.MyStarPlugin'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/MyStarPlugin.java', Line 65, Column 7: Expression "int" is not an rvalue
   at org.codehaus.janino.Java$Located.throwCompileException(Java.java:111)
   at org.codehaus.janino.Java$Atom.toRvalueOrCompileException(Java.java:2698)
   at org.codehaus.janino.Parser.parseArgumentList(Parser.java:2696)
   at org.codehaus.janino.Parser.parseArguments(Parser.java:2682)
   at org.codehaus.janino.Parser.parsePrimary(Parser.java:2354)
   at org.codehaus.janino.Parser.parseUnaryExpression(Parser.java:2252)
   at org.codehaus.janino.Parser.parseMultiplicativeExpression(Parser.java:2211)
   at org.codehaus.janino.Parser.parseAdditiveExpression(Parser.java:2190)
   at org.codehaus.janino.Parser.parseShiftExpression(Parser.java:2169)
   at org.codehaus.janino.Parser.parseRelationalExpression(Parser.java:2072)
   at org.codehaus.janino.Parser.parseEqualityExpression(Parser.java:2046)
   at org.codehaus.janino.Parser.parseAndExpression(Parser.java:2025)
   at org.codehaus.janino.Parser.parseExclusiveOrExpression(Parser.java:2004)
   at org.codehaus.janino.Parser.parseInclusiveOrExpression(Parser.java:1983)
   at org.codehaus.janino.Parser.parseConditionalAndExpression(Parser.java:1962)
   at org.codehaus.janino.Parser.parseConditionalOrExpression(Parser.java:1941)
   at org.codehaus.janino.Parser.parseConditionalExpression(Parser.java:1922)
   at org.codehaus.janino.Parser.parseAssignmentExpression(Parser.java:1901)
   at org.codehaus.janino.Parser.parseExpression(Parser.java:1886)
   at org.codehaus.janino.Parser.parseVariableInitializer(Parser.java:966)
   at org.codehaus.janino.Parser.parseVariableDeclaratorRest(Parser.java:1230)
   at org.codehaus.janino.Parser.parseVariableDeclarator(Parser.java:1215)
   at org.codehaus.janino.Parser.parseVariableDeclarators(Parser.java:1177)
   at org.codehaus.janino.Parser.parseBlockStatement(Parser.java:1158)
   at org.codehaus.janino.Parser.parseBlockStatements(Parser.java:1085)
   at org.codehaus.janino.Parser.parseMethodDeclarationRest(Parser.java:938)
   at org.codehaus.janino.Parser.parseClassBodyDeclaration(Parser.java:565)
   at org.codehaus.janino.Parser.parseClassBody(Parser.java:515)
   at org.codehaus.janino.Parser.parseClassDeclarationRest(Parser.java:481)
   at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:269)
   at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:168)
   at org.codehaus.janino.JavaSourceIClassLoader.findCompilationUnit(JavaSourceIClassLoader.java:203)
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:146)
   ... 7 more
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 17, 2020, 04:59:42 AM
I'm looking for a way to make an industry require two industry slots.
My hackjob solution is to make it unavailible if there are less than two open, and auto-place an secondary industry on build, wich causes issues I would rather not have to account for since it can be removed...

is there a better way?
Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alluvian on March 17, 2020, 06:35:29 AM
I'm looking for a way to make an industry require two industry slots.
My hackjob solution is to make it unavailible if there are less than two open, and auto-place an secondary industry on build, wich causes issues I would rather not have to account for since it can be removed...

is there a better way?
Thanks :)

One alternative would be to still require 2 slots to start, but on build to reduce the total slots available by one. However, this means you would need to restore the reduced slot if/when the industry is removed.

Another would be to add a planetary condition (or other similar non-industry slot addition) that has the -1 reduction effect while present.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 17, 2020, 08:08:04 AM

One alternative would be to still require 2 slots to start, but on build to reduce the total slots available by one. However, this means you would need to restore the reduced slot if/when the industry is removed.

Another would be to add a planetary condition (or other similar non-industry slot addition) that has the -1 reduction effect while present.

I'd have done that if it was possible to modify the total industry slots on a market, which it is not (without touching pop&infrastructure) to my knowledge.

there is, as far as I can see, no way to make something count as industry (and therefore counting towards the limit on a market) without extending baseIndustry.

but I would gladly be proven wrong
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 17, 2020, 11:51:48 AM
Another question though: how do I get the instance of the statsScript associated with a ship's system?

You can't directly - but if that script puts a reference to itself into the CombatEngineAPI.getCustomData(), you could use that.


I'd have done that if it was possible to modify the total industry slots on a market, which it is not (without touching pop&infrastructure) to my knowledge.

(This'll be possible in the next release, btw, there'll be a market stat for this.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 17, 2020, 01:03:28 PM
I have the slight fear that my entire mod will become obsolete with the next release.

Is there a way to do it for the current release, or a way to make invisible industry buildings?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 17, 2020, 01:21:53 PM
IIRC if you override BaseIndustry.isHidden() to return true, that industry won't show up in the main list. It'd still show up in the "industry count tooltip", though - at least I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 17, 2020, 01:40:48 PM
Yep, that worked. IndustryCount doesn't show it, but industries&Structures tooltip does.
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harpuea on March 18, 2020, 10:10:56 AM
Is there a way to change the sprite of a ship without having to make duplicated Hulls, variant, and CSVs files? I just want to repaint a ship so all the ships in the fleet match colors. I messed around in Eclipse and found Ship.setSprite API, but it seems that will be complicated to write UI in game in order to work for all ships.

For now, I'll try the hullmod approach. But that is rather specific to a ship and isn't a broad stroke approach in order to paint ALL ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 18, 2020, 04:02:39 PM
If you are okay with all ships of that class having your paint scheme, you should be able to easily make a mod to change the sprites. Just give your sprites the exact same names (and folders) as the ones you want to replace and (if you are replacing mod sprites) be sure to prefix your mod's ID with "zz" so it loads last.

If you only want your ships to have the paint scheme, then a hullmod will probably work. I've never messed around with dynamically changing sprites, so I'm not sure what you can and can't do there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 19, 2020, 01:30:53 AM
Solved one problem, got the next.
I want to modify the export value for goods provided by a single market.

Is that doable? (please don't say next version :P )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harpuea on March 19, 2020, 06:00:53 AM
How exactly does setSprite() work? Any one know? I tried messing around a hullmod and the ship always turn transparent.

Code
{
"graphics":{
"paintjobs":{
"diableavionics_vapor":"graphics/da/ships/diableavionics_vapor_white.png",
},
}
}

Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.CollisionClass;

public class Paintjob extends BaseHullMod {

    private float CenterX = 0f;
private float CenterY = 0f;

@Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
    }
   
    @Override
    public String getDescriptionParam(int index, HullSize hullSize) {
        return null;
    }
   
    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
    CenterX  = ship.getSpriteAPI().getCenterX();
    CenterY   = ship.getSpriteAPI().getCenterY();
    ship.setSprite("paintjobs", "diableavionics_vapor"); //need settings.sjon file
    ship.getSpriteAPI().setCenterX(CenterX);
    ship.getSpriteAPI().setCenterY(CenterY);
    }
   
    @Override
    public boolean isApplicableToShip(ShipAPI ship)
    {
   
return ( ship.getHullSpec().getHullId().startsWith("diableavionics_vapor"));
    }
}

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 19, 2020, 10:23:39 AM
Solved one problem, got the next.
I want to modify the export value for goods provided by a single market.

Is that doable? (please don't say next version :P )

Only market.getIncomeMult(), I'm afraid - which affects both exports and baseline colony income. You could also compute it separately and add it as its own item in the monthly income report, but with that approach, it would not show up in "income" field in the colony screen or the colony list.

@Harpuea: hmm, I just tried "ship.setSprite("newGame", "mixed");" and that worked, so I'm not sure. This kind of sounds like the sprite you're using doesn't exist (i.e. a typo in the path?) or is not a 24-bit png or is corrupted in some way etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 19, 2020, 10:49:25 AM
Only market.getIncomeMult(), I'm afraid - which affects both exports and baseline colony income. You could also compute it separately and add it as its own item in the monthly income report, but with that approach, it would not show up in "income" field in the colony screen or the colony list.

Hm, not the answer I was hoping for, but kinda what I expected.
Any chance of having an API hook for that in the next version? I was trying to assign a dynamic export value to luxury goods, so the export value/unit would increase based on the presence of some conditions.

Thanks,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 19, 2020, 10:54:02 AM
Probably not, to be honest. I'll keep it in mind in case I happen to be doing other stuff in that area of the code, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harpuea on March 19, 2020, 12:13:31 PM
Quote
@Harpuea: hmm, I just tried "ship.setSprite("newGame", "mixed");" and that worked, so I'm not sure. This kind of sounds like the sprite you're using doesn't exist (i.e. a typo in the path?) or is not a 24-bit png or is corrupted in some way etc.

It was an issue with color mode. Thank you very much.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 19, 2020, 12:17:20 PM
Glad you got it working!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 20, 2020, 03:58:31 PM
The industry limit can be adjusted via dynamic stat mods in this version (0.9.1a) already, which might prove useful for anyone reading this while searching the thread.
Code
market.getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).modify...

for my actual question:
I'd like to set Recreational Drugs as legal on a market via a condition.
Code
market.getCommodityData(Commodities.DRUGS).setSupplyLegal(true);
doesn't seem to do it. What am I missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 20, 2020, 04:41:54 PM
for my actual question:
I'd like to set Recreational Drugs as legal on a market via a condition.
Code
market.getCommodityData(Commodities.DRUGS).setSupplyLegal(true);
doesn't seem to do it. What am I missing?

Taking a quick look at the code, that only works the other way - to make something that would otherwise be legal, illegal. It's not used in vanilla as far as I can tell and I'm not even sure it works correctly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 20, 2020, 05:05:58 PM
I take it there's no current way to achieve that then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 20, 2020, 05:12:38 PM
I don't believe so, but it depends on the specifics of what you're doing. For example if the drugs are being produced by a specific industry, then having it return true from isSupplyLegal() *should* make them legal on that market as far as getting income from exports.

(You could also set the market to free port, though that of course has other implications...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on March 21, 2020, 02:48:27 AM
Hello, two things:

Is there a way to change when enemy retreats? I fly with big fleet and when I meet small enemy, I deploy matching force of my ships, so that I dont overpower them but keep it fair. Of course enemy retreats because calculations take into account my whole fleet. Same thing when I join a friend in a fight, I deploy only one ship, but enemies turn tails. And so, how do I make AI braver? Its ok if only in battle - fleeing on campaign screen is permitted :) 

Second thing - I suspect Alex actually enjoys helping modders, seeing how often he replies here, what a guy!

Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 21, 2020, 06:38:06 AM
I don't believe so, but it depends on the specifics of what you're doing. For example if the drugs are being produced by a specific industry, then having it return true from isSupplyLegal() *should* make them legal on that market as far as getting income from exports.

(You could also set the market to free port, though that of course has other implications...)

I'm trying to make the general import and export of drugs (only drugs, not organs) legal for a specific market, via a condition that can be applied by the player through a menu.
This should affect all industries, not just mine - which it currently doesn't as I'd like to avoid that if possible :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2020, 10:16:05 AM
Is there a way to change when enemy retreats? I fly with big fleet and when I meet small enemy, I deploy matching force of my ships, so that I dont overpower them but keep it fair. Of course enemy retreats because calculations take into account my whole fleet. Same thing when I join a friend in a fight, I deploy only one ship, but enemies turn tails. And so, how do I make AI braver? Its ok if only in battle - fleeing on campaign screen is permitted :) 

IIRC the AI doesn't consider enemy reserves when deciding whether to retreat from the battlefield.

I'm not sure if it's in the current release or not, but: CombatTaskManagerAPI.setPreventFullRetreat(false) would do the job.

Otherwise, there's BattleCreationContext.aiRetreatAllowed, but getting to that would be more complicated.

Second thing - I suspect Alex actually enjoys helping modders, seeing how often he replies here, what a guy!

(Ha! Let's just say I'm glad to help.)

I'm trying to make the general import and export of drugs (only drugs, not organs) legal for a specific market, via a condition that can be applied by the player through a menu.
This should affect all industries, not just mine - which it currently doesn't as I'd like to avoid that if possible :)

Ah, gotcha. Nothing comes to mind, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 21, 2020, 08:16:28 PM
Is there a way to make commodities be treated as crew/marines for cargo purposes (use crew capacity, can't be dumped with other cargo)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2020, 08:36:47 PM
No on both counts, I'm afraid - crew/marines are hardcoded as the only ones in a few different places. Sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 22, 2020, 03:46:03 AM
Ah, ouch. Could it be changed to read the personnel tag in commodities.csv?

Two new questions:
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 22, 2020, 09:20:01 AM
Ah, ouch. Could it be changed to read the personnel tag in commodities.csv?

Probably not, honestly, not unless there's a vanilla use case. It'd be too much of a pain to do and make sure that it works (and that it continues to work) otherwise. There are many loose ends where I'm not *quite* sure whether they would "just work" or would need to be changed, and it's a lot of stuff to look through.

How do I get a fleet's immediate movement waypoint (e.g. "I want to go to another star system, so I am currently headed for jump point X")? Is NavigationModulePlugin.getClickToMoveLocation() what I should be using?

Hmm. So the ultimate course target is SectorAPI.getUIData().getCourseTarget(). The intermediate one... <digs in> doesn't look like it's exposed. Let me add these to CampaignUIAPI:
   SectorEntityToken getCurrentCourseTarget();
   SectorEntityToken getNextStepForCourse(SectorEntityToken courseTarget);
   void layInCourseForNextStep(SectorEntityToken courseTarget);
   String getNameForCourseTarget(SectorEntityToken entity, boolean isEndpoint);
   float getLastLegDistance(SectorEntityToken courseTarget);
   
In the meantime, I think playerFleet.getInteractionTarget() should do the job. NavigationModulePlugin is ... ahh, I totally misinterpreted the question, thought it was about the course widget. Aha. Actually, getInteractionTarget() should work there, too, but it may not always point to that, i.e. if the fleet gets distracted chasing an enemy. getClickToMoveLocation() is just going to be some point along the path, which gets adjusted depending on how fast the fleet wants to go etc (and is iirc capped out at 10,000 units away from the fleet), it's not always going to be the destination.


A user reported a graphical glitch in my mod's use of FleetMemberPickerDialog; see the white square in
...
At a guess, what might cause such a thing?

Probably the icon rendering not being tested with icons that large - it does some stuff clearing out the destination alpha buffer and this likely means that the quads it's doing this with start overlapping for neighboring icons past a certain size and cause a bit of a mess. I *think* I may have tweaked this in the dev version? Not 100% sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Karamitsuko on March 24, 2020, 10:49:10 AM
Is there any way to add restricted hullmods (such as the missile autoforge) to ships that aren't meant to have them by the use of console commands? Or, would I have to actually add them to the ship files themselves in order to do it? I've already tried manually adding the blueprint for certain restricted modspecs into my inventory and learning them that way, but they still won't allow me to actually put them on a ship
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 24, 2020, 12:05:09 PM
I am facing a rather problematic situation - I got a class that just won't load:

Code
java.lang.RuntimeException: Problem loading class [com.fs.starfarer.api.impl.campaign.econ.conditions.deconomics_edict_conscription]
at com.fs.starfarer.loading.scripts.ScriptStore.Ó00000(Unknown Source)
at com.fs.starfarer.loading.newsuper.getNewPluginInstance(Unknown Source)
at com.fs.starfarer.campaign.econ.MarketCondition.readResolve(Unknown Source)
at com.fs.starfarer.campaign.econ.MarketCondition.<init>(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)

All entries seem fine and the other 7 conditions I made load without issue.
This happens regardless of what the content of the class is.

Do you have any pointers for me?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 24, 2020, 12:22:36 PM
Is there any way to add restricted hullmods (such as the missile autoforge) to ships that aren't meant to have them by the use of console commands? Or, would I have to actually add them to the ship files themselves in order to do it? I've already tried manually adding the blueprint for certain restricted modspecs into my inventory and learning them that way, but they still won't allow me to actually put them on a ship

You'd have to either edit the variant file or set the hullmod to not be hidden (via hull_mods.csv), but the latter might have some unintended consequences such as other ships starting to use it. Not 100% sure.

Do you have any pointers for me?

Post more of the error - there should be another stack trace, I believe? - and the contents of the class :)

My guess would be the maybe it doesn't have a default constructor?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 24, 2020, 02:25:54 PM
Oh my god there is a second stack trace
problem solved - thank you so much
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 26, 2020, 02:56:32 PM
Are there hardcoded/seeded (by hull id specifically) derelicts in vanilla, and if so, what class in the API handles that and can it be easily modified?

If that part is obfuscated from the API, can I by chance alternatively get a list of the hull ids that can be seeded?

(I've removed all the vanilla references to hull ids in favor of a unique TC prefix for each of my ids (to prevent any mod merging from causing crashes or other weirdness) and replaced each hull instance that is necessary with an overriding csv line which removes its tags for blueprints/faction use and adds hints to remove them from the codex and prevent them from spawning in markets.)

Trying to cover all my bases for the full TC experience before working on additional tweaks to the "lite version"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 26, 2020, 04:18:34 PM
Other than MiscellaneousThemeGenerator spawning XIV Legions, hmm. There's a derelict shuttle on the station near Asharu (see: Corvus.java), and I *think* that might be it. Nothing else comes to mind, at least.

Oh! The game will also spawn a nebula_Standard whenever it can't find a ship that it's trying to spawn.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 26, 2020, 06:19:04 PM
Other than MiscellaneousThemeGenerator spawning XIV Legions, hmm. There's a derelict shuttle on the station near Asharu (see: Corvus.java), and I *think* that might be it. Nothing else comes to mind, at least.

Oh! The game will also spawn a nebula_Standard whenever it can't find a ship that it's trying to spawn.

Thanks! The only thing that may be a problem there for me is the legion. The shuttle is unchanged in the TC (I'm like 90% sure anyway) and the nebula which will change with the next release shouldn't ideally come up if I'm doing things correctly.

I'll take a look at the theme generator class and see about different solutions. I feel that not changing the id may inevitably interfere with other mods, so I will likely have to do something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 27, 2020, 05:04:32 AM
How do I get the list of freelance administrators the player has hired?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 27, 2020, 05:18:31 AM
CharacterDataAPI has getAdmins()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 27, 2020, 09:14:25 AM
I'm trying to selectively disable the storage parts of a Submarket - as in, can't store ships in a commodity-only-Submarket.
Could you point me in the right direction? I'm not finding anything in BaseSubmarketPlugin...


never mind, I can't read.
thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on March 27, 2020, 07:11:28 PM
What's the fastest way to grab the player's selected skill for quests and such?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArneHD on March 28, 2020, 06:42:49 AM
Does anyone here know how to get a hold of Java 7? I've set up Netbeans IDE, but I've only been able to find JDE 14/13.

Thanks for your help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 28, 2020, 06:58:00 AM
Does anyone here know how to get a hold of Java 7? I've set up Netbeans IDE, but I've only been able to find JDE 14/13.

Thanks for your help.

download from oracles website or:
https://drive.google.com/open?id=1cle4yGhPkROCu3z5WKHKLR098ObGLwPV
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 28, 2020, 07:11:54 AM
You can use a newer JDK btw, you just need to set your IDE to compile for JDK 7 (in Netbeans it's the project's Source/Binary Format)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArneHD on March 28, 2020, 07:45:44 AM
Does anyone here know how to get a hold of Java 7? I've set up Netbeans IDE, but I've only been able to find JDE 14/13.

Thanks for your help.

download from oracles website or:
https://drive.google.com/open?id=1cle4yGhPkROCu3z5WKHKLR098ObGLwPV

Thanks a million! That worked perfectly!

You can use a newer JDK btw, you just need to set your IDE to compile for JDK 7 (in Netbeans it's the project's Source/Binary Format)

Well, now I just feel like an idiot. I spent an afternoon trying to get things to work and answer turns out to be a damn drop down menu.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on March 30, 2020, 01:25:30 AM
Hello! When using the method ship.getLaunchBaysCopy() on a ship with existing launch bay weapon types, but no fighter slots, it returns an empty list. Is this intentional, or am I missing something? Also, it would be useful if there was an API hook for FighterLaunchBayAPI to get the absolute location. Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2020, 10:57:15 AM
Hello! When using the method ship.getLaunchBaysCopy() on a ship with existing launch bay weapon types, but no fighter slots, it returns an empty list. Is this intentional, or am I missing something? Also, it would be useful if there was an API hook for FighterLaunchBayAPI to get the absolute location. Thanks :)

Hey! Yeah, this is intentional - a FighterLaunchBayAPI is like a WeaponAPI, not like a WeaponSlotAPI.

Added:
WeaponSlotAPI - List<Vector2f> getLaunchPointOffsets();
and
FighterLaunchBayAPI - WeaponSlotAPI getWeaponSlot();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on March 30, 2020, 01:39:40 PM
Bit of a weird question. What are the extension that are used by the game in the root folder of a mod directorie?

What I mean: the mod-info is read by the game, I presume stuff like readme.txt or license. txt are not. How does one decide if a particular file is essential for a mod or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: toasterific on March 30, 2020, 02:44:01 PM
Hello, I'm pretty new to the forum and a very big dummy when it comes to coding, i can't help but get confused about where to modify the skill values in the game? (for example Ship Design points, Fleet size, Max admin/officers per level) I'm just trying to rebalance some things for my own gameplay and just generally messing around with values, but for some its quite hidden away and i'm nowhere near to solving this problem since most tutorial i see aims at planets and ships... I appreciate it if you'd help a fellow dumb gamer
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 30, 2020, 06:15:21 PM
Hello, I'm pretty new to the forum and a very big dummy when it comes to coding, i can't help but get confused about where to modify the skill values in the game? (for example Ship Design points, Fleet size, Max admin/officers per level) I'm just trying to rebalance some things for my own gameplay and just generally messing around with values, but for some its quite hidden away and i'm nowhere near to solving this problem since most tutorial i see aims at planets and ships... I appreciate it if you'd help a fellow dumb gamer

Fractal Softworks\Starsector\starsector-core\data\characters\skills -That's where the skills are handled. Start with skill_data.csv.

Keep in mind, if the path in that file is something like: com.fs.starfarer.api.impl.campaign.skills- Then the stats are handled in the api and you will have to copy from there and reference your changes in a new file in the skills folder- OR -compile your script into a jar and reference it that way.

That will get you started at least.  :)

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

Is it possible to hide a ship system in the codex?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2020, 06:20:16 PM
Bit of a weird question. What are the extension that are used by the game in the root folder of a mod directorie?

What I mean: the mod-info is read by the game, I presume stuff like readme.txt or license. txt are not. How does one decide if a particular file is essential for a mod or not.

That's it, just the mod_info file. Version Checker might look for an additional file, not 100% sure?

Is it possible to hide a ship system in the codex?

Hmm, I don't believe so.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 30, 2020, 06:58:59 PM
Hmm, I don't believe so.

Ah well not really a big deal. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: toasterific on March 30, 2020, 08:30:22 PM
Hello, I'm pretty new to the forum and a very big dummy when it comes to coding, i can't help but get confused about where to modify the skill values in the game? (for example Ship Design points, Fleet size, Max admin/officers per level) I'm just trying to rebalance some things for my own gameplay and just generally messing around with values, but for some its quite hidden away and i'm nowhere near to solving this problem since most tutorial i see aims at planets and ships... I appreciate it if you'd help a fellow dumb gamer

Fractal Softworks\Starsector\starsector-core\data\characters\skills -That's where the skills are handled. Start with skill_data.csv.

Keep in mind, if the path in that file is something like: com.fs.starfarer.api.impl.campaign.skills- Then the stats are handled in the api and you will have to copy from there and reference your changes in a new file in the skills folder- OR -compile your script into a jar and reference it that way.

That will get you started at least.  :)

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

Is it possible to hide a ship system in the codex?
yep, the .csv files doesnt provide the value / script that can be changed, only the description of it tho...

Quote
compile your script into a jar and reference it that way.
And this is what i need help with right now since there aren't a lot of tutorials explaining how to make utility mods :/
or at least an external link where i can get somewhere hmm
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 30, 2020, 08:56:34 PM
yep, the .csv files doesnt provide the value / script that can be changed, only the description of it tho...

Quote
compile your script into a jar and reference it that way.
And this is what i need help with right now since there aren't a lot of tutorials explaining how to make utility mods :/
or at least an external link where i can get somewhere hmm

For the IDE tutorial to do this I recommend: https://fractalsoftworks.com/forum/index.php?topic=10057.0 (https://fractalsoftworks.com/forum/index.php?topic=10057.0) It's a little outdated but should give you a good starting point.

The csv file is important because you can't just change the source in the API and have the game read it. That's provided as a reference only and you have to copy it and extract the code from the zip to even be able to open it in notepad.

You don't strictly need an IDE to change these values, though, at least I'm fairly sure you don't as you should be able to create a "scripts" directory under the skills directory and put your changed scripts there. You can then create your own skill stats file by copying and extracting the API directory in starsector core and then reference your new script by editing the csv file to point to your code instead. I don't think you need a jar to do that. It's just better to do it that way if you are releasing your changes as a mod. For personal use you can probably save time by skipping the IDE (though it is really worth it to know how to do this if you ever want to publicly release anything).

I can give an example if that would be helpful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on March 31, 2020, 11:01:24 AM
Bit of a weird question. What are the extension that are used by the game in the root folder of a mod directorie?

What I mean: the mod-info is read by the game, I presume stuff like readme.txt or license. txt are not. How does one decide if a particular file is essential for a mod or not.

That's it, just the mod_info file. Version Checker might look for an additional file, not 100% sure?

I know some mod have .ini and .json file that seems to refer to config or settings Like lazylib_setting.json for example. I'm asking because I'm trying to mash together a  couple mods into a single mod, for experiment, and I want to know what I should keep and where I should put it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 31, 2020, 11:35:00 AM
Ah - that's mod-specific, then; not really something I can answer in a general way. Pretty much any file that's there, is probably there for a reason, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on March 31, 2020, 12:53:45 PM
but what happens when a mod as a file there with the same name as one from another mod? Like for example I often see a licence.txt. Does they have to make sure there setting file is named differently because at runtime they get overwrited?

Also, since im here. The SWP has  a rules.csv and a rules.xlsx. Are these merged together at runtime? Or is the rules.xlsx disregarded by the game
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 31, 2020, 01:37:21 PM
I'm trying to reset a fleet member to its base hull variant if it has no D-Mods.

shipVariant is ShipVariantAPI of the fleet member I want to reset:

shipVariant.setHullSpecAPI(shipVariant.getHullSpec().getBaseHull());

this does not seem to do the trick.
am I missing something obvious again?
Title: difficulty modding normal/starfarer
Post by: spobely on March 31, 2020, 03:00:54 PM
I think this is my first time using a forum in like 7 years

Anyways is there a way to add modifiers to "normal" and starfarer difficulty? In settings.json I could edit easy like:
Code
	"easyPlayerDamageDealtMult":1,
"easyPlayerDamageTakenMult":1,
"easySensorBonus":750,
"easySalvageMult":1.0,
"easyOfficerLevelMult":1,

Can the same be done for starfarer/normal? And if so how
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 31, 2020, 03:20:34 PM
I think this is my first time using a forum in like 7 years

Anyways is there a way to add modifiers to "normal" and starfarer difficulty? In settings.json I could edit easy like:
Code
	"easyPlayerDamageDealtMult":1,
"easyPlayerDamageTakenMult":1,
"easySensorBonus":750,
"easySalvageMult":1.0,
"easyOfficerLevelMult":1,

Can the same be done for starfarer/normal? And if so how

You can to a point, yes. I think it will depend upon what you want to do and whether or not you have access to that in the API. And to my knowledge you can only do this for normal and easy (maybe ironmode?- never tried).

You would have to create a script that loads on a new campaign. The script would read your settings file and parse the values that would act as modifiers to apply your changes. Then the script would check for the easy setting. If the easy setting exists, make your easy changes. If not, make normal changes. You will save yourself a lot of time by using an IDE so it's easier to find the API you would have to call. It won't be trivial to do, but it is possible.

To give you a head start because I've used this before:

To check easy setting:
Code
            boolean easyMode = com.fs.starfarer.api.util.Misc.isEasy();
                                                        // higher chance of success when on easy difficulty
            if (easyMode) {
                fireChance += 15;
                aidCost *= 0.65;
            }

Is an example from my commodity request script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 01, 2020, 12:23:09 PM
I'm trying to reset a fleet member to its base hull variant if it has no D-Mods.

shipVariant is ShipVariantAPI of the fleet member I want to reset:

shipVariant.setHullSpecAPI(shipVariant.getHullSpec().getBaseHull());

this does not seem to do the trick.
am I missing something obvious again?

Also, I can't seem to find code for the vanilla restoration function - is it obfuscated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2020, 01:09:08 PM
I'm trying to reset a fleet member to its base hull variant if it has no D-Mods.

shipVariant is ShipVariantAPI of the fleet member I want to reset:

shipVariant.setHullSpecAPI(shipVariant.getHullSpec().getBaseHull());

this does not seem to do the trick.
am I missing something obvious again?

You probably just want to suppress its d-mods, by iterating over variant.getPermaMods() and suppressing ones with the dmod tag, using variant.addSuppressedMod().

Also, I can't seem to find code for the vanilla restoration function - is it obfuscated?

Yeah, it's in core code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 01, 2020, 01:26:21 PM

You probably just want to suppress its d-mods, by iterating over variant.getPermaMods() and suppressing ones with the dmod tag, using variant.addSuppressedMod().


I'm making an industry that slowly removes D-Mods of ships at a reduced cost, by removing them via ship.getVariant().removePermaMod() - but judging by your answer that might not be the way to go.
The issue I am facing is that a ship without any active D-Mods does not revert back to the standard variant ( Kite(D) -> Kite ) - which I was trying to trigger manually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2020, 02:32:04 PM
Ah, right - what you're doing there with .setHullSpecAPI() seems generally right, then. The way you want to get the base hull is this:

Code
ShipHullSpec base = v.getHullSpec().getDParentHull();
if (!v.getHullSpec().isDefaultDHull() && !v.getHullSpec().isRestoreToBase()) base = v.getHullSpec();
if (base == null && v.getHullSpec().isRestoreToBase()) {
base = v.getHullSpec().getBaseHull();
}

IIRC this handles some special cases about pre-made d-hulls, though, so I'm not sure if this is all necessary anymore, but this is how the restore code does it.

(To be honest, I didn't look too deeply into this right now...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MISTB on April 01, 2020, 02:55:40 PM
So I've been working on a mod and have most everything down and a ship prepped with decorative weapons to be animated, but i'm not familiar with java at all. Pouring through others mods I found most of what I needed to do but since their animations are more complex i'm having trouble understanding exactly what is doing what.

Basically, if anyone can throw together a very basic script with some stand in ID's that animates a single decorative weapon in a straight line while active venting I think i'd be able to understand a lot easier than trying to determine what is what from a very complex animation script. Can tell for the most part what is what in the scripting, but not competent enough in Java to directly create a barebones script since i'm unsure what's absolutely necessary and what isn't.

Thanks in advance for anyone willing to spend their time throwing one together for me to look at or use. Hoping I can get the hang of it and make a good variety of ships without having to pester someone to script for me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 01, 2020, 03:29:36 PM
Ah, right - what you're doing there with .setHullSpecAPI() seems generally right, then. The way you want to get the base hull is this:

-code

IIRC this handles some special cases about pre-made d-hulls, though, so I'm not sure if this is all necessary anymore, but this is how the restore code does it.

(To be honest, I didn't look too deeply into this right now...)

And with that, my issue is solved. I honestly still don't know where my error was, but I am very grateful for you solving it.
Thank you for repeatedly taking the time answering questions, I very much appreciate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: GigaVivian on April 02, 2020, 05:03:33 PM
I can't find if this has been asked already, I know easy player damage has been mentioned alot, but what if I want to change the Damage types themselves? Like make Fragmentation damage deal 30% to all types but hull instead of 25%? As the player damage (assumingly) does not affect your >non-player controlled< fleet or ally's ships' vs enemy ships' (and vise versa) damage, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2020, 05:12:07 PM
And with that, my issue is solved. I honestly still don't know where my error was, but I am very grateful for you solving it.
Thank you for repeatedly taking the time answering questions, I very much appreciate it.

You're welcome, glad that did it!

I can't find if this has been asked already, I know easy player damage has been mentioned alot, but what if I want to change the Damage types themselves? Like make Fragmentation damage deal 30% to all types but hull instead of 25%? As the player damage (assumingly) does not affect your >non-player controlled< fleet or ally's ships' vs enemy ships' (and vise versa) damage, right?

It's not currently possible. However - let me add the relevant setter methods to the DamageType enum. Might even end up being of use to a TC that wanted to completely revamp/rename damage types.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gwyvern on April 02, 2020, 10:35:55 PM
As long as you are on the topic, how difficult would it be to allow the addition of whole new damage types?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 03, 2020, 08:53:58 AM
As long as you are on the topic, how difficult would it be to allow the addition of whole new damage types?

It'd be pretty difficult, especially since it's also something the AI is aware of. In practical terms, while not strictly impossible, it's a very definite "no" - sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 03, 2020, 03:57:55 PM
I've had a report of substantial collisions upon starting a battle with modded ships (more so than vanilla). Is there anything I can do about this? The current theory is that smaller ships are too slow and when larger ships (that spawn in the back) have max speed boosts and are relatively fast for their class they often plow through the front line and even destroy allied ships. Since I nerfed carrier speed rather substantially to prevent kiting and force carrier protection, I also think that could be coming into play if a lot of frigate carriers are deployed.

Probably not much I can do other than increase the speed of smaller ships globally, but figured I'd ask just in case.

------

I'm going to look into the API for some clarity on this, but I'm concerned I'm not seeing enough procurement missions in the campaign simulation which is making it hard to troubleshoot a bug with them. Do I strictly need economy deficits for those to come into play? I'm flying a freighter heavy fleet (I think that is a factor iirc) with plenty of free cargo space yet I only get the occasional mission of that type and though I've had a few mod faction missions, these spawn much more frequently on pirate colonies (which have deficits).

The consideration I am trying to make with this is to give factions more equality of starting industries/resources at players' request. (I gave the Luddic Church fuel production, another large refining colony, a couple more military bases and an orbital works, for instance. I also gave Gilead a high command star fortress to guard it from above.) That being said, I don't want to completely remove procurement missions when playing the campaign stand-alone outside of the volatility of faction dynamics in Nex. Right now in my current build, though factions have strengths and weakness in market share, it's split fairly evenly among most commodities. Any pointers?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 03, 2020, 07:28:42 PM
I've had a report of substantial collisions upon starting a battle with modded ships (more so than vanilla). Is there anything I can do about this? The current theory is that smaller ships are too slow and when larger ships (that spawn in the back) have max speed boosts and are relatively fast for their class they often plow through the front line and even destroy allied ships. Since I nerfed carrier speed rather substantially to prevent kiting and force carrier protection, I also think that could be coming into play if a lot of frigate carriers are deployed.

Probably not much I can do other than increase the speed of smaller ships globally, but figured I'd ask just in case.

Yeah, that AI generally assumes that it's the smaller ship's job to get out of the way, and that it's capable of it. Smaller ships too far out of the expected movement speed range band cause problems.

Do I strictly need economy deficits for those to come into play?

I *think* it needs to not be available "nearby" but I'm not 100% sure. You'd probably need to dig through ProcurementMissionIntel to figure it out for sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 03, 2020, 09:31:57 PM
So I tried:
How do I get a fleet's immediate movement waypoint (e.g. "I want to go to another star system, so I am currently headed for jump point X")? Is NavigationModulePlugin.getClickToMoveLocation() what I should be using?

Hmm. So the ultimate course target is SectorAPI.getUIData().getCourseTarget(). The intermediate one... <digs in> doesn't look like it's exposed. Let me add these to CampaignUIAPI:
   SectorEntityToken getCurrentCourseTarget();
   SectorEntityToken getNextStepForCourse(SectorEntityToken courseTarget);
   void layInCourseForNextStep(SectorEntityToken courseTarget);
   String getNameForCourseTarget(SectorEntityToken entity, boolean isEndpoint);
   float getLastLegDistance(SectorEntityToken courseTarget);
   
In the meantime, I think playerFleet.getInteractionTarget() should do the job. NavigationModulePlugin is ... ahh, I totally misinterpreted the question, thought it was about the course widget. Aha. Actually, getInteractionTarget() should work there, too, but it may not always point to that, i.e. if the fleet gets distracted chasing an enemy. getClickToMoveLocation() is just going to be some point along the path, which gets adjusted depending on how fast the fleet wants to go etc (and is iirc capped out at 10,000 units away from the fleet), it's not always going to be the destination.
but fleet.getInteractionTarget() seems to always return null for an NPC fleet, even when the fleet is clearly going somewhere (within the same star system) on an assignment.
Should I be doing something different?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2020, 11:17:55 AM
but fleet.getInteractionTarget() seems to always return null for an NPC fleet, even when the fleet is clearly going somewhere (within the same star system) on an assignment.
Should I be doing something different?

Ahh - just yesterday, I ran into an issue with the interaction target being set to null by the tactical module, overriding the jump point that was set as the target (this was causing AI fleets to jump out without the jump-point opening). I'm not sure if this is also an issue in the release, or if this was just a dev bug, but it sounds like it might be the former, then. Nothing comes to mind as a good workaround, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 04, 2020, 12:42:53 PM
@Alex

Thanks for the info!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 05, 2020, 06:14:18 AM
Yeah, that AI generally assumes that it's the smaller ship's job to get out of the way, and that it's capable of it. Smaller ships too far out of the expected movement speed range band cause problems.

I have seen Doom crashing into capital ships and other cruisers. It is clearly the Doom flying into them, not, as you say, them expecting it to get out of the way. I can't remember if I've seen other ships displaying the same behavior, but either way you should watch for this when you are playtesting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 05, 2020, 06:31:25 AM
Is it possible that negative income application on colonies is bugged?
I am trying to apply costs via
Code
getIncome().modifyFlat()
and it sometimes works - and sometimes does this:
(https://i.imgur.com/GfUO342.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sordid on April 05, 2020, 06:36:00 AM
How do you change the number of skill points the player gets at the beginning of a new game? I assume it's just one number somewhere in the files, but I can't find it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 05, 2020, 06:47:38 AM
How do you change the number of skill points the player gets at the beginning of a new game? I assume it's just one number somewhere in the files, but I can't find it.

Starting options are managed by rules.csv.
Find the starting option you would like to edit in that file and change the number behind NGCAddCharacterPoints in the column "script" to the number you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sordid on April 05, 2020, 08:01:20 AM
Starting options are managed by rules.csv.
Find the starting option you would like to edit in that file and change the number behind NGCAddCharacterPoints in the column "script" to the number you want.

Brilliant, thanks very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 05, 2020, 08:42:59 AM
Is it possible that negative income application on colonies is bugged?
I am trying to apply costs via
Code
getIncome().modifyFlat()
and it sometimes works - and sometimes does this:
(https://i.imgur.com/GfUO342.png)

Hmm - if it sometimes work and sometimes doesn't, I'd guess at least the consistency issue is somewhere in your code. Also, you should absolutely not be using income for negative values here - that's what upkeep is for. I wouldn't be surprised if the code clamps income to at least 0 or some such, as a sanity check.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 06, 2020, 07:10:42 AM
I'm using engine.getFleetManager(ship.getOriginalOwner()).spawnShipOrWing(...) to spawn in my drones fighter-style, and am using engine.getFleetManager(ship.getOriginalOwner()).setSuppressDeploymentMessages(true); to prevent the deployment messages, but upon ending missions (untested in campaign), the spawned drones all appear:
Spoiler
(https://i.imgur.com/S8Nvb50.png)
[close]
How do I prevent this? Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 06, 2020, 09:19:35 AM
Someone with more experience doing this might know better, but my initial guess would be that 1) this is unavoidable in missions and 2) this would not happen in the campaign, since it double-checks fleet members against what was present in the original fleets and discards ones that are not found.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on April 06, 2020, 01:49:44 PM
Whats the standard JSON format used? Im trying to read json files in the starsector-core folder and I keep getting invalid Json format errors. Im fairly noob when it comes to these things of course, but I did try to paste the files in JsonFormatter or JSonLint and they dont like them either.

the specific files are
starsector-core\data\campaign\pings.json
starsector-core\data\config\engine_styles.json
starsector-core\data\config\settings.json
they have some weird number value with letters for some field: 1f

starsector-core\data\config\custom_entities.json
has some STATIONS instead of a value. It refer to something else, but how is that parsed?

I'm asking because I'm trying to replicate the process of merging related mod files outside the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 06, 2020, 02:16:54 PM
STATIONS is an enum; for json purposes it's a string, but the game will generally parse it into an enum after loading the file - but that's after the json parser is done. The json parser the game uses supports stuff like "1f", with f meaning "type float" but that's not any different than just having a "1" there. If you see a 1f etc in the game's json files, it's unintentional - just used to doing it inside java code for float constants etc.

The main incompatibility with a standard json parser would be added support for #-style comments.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 06, 2020, 06:40:17 PM
What does:

Code
			"specialItems":[
"pristine_nanoforge",
],

- do in the econ files?

--------------
*EDIT*

I *think* it needs to not be available "nearby" but I'm not 100% sure. You'd probably need to dig through ProcurementMissionIntel to figure it out for sure.

Didn't get a chance to dig into this yet, but weirdly enough after the most recent economy changes (moving around orbital stations adding additional markets, etc) all of a sudden procurement intel missions are sprouting up like weeds even at markets across the sector from where I am (Nvm its all nearby). At least I can test more easily now XD
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 06, 2020, 07:42:03 PM
What does:

Code
			"specialItems":[
"pristine_nanoforge",
],

- do in the econ files?

... nothing, apparently - I think it's just something I forgot to clean up out of aztlan.json. This is from before deciding to specify the special items preinstalled on an industry via this sort of array: ["orbitalworks", "pristine_nanoforge"],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 07, 2020, 01:20:59 AM
... nothing, apparently - I think it's just something I forgot to clean up out of aztlan.json. This is from before deciding to specify the special items preinstalled on an industry via this sort of array: ["orbitalworks", "pristine_nanoforge"],

Ah ok that makes sense, thanks. Ill remove it from my override so I don't get confused later on down the line.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on April 07, 2020, 06:54:40 AM
how does Starsector handle numeric array merging? Like string array are concatenated (see protrait) and value are overwriten. But a faction color is an array of numeric value, if I write a modfile with a  new color for lets say the hegemony, what happens?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2020, 08:57:27 AM
Good question :) It's handled with a horrible hack. JSON arrays whose key names contain "color", "button", or start with "music_", are treated as values and are overwritten instead of being concatenated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 07, 2020, 11:17:43 AM
So I think income is capped to a positive total, which is why it only sometimes ignored the negative income I was applying.
Now, I tried applying a flat mod to the upkeep as per your suggestion, and this happened:
(https://i.imgur.com/7TJnDV3.png)

While it is definitely doing something (it would be 5k upkeep otherwise) most of the effect is ignored.
I am applying the upkeep via getUpkeep().modifyFlat().

edit: the final thing I could do would be to apply a mult mod that brings upkeep up to the total I need, but I'd like to avoid that as it might confuse people a lot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2020, 12:57:38 PM
Hmm - what's the issue? Everything I'm seeing looks like it could be right but I don't know what you're expecting to see.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 07, 2020, 01:09:09 PM
Restoration docks have no exports, so the upkeep amount should be the full ~40.000 - but for some reason, it instead displays (and calculates) 6.000, which is not what I was expecting or what I need it to do.

It looks like I might be misunderstanding something here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2020, 01:31:29 PM
Possible that you didn't let it run a full month? Upkeep in the report is based on how long the upkeep has been that high, e.g. if you built the structure half a month ago, it'd show half the monthly upkeep there. If the upkeep is variable, then what you see in the report is pretty much just not going to match the tooltip, since the tooltip shows the current snapshot, while the report has the actual accumulated expenses (sampled 10 times per month).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 07, 2020, 02:54:17 PM
I *think* it needs to not be available "nearby" but I'm not 100% sure. You'd probably need to dig through ProcurementMissionIntel to figure it out for sure.

Ok I took a look at this in the API. I think you are correct in that:

Code
		for (MarketAPI curr : Misc.getMarketsInLocation(from.getContainingLocation())) {
//if (curr == from) continue;
if (curr.getPrimaryEntity() != null && from.getPrimaryEntity() != null) {
float dist = Misc.getDistance(curr.getPrimaryEntity().getLocation(), from.getPrimaryEntity().getLocation());
if (dist > 10000) continue;
}

- from doNearbyMarketsHave() checks for the selected commodity of the mission to be available in a sufficient quantity at all nearby markets relative to the candidate market once a commodity itself has been chosen. All those that have enough within that distance won't be chosen so the more efficient the campaigns systems are the less likely these types of missions will be available without some kind of dynamic interference. (It also won't choose hidden or player owned markets in general).

So deficits don't seem to matter - But!- if you have created your colonies to have the resources they need nearby regardless of faction (within 10000 in system) then likely no procurement missions will spawn there for that commodity.

Please correct any inaccuracies as this is a first pass. Just my take so far.  :)

What does this mean when it checks settings?

Code
		Global.getSettings().profilerBegin(this.getClass().getSimpleName() + ".pickCommodity()");

Or

Code
		Global.getSettings().profilerBegin(this.getClass().getSimpleName() + ".pickMarket()");

(And a side note)

Code
		WeightedRandomPicker<Float> durationPicker = new WeightedRandomPicker<Float>();
durationPicker.add(20f);
durationPicker.add(30f);
durationPicker.add(40f);
durationPicker.add(60f);

The lowest duration here is a little too low, imo. (I didn't thoroughly check whether this gets modified later like, say, the commodity size requested which later gets modified by market size, etc.) I've found that sometimes it's all but impossible to complete the mission in that short an amount of time if the RNG is right. It makes these less appealing than the bar missions- both because the reward is less and the difficulty can be higher due to the variance. Just some pondering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2020, 08:27:57 PM
Just real quick - this:
Global.getSettings().profilerBegin(this.getClass().getSimpleName() + ".pickCommodity()");

Takes some performance metrics and prints them to the log if running in dev mode when the game exits. Possibly this also requires holding down some key? I forget. Basically it's performance debugging related code and can safely be ignored, except that every profilerBegin() must be matched with a profilerEnd(), so if you happen to be copy-pasting core code to use elsewhere, just removing all these is your best bet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 07, 2020, 11:57:25 PM
Just real quick - this:
Global.getSettings().profilerBegin(this.getClass().getSimpleName() + ".pickCommodity()");

Takes some performance metrics and prints them to the log if running in dev mode when the game exits. Possibly this also requires holding down some key? I forget. Basically it's performance debugging related code and can safely be ignored, except that every profilerBegin() must be matched with a profilerEnd(), so if you happen to be copy-pasting core code to use elsewhere, just removing all these is your best bet.
Thanks! This is really helpful! I can now rule this out as an obfuscated calculation. The recent economy update has been really great, btw. It is much easier to create diverse economics without getting hamstrung by food shortages, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 08, 2020, 02:29:39 AM
Possible that you didn't let it run a full month? Upkeep in the report is based on how long the upkeep has been that high, e.g. if you built the structure half a month ago, it'd show half the monthly upkeep there. If the upkeep is variable, then what you see in the report is pretty much just not going to match the tooltip, since the tooltip shows the current snapshot, while the report has the actual accumulated expenses (sampled 10 times per month).

That was what I was missing - expenses on month end are fractioned by economy tick.
Adding the flat amounts to the current economy report works like a charm, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on April 08, 2020, 04:32:24 AM
I'm afraid I've hit something too ambitious for my abilities.

What I'm trying to do is make a right click system that can be overwritten by a hullmod that adds a shield. I've tried to make a dummy 'makeshift shield' hullmod that can be installed on the ship, and the hullmod has:

Code
	public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
ship.setShield(ShieldType.FRONT, 0.6f, 1.4f, SHIELD_ARC);
}

This however doesn't work. I'm looking at the code, and I'm wondering: is it actually possible to swap out a phase cloak / right-click system for a shield via hullmod? And if there is, may I ask how?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on April 11, 2020, 04:52:43 PM
Hello Alex, I am putting in a hullmod that should not be installed on any ship's modules so I used this method. It seems that modded ships like the Cathedral (from SWP) aren't affected by this and I'm able to attach it on the Cathedral's modules. Are there any plans to make a vanilla ship with modules, so a way to block hullmods on modules can be implemented?
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import org.apache.log4j.Logger;

public class CHM_commissioned2 extends BaseHullMod {
    private static Logger LOG = Global.getLogger(CHM_commissioned2.class);

    @Override
    public boolean isApplicableToShip(ShipAPI ship) {
        if (ship.getParentStation() != null) {
            LOG.info("What is my AHHHHHHHHHHHHHHHHHHHHHHHHHHHH:" + ship.getParentStation().getId());
        }
        return (ship.getParentStation() == null);
    }
    /*@Override
    public boolean isApplicableToShip(ShipAPI ship) {
        return !(ship.getParentStation() != null);
    }*/
    @Override
    public String getUnapplicableReason(ShipAPI ship) {
        return "Trying to install this on a module? First of all...";
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 12, 2020, 05:08:03 AM
Two quick questions

1: Is it possible to make a Hullmod that add extra logistic slots to the ship it's installed in?

2: Is it possible to make a Hullmod cost credits to install, possibly unrecoverable (Ie you pay to put it in, but don't get it back if you uninstall it)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sordid on April 12, 2020, 06:31:49 AM
How do you make the game start battles with the view zoomed out all the way? I see no reason to ever zoom in, and having to zoom out at the start of every single battle is getting a bit tiresome.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2020, 11:26:27 AM
Hello Alex, I am putting in a hullmod that should not be installed on any ship's modules so I used this method. It seems that modded ships like the Cathedral (from SWP) aren't affected by this and I'm able to attach it on the Cathedral's modules. Are there any plans to make a vanilla ship with modules, so a way to block hullmods on modules can be implemented?

Hmm - assuming it's in this release, you could I think use ship.getFleetMember() to figure out if the current ship's hull corresponds to the main body of the ship or to one of its modules.


1: Is it possible to make a Hullmod that add extra logistic slots to the ship it's installed in?

Yes:

ship.getMutableStats().getDynamic().getMod(Stats.MAX_LOGISTICS_HULLMODS_MOD).modifyFlat(...)

2: Is it possible to make a Hullmod cost credits to install, possibly unrecoverable (Ie you pay to put it in, but don't get it back if you uninstall it)

Not easily or cleanly, I don't think. It might be possible to do something where you can only install the hullmod at a station after you've paid to make it temporarily available or something, but you'd have to get creative with it (as opposed to it just cleanly working in the refit screen).

How do you make the game start battles with the view zoomed out all the way? I see no reason to ever zoom in, and having to zoom out at the start of every single battle is getting a bit tiresome.

Hmm - you could set minCombatZoom in settings.json to be the same as maxCombatZoom - it might still start at the default zoom, but would in this case - iirc? - zoom out to full after one touch of the zoom control.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sordid on April 12, 2020, 02:22:58 PM
How do you make the game start battles with the view zoomed out all the way? I see no reason to ever zoom in, and having to zoom out at the start of every single battle is getting a bit tiresome.

Hmm - you could set minCombatZoom in settings.json to be the same as maxCombatZoom - it might still start at the default zoom, but would in this case - iirc? - zoom out to full after one touch of the zoom control.

Ah, awesome! That even starts fully zoomed out. Thanks a bunch!

Also, and this might be more of a bug report, buuuut.... a pather base that was supplying cells in my colonies decivilized and became an abandoned station, but somehow it's still supplying them? So I can't get rid of them because I can't do anything with the station other than store stuff in it. Wat do? Can I, like, edit the save file to get rid of that? I can look up the names of places in the save file, but I can't make heads or tails of what to edit in there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on April 12, 2020, 02:34:09 PM
Hello Alex, I am putting in a hullmod that should not be installed on any ship's modules so I used this method. It seems that modded ships like the Cathedral (from SWP) aren't affected by this and I'm able to attach it on the Cathedral's modules. Are there any plans to make a vanilla ship with modules, so a way to block hullmods on modules can be implemented?

Hmm - assuming it's in this release, you could I think use ship.getFleetMember() to figure out if the current ship's hull corresponds to the main body of the ship or to one of its modules.
Ok that's great to hear!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 13, 2020, 02:31:38 AM
Hello, after some theorising about a possible TC with some folks that hinges around the idea of a custom hyperspace map with fog of war. This isn't possible to implement in the vanilla map, so my question is, is it currently possible to override the hyperspace map GUI element? Furthermore, how is the hyperspace map rendered in game? How is it layered, what elements can be removed, can elements be added?

If not, some API hooks to apply effects / or somehow replace the hyperspace map would be greatly appreciated.

Thanks  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2020, 10:59:47 AM
Ah, awesome! That even starts fully zoomed out. Thanks a bunch!

Yep!

Also, and this might be more of a bug report, buuuut.... a pather base that was supplying cells in my colonies decivilized and became an abandoned station, but somehow it's still supplying them? So I can't get rid of them because I can't do anything with the station other than store stuff in it. Wat do? Can I, like, edit the save file to get rid of that? I can look up the names of places in the save file, but I can't make heads or tails of what to edit in there.

Ah, it is a bug report - thank you, and fixed. I'd already done this for pirate bases (that is, making sure they can't decivilize), but missed Pather cells. The good news is Pather cells are currently bugged so that if your stability is 2 or higher, incidents will never happen, so you're basically free to ignore them - no need to remove them from the save file. Which I think could get kind of tricky anyway.


Hello, after some theorising about a possible TC with some folks that hinges around the idea of a custom hyperspace map with fog of war. This isn't possible to implement in the vanilla map, so my question is, is it currently possible to override the hyperspace map GUI element? Furthermore, how is the hyperspace map rendered in game? How is it layered, what elements can be removed, can elements be added?

If not, some API hooks to apply effects / or somehow replace the hyperspace map would be greatly appreciated.

Thanks  :)

See: HyperspaceTerrainPlugin.renderOnMap(), and renderOnMapAbove() it its superclass. Although, you're not asking just about the hyperspace terrain, are you? You couldn't hide stars, I don't think. Terrain, you could - but that's just the HyperspaceTerrainPlugin. It's hard to say because I don't understand exactly what the goal of having fog of war here would be - what would be hidden and why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sordid on April 13, 2020, 11:31:08 AM
Ah, it is a bug report - thank you, and fixed. I'd already done this for pirate bases (that is, making sure they can't decivilize), but missed Pather cells. The good news is Pather cells are currently bugged so that if your stability is 2 or higher, incidents will never happen, so you're basically free to ignore them - no need to remove them from the save file. Which I think could get kind of tricky anyway.

Your bugfix response time is very impressive, you must be very proud. ;)

I tried the console commands mod, and that let me remove the pather cells condition from my markets, but the intel screen colony threat notifications still remain. I'm basically done with this playthrough, though, so I'm just not going to worry about them.

If I may make a suggestion - it would be a lot more awesome if, instead of pather and pirate bases never decivilizing, decivilizing them destroyed them. That's why I raided that pather base a bunch of times in the first place, because I didn't have a fleet strong enough to take it on directly, so I figured I'd decivilize it and get rid of it that way. It would be neat to have that easier but not quite as quick option, you know?

In any case, thanks for the fix. Looking forward to the next version!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2020, 12:13:32 PM
Your bugfix response time is very impressive, you must be very proud. ;)

It was an easy one :)

If I may make a suggestion - it would be a lot more awesome if, instead of pather and pirate bases never decivilizing, decivilizing them destroyed them. That's why I raided that pather base a bunch of times in the first place, because I didn't have a fleet strong enough to take it on directly, so I figured I'd decivilize it and get rid of it that way. It would be neat to have that easier but not quite as quick option, you know?

Hmm - makes sense, but being able to raid repeatedly like that to cause something to decivilize is not exactly intended in the first place, and would be much more difficult in the next release, with the new raid mechanics. Still, I'll keep it in mind!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 13, 2020, 05:08:26 PM
Ah, awesome! That even starts fully zoomed out. Thanks a bunch!

Yep!

Also, and this might be more of a bug report, buuuut.... a pather base that was supplying cells in my colonies decivilized and became an abandoned station, but somehow it's still supplying them? So I can't get rid of them because I can't do anything with the station other than store stuff in it. Wat do? Can I, like, edit the save file to get rid of that? I can look up the names of places in the save file, but I can't make heads or tails of what to edit in there.

Ah, it is a bug report - thank you, and fixed. I'd already done this for pirate bases (that is, making sure they can't decivilize), but missed Pather cells. The good news is Pather cells are currently bugged so that if your stability is 2 or higher, incidents will never happen, so you're basically free to ignore them - no need to remove them from the save file. Which I think could get kind of tricky anyway.


Hello, after some theorising about a possible TC with some folks that hinges around the idea of a custom hyperspace map with fog of war. This isn't possible to implement in the vanilla map, so my question is, is it currently possible to override the hyperspace map GUI element? Furthermore, how is the hyperspace map rendered in game? How is it layered, what elements can be removed, can elements be added?

If not, some API hooks to apply effects / or somehow replace the hyperspace map would be greatly appreciated.

Thanks  :)

See: HyperspaceTerrainPlugin.renderOnMap(), and renderOnMapAbove() it its superclass. Although, you're not asking just about the hyperspace terrain, are you? You couldn't hide stars, I don't think. Terrain, you could - but that's just the HyperspaceTerrainPlugin. It's hard to say because I don't understand exactly what the goal of having fog of war here would be - what would be hidden and why?

The goal would be to hide everything, and have abstract regions on the map highlighted, with sections charted as the player travels outwards. At first this would be blind, but quests etc. could potentially give coordinates of specific locations in the murk. This would mean being able to clear absolutely everything from the map and have custom objects rendered over it, but it doesn't sound like that's possible at the moment.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2020, 05:21:27 PM
Ah - your best/only bet might be to temporarily remove the star anchor jump-points from hyperspace. Either that, or temporarily giving it a sensor profile - i.e. something like:

jumpPoint.setSensorProfile(<some number>);
jumpPoint.setDiscoverable(true);

That *might* also work as far as concealing stars.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 13, 2020, 06:37:17 PM
Ah - your best/only bet might be to temporarily remove the star anchor jump-points from hyperspace. Either that, or temporarily giving it a sensor profile - i.e. something like:

jumpPoint.setSensorProfile(<some number>);
jumpPoint.setDiscoverable(true);

That *might* also work as far as concealing stars.

That's really funky, but if it works is also genius. I'll do some fiddling and see if that works out. Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2020, 06:59:21 PM
Good luck :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 13, 2020, 10:58:58 PM
Hello, after some theorising about a possible TC with some folks that hinges around the idea of a custom hyperspace map with fog of war.

Not sure how much you intend to override, but this list may help save you some time considering you're wanting to do a TC. It's easier in my experience to just delete what you don't need rather than type everything out. This post includes most if not all vanilla files. I can't remember how much I added to this before I started working on reducing the need for the replace array in general.

Replace Array Possible Entries For Windows (https://fractalsoftworks.com/forum/index.php?topic=14684.msg239156#msg239156)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 14, 2020, 03:44:06 AM
Hello, after some theorising about a possible TC with some folks that hinges around the idea of a custom hyperspace map with fog of war.

Not sure how much you intend to override, but this list may help save you some time considering you're wanting to do a TC. It's easier in my experience to just delete what you don't need rather than type everything out. This post includes most if not all vanilla files. I can't remember how much I added to this before I started working on reducing the need for the replace array in general.

Replace Array Possible Entries For Windows (https://fractalsoftworks.com/forum/index.php?topic=14684.msg239156#msg239156)

Thanks for the post, I'm sure it'll be useful when I start diving in  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on April 15, 2020, 11:56:24 AM
I tried some personal edit in a mod by starting from someone else. I got an error message. It seems to tell me the field id is missing from a file, however how can I know which file?

I cant seem to be able to paste my log here, it always crash my post

I also have a very very weird and seemingly useless question betraying my ignorance.

Each mod_info of a mod point to a single mod plugin. Could a single mod define multiple plugin? Could a single mod have multiple mod info?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 15, 2020, 07:35:51 PM
What does MarketAPI.reapplyIndustries() do? Is it necessary when changing industries through a script or, maybe, does it read and reapply what is contained in the economy json files?

-----------------------------------------
I had someone ask about portrait overrides or otherwise adding or removing portraits, so thought this might be helpful to anyone needing info on this (Edited for a general audience):

The faction file determines what portrait png files from the graphics folder will be applied to created npcs within that faction. So, afaik all portraits are added to the campaign this way in vanilla. Its not a script but part of the JSON file that is read by the game. You should be able to add portraits to each faction's pool using scripts, though. As an example of code that modifies portraits:

Spoiler
/**
 *   By Morrokain
 *
 *  Parameters: Accepts "ALL" or a faction ID which it will use to obtain that faction's portraits.
 */
public class SetPlayerPortraits extends BaseCommandPlugin {

    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
       
        String faction = params.get(0).getString(memoryMap);

        WeightedRandomPicker<String> factionMalePortraitIDs = new WeightedRandomPicker<>();
        WeightedRandomPicker<String> factionFemalePortraitIDs = new WeightedRandomPicker<>();

        if (!faction.equalsIgnoreCase("all")) {
            factionMalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.MALE);
            factionFemalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.FEMALE);
        } else {
            List<FactionAPI> allFactions = Global.getSector().getAllFactions();
            Iterator<FactionAPI> iterator = allFactions.iterator();
            String nextFaction;

            while (iterator.hasNext()) {
                nextFaction = iterator.next().getId();

                if (!nextFaction.equalsIgnoreCase("remnant") && !nextFaction.equalsIgnoreCase("pirates")
                        && !nextFaction.equalsIgnoreCase("sleeper") && !nextFaction.equalsIgnoreCase("scavengers")
                        && !nextFaction.equalsIgnoreCase("poor") && !nextFaction.equalsIgnoreCase("derelict")
                        && !nextFaction.equalsIgnoreCase("luddic_path") && !nextFaction.equalsIgnoreCase("player")
                        && !nextFaction.equalsIgnoreCase("neutral")) {

                    factionMalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.MALE));
                    factionFemalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.FEMALE));
                }
            }
        }

        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).clear();
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).clear();
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).addAll(factionMalePortraitIDs);
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).addAll(factionFemalePortraitIDs);
        return true;
    }

}
[close]

If you are wanting to replace portraits (either overriding the vanilla portraits in a mod you are making or removing the mod portraits from being used in a mod due to subjective portrait tastes/themes, for instance) you don't have to mess with the replace array in mod_info for the portrait files but instead replace the faction files (to completely change everything- additions don't require this and can just add the portrait references in a mod faction json of the same name). For example:

Code
  	     "data\\world\\factions\\player.faction",
-In the replace array- Would override the player faction file in windows. Then change the portrait references in that faction file to reference your own portraits png names:

Code
			"graphics/portraits/portrait_hegemony01.png",
-is an example of how this is referenced in the faction file. Scroll down towards the bottom to see it.


To remove portraits, comment out the portrait line for the portrait files you don't want by adding a #

Code
			#"graphics/portraits/portrait_hegemony01.png",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 15, 2020, 07:59:40 PM
I want to iterate through every loaded mod and load a text file from each mod, but I don't know which mods have it and which don't. SettingsAPI.loadText()'s method contract implies I can handle FileNotFound exceptions, but it catches them itself and crashes the game instead. Is there any way for me to check if the file exists before I pass the path to loadText()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 15, 2020, 09:20:09 PM
I tried some personal edit in a mod by starting from someone else. I got an error message. It seems to tell me the field id is missing from a file, however how can I know which file?

I cant seem to be able to paste my log here, it always crash my post

That's due to the log containing a special character of some sort. But, yeah, need more to go on. The file is probably mentioned in one of the lines before the error, though.

Each mod_info of a mod point to a single mod plugin. Could a single mod define multiple plugin? Could a single mod have multiple mod info?

It's just one mod_info and one plugin per mod.


What does MarketAPI.reapplyIndustries() do? Is it necessary when changing industries through a script or, maybe, does it read and reapply what is contained in the economy json files?

It refreshes admin stats, and then calls unapply()/apply() on all industries in order. I don't think it's necessary in the normal course of things - this will happen during normal economy ticks, anyway. However, if you're relying on market data to be accurate vis a vis an industry change you just made, then this might be necessary. But that could get a little dodgy, anyway, as it might take an economy tick for all the impacts of an industry change to propagate.

If you make a change in response to a UI interaction, it's probably better to call Global.getSector().getEconomy().tripleStep(). You *do not* want to call this from a general script that's just running on a timer/interval/whatever, though, as it might be enough to drop a frame or two. But in response to UI interactions, it's fine.


I want to iterate through every loaded mod and load a text file from each mod, but I don't know which mods have it and which don't. SettingsAPI.loadText()'s method contract implies I can handle FileNotFound exceptions, but it catches them itself and crashes the game instead. Is there any way for me to check if the file exists before I pass the path to loadText()?

I think if you just catch RuntimeException there - instead of IOException - you should be fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 16, 2020, 12:53:26 AM
It refreshes admin stats, and then calls unapply()/apply() on all industries in order. I don't think it's necessary in the normal course of things - this will happen during normal economy ticks, anyway. However, if you're relying on market data to be accurate vis a vis an industry change you just made, then this might be necessary. But that could get a little dodgy, anyway, as it might take an economy tick for all the impacts of an industry change to propagate.

If you make a change in response to a UI interaction, it's probably better to call Global.getSector().getEconomy().tripleStep(). You *do not* want to call this from a general script that's just running on a timer/interval/whatever, though, as it might be enough to drop a frame or two. But in response to UI interactions, it's fine.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 16, 2020, 05:38:31 AM
I want to iterate through every loaded mod and load a text file from each mod, but I don't know which mods have it and which don't. SettingsAPI.loadText()'s method contract implies I can handle FileNotFound exceptions, but it catches them itself and crashes the game instead. Is there any way for me to check if the file exists before I pass the path to loadText()?

I think if you just catch RuntimeException there - instead of IOException - you should be fine.

Agh, dang, that works. Obvious in retrospect. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hydra7-1 on April 16, 2020, 01:01:11 PM
Which would be easier? adding a post combat dialogue option, or making a unique item drop for a bounty?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 16, 2020, 01:12:34 PM
The latter, I would say. I think using the fleet.addDrop* methods would work. As - I think - should using the BaseSalvageSpecial.addExtraSalvage() method. Adding a post-combat dialog option is way more complicated, and would involve overriding the combat dialog, which wouldn't play nice with other mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hydra7-1 on April 16, 2020, 04:30:45 PM
So I would have the fleet drop a unique item, which could then be turned in as a quest item that can turned in for the bounty target as an officer. That would most likely be the most mod friendly way to recruit HVB/IBB yes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 16, 2020, 06:40:21 PM
If I add a condition to a market such as:

Code
derinkyu.getMarket().addCondition(Conditions.ORE_MODERATE);

and then add the Mining Industry- during a script called during onNewGameAfterEconomyLoad()-

- the market does not actually produce the Ore commodity in the economy. Can I not do that there or am I doing something wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 16, 2020, 07:10:28 PM
Try calling MarketAPI.reapplyConditions()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 16, 2020, 07:28:26 PM
Mark the condition as surveyed.
Code: java
	MarketAPI tigraCity = getMarket("tigra_city");
tigraCity.addCondition(Conditions.ORE_MODERATE);
tigraCity.getCondition(Conditions.ORE_MODERATE).setSurveyed(true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 16, 2020, 07:34:54 PM
Try calling MarketAPI.reapplyConditions()

I tried this. No luck.

Mark the condition as surveyed.
Code: java
	MarketAPI tigraCity = getMarket("tigra_city");
tigraCity.addCondition(Conditions.ORE_MODERATE);
tigraCity.getCondition(Conditions.ORE_MODERATE).setSurveyed(true);

Didn't try this. Trying it now. Probably combined with the above advice just to be sure.

Thanks for the help both of you!

*EDIT* It works, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: pignaut on April 17, 2020, 06:34:48 AM
Hello all.
I'm having some trouble getting my mod to work/compile properly.

I've followed this tutorial ( https://fractalsoftworks.com/forum/index.php?topic=10057.0 (https://fractalsoftworks.com/forum/index.php?topic=10057.0) ), and used Sundog's Fuel Siphoning mod ( https://fractalsoftworks.com/forum/index.php?topic=15272.0 (https://fractalsoftworks.com/forum/index.php?topic=15272.0) ) as a reference.

Whenever I try and play Starsector, with my mod loaded, it crashes when the loading bar reaches its end.

I'm using intelliJ IDEA 15.0.6, my JDK is "jdk1.7.0_80".

Under File->Settings<Build, Execution, Deployment->Compiler->Java Compiler, the Project Bytecode is set to 1.7.

Under File->Project Structure->Project, the Project SDK is set to 1.7.

When attempting to make my Jar file*, I am unable to select my class as the Main Class
(Selecting it and clicking OK pops us a message saying "*class-name* is not acceptable")

To get around that, I left the Main Class field of the Create JAR from Modules window empty. From that I do get a JAR file (which contains my actual JAR file, and the Starsector api files). What I've been doing is extracting this with 7zip, then using the JAR file in that.

When I launch Starsector, I am able to see my mod in the mod-list and can enable it.

The error message that appear is:
Quote
Fatal: Error compiling
[supplies_from_planets.campaign.abilities.SuppliesFromPlanets]
cause: supplies_from_planets.campaign.abilities.SuppliesFromPlanets
Chack starsector.log for more info

And the log file has this:
Quote
4086 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [supplies_from_planets.campaign.abilities.SuppliesFromPlanets]
java.lang.RuntimeException: Error compiling [supplies_from_planets.campaign.abilities.SuppliesFromPlanets]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: supplies_from_planets.campaign.abilities.SuppliesFromPlanets
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)


I don't know what I'm doing wrong, but I'm guessing I've set up my IDE wrong? Or I've forgotten to do something? I don't know.


*File->Project Structure->Artifacts->+->Create JAR from Modules
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 17, 2020, 08:49:05 PM
Hello, a follow-up to the hyperspace system hiding:
The script
Code
    
@Override
    public void onNewGameAfterProcGen() {
        for (SectorEntityToken token : Global.getSector().getHyperspace().getAllEntities()) {
            token.setDiscoverable(true);
            token.setSensorProfile(2000f);
        }
    }
successfully hides all systems as can be seen in this screenshot.

Spoiler
(https://i.imgur.com/XlYKnvN.png)
[close]

The only problem is, when coming across a system in hyperspace, it returns null for the discovery process, and is only visible on map when the player is within sensor range, and disappears otherwise. How would I go about permanently having systems appear on map?

Spoiler
(https://i.imgur.com/VvaGIX1.png)(https://i.imgur.com/p7mcWHT.png)
[close]

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 17, 2020, 09:04:35 PM
Hmm. I suspect CoreDiscoverEntityPlugin isn't handling a JumpPointAPI being "discovered" well. Although, hm, looking at the code for that, I'm not sure why it wouldn't stay discovered - it should setDiscoverable(null) and setSensorProfile(null) in all cases.

The solution for the "Discovered: null" thing would be to provide your own implementation of this, though - basically copy CoreDiscoverEntityPlugin, register your implementation via something like:
if (!plugins.hasPlugin(YourDiscoverEntityPlugin.class)) {
   plugins.addPlugin(new YourDiscoverEntityPlugin(), true);
}

In an appropriate ModPlugin method.

And make sure its getHandlingPriority() method returns... probably GenericPluginManagerAPI.MOD_SPECIFIC, if the parameter is a hyperspace anchor.

Not sure about it not staying discovered, though, that doesn't make sense to me.

Edit: ah, it looks like only nascent jump-points (which your code is also making discoverable) are being "discovered", the jump-points aren't. Aha... hmm. Some old code in play here, I don't want to wantonly tweak it, but basically jump-points can't be discoverable like that. So I'd say the best solution would be a custom script that mimics what CoreDiscoverEntityPlugin does but just checks when the player is near-enough an undiscovered star to "discover" it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 18, 2020, 03:05:10 AM
Read and weep fellas 8) 8) 8)

Spoiler
(https://i.imgur.com/y8ZpeEu.png)
[close]

Cheers Alex, your advice works perfectly  ;D. Mod idea and TC conversion validated!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 18, 2020, 08:21:32 AM
Nice!!!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 18, 2020, 10:00:32 PM
I feel like I've missed something fundamental in the usage of the FogOfWarAPI in combat. I'm trying to reveal the area around a battle objective, and while it appears to be doing so, it isn't showing any ships or entities within that area.

The setup is based on a hullmod carried by a ship. I'll brush right over how I'm acquiring the objectives, but this is the meat of the script that should clear the fog of war (in the "advanceInCombat()" method of the hullmod):
Code
int owner = ship.getOriginalOwner();
FogOfWarAPI fog = engine.getFogOfWar(owner);
...
fog.revealAroundPoint(objective,
        objective.getLocation().getX(),
        objective.getLocation().getY(),
        REVEAL_AREA);
That bit works, it reveals the fog in a circle around the objective in question just fine. But for whatever reason, enemy ships are still invisible within that area. (The objective is being invisibly captured by the enemy despite them having to be within the revealed area.)

- I have also tried this setup where I spawn a custom projectile, with the ship in question as the source, on the point of the objective and then reveal fog around that instead, but the result was the same.
- Further, I'm 99% sure I'm using the setup correctly because I've played with a script revealing fog before, and that was also based on a projectile, however that was run through an everyFrameEffectPlugin as opposed to an advance script.

Does anyone know why the fog is lifted in the area specified, but enemy ships within it are still "hidden"? Have I missed something really fundamental?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2020, 09:40:11 AM
Hmm - I'd say to take a look at this:
com.fs.starfarer.api.impl.combat.EscapeRevealPlugin

I don't see what you might be doing wrong, though, it seems like it should work. IIRC the reveal radius needs to be >1000 for it to work? I'm not actually 100% sure, this is a very hazy memory. And you need to do it every single frame.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaykat on April 19, 2020, 01:41:49 PM
(I'm not a scripter no bully plz ._.)

I added a market condition from Unknown Skies to a planet I made, but the game crashes when it's on any planet (US_Bedrock). I tested it and this happens to any US market condition. The error is:

"US_BEDROCK" is neither a method, a field, nor a member class of "com.fs.starfarer.api.impl.campaign.ids.Conditions"

The weird thing is I have another planet with the type US_Auric and that works fine, so it's not US. So so, my lizard brain reading the error makes me think I need to somehow make my files dependent on US, but I don't know how. It doesn't make sense to me when the planet types work just fine without doing that already. Can someone way more knowledgeable than me explain what's going on here and maybe how to fix it? I am super confused about all this >_<
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2020, 01:46:51 PM
Instead of doing Conditions.US_BEDROCK, to "US_Bedrock" (with the quotes). The Conditions class has the ids of the vanilla
conditions in strings - for easier use, changes, and cross-referencing - but conditions added by mods wouldn't be found there. So you need to just specify it as a string literal, with the double quotes and so on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaykat on April 19, 2020, 01:50:40 PM
Instead of doing Conditions.US_BEDROCK, to "US_Bedrock" (with the quotes). The Conditions class has the ids of the vanilla
conditions in strings - for easier use, changes, and cross-referencing - but conditions added by mods wouldn't be found there. So you need to just specify it as a string literal, with the double quotes and so on.

Agh, it's ALWAYS simpler than I think it is! Thank you so much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2020, 01:56:01 PM
You're welcome, good luck :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 19, 2020, 04:23:37 PM
IIRC the reveal radius needs to be >1000 for it to work? I'm not actually 100% sure, this is a very hazy memory. And you need to do it every single frame.

That would have made me laugh, since I'd tried it with a bunch of different radii but the highest I'd set it to was exactly 1000. ;D Somewhat thankfully, setting it higher didn't fix the issue.

I am definitely calling the function every frame - at least I think I am. The piece of script I shared is running every iteration of the advanceInCombat() method of a hullmod script. That runs every frame, right?

As for the EscapeRevealPlugin, all I can glean differently from that is using "this" for the Object source of the revealAroundPoint() method, and that didn't seem to help either - much like when I tried it with "ship" in its place, it seems only one area of fog can be cleared by a single object, so once it has more than one objective to reveal, it starts flickering and doing odd things.

Once again though I'm thinking this might be a difference between the advanceInCombat hullmod method, and the advance method of an everyFrameEffectPlugin. It just seems odd that there's a difference so I'm naturally apprehensive of trying that instead. I'll give it a whirl as an everyFrame anyway and report back.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 19, 2020, 06:07:49 PM
Follow up to the above: Moving the fog reveal code to an everyFrameEffectPlugin worked! ;D And while I'm glad to have this working, I'm really confused as to why that worked! :o What's the fundamental difference between the advance methods here, and why should they act differently with the same code?

Nonetheless, thanks for the help.

I Spy
(https://i.imgur.com/t7r3set.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2020, 06:34:25 PM
Ah! I bet what's happening is fog of war state is reset every frame and re-calculated. And the method for doing it in the hullmod runs before it's reset, i.e. when it doesn't matter. At least, that'd be my guess. Doesn't quite explain why it *looks* like it works, though, but... well, maybe it runs after checks for ships being visible, but before rendering, or something. Point being, I strongly suspect it's due to the order of operations. In any case, glad you got it working!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 19, 2020, 07:09:51 PM
Ah! I bet what's happening is fog of war state is reset every frame and re-calculated. And the method for doing it in the hullmod runs before it's reset, i.e. when it doesn't matter. At least, that'd be my guess. Doesn't quite explain why it *looks* like it works, though, but... well, maybe it runs after checks for ships being visible, but before rendering, or something. Point being, I strongly suspect it's due to the order of operations.

Huh, that would explain the issues I was seeing. Odd, but fair enough.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xaiier on April 21, 2020, 02:27:52 AM
I found a strange issue while spawning emp arcs with the CombatEngineAPI methods spawnEmpArc(...) & spawnEmpArcPierceShields(...)

If you target a combat entity which doesn't have any valid arc targets within the maxRange distance of the source location, the arc will instead target somewhere along the circumference of a circle centered at (0,0) in the combat space. The radius of this circle doesn't appear to have any relationship to shield size or anything that I could find. It appears as though the method is using some default value when finding a target fails and causing these arcs to stretch out towards the origin.

The vanilla implementations of this kind of thing (ex: TachLance) all use arbitrarily large maxRange values which hide the issue. With such large values, finding a valid target always succeeds.

Interestingly, this doesn't hold true for the custom CombatEntityAPI classes defined in LazyLib - the arcs go to their target and ignore any restrictions defined by maxRange.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: _Dividebyzero_ on April 21, 2020, 06:59:54 PM
Is there a way to add a recoverable ship to a debris field during system creation?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 21, 2020, 08:32:41 PM
I found a strange issue while spawning emp arcs with the CombatEngineAPI methods spawnEmpArc(...) & spawnEmpArcPierceShields(...)

If you target a combat entity which doesn't have any valid arc targets within the maxRange distance of the source location, the arc will instead target somewhere along the circumference of a circle centered at (0,0) in the combat space. The radius of this circle doesn't appear to have any relationship to shield size or anything that I could find. It appears as though the method is using some default value when finding a target fails and causing these arcs to stretch out towards the origin.

The vanilla implementations of this kind of thing (ex: TachLance) all use arbitrarily large maxRange values which hide the issue. With such large values, finding a valid target always succeeds.

Interestingly, this doesn't hold true for the custom CombatEntityAPI classes defined in LazyLib - the arcs go to their target and ignore any restrictions defined by maxRange.

Hmm, alright, I'll keep this in mind. In general, I would recommend always passing in a very high value for max range, I'm not sure that's ever been used anywhere in vanilla with small values and the fact that this is a parameter at all is probably an oversight.


Is there a way to add a recoverable ship to a debris field during system creation?

Yeah - something like this:

ShipRecoverySpecialData data = new ShipRecoverySpecialData(null);
data.addShip("centurion_Assault", ShipCondition.PRISTINE);
Misc.setSalvageSpecial(debrisField, data);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: _Dividebyzero_ on April 21, 2020, 08:45:23 PM
Is there a way to add a recoverable ship to a debris field during system creation?

Yeah - something like this:

ShipRecoverySpecialData data = new ShipRecoverySpecialData(null);
data.addShip("centurion_Assault", ShipCondition.PRISTINE);
Misc.setSalvageSpecial(debrisField, data);

Will try that out, thanks a lot!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: planeswalker on April 23, 2020, 05:14:21 AM
Hey all, I have a question regarding feasibility and if it can be done can someone point me to a dummies guide to doing it.

For quite some time now I've been using the console command mod to add 20 OP to all my ships but it resets everytime I leave the game. I thought of making a hullmod that will cost 'negative OP' like I've seen some mod hullmods do. Is it also possible to restrict it to player only so AI ships cannot get it?

Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 23, 2020, 04:24:00 PM
... I thought of making a hullmod that will cost 'negative OP' like I've seen some mod hullmods do. Is it also possible to restrict it to player only so AI ships cannot get it?

Easy. Just don't put it in any default variants, and don't put it in any faction's "knownHullmods" list. By default factions only use those hullmods attached to their ship loadouts or noted in the faction file.

So... basically you have to do nothing. ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Thaago on April 23, 2020, 04:33:38 PM
Regarding hullmods and the above question, does setting Hidden to True in the csv also stop autofit from including it? I know it stops codex entry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2020, 04:42:59 PM
Indirectly - IIRC the plugin that provides autofit with which hullmods are available strips out any "hidden" ones.

"hidden" basically means "built in only, can never be installed otherwise"
"hidden" + "alwaysHidden" means "this is required for some internal functionality, do not show this to the player anywhere, including as being installed on the ship in the refit screen"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 24, 2020, 02:39:04 PM
Use case: Trying to make a market connected to the economy but with only a military market.

1) What is the specId of the black market and open market submarkets? Is the open market a submarket or the primary market itself?

2) Does this do anything bad as far as supply/demand of the economy?

Example:

Code
        SectorEntityToken fortress = system.getEntityById("gilead_station");
        fortress.getMarket().removeSubmarket("black_market");
        fortress.getMarket().removeSubmarket("open_market");
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 24, 2020, 03:05:41 PM
1) For ids, see data/campaign/submarkets.csv and the Submarkets class. The open market is a submarket like the other ones.

2) It shouldn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: planeswalker on April 24, 2020, 11:47:05 PM
... I thought of making a hullmod that will cost 'negative OP' like I've seen some mod hullmods do. Is it also possible to restrict it to player only so AI ships cannot get it?

Easy. Just don't put it in any default variants, and don't put it in any faction's "knownHullmods" list. By default factions only use those hullmods attached to their ship loadouts or noted in the faction file.

So... basically you have to do nothing. ;)

Oh right ok, lol. More importantly is there a 'dummies guide to make a custom hullmod guide' on this forum? My searches gave me a lot of tips for making new ships, weapons etc but not hullmods. Maybe my search skills are abit bad. Thanks!

Ok nvm I think I found a older post in this thread, lemme try that first.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 24, 2020, 11:57:15 PM
Does anyone know if there is a method to get a particular keypress from the player in accordance with their keybind settings? Specifically I want to be able to check if a player is pressing the "use system" key, which may not necessarily be F. Is that possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on April 28, 2020, 12:11:48 PM
What's the easiest way to iterate though all markets a faction owns starting from a market they own? marketAPI.getFaction() gives factionAPI, but there's nothing in it that actually returns a set of all markets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 28, 2020, 12:34:32 PM
Does anyone know if there is a method to get a particular keypress from the player in accordance with their keybind settings? Specifically I want to be able to check if a player is pressing the "use system" key, which may not necessarily be F. Is that possible?

No easy way - I think the best you could do is SettingsAPI.getControlStringForEnumName("SHIP_USE_SYSTEM") and then try to parse that, accounting for it possibly being mapped to something with a modifier key as well. Can't say I'd recommend it, though.

What's the easiest way to iterate though all markets a faction owns starting from a market they own? marketAPI.getFaction() gives factionAPI, but there's nothing in it that actually returns a set of all markets?

See: Global.getSector().getEconomy().getMarketsCopy()

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on April 28, 2020, 12:45:34 PM
See: Global.getSector().getEconomy().getMarketsCopy()

I don't think I quite understand. That would give me the list of ALL markets in the entire sector, right? I can iterate through all of them and check if they belong to the faction I want one by one, is that the solution? I'm mostly afraid it would be really slow to check every single market every time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 28, 2020, 01:14:41 PM
See: Global.getSector().getEconomy().getMarketsCopy()

I don't think I quite understand. That would give me the list of ALL markets in the entire sector, right? I can iterate through all of them and check if they belong to the faction I want one by one, is that the solution? I'm mostly afraid it would be really slow to check every single market every time.

Code
ArrayList<MarketAPI> playerMarketList = new ArrayList<>();
for (MarketAPI market : Global.getSector().getEconomy().getMarketsCopy()){
        if(market.isPlayerOwned()){
                playerMarketList.add(market);
        }
}
return playerMarketList;

The total market list is usually <50 markets, which makes iterating through them a non issue unless you do it every frame.
Be aware that Nexerelin "Autonomous colonies" are player faction markets, but do not count as playerOwned.


Edit - I just reread your question: to get all markets that a certain faction owns, use Misc.getFactionMarkets() - be wary of the above though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on April 28, 2020, 01:42:51 PM
Misc.getFactionMarkets()

Thank you, that's exactly what I wanted!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 28, 2020, 02:03:44 PM
(Incidentally, Misc.getFactionMarkets() also iterates through the entire market list. But, as SirHartley said, it's small enough that this isn't generally a problem.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on April 28, 2020, 10:36:49 PM
Does anyone know if there is a method to get a particular keypress from the player in accordance with their keybind settings? Specifically I want to be able to check if a player is pressing the "use system" key, which may not necessarily be F. Is that possible?

No easy way - I think the best you could do is SettingsAPI.getControlStringForEnumName("SHIP_USE_SYSTEM") and then try to parse that, accounting for it possibly being mapped to something with a modifier key as well. Can't say I'd recommend it, though.

Darn. I'd prefer something stable, so I might resort to my alternative, far less graceful script format. ;) Ah well, the price we pay for cool stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: planeswalker on May 02, 2020, 08:01:39 PM
Right, only had time to get back to starsector and mini modding but I ran into a snag.

So I started as simple as possible, I made a entry in hullmods.csv. I copied everything from the augmented engine entry into a new line, then changed the name, id and the cost. I loaded up star sector with console command mod, loaded in the new 'technology overhaul' hull mod and fitted it on a ship. This works fine as I now had a +2 burn mod that gave me hullpoints to play with (negative cost).

Now I run into a snag, I made a copy of the AugmentedEngines.java and renamed it into AugmentedEngines2.java ( I want to increase the max burn bonus to 4 without effecting the 'vanilla' engine hullmod). I changed the entry in hullmods.csv to point to this new file and I tried loading star sector. It crashed and I got this in the error log.

Spoiler
13128 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.hullmods.AugmentedEngines2]
java.lang.RuntimeException: Error compiling [data.hullmods.AugmentedEngines2]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.AugmentedEngines2'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.hullmods.AugmentedEngines2' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more
[close]
Could anyone tell me where I went wrong? I must have missed a step somewhere for adding a hull mod. Unfortunately the info I got from searching this forum only showed how to edit a pre-existing hullmod and not make a one from scratch. Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on May 02, 2020, 08:06:25 PM
Right, only had time to get back to starsector and mini modding but I ran into a snag.

So I started as simple as possible, I made a entry in hullmods.csv. I copied everything from the augmented engine entry into a new line, then changed the name, id and the cost. I loaded up star sector with console command mod, loaded in the new 'technology overhaul' hull mod and fitted it on a ship. This works fine as I now had a +2 burn mod that gave me hullpoints to play with (negative cost).

Now I run into a snag, I made a copy of the AugmentedEngines.java and renamed it into AugmentedEngines2.java ( I want to increase the max burn bonus to 4 without effecting the 'vanilla' engine hullmod). I changed the entry in hullmods.csv to point to this new file and I tried loading star sector. It crashed and I got this in the error log.

Spoiler
13128 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.hullmods.AugmentedEngines2]
java.lang.RuntimeException: Error compiling [data.hullmods.AugmentedEngines2]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.hullmods.AugmentedEngines2'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.hullmods.AugmentedEngines2' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more
[close]
Could anyone tell me where I went wrong? I must have missed a step somewhere for adding a hull mod. Unfortunately the info I got from searching this forum only showed how to edit a pre-existing hullmod and not make a one from scratch. Thanks
Did you also change line #7 of your newly-copied AugmentedEngines2.java from:

public class AugmentedEngines extends BaseLogisticsHullMod {

to

public class AugmentedEngines2 extends BaseLogisticsHullMod {

as part of your copy-pasting?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: planeswalker on May 02, 2020, 08:43:31 PM
That solved it, thanks Timediver.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 03, 2020, 04:50:49 AM
What does DO_NOT_AIM and HEATSEEKER tag does in weapon_data.csv file? How would it change that how vanilla sabot missiles work? Shoulnd't these tags be already  part of any guided missiles?

Edit:Well I quickly figure out HEATSEEKER tag is for salamanders that targeting engines. Other question still remains though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NeoLemon on May 03, 2020, 04:57:39 AM
Guys why this thread haven't sticked yet? so other people know where to ask trivial question.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 03, 2020, 07:42:06 AM
DO_NOT_AIM tells the ship that it can fire the missile without pointing it at the target first.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AxleMC131 on May 03, 2020, 10:28:09 PM
DO_NOT_AIM tells the ship that it can fire the missile without pointing it at the target first.

Take note: "DO_NOT_AIM" is sometimes joined with the "GUIDED_POOR" tag, which means the ship will try to point at the target to fire the missile, even though it doesn't have to. GUIDED_POOR in conjunction with DO_NOT_AIM denotes a missile with poor tracking over its range (or that have an otherwise very short range), such as the Sabot and Atropos.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Raeven on May 05, 2020, 11:44:26 AM
hey i wanna ask does ai fleets implement custom hullmods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 05, 2020, 12:00:04 PM
If the faction has access to them (via the .faction file), and if the ship variants used by that faction use those hullmods, then yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 05, 2020, 05:49:34 PM
If I am just trying to add a jar to a mod that also has a rules file but otherwise doesn't include anything else. What is necessary to make the mod recognizable?

I have:

-mod_info.json recognizing the jar

-empty mod plugin also defined in mod_info

-the rule command package defined in settings

Maybe I don't have the jar built correctly? Or the .idea portion has corrupted files? I figured that would be enough.

Examples:

Spoiler
{
  "id":"fleetdialogue_morro",
   "name":"Fleet Dialogue Options",
   "version":"0.4",
     "author":"Morrokain",
   "description":Adds ceasefire and commodity request options to standard fleet dialogue. Bribery can be used to increase the chances of a successful ceasefire.",
  "gameVersion":"0.9.1a",
   "modPlugin":"fleet_dialogue.plugin.FleetDialogueModPlugin",
   "jars": ["Fleet Dialogue v0.9.1a.jar"],
}



{
   # where rule commands called from rules.csv can be implemented.
   # rules from multiple packages CAN NOT share the same name   
   "ruleCommandPackages":[
          "fleet_dialogue.rulecmd"
   ],
}


(https://i.imgur.com/awhqYCP.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 05, 2020, 05:52:53 PM
It doesn't sound like you're missing anything fundamental. What's the error message? And are there any error messages on loading, or prior to the last error message?

I'd also try copying one of the vanilla rules just to make sure it's not something specific to your rule command. E.G. (iirc) if your rule command does not have a default constructor, things will break. Or if somethings goes wrong during its instantiation (i.e. say in a default value assignment to a data member), things will also break.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 05, 2020, 07:35:48 PM
It doesn't sound like you're missing anything fundamental. What's the error message? And are there any error messages on loading, or prior to the last error message?

I'd also try copying one of the vanilla rules just to make sure it's not something specific to your rule command. E.G. (iirc) if your rule command does not have a default constructor, things will break. Or if somethings goes wrong during its instantiation (i.e. say in a default value assignment to a data member), things will also break.

Ah silly me! It's apparently a problem with the mod_info.json according to the log (missed a quote in the description portion). Since nothing crashed I didn't think to look there. It's at least recognized now, if not yet functional. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 06, 2020, 06:53:04 PM
I'm trying to make a hullmod that increases the number of logistics mods that may be added to a ship by 1. I've managed to get it into Starsector, with costs appropriate to hull size, I've finagled it so that the shipyard UI doesn't mistakenly categorize it as a Logistics hullmod in one form or another.

In every respect it works, except that it does not actually increase the number of Logistics hullmods that can be applied to a ship.

Am I missing something really obvious here?

Code
public class sd_AHM_LogisticSlot extends BaseHullMod {

private static final int LOGISTICS_HULLMOD_SLOTS_BONUS = 1;

public void applyEffectsBeforeShipCreation(ShipAPI ship, MutableShipStatsAPI stats, String id) {
ship.getMutableStats().getDynamic().getMod(Stats.MAX_LOGISTICS_HULLMODS_MOD).modifyFlat(id, LOGISTICS_HULLMOD_SLOTS_BONUS);
}

public String getDescriptionParam(int index, HullSize hullsize) {
if (index == 0) return "" + LOGISTICS_HULLMOD_SLOTS_BONUS;
return null;
}

}

I'm feeling very dumb at the moment.

[edit]

Okay, so, thanks to TaxPriest, it's almost-all-working now: by changing

Code
ship.getMutableStats()
to simply
Code
stats
it is in almost all respects working.

The only thing that's left somewhat unideal is that the shipyard still shows the normal maximum number of logistics hullmods when you have the newly-enlarged number of logistics hullmods installed and mouse-over an additional one. But still!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 06, 2020, 08:02:44 PM
What happens if you install this mod, then install 3 logistics mods, and then uninstall this mod? IIRC this is only really supported as a built-in and wouldn't handle this sort of case (i.e. where removing the mod with this bonus is possible).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Raeven on May 06, 2020, 11:41:44 PM
Can you edit the hullmods in the starfarer.api.zip files directly and save it? i want to edit the numbers a bit on expanded cargo holds, fuel tank, deck crew and ground support,

if not,how to make a simple mod to edit these hullmods?  thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 07, 2020, 05:40:26 AM
What happens if you install this mod, then install 3 logistics mods, and then uninstall this mod? IIRC this is only really supported as a built-in and wouldn't handle this sort of case (i.e. where removing the mod with this bonus is possible).

If you uninstall the hullmod granting extra logistics slot, resulting in too-many-logistics-mods, the topmost (IE, the first-added) Logistics hullmod is automatically kicked off the ship. (I guess it got voted off by the others.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 07, 2020, 05:42:44 AM
Can you edit the hullmods in the starfarer.api.zip files directly and save it? i want to edit the numbers a bit on expanded cargo holds, fuel tank, deck crew and ground support,

if not,how to make a simple mod to edit these hullmods?  thanks in advance.

What you're going to need to do is make a mod that copies those files out to

Raevenmod/data/hullmods

You're going to need to copy the hull_mods.csv lines pertaining to those hull mods as well into a hull_mods.csv in that folder.

Edit the copies of the .java files in that folder, then save them. You'll also need a mod_info, and it's probably a decent practice to use the REPLACE method in mod_info, but it's not strictly necessary.

Then just drop that in your Starsector/mods folder, activate it in the launcher, and Ludd's your uncle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2020, 08:20:34 AM
If you uninstall the hullmod granting extra logistics slot, resulting in too-many-logistics-mods, the topmost (IE, the first-added) Logistics hullmod is automatically kicked off the ship. (I guess it got voted off by the others.)

Ah, ok, cool! Fixed up the number-of-logistics mod display in the tooltip, btw.

What confuses me now is this is your method signature:
public void applyEffectsBeforeShipCreation(ShipAPI ship, MutableShipStatsAPI stats, String id)

But that's not actually a method in HullModEffect. The methods there are:
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id);
void applyEffectsAfterShipCreation(ShipAPI ship, String id);

So your code as is seems like it wouldn't work at all, i.e. that method would just never get called. But it'd still compile, because the base class has (empty) implementations of the two actual methods that get called. Am I missing something? That fact that this is working for you kinda makes me wonder if what you posted and what you're actually running are the same thing...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 07, 2020, 08:53:21 AM
If you uninstall the hullmod granting extra logistics slot, resulting in too-many-logistics-mods, the topmost (IE, the first-added) Logistics hullmod is automatically kicked off the ship. (I guess it got voted off by the others.)

Ah, ok, cool! Fixed up the number-of-logistics mod display in the tooltip, btw.

What confuses me now is this is your method signature:
public void applyEffectsBeforeShipCreation(ShipAPI ship, MutableShipStatsAPI stats, String id)

But that's not actually a method in HullModEffect. The methods there are:
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id);
void applyEffectsAfterShipCreation(ShipAPI ship, String id);

So your code as is seems like it wouldn't work at all, i.e. that method would just never get called. But it'd still compile, because the base class has (empty) implementations of the two actual methods that get called. Am I missing something? That fact that this is working for you kinda makes me wonder if what you posted and what you're actually running are the same thing...

Ack! I skipped a step in my edit, yes. >_< That had been confusing the hell out of me. This is what I've currently got going:

Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.hullmods.BaseLogisticsHullMod; // Let me see if this fixes it...
import com.fs.starfarer.api.impl.campaign.ids.Stats; //Needed this to grab MAX_LOGISTICS_HULLMODS_MOD

import com.fs.starfarer.api.combat.ShipAPI; // Needed for vanilla incompatibility catch - I think.
// import data.scripts.util.MagicIncompatibleHullmods; //Needed for handling incompatibilities with hullmods not in my mod.
import com.fs.starfarer.api.Global; // Needed to grab the alert sound to play.

public class sd_AHM_LogisticSlot extends BaseHullMod {

private static final int LOGISTICS_HULLMOD_SLOTS_BONUS = 1;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.MAX_LOGISTICS_HULLMODS_MOD).modifyFlat(id, LOGISTICS_HULLMOD_SLOTS_BONUS);
}

public String getDescriptionParam(int index, HullSize hullsize) {
if (index == 0) return "" + LOGISTICS_HULLMOD_SLOTS_BONUS;
return null;
}

}

And here, it is working as-expected:

At maximum hullmods (https://imgur.com/fYoDjIm) it won't let me add more, by giving me the tooltip (in this case, I had set the maximum Logistics hullmods to 3 in settings previously).

Adding the Logistics Slot increaser (https://imgur.com/RFugTuE) allows me to add another Logistics hullmod again...

Having done so, (https://imgur.com/mhlTgwO) it now correctly prohibits me from adding another logistics hullmod, though the tooltip does not accurately reflect that my new Logistics hullmod cap is 4 rather than three.

Lastly, removing the Logistics Slot Increaser (https://imgur.com/7NvtXBc) does not give me back its OP and let me keep a freebie logistics mod; it kicks the topmost logistic mod off the ship.

Now I just need to troubleshoot why, if I'm at the logistics mod cap, my clone-alternates of Augmented Drive Field are still showing as permissible in the shipyard UI, and, if taken, will kick off the topmost Logistics hullmod.

They both have the Logistics tag in the hull_mods.csv and they both extend BaseLogisticsHullMod...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2020, 09:19:47 AM
Ok, nice. This seems all good, then. (Edit: aside from the max shown in the tooltip thing, which, right, I've just changed on my end.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on May 07, 2020, 09:48:38 AM
I've been curious about this one, how does accuracy actually work?

I Know it's made up of Min Spread, Max Spread, spread/shot and spread decay/sec, but the mechanics explained by a wiki I read don't seem to add up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2020, 09:51:23 AM
You mean here?
https://starsector.fandom.com/wiki/Weapon_data.csv

That seems accurate to me; what's not adding up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 07, 2020, 10:55:11 AM
Ok, nice. This seems all good, then. (Edit: aside from the max shown in the tooltip thing, which, right, I've just changed on my end.)

Huzzah! Though it might be nice if there was some kind of pop-up handler for "X was removed and here is why," or at least an alert "something you did caused a hullmod that you didn't uninstall to be removed, and the game doesn't know what it was."
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on May 07, 2020, 01:43:05 PM
I'm trying to add an option in my mod settings file to hide/disable a custom ship in my mod. I tried modifying the hints and tags on the ShipHullSpecAPI, but that doesn't seem to do anything. It is possible to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on May 07, 2020, 02:34:53 PM
You mean here?
https://starsector.fandom.com/wiki/Weapon_data.csv

That seems accurate to me; what's not adding up?

Yes from there, perhaps it's just the way my brain compiles it all together but here's how it looks to me.

1. Min Spread is the minimum amount of spread in degrees that a shot can deviate.
2. Max Spread is the maximum amount of spread in degrees that a shot can deviate.
3. Spread/shot is the number of extra degrees added to Min Spread each shot. This value can accumulate up to the Max Spread then increase no further.
4. A weapon will fire with degrees of deviation equal to Min Spread + Accumulated Spread/Shot
5. When the weapon is not firing spread decay/sec will subtract it's value from the Accumulated Spread/Shot value until it hits zero or the weapon resumes firing.

From my perspective of not firing this would mean that a weapon like the Arbelest Autocannon despite it's accuracy rating to actually have perfect aim in the hands of the AI since it has a chargedown of 1 second which would be more then enough to clear it's accumulated Spread/shot. [My perspective of actively firing is when there's actually stuff coming out of the barrel]

I know this can't be true since I've seen the AI fire the weapon and seen shots deviate.

I suppose as a follow-up question to help answer my previous one does chargedown count as part of the firing cycle for purpose of spread decay/sec? As in does spread decay/sec not kick in until after charagedown is cleared?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2020, 02:47:01 PM
I'm trying to add an option in my mod settings file to hide/disable a custom ship in my mod. I tried modifying the hints and tags on the ShipHullSpecAPI, but that doesn't seem to do anything. It is possible to do this?

Have you added the HIDE_IN_CODEX hint for it in ship_data.csv? Depends on what you mean by hide/disable, though, I'm not sure exactly what that means to you.

I suppose as a follow-up question to help answer my previous one does chargedown count as part of the firing cycle for purpose of spread decay/sec? As in does spread decay/sec not kick in until after charagedown is cleared?

Ah, gotcha. Yeah, this is correct - another way to think of it is spread reduces only when the weapon could fire, but isn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on May 07, 2020, 02:55:26 PM
Quote
Ah, gotcha. Yeah, this is correct - another way to think of it is spread reduces only when the weapon could fire, but isn't.

Thanks for that, makes it alot clearer. Kinda of wish the wiki had stated that. Intuitively (at least for me) it's easy to think of something not firing the moment shells/bullets stop coming out of the barrel.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 07, 2020, 03:36:45 PM
Alex, you're amazing. I have another fiddly problem, though:

How does

Code
CORONA_EFFECT_MULT

really work?

Because I changed it as such in my Sundiving mod, yonks and yonks ago;

Code
public static final float CORONA_EFFECT_REDUCTION = 0.0f;
...
stats.getDynamic().getStat(Stats.CORONA_EFFECT_MULT).modifyMult(id, CORONA_EFFECT_REDUCTION);

Then there's this, in StarCoronaTerrainPlugin.java:

Code
float resistance = member.getStats().getDynamic().getValue(Stats.CORONA_EFFECT_MULT);

With a 0 in CORONA_EFFECT_MULT from the Solar Shielding mod when installed, that means that

Code
float adjustedLossMult = (0f + params.crLossMult * intensity * resistance * lossMult * CR_LOSS_MULT_GLOBAL);

should have a 0 for resistance, thus yielding an adjustedLossMult of 0.

And yet, as observed by myself and others, when venturing into a sun even with every ship possessing Solar Shielding, supplies evaporate.

I'm trying to figure out why this is happening and how to fix it.

I think it has to do with this, from StarCoronaTerrainPlugin:
Code
float loss = (-1f * recoveryRate + -1f * lossRate * adjustedLossMult) * days * 0.01f;
Is that correct?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2020, 03:57:32 PM
Yeah basically what CORONA_EFFECT_MULT == 0 does is prevent the ship from losing CR while in corona, but not because it's not losing it - rather, because the repair rate matches the loss rate. I've got a TODO item to look at it at some point, since, yeah, the way this works right now makes Solar Shielding rather less good than what it looks like at first glance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 07, 2020, 04:14:28 PM
Yeah basically what CORONA_EFFECT_MULT == 0 does is prevent the ship from losing CR while in corona, but not because it's not losing it - rather, because the repair rate matches the loss rate. I've got a TODO item to look at it at some point, since, yeah, the way this works right now makes Solar Shielding rather less good than what it looks like at first glance.

Oooof. So setting CORONA_EFFECT_MULT to 0 actually makes supplies evaporate worse because instead of taking more damage than can be repaired at once, it's losing and fully repairing at every tick, and every tick consumes 1u of supply? At least, that's my current hypothesis?

I'm trying to figure out a way to fix that in the hullmod as-is, but... That looks as if it may not be possible without replacing StarCoronaTerrainPlugin?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2020, 04:31:11 PM
No, it's still better. Without it you'd lose supplies at the same rate and *also* lose additional CR you'd need to repair later after getting out of the corona.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 07, 2020, 04:39:04 PM
Okay, yeah, having tested it further, with values of 0.1, 0.05 (same as BladeBreaker Engineering) and my own 0, supplies still just absolutely evaporate... The weird thing is, with it at 0, supplies/day doesn't actually visually change, but with a 0.1 and 0.05 my fleet jumps from 7.8/day to 100+.

Why are supplies evaporating so fast, I'm trying to work out. And I'm also trying to work out if it's possible to do anything with a mod that won't break when and if you update StarCoronaTerrainPlugin.

Well, heck. I dunno. But thank you anyway, and thank you for actively engaging with us.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2020, 05:07:24 PM
My guess is because the CR loss and recovery happens in the same frame, and the fleet is never in the "CR below maximum, so supply recovery is higher than baseline" state at the point when the UI calculates the supply use rate. So setting it to 0 kind of breaks the UI.

Edit: so, right, if you set the value to 0.01 or some such, it should show you accurate supply use numbers. Note that this number *will not change* if you set it to, say, 0.5. The number is the daily use rate, and setting the mult to a higher value ultimately means it'll take more days to repair the CR damage, but the supply use rate will remain constant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on May 08, 2020, 06:06:17 AM
I'm trying to add an option in my mod settings file to hide/disable a custom ship in my mod. I tried modifying the hints and tags on the ShipHullSpecAPI, but that doesn't seem to do anything. It is possible to do this?

Have you added the HIDE_IN_CODEX hint for it in ship_data.csv? Depends on what you mean by hide/disable, though, I'm not sure exactly what that means to you.

HIDE_IN_CODEX works if I put it in the ship_data.csv, but if I use the below code to try to reveal the ship in the codex in-game, it doesn't appear in the codex. Essentially I want the player to be able to toggle whether the ship appears in the codex, is available to build, and shows up in markets. Essentially, if they don't enable the ship in the settings file, the player should never encounter it or find out it exists unless they use the console to spawn one.

Thanks for your help!

Code
        if(Global.getSettings().getBoolean("boggledRequireConstructionRig"))
        {
            Global.getSettings().getHullSpec("boggled_construction_rig").getTags().clear();
            Global.getSettings().getHullSpec("boggled_construction_rig").getTags().add("base_bp");
            Global.getSettings().getHullSpec("boggled_construction_rig").getHints().clear();
            Global.getSettings().getHullSpec("boggled_construction_rig").getHints().add(ShipHullSpecAPI.ShipTypeHints.CIVILIAN);
        }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 08, 2020, 08:14:17 AM
Fallback option: minimod with only that ship. Code it to throw an error if the main mod isn't enabled.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2020, 08:42:00 AM
Hmm, I'm not sure that's doable. IIRC currently the Codex data is only built once at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on May 08, 2020, 10:04:17 AM
Hmm, I'm not sure that's doable. IIRC currently the Codex data is only built once at some point.

Ok. Thanks for the information!

Hmm, I'm not sure that's doable. IIRC currently the Codex data is only built once at some point.

I suppose this would solve the problem, although I don't want to hassle the player to download a second mod just for a single utility ship. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on May 09, 2020, 05:12:18 AM
I'm trying to change the icon placement of a submarket in the planetary menu, but it does not change position regardless of the order entered in submarkets.csv

Is this determined by something else?
(https://i.imgur.com/ihdG7Km.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 09, 2020, 09:04:48 AM
Ah - "Storage" is hardcoded to be last, sorry! The order column should, iirc, let you position it on the rightmost side of the left group, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 09, 2020, 10:12:20 AM
There are 3 colors you can specify for a faction: Color, baseuicolor and darkuicolor. How are they calculated if no value is given for them?. Baseuicolor seems to default to color, but darkuicolor seems noticably well, darker. I mean it make sense, since baseuicolor is text on top of darkuicolor. But If I wanted to preview the color effect whitout loading the game, what should i do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 09, 2020, 12:25:30 PM
The dark UI color is:
Misc.setAlpha(Misc.scaleColorOnly(color, 0.4f), 175)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 09, 2020, 12:40:13 PM
so you set the alpha to 175  on a scaled color from the base? How does scaleColorOnly work? (And what the difference with scaleColor)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on May 09, 2020, 01:10:48 PM
Ah - "Storage" is hardcoded to be last, sorry! The order column should, iirc, let you position it on the rightmost side of the left group, though.

Yep, positioning on the left group works - good enough for me, thank you.
Another question regarding this, I'd like to change the overlay/rim colour on that button - is this possible? I didn't find anything in BaseSubmarketPlugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 09, 2020, 01:35:46 PM
so you set the alpha to 175  on a scaled color from the base? How does scaleColorOnly work? (And what the difference with scaleColor)

scaleColorOnly doesn't touch the alpha component. In this case it wouldn't matter since setAlpha overwrites it to 175 regardless, but it'd matter if a subsequent call scaled the alpha. (You can see the implementations of those methods in Misc...)

Another question regarding this, I'd like to change the overlay/rim colour on that button - is this possible? I didn't find anything in BaseSubmarketPlugin.

IIRC that's just based on the "faction" of the submarket.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on May 09, 2020, 02:17:14 PM
Yep that did it, thanks for the help!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 09, 2020, 07:17:58 PM
scaleColorOnly doesn't touch the alpha component. In this case it wouldn't matter since setAlpha overwrites it to 175 regardless, but it'd matter if a subsequent call scaled the alpha. (You can see the implementations of those methods in Misc...)

Im sorry for being probably quite ignorant. But how do I see the implementation? I found the API, but that only gives the signature of the method. Is there source code somewhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 09, 2020, 09:39:44 PM
starfarer.api.zip in the starsector-core/ folder! I'd unzip it and tell your IDE it's a source folder so you can navigate to it more easily.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 10, 2020, 01:38:47 AM
I tried to add some fluff (and other things) to the Hybrasil system.

Most of what I added worked, but all of the planets that didn't previously have a custom description don't have, even though I thought I had done it correctly;

For example, in the Java generating Elada, I added this line:


Code
hybrasil2.setCustomDescriptionId("planet_elada");
hybrasil2.applySpecChanges();

Just above the applySpecChanges(), the way it can be seen in the one for Culann:

Code
hybrasil1.setCustomDescriptionId("planet_culann");
hybrasil1.applySpecChanges();

I copied all the vanilla description strngs pertaining to Culann to a descriptions.csv, edited the ones I felt wee too short, and added the ones I thought I need to make; for instance, there's planet_elada,CUSTOM,blahblahblah...

Yet, it is not working.


Also in the process of doing this, the pirates of Donn picked up an Orbital Works and a corrupted nanoforge, yet they do not seem to be counting as a military planet, nor is their orbital battlestation showing up the way that an orbital I added over Cethlenn does. But they have it, I can see that in the colony info.

What might be going wrong here? I'm stumped.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on May 10, 2020, 06:10:18 AM
Okay, so I got a very general question - I'd like to use the officer selector to allow the player to choose an officer for something (other than as ship captain) - essentially, the Administrator selection panel for officers, returning the chosen person when selected and confirmed.

Is that panel available to us codewise? Looking through rules, it doesn't seem to be there so it's probably obf, but hope dies last :)
Edit - VisualPanelAPI doesn't seem to be it as well...

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 10, 2020, 08:35:31 AM
I tried to add some fluff (and other things) to the Hybrasil system.

Maybe obvious, but to make sure: you're creating a new game to test these changes, right? This code only runs once when a new campaign is created, so changing it would have zero effect on an existing savefile.

Nothing jumps out as being obviously wrong.


Okay, so I got a very general question - I'd like to use the officer selector to allow the player to choose an officer for something (other than as ship captain) - essentially, the Administrator selection panel for officers, returning the chosen person when selected and confirmed.

Is that panel available to us codewise? Looking through rules, it doesn't seem to be there so it's probably obf, but hope dies last :)
Edit - VisualPanelAPI doesn't seem to be it as well...

There's no generic version of that for picking a person, no - sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowDragon8685 on May 10, 2020, 10:34:18 AM
I tried to add some fluff (and other things) to the Hybrasil system.

Maybe obvious, but to make sure: you're creating a new game to test these changes, right? This code only runs once when a new campaign is created, so changing it would have zero effect on an existing savefile.

Nothing jumps out as being obviously wrong.

It turns out I'm a dumdum, and forgot to check that other mods (in this case Nex) also edit Hybrasil.java, and I need to go back and have a bit of a rethink. Thank you though!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ByteHammer on May 10, 2020, 04:21:36 PM
Somewhat related questions. The first is a general question, and the last two are related modding questions:

Is it possible to change the skin of a ship in-game to another existing skin? For example, some ships have a variant with a separate paintjob. Is there a way to apply that? Autofit doesn't seem to do so.

Would it be possible to implement custom paintjobs for ships in this way? Let's say I want to take a few ships from different factions, make a new paintjob for these ships, and add them to the game. Is there a way to apply the paintjob to a ship, say by changing the variant of the ship, without applying it to all ships of the same type in the game?

If not, would I have to do something like Tiandong Refitting to achieve these results?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Unnamed_Shadow on May 11, 2020, 12:27:43 AM
So im editing the ship_data cvs file.

I know adding the tag rare_bp will make that specific ship drop as a rare blueprint drop.

But the question comes about the rarity line.

How does this work? I know it is from 0 to 1.

But i also notice that some of the vanilla rare_bp tagged blueprints don't have any number in rarity.

is the 0 to 1 number to make them even rarer drops also how does it work? Is 0 super rare or 1 super rare?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 11, 2020, 08:40:14 AM
It turns out I'm a dumdum, and forgot to check that other mods (in this case Nex) also edit Hybrasil.java, and I need to go back and have a bit of a rethink. Thank you though!

Ah, makes sense!

Somewhat related questions. The first is a general question, and the last two are related modding questions:

Is it possible to change the skin of a ship in-game to another existing skin? For example, some ships have a variant with a separate paintjob. Is there a way to apply that? Autofit doesn't seem to do so.

There isn't, as far as the game is concerned, these are (for most purposes) treated as separate hull types. They can be flagged to share goal autofit variants, though, and a few related things.

Would it be possible to implement custom paintjobs for ships in this way? Let's say I want to take a few ships from different factions, make a new paintjob for these ships, and add them to the game. Is there a way to apply the paintjob to a ship, say by changing the variant of the ship, without applying it to all ships of the same type in the game?

If not, would I have to do something like Tiandong Refitting to achieve these results?

Your best bet, I think, is how the vanilla game does it - adding .skin files for these paintjobs, which is basically shorthand for creating another hull based on an existing one. See the files in data/hulls/skins/ for some examples.


So im editing the ship_data cvs file.

I know adding the tag rare_bp will make that specific ship drop as a rare blueprint drop.

But the question comes about the rarity line.

How does this work? I know it is from 0 to 1.

But i also notice that some of the vanilla rare_bp tagged blueprints don't have any number in rarity.

is the 0 to 1 number to make them even rarer drops also how does it work? Is 0 super rare or 1 super rare?

Yeah, "rarity" is a bad name for it, it should be "frequency", since 0 is more rare (well, nonexistent), and 1 is default. Whenever the game rolls drops, the rarity column (where present) will be a multiplier for the chance of getting that specific ship/weapon/etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 11, 2020, 09:33:36 AM
How can we lower or remove hammer barrages missile spread?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on May 11, 2020, 05:14:22 PM
I'm looking for a way to override the AI's target choice. 
My scenario is I've got a special ship system AI that while active and when certain criteria are met I'd like to force the ship system's owner to care about a different target.  I've tried calling ShipAPI.setShipTarget(), but the next frame the AI has chosen the old target to be the target again.  Is there any simple way to say "No, I really mean it, care about this target"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 11, 2020, 06:04:37 PM
How can we lower or remove hammer barrages missile spread?

You can change that in hammerrack.wpn; see hardpointAngleOffsets and hardpointAngleOffsets.

I'm looking for a way to override the AI's target choice. 
My scenario is I've got a special ship system AI that while active and when certain criteria are met I'd like to force the ship system's owner to care about a different target.  I've tried calling ShipAPI.setShipTarget(), but the next frame the AI has chosen the old target to be the target again.  Is there any simple way to say "No, I really mean it, care about this target"?

Depending on what you mean by "cares about" - probably not. That is, if you mean "make the AI prioritize this target", about the only thing I can think of is creating an eliminate order and assigning that ship to it, but it'd be visible to the player.

(setShipTarget() is equivalent to the R key for the player, btw, so it wouldn't do anything like this.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on May 11, 2020, 07:34:17 PM
I'm looking for a way to override the AI's target choice. 
My scenario is I've got a special ship system AI that while active and when certain criteria are met I'd like to force the ship system's owner to care about a different target.  I've tried calling ShipAPI.setShipTarget(), but the next frame the AI has chosen the old target to be the target again.  Is there any simple way to say "No, I really mean it, care about this target"?

Depending on what you mean by "cares about" - probably not. That is, if you mean "make the AI prioritize this target", about the only thing I can think of is creating an eliminate order and assigning that ship to it, but it'd be visible to the player.

(setShipTarget() is equivalent to the R key for the player, btw, so it wouldn't do anything like this.)

Ahhh, OK.  Thanks for the tip!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ByteHammer on May 11, 2020, 08:04:01 PM
Somewhat related questions. The first is a general question, and the last two are related modding questions:

Is it possible to change the skin of a ship in-game to another existing skin? For example, some ships have a variant with a separate paintjob. Is there a way to apply that? Autofit doesn't seem to do so.

There isn't, as far as the game is concerned, these are (for most purposes) treated as separate hull types. They can be flagged to share goal autofit variants, though, and a few related things.

Would it be possible to implement custom paintjobs for ships in this way? Let's say I want to take a few ships from different factions, make a new paintjob for these ships, and add them to the game. Is there a way to apply the paintjob to a ship, say by changing the variant of the ship, without applying it to all ships of the same type in the game?

If not, would I have to do something like Tiandong Refitting to achieve these results?

Your best bet, I think, is how the vanilla game does it - adding .skin files for these paintjobs, which is basically shorthand for creating another hull based on an existing one. See the files in data/hulls/skins/ for some examples.

Thanks for the reply.

It sounds like I'd also need to create a mod to convert an original hull to a another hull, then, yeah? I think the only other mod I know of that accomplishes this is Tiandong. Otherwise, I guess I could just use the console mod to add the variant hull and delete the original hull.

It's kind of overkill, but what I'm going for here is the ability to convert captured/purchased original ships into a "player empire" variant, where I can unify the materials and aesthetics of some of my favorite ships and have a fleet that not only works well together, but looks like it belongs together.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 11, 2020, 08:39:28 PM
Yeah, I get what you're going for! I'd say the most practical way is to create these skins and do the "exchange" using the console. And you could give yourself the blueprint for those via the console as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on May 12, 2020, 06:04:26 AM
If I create a custom RouteFleetSpawner that creates player-friendly fleets in a system (similar to Lion's Guard), will they count towards autorepelling expeditions/raids when the player isn't at home?

Is it governed by
Code
fleet.getMemoryWithoutUpdate().set("$isPatrol", true)
as I think it is?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2020, 09:40:03 AM
This is governed by the RouteData having an OptionalFleetData specified, and the "strength" field of the latter being set.

See MilitaryBase, line 406 for an example of this:
Code: java
OptionalFleetData extra = new OptionalFleetData(market);
extra.fleetType = type.getFleetType();

RouteData route = RouteManager.getInstance().addRoute(sid, market, Misc.genRandomSeed(), extra, this, custom);
extra.strength = (float) getPatrolCombatFP(type, route.getRandom());
extra.strength = Misc.getAdjustedStrength(extra.strength, market);

Also see WarSimScript.getFactionStrength() for how it's calculated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on May 12, 2020, 10:54:41 AM
This is governed by the RouteData having an OptionalFleetData specified, and the "strength" field of the latter being set.

See MilitaryBase, line 406 for an example of this:
Code: java
OptionalFleetData extra = new OptionalFleetData(market);
extra.fleetType = type.getFleetType();

RouteData route = RouteManager.getInstance().addRoute(sid, market, Misc.genRandomSeed(), extra, this, custom);
extra.strength = (float) getPatrolCombatFP(type, route.getRandom());
extra.strength = Misc.getAdjustedStrength(extra.strength, market);

Also see WarSimScript.getFactionStrength() for how it's calculated.

Thank you, that explains it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on May 14, 2020, 04:45:52 AM
Have an... efficiency or safety question? Inexperienced so apologies in advance.

Currently I am managing the presence of two NPC's on a player planet comms directory with a rule that falls under the 'FireAll PopulateAll' trigger, set to fire on a player faction market only.  So, you interact with one of your own planets, and this rule triggers a script that may execute 10-20 lines of code, depending on conditions - in this case presence of specific industries.

I used Rules for this on the assumption that it would be impossible for it to interfere with other mods or features; the 'FireAll PopulateAll' trigger means that I can implement my mod without changing any vanilla rules and have anything notable happen through command scripts.

Do I have the wrong implementation of this, or am I worrying over nothing?  I know that the AsteroidInteraction example mod implements InteractionDialogPlugin for instance, and I could conceivably do all this through that.

Will state for the record that I do not know how the game decides who shows up on comms.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 14, 2020, 12:21:57 PM
the following file are always replaced:
Sound files (e.g, .ogg, .wav)
Graphics (.png, .jpg)
Scripts (.java)
Weapon and projectile specifications (.wpn, .proj)
Ship hull and variant specifications (.ship, .variant)
Fonts (.fnt)

if I name them in my mod_info replace file, does it does something if multiple mod try to replace them, or is it just useless?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 14, 2020, 12:30:01 PM
Have an... efficiency or safety question? Inexperienced so apologies in advance.

Currently I am managing the presence of two NPC's on a player planet comms directory with a rule that falls under the 'FireAll PopulateAll' trigger, set to fire on a player faction market only.  So, you interact with one of your own planets, and this rule triggers a script that may execute 10-20 lines of code, depending on conditions - in this case presence of specific industries.

I used Rules for this on the assumption that it would be impossible for it to interfere with other mods or features; the 'FireAll PopulateAll' trigger means that I can implement my mod without changing any vanilla rules and have anything notable happen through command scripts.

Do I have the wrong implementation of this, or am I worrying over nothing?  I know that the AsteroidInteraction example mod implements InteractionDialogPlugin for instance, and I could conceivably do all this through that.

Will state for the record that I do not know how the game decides who shows up on comms.

Hmm - this seems reasonable, I think? I'm assuming you're doing this in a rule triggered by OpenInteractionDialog, with a high "score:" in one of the conditions,  and then re-firing "FireBest OpenInteractionDialog" (after setting a flag so *this* rule doesn't fire again) so that whatever normally fires can take over and, e.g. show the standard colony interaction dialog? I'm doing quite a bit of reading between the lines here :)


the following file are always replaced:
Sound files (e.g, .ogg, .wav)
Graphics (.png, .jpg)
Scripts (.java)
Weapon and projectile specifications (.wpn, .proj)
Ship hull and variant specifications (.ship, .variant)
Fonts (.fnt)

if I name them in my mod_info replace file, does it does something if multiple mod try to replace them, or is it just useless?

If multiple mods provide these files, they're considered incompatible and there's nothing in places to try to resolve these kinds of conflicts. The "replace" section doesn't come into play, since these files always replace anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on May 14, 2020, 01:36:35 PM
Spoiler
Have an... efficiency or safety question? Inexperienced so apologies in advance.

Currently I am managing the presence of two NPC's on a player planet comms directory with a rule that falls under the 'FireAll PopulateAll' trigger, set to fire on a player faction market only.  So, you interact with one of your own planets, and this rule triggers a script that may execute 10-20 lines of code, depending on conditions - in this case presence of specific industries.

I used Rules for this on the assumption that it would be impossible for it to interfere with other mods or features; the 'FireAll PopulateAll' trigger means that I can implement my mod without changing any vanilla rules and have anything notable happen through command scripts.

Do I have the wrong implementation of this, or am I worrying over nothing?  I know that the AsteroidInteraction example mod implements InteractionDialogPlugin for instance, and I could conceivably do all this through that.

Will state for the record that I do not know how the game decides who shows up on comms.
[close]

Hmm - this seems reasonable, I think? I'm assuming you're doing this in a rule triggered by OpenInteractionDialog, with a high "score:" in one of the conditions,  and then re-firing "FireBest OpenInteractionDialog" (after setting a flag so *this* rule doesn't fire again) so that whatever normally fires can take over and, e.g. show the standard colony interaction dialog? I'm doing quite a bit of reading between the lines here :)


Messed up my explanation slightly - and what I have done is probably only working by chance, based on what you've said.

My rule just has the 'PopulateOptions' trigger, which is shared with a bunch of interaction rules, and called by FireAll in a large number of others, including anything related to markets.

Conditions are simply '$hasMarket' and '$faction.id == player', with a script, and no weighting or anything else.  End result is it executes the script on a player market and then the rest continues as normal afterwards with no input from me.

EDIT:  Ah, without '$menuState == main' its gonna be firing more often than I want
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 14, 2020, 02:45:35 PM
Ah - that still sounds reasonable, yeah. I'd add something like:

conditions: !$didThing
script: $didThing = true 0

As a failsafe to ensure that your rule doesn't run more than once per interaction with the market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 15, 2020, 04:53:12 AM
How can we lower or remove hammer barrages missile spread?

You can change that in hammerrack.wpn; see hardpointAngleOffsets and hardpointAngleOffsets.

You wrote hardpointAngleOffsets twice, what is the second value that I need to change? Thanks for your interest.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on May 15, 2020, 06:41:38 AM
Ah - that still sounds reasonable, yeah. I'd add something like:

conditions: !$didThing
script: $didThing = true 0

As a failsafe to ensure that your rule doesn't run more than once per interaction with the market.

Works like a charm! Thanks for taking the time, Alex.

Here's the final rule for clarity, if anyone is interested:

Spoiler
Runs 'CBCC_CommPersonCheck' command script when you interact with a player owned market, will not repeat until you leave and the 0-day boolean expires.

idtriggerconditionsscripttext
CBCC_pop_contact    PopulateOptions    $hasMarket
$menuState == main   
$faction.id == player
!$charcheck
CBCC_CommPersonCheck   
$charcheck = true 0
Executing Custom Script now

see https://starsector.fandom.com/wiki/Rules.csv_Tutorial to set up your scripts to be used correctly by Rules.csv
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 15, 2020, 07:20:15 AM
How can we lower or remove hammer barrages missile spread?

You can change that in hammerrack.wpn; see hardpointAngleOffsets and hardpointAngleOffsets.

You wrote hardpointAngleOffsets twice, what is the second value that I need to change? Thanks for your interest.

turretAngleOffsets
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 15, 2020, 09:10:18 AM
Works like a charm! Thanks for taking the time, Alex.

Here's the final rule for clarity, if anyone is interested:

Nice! One final thing I'd suggest, renaming $charcheck to something like $CBCC_charcheck, juuust to make any potential conflicts with other mods less likely. The same kind of idea when adding mod-specific (and hopefully mod-unique) prefixes to ship id's, weapon id's, rule id's, and so on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 18, 2020, 07:26:47 AM
How to increase colony industry limit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mondaymonkey on May 18, 2020, 07:35:42 AM
How to increase colony industry limit?

You can adjust maximum industries per each market size by changing the settings line:

"maxIndustries":[1,1,1,2,3,3,4,4,4,4],

You can not change 12 buildings total cap. Anyhow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 19, 2020, 12:53:22 PM
Both  hound_overdriven.variant and variants/hound_d_pirates_overdriven.variant from starsector_core have the same variant id: hound_d_pirates_Overdriven

when a faction try to spawn this variant because it has the proper hull, what happens?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2020, 01:12:03 PM
I think the one in the hound/ folder will get used, but I'm not sure. This is (of course) an oversight. I guess you could change one of them and see which one gets picked up if you need to be sure :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 19, 2020, 01:51:07 PM
in the same kind of question. Both module_bastion_pd1.ship And module_bastion_pd1_lowtech.ship got the same hullId: module_bastion_pd1.

However, they link to different sprites, is there really one sprite we never see, or is there some mechanism to separate hull with same id?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2020, 02:32:59 PM
One's probably (very likely, actually, almost certainly) an older/unused version, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on May 19, 2020, 07:13:24 PM
question

i have noticed that weapons with very low turn rate value (3 or less) when placed on a hardpoint become unable to actively turn at all. they do keep constant facing direction if the mount arc allows it, i.e. they will keep facing the same direction when the host ship is turning, as long as that direction is within the mount's arc.

so

is there a way i can mitigate this problem in a specific slot using scripts?
can i somehow force set turnrate value of any weapon mounted in this specific slot to some fixed value or add flat bonus(not multiplier) to a turn rate value ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 19, 2020, 08:29:12 PM
Gauss has turn rate 3 and does turn when in a hardpoint. You can easily check this on a Dominator.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on May 19, 2020, 08:53:46 PM
Gauss has turn rate 3 and does turn when in a hardpoint. You can easily check this on a Dominator.
2 or less then, my mistake
Spoiler
(https://i.imgur.com/uB9UZKh.gif)
[close]
the weapon in gif has turnrate of exactly 2
upon closer look i see that it does in fact try to follow mouse, but can actually do that only when ship is turning opposite direction
inertia-assisted aiming?

upd
upon closer look i can see that it does in fact turn - almost imperceptibly slow, but it does turn.
so, my question stands - how can i buff turnrate of a hardpoint mounted weapon by a flat value or force set it to a fixed value ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 20, 2020, 04:55:48 PM
Figured I'd ask this here since this thread is more for this type of thing:

Where can I find a list of variables that are replaceable in the text portion of Rules.csv? Things like $personRank, $PersonRank, $playerName, $hisOrHer, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2020, 05:02:07 PM
upon closer look i can see that it does in fact turn - almost imperceptibly slow, but it does turn.
so, my question stands - how can i buff turnrate of a hardpoint mounted weapon by a flat value or force set it to a fixed value ?

Set the base turn rate to 3? :) No way to specifically do what you're asking.

Figured I'd ask this here since this thread is more for this type of thing:

Where can I find a list of variables that are replaceable in the text portion of Rules.csv? Things like $personRank, $PersonRank, $playerName, $hisOrHer, etc.

See: CoreRuleTokenReplacementGeneratorImpl

Note that you can also provide a custom one if needed.

Also regular variables from memory get substituted, you can either check the memory via the devMode dialog option or look in CoreCampaignPlugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 20, 2020, 05:15:10 PM
See: CoreRuleTokenReplacementGeneratorImpl

Note that you can also provide a custom one if needed.

Also regular variables from memory get substituted, you can either check the memory via the devMode dialog option or look in CoreCampaignPlugin.

Thanks! In this case, I'm parsing a returned string that is sometimes randomly selected and replacing found variables that way since the string is being pulled from a different spreadsheet instead of being contained in rules. I already have the parsing/replacement algorithm working, I just need all the variable definitions to check for. I haven't stress tested using every variable yet, but I doubt it will be an issue.

I will implement the custom generator if needed, but as long as I have the hooks to get the entity information for each variable then it shouldn't be necessary- though I haven't looked at it yet. It might give me some pointers on keeping the algorithm efficient. Thanks again for all the help you give to modders. :)

*EDIT* Oh you know what, I can use the public method to get all the replacement tokens for the script in a map. That will save a lot of time!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2020, 05:33:47 PM
... ah. This method:

Misc.getStringWithTokenReplacement()

May be relevant to your interests. It basically, as far as I can see, does what you're trying to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 20, 2020, 07:52:55 PM
... ah. This method:

Misc.getStringWithTokenReplacement()

May be relevant to your interests. It basically, as far as I can see, does what you're trying to do.

Ah thanks. I should have asked lol. That will save me the time of defining all the keys. And now I have my own parsing logic in case I want to use it to define my own tokens without overriding the generator.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2020, 08:08:19 PM
You don't have to override the generator, multiple ones can coexist at once. See CoreLifecyclePluginImpl:

Code
public void onGameLoad(boolean newGame) {
...
/* the token replacement generators don't get saved
  add them on every game load */
Global.getSector().getRules().addTokenReplacementGenerator(new CoreRuleTokenReplacementGeneratorImpl());
...
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 20, 2020, 09:00:20 PM
You don't have to override the generator, multiple ones can coexist at once. See CoreLifecyclePluginImpl:

Code
public void onGameLoad(boolean newGame) {
...
/* the token replacement generators don't get saved
  add them on every game load */
Global.getSector().getRules().addTokenReplacementGenerator(new CoreRuleTokenReplacementGeneratorImpl());
...
}

So I could use this to add my own map of tokens as a separate generator class that could then be accounted for when using the Misc method to replace rules tokens? (which could then be used on the spreadsheet strings?) That would be the use case I would think I would need.

I've handled that functionality in my util class, though, so may as well use it for now (hehe makes me feel better about spending time on it :-[ 8)), but if that is possible I will keep it in my back pocket if performance becomes an issue since a map seems very efficient to use.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2020, 09:14:57 PM
So I could use this to add my own map of tokens as a separate generator class that could then be accounted for when using the Misc method to replace rules tokens? (which could then be used on the spreadsheet strings?) That would be the use case I would think I would need.

Correct!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 20, 2020, 09:35:26 PM
Correct!

Thanks!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 20, 2020, 11:01:24 PM
So I could use this to add my own map of tokens as a separate generator class that could then be accounted for when using the Misc method to replace rules tokens? (which could then be used on the spreadsheet strings?) That would be the use case I would think I would need.

Correct!

I tried this out. Turns out that the problem is that when you reload a save it no longer saves the replacements and they show up as variables. Maybe I am doing something wrong, but I am adding the generator to rules on a new game. I tried to do it onApplicationLoad() to avoid the save problem, but it throws an error when I do so. Any advice?

*EDIT* Don't spend time on this unless you feel the need. I think I got this solved already.

*EDIT 2* Solved. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2020, 08:33:28 AM
Ah - per the comment in the chunk of code I pasted a few posts earlier: you need to do it in onGameLoad(), since they are not saved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 21, 2020, 01:42:54 PM
Ah - per the comment in the chunk of code I pasted a few posts earlier: you need to do it in onGameLoad(), since they are not saved.

Ha I have no idea why my brain saw that and thought it was onNewGame()...  ::)

Made that change and it works like a charm now! Thanks for the catch.
-----------------------------

Ok next question: If I wanted to make a script to iterate over npcs at a market comm board, when is the best point to do this dynamically? When the player first docks at a market? Or maybe when the comm board is opened?

What I'm attempting is to use the logic I created to allow gender-based post names. (ie Lord/Lady of Commerce, Priest/Priestess of Commodities, etc)
Since npcs will change after invasions, etc, I can't just do this once so I instead have to make it dynamic. I also want to limit how many npcs I am iterating over at a time so keeping it to "as the player would see this" seems to be the best solution. I'm fairly sure the only time you can see post names is when actually docking at the market. You can't view them while simply being in the system, iirc.

*EDIT*
And unrelated:

Is:

Code
                index = (int) ((Math.random() * (1 + optionsList.size())) - 1);

a "true-er" random than?:

Code
                index = (int) (Math.random() * (optionsList.size()));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2020, 03:44:03 PM
Ok next question: If I wanted to make a script to iterate over npcs at a market comm board, when is the best point to do this dynamically? When the player first docks at a market? Or maybe when the comm board is opened?

What I'm attempting is to use the logic I created to allow gender-based post names. (ie Lord/Lady of Commerce, Priest/Priestess of Commodities, etc)
Since npcs will change after invasions, etc, I can't just do this once so I instead have to make it dynamic. I also want to limit how many npcs I am iterating over at a time so keeping it to "as the player would see this" seems to be the best solution. I'm fairly sure the only time you can see post names is when actually docking at the market. You can't view them while simply being in the system, iirc.

The time to do it would be when the NPCs are created, no? Since if the NPCs change you have to redo it once. So if there's any post-invasion hook you'd want to do it there. Otherwise, you could do it when the player opens the colony, yeah, but that risks it being out of sync if *something* refers to the NPCs when you're not docked at the colony. For example, a piece of intel might talk about a specific NPC at a market and mention their rank or post.

*EDIT*
And unrelated:

Is:

Code
                index = (int) ((Math.random() * (1 + optionsList.size())) - 1);

a "true-er" random than?:

Code
                index = (int) (Math.random() * (optionsList.size()));

Well, the first one will frequently produce -1 as the result, so... :)

The second one should be fine, but you could also do:

Misc.random.nextInt(optionsList.size());

And not worry about it. Misc.random is a static instance of Random that the game uses for general purposes whenever that's needed. (Often, though, it'll instantiate a Random with a specific seed, when repeatable behavior over save/load cycles is needed...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 21, 2020, 04:57:15 PM
The time to do it would be when the NPCs are created, no? Since if the NPCs change you have to redo it once. So if there's any post-invasion hook you'd want to do it there. Otherwise, you could do it when the player opens the colony, yeah, but that risks it being out of sync if *something* refers to the NPCs when you're not docked at the colony. For example, a piece of intel might talk about a specific NPC at a market and mention their rank or post.

Ideally, yes, I just wasn't sure how easy that would be compared to using a standard docking rule or something to run the script. The intel part is a small setback though I didn't think of that. I have no clue about whether a post invasion hook is possible I'll have to ask Histidine.

Otherwise, would the correct way of doing this (initially) be to iterate over all markets at the start of a new game, say, afterEconomyLoad() or something? Is there a way to know when an NPC is created? Like a way of setting up a listener or something? (I don't think I've done this before).

Quote
Well, the first one will frequently produce -1 as the result, so... :)

The second one should be fine, but you could also do:

Misc.random.nextInt(optionsList.size());

And not worry about it. Misc.random is a static instance of Random that the game uses for general purposes whenever that's needed. (Often, though, it'll instantiate a Random with a specific seed, when repeatable behavior over save/load cycles is needed...)

*facepalm* yeah I see that now lol. And the random the game uses would be ideal, so I will change it to that. The repeatable behavior part is nice because then players can't save scum (in the case of some instances of this) to get the result they want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2020, 05:49:28 PM
Ideally, yes, I just wasn't sure how easy that would be compared to using a standard docking rule or something to run the script. The intel part is a small setback though I didn't think of that. I have no clue about whether a post invasion hook is possible I'll have to ask Histidine.

Otherwise, would the correct way of doing this (initially) be to iterate over all markets at the start of a new game, say, afterEconomyLoad() or something? Is there a way to know when an NPC is created? Like a way of setting up a listener or something? (I don't think I've done this before).

There's no way to know. You can look in CoreLifecyclePluginImpl to see when vanilla does it but that's no guarantee regarding when mods might do it. It could literally happen at any time.

*facepalm* yeah I see that now lol. And the random the game uses would be ideal, so I will change it to that. The repeatable behavior part is nice because then players can't save scum (in the case of some instances of this) to get the result they want.

(Ah, please re-read what I said more carefully. Misc.random does not produce consistent save/load behavior.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 21, 2020, 05:59:36 PM
There's no way to know. You can look in CoreLifecyclePluginImpl to see when vanilla does it but that's no guarantee regarding when mods might do it. It could literally happen at any time.
Yeah that was my thought as well. For my specific implementation, this wouldn't likely be a problem... but considering the intel caveat it would probably be hard to do this globally for all modders. Oh well, maybe I can expand upon that later.

Quote
(Ah, please re-read what I said more carefully. Misc.random does not produce consistent save/load behavior.)

Oh so the game sometimes uses a random with a seed to do that, but Misc.random does not? Is that what you were saying? Sorry if it's not clicking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2020, 06:06:29 PM
Oh so the game sometimes uses a random with a seed to do that, but Misc.random does not? Is that what you were saying? Sorry if it's not clicking.

Right, yeah, that's what I meant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 22, 2020, 12:28:07 PM
*Solved* Can anyone help getting this file to load correctly? The log shows the issue.

Code:
Code
            JSONArray StringData = Global.getSettings().getMergedSpreadsheetDataForMod("id", FILE, "fleetdialogue_morro");
            for(int i = 0; i < StringData.length(); i++) {
                JSONObject row = StringData.getJSONObject(i);
                if(row.getString("id")!=null){
                    // Set up dialogue response map. Response category keys are hardcoded and called in the various get methods implemented below.
                    // Also checks for missing or empty dialogue responses as a safeguard.
                    if (row.getString("commodityRequestDescription") != null && !row.getString("commodityRequestDescription").isEmpty()) {
                        DIALOGUE_RESPONSES.put("commodityRequestDescription", row.getString("commodityRequestDescription"));
                    }
                    if (row.getString("commoditySupplyRequestDescription") != null && !row.getString("commoditySupplyRequestDescription").isEmpty()) {
                        DIALOGUE_RESPONSES.put("commoditySupplyRequestDescription", row.getString("commoditySupplyRequestDescription"));
                    }
                    // Add nested map to the faction map under the faction id.
                    FACTION_DIALOGUE.put(row.getString("id"), DIALOGUE_RESPONSES);
                }
            }

            // This is to test that the information is being loaded correctly.
            String defaultCommodityRequestDescription = FACTION_DIALOGUE.get("default").get("commodityRequestDescription").toString();
            String defaultCommoditySupplyRequestDescription = FACTION_DIALOGUE.get("default").get("commoditySupplyRequestDescription").toString();
            String hegCommodityRequestDescription = FACTION_DIALOGUE.get("hegemony").get("commodityRequestDescription").toString();
            String hegCommoditySupplyRequestDescription = FACTION_DIALOGUE.get("hegemony").get("commoditySupplyRequestDescription").toString();

            LOG.error("Contents of dialogue map for default: " + defaultCommodityRequestDescription + " " + defaultCommoditySupplyRequestDescription);
            LOG.error("Contents of dialogue map for hegemony: " + hegCommodityRequestDescription + " " + hegCommoditySupplyRequestDescription);

File Contents:
id,commodityRequestDescription,commoditySupplyRequestDescription,
default,"After exchanging a few pleasantries, you inform the $personRank that you could use some assistance. The weight of your influence, if any, with $hisOrHer faction is behind the request, as is the military strength of each of your respective forces...","You should see this under default.",
hegemony,"$lordOrLady...$priestOrPriestess...$sorcererOrSorceress","Test",

Log on application start:
11915 [Thread-4] ERROR factions.FDialogue_factionTextLoader  - Contents of dialogue map for default: $lordOrLady...$priestOrPriestess...$sorcererOrSorceress Test
11915 [Thread-4] ERROR factions.FDialogue_factionTextLoader  - Contents of dialogue map for hegemony: $lordOrLady...$priestOrPriestess...$sorcererOrSorceress Test

*EDIT*

Nvm, I figured it out. I needed to create the map for the responses each iteration of the loop rather than using a global static map. It reads the file correctly now.

(New code)

Code
            for(int i = 0; i < StringData.length(); i++) {
                JSONObject row = StringData.getJSONObject(i);
                Map<String, String> responses = new HashMap<>();
                responses.clear();
                if(row.getString("id")!=null){
                    // Set up dialogue response map. Response category keys are hardcoded and called in the various get methods implemented below.
                    // Also checks for missing or empty dialogue responses as a safeguard.
                    if (row.getString("commodityRequestDescription") != null && !row.getString("commodityRequestDescription").isEmpty()) {
                        responses.put("commodityRequestDescription", row.getString("commodityRequestDescription"));
                    }
                    if (row.getString("commoditySupplyRequestDescription") != null && !row.getString("commoditySupplyRequestDescription").isEmpty()) {
                        responses.put("commoditySupplyRequestDescription", row.getString("commoditySupplyRequestDescription"));
                    }
                    // Add nested map to the faction map under the faction id.
                    FACTION_DIALOGUE.put(row.getString("id"), responses);
                }
            }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on May 23, 2020, 07:16:27 PM
Want to try a bit of weapon modding, but have some questions before I really get stuck in.

Does setting a weapon's rarity above 1.0 have any affect to it's commonality?

Is there any issue with have a duplicate weapon with the same display name, but different ID?

Is there a way to set weapon frequency similar to hull frequency in the faction file?
   If so, do weapons otherwise default to a frequency of 1.0? (100%)
      
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 26, 2020, 03:41:00 AM
I try to make certain industry produce more commodities but after I make changes in .java file, no effects seems to happen at all. Any way to implement the changes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2020, 08:47:38 AM
Does setting a weapon's rarity above 1.0 have any affect to it's commonality?

Sorry for the delay - it should make it more common in drops, but rarity only affects drops from salvage etc, not how often it's used by ships.

Is there any issue with have a duplicate weapon with the same display name, but different ID?

That should be fine.

Is there a way to set weapon frequency similar to hull frequency in the faction file?
   If so, do weapons otherwise default to a frequency of 1.0? (100%)

There isn't, no - aside from setting "tier" higher or lower; higher-tier weapons are less common.


I try to make certain industry produce more commodities but after I make changes in .java file, no effects seems to happen at all. Any way to implement the changes?

Are you changing the source in starfarer.api.zip? That's just provided for reference and isn't directly used by the game. You'll need to put your changes in a separate file in your mod, and probably compile them etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nia Tahl on May 26, 2020, 10:39:12 AM
So I've been doing some fiddling with some spawned projectiles and it seems that while the api comments say that modifiers for range and such values are pulled from the source weapon, they are actually pulled from the ship passed as damage source which is proving to be inconvenient as I'd like to spawn a projectile with a variable damage source (as it spawns from another ship) without that affecting the projectile properties.

Am I correct in my observations and is there another way of spawning a projectile like that from another ship without it immediately colliding with said ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 26, 2020, 11:20:36 AM
Quote
Are you changing the source in starfarer.api.zip? That's just provided for reference and isn't directly used by the game. You'll need to put your changes in a separate file in your mod, and probably compile them etc.
I'm modding a mod called better colonies for my taste. It's in "src.zip\src\com\fs\starfarer\api\impl\campaign\econ\impl"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2020, 11:49:23 AM
Looks like that mod also provides the source for reference. But when the game runs, it's using the compiled code from the jar. In that case, changing that code wouldn't do anything, you'd need to recompile it and replace the jar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on May 26, 2020, 12:18:31 PM
Sorry for the delay - it should make it more common in drops, but rarity only affects drops from salvage etc, not how often it's used by ships.

Does that mean that rarity doesn't have an affect on it's chance to show up in an appropriate market then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2020, 12:20:08 PM
It... maybe should. But, right, it doesn't!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 26, 2020, 03:13:51 PM
When adding a paragraph using the TextPanelAPI, what is format for adding text highlights? What is the best method implementation to use for that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2020, 04:33:35 PM
I'd say just search the TextPanelAPI interface for "highlight" and use the methods there :) Nothing in there is deprecated or inadvisable, just depends on whatever is most convenient in your case. The addPara() methods match how TooltipMakerAPI works and are a later addition.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 26, 2020, 05:50:06 PM
I'd say just search the TextPanelAPI interface for "highlight" and use the methods there :) Nothing in there is deprecated or inadvisable, just depends on whatever is most convenient in your case. The addPara() methods match how TooltipMakerAPI works and are a later addition.

Ah ok gotcha. So, based upon the syntax connotations, those methods add the highlights to previously existing paragraphs?

Let's say I successfully parse A from a full string or substring. (Note: The parent string has already been added to the LabelAPI using the addParagraph() method and had its variables replaced - so this parsed string could potentially be a former replacement token that has been converted into it's replacement).

If so, I just pass A (should be a string) into:
Code
 
dialog.getTextPanel().highlightInLastPara(Misc.getHighlightColor(), A);
- ?

Parsing code if needed:
Spoiler
Code
    public static void parseDialogueHighlights(String responseDialogue, InteractionDialogAPI dialog) {
        if (responseDialogue.contains("$" + START_TEXT_HIGHLIGHT)) {
            List<String> remainingElements = Arrays.asList(responseDialogue.split(START_TEXT_HIGHLIGHT_REGEX));
            for (int i = 0; i < remainingElements.size(); i++) {
                String element = remainingElements.get(i);
                if (element.contains("$" + END_TEXT_HIGHLIGHT)) {
                    List<String> highLightComponents = Arrays.asList(element.split(END_TEXT_HIGHLIGHT_REGEX, 1));
                    String highlight = highLightComponents.get(0);
                    dialog.getTextPanel().highlightInLastPara(Misc.getHighlightColor(), highlight);
                }
            }
        }
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on May 26, 2020, 07:37:09 PM
It... maybe should. But, right, it doesn't!

Does that mean that only Tier determines the chance for a buy-able weapon to spawn in a market, or are there other factors that could be modified to alter the chance?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2020, 08:18:49 PM
Ah ok gotcha. So, based upon the syntax connotations, those methods add the highlights to previously existing paragraphs?

Let's say I successfully parse A from a full string or substring. (Note: The parent string has already been added to the LabelAPI using the addParagraph() method and had its variables replaced - so this parsed string could potentially be a former replacement token that has been converted into it's replacement).

That seems reasonable. I mean, you could give it a try and see if it works :) But on a cursory reading, nothing jumps out as being wrong.

Does that mean that only Tier determines the chance for a buy-able weapon to spawn in a market, or are there other factors that could be modified to alter the chance?

You can take a look at BaseSubmarketPlugin's addWeapons method, and place that this method (and similar) are called from. In brief, it's not just that; there's some logic for having a range of different weapon roles available etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on May 26, 2020, 08:24:33 PM
Will the game ever support a possible "dummy skill" implementation where skill can be made from a mod but hidden from the skill overview.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 26, 2020, 08:55:02 PM
That seems reasonable. I mean, you could give it a try and see if it works :) But on a cursory reading, nothing jumps out as being wrong.

I tried it and nothing seems to be highlighted. I wasn't expecting the parsed separators to be removed from the parent string since I haven't coded that logic yet, but the string sent into the highlight method should at least be highlighted in one instance, right? - though probably not multiple duplicates yet. That doesn't seem to be happening.

I'll keep testing and give more info when I can. I'll also set up some logging to make sure I'm getting the correct substrings I'm intending to. That should help as well in debugging this. Lots of things could potentially be going wrong so I'll try and narrow it down further.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2020, 09:06:52 PM
Will the game ever support a possible "dummy skill" implementation where skill can be made from a mod but hidden from the skill overview.

There's an "npc_only" tag (I don't think it's in now, in-dev only) that basically makes the skill not get used anywhere or show up. I.E. AI officers won't get it either and it needs to be explicitly added to a person.

I tried it and nothing seems to be highlighted. I wasn't expecting the parsed separators to be removed from the parent string since I haven't coded that logic yet, but the string sent into the highlight method should at least be highlighted in one instance, right? - though probably not multiple duplicates yet. That doesn't seem to be happening.

I'll keep testing and give more info when I can. I'll also set up some logging to make sure I'm getting the correct substrings I'm intending to. That should help as well in debugging this. Lots of things could potentially be going wrong so I'll try and narrow it down further.

Ah - I'd suggest trying hardcoded highlights to try to narrow down the issue. Also, you may need to set a highlight color, and it may be sensitive to the order (i.e. you might have to do set color, then highlight, or vice versa), but I don't 100% remember off the top of my head. Basically what I'm suggesting is get *any* highlight working and then go from there to try to identify what's making your case not work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on May 26, 2020, 09:44:29 PM
You can take a look at BaseSubmarketPlugin's addWeapons method, and place that this method (and similar) are called from. In brief, it's not just that; there's some logic for having a range of different weapon roles available etc.

The weapon roles would be determined by the tags correct?
Higher pd is weighted if the market needs Point Defense Weapons for example?

If this is true is there a list of what tags do? A lot are self evident like Kinetic, HE and Energy, but what's the difference between a rocket and a missile? What does the AI use the Utility tag for?


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 26, 2020, 09:50:37 PM
Ah - I'd suggest trying hardcoded highlights to try to narrow down the issue. Also, you may need to set a highlight color, and it may be sensitive to the order (i.e. you might have to do set color, then highlight, or vice versa), but I don't 100% remember off the top of my head. Basically what I'm suggesting is get *any* highlight working and then go from there to try to identify what's making your case not work.

Thanks! :) I'll narrow it down- hopefully tomorrow at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 27, 2020, 05:15:32 AM
Looks like that mod also provides the source for reference. But when the game runs, it's using the compiled code from the jar. In that case, changing that code wouldn't do anything, you'd need to recompile it and replace the jar.
I don't want to derail the thread but how to do what you're saying in this post? I really don't know where to look, any help would be appreciated. Thanks for help  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on May 27, 2020, 05:58:28 AM
Looks like that mod also provides the source for reference. But when the game runs, it's using the compiled code from the jar. In that case, changing that code wouldn't do anything, you'd need to recompile it and replace the jar.
I don't want to derail the thread but how to do what you're saying in this post? I really don't know where to look, any help would be appreciated. Thanks for help  :)

You are editing a part of the provided source code that is not actually loaded. Starsector loads the contents of the provided .jar file, which is the compiled version of what you are playing around with.
To compile code, you need an IDE, usually IntelliJ (http://fractalsoftworks.com/forum/index.php?topic=10057.0) or Netbeans (http://fractalsoftworks.com/forum/index.php?topic=3173.msg45967) are suggested.

If you have no idea what you are doing, consider following a part of the tutorial that requires code compilation from here:
https://starsector.fandom.com/wiki/Intro_to_Modding

which will give you a better overview of how making a Starsector mod works.
You could also come join the Discord, where a lot of very helpful people can answer your questions quicker than they will be answered here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on May 27, 2020, 08:07:04 PM
Will the game ever support a possible "dummy skill" implementation where skill can be made from a mod but hidden from the skill overview.

There's an "npc_only" tag (I don't think it's in now, in-dev only) that basically makes the skill not get used anywhere or show up. I.E. AI officers won't get it either and it needs to be explicitly added to a person.
im so interested in this feature now...  ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 28, 2020, 03:23:08 PM
Ah - I'd suggest trying hardcoded highlights to try to narrow down the issue. Also, you may need to set a highlight color, and it may be sensitive to the order (i.e. you might have to do set color, then highlight, or vice versa), but I don't 100% remember off the top of my head. Basically what I'm suggesting is get *any* highlight working and then go from there to try to identify what's making your case not work.

Thanks! :) I'll narrow it down- hopefully tomorrow at some point.

Not 100% sure yet, but it looks like it wasn't working because the string sent into the highlight method needs to be surrounded by spaces (maybe punctuation is ok? Haven't tested that yet, actually) in the paragraph it is trying to highlight. So, it looks like the lack of separator removal logic was part of the problem. It still isn't working when the separators are removed, but I got a success case by hardcoding "and" and it was highlighted. So hmm. I'll look at this more tonight.

For instance, sending in "credit" will work with: "Not a credit more!" but not: "Give me your credits!"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on May 28, 2020, 04:43:48 PM
Is it possible to manually (I mean via script call or similar) kill crew during combat and have those losses appear in the results screen afterwards? And if so, can it also be done with Marines? (And just out of curiosity, other cargo items)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on May 28, 2020, 04:47:15 PM
Is it possible to manually (I mean via script call or similar) kill crew during combat and have those losses appear in the results screen afterwards? And if so, can it also be done with Marines? (And just out of curiosity, other cargo items)
I believe this can be done through rules modifications, you can get the lowest hull level of a ship through ShipAPI via plugin, and then have a rules hook that fires at the end of combat, with marine losses subtracted and the player notified similarly to crew. Most rules scripts are in api impl, so you should find what you're looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on May 28, 2020, 05:15:48 PM
I believe this can be done through rules modifications, you can get the lowest hull level of a ship through ShipAPI via plugin, and then have a rules hook that fires at the end of combat, with marine losses subtracted and the player notified similarly to crew. Most rules scripts are in api impl, so you should find what you're looking for.
Hi, thanks for the quick reply!

However, I was thinking of something that can give me finer control of how many gets killed. For example, if you shoot this gun, 5 crew immediately get killed, or if you get hit by this projectile, 5 marines get killed. Something like that. If I read your suggestion right, the losses incurred would be calculated relative to the ship hull/crew losses formula...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 28, 2020, 05:42:52 PM
Not 100% sure yet, but it looks like it wasn't working because the string sent into the highlight method needs to be surrounded by spaces (maybe punctuation is ok? Haven't tested that yet, actually) in the paragraph it is trying to highlight. So, it looks like the lack of separator removal logic was part of the problem. It still isn't working when the separators are removed, but I got a success case by hardcoding "and" and it was highlighted. So hmm. I'll look at this more tonight.

For instance, sending in "credit" will work with: "Not a credit more!" but not: "Give me your credits!"

Ah - right, yeah, highlighting requires whitespace/punctuation boundaries. Otherwise it could be a real mess highlighting things like, uhh, "the accredited institution pays you X credits" and so on. I mean, one could always go the "add markup to text" route, but that's more of a pain.

However, I was thinking of something that can give me finer control of how many gets killed. For example, if you shoot this gun, 5 crew immediately get killed, or if you get hit by this projectile, 5 marines get killed. Something like that. If I read your suggestion right, the losses incurred would be calculated relative to the ship hull/crew losses formula...

I don't think you could do that seamlessly. Best you could do, I think, would be to note these losses, and then apply them after the combat, separately, and have an intel item pop up.

(Or, I mean, you *could* provide a custom implementation of FleetEncounterContext or FleetInteractionDialogPluginImpl, but that'd I think make your mod incompatible with Nexerlein and/or any other mod that does that.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 28, 2020, 06:40:26 PM
Ah - right, yeah, highlighting requires whitespace/punctuation boundaries. Otherwise it could be a real mess highlighting things like, uhh, "the accredited institution pays you X credits" and so on. I mean, one could always go the "add markup to text" route, but that's more of a pain.

Oh right yeah that makes sense! I have it *mostly* working now.

*EDIT* Ok now I really don't understand what's going on... see details below. I seem to be getting inconsistent results from the highlight method. Specifically look at "credit" in the second log and screenshot- "credits" gets the highlight... minus the "s" which debunks the earlier logic. I originally thought credit came before credits but looking again that's incorrect. Maybe it is only performing the highlight on the first instance? *See below post* The log verifies the logic to pass the correct data into the highlight method is working as intended. I also added a code example of where the logging happens for reference.

Speaking of "X credits", when the replacement token is storing an int and replaces X with the correct amount of credits, passing that amount (as a string) into the highlight method doesn't work for some reason. I have tested other replacement tokens like $HeOrShe, $personName, etc- at both the start of the line and between other logic tokens and all of that works fine. This leads me to believe that the issue is that the replacement token points to an int. *See below post*

Any way to handle this that you can think of? The way the token parser works is that it compiles the list of highlights found into a List (from a comma separated string) and then iterates through the list and passes each highlight into the method. The string it parses through is the returned string from:
Code
responseDialogue = Misc.getStringWithTokenReplacement(responseDialogue, dialog.getInteractionTarget(), memoryMap);

I set up some logging and got:

Log:
Spoiler
68571 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Faction id: hegemony - was found in FleetDialogue_factionText.csv, but no valid entry was found for: commodityRequestSuccessHaveToPay
68571 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Using default dialogue response for: commodityRequestSuccessHaveToPay
68571 [Thread-4] INFO  util.FDialogue_cellDataManager  - Multiple dialogue options detected in cell. 2 total options detected. Selected option: 1
68571 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: 3981,and,
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: 3981
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: and
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: Four Cross,
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: Four Cross
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: She,
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: She
[close]
Spoiler
425639 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Faction id: hegemony - was found in FleetDialogue_factionText.csv, but no valid entry was found for: commodityRequestSuccessHaveToPay
425639 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Using default dialogue response for: commodityRequestSuccessHaveToPay
425640 [Thread-4] INFO  util.FDialogue_cellDataManager  - Multiple dialogue options detected in cell. 2 total options detected. Selected option: 2
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: 4208,credit,
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: 4208
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: credit
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: lieutenant,and,she,
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: lieutenant
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: and
425641 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: she
[close]

Game screenshots of results:
Spoiler
(https://i.imgur.com/JX323M0.png)
(https://i.imgur.com/U7HxwhS.png)
[close]

Original cell string:
Spoiler
"I suppose I could help you, but don't think I'm dumb enough to simply give it away... it'll cost you $STARTHL$AidRequest_estCost$ENDHL credits for my overhead costs $STARTHLand$ENDHL inconvenience."$NEWLINEYou know that the market cost of what you are asking for is probably lower than what you are currently being forced to pay, but $STARTHL$personName$ENDHL has you in a tight spot. $NEWLINE$STARTHL$HeOrShe$ENDHL is doing you a favor by helping you, and a convenience markup is common in such situations anyway.OR"Sure, but you're crazy to think I'd just give you something for free. $STARTHL$AidRequest_estCost$ENDHL credits gets you what you need. Not a $STARTHLcredit$ENDHL less, either!"$NEWLINEThis arrangement is clearly benefiting the $STARTHL$personRank$ENDHL since the market cost of resupplying your fleet might generally be much lower, but your reputation is average $STARTHLand$ENDHL $STARTHL$heOrShe$ENDHL has no real reason to help you in the first place.
[close]

Spoiler
Code
    private static void addDialogueHighlights(String highlights, InteractionDialogAPI dialog) {
        if (highlights != null) {
            LOG.info("Highlights detected in dialogue response: " + highlights);
            List<String> highlightList = Arrays.asList(highlights.split(","));
            for (int i = 0; i < highlightList.size(); i++) {
                LOG.info("Attempting to highlight: " + highlightList.get(i));
                dialog.getTextPanel().highlightInLastPara(Misc.getHighlightColor(), highlightList.get(i));
            }
        }
    }
[close]

What I assume the returned string looks like:
Spoiler
"I suppose I could help you, but don't think I'm dumb enough to simply give it away... it'll cost you $STARTHL3981$ENDHL credits for my overhead costs $STARTHLand$ENDHL inconvenience."$NEWLINEYou know that the market cost of what you are asking for is probably lower than what you are currently being forced to pay, but $STARTHLFour Cross$ENDHL has you in a tight spot. $NEWLINE$STARTHLShe$ENDHL is doing you a favor by helping you, and a convenience markup is common in such situations anyway.OR"Sure, but you're crazy to think I'd just give you something for free. $STARTHL3981$ENDHL credits gets you what you need. Not a $STARTHLcredit$ENDHL less, either!"$NEWLINEThis arrangement is clearly benefiting the $STARTHLcaptain$ENDHL since the market cost of resupplying your fleet might generally be much lower, but your reputation is average $STARTHLand$ENDHL $STARTHLShe$ENDHL has no real reason to help you in the first place.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on May 28, 2020, 06:53:14 PM
I don't think you could do that seamlessly. Best you could do, I think, would be to note these losses, and then apply them after the combat, separately, and have an intel item pop up.
Hmm, I see. That'll work, I think! Maybe I could also just add some floating text during the combat so the player knows what happened and when. Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 29, 2020, 07:33:12 PM
Ahhhh OK, I think I have this sorted now.

The reason I was confused was that the highlight method overwrites the paragraph each time it is called. Because of this, the other highlights I was specifying would only get captured if they were contained in another paragraph from addParagraph(). (This sometimes happens because when I parse a new line I call addParagraph() each time then call the highlight method before adding another new paragraph for the next dialogue component.) That is why it seemed like it highlighted a random amount of strings... (Some dialogue choices have multiple paragraphs and some don't.) Also, the credit amount issue that I was theorizing was somehow related to the integer from replacement was all wrong. :P It was just ironically being overridden by the next highlight each time I tested it despite changing the highlights multiple times. Even when I hardcoded it for a test I called the method twice... so the credit portion just happened to be overridden in every instance. Ha!  ::)

The actual way to specify additional highlights in the same paragraph is to add additional string parameters to:
Code
                dialog.getTextPanel().highlightInLastPara();

Well... that complicates things since the number of highlights per paragraph ideally would be variable. Unless there is a way to dynamically change method signatures and add parameters based upon a list size (I don't know I've never tried) I will just have to set a maximum number of highlights per paragraph and create a switch based upon the List size to determine which method signature to use if all else fails.

However, I also messed around with:

Code
                Highlights highlightData = new Highlights();
                highlightData.setText(highlightList.get(i));
                highlightData.setColors(Misc.getHighlightColor());
                dialog.getTextPanel().setHighlightsInLastPara(highlightData);

I'm going to try the append() method for the HighLights class to see if I can get dynamic highlights that way using a List. If not, I'll use the other implementation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 30, 2020, 09:00:03 AM
TextPanelAPI.addPara returns a LabelAPI. You can then call LabelAPI.setHighlight and LabelAPI.setHighlightColors, much easier that way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 30, 2020, 02:51:59 PM
TextPanelAPI.addPara returns a LabelAPI. You can then call LabelAPI.setHighlight and LabelAPI.setHighlightColors, much easier that way.

Thanks for the info!  :)

The main difference I see between the two ways of doing that is the LabelAPI allows for index based highlights and dehighlights. That may definitely come in handy and I'll keep it in the back of my mind.

It doesn't solve the original problem though- because adding highlights from LabelAPI's general highlight method still requires multiple substrings as additional parameters rather than accepting a List or Array.

However:

Dynamic highlights from parsing the cell can be done using:

Code
        if (highlights != null) {
            LOG.info("Highlights detected in dialogue response: " + highlights);
            List<String> highlightList = Arrays.asList(highlights.split(","));
            Highlights highlightData = new Highlights();
            for (int i = 0; i < highlightList.size(); i++) {
                LOG.info("Attempting to highlight: " + highlightList.get(i));
                highlightData.append(highlightList.get(i), Misc.getHighlightColor());
            }
            dialog.getTextPanel().setHighlightsInLastPara(highlightData);
        }

That will highlight every parsed highlight wrapper string in the paragraph. Unless I'm missing something (very possible haha) I think this might be the only way to add highlights dynamically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 30, 2020, 03:12:03 PM
The varargs thing - where you can pass in multiple strings as additional parameters - also accepts an array.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 30, 2020, 04:05:10 PM
The varargs thing - where you can pass in multiple strings as additional parameters - also accepts an array.

Ah ok! I was trying a List. I also tried List.toArray() which probably doesn't work because it returns Object[] instead of String[].

What you need to pass in is String[] list = string.split(","); I haven't confirmed it works yet, but at least IntelliJ doesn't gripe at me about it like it does the other two.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 30, 2020, 04:32:10 PM
You can also do list.toArray(new String[0]) which returns a "String []"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 30, 2020, 04:54:19 PM
You can also do list.toArray(new String[0]) which returns a "String []"

Can this same technique be used to set multiple highlight colors in the same paragraph using LabelAPI.setHighlightColors(Color... colors)? (Don't have time to test it at the moment)

So I could set a color option per highlight wrapper and then pass in the colors in the same order as the highlight list?

Like:

Code
Color[] colors = list.toArray(new Color[0]);
LabelAPI.setHighlightColors(colors);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 30, 2020, 05:09:13 PM
Yep!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 30, 2020, 06:08:41 PM
Yep!

Sweet!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 31, 2020, 06:08:44 AM
Spoiler
Looks like that mod also provides the source for reference. But when the game runs, it's using the compiled code from the jar. In that case, changing that code wouldn't do anything, you'd need to recompile it and replace the jar.
I don't want to derail the thread but how to do what you're saying in this post? I really don't know where to look, any help would be appreciated. Thanks for help  :)

You are editing a part of the provided source code that is not actually loaded. Starsector loads the contents of the provided .jar file, which is the compiled version of what you are playing around with.
To compile code, you need an IDE, usually IntelliJ (http://fractalsoftworks.com/forum/index.php?topic=10057.0) or Netbeans (http://fractalsoftworks.com/forum/index.php?topic=3173.msg45967) are suggested.

If you have no idea what you are doing, consider following a part of the tutorial that requires code compilation from here:
https://starsector.fandom.com/wiki/Intro_to_Modding

which will give you a better overview of how making a Starsector mod works.
You could also come join the Discord, where a lot of very helpful people can answer your questions quicker than they will be answered here.
[close]
I decompiled it with intellij idea but the file says it's read only even though I checked it and made sure it's not a read only file. It's a .class file btw.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on May 31, 2020, 09:23:01 AM
I have created a ship, and everything works as intended. But still need some help with:

1. Description. It is looks like descriptions.csv in custom mod folder should not be edited with ordinary text editor, just like ship_data.csv. While ship_data.csv can be edited via SWE (https://fractalsoftworks.com/forum/index.php?topic=11491.0), it is looks like it can't work with descriptions. Is there any tools?

2. Tags. What shall I use to ensure:
-Non of a factions will not use this hull. Never.
-Non of markets will not sale this hull in a shop. Never.
-BP drops only as rare_bp, but with much smaller probability, like 1/20 of default BP of a same kind. Which rarity value shall I set for this?

3. Is there any possibility to make shiphull available for player-ordered building after BP is acquired, but not available for player faction's generated fleets not to use it?

Thank you!

EDIT: Typo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 31, 2020, 08:46:06 PM
I decompiled it with intellij idea but the file says it's read only even though I checked it and made sure it's not a read only file. It's a .class file btw.

It sounds like you took a wrong turn somewhere. What you'd want to be doing is creating your own source file, compiling it, and also providing - in your mod - a file that points to your class instead of the vanilla one. E.G. if you were replacing an industry's code, you'd have your own version of it, and an entry in your mod's industries.csv, etc.

1. Description. It is looks like descriptions.csv in custom mod folder should not be edited with ordinary text editor, just like ship_data.csv. While ship_data.csv can be edited via SWE (https://fractalsoftworks.com/forum/index.php?topic=11491.0), it is looks like it can't work with descriptions. Is there any tools?

I don't know what external tools would work out of the box. I know excel can be configured to produce csv files the game can read, but I don't know the details. Personally I use google sheets and its "download as csv" option, so whatever format that ends up as, the game reads.

2. Tags. What shall I use to ensure:
-Non of a factions will not use this hull. Never.

As long as it's not in a blueprint package and none of the factions are configured (via their .faction file) to have it, they won't have it.

-Non of markets will not sale this hull in a shop. Never.
-BP drops only as rare_bp, but with much smaller probability, like 1/20 of default BP of a same kind. Which rarity value shall I set for this?

If you want 1/20, rarity would be 0.05.

3. Is there any possibility to make shiphull available for player-ordered building after BP is acquired, but not available for player faction's generated fleets not to use it?

I don't believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on June 01, 2020, 02:22:53 AM
Hello,

I'm back on Starsector modding once again, and I was wondering how does pulse weapons works, and if there was a way to use the pulse charging effect on non pulse weapon, like a ballistic artillery. Is there an easy way around ?
Or would that involve scripting a custom behavior for the weapon as en everyframe effect (I guess checking for the charge level until it get back to 0 could work for the percentage of charge, but how can I make a weapon fire with a everyframe plugin ?)
If anyone is familiar with thoses things, feel free to pm me, thanks !
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on June 01, 2020, 02:58:31 AM
google sheets

Can't believe answer was so easy. Probably that is why I didn't try it by myself.

Thank you!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 01, 2020, 01:59:20 PM
1. Description. It is looks like descriptions.csv in custom mod folder should not be edited with ordinary text editor, just like ship_data.csv. While ship_data.csv can be edited via SWE (https://fractalsoftworks.com/forum/index.php?topic=11491.0), it is looks like it can't work with descriptions. Is there any tools?

I don't know what external tools would work out of the box. I know excel can be configured to produce csv files the game can read, but I don't know the details. Personally I use google sheets and its "download as csv" option, so whatever format that ends up as, the game reads.

You can use a text editor to edit descriptions iirc (I used notepad) or you can use Excel or OpenOffice Spreadsheet editor. For editors you just use commas as your deliminator. (Should be one of the first settings available when opening the file).

What you can't do (at least not without caution or errors will occur) is mix and match tools. So once you choose one you mostly have to stick with it because the formats between tools cause hidden escaped characters to be misread as actual characters (my theory) when switching between formats.

In general, you have to be careful using quotes and commas when editing descriptions, and always back up your file before you make any edits. Every time. Seriously. If you get into a situation where a hidden escape character is causing an issue you won't be able to fix it to my knowledge. The file will look completely normal in a text editor but Starsector won't be able to read it correctly. For instance, if you use quotes in notepad to separate your text cells and then add nested quotes within the quotes, they have to be escaped iirc. If you use quotes to wrap your text and then open it in an editor- the quotes might disappear and they might not. Depends upon the editor. Using notepad I think I used ' as quote wrappers and " as cell wrappers. New lines are captured in notepad as well as editors.

Notepad Example:

Code
archean_avalanche,WEAPON,"A powerful strike cannon that uses the ship's own power core to generate enough energy to fire a massive projectile. Completely decimates armor. Flux inefficiency and low ammo storage prevent this weapon from dominating the sector's ballistic demand.

The avalanche is an older design most notably used by the Luddic Church, independents and pirates as a way to combat heavily armored targets with enough point defense to defend against explosive missiles that would otherwise perform the same role. The weapon must draw a non-insignificant amount of power from the defensive shield systems to effectively maintain prolonged fire.

Even if the clip size was larger, most vessel's power cores would be severely stressed by more than a couple of these weapons installed.",Strike,,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 01, 2020, 02:56:05 PM
Hello,

I'm back on Starsector modding once again, and I was wondering how does pulse weapons works, and if there was a way to use the pulse charging effect on non pulse weapon, like a ballistic artillery. Is there an easy way around ?
Or would that involve scripting a custom behavior for the weapon as en everyframe effect (I guess checking for the charge level until it get back to 0 could work for the percentage of charge, but how can I make a weapon fire with a everyframe plugin ?)
If anyone is familiar with thoses things, feel free to pm me, thanks !

Pulse weapons are extremely deprecated so I'd recommend not using them. Unless you just mean adding a chargeup time  to a weapon firing? Or do you mean the (very, very old) "hold button to charge, release to fire" behavior?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on June 02, 2020, 08:22:16 AM
One more question: is it possible to change a frontal shield direction? Particularly, can I made a rear shield instead of a front?

I know, I can just rotate a sprite and pilot ship backward. Also, I can add an invisible module with shield emitter, similar to station modules. But redirection of a frontal shield would give the best gameplay experience.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2020, 11:03:56 AM
It's not possible, no. Even if it were, the ship's AI wouldn't really be aware of it, so that would be a problem...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on June 03, 2020, 08:58:30 AM
It's a pity! That would be a really interesting concept.

Anyway, thanks for putting up with my stupid questions. let it be of no use to community, the process itself is very, very interesting to me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 04, 2020, 02:44:01 AM
Is there a way to force a ship to render over another/ alter its render level?

Obviously this isn't possible normally, but I have a ship that's set to fighter collisionclass on creation.
Before, it would render above everything , so it looked like it was flying over other ships. I don't know what I did, but that doesn't seem to be the case anymore, and now it only renders over ships that are above its weight class (it's a frigate), and when it flies over other frigates, it goes below them

its really triggering my OCD, any help would be appreciated

EDIT: I made a new game and it works, ship flies over everything...didn't touch the script or anything..weeeird

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: peeaa on June 04, 2020, 11:52:53 AM
How do I overwrite faction files of vanilla starsector and the faction files of other mods? I have all the faction files and the portraits done but I can't get the game the overwrite the old portraits from other mods or the vanilla game.

mod_info looks like this, probably done way wrong:

{
   "id":"portraits2", # internal id
   "name":"Portrait Pack CUSTOM", # displayed to the player
   "version":"v2",
   "description":"Adds way more portraits for the campaign for player choice.",
   "gameVersion":"0.8a",
"replace":["data/world/factions/player.faction",],
"replace":["data/world/factions/hegemony.faction",],
"replace":["data/world/factions/independent.faction",],
"replace":["data/world/factions/kinghts_of_ludd.faction",],
"replace":["data/world/factions/lions_guard.faction",],
"replace":["data/world/factions/luddic_church.faction",],
"replace":["data/world/factions/luddic_path.faction",],
"replace":["data/world/factions/persean_league.faction",],
"replace":["data/world/factions/pirates.faction",],
"replace":["data/world/factions/poor.faction",],
"replace":["data/world/factions/scavengers.faction",],
"replace":["data/world/factions/sindrian_diktat.faction",],
"replace":["data/world/factions/sleeper.faction",],
"replace":["data/world/factions/tritachyon.faction",],
"replace":["mods/Blackrock Drive Yards/data/world/factions/blackrock_Driveyards.faction",],
"replace":["mods/Blackrock Drive Yards/data/world/factions/br_consortium.faction",],
"replace":["mods/HMI/data/world/factions/brighton.faction",],
"replace":["mods/HMI/data/world/factions/hmi.faction",],
"replace":["mods/Underworld/data/world/factions/cabal.faction",],
"replace":["mods/DIABLEAVIONICS/data/world/factions/diableavionics.faction",],
"replace":["mods/Shadowyards/data/world/factions/shadow_industry.faction",],
"replace":["mods/tahlan/data/world/factions/tahlan_legioinfernalis.faction",],
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 04, 2020, 07:37:39 PM
How do I overwrite faction files of vanilla starsector and the faction files of other mods? I have all the faction files and the portraits done but I can't get the game the overwrite the old portraits from other mods or the vanilla game.

You can't override faction files of other mods. You just have to change the files in the mod itself (personal use only - do not publish the changes without author permission).

For vanilla, here is the implementation: (So the replace section is all one entry with commas separating each replaced file path. The final entry should not have a comma.

  "replace":[
          "data\\world\\factions\\pirates.faction",
          "data\\world\\factions\\neutral.faction",
          "data\\world\\factions\\hegemony.faction",
          "data\\world\\factions\\independent.faction",
          "data\\world\\factions\\player.faction",
          "data\\world\\factions\\sindrian_diktat.faction",
          "data\\world\\factions\\knights_of_ludd.faction",
          "data\\world\\factions\\luddic_church.faction",
          "data\\world\\factions\\luddic_path.faction",
          "data\\world\\factions\\persean_league.faction",
          "data\\world\\factions\\tritachyon.faction",
          "data\\world\\factions\\remnants.faction",
          "data\\world\\factions\\scavengers.faction",
          "data\\world\\factions\\lions_guard.faction",
          "data\\world\\factions\\derelict.faction",
          "data\\world\\factions\\poor.faction",
          "data\\world\\factions\\sleeper.faction"]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Fen on June 04, 2020, 09:05:06 PM
Has anyone attempted to make a mod that lets you build hullmods into a hull permanently? How difficult would that be to do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 04, 2020, 09:44:07 PM
Has anyone attempted to make a mod that lets you build hullmods into a hull permanently? How difficult would that be to do?

Coming in the next Starsector update. (Story points allow you to do this iirc twice?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on June 04, 2020, 09:50:34 PM
Has anyone attempted to make a mod that lets you build hullmods into a hull permanently? How difficult would that be to do?
That's straightforward to do, and it's also going to be a feature of the next starsector update iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Fen on June 04, 2020, 09:52:37 PM
Has anyone attempted to make a mod that lets you build hullmods into a hull permanently? How difficult would that be to do?

Coming in the next Starsector update. (Story points allow you to do this iirc twice?)

Oh, that's pretty cool. Guess I'll catch up with what's coming then, been away from the game for a year or so xP
I hope they make the limit and cost easily accessible to mod.

That's straightforward to do, and it's also going to be a feature of the next starsector update iirc.

That's interesting. I'm surprised no one made it in the meantime if it's pretty straightforward.
I guess the positive side to that is that if it's too restrictive/limited in the next update, it shouldn't be hard to add in another avenue to do it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 04, 2020, 09:58:16 PM
That's interesting. I'm surprised no one made it in the meantime if it's pretty straightforward.
I guess the positive side to that is that if it's too restrictive/limited in the next update, it shouldn't be hard to add in another avenue to do it

If you mean to have a hullmod be permanent on a ship and otherwise not removable, that is straightforward to do. Making a selected hullmod in the refit screen permanent upon selection for a cost (what I'm assuming you mean) would probably be much harder (never tried so I could be wrong though).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Fen on June 04, 2020, 10:06:05 PM
If you mean to have a hullmod be permanent on a ship and otherwise not removable, that is straightforward to do. Making a selected hullmod in the refit screen permanent upon selection for a cost (what I'm assuming you mean) would probably be much harder (never tried so I could be wrong though).

Yeah, I mean paying to make a hullmod into a permanent part of a ship.
So for example, paying 250,000 to add Military Subsystems to a ship as a built-in feature, like how some support ships have ECM, ECCM, and/or Relay mods as features.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 04, 2020, 10:11:23 PM
Yeah, I mean paying to make a hullmod into a permanent part of a ship.
So for example, paying 250,000 to add Military Subsystems to a ship as a built-in feature, like how some support ships have ECM, ECCM, and/or Relay mods as features.

Then at a guess considering the UI work it would take- even if the API hooks existed (which I'm not sure they do)... probably impossible currently? Alex generally takes a lot of extra effort to make new features moddable though, so Story Points likely won't be an exception there, at least not permanently. (Good things take time. Great things take even more time. :) )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: peeaa on June 05, 2020, 02:56:18 AM
How do I overwrite faction files of vanilla starsector and the faction files of other mods? I have all the faction files and the portraits done but I can't get the game the overwrite the old portraits from other mods or the vanilla game.

You can't override faction files of other mods. You just have to change the files in the mod itself (personal use only - do not publish the changes without author permission).

For vanilla, here is the implementation: (So the replace section is all one entry with commas separating each replaced file path. The final entry should not have a comma.

  "replace":[
          "data\\world\\factions\\pirates.faction",
          "data\\world\\factions\\neutral.faction",
          "data\\world\\factions\\hegemony.faction",
          "data\\world\\factions\\independent.faction",
          "data\\world\\factions\\player.faction",
          "data\\world\\factions\\sindrian_diktat.faction",
          "data\\world\\factions\\knights_of_ludd.faction",
          "data\\world\\factions\\luddic_church.faction",
          "data\\world\\factions\\luddic_path.faction",
          "data\\world\\factions\\persean_league.faction",
          "data\\world\\factions\\tritachyon.faction",
          "data\\world\\factions\\remnants.faction",
          "data\\world\\factions\\scavengers.faction",
          "data\\world\\factions\\lions_guard.faction",
          "data\\world\\factions\\derelict.faction",
          "data\\world\\factions\\poor.faction",
          "data\\world\\factions\\sleeper.faction"]

Thank you for the reply, I had the previous version of my mod done by manually replacing parts of other mods so I guess I'll have to stick with that. And personal use only ofc, from what I've seen by scrolling these forums starsector modding scene is way more strict with mod content usage than some other modding scenes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 05, 2020, 09:42:09 PM
I'm creating a proof-of-concept campaign feature where two temporary, random fleets are generated and the player uses one of them to fight the other. The player does not use their own ships or officers acquired in campaign.

Right now, I can display the fleets and launch a battle from a rules-based interaction dialog. But there are two problems:
- The player's campaign fleet is added to the temporary player fleet and available for deployment in-battle, even though the campaign fleet isn't added to the BattleAPI
- I don't know how to detect battle completion and display its outcome

So, my question is: Is it feasible to do this sort of thing purely within the rules-based dialog, and if so, how do I fix the above issues?
(I would prefer not to deal with the complexity of the regular fleet interaction dialog if I don't have to)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 06, 2020, 04:03:39 AM
Is there any simple way to override the effect of setPhase() disabling weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on June 06, 2020, 06:48:02 PM
Is there a way for a destroyed ship (a fighter) to not leave a husk when destroyed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 06, 2020, 07:02:38 PM
Is there a way for a destroyed ship (a fighter) to not leave a husk when destroyed?

I *think* I asked this before and no. (At least not at the time I asked- which was a long while ago.)

Though, setting the break probability to 100% and adding a bunch of break pieces helps slightly reduce beam/shot mitigation at the cost of performance iirc- if that is the use case in this instance.

(The other two questions before this I have no clue or I would have responded. Never tried either of them and the one time I tried to interpret the fleet gathering code for battles ended in a tactical retreat lol. ;) )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on June 06, 2020, 07:27:10 PM
I *think* I asked this before and no. (At least not at the time I asked- which was a long while ago.)

Though, setting the break probability to 100% and adding a bunch of break pieces helps slightly reduce beam/shot mitigation at the cost of performance iirc- if that is the use case in this instance.

(The other two questions before this I have no clue or I would have responded. Never tried either of them and the one time I tried to interpret the fleet gathering code for battles ended in a tactical retreat lol. ;) )
Oh, that's a shame. I was wondering cause I thought sometimes my fighters get literally vaporized when getting blown up, not leaving a wreck, and I thought it would be nice if it always happened like that. At least for this line of fighter I am trying to make.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 06, 2020, 09:37:06 PM
Oh, that's a shame. I was wondering cause I thought sometimes my fighters get literally vaporized when getting blown up, not leaving a wreck, and I thought it would be nice if it always happened like that. At least for this line of fighter I am trying to make.

I field a lot of fighters in my mod (3X that of vanilla at least) and it shouldn't be a problem to be honest. (Especially if beams are piercing- which is the primary downside to fighter wrecks from what I can tell.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on June 07, 2020, 04:45:05 AM
I'm creating a proof-of-concept campaign feature where two temporary, random fleets are generated and the player uses one of them to fight the other. The player does not use their own ships or officers acquired in campaign.

Right now, I can display the fleets and launch a battle from a rules-based interaction dialog. But there are two problems:
- The player's campaign fleet is added to the temporary player fleet and available for deployment in-battle, even though the campaign fleet isn't added to the BattleAPI
- I don't know how to detect battle completion and display its outcome

So, my question is: Is it feasible to do this sort of thing purely within the rules-based dialog, and if so, how do I fix the above issues?
(I would prefer not to deal with the complexity of the regular fleet interaction dialog if I don't have to)

No-one else replied, and my knowledge is limited, but from what I can see the Battle API receives a fleet from the FleetInteractionDialog, which also has code that handles the aftermath of the battle right up till the dialog box is closed.  My brain says you're stuck making your own interaction to do this - at least I would assume doing this without an interaction would be even more complicated somehow.

If there is a way to do this in rules without your own custom interaction/fleet dialog then I would also like to know! Working on my own dialogues for other stuff.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 07, 2020, 08:32:14 AM
Is there a way for a destroyed ship (a fighter) to not leave a husk when destroyed?

You need to run an every frame script that looks for the ships you want and tells the engine to remove them if they aren't alive.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 07, 2020, 09:49:46 AM
I'm creating a proof-of-concept campaign feature where two temporary, random fleets are generated and the player uses one of them to fight the other. The player does not use their own ships or officers acquired in campaign.

Right now, I can display the fleets and launch a battle from a rules-based interaction dialog. But there are two problems:
- The player's campaign fleet is added to the temporary player fleet and available for deployment in-battle, even though the campaign fleet isn't added to the BattleAPI
- I don't know how to detect battle completion and display its outcome

So, my question is: Is it feasible to do this sort of thing purely within the rules-based dialog, and if so, how do I fix the above issues?
(I would prefer not to deal with the complexity of the regular fleet interaction dialog if I don't have to)

I'd say that using SectorAPI.setPlayerFleet() (assumnig this is exposed in the current release?) to temporarily change what the player fleet is is your best bet. The implementation of BattleAPI checks whether a fleet is the player fleet in a number of places to figure out whether a side is the player side, etc.


Is there any simple way to override the effect of setPhase() disabling weapons?

There isn't, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on June 09, 2020, 12:12:08 PM
Sincere apologies for asking a question as broad as this, but -
I am trying to add an industry that behaves as campaign layer comm relay without actually adding a relay to the system.
The implementation of Campaign Objectives stumps me (there are two concurrent systems for handling them?)

To boil it down - is it possible to make a star system think it has a comm relay while it doesn't have one - and if yes, where do I start?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 09, 2020, 12:30:59 PM
There's only one system for it; I'm not sure what you mean. Perhaps you're also looking at the combat-level comm relays?

Take a look at CommRelayCondition and CommRelayEntityPlugin. The former does most of the work, the latter populates its list of relays.

The easiest thing would IMO for the industry to add/remove a hidden comm relay somewhere. You could also have a different custom entity function as a relay as long as its plugin was similar enough to CommRelayEntityPlugin - that is, as long as it adds the condition/adds the entity to the condition's list of relays.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 10, 2020, 10:03:08 PM
Is there anyway to directly modify the replacement rate % for carriers in combat? I saw some mults for fighter replacement but I dont think those are doing what I want
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 11, 2020, 12:28:36 AM
Is there anyway to directly modify the replacement rate % for carriers in combat? I saw some mults for fighter replacement but I dont think those are doing what I want

That should be what you use from my experience. What's your target implementation? I'll try and help. I don't think you can go below 30% replacement rate in general though for any individual carrier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 11, 2020, 03:00:19 AM
Hmm - something like:

String key = SINK_DATA_KEY + "_" + ship.getId();

And then using key instead of SINK_DATA_KEY in the rest of the method should do the job. I've changed it to this on my end, but for the moment you'd need to override the hullmod with your own implementation to get this effect.
I'm trying something like this for one of my mods that would also suffer this, but my tools for reasons outside of my control are... Notepad++. That's it XD.

When it tries to compile I get
"Unknown variable or type "ship""

I figure there's something else I'll have to import?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 11, 2020, 02:03:19 PM
Is there anyway to directly modify the replacement rate % for carriers in combat? I saw some mults for fighter replacement but I dont think those are doing what I want

That should be what you use from my experience. What's your target implementation? I'll try and help. I don't think you can go below 30% replacement rate in general though for any individual carrier.

I'm working on a hullmod that launches a drone from a carrier when a ship that has it gets close, and I just want to decrease the carriers replacement rate as the drone is repairing the ship..if you could help , i'd appreciate it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 11, 2020, 03:06:59 PM
I'm working on a hullmod that launches a drone from a carrier when a ship that has it gets close, and I just want to decrease the carriers replacement rate as the drone is repairing the ship..if you could help , i'd appreciate it

I think a way you could do this would be to set up a timer under:

Code
	@Override
public void advanceInCombat(ShipAPI ship, float amount) {

}

Then to periodically reduce replacement rate you would use something like:

Code
  
*(outside timer)*     
float reduction = 0f;
MutableShipStatsAPI stats = ship.getMutableStats();
*(outside timer)*

*(drone repairing returns true)*
*(inside timer)*

reduction = 10f;
stats.getFighterRefitTimeMult().modifyPercent(id, 100 - reduction);
*(increment timer)*

*(drone repairing returns true)*
reduction = 20f;
stats.getFighterRefitTimeMult().modifyPercent(id, 100 - reduction);
*(increment timer)*

etc, until:

 *(drone repairing returns false)*
 *(reset replacement rate)*
 *(reset timer)*
 reduction = 0f;

*(inside timer)*

Hopefully that make sense I'm not sure how well I explained it. Then you can use increments that fit the behavior you would like to see. For instance here I go by 10% with an implied timer of ~5 seconds to create roughly a 2% decay per second.

If you just want a flat decrease while repairing you wouldn't even really need the timer. That would more be like:

Code
while (drone repairing) {
    float reduction = 50f;
    ship.getMutableStats().getFighterRefitTimeMult().modifyPercent(id, reduction);
}

You might have to play around with the various modifiers to getFighterRefitTimeMult() to see what works the best. For instance to increase the replacement rate I use:

getFighterRefitTimeMult().modifyMult(id, 1f - REFIT_TIME_PERCENT / 100f);

Hope that helps! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 11, 2020, 07:06:50 PM
Thanks! I (think) it works; when I tried it replacement rate seemed to decrease faster after taking fighter casualties, its too bad I can't directly set the replacement rate % though. This should be good enough either way :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 11, 2020, 10:22:48 PM
I'm trying something like this for one of my mods that would also suffer this, but my tools for reasons outside of my control are... Notepad++. That's it XD.

When it tries to compile I get
"Unknown variable or type "ship""

I figure there's something else I'll have to import?

Ah that sucks an IDE is much easier to use with this sort of thing. If you link me the code I'll plug it in real quick and see what I find as it may be something simple.

Thanks! I (think) it works; when I tried it replacement rate seemed to decrease faster after taking fighter casualties, its too bad I can't directly set the replacement rate % though. This should be good enough either way :)

Glad that helped! There might be a method to set the refit rate as a flat amount. (I *think* this would essentially be your preferred way of setting replacement rate % directly but I don't think I've ever used it so I'm not sure.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheWetFish on June 13, 2020, 12:35:52 AM
Can we interact with the process of splitting a hulk into pieces?
Either overriding how it splits up or adding arbitrary shaped additional splits in it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on June 13, 2020, 01:59:13 AM
Pulse weapons are extremely deprecated so I'd recommend not using them. Unless you just mean adding a chargeup time  to a weapon firing? Or do you mean the (very, very old) "hold button to charge, release to fire" behavior?

It's the old behavior that I'm referencing, yes. I've been trying different script on some weapon so that their effect varies depending on the charge level before the shot (my mains attempts were : increasing the speed and range for a large kinetic railgun, increasing the explosive power and adding some AoE to a large explosive artillery, and more recently, I tried using the charge level to increase the size of the burst fired by a medium fragmentation weapon, a sort of volleygun which could either fire a few rounds at a time at a quick firerate, or a large batch of projectile if charged for some time).

Is there actually a way to make this work, even with scripting ? I don't really know how, maybe checking the charging rate to spot the frame where its decreasing, meaning that the fire button has been released ? But then, can I make a weapon fire by forcing its charge level to 1 ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on June 13, 2020, 02:30:43 AM
Hello,
What parameter do I add/remove/change in xml save file if I want Legio Infernalis market destroyed (alternatively susceptible to saturation bombardment and abandonment)?
I updated Tahlan mod so I could disables sieges, but there are plenty leftover Legio stations in hyperspace that cant be defeated (cant invade, saturate, destroy, nothing).
thank you

EDIT
actually better place for this question would be Nia Tahl's thread, sorry
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 13, 2020, 03:13:16 PM
How do I stop custom inbuilt weapons from dropping blueprints from, say, Tech Mining?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2020, 04:16:04 PM
It's the old behavior that I'm referencing, yes. I've been trying different script on some weapon so that their effect varies depending on the charge level before the shot (my mains attempts were : increasing the speed and range for a large kinetic railgun, increasing the explosive power and adding some AoE to a large explosive artillery, and more recently, I tried using the charge level to increase the size of the burst fired by a medium fragmentation weapon, a sort of volleygun which could either fire a few rounds at a time at a quick firerate, or a large batch of projectile if charged for some time).

Is there actually a way to make this work, even with scripting ? I don't really know how, maybe checking the charging rate to spot the frame where its decreasing, meaning that the fire button has been released ? But then, can I make a weapon fire by forcing its charge level to 1 ?

Hmm, offhand, I'm not quite sure. I mean, you could have the weapon script launch a custom effect/shot and have the normal weapon shot be entirely invisible, so that might be the way to go. Regardless, though, the ship AI won't be aware of it - either using this or defending against it - so it seems... well, it could be alright in some specific circumstances, but you'd want to be very careful it doesn't become something that can easily cheese the AI because it doesn't know about it.

How do I stop custom inbuilt weapons from dropping blueprints from, say, Tech Mining?

SYSTEM hint in the csv should do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on June 13, 2020, 05:05:25 PM
Is there a method I could grab a Ship's Tech Type(or Design) through the applyEffectsBeforeShipCreation?
Code
    @Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        if ("Tri-Tachyon".equals(stats.getVariant().getHullSpec().getManufacturer())) {
            stats.getFluxCapacity().modifyPercent(id, 500f);
        }
    }
Gave me mixed results when the Tri-Tachyon Buffalo didn't get the increased flux capacity unless the original Buffalo was designed by Tri-Tachyon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2020, 07:59:27 PM
Hmm, that's odd, since that works for me - just pasting your code into the Heavy Armor hullmod makes it give +500% flux to the Tri-Tachyon Buffalo version (and not give it to the other ones).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on June 13, 2020, 08:18:42 PM
Hi, is there a way to 'hook' into events, like when a battle finishes? By this I mean I want to run a function when a player finishes a battle (AI battles not necessary).

Edit: And a second question - is it possible to make a skill (like Power Grid Modularion, Combat Endurace, Carrier Command, etc) but will only apply to officers? In other words, a skill that won't appear on the player's character sheet, but will on an officer's.

Edit 2: What are the conditions that affect the AI's decision to use their missiles? Because I've set a frigate with missiles that have DO_NOT_AIM, DO_NOT_CONSERVE hints and it simply refuses to fire them no matter what. It's got 80 ammo too so I don't get why it behaves like that. Do the tags do anything to influence this? Does the fact that the hardpoints don't point to the enemy affect this? But then I'd assumed "DO_NOT_AIM"  would account for that. Simply put, I just want the AI to use all of their missile ammo with no regard, like they do with Swarmer SRMs. Update: This problem seems to happen when testing against frigates. I noticed the Squall had the tag USE_VS_FRIGATES, but even after giving this tag to my missiles, they still don't  fire quite as vigorously at a Cerberus as they do an Enforcer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on June 14, 2020, 02:34:17 AM
Hmm, offhand, I'm not quite sure. I mean, you could have the weapon script launch a custom effect/shot and have the normal weapon shot be entirely invisible, so that might be the way to go. Regardless, though, the ship AI won't be aware of it - either using this or defending against it - so it seems... well, it could be alright in some specific circumstances, but you'd want to be very careful it doesn't become something that can easily cheese the AI because it doesn't know about it.

Oh, I see how that could work. I already played a bit with projectile spawning so that wouldn't be too hard to script. Isn't there a way to script special weapon AI ? My guess about this is that the AI will always go for the full charged shot, so, while it won't be able to fire weaker shot at a faster rate, it'll still deal the same average DPS over a complete combat length ?
Hmm, so the AI isn't alawys aware of script spawned projectiles ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 14, 2020, 08:44:37 AM
Is there a way to set up a campaign battle such that the player can always use the ESC menu to exit and return to the fleet interaction dialog (instead of being kicked back to main menu), like devmode does?

Hi, is there a way to 'hook' into events, like when a battle finishes? By this I mean I want to run a function when a player finishes a battle (AI battles not necessary).
BaseCampaignEventListener has methods reportBattleOccured, reportBattleFinished
then you check the BattleAPI param for whether the player was involved in the battle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on June 14, 2020, 11:26:31 AM
Hmm, that's odd, since that works for me - just pasting your code into the Heavy Armor hullmod makes it give +500% flux to the Tri-Tachyon Buffalo version (and not give it to the other ones).
That's weird... I'll have to see why.. maybe something didn't compile correctly.

High-Tech Manufacturer doesn't exist, does it? (design type: high-tech)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 14, 2020, 11:49:08 AM
Oh, I see how that could work. I already played a bit with projectile spawning so that wouldn't be too hard to script. Isn't there a way to script special weapon AI ? My guess about this is that the AI will always go for the full charged shot, so, while it won't be able to fire weaker shot at a faster rate, it'll still deal the same average DPS over a complete combat length ?
Hmm, so the AI isn't alawys aware of script spawned projectiles ?

You could script autofire AI, but not when the weapon is fired by the ship "manually". I have no idea what the AI will do with a PULSE weapon - that's not supported, so it might do as you surmise, might shoot with random charge levels, or might not shoot at all (i.e. it might just hold down the button and keep it at full charge).

The AI only cares about more dangerous projectiles; for other stuff it'll (depending on various factors) just look at the weapon - where it's facing, whether it's firing, etc.

Is there a way to set up a campaign battle such that the player can always use the ESC menu to exit and return to the fleet interaction dialog (instead of being kicked back to main menu), like devmode does?

Hmm - none that I can think of, unfortunately - sorry!

High-Tech Manufacturer doesn't exist, does it? (design type: high-tech)

The tech type can be an arbitrary string, so I'm not sure the question makes sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mongreal on June 14, 2020, 01:05:12 PM
You could script autofire AI, but not when the weapon is fired by the ship "manually". I have no idea what the AI will do with a PULSE weapon - that's not supported, so it might do as you surmise, might shoot with random charge levels, or might not shoot at all (i.e. it might just hold down the button and keep it at full charge).

The AI only cares about more dangerous projectiles; for other stuff it'll (depending on various factors) just look at the weapon - where it's facing, whether it's firing, etc.

I'll try to make it so that the weapon always fire when reaching the max charge level, so, as long as the AI at least try to fire it, something should happen (hopefully ?)
While I'm busy trying to make this work, another tricky subject : Is there a way to use a station module as a "shield" for it's parent ? As in, making it so that it can't take real damage, but transfer the damage taken as shield damage (hard flux) on the parent ? It look easier with module since they already use collisions and bounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on June 18, 2020, 12:21:22 PM
Hullmod query - I am making a missile ammo hullmod that I want to be incompatible with Expanded Missile Racks

I can of course prevent the player from adding it if Expanded Missile Racks is present using Public Boolean isApplicableToShip, but I'm unsure how to achieve the opposite without replacing the vanilla 'missleracks' java class, which does not have any incompatibilities.

Is there something I can do in applyEffectsBeforeShipCreation of my new hullmod that might prevent EMR being selectable? or some other solution?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 18, 2020, 01:27:12 PM
Hullmod query - I am making a missile ammo hullmod that I want to be incompatible with Expanded Missile Racks

I can of course prevent the player from adding it if Expanded Missile Racks is present using Public Boolean isApplicableToShip, but I'm unsure how to achieve the opposite without replacing the vanilla 'missleracks' java class, which does not have any incompatibilities.

Is there something I can do in applyEffectsBeforeShipCreation of my new hullmod that might prevent EMR being selectable? or some other solution?

Check out MagicLib https://fractalsoftworks.com/forum/index.php?topic=13718.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 18, 2020, 03:33:35 PM
If I was setting up an interval tracker in:

Code
	@Override
public void advanceInCombat(ShipAPI ship, float amount)

 - and subtracting 1 from the int tracker each advance until it reaches 0- what value for the int would equal 1 in combat second?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 18, 2020, 03:40:28 PM
Could you show a bit more code? This doesn't sound right on several fronts.

Of note: "amount" is the number of seconds passed in the frame - so, it'd be ~0.0167 at 60 fps, double that at 30 fps, and so on. You shouldn't rely on a specific amount of time passing each time the method is called since it's frame rate dependent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 18, 2020, 04:00:23 PM
Could you show a bit more code? This doesn't sound right on several fronts.

Of note: "amount" is the number of seconds passed in the frame - so, it'd be ~0.0167 at 60 fps, double that at 30 fps, and so on. You shouldn't rely on a specific amount of time passing each time the method is called since it's frame rate dependent.

Ah ok got it. Here is the entire class. Any help with the tracker is much appreciated so the enemy ship doesn't spout a new line of popup text every time it enters the aura (faster ships move in and out frequently at times. I also want to use this to play a sound effect- so that being spammed in the same way would also get annoying.

(As a side note, I just coded the "rotating logic" and haven't tested it yet (very unfamiliar with this kind of thing and it is a first attempt) but I know the graphic will render. If it looks like that won't work or is a poor way to do it let me know. I'm not sure if here is the best way to do it or in the renderer class itself. :D )

Code
public class CHM_adamantine_consortium extends BaseHullMod {

private static final String ID = "CHM_adamantine_consortium";
private static final float MALFUNCTION_PROB = 0.05f;
private static final float CRIT_MALFUNCTION_PROB = 0.5f;

private static int INTERVAL_TRACKER = 0;
private static boolean IS_ROTATING = false;

// Logging components.
private static final Logger LOG = Global.getLogger(CHM_adamantine_consortium.class);

private static Map<HullSize, Float> mag = new HashMap<>();
static {
mag.put(HullSize.FRIGATE, 0.4f);
mag.put(HullSize.DESTROYER, 0.6f);
mag.put(HullSize.CRUISER, 0.8f);
mag.put(HullSize.CAPITAL_SHIP, 1f);
}

@Override
public void advanceInCombat(ShipAPI ship, float amount) {
CombatEngineAPI combatEngine = Global.getCombatEngine();
if (!combatEngine.getCustomData().containsKey(ID)) {
combatEngine.getCustomData().put(ID, new HashMap<>());
}
if (INTERVAL_TRACKER > 0) {
    INTERVAL_TRACKER -= 1;
        }
try {
Map<ShipAPI, DreadAuraEffectOrigin> ships = (Map) combatEngine.getCustomData().get(ID);
            for (ShipAPI enemy : CombatExtensionsKt.getNearbyEnemies(ship, 1500f)) {
                if (!enemy.isDrone() && !enemy.isFighter() && enemy.isAlive()) {
                    DreadAuraEffectOrigin aura = ships.get(enemy);
                    if (aura == null) {
                        aura = new DreadAuraEffectOrigin();
                        ships.put(enemy, aura);
                        LOG.info("Adding ship: " + enemy.getName() + " to ships map.");
                    }
                    MutableShipStatsAPI stats = enemy.getMutableStats();
                    float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
                    stats.getWeaponMalfunctionChance().modifyFlat(ID, MALFUNCTION_PROB * effect);
                    stats.getCriticalMalfunctionChance().modifyFlat(ID, CRIT_MALFUNCTION_PROB * effect);
                    aura.alpha = 1f;
                    createAura(aura, enemy, amount);
                    if (!aura.text && INTERVAL_TRACKER == 0) {
                        //add text popup logic here
                        LOG.info("Text would popup here.");
                        aura.text = true;
                        INTERVAL_TRACKER = 1000;
                    }
                }
            }
            for (ShipAPI enemy : ships.keySet()) {
                if (enemy != null && (!enemy.isAlive() || MathUtils.getDistance(ship, enemy) > 1500)) {
                    DreadAuraEffectOrigin aura = ships.get(enemy);
                    aura.resetAura();
                    if (aura.text) {
                        LOG.info("Text boolean has been reset.");
                    }
                    aura.text = false;
                }
            }
} catch (ClassCastException e) {
LOG.error(e);
            throw new RuntimeException(e);
}
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + "%";
return null;
}

public boolean isApplicableToShip(ShipAPI ship) {
return ship != null && ship.getCaptain().isPlayer();
}


private static void createAura(DreadAuraEffectOrigin aura, ShipAPI origin, float amount) {
float radius;
if (!IS_ROTATING) {
            radius = origin.getShieldRadiusEvenIfNoShield() * 1.5f + 50f;
            aura.sprite.setSize(radius, radius);
            aura.sprite.setAlphaMult(aura.alpha);
            aura.sprite.setAngle(aura.angle);
            aura.angle += 0.1f * amount;
            if (aura.angle > 10000f) {
                aura.angle -= 10000f;
            }
            IS_ROTATING = true;
        } else {
    aura.sprite.setAngle(aura.angle);
    aura.angle += 1;
        }
}

public final static class DreadAuraEffectOrigin {
public float alpha;
public float angle;
public boolean text;
public SpriteAPI sprite;


public DreadAuraEffectOrigin() {
alpha = 0f;
angle = 0f;
text = false;
sprite = Global.getSettings().getSprite("misc", "dread_aura");
}

public void resetAura() {
    IS_ROTATING = false;
sprite.setAlphaMult(0f);
alpha = 0f;
}
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 18, 2020, 04:23:02 PM
Ah, I see. Take a look at:
com.fs.starfarer.api.impl.hullmods.PeriodicMissileReload

It uses an IntervalUtil; you'll want to adapt is somewhat (you probably just want to have, like, a "float secondsRemaining" and subtract amount from it every frame).

Basically the issues with your current approach are:
1) Using a static variable for INTERVAL_TRACKER, meaning it'll get shared across different instances of this hullmod, will persist across save re-loads, etc
2) Subtracting a fixed amount, but I already talked about that in the previous post.

The way to do handle 1) is to, instead, store data in the combat engine's getCustomData() map, which is what PeriodicMissileReload does.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 18, 2020, 06:24:54 PM
Ah, I see. Take a look at:
com.fs.starfarer.api.impl.hullmods.PeriodicMissileReload

It uses an IntervalUtil; you'll want to adapt is somewhat (you probably just want to have, like, a "float secondsRemaining" and subtract amount from it every frame).

Basically the issues with your current approach are:
1) Using a static variable for INTERVAL_TRACKER, meaning it'll get shared across different instances of this hullmod, will persist across save re-loads, etc
2) Subtracting a fixed amount, but I already talked about that in the previous post.

The way to do handle 1) is to, instead, store data in the combat engine's getCustomData() map, which is what PeriodicMissileReload does.

Ah thanks a ton! I didn't even think about it persisting, yeah. In this use case it *probably* wouldn't effect things too much since only the flagship has this hullmod and even persisting between combat sessions it would probably tick down before it reached any enemies- but this is a much better way and its better to be safe about that sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DecoyGrenadeOut on June 19, 2020, 03:48:36 AM
Is it possible to make a mod that essentially notifies you when a given weapon group is able to all fire in game and/or display the ammo count of weapon in the group? I have quite some trouble timing weapons with long cool down (AM blaster) and strike weapon like AP lasers and it would be great if it's possible to have something like that in the game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 19, 2020, 05:04:26 AM
So I'm at a loss trying to get Shared Flux to work on a individual ship basis.
I tried:
Code
package data.scripts;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.impl.hullmods.SharedFluxSink;

public class SharedShipFluxSink extends SharedFluxSink {

@Override
public void advanceInCombat(ShipAPI ship, float amount) {
super.advanceInCombat(ship, amount);

if (!ship.isAlive()) return;

CombatEngineAPI engine = Global.getCombatEngine();

String key = SINK_DATA_KEY + "_" + ship.getId();

FluxSinkData data = (FluxSinkData) engine.getCustomData().get(key);
if (data == null) {
data = new FluxSinkData();
engine.getCustomData().put(key, data);

for (ShipAPI module : ship.getChildModulesCopy()) {
if (module.getStationSlot() == null || !module.isAlive() || !Misc.isActiveModule(module)) continue;
float d = module.getMutableStats().getFluxDissipation().getModifiedValue();
d *= FLUX_FRACTION;
data.dissipation.put(module, d);
}
}
}
}
But then I get
Code
java.lang.RuntimeException: Error compiling [data.scripts.SharedShipFluxSink]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/SharedShipFluxSink.java', Line 37, Column 26: Member with "/*default*/" access cannot be accessed from type "data.scripts.SharedShipFluxSink".
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 19, 2020, 03:07:08 PM
Ok, so I implemented the interval (actually quite useful to prevent text popups from happening simultaneously when under the aura) and the map in the combat engines data to prevent persistence.

I wanted to do the same thing to the rotation Boolean in case I want to implement boss ships with this hullmod in the future so that nothing important will persist between the two entities.

But... IntelliJ is throwing a warning that the Boolean is "always false" or "always true" in this code: (And also says the initialization from  "(Boolean) combatEngine.getCustomData().get(rotatingKey);" is redundant in the last section)

Code
	private static void createAura(DreadAuraEffectOrigin aura, ShipAPI origin, CombatEngineAPI combatEngine, float amount) {
float radius;
        String rotatingKey = IS_ROTATING_KEY + "_" + origin.getId();
        Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
        if (isRotating == null) {
            isRotating = false;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
        }
if (!isRotating) {
            radius = origin.getShieldRadiusEvenIfNoShield() * 1.5f + 50f;
            aura.sprite.setSize(radius, radius);
            aura.sprite.setAlphaMult(aura.alpha);
            aura.sprite.setAngle(aura.angle);
            aura.angle += 0.1f * amount;
            if (aura.angle > 10000f) {
                aura.angle -= 10000f;
            }
            isRotating = true;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
            LOG.info("Aura created. Rotating logic engaged.");
        } else {
    aura.sprite.setAngle(aura.angle);
    aura.angle += 1;
        }
}

public final static class DreadAuraEffectOrigin {
public float alpha;
public float angle;
public boolean textPopupHappened;
public SpriteAPI sprite;

public DreadAuraEffectOrigin() {
alpha = 0f;
angle = 0f;
            textPopupHappened = false;
sprite = Global.getSettings().getSprite("misc", "dread_aura");
}

public void resetAura(CombatEngineAPI combatEngine, ShipAPI origin) {
            String rotatingKey = IS_ROTATING_KEY + "_" + origin.getId();
            Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
            isRotating = false;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
sprite.setAlphaMult(0f);
alpha = 0f;
}
}

 -  is this IntelliJ getting confused because of the proprietary API? Or am I doing something wrong here and the Boolean is actually not getting updated in the map as intended? Sorry if this is obvious but just making sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 19, 2020, 03:29:50 PM
Kind of need to know which lines it's showing which warnings for. That said, you've got:

Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
isRotating = false;

Which seems like leftover debug code or some such?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 19, 2020, 04:16:30 PM
Kind of need to know which lines it's showing which warnings for.

I'm probably just not understanding maps correctly to be honest.

From:
Code
        Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
        if (isRotating == null) {
            isRotating = false;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
        }
The line for the warning "is always false":
Code
            combatEngine.getCustomData().put(rotatingKey, isRotating);

From:
Code
		if (!isRotating) {
            radius = origin.getShieldRadiusEvenIfNoShield() * 1.5f + 50f;
            aura.sprite.setSize(radius, radius);
            aura.sprite.setAlphaMult(aura.alpha);
            aura.sprite.setAngle(aura.angle);
            aura.angle += 0.1f * amount;
            if (aura.angle > 10000f) {
                aura.angle -= 10000f;
            }
            isRotating = true;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
            LOG.info("Aura created. Rotating logic engaged.");
        } else {

The line for "is always true":
Code
            combatEngine.getCustomData().put(rotatingKey, isRotating);

-----------------------------------------------------------------------------------------------------------------------------
That said, you've got:

Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
isRotating = false;

Which seems like leftover debug code or some such?

Er, can you explain more? I'm not getting it, sorry. :( The idea here is that I initially check for the Boolean to be present in the data map (by the key). I chose Boolean since it can be null, and when it is null because the key doesn't exist in the map, I set it to false as a default and then (theoretically) re-add the Boolean to the map under the same key using:

Code
            combatEngine.getCustomData().put(rotatingKey, isRotating); // So it should be false now instead of null is the idea. I assume putting the same key into the map with a new value overrides it?

So, the next time         Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey); - is called it should return false instead of null. (createAura() runs under:    public void advanceInCombat(ShipAPI ship, float amount) so it should run every frame.)

After the Aura is created using:

Code
		if (!isRotating) {
            radius = origin.getShieldRadiusEvenIfNoShield() * 1.5f + 50f;
            aura.sprite.setSize(radius, radius);
            aura.sprite.setAlphaMult(aura.alpha);
            aura.sprite.setAngle(aura.angle);
            aura.angle += 0.1f * amount;
            if (aura.angle > 10000f) {
                aura.angle -= 10000f;
            }
            isRotating = true;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
            LOG.info("Aura created. Rotating logic engaged.");

 -  the map is again overridden with a "true" instead of "false"

This way, the next frame "if (!isRotating)" will fail and so:

Code
        } else {
    aura.sprite.setAngle(aura.angle);
    aura.angle += 1;
        }

- will run instead. When the aura is "removed" the map should again set the value to "false" under the rotating key. See:

Code
		public void resetAura(CombatEngineAPI combatEngine, ShipAPI origin) {
            String rotatingKey = IS_ROTATING_KEY + "_" + origin.getId();
            Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
            isRotating = false;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
sprite.setAlphaMult(0f);
alpha = 0f;
}

(Hope this makes sense lol! I'm probably not doing this the optimal way.  :-[ )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 19, 2020, 04:54:05 PM
It's a bit of a strange warning - I mean, what it's saying is 100% correct, the variable IS going to always be true (or false) in the places where it warns that's the case, but I'm not sure *why* this merits a warning.

That said, code like this:
Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
isRotating = false;
combatEngine.getCustomData().put(rotatingKey, isRotating);

Why are you doing that instead of just:
combatEngine.getCustomData().put(rotatingKey, false);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 19, 2020, 05:08:58 PM
It's a bit of a strange warning - I mean, what it's saying is 100% correct, the variable IS going to always be true (or false) in the places where it warns that's the case, but I'm not sure *why* this merits a warning.

That said, code like this:
Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
isRotating = false;
combatEngine.getCustomData().put(rotatingKey, isRotating);

Why are you doing that instead of just:
combatEngine.getCustomData().put(rotatingKey, false);

My guess is that it doesn't understand that advanceInCombat() is actually run every frame? The warning is more of a "hey this isn't necessary" rather than a "this will cause problems" with possibly the assumption that if you were counting on the variable being changed it would alert you to the fact that it isn't. Usually this isn't shown if the IDE recognizes that the boolean is set somewhere else. (In this case in the next iteration of the EveryFrameScript.

As far as the second one, I just wasn't being efficient. Originally it stemmed from the idea of "if (!isRotating) {}" - being checked after  "Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);" - where in the first iteration/frame "isRotating" could be null and throw an exception unless I explicitly set it to false - even though the map contains an actual boolean value.

But I can just change it to: "if (!(Boolean) combatEngine.getCustomData().get(rotatingKey)) {}" - so that it's guaranteed to not be null (since the earlier if statement would catch that and set the map correctly).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 19, 2020, 07:31:23 PM
I think you might be operating under some misapprehension about how stuff works in Java. I mean in the resetAura() method, why not just set the map entry to false directly? Getting the value and storing it in a local variable and then changing that local variable isn't inefficient, it's more just completely unnecessary/pointless, if that makes sense.

What I mean is this:
public void resetAura(CombatEngineAPI combatEngine, ShipAPI origin) {
            String rotatingKey = IS_ROTATING_KEY + "_" + origin.getId();
            Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
            isRotating = false;
            combatEngine.getCustomData().put(rotatingKey, isRotating);
            sprite.setAlphaMult(0f);
            alpha = 0f;
}

Should just be:
public void resetAura(CombatEngineAPI combatEngine, ShipAPI origin) {
            combatEngine.getCustomData().put(rotatingKey, false);
            sprite.setAlphaMult(0f);
            alpha = 0f;
}

There's no functional difference. If you're thinking there is, that's the "misapprehension", so if you explain what you're thinking, I can hopefully clear it up. Edit: or do you just mean it was a copy-paste gone a bit bad? Just trying to clear it up!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 19, 2020, 10:49:13 PM
Edit: or do you just mean it was a copy-paste gone a bit bad? Just trying to clear it up!

This yeah. XD I was sort of copy pasting the concept from the ships data map- which requires the local object since the data map's value is a map itself.

That being said, even for a primitive if I needed to reassign the value from the data map multiple times without needing to add it back in the map, having a local variable is necessary so I might default to it anyway to be honest - especially if I'm unsure of the exact scope of the class at the start. Imo, it can also be "cleaner" from the perspective of read-ability to do things this way. Definitely not in this case, but you get the idea.

The IDE highlights all instances of variables when clicking on any one instance so that can be invaluable to me for times when the code gets complex. You can also do this with objects/object methods, sure, but if multiple objects of the same class use the same method for different values or the object is the same instance of the class but uses an individual method for different values, etc, it can get trickier/misleading to encompass a single value and its use in the code across the whole class using this technique. So that's another reason I would be tempted to go the local variable route anyway. At least initially. (My old team lead and a couple of teachers I had also hated anything hardcoded so I'm probably a little brainwashed by now too.)  :D

In the case of the rotation logic, though, once the local variable was just *sitting there* from the copy paste I was kind of "hardwired" to just use it lol. So I set up the if statement to check the local variable instead of realizing immediately that it would be the only instance of that engine data call in the actual logic. Read-ability doesn't matter there and so it makes much more sense to just skip the local variable all together for that use case and directly add it to the engine data - especially since each assignment requires an update to the data map anyway like you pointed out. (Unlike the ships data map.)

Still, after that first implementation I definitely went too "copy paste crazy" with it lol - which is sloppy. I tend to take an iterative approach to coding and likely would have caught it in the clean up phase. I actually already had it looking like your example before I saw this post due to your earlier comment and by catching the fact that I could directly call the value in the if statement - which made me go "oh this could be way cleaner than it is."

Basically, I make new code as efficient as I can while ensuring functionality and trying to think down the line of flexibility for use, then go back over it and think to myself "how can I scrape out anything unnecessary?" - which can sometimes even cause refactoring of the logic if I notice I can do something in a more efficient way that I didn't initially catch. For instance, if I feel a code block is too big and could be simplified with private helper methods, etc. That one in particular somewhat helps prevent the above use of instance highlighting from being as necessary so I usually don't regret it, hah. That's kind of how my thought process works if that makes sense. ;D

Anyway, thanks for taking the time you did to respond I always appreciate it.

Here's the updated code. (In a spoiler because this post is already huge.) Feel free to poke more holes if you see them as it really helps me learn! I also have a lot more to add to this class, so the more efficient it is the better!

Spoiler
Code
public class CHM_adamantine_consortium extends BaseHullMod {

private static final String ID = "CHM_adamantine_consortium";
private static final float MALFUNCTION_PROB = 0.05f;
private static final float CRIT_MALFUNCTION_PROB = 0.5f;

    public static String TEXT_POPUP_INTERVAL_KEY = "text_popup_interval_key";
public static String IS_ROTATING_KEY = "rotating_key";

// Logging components.
private static final Logger LOG = Global.getLogger(CHM_adamantine_consortium.class);

private static Map<HullSize, Float> mag = new HashMap<>();
static {
mag.put(HullSize.FRIGATE, 0.4f);
mag.put(HullSize.DESTROYER, 0.6f);
mag.put(HullSize.CRUISER, 0.8f);
mag.put(HullSize.CAPITAL_SHIP, 1f);
}

    public static class PeriodicTextPopupTracker {
        IntervalUtil interval = new IntervalUtil(8f, 12f);
    }

@Override
public void advanceInCombat(ShipAPI ship, float amount) {
CombatEngineAPI combatEngine = Global.getCombatEngine();
if (!combatEngine.getCustomData().containsKey(ID)) {
combatEngine.getCustomData().put(ID, new HashMap<>());
}
        String key = TEXT_POPUP_INTERVAL_KEY + "_" + ship.getId();
        PeriodicTextPopupTracker textTracker = (PeriodicTextPopupTracker) combatEngine.getCustomData().get(key);
        if (textTracker == null) {
            textTracker = new PeriodicTextPopupTracker();
            combatEngine.getCustomData().put(key, textTracker);
        }
        textTracker.interval.advance(amount);
try {
Map<ShipAPI, DreadAuraEffectOrigin> ships = (Map) combatEngine.getCustomData().get(ID);
            for (ShipAPI enemy : CombatExtensionsKt.getNearbyEnemies(ship, 1500f)) {
                if (!enemy.isDrone() && !enemy.isFighter() && enemy.isAlive()) {
                    DreadAuraEffectOrigin aura = ships.get(enemy);
                    if (aura == null) {
                        aura = new DreadAuraEffectOrigin();
                        ships.put(enemy, aura);
                        LOG.info("Adding ship: " + enemy.getName() + " to ships map.");
                    }
                    MutableShipStatsAPI stats = enemy.getMutableStats();
                    float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
                    stats.getWeaponMalfunctionChance().modifyFlat(ID, MALFUNCTION_PROB * effect);
                    stats.getCriticalMalfunctionChance().modifyFlat(ID, CRIT_MALFUNCTION_PROB * effect);
                    aura.alpha = 1f;
                    createAura(aura, enemy, combatEngine, amount);
                    if (!aura.textPopupHappened && textTracker.interval.intervalElapsed()) {
                        // Scared text popup here.
                        LOG.info("Text would popup here.");
                        aura.textPopupHappened = true;
                    }
                }
            }
            for (ShipAPI enemy : ships.keySet()) {
                if (enemy != null && (!enemy.isAlive() || MathUtils.getDistance(ship, enemy) > 1500)) {
                    DreadAuraEffectOrigin aura = ships.get(enemy);
                    aura.resetAura(combatEngine, enemy);
                    if (aura.textPopupHappened && textTracker.interval.intervalElapsed()) {
                        // Relief text popup here.
                        LOG.info("Text boolean has been reset.");
                    }
                    aura.textPopupHappened = false;
                }
            }
} catch (ClassCastException e) {
LOG.error(e);
            throw new RuntimeException(e);
}
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + "%";
return null;
}

public boolean isApplicableToShip(ShipAPI ship) {
return ship != null && ship.getCaptain().isPlayer();
}


private static void createAura(DreadAuraEffectOrigin aura, ShipAPI origin, CombatEngineAPI combatEngine, float amount) {
float radius;
        String rotatingKey = IS_ROTATING_KEY + "_" + origin.getId();
        Boolean isRotating = (Boolean) combatEngine.getCustomData().get(rotatingKey);
        if (isRotating == null) {
            combatEngine.getCustomData().put(rotatingKey, false);
        }
if (!(Boolean) combatEngine.getCustomData().get(rotatingKey)) {
            radius = origin.getShieldRadiusEvenIfNoShield() * 1.5f + 50f;
            aura.sprite.setSize(radius, radius);
            aura.sprite.setAlphaMult(aura.alpha);
            aura.sprite.setAngle(aura.angle);
            aura.angle += 0.1f * amount;
            if (aura.angle > 10000f) {
                aura.angle -= 10000f;
            }
            combatEngine.getCustomData().put(rotatingKey, true);
            LOG.info("Aura created. Rotating logic engaged.");
        } else {
    aura.sprite.setAngle(aura.angle);
    aura.angle += 1;
        }
}

public final static class DreadAuraEffectOrigin {
public float alpha;
public float angle;
public boolean textPopupHappened;
public SpriteAPI sprite;

public DreadAuraEffectOrigin() {
alpha = 0f;
angle = 0f;
            textPopupHappened = false;
sprite = Global.getSettings().getSprite("misc", "dread_aura");
}

public void resetAura(CombatEngineAPI combatEngine, ShipAPI origin) {
            String rotatingKey = IS_ROTATING_KEY + "_" + origin.getId();
            combatEngine.getCustomData().put(rotatingKey, false);
sprite.setAlphaMult(0f);
alpha = 0f;
}
}
}

[close]


*EDIT* Tiny nitpick here, but for the sake of other modders looking at this:

Should just be:
public void resetAura(CombatEngineAPI combatEngine, ShipAPI origin) {
            combatEngine.getCustomData().put(rotatingKey, false);
            sprite.setAlphaMult(0f);
            alpha = 0f;
}

 - is missing:

Code
            String rotatingKey = IS_ROTATING_KEY + "_" + origin.getId();

Since that is dependent upon the origin as a safeguard, and "rotatingKey" is not global and is not passed into the method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 20, 2020, 03:47:26 PM
Gotcha! And, yeah, you definitely want it in a variable if it's used multiple times (or even once); just that one case looked ... odd. Like sometimes people will do that if they think setting the variable will somehow affect the contents of the map or some such, wanted to make sure that wasn't the case here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 20, 2020, 04:55:52 PM
Gotcha! And, yeah, you definitely want it in a variable if it's used multiple times (or even once); just that one case looked ... odd. Like sometimes people will do that if they think setting the variable will somehow affect the contents of the map or some such, wanted to make sure that wasn't the case here.

Haha yeah I saw it and went *facepalm* but that's the risk when you post code publicly! :P And thanks for the help in case I was misunderstanding. There are plenty of times where that likely is the case.

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

Ok, so new question that isn't time sensitive at all, I just want to confirm my logic and make sure I'm not missing something because I plan on writing a tutorial about it.

In regards to custom data in the faction file, I know how to use it with rules when its a single value.

In this use case, however, I want a full object with a set of values that I use in code to do various manipulations. The main thing I want to know is how resilient the code is to missing values in the faction file. I'm trying to make this as flexible to customize as possible.

For example, having:

JSON in faction file under "custom":

Code
		"dreadAuraData":{
"resistant":true,
"immune":true,
"isAI":false,
"saysText":true,
},

  - should work just as well (without crashes) as:

Code
		"dreadAuraData":{
"immune":true,
},

 - and only provide the relevant functionality.

What I have code wise:

Relevant globals across both classes:

Code
	private static DreadAuraFactionDataManager AURA_MANAGER = new DreadAuraFactionDataManager();

    private static String FACTION_AURA_DATA_KEY = "dreadAuraData";
    private static String FACTION_AURA_IMMUNE_KEY = "immune";
    private static String FACTION_AURA_RESISTANT_KEY = "resistant";

Code in hullmod class to get and manipulate the data based upon the settings that are found in the faction file:

Code
                    JSONObject factionAuraData = AURA_MANAGER.getFactionAuraData(enemy);
                    if (AURA_MANAGER.checkFactionImmunity(factionAuraData)) {
                        float malfunctionChance = AURA_MANAGER.calculateAuraMalfunctionStrength(factionAuraData, ship, enemy);
                        float critMalfunctionChance = AURA_MANAGER.calculateAuraCritMalfunctionStrength(factionAuraData, ship, enemy);

                        // you can ignore below here - just wanted to enclose the whole if code block.
                        MutableShipStatsAPI stats = enemy.getMutableStats();
                        float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
                        stats.getWeaponMalfunctionChance().modifyFlat(ID, malfunctionChance * effect);
                        stats.getCriticalMalfunctionChance().modifyFlat(ID, critMalfunctionChance * effect);
                        aura.alpha = 1f;
                        createAura(aura, enemy, combatEngine, amount);
                        if (!aura.textPopupHappened && textTracker.interval.intervalElapsed()) {
                            // Scared text popup here.
                            LOG.info("Text would popup here.");
                            aura.textPopupHappened = true;
                        }
                    }

Supporting helper class relevant methods:

Code
    public JSONObject getFactionAuraData(ShipAPI origin) {
        JSONObject factionCustomData = origin.getCaptain().getFaction().getCustom();
        if (factionCustomData == null) {
            return null;
        }
        try {
            return factionCustomData.getJSONObject(FACTION_AURA_DATA_KEY);
        } catch (JSONException e) {
            LOG.error(e);
            throw new RuntimeException(e);
        }
    }

    public boolean checkFactionImmunity(JSONObject factionAuraData) {
        if (factionAuraData != null) {
            try {
                return (!factionAuraData.has(FACTION_AURA_IMMUNE_KEY) || factionAuraData.getBoolean(FACTION_AURA_IMMUNE_KEY));
            } catch (JSONException e) {
                LOG.error(e);
                throw new RuntimeException(e);
            }
        } else {
            return true;
        }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 20, 2020, 05:19:09 PM
JSONObject has getXXXX and optXXXX methods for getting data out. The get variety throw an exception when the value is not specified. The opt variety takes a default value as a second parameter and returns that when the value is not specified. So:

json.getBoolean("resistant");  // will throw an exception when "resistant" is not specified
json.optBoolean("resistant", false); // will return false when "resistant" is not specified

This also seems like it'd be fairly straightforward to test...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 20, 2020, 05:28:24 PM
JSONObject has getXXXX and optXXXX methods for getting data out. The get variety throw an exception when the value is not specified. The opt variety takes a default value as a second parameter and returns that when the value is not specified. So:

json.getBoolean("resistant");  // will throw an exception when "resistant" is not specified
json.optBoolean("resistant", false); // will return false when "resistant" is not specified

This also seems like it'd be fairly straightforward to test...

Thanks!

(Not as straightforward as you would think unless I wrote specific dummy code to test it... which in my experience isn't always reliable in the use case for various reasons since the use case is often more complex. To truly test this reliably, I have to find the correct faction fleet after manually adding the hullmod in the refit screen because Commissioned Crews doesn't add it upon market dock for some reason, and then engage in combat and check the log for the right code path based upon added logging that currently doesn't exist if it doesn't crash outright - so you just saved me likely a whole day of testing at worst case scenario. I'll hold off on any questions for a while, though, I know you are super busy! Sorry!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 20, 2020, 05:34:55 PM
I'll just say, if you haven't actually tested every code branch you've got, you should probably assume it's busted! This isn't me being extreme or anything, it's just a sad fact of life. About 90% of the time when I go, "sigh, but let me test this thing that's a pain to test, anyway, and that looks like it'll work", I find bugs...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 20, 2020, 05:42:13 PM
I'll just say, if you haven't actually tested every code branch you've got, you should probably assume it's busted! This isn't me being extreme or anything, it's just a sad fact of life. About 90% of the time when I go, "sigh, but let me test this thing that's a pain to test, anyway, and that looks like it'll work", I find bugs...

Hmm, ok I'll take your advice on that and yeah that's definitely happened to me sometimes. I haven't ever really gotten the debugger to work with Starsector so that is part of the reason it's a bigger pain unless I very carefully log everything (which I've done in the past) but that's more of a reflection of my lack of understanding of the IDE nuances/functionality than anything the core game does.

I shall double my efforts.

*EDIT* I also came from a team based environment where asking peers/superiors is preferred to slogging it out yourself so that probably influences the question flood somewhat and that's my fault. (One of my friends actually failed the interview because they answered "If you don't know something, what do you do?" with "Research and trial and error" instead of "Ask someone" - so it's a bad habit I have and this is obviously not the same environment. I'm taking time out of someones day to ask questions and I'll try to keep this in mind going forward.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 21, 2020, 05:56:20 AM
So I'm at a loss trying to get Shared Flux to work on a individual ship basis.
I tried:
Code
package data.scripts;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.impl.hullmods.SharedFluxSink;

public class SharedShipFluxSink extends SharedFluxSink {

@Override
public void advanceInCombat(ShipAPI ship, float amount) {
super.advanceInCombat(ship, amount);

if (!ship.isAlive()) return;

CombatEngineAPI engine = Global.getCombatEngine();

String key = SINK_DATA_KEY + "_" + ship.getId();

FluxSinkData data = (FluxSinkData) engine.getCustomData().get(key);
if (data == null) {
data = new FluxSinkData();
engine.getCustomData().put(key, data);

for (ShipAPI module : ship.getChildModulesCopy()) {
if (module.getStationSlot() == null || !module.isAlive() || !Misc.isActiveModule(module)) continue;
float d = module.getMutableStats().getFluxDissipation().getModifiedValue();
d *= FLUX_FRACTION;
data.dissipation.put(module, d);
}
}
}
}
But then I get
Code
java.lang.RuntimeException: Error compiling [data.scripts.SharedShipFluxSink]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/SharedShipFluxSink.java', Line 37, Column 26: Member with "/*default*/" access cannot be accessed from type "data.scripts.SharedShipFluxSink".
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
I dislike bumping, but I've failed to make progress on this front still, and now it is become irritant :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 21, 2020, 10:07:00 AM
Which line is line 37?

The error is saying that you're trying to access a data member that was declared without a public/protected/private modifier (which IIRC defaults to protected? Honestly, I kind of forget). But since it's Janino (and not a proper IDE), it could also be something going wrong with it...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 21, 2020, 02:41:14 PM
37 (:P ), which should be "data.dissipation.put(module, d);"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 21, 2020, 02:44:55 PM
Right, so that means you can't access data.dissipation due to it having the default access modifier. Easiest way around it is probably to make your own copy of that class, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 21, 2020, 02:57:15 PM
Thanks, will try that now!
EDIT: That worked a charm, thanks a million!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on June 22, 2020, 03:44:59 AM
Is there a way to set a ship's fighter replacement rate?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on June 22, 2020, 04:54:21 AM
Hello again!

I encountered a problem, trying to create a chain of station modules, something like that:

Main hull -> module A -> module B -> module C.

The point is that if a player loses module C, he still has others, but if he loses module A, then all subsequent modules destroyed with it.

The problem is that the game persistently loads only the main hull and module A, but not the subsequent ones. I suspect that I ran into a wall of vanilla functionality. So the question is: am I doing something wrong or is an additional plugin really needed here? All the same, I would like to stay within the vanilla, if possible.

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on June 22, 2020, 05:27:52 AM
I encountered a problem, trying to create a chain of station modules, something like that:

Main hull -> module A -> module B -> module C.

The point is that if a player loses module C, he still has others, but if he loses module A, then all subsequent modules destroyed with it.
You can't stack modules on other modules. There is a workaround: you make each module a child of the mothership, then use code to change their positions every frame. Chain-reaction destruction has to be coded manually too.

Here's a guide how to do it. (http://fractalsoftworks.com/forum/index.php?topic=17097.msg269978)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on June 22, 2020, 06:14:12 AM
Sir, this is exactly what I need!

Unfortunately, I barely understand Java, and therefore I can hardly reproduce the logic. Can I just steal this splendor "symbol to symbol"? However, even in this case I’m not sure that I will succeed. Worth to try.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on June 22, 2020, 06:59:16 AM
Be my guest.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 22, 2020, 07:03:16 AM
So open question: What do the various columns in hullmods.csv do? The wiki is quite outdated.
Specifically, I'm unsure as to what tags and uitags accepts and does, and the difference between hidden and hiddeneverywhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 22, 2020, 10:08:24 AM
Is there a way to set a ship's fighter replacement rate?

Built in hullmod:

Code
MutableShipStatsAPI.getFighterRefitTimeMult()

So open question: What do the various columns in hullmods.csv do? The wiki is quite outdated.
Specifically, I'm unsure as to what tags and uitags accepts and does, and the difference between hidden and hiddeneverywhere.

A bit of guess, but I think "Hidden" prevents it from dropping or being sold in markets but it is still visible in the refit screen - like the XIV Battlegroup hullmod - while "HiddenEverywhere" makes the hullmod completely invisible yet still apply its effects.

tags I think is just for autofit and probably the ones that are visible under starsector core are the only ones - but again a guess.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 22, 2020, 11:53:28 AM
Okay, weird compilation error:
Code
2312 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.hullmods.YunruFighterModules'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.hullmods.YunruFighterModules' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more
The reason it makes no sense is because, well, it's untrue:
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
import java.util.List;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI.ShipEngineAPI;

public class YunruFighterModules extends BaseHullMod {
    //////////
    // This section of code was taken largely from the Ship and Weapon Pack mod.
    // I did not create it. Credit goes to DarkRevenant.
    //////////
    private static void advanceChild(ShipAPI child, ShipAPI parent) {
        ShipEngineControllerAPI ec = parent.getEngineController();
        /* Mirror parent's fighter commands */
        if (child.hasLaunchBays()) {
            if (parent.getAllWings().size() == 0 && (Global.getCombatEngine().getPlayerShip() != parent || !Global.getCombatEngine().isUIAutopilotOn()))
                parent.setPullBackFighters(false); // otherwise module fighters will only defend if AI parent has no bays
            if (child.isPullBackFighters() ^ parent.isPullBackFighters()) {
                child.giveCommand(ShipCommand.PULL_BACK_FIGHTERS, null, 0);
            }
            if (child.getAIFlags() != null) {
                if (((Global.getCombatEngine().getPlayerShip() == parent) || (parent.getAIFlags() == null))
                        && (parent.getShipTarget() != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                } else if ((parent.getAIFlags() != null)
                        && parent.getAIFlags().hasFlag(AIFlags.CARRIER_FIGHTER_TARGET)
                        && (parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET) != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET));
                } else if (parent.getShipTarget() != null){
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                }
            }
        }
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 22, 2020, 11:56:56 AM
Okay, weird compilation error:
Spoiler
Code
2312 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.hullmods.YunruFighterModules'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.hullmods.YunruFighterModules' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more
[close]
The reason it makes no sense is because, well, it's untrue:
Spoiler
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
import java.util.List;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI.ShipEngineAPI;

public class YunruFighterModules extends BaseHullMod {
    //////////
    // This section of code was taken largely from the Ship and Weapon Pack mod.
    // I did not create it. Credit goes to DarkRevenant.
    //////////
    private static void advanceChild(ShipAPI child, ShipAPI parent) {
        ShipEngineControllerAPI ec = parent.getEngineController();
        /* Mirror parent's fighter commands */
        if (child.hasLaunchBays()) {
            if (parent.getAllWings().size() == 0 && (Global.getCombatEngine().getPlayerShip() != parent || !Global.getCombatEngine().isUIAutopilotOn()))
                parent.setPullBackFighters(false); // otherwise module fighters will only defend if AI parent has no bays
            if (child.isPullBackFighters() ^ parent.isPullBackFighters()) {
                child.giveCommand(ShipCommand.PULL_BACK_FIGHTERS, null, 0);
            }
            if (child.getAIFlags() != null) {
                if (((Global.getCombatEngine().getPlayerShip() == parent) || (parent.getAIFlags() == null))
                        && (parent.getShipTarget() != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                } else if ((parent.getAIFlags() != null)
                        && parent.getAIFlags().hasFlag(AIFlags.CARRIER_FIGHTER_TARGET)
                        && (parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET) != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET));
                } else if (parent.getShipTarget() != null){
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                }
            }
        }
    }
}
[close]

It *might* be because you are missing this import:

Code
import com.fs.starfarer.api.combat.BaseHullMod;

Which is what your class is attempting to extend.

*Edit* Ah ok upon a second look I see you technically import the entire combat directory so maybe not, but it might be worth a try to make an explicit import just in case the compiler likes that better for some reason. Other than that I have no clue lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 22, 2020, 12:03:28 PM
First off; oof, how'd I miss that?
Second, the error still occurs, with the same report, sadly.

EDIT: I have to have a duplicate somewhere, because I changed the name and it's coming up with the exact same report, including filename.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 22, 2020, 12:06:00 PM
A bit of guess, but I think "Hidden" prevents it from dropping or being sold in markets but it is still visible in the refit screen - like the XIV Battlegroup hullmod - while "HiddenEverywhere" makes the hullmod completely invisible yet still apply its effects.

Correct!

tags I think is just for autofit and probably the ones that are visible under starsector core are the only ones - but again a guess.

tags are used for drops and other such. uiTags is what shows up in the hull mod picker dialog in the refit screen; they can be arbitrary strings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 22, 2020, 12:22:27 PM
First off; oof, how'd I miss that?
Second, the error still occurs, with the same report, sadly.

EDIT: I have to have a duplicate somewhere, because I changed the name and it's coming up with the exact same report, including filename.

Probably a silly question, but did you also change the corresponding column for the script in hullmods.csv alongside the class name when testing this? (That is assuming the compile issue stems from trying to run the game rather than trying to compile the jar itself using an IDE. I'm not completely sure of the context- but that CombatMain is running in the error it makes me think its attempting to run the game.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on June 22, 2020, 06:00:36 PM
Is there a way to set a ship's fighter replacement rate?

Built in hullmod:

Code
MutableShipStatsAPI.getFighterRefitTimeMult()
Sorry, I should have been clearer. This changes the rate of refit time recovering, but I'm looking for a way to directly change the % value. For example, if I wanted to make a weapon that would cost the ship 5% of its fighter % gauge when it fires.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 22, 2020, 07:19:05 PM
Sorry, I should have been clearer. This changes the rate of refit time recovering, but I'm looking for a way to directly change the % value. For example, if I wanted to make a weapon that would cost the ship 5% of its fighter % gauge when it fires.

Ah gotcha. I don't think you can, unfortunately. I could be wrong though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 24, 2020, 03:55:39 PM
I want to be absolutely sure before I make these changes, so:

There is no current way to change DP (as in percent of possible ships deployed in the tactical pre-combat deployment screen) using skin files, correct?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2020, 05:21:54 PM
You could add a built-in hullmod, hidden or otherwise. But not as a direct base-level stat change, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 24, 2020, 05:52:03 PM
You could add a built-in hullmod, hidden or otherwise. But not as a direct base-level stat change, no.

Wait, do you mean MutableShipStatsAPI.getSuppliesToRecover()? That is what I am currently using in the built-in hullmod. I checked today and it only reduces or increases the supply *cost* - in supplies - per deployment. It does not modify the deployment cost in relation to max combat DP during an actual battle. (I just became aware of this today. I thought it did this in the past but I could have just been making an assumption.)

I did a quick sweep of the MutableShipStatsAPI methods and I don't see anything else that would qualify.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2020, 05:55:57 PM
Ahh, never mind, you're right - I forgot that the deployment points are the unmodified value of that stat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 24, 2020, 06:15:37 PM
Ahh, never mind, you're right - I forgot that the deployment points are the unmodified value of that stat.

Ah well, I have a solution in any case. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on June 26, 2020, 03:36:29 AM
I'm having a weird issue relating to .system loading. I'm not sure if it's a mistake I've made, which it could well be, but there isn't something that I'm obviously doing wrong. I have a shipsystem file with json contents below:
 .system file
Code
{ ### the drone AI written for the deuces doesn't use a lot of the values here, only those marked with ###, but the game will crash on launch if the unused values are missing
"id":"PSE_droneCorona",
"type":"STAT_MOD",
"statsScript":"data.scripts.shipsystems.PSE_DroneCorona",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.PSE_DroneCoronaSystemAI",

"droneVariant":"PSE_drone1_Drone",

"allowFreeRoam":true,

"launchSpeed":150,
"launchDelay":0.5,
"maxDrones":3,
"droneBehavior":[
{"droneIndex":[0],
"defaultFacing":"MATCH_SHIP_FACING", # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
"faceEnemy":true,
"holdRoamRange":20, ###
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP], # also SHIP_TARGET to prefer targeting the mothership's target
"initialOrbitAngle":0, ###
"focusModeOrbitAngle":0, ### CUSTOM
"orbitRadius":-35, ### # plus ship radius
"orbitDir":0, # -1 or 1
"orbitSpeed":0, # pixels/second
},
{"droneIndex":[1],
"defaultFacing":"MATCH_SHIP_FACING",
"faceEnemy":true,
"holdRoamRange":20, ###
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP],
"initialOrbitAngle":50, ###
"focusModeOrbitAngle":5, ### CUSTOM
"orbitRadius":-35, ###
"orbitDir":0,
"orbitSpeed":0,
},
{"droneIndex":[2],
"defaultFacing":"MATCH_SHIP_FACING",
"faceEnemy":true,
"holdRoamRange":20,
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP],
"initialOrbitAngle":-50, ###
"focusModeOrbitAngle":-5, ### CUSTOM
"orbitRadius":-35, ###
"orbitDir":0,
"orbitSpeed":0,
},
],

"useSound":"drone_launch",
"outOfUsesSound":"gun_out_of_ammo",
}
(notice how easy it is to put this in spoilers :P)
[close]
My mod has a json loading class (using SettingsAPI) that will read certain values that I have marked, when I hijacked the structure of the base DRONE_LAUNCHER shipsystem json config. The issue is that when I remove the unused values so that it has contents like so:
modified
Code
{
"id":"PSE_droneCorona",
"type":"STAT_MOD",
"statsScript":"data.scripts.shipsystems.PSE_DroneCorona",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.PSE_DroneCoronaSystemAI",

"droneVariant":"PSE_drone1_Drone",

"launchSpeed":150,
"launchDelay":0.5,
"maxDrones":3,
"droneBehavior":[
{"droneIndex":[0],
"initialOrbitAngle":0,
"focusModeOrbitAngle":0,
"orbitRadius":-35, # plus ship radius
},
{"droneIndex":[1],
"initialOrbitAngle":50,
"focusModeOrbitAngle":5,
"orbitRadius":-35,
},
{"droneIndex":[2],
"initialOrbitAngle":-50,
"focusModeOrbitAngle":-5,
"orbitRadius":-35,
},
],

"useSound":"drone_launch",
"outOfUsesSound":"gun_out_of_ammo",
}
[close]
The game crashes before any modplugins are loaded, with the error "Fatal: JSONObject["targetPriority"] not found.", which indicates that it can't find the first sequential value relevant to the DRONE_LAUNCHER shipsystem type that I am not using. The thing that has me the most confused, is that this is actually of STAT_MOD type. Why is it complaining that it can't find a value that is used by DRONE_LAUNCHER?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 26, 2020, 05:42:04 AM
edit:nevermind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 26, 2020, 01:08:41 PM
I'm having a weird issue relating to .system loading. I'm not sure if it's a mistake I've made, which it could well be, but there isn't something that I'm obviously doing wrong. I have a shipsystem file with json contents below:
 .system file
Code
{ ### the drone AI written for the deuces doesn't use a lot of the values here, only those marked with ###, but the game will crash on launch if the unused values are missing
"id":"PSE_droneCorona",
"type":"STAT_MOD",
"statsScript":"data.scripts.shipsystems.PSE_DroneCorona",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.PSE_DroneCoronaSystemAI",

"droneVariant":"PSE_drone1_Drone",

"allowFreeRoam":true,

"launchSpeed":150,
"launchDelay":0.5,
"maxDrones":3,
"droneBehavior":[
{"droneIndex":[0],
"defaultFacing":"MATCH_SHIP_FACING", # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
"faceEnemy":true,
"holdRoamRange":20, ###
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP], # also SHIP_TARGET to prefer targeting the mothership's target
"initialOrbitAngle":0, ###
"focusModeOrbitAngle":0, ### CUSTOM
"orbitRadius":-35, ### # plus ship radius
"orbitDir":0, # -1 or 1
"orbitSpeed":0, # pixels/second
},
{"droneIndex":[1],
"defaultFacing":"MATCH_SHIP_FACING",
"faceEnemy":true,
"holdRoamRange":20, ###
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP],
"initialOrbitAngle":50, ###
"focusModeOrbitAngle":5, ### CUSTOM
"orbitRadius":-35, ###
"orbitDir":0,
"orbitSpeed":0,
},
{"droneIndex":[2],
"defaultFacing":"MATCH_SHIP_FACING",
"faceEnemy":true,
"holdRoamRange":20,
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP],
"initialOrbitAngle":-50, ###
"focusModeOrbitAngle":-5, ### CUSTOM
"orbitRadius":-35, ###
"orbitDir":0,
"orbitSpeed":0,
},
],

"useSound":"drone_launch",
"outOfUsesSound":"gun_out_of_ammo",
}
(notice how easy it is to put this in spoilers :P)
[close]
My mod has a json loading class (using SettingsAPI) that will read certain values that I have marked, when I hijacked the structure of the base DRONE_LAUNCHER shipsystem json config. The issue is that when I remove the unused values so that it has contents like so:
modified
Code
{
"id":"PSE_droneCorona",
"type":"STAT_MOD",
"statsScript":"data.scripts.shipsystems.PSE_DroneCorona",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.PSE_DroneCoronaSystemAI",

"droneVariant":"PSE_drone1_Drone",

"launchSpeed":150,
"launchDelay":0.5,
"maxDrones":3,
"droneBehavior":[
{"droneIndex":[0],
"initialOrbitAngle":0,
"focusModeOrbitAngle":0,
"orbitRadius":-35, # plus ship radius
},
{"droneIndex":[1],
"initialOrbitAngle":50,
"focusModeOrbitAngle":5,
"orbitRadius":-35,
},
{"droneIndex":[2],
"initialOrbitAngle":-50,
"focusModeOrbitAngle":-5,
"orbitRadius":-35,
},
],

"useSound":"drone_launch",
"outOfUsesSound":"gun_out_of_ammo",
}
[close]
The game crashes before any modplugins are loaded, with the error "Fatal: JSONObject["targetPriority"] not found.", which indicates that it can't find the first sequential value relevant to the DRONE_LAUNCHER shipsystem type that I am not using. The thing that has me the most confused, is that this is actually of STAT_MOD type. Why is it complaining that it can't find a value that is used by DRONE_LAUNCHER?

Darn spoilers mean I have to put this in notepad to look at it (*grumble* *grumble* code spoiler compression *grumble* *grumble*)  :P

Anyway this is a guess, but assuming you changed it to STAT_MOD to try and prevent those values from being read- it probably doesn't work that way. Just having defined drones in the first place means that the system loader will look for all the relevant values of the droneBehavior JSONObject contained in each index of the droneBehavior array. Defining DRONE_LAUNCHER doesn't do this but rather having the presence of droneBehavior[] does, if that makes sense.

Even if the drones are technically weaponless, I'd assume they would need a target priority by default even if the system doesn't actually use it. Same thing with orbitSpeed and orbitDir. The loader expects these values to be there whether they are actually used or not. What the custom AI uses is probably irrelevant in that case. If it didn't work that way then you probably wouldn't have been able to define drones under STAT_MOD in the first place. It would have either thrown an error or ignored those values because it would be only expecting a statsScript and the basic default system values.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on June 26, 2020, 05:53:37 PM
I'm having a weird issue relating to .system loading. I'm not sure if it's a mistake I've made, which it could well be, but there isn't something that I'm obviously doing wrong. I have a shipsystem file with json contents below:
 .system file
Code
{ ### the drone AI written for the deuces doesn't use a lot of the values here, only those marked with ###, but the game will crash on launch if the unused values are missing
"id":"PSE_droneCorona",
"type":"STAT_MOD",
"statsScript":"data.scripts.shipsystems.PSE_DroneCorona",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.PSE_DroneCoronaSystemAI",

"droneVariant":"PSE_drone1_Drone",

"allowFreeRoam":true,

"launchSpeed":150,
"launchDelay":0.5,
"maxDrones":3,
"droneBehavior":[
{"droneIndex":[0],
"defaultFacing":"MATCH_SHIP_FACING", # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
"faceEnemy":true,
"holdRoamRange":20, ###
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP], # also SHIP_TARGET to prefer targeting the mothership's target
"initialOrbitAngle":0, ###
"focusModeOrbitAngle":0, ### CUSTOM
"orbitRadius":-35, ### # plus ship radius
"orbitDir":0, # -1 or 1
"orbitSpeed":0, # pixels/second
},
{"droneIndex":[1],
"defaultFacing":"MATCH_SHIP_FACING",
"faceEnemy":true,
"holdRoamRange":20, ###
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP],
"initialOrbitAngle":50, ###
"focusModeOrbitAngle":5, ### CUSTOM
"orbitRadius":-35, ###
"orbitDir":0,
"orbitSpeed":0,
},
{"droneIndex":[2],
"defaultFacing":"MATCH_SHIP_FACING",
"faceEnemy":true,
"holdRoamRange":20,
"freeRoamRange":100,
"targetPriority":[MISSILE, FIGHTER, SHIP],
"initialOrbitAngle":-50, ###
"focusModeOrbitAngle":-5, ### CUSTOM
"orbitRadius":-35, ###
"orbitDir":0,
"orbitSpeed":0,
},
],

"useSound":"drone_launch",
"outOfUsesSound":"gun_out_of_ammo",
}
(notice how easy it is to put this in spoilers :P)
[close]
My mod has a json loading class (using SettingsAPI) that will read certain values that I have marked, when I hijacked the structure of the base DRONE_LAUNCHER shipsystem json config. The issue is that when I remove the unused values so that it has contents like so:
modified
Code
{
"id":"PSE_droneCorona",
"type":"STAT_MOD",
"statsScript":"data.scripts.shipsystems.PSE_DroneCorona",
"aiType":"CUSTOM",
"aiScript":"data.scripts.shipsystems.ai.PSE_DroneCoronaSystemAI",

"droneVariant":"PSE_drone1_Drone",

"launchSpeed":150,
"launchDelay":0.5,
"maxDrones":3,
"droneBehavior":[
{"droneIndex":[0],
"initialOrbitAngle":0,
"focusModeOrbitAngle":0,
"orbitRadius":-35, # plus ship radius
},
{"droneIndex":[1],
"initialOrbitAngle":50,
"focusModeOrbitAngle":5,
"orbitRadius":-35,
},
{"droneIndex":[2],
"initialOrbitAngle":-50,
"focusModeOrbitAngle":-5,
"orbitRadius":-35,
},
],

"useSound":"drone_launch",
"outOfUsesSound":"gun_out_of_ammo",
}
[close]
The game crashes before any modplugins are loaded, with the error "Fatal: JSONObject["targetPriority"] not found.", which indicates that it can't find the first sequential value relevant to the DRONE_LAUNCHER shipsystem type that I am not using. The thing that has me the most confused, is that this is actually of STAT_MOD type. Why is it complaining that it can't find a value that is used by DRONE_LAUNCHER?

Darn spoilers mean I have to put this in notepad to look at it (*grumble* *grumble* code spoiler compression *grumble* *grumble*)  :P

Anyway this is a guess, but assuming you changed it to STAT_MOD to try and prevent those values from being read- it probably doesn't work that way. Just having defined drones in the first place means that the system loader will look for all the relevant values of the droneBehavior JSONObject contained in each index of the droneBehavior array. Defining DRONE_LAUNCHER doesn't do this but rather having the presence of droneBehavior[] does, if that makes sense.

Even if the drones are technically weaponless, I'd assume they would need a target priority by default even if the system doesn't actually use it. Same thing with orbitSpeed and orbitDir. The loader expects these values to be there whether they are actually used or not. What the custom AI uses is probably irrelevant in that case. If it didn't work that way then you probably wouldn't have been able to define drones under STAT_MOD in the first place. It would have either thrown an error or ignored those values because it would be only expecting a statsScript and the basic default system values.

Thanks, that inference turned out to be correct. Adding prefixes to all the keys that would derail the spec loader works a treat, .system file is nice and neat now  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 27, 2020, 12:08:40 AM
Is there anyway to set a ship as disabled while they're deployed in battle, so that at the end of battle report they are listed as disabled as well with chance of being recovered via scripting?
I have been trying
Quote
FleetMember.getStatus().disable();
which just throws null pointer, even if I get get fleetmemberAPI directly from the ship's ShipAPI before evaluating the variable. I'm stumped. With the script i wrote, this is set to trigger when the ShipAPI in question is a hulk/dead, could that possibly be the cause?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 27, 2020, 10:08:51 AM
This came up in another thread and I really don't know how this works, but, is the quality modifier of a variant used in the autoresolve calculation in any way?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 27, 2020, 10:10:39 AM
Is there anyway to set a ship as disabled while they're deployed in battle, so that at the end of battle report they are listed as disabled as well with chance of being recovered via scripting?
I have been trying
Quote
FleetMember.getStatus().disable();
which just throws null pointer, even if I get get fleetmemberAPI directly from the ship's ShipAPI before evaluating the variable. I'm stumped. With the script i wrote, this is set to trigger when the ShipAPI in question is a hulk/dead, could that possibly be the cause?

Hmm - I'd suggest applying damage to it several times, based on its maximum hitpoints, until it's disabled.

This came up in another thread and I really don't know how this works, but, is the quality modifier of a variant used in the autoresolve calculation in any way?

It doesn't, and in fact it's not used for anything anymore.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on June 27, 2020, 10:23:21 AM
Is there a fast way to give a specific hull a unique shield color without creating a hull style?

P.S. Same question for engine jets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 27, 2020, 04:44:16 PM
Is there a fast way to give a specific hull a unique shield color without creating a hull style?

P.S. Same question for engine jets.

For engine jets, you can change it to CUSTOM and define an engine style color in settings.JSON for your mod (iirc anyway - it could be another location) but check the core settings file for reference there just to be sure.

I'm honestly not sure on shield color though. You might have to define a new hull tech type for that.

It should also be noted that you can change engine types with a .skin file using:

Code
	"engineSlotChanges":{
   "0":{"style":"LOW_TECH"},
   "1":{"style":"LOW_TECH"},
   "2":{"style":"LOW_TECH"},
   "3":{"style":"LOW_TECH"},
   "4":{"style":"LOW_TECH"},
   "5":{"style":"LOW_TECH"},
   "6":{"style":"LOW_TECH"},
   "7":{"style":"LOW_TECH"},
},

That also supports CUSTOM.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on June 27, 2020, 10:20:43 PM
Yes, gentleman, I am aware of this.There is no difficulty creating new styles in hull_styles.json and engine_styles.json respectively. This is what I want to avoid. You see, I do not want to create styles since they will be applied only to a single ship, and they will be almost complete copies of vanilla, except for a couple of lines.

Let’s go on the other side. We can change the color of covers in .ship files via "coversColor": "R,G,B,T", It would be great to be able to:

"style": "HIGH_TECH",
"shieldRingColor":[R,G,B,T],
"shieldInnerColor":[R,G,B,T],

But I doubt it will work. Alternatively, determine a style directly in a .ship file. Is it possible?

Spoiler
Code: Can I put this directly to a .ship file?
"style":{
"hyperspaceJitterColor":[100,165,255,200],
"baseCampaignExplosionColor":[100,165,255,255],
"baseCombatExplosionColor":[100,165,255,255],
"fighterRepairFlickerColor":[100,165,255,255],
"fighterChipIconColor":[100,165,255,255],
"weaponDisabledExplosionColor":[100,165,255,255],
"shieldRingColor":[X,Y,Z,A],
"shieldInnerColor":[X,Y,Z,A],
"fluxVentCoreColor":[255,255,255,255],
"fluxVentFringeColor":[125,0,155,255],
"engineLoopSet":"engine_loop", # id of entry in sounds.json
"engineAccelerateSet":"engine_accelerate", # id of entry in sounds.json
"empLoopSet":"emp_loop", # id of entry in sounds.json
"fluxLoopSet":"flux_loop", # id of entry in sounds.json
"ventFluxSet":"vent_flux", # id of entry in sounds.json
"shieldBurnoutSet":"shield_burnout", # id of entry in sounds.json
"shieldLowerSet":"shield_lower", # id of entry in sounds.json
"shieldRaiseSet":"shield_raise", # id of entry in sounds.json
"explosionShipSet":"explosion_ship", # id of entry in sounds.json
"damageDecalSheet":"graphics/damage/damage_decal_sheet_base.png",
"damageDecalGlowSheet":"graphics/damage/damage_decal_sheet_glow.png",

#"colorShiftCovers":true,
"coversColorShiftAmount":1,  # 0 to 1
"coversMatchShipBrightness":true,
"slotCoverSmallTurret":"graphics/weapons/covers/cover_turret_hightech_small.png",
"slotCoverSmallHardpoint":"graphics/weapons/covers/cover_hardpoint_hightech_small.png",
"slotCoverMediumTurret":"graphics/weapons/covers/cover_turret_hightech_medium.png",
"slotCoverMediumHardpoint":"graphics/weapons/covers/cover_hardpoint_hightech_medium.png",
"slotCoverLargeTurret":"graphics/weapons/covers/cover_turret_hightech_large.png",
"slotCoverLargeHardpoint":"graphics/weapons/covers/cover_hardpoint_hightech_large.png",

"dHullOverlayLight":"graphics/damage/dmod_overlay_hightech_light.png",
"dHullOverlayMedium":"graphics/damage/dmod_overlay_hightech_medium.png",
"dHullOverlayHeavy":"graphics/damage/dmod_overlay_hightech_heavy.png",
},
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 29, 2020, 12:33:47 PM
What exactly does ship size determine?

Is it just OP/Max Vents/Max Capacitors, or is there more I'm missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 29, 2020, 12:46:06 PM
Alternatively, determine a style directly in a .ship file. Is it possible?

It's not possible, no - copy-pasting styles like you're talking about / want to avoid is basically the way to go.

What exactly does ship size determine?

Is it just OP/Max Vents/Max Capacitors, or is there more I'm missing?

Also hullmod cost, and base sensor range/profile. I might be forgetting something else...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 29, 2020, 12:54:42 PM
Damn! I'd noted down and got values for those I listed (with OP actually being hullmod cost XD), but I didn't get any values for sensor range/profile.

My end goal is to create new psuedo-sizes using hidden hullmods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 29, 2020, 02:22:50 PM
Yes, gentleman, I am aware of this.There is no difficulty creating new styles in hull_styles.json and engine_styles.json respectively. This is what I want to avoid. You see, I do not want to create styles since they will be applied only to a single ship, and they will be almost complete copies of vanilla, except for a couple of lines.

I'm a little confused as to why you would want to do this to be honest. What is the functional difference between defining a new style and adding it to the .ship file vs adding it directly to the ship file??

Both ways only affect the ships you add them to and defined CUSTOMs can also be added to skins. It's far more efficient to do it the first way and define a custom style. If you defined a style in every ship file, that would basically be redundant code 99% of the time. Even if dealing with only a single ship you want to edit this way, it's not really a big deal efficiency-wise and is much cleaner overall to have a standardized implementation.

Defining a style handles all the details in one code instance and allows you to reference those details as many times as needed. Even if you need to do a bunch of tiny edits using multiple styles, it's probably better to have that all in one place for reference and just add the one entry key to the ship itself instead of having to search through every ship file that you think has the same style configuration. The far easier way would be to mass search all ships for the style key in question, if that makes sense.

Idk, maybe I am misunderstanding your use case here, but from the initial way you explained it, I think the custom style approach would make it a lot easier on you in the long run - especially if you decided to add this to a bunch of other ships in the future.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 29, 2020, 02:44:40 PM
This is possibly a bigger question than intended for this thread, but is it possible to have hullmods applied to the core ship apply to attached modules too?

In fact, should probably start simplest: Do hullmods on a ship apply to it's modules too (I believe commander bonuses do, but am in the dark otherwise)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 29, 2020, 03:18:34 PM
This is possibly a bigger question than intended for this thread, but is it possible to have hullmods applied to the core ship apply to attached modules too?

In fact, should probably start simplest: Do hullmods on a ship apply to it's modules too (I believe commander bonuses do, but am in the dark otherwise)?

No I don't think so, but you could always add the hullmod to the module itself - either as a separate hidden one or just the same one if that doesn't matter.

For hullmods that are added dynamically, you could set up a script to check for the presence of the hullmod on the mothership then get its modules and add it to those dynamically as well, either through an everyframescript in the campaign or an everyframescript in the combat layer - whatever your use case requires.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 29, 2020, 03:46:23 PM
That sounds like a very easy source of lag?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 29, 2020, 04:07:15 PM
That sounds like a very easy source of lag?

Not really. I mean, it will take *some* resources, yes, but I've set up several without any noticeable impact to performance if all you are doing is checking a boolean. Obviously it depends upon your rig, but adding a couple of these is negligible. It's when you start setting up a ton of them or do multiple complex checks per frame that it gets bad.

If your use case is combat, you could also extend BaseCombatLayeredRenderingPlugin and simply add the code to public void init() so it only runs once at the beginning of combat (I believe, anyway). In that case you would add the render plugin using -

Code
	"plugins":{
"your_plugin":"data.scripts.plugins.your_plugin",
},

For the campaign, you could set up an interval or do what Commissioned Crews does and run the code when you dock somewhere. Personally I'd do the interval depending upon what the hullmod does.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 29, 2020, 04:12:20 PM
My thoughts was basically have the modules copy the parent's hullmods, overwriting it's own.
For module-only-in-function ships, like having multiple shields, or more than 6 (8?) fighter slots.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 29, 2020, 04:31:05 PM
My thoughts was basically have the modules copy the parent's hullmods, overwriting it's own.
For module-only-in-function ships, like having multiple shields, or more than 6 (8?) fighter slots.

Should be doable, yeah. You might need to add a "master hullmod" that's hidden to detect, but that's only if there isn't something like a hasModules() boolean you can check the ShipAPI for. I'm not sure off the top of my head.

You can definitely get a list of hullmods and check the number of fighter bays iirc, so transferring the list to any child modules should be fairly straightforward I would think. Multiple shields should also be doable by getting the modules and checking for a shield for each one and setting up a counter where you can kill the iteration if the count goes over 2, for instance.

(Obviously if using a an everyframe script you don't want to keep iterating every frame because that would likely impact performance, so you would set up a boolean to disable all the iterations once the initial pass is complete and the functionality does what you want it to do. That's what I meant by only checking a boolean each frame.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on July 01, 2020, 03:06:12 PM
I've been staring at this too long and am losing my mind over what is, presumably, simple.

Currently re-creating the steps to make Officers and add them to comms for the player to hire, but am falling down at this line of code originally from the OfficerManagerEvent:

     officer.person.getMemoryWithoutUpdate().set("$ome_eventRef", this);

So 'this' needs to be the reference to the callable event, but I cannot work out how to pass a callable event reference here.  So, any officers I make cannot trigger it, and cannot be hired or display their attributes.

Am I making sense, or is there a way to use OfficerManagerEvent I should know about?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 01, 2020, 03:42:45 PM
You should be able to create your own OfficerManagerEvent object to use without side effects. Just make sure you init() it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 01, 2020, 03:49:41 PM
I've been staring at this too long and am losing my mind over what is, presumably, simple.

Currently re-creating the steps to make Officers and add them to comms for the player to hire, but am falling down at this line of code originally from the OfficerManagerEvent:

     officer.person.getMemoryWithoutUpdate().set("$ome_eventRef", this);

So 'this' needs to be the reference to the callable event, but I cannot work out how to pass a callable event reference here.  So, any officers I make cannot trigger it, and cannot be hired or display their attributes.

Am I making sense, or is there a way to use OfficerManagerEvent I should know about?

Industrial.Evolution Academy does exactly that, feel free to take a look at the code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on July 02, 2020, 06:51:03 AM
You should be able to create your own OfficerManagerEvent object to use without side effects. Just make sure you init() it.
Industrial.Evolution Academy does exactly that, feel free to take a look at the code.

Thanks for this! its exactly what I needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on July 03, 2020, 04:32:18 AM
Just a quick one: I have a ship that has an engine boosting system, and an engine module. I'd like to disable the ship system if the module is missing, however I'm not sure how to check if a ship has a module. May I ask how to do this, if it's possible at all?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 03, 2020, 08:42:26 AM
See: ShipAPI.getChildModulesCopy()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: powerlunatic on July 03, 2020, 03:10:22 PM
Is it possible to split the descriptions.csv into several more .csv files and load them manually via my mod's base plugin? Or is it possible to read them via SettingsAPI's loadCSV then inject it into the database, somehow? If possible, an example or pointer to relevant documentation would be neat!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 03, 2020, 04:34:20 PM
Is it possible to split the descriptions.csv into several more .csv files and load them manually via my mod's base plugin? Or is it possible to read them via SettingsAPI's loadCSV then inject it into the database, somehow? If possible, an example or pointer to relevant documentation would be neat!
Even if there was... why would you want to?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 03, 2020, 04:45:20 PM
Here's an example of how I read the fleet dialogue csv for a reference to how to read .csv files in general:

Spoiler
public class FDialogue_factionTextLoader {

    /**
     *   Spreadsheet data.
     */
    // The file directory that contains the dialogue options based upon faction id. Each response dialogue category is optional as a default exists.
    private static final String FILE = "data/config/FleetDialogue/factions/FleetDialogue_factionText.csv";
    // End file data.

    // Column ids in FleetDialogue_factionText.csv.
    // Default faction id under "id" column.
    private static String DEFAULT_ID = "default";
    // Additional faction ids can implement any number of dialogue column ids to provide custom responses for the faction.

    // Dialogue column ids.
    // Imports faction dialogue matching any dialogue column ids which are defined here.
    // Responses for each column are based upon an existing faction id in the "id" column.
    // If no faction id exists for a dialogue column, or the corresponding dialogue cell to the faction id is empty, the default response is used instead.
    private static String COMMODITY_REQUEST_DESCRIPTION = "commodityRequestDescription";
    private static String COMMODITY_SUPPLY_REQUEST_DESCRIPTION = "commoditySupplyRequestDescription";
    private static String COMMODITY_FUEL_REQUEST_DESCRIPTION = "commodityFuelRequestDescription";
    private static String COMMODITY_DEMAND_DESCRIPTION = "commodityDemandDescription";
    private static String COMMODITY_REQUEST_PLAYER_UNKNOWN = "commodityRequestPayerUnknown";
    private static String COMMODITY_REQUEST_SUCCESS = "commodityRequestSuccess";
    private static String COMMODITY_REQUEST_SUCCESS_FRIENDLY = "commodityRequestSuccessFriendly";
    private static String COMMODITY_REQUEST_SUCCESS_EXALTED = "commodityRequestSuccessExalted";
    private static String COMMODITY_REQUEST_SUCCESS_SUSPICIOUS = "commodityRequestSuccessSuspicious";
    private static String COMMODITY_REQUEST_SUCCESS_ANNOYED = "commodityRequestSuccessAnnoyed";
    private static String COMMODITY_REQUEST_SUCCESS_HAVETOPAY = "commodityRequestSuccessHaveToPay";
    // End column ids.

    /**
     *   Class data.
     */
    // Logger data. For use in troubleshooting logging only.
    private static final Logger LOG = Global.getLogger(FDialogue_factionTextLoader.class);
    private static final String FACTION_ID_PREFIX = "Faction id: ";
    private static final String NO_VALID_DIALOGUE_COLUMN = " - was found in FleetDialogue_factionText.csv, but no valid entry was found for: ";
    private static final String VALID_DIALOGUE_COLUMN = " - was found in FleetDialogue_factionText.csv, and a valid entry was found for: ";
    private static final String USE_DEFAULT_RESPONSE_FOR_CATEGORY = "Using default dialogue response for: ";
    private static final String CUSTOM_FACTION_ID_PREFIX = "Using custom faction: ";
    private static final String RESPONSE_CATEGORY_PREFIX = " - dialogue response for: ";
    private static final String CUSTOM_FACTION_ID_NOT_FOUND = " - was not found in FleetDialogue_factionText.csv.";
    // End Logger data.
    private static Map<String, Map> FACTION_DIALOGUE = new HashMap<>();
    private static Object CELL_DATA;
   
    public static void readDialogueFile(){
        FACTION_DIALOGUE.clear();
        // Attempt to read the file row by row and store all factions ids in a map containing a nested map of all possible dialogue responses by faction id.
        // Each faction id is the map key to the nested map of possible dialogue implementations for each faction - also contained in a map.
        try {
            JSONArray StringData = Global.getSettings().getMergedSpreadsheetDataForMod("id", FILE, "fleetdialogue_morro");
            for(int i = 0; i < StringData.length(); i++) {
                JSONObject row = StringData.getJSONObject(i);
                Map<String, String> responses = new HashMap<>();
                responses.clear();
                if(row.getString("id") != null){
                    // Set up dialogue response map. Response category keys are hardcoded and called in the various get methods implemented below.
                    // Also checks for missing or empty dialogue responses as a safeguard.
                    if (row.getString(COMMODITY_REQUEST_DESCRIPTION) != null && !row.getString(COMMODITY_REQUEST_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_DESCRIPTION, row.getString(COMMODITY_REQUEST_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_SUPPLY_REQUEST_DESCRIPTION) != null && !row.getString(COMMODITY_SUPPLY_REQUEST_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_SUPPLY_REQUEST_DESCRIPTION, row.getString(COMMODITY_SUPPLY_REQUEST_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_FUEL_REQUEST_DESCRIPTION) != null && !row.getString(COMMODITY_FUEL_REQUEST_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_FUEL_REQUEST_DESCRIPTION, row.getString(COMMODITY_FUEL_REQUEST_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_DEMAND_DESCRIPTION) != null && !row.getString(COMMODITY_DEMAND_DESCRIPTION).isEmpty()) {
                        responses.put(COMMODITY_DEMAND_DESCRIPTION, row.getString(COMMODITY_DEMAND_DESCRIPTION));
                    }
                    if (row.getString(COMMODITY_REQUEST_PLAYER_UNKNOWN) != null && !row.getString(COMMODITY_REQUEST_PLAYER_UNKNOWN).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_PLAYER_UNKNOWN, row.getString(COMMODITY_REQUEST_PLAYER_UNKNOWN));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS) != null && !row.getString(COMMODITY_REQUEST_SUCCESS).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS, row.getString(COMMODITY_REQUEST_SUCCESS));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_FRIENDLY) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_FRIENDLY).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_FRIENDLY, row.getString(COMMODITY_REQUEST_SUCCESS_FRIENDLY));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_EXALTED) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_EXALTED).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_EXALTED, row.getString(COMMODITY_REQUEST_SUCCESS_EXALTED));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS, row.getString(COMMODITY_REQUEST_SUCCESS_SUSPICIOUS));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_ANNOYED) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_ANNOYED).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_ANNOYED, row.getString(COMMODITY_REQUEST_SUCCESS_ANNOYED));
                    }
                    if (row.getString(COMMODITY_REQUEST_SUCCESS_HAVETOPAY) != null && !row.getString(COMMODITY_REQUEST_SUCCESS_HAVETOPAY).isEmpty()) {
                        responses.put(COMMODITY_REQUEST_SUCCESS_HAVETOPAY, row.getString(COMMODITY_REQUEST_SUCCESS_HAVETOPAY));
                    }
                    // Add nested map to the faction map under the faction id.
                    FACTION_DIALOGUE.put(row.getString("id"), responses);
                }
            }

            // Log error if dialogue file cannot be parsed correctly.
        } catch (IOException | JSONException ex) {
            LOG.error("unable to read " + FILE);
        }
    }
[close]

 - this stores all your relevant strings from the file in a map which you can use for whatever you want.

An example entry from the file it's reading (screenshot):
Spoiler
(https://i.imgur.com/ogaxWjp.png)
[close]

As far as actually adding those strings to descriptions for hulls, I actually doubt that is possible but Alex would have to chime in. I think it is handled on the game load only.

If it's containted in the persistant data, though, then maybe something like:

Spoiler
        JSONObject descriptions = (JSONObject) Global.getSector().getPersistentData().get("descriptions");
        Object yourID = "hullID";
        Object yourType = "SHIP";
        Object yourDescription = "description";
        Object yourRole = "role";
        try {
            descriptions.put("id", yourID);
            descriptions.put("type", yourType);
            descriptions.put("text1", yourDescription);
            descriptions.put("text2", yourRole);
        } catch (JSONException e) {
            LOG.error(e);
        }
        Global.getSector().getPersistentData().put("descriptions", descriptions);
[close]

*Might* work, but it depends upon the format it is kept in and I don't think that is documented anywhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on July 04, 2020, 07:32:09 AM
So, I made a simple hullmod. And it works as it should. How do i make it incompatible with specific hullmod (efficiency overhaul)? I can always:
Code
@Override
public boolean isApplicableToShip(ShipAPI ship) {
return !ship.getVariant().getHullMods().contains("efficiency_overhaul");
}

public String getUnapplicableReason(ShipAPI ship) {
if (ship.getVariant().getHullMods().contains("efficiency_overhaul")) {
return "Incompatible with Efficiency Overhaul";
}

That will prevent my mod to be used with Efficiency Overhaul, but it will not prevent Efficiency Overhaul to be installed if my mod is built-in.

Shall I add some strings to EfficiencyOverhaul.java somehow? Or even overwrite it? There should be an easier way.

Also, which is the best way to make randomly generated NPC variants obey that rule?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 04, 2020, 08:38:40 AM
the newest version of MagicLib has a pre made Hullmod incompatibility feature. I'd suggest you check it out, saves time and problems with bugs in the future!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on July 04, 2020, 09:38:39 AM
I don’t want to offend Mr.Tartiflette in any way, but every time I try to figure out his scrolls, I want to cry.

Not because the library is bad, but because I know Java so well, that I make two mistakes when I just write "Java". Glory to the spell checker!

In this particular example, I can only guess what needs to be done. My best guess is:

1.Add this to the title:
Code
import data.scripts.util.MagicIncompatibleHullmods;
import data.scripts.util.MagicTxt;
import static data.scripts.util.MagicTxt.getString;

2. And this to the body:
Code
if(stats.getVariant().getHullMods().contains("efficiency_overhaul")){

   MagicIncompatibleHullmods.removeHullmodWithWarning(stats.getVariant(), "efficiency_overhaul", "my_hullmod_name");

}

And it ain't work... And I am not surprised. ;D

Vanilla scripts, made by Alex are more intuitive to me for <profanity> reverse engineering.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 04, 2020, 10:22:17 AM
So, I made a simple hullmod. And it works as it should. How do i make it incompatible with specific hullmod (efficiency overhaul)? I can always:
Spoiler
Code
@Override
public boolean isApplicableToShip(ShipAPI ship) {
return !ship.getVariant().getHullMods().contains("efficiency_overhaul");
}

public String getUnapplicableReason(ShipAPI ship) {
if (ship.getVariant().getHullMods().contains("efficiency_overhaul")) {
return "Incompatible with Efficiency Overhaul";
}
[close]

That will prevent my mod to be used with Efficiency Overhaul, but it will not prevent Efficiency Overhaul to be installed if my mod is built-in.

Shall I add some strings to EfficiencyOverhaul.java somehow? Or even overwrite it? There should be an easier way.

Also, which is the best way to make randomly generated NPC variants obey that rule?

It is interesting to me that the built in part of this matters. Rather, can you not equip your hullmod first and then be able to equip efficiency overhaul because it doesn't contain a check for your hullmod? If you can't, it might be related to the utility mod cap and that is why it seems to need to be built in, I'd think, though I could be wrong.

Anyway, you would have to override the efficiency overhaul mod itself to prevent that from being installed afterwards by adding the reverse of your check to it, if so. Assuming you can't get MagicLib to work.

(I'm not familiar with MagicLib but are you sure you have the parameters in the correct order? That's one thing that could be going wrong. Does the log say anything?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on July 04, 2020, 11:03:14 AM
Quote
(I'm not familiar with MagicLib but are you sure you have the parameters in the correct order? That's one thing that could be going wrong. Does the log say anything?)

I am sure that the order is wrong. Other would be strange. I did not save the log.

Quote
It is interesting to me that the built in part of this matters. Rather, can you not equip your hullmod first and then be able to equip efficiency overhaul because it doesn't contain a check for your hullmod? If you can't, it might be related to the utility mod cap and that is why it seems to need to be built in, I'd think, though I could be wrong.

Built-in matters. If I add my hullmod first (not built-in), and then efficiency overhaul, my hullmod removes itself from the build and can not be equipped until efficiency overhaul is removed. In this state, the rule is fulfilled, although in one direction. But if I made my hullmod built-in, it is possible to add efficiency overhaul, while my hullmod remain active (can not be removed?).

I can’t add lines to the vanilla code. and rewrite it completely - create compatibility issues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 04, 2020, 11:46:37 AM
I can’t add lines to the vanilla code. and rewrite it completely - create compatibility issues.

It doesn't necessarily have to, just fyi.

1) Copy the hullmod from the source into your own hullmods folder. Add your check to the code. Give it a unique name.

2) Copy the line from hullmods.csv and in the script column point to your unique one instead of the vanilla one. Leave everything else unchanged.

3) For your mod id, add some "??" before it.

csv files merge and any duplicate entries of vanilla ids outside of vanilla (so from other mods trying to edit this as well - vanilla will be overridden in any case) are loaded and overridden reverse-alphabetically. Adding the "??" ensures that you will be the first one loaded and so the first one overridden if another mod also edits it.

That should handle any incompatibility with other mods - though it will in-turn allow the user to equip both hullmods when it is built-in in the case that another mod does override your check so be aware of that for troubleshooting purposes.

Having MagicLib work is likely a more ideal solution, but just letting you know you have options.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 04, 2020, 12:15:13 PM
Sorry if I have asked this in the past I honestly can't remember. Is there anything in the weapon file json that supports preventing the ship from active venting while the weapon is firing a burst? (Specifically beams)

My Tachyon Lance version has a long cooldown and is active for ~2.5 seconds and sometimes the AI starts it and only lets it burst for .5 to 1 second then immediately vents to keep the low flux boost. Even frontloading the damage still wastes the cooldown to a large degree. (Not to mention cutting off a rather cool sound effect if I do say so myself  :D )

I can handle this with AI variants by ensuring they have enough flux cap and dissipation to not do this, but many users might not be aware of why this is happening and I'd rather just disable the behavior all together if possible so that it is more obvious (due to a maxed flux bar on firing or no firing at all) to the user what the problem with their loadout is.

If a combat script is required, any examples to reference would be great! Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 04, 2020, 12:27:12 PM
There's no way to do that with the weapon file. However, if you've got a script, you could either block the command to vent flux while that weapon is firing, OR (so that the player still has the option to do it) set AIFlags.DO_NOT_VENT via ship.getAIFlags(). (Check that the return value there isn't null since it may be null for the player's ship.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on July 04, 2020, 12:27:59 PM
It doesn't necessarily have to, just fyi.
Spoiler
1) Copy the hullmod from the source into your own hullmods folder. Add your check to the code. Give it a unique name.

2) Copy the line from hullmods.csv and in the script column point to your unique one instead of the vanilla one. Leave everything else unchanged.

3) For your mod id, add some "??" before it.

csv files merge and any duplicate entries of vanilla ids outside of vanilla (so from other mods trying to edit this as well - vanilla will be overridden in any case) are loaded and overridden reverse-alphabetically. Adding the "??" ensures that you will be the first one loaded and so the first one overridden if another mod also edits it.

That should handle any incompatibility with other mods - though it will in-turn allow the user to equip both hullmods when it is built-in in the case that another mod does override your check so be aware of that for troubleshooting purposes.
[close]

Yes, mister, that works. I did so initially, but I do not like this method. A little earlier or a little later this will lead to this:
Spoiler
(https://i.imgur.com/vhbHvKM.jpg)
[close]

I really should make magiclib work. Well, I'll go ask in the appropriate thread.

Anyway, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 04, 2020, 05:13:39 PM
It doesn't necessarily have to, just fyi.
Spoiler
1) Copy the hullmod from the source into your own hullmods folder. Add your check to the code. Give it a unique name.

2) Copy the line from hullmods.csv and in the script column point to your unique one instead of the vanilla one. Leave everything else unchanged.

3) For your mod id, add some "??" before it.

csv files merge and any duplicate entries of vanilla ids outside of vanilla (so from other mods trying to edit this as well - vanilla will be overridden in any case) are loaded and overridden reverse-alphabetically. Adding the "??" ensures that you will be the first one loaded and so the first one overridden if another mod also edits it.

That should handle any incompatibility with other mods - though it will in-turn allow the user to equip both hullmods when it is built-in in the case that another mod does override your check so be aware of that for troubleshooting purposes.
[close]

Bad Morrokain! Bad, bad, bad! Only TCs and rebalances have the privilege to override vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 05, 2020, 12:57:02 AM
Bad Morrokain! Bad, bad, bad! Only TCs and rebalances have the privilege to override vanilla.

*Whimpers mournfully* I did bad?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: toastyblitz on July 05, 2020, 05:41:08 AM
Is there an import I should be using at the top of my system generator to allow me to assign my faction a planet/market? the FactionAPI only lists vanilla factions, and while the log is saying the game is reading my .faction file, I'm not sure how to go about this. I was trying to use planet.setFaction and market.setFaction.


*edit again*

figured it out, i was using planet.setFaction(Factions.myfaction) when it should have been planet.setFaction("myfaction")
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on July 05, 2020, 01:07:34 PM
Follow-up question!

If I set an officers skills to zero, is that the same as him/her not having those skills?

this code:   person.getStats().getSkillsCopy();

returns a 'List<SkillLevelAPI>' , including skills that I reduced to zero and the aptitudes.  Is this an artifact of how they're adapted from the player skills?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 05, 2020, 02:12:28 PM
Only TCs and rebalances have the privilege to override vanilla.

Ok all silliness aside, I took and look and it turns out that lots of mods override vanilla... You even have one for Pilums. I understand that the more people do this the more complex the modiverse gets, but this seems unnecessarily strict in this case considering all of the examples to the contrary.

So what defines a "rebalance" - is Lightshow considered one? Or Better Colonies? Boardable Unboardables? How is that any different from adding a hullmod check to a vanilla hullmod other than it's a new mod and not an existing one??

We need to be consistent here and not play favorites so I'd like some clarification as to what you mean and when you consider this "appropriate". It had better not be "well those are established good mods" or some crap like that.  >:(

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

Is there an import I should be using at the top of my system generator to allow me to assign my faction a planet/market? the FactionAPI only lists vanilla factions, and while the log is saying the game is reading my .faction file, I'm not sure how to go about this. I was trying to use planet.setFaction and market.setFaction.


*edit again*

figured it out, i was using planet.setFaction(Factions.myfaction) when it should have been planet.setFaction("myfaction")

Some API hooks won't accept a string for a faction ID and requires the enum to be used. You can add you own enum class to accommodate this.

Example:

package archeus.campaign.ids;

public class ArcheusFactions extends com.fs.starfarer.api.impl.campaign.ids.Factions{

   
   public static final String ARCHEUS = "archean_order";
   public static final String ADAMANTINE = "adamantine_consortium";
   public static final String TRADERGUILDS = "trader_guilds";
   public static final String SCICORPS = "scicorps";

}

Follow-up question!

If I set an officers skills to zero, is that the same as him/her not having those skills?

this code:   person.getStats().getSkillsCopy();

returns a 'List<SkillLevelAPI>' , including skills that I reduced to zero and the aptitudes.  Is this an artifact of how they're adapted from the player skills?

I don't think it's the same, but it might functionally work the same way, I'm not really sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 05, 2020, 07:59:24 PM
Moved the discussion about overriding vanilla stuff to another thread:

http://fractalsoftworks.com/forum/index.php?topic=18787.0


Follow-up question!

If I set an officers skills to zero, is that the same as him/her not having those skills?

this code:   person.getStats().getSkillsCopy();

returns a 'List<SkillLevelAPI>' , including skills that I reduced to zero and the aptitudes.  Is this an artifact of how they're adapted from the player skills?

I don't think it's the same, but it might functionally work the same way, I'm not really sure.

I think that's correct, yeah.   
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 07, 2020, 03:20:49 PM
So I recently learned that I can add/remove a faction's known ships/weapons/fighters using the API and that's great! It means I won't have to override vanilla factions anymore - locking those files away from other modders when mod merging.

First off, I was wondering if the same could be done with blueprints? I currently override vanilla ships/weapons/fighters in the csvs - but only to add "no drop, no sell" or "UNBOARDABLE", etc and remove the blueprint tags so they are not included in blueprint packages/rare_bp drops. This is problematic when mod merging for a number of reasons.

My thought was to do this through code instead by creating a database of vanilla stuff then iterating through all of it at the start of a campaign before anything is added to markets and add/remove the necessary tags/remove them from blueprints. What would be the best point for that? OnNewGame?

Alternatively, I could create mod-specific blueprint packages and prevent vanilla blueprints from dropping. That would take more work but would be more ideal. However, it only would work if I could remove known blueprints from a faction.

Any general advice? 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.

In the far off future, this will also allow me to add vanilla balanced ships through a separate ship entry, and similarly toggle functionality between a fully vanilla balanced setting and the TC experience while keeping everything "under one house" so to speak. I don't particularly want to modulize too much as checking the forums/creating the forum pages alone would provide a lot more work/maintenance than I would want to tackle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 07, 2020, 03:27:45 PM
Take a look at ShipHullSpecAPI.addTag(). If you want to remove the tag, you could call getTags().remove(tag). IIRC weapon and fighter wing specs have similar methods. You'd want to do this kind of modification... probably in the onApplicationLoad() method of your mod plugin, since you only need to do this once, and it's not tied to the campaign. And, in fact, these methods are provided specifically with your kind of use case in mind!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 07, 2020, 03:32:51 PM
Take a look at ShipHullSpecAPI.addTag(). If you want to remove the tag, you could call getTags().remove(tag). IIRC weapon and fighter wing specs have similar methods. You'd want to do this kind of modification... probably in the onApplicationLoad() method of your mod plugin, since you only need to do this once, and it's not tied to the campaign. And, in fact, these methods are provided specifically with your kind of use case in mind!

Amazing! Thanks! I wasn't sure if the ShipHullSpecAPI was technically loaded at OnApplicationLoad() so glad that I can just do it immediately. Ah I'm excited by this!  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 07, 2020, 04:39:44 PM
Nice, good luck :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 10, 2020, 03:59:13 AM
Hi, I don't know if this is the right place to ask, but is there any way we could get API support for playable fighters?

You might have remembered me asking about this a few months ago. By setting hull and collisionclass to FIGHTER, you get a broadly playable analog that behaves how you'd expect - but there are two major impediments to this approach that had me initially give up the concept. Instead I made "hybrid" ship, with frigate hullsize and fighter collision, but this had unintended effect of breaking lot of custom AI and other things, so I revisited this topic and was able to make something that was playable, outside of a few issues. I think if this support could be added, it would make it a lot easier for people to explore in the future and also eliminate the weird edge cases I experienced.

The main  issue is that the game crash when ship tries to retreat from battles. I don't 100% know why except its caused by RetreatManuever(?), I assume there is no "retreat manuever" for fighters?.

The second issue is there is no real UI/HUD for fighters - for instance, a piloted fighter only appears as a green triangle on the command UI, so if you were to swap to another ship, swapping back to it, or commanding it is impossible.

In the mod I made, I was able to circumvent this by turning the "fighter" back into a frigate when it was within the retreat radius, and when the Command UI was open. But there are a few other edge cases where things get weird - this particular mod ship, for example, cannot be "disabled" like a normal ship can. It can be blown up in combat, and be knocked down to 0% hull, but always is recoverable, so I also had to add a condition where once HP is below 2% threshold, the hullsize reverts back to FRIGATE so it can be properly disabled.

Onto to the less pressing issues, there are no warnings for the end of peak performance/low CR and overloading(Either the warning that appears at the top of the screen, or over the ship), and no hull/flux indicators over the ship. With scripting and MagicLIB it's easy enough to atleast loosely replicate a hull/flux indicator, as well as an overload pop-up over affected ships, though.

Anyway, I have a simple(i think) proposal that should make a lot easier to implement for people who want to play around with this concept.

is there anyway to add something like a FIGHTER tag (like CARRIER tag) that could be used to give "playable" fighters special behavior?  What MesoTroniK suggest, was if there was a condition evaluated (like if(ship.isPlayableFighter)), the default behavior of fighters could be preserved, but the boolean returning as true would allow for slightly different behavior. I'm just guessing since I have no idea whats under the hood of the AI implementation for retreat, but with something like this, I'd imagine something simple like switching the ship to frigate hullsize before it retreated or such could be done, or just having it do the same method normal ships do on retreat, as well as serving as a toggle that would let ships like this appear in the Command UI and retain a HUD Status bar.

Sorry again if this is not really the right place to ask.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 10, 2020, 07:12:31 AM
if I add a custom drop group to a vanilla entity in salvage_entity_gen_data.csv, will it get overridden by other mods that also add groups to the same entity but are later in load order? Or do they get merged?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 10, 2020, 08:43:36 AM
@shoi: Ah, I can't really do that - as you've found out, there are a lot of places where these are handled differently, so it'd be a ton of work. More importantly, there's no vanilla use case, which means that 1) it's unlikely I would find all the cases that need changing, and 2) there's a solid chance I would break something at a later date without realizing it. Apologies!

if I add a custom drop group to a vanilla entity in salvage_entity_gen_data.csv, will it get overridden by other mods that also add groups to the same entity but are later in load order? Or do they get merged?

CSV rows never get merged, only one of the rows will be used. (I always forget whether it's first or last in load order, but one of those.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 10, 2020, 09:07:08 AM
Thanks! Any way to add that via code on sector gen then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on July 11, 2020, 08:21:42 AM
Please forgive my obsession, but I'm here again.

So, I'm trying to make a simple hullmod that will force the ship to automatically venting when the condition is met. There were no problems with defining the condition. But for the third hour now I have been fighting the venting command. Everything should be simple, since in ShipCommand.java it is not at all difficult to find that it is VENT_FLUX.

But here my hands, growing out of ***, prove themselves! Can someone give a ready-made string to execute the command?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 11, 2020, 08:47:05 AM
Thanks! Any way to add that via code on sector gen then?

You'd have to add it to specific entities; see:
http://fractalsoftworks.com/forum/index.php?topic=15244.0

Probably want to do it in ModPlugin.onNewGame() or thereabouts.

Please forgive my obsession, but I'm here again.

So, I'm trying to make a simple hullmod that will force the ship to automatically venting when the condition is met. There were no problems with defining the condition. But for the third hour now I have been fighting the venting command. Everything should be simple, since in ShipCommand.java it is not at all difficult to find that it is VENT_FLUX.

But here my hands, growing out of ***, prove themselves! Can someone give a ready-made string to execute the command?

ship.giveCommand(ShipCommand.VENT_FLUX, null, 0);

Along with the requisite imports etc. (If you haven't already, setting up an IDE might be worthwhile, since you'll get specific errors for these sorts of issues which should point you in the right direction, generally.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Professor Pinkie on July 11, 2020, 09:01:25 AM
Perfect! Works as it should. I forgot ship.giveCommand part.

Thank you very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mayu on July 11, 2020, 10:22:16 AM
Hello everyone, I am a complete newbie to this and I am having a problem of adding a custom market condition. What I want to happen is to increase the fuel production and to lessen the Volatiles demand. The thing is that, the code below does increase fuel production by 2 but the demand remains unaffected. Could anyone kind enough to give me a guidance here, thanks!


Spoiler
Code

package data.scripts.campaign.econ;

import com.fs.starfarer.api.campaign.econ.Industry;
import com.fs.starfarer.api.impl.campaign.econ.BaseHazardCondition;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.util.Misc;

public class amfuel extends BaseHazardCondition{

private final int FUEL_BONUS=2;

public void apply(String id) {

Industry industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
        }

        industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            if (industry.isFunctional()) {
               industry.supply(id + "_0", Commodities.FUEL, FUEL_BONUS, "Central Fuel Production");
            } else {
               industry.getSupply(Commodities.FUEL).getQuantity().unmodifyFlat(id + "_0");
            }
        }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 12, 2020, 08:27:38 AM
Last suggestion works, thanks for pointing me towards the documentation.

Another questions, I'd like to edit the following tooltip on a per-fleetmember basis:
(https://i.imgur.com/UmAvS50.png)

is this possible? If yes, where?

Hello everyone, I am a complete newbie to this and I am having a problem of adding a custom market condition. What I want to happen is to increase the fuel production and to lessen the Volatiles demand. The thing is that, the code below does increase fuel production by 2 but the demand remains unaffected. Could anyone kind enough to give me a guidance here, thanks!

Spoiler
Code

package data.scripts.campaign.econ;

import com.fs.starfarer.api.campaign.econ.Industry;
import com.fs.starfarer.api.impl.campaign.econ.BaseHazardCondition;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.util.Misc;

public class amfuel extends BaseHazardCondition{

private final int FUEL_BONUS=2;

public void apply(String id) {

Industry industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
        }

        industry = market.getIndustry(Industries.FUELPROD);
        if(industry!=null){
            if (industry.isFunctional()) {
               industry.supply(id + "_0", Commodities.FUEL, FUEL_BONUS, "Central Fuel Production");
            } else {
               industry.getSupply(Commodities.FUEL).getQuantity().unmodifyFlat(id + "_0");
            }
        }
}
[close]
change
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
to
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id, -2);
"" denotes a string (also called text) in java. You just modified the id by adding a "-2" to it, while the actual modifier was 0.
consider using an IDE; it will make your life easier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 12, 2020, 08:43:46 AM
Last suggestion works, thanks for pointing me towards the documentation.

Glad you got it working!

Another questions, I'd like to edit the following tooltip on a per-fleetmember basis:
(https://i.imgur.com/UmAvS50.png)

is this possible? If yes, where?

Ah, not possible, unfortunately. IIRC it's just a string - possibly loaded from strings.json (or maybe not), but either way, not customizable per ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 12, 2020, 09:22:42 AM
Thanks for the answer,
I'm just wondering because it seems to be implemented for other submarkets:
(https://i.imgur.com/qQERKfk.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 12, 2020, 09:30:04 AM
Yeah, it's just those two cases based on whether it's storage or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 12, 2020, 09:39:17 AM
How do you get a hand-crafted nebula system to be called "XYZ Nebula" instead of "XYZ Star System"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 12, 2020, 09:43:12 AM
system.setType(StarSystemType.NEBULA) *before* calling system.setBaseName().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 12, 2020, 09:45:14 AM
Thought I tried that right before posting, but I must have forgotten to recompile. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hiroyan495 on July 12, 2020, 06:33:47 PM
I know this is going to sound like madness... and it is.

But what if you were to hypothetically say... that you tried to have 14 description parameters in your test-hullmod and the game doesn't have any of your sh*t after the 9th one?
I tested around a lot and it really seems like it's not an issue with me having a typo in my hull_mods.csv.

Spoiler
99189 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.util.MissingFormatArgumentException: Format specifier 's'
java.util.MissingFormatArgumentException: Format specifier 's'
   at java.util.Formatter.format(Unknown Source)
   at java.util.Formatter.format(Unknown Source)
   at java.lang.String.format(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.addPara(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.addPara(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2$12.createImpl(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.create(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.beforeShown(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.showTooltip(Unknown Source)
   at com.fs.starfarer.ui.Objectsuper.public.super(Unknown Source)
   at com.fs.starfarer.ui.Objectsuper.processInput(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.e$Oo.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.e.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.N.processInputImpl(Unknown Source)
   at com.fs.starfarer.coreui.refit.ModPickerDialogV3.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.N.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.O0oO.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.N.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.Objectsuper.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.processInput(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

^ The log ^

Spoiler
Installing an archotech core into the ship systems significantly improves its performance and gives the ship its own personality.

Usually only utilized by rogue AI, as the core remains dormant until it is host to an alpha-level AI core.

Nanomachines take care of all reparations and maintenance, engines run mostly on power and garbage is recycled.

- Reduces the rate at which combat readiness degrades by %s
- Reduces supply use for maintenance and fuel use by %s
- Increases the repair rate by %s
- Increases the combat readiness recovery rate by %s
- Reduces the time required to repair disabled weapons and engines (in combat) by %s
- As the ship is fully automated, the need for a crew is completely removed

Conduits, resembling tentacles, extend from the core, providing the entire ship with power, generated by the core itself
This results in a vastly better performance of the ship systems and a higher flux efficiency.

- Increases maximum burn level by %s
- The ship's sensor profile is reduced by %s
- Weapon fire costs are reduced by %s
- Reduces the amount of damage taken by shields by %s
- Reduces the amount of soft flux raised shields generate per second by %s
- Increases the ship's top speed in combat by %s/%s/%s/%s su/second, depending on hull size
- Increases the ship's maneuverability by %s
[close]

Spoiler
public String getDescriptionParam(int index, HullSize hullSize) {
      if (index == 0) return "" + (int) DEGRADE_REDUCTION_PERCENT + "%";
      if (index == 1) return "" + (int) (100f - (MAINTENANCE_MULT * 100f)) + "%";
      if (index == 2) return "" + (int) Math.round(REPAIR_RATE_BONUS) + "%";
      if (index == 3) return "" + (int) Math.round(CR_RECOVERY_BONUS) + "%";
      if (index == 4) return "" + (int) REPAIR_BONUS + "%";
      if (index == 5) return "" + BURN_LEVEL_BONUS;
      if (index == 6) return "" + (int) (100f - (PROFILE_MULT * 100f)) + "%";
      if (index == 7) return "" + (int) (100f - (WEAPON_FLUX_COST_MULT * 100f)) + "%";
      if (index == 8) return "" + (int) SHIELD_BONUS + "%";
      if (index == 9) return "" + (int) SHIELD_UPKEEP_BONUS + "%";
      if (index == 10) return "" + ((Float) speed.get(HullSize.FRIGATE)).intValue();
      if (index == 11) return "" + ((Float) speed.get(HullSize.DESTROYER)).intValue();
      if (index == 12) return "" + ((Float) speed.get(HullSize.CRUISER)).intValue();
      if (index == 13) return "" + ((Float) speed.get(HullSize.CAPITAL_SHIP)).intValue();
      if (index == 14) return "" + (int) MANEUVER_BONUS + "%";
      return null;
   }
[close]

The hullmod itself seems to work fine in the game, but as soon as you hover over the description the game crashes. I tried commenting any parameters after index == 9 out and removing the values from the hull_mods.csv accordingly, which resulted in the game not crashing and displaying all values correctly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 12, 2020, 06:37:57 PM
Yeah, it just supports up to 10 total values; sorry :)

(Didn't think anyone would be crazy enough, etc etc.)

The good news is in the next release, HullModEffect will have these methods:

boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec);
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec);

Which means you'll be able to compose the entire tooltip with code, basically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hiroyan495 on July 12, 2020, 06:44:18 PM
I'm looking forward to it! Thanks for the quick reply Alex! I'll figure out a temporary solution. :^)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 13, 2020, 12:22:03 AM
In BattleCreationContext, what's the difference between aiRetreatAllowed and fightToTheLast?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mayu on July 13, 2020, 12:29:43 AM
change
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id + "-2", 0);
to
Code
industry.getDemand(Commodities.VOLATILES).getQuantity().modifyFlat(id, -2);
"" denotes a string (also called text) in java. You just modified the id by adding a "-2" to it, while the actual modifier was 0.
consider using an IDE; it will make your life easier.

It worked nicely, thank you very much Sir Hartley! Also, I'll follow your advice about using IDE.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 13, 2020, 09:14:44 AM
In BattleCreationContext, what's the difference between aiRetreatAllowed and fightToTheLast?

"fightToTheLast" will make the AI give "full assault" orders at a time when it would usually give full retreat orders. So it might still retreat a ship or two piecemeal before that point, unless "aiRetreatAllowed" is also set.

(Not the best or cleanest of distinctions, to be perfectly honest, I think I wasn't thinking about "aiRetreatAllowed" existing when adding "fightToTheLast", and that was part of a multi-pronged approach to help solve a specific problem - cleanup of the last few ships being tedious - so it's just pretty narrow and specific.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 14, 2020, 02:45:03 PM
Been digging around the API, and though I know I can clear known hullmods from factions (to replace them with custom versions), I can't seem to find a way to set a vanilla hullmod to HIDDEN (so it won't spawn in markets) through code instead of the csv file. Is this possible, or is this even necessary? Does removing them from variants and the known hullmods list prevent them from showing up in markets? I know it prevents them from showing up in autofit fleets, but I wasn't sure about the market part.

Also, if the above is true, do they ever spawn randomly in loot?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 14, 2020, 03:21:14 PM
Isn't there a HullModSpecAPI.setHidden() method? Might not be in the current release, hmm.

IIRC the stuff for sale is from the faction's known hullmods. As far as drops, yeah, they could drop if they're not hidden, since drops are based on tags. I *think* if you add a no_drop tag to the hullmod it won't drop but I'm not 100% sure that in the currently-released version all the drop groups respect the tag.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 14, 2020, 03:35:30 PM
Isn't there a HullModSpecAPI.setHidden() method? Might not be in the current release, hmm.

IIRC the stuff for sale is from the faction's known hullmods. As far as drops, yeah, they could drop if they're not hidden, since drops are based on tags. I *think* if you add a no_drop tag to the hullmod it won't drop but I'm not 100% sure that in the currently-released version all the drop groups respect the tag.

There might be but I can't verify because: The problem is that I can't seem to find a way to get the list of all HullModSpecAPIs from Global. I haven't thoroughly checked, to be sure, but I can't find anything that actually returns that object. Maybe it is in persistentData? If so, what is the key and return value? List, Map, Set, etc?

If I can get access to those I can both add that tag and set them as hidden and hope for the best! And that way I can set it up to be configurable in settings. Otherwise I just have to use the csv override, but it's better than nothing!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 14, 2020, 03:41:04 PM
Ah - SettingsAPI has:
List<HullModSpecAPI> getAllHullModSpecs();

I highly recommend checking the javadoc, here:
http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

In this case for example you could open up the page for SettingsAPI (which has all this kind of stuff) and search for "hullmod".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 14, 2020, 03:46:41 PM
Ah - SettingsAPI has:
List<HullModSpecAPI> getAllHullModSpecs();

I highly recommend checking the javadoc, here:
http://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

In this case for example you could open up the page for SettingsAPI (which has all this kind of stuff) and search for "hullmod".

Ah thanks! Most helpful! Never would have thought it would be under settings. I don't check that doc as often as I should. I generally assume the IDE can handle the searching, but keyword searching from the doc is much better here if I have no clue where to start. Good point!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 14, 2020, 03:47:43 PM
(Yeah, SettingsAPI is the place for almost everything that's not specific to a particular savegame.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 14, 2020, 05:26:10 PM
(Yeah, SettingsAPI is the place for almost everything that's not specific to a particular savegame.)

Ah, interesting. I'll try to remember that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 15, 2020, 01:13:44 PM
When using the boolean = removeAll(Collection), does it assume that each value in the collection actually exists in the set in question?

I'm using:

Code
        Iterator<FactionAPI> allFactions = Global.getSector().getAllFactions().iterator();
        Map<String, String> vanillaFactions = vanillaIDsDatabase.getFactionIDs();
        while (allFactions.hasNext()) {
            if (vanillaFactions.containsKey(allFactions.next().getId())) {
                if (!allFactions.next().getKnownFighters().removeAll(vanillaIDsDatabase.getOverriddenFighterWingIDs().values())) {
                    LOG.error("Could not remove all overridden vanilla fighter wings from " + allFactions.next().getId());
                }
                if (!allFactions.next().getPriorityFighters().removeAll(vanillaIDsDatabase.getOverriddenFighterWingIDs().values())) {
                    LOG.error("Could not remove all overridden priority vanilla fighter wings from " + allFactions.next().getId());
                }
            }
        }

This:
- Checks to make sure the faction is a vanilla one.
- Uses the values() method of a map containing the fighter wing ids for each vanilla fighter to remove them all from known fighters and priority fighters.
- Logs if this wasn't successful. Not sure if it logs if one isn't removed or only if all aren't removed.

Log:
Spoiler
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla hullmods from remnant
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla hullmods from hegemony
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from poor
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from independent
42157 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla fighter wings from persean
42158 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from knights_of_ludd
42158 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden vanilla fighter wings from adamantine_consortium
42158 [Thread-4] ERROR data.scripts.overrides.VanillaOverridesManager  - Could not remove all overridden priority vanilla fighter wings from tritachyon
[close]

Annnd looking at this... why the heck is it trying to do that for admantine_consortium?? That's not even in the ids map and should have failed the containsKey() check!  Arrgh that... doesn't make any sense! >:(

*EDIT*
Wait a minute, trying to think back to college but I think I understand what's going on now. I need to assign the Iterator.next() to a FactionAPI instead and use that when I need to check multiple things.

It's not failing the containsKey() it's just going to the next FactionAPI every time I call the next() method! *Feels dumb*

Anyway the initial question remains. Would it be better to iterate through the values, check for them to exist in the set and them remove them one by one? Or should passing in the collection do the job? Thanks!

Map contents:
Spoiler
public class VanillaIDsDatabase {

    private static final Map<String, String> FACTION_IDS = new HashMap<>();
   private static final Map<String, String> HULLMOD_IDS = new HashMap<>();
    private static final Map<String, String> FIGHTER_SHIP_IDS = new HashMap<>();
   private static final Map<String, String> FIGHTER_WING_IDS = new HashMap<>();

   public void initMaps() {

       // Vanilla faction ids.
        FACTION_IDS.put("hegemony", "hegemony");
        FACTION_IDS.put("luddic_church", "luddic_church");
        FACTION_IDS.put("luddic_path", "luddic_path");
        FACTION_IDS.put("sindrian_diktat", "sindrian_diktat");
        FACTION_IDS.put("derelict", "derelict");
        FACTION_IDS.put("independent", "independent");
        FACTION_IDS.put("knights_of_ludd", "knights_of_ludd");
        FACTION_IDS.put("lions_guard", "lions_guard");
        FACTION_IDS.put("persean_league", "persean_league");
        FACTION_IDS.put("pirates", "pirates");
        FACTION_IDS.put("remnant", "remnant");
        FACTION_IDS.put("scavengers", "scavengers");
        FACTION_IDS.put("tritachyon", "tritachyon");

        // Currently overridden vanilla hullmod ids.
       HULLMOD_IDS.put("advancedoptics", "advancedoptics");
       HULLMOD_IDS.put("turretgyros", "turretgyros");
       HULLMOD_IDS.put("magazines", "magazines");
       HULLMOD_IDS.put("missleracks", "missleracks");
       HULLMOD_IDS.put("extendedshieldemitter", "extendedshieldemitter");
       HULLMOD_IDS.put("frontemitter", "frontemitter");
        HULLMOD_IDS.put("fluxcoil", "fluxcoil");
        HULLMOD_IDS.put("fluxdistributor", "fluxdistributor");
        HULLMOD_IDS.put("converted_hangar", "converted_hangar");
        HULLMOD_IDS.put("operations_center", "operations_center");
        HULLMOD_IDS.put("frontshield", "frontshield");
        HULLMOD_IDS.put("heavyarmor", "heavyarmor");
        HULLMOD_IDS.put("targetingunit", "targetingunit");
        HULLMOD_IDS.put("adaptiveshields", "adaptiveshields");
        HULLMOD_IDS.put("safetyoverrides", "safetyoverrides");
        HULLMOD_IDS.put("stabilizedshieldemitter", "stabilizedshieldemitter");
        HULLMOD_IDS.put("dedicated_targeting_core", "dedicated_targeting_core");
        HULLMOD_IDS.put("augmentedengines", "augmentedengines");
        HULLMOD_IDS.put("expanded_deck_crew", "expanded_deck_crew");
        HULLMOD_IDS.put("unstable_injector", "unstable_injector");
        HULLMOD_IDS.put("armoredweapons", "armoredweapons");
        HULLMOD_IDS.put("autorepair", "autorepair");

        // Add vanilla fighter ship definition ids.
        FIGHTER_SHIP_IDS.put("talon", "talon");
        FIGHTER_SHIP_IDS.put("dagger", "dagger");
        FIGHTER_SHIP_IDS.put("wasp", "wasp");
        FIGHTER_SHIP_IDS.put("xyphos", "xyphos");
        FIGHTER_SHIP_IDS.put("broadsword", "broadsword");
        FIGHTER_SHIP_IDS.put("piranha", "piranha");
        FIGHTER_SHIP_IDS.put("trident", "trident");
        FIGHTER_SHIP_IDS.put("longbow", "longbow");
        FIGHTER_SHIP_IDS.put("mining_drone", "mining_drone");
        FIGHTER_SHIP_IDS.put("gladius", "gladius");
        FIGHTER_SHIP_IDS.put("warthog", "warthog");
        FIGHTER_SHIP_IDS.put("thunder", "thunder");
        FIGHTER_SHIP_IDS.put("claw", "claw");
        FIGHTER_SHIP_IDS.put("hoplon", "hoplon");
        FIGHTER_SHIP_IDS.put("spark", "spark");
        FIGHTER_SHIP_IDS.put("lux", "lux");
        FIGHTER_SHIP_IDS.put("flash", "flash");
        FIGHTER_SHIP_IDS.put("perdition", "perdition");
        FIGHTER_SHIP_IDS.put("cobra", "cobra");

        // Add vanilla fighter wing ids.
        FIGHTER_WING_IDS.put("talon_wing", "talon_wing");
        FIGHTER_WING_IDS.put("xyphos_wing", "xyphos_wing");
        FIGHTER_WING_IDS.put("gladius_wing", "gladius_wing");
        FIGHTER_WING_IDS.put("warthog_wing", "warthog_wing");
        FIGHTER_WING_IDS.put("thunder_wing", "thunder_wing");
        FIGHTER_WING_IDS.put("claw_wing", "claw_wing");
        FIGHTER_WING_IDS.put("wasp_wing", "wasp_wing");
        FIGHTER_WING_IDS.put("dagger_wing", "dagger_wing");
        FIGHTER_WING_IDS.put("piranha_wing", "piranha_wing");
        FIGHTER_WING_IDS.put("trident_wing", "trident_wing");
        FIGHTER_WING_IDS.put("perdition_wing", "perdition_wing");
        FIGHTER_WING_IDS.put("cobra_wing", "cobra_wing");
        FIGHTER_WING_IDS.put("longbow_wing", "longbow_wing");
        FIGHTER_WING_IDS.put("mining_drone_wing,", "mining_drone_wing,");
        FIGHTER_WING_IDS.put("flash_wing", "flash_wing");
        FIGHTER_WING_IDS.put("spark_wing", "spark_wing");
        FIGHTER_WING_IDS.put("lux_wing", "lux_wing");
   }

    public Map<String, String> getFactionIDs() {
        return FACTION_IDS;
    }

   public Map<String, String> getOverriddenHullmodIDs() {
        return HULLMOD_IDS;
    }

    public Map<String, String> getOverriddenFighterShipIDs() {
        return FIGHTER_SHIP_IDS;
    }

    public Map<String, String> getOverriddenFighterWingIDs() {
        return FIGHTER_WING_IDS;
    }
}

[close]

*EDIT 2*

Ahh, nvm - missed this part of the interface documentation:     * @return <tt>true</tt> if this set changed as a result of the call

I only read the description at first and that part didn't seem clear. Should of kept reading. ::)
Hmm, now I'm wondering why the call is returning false so often. The set should have changed. Sigh, back to the drawing board.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2020, 05:42:30 PM
I feel like the check here is actually unnecessary. You're removing stuff and it's going to remove stuff. The only reason you'd care about the return value is if you need to know whether all the things you passed in were present and removed, or not.

But regardless of that, the outcome is that the set you're removing things from will not have *any* of the things passed in to removeAll() - so unless I'm missing something, I don't think you need to check.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 15, 2020, 05:58:26 PM
I feel like the check here is actually unnecessary. You're removing stuff and it's going to remove stuff. The only reason you'd care about the return value is if you need to know whether all the things you passed in were present and removed, or not.

But regardless of that, the outcome is that the set you're removing things from will not have *any* of the things passed in to removeAll() - so unless I'm missing something, I don't think you need to check.

Agreed yeah. I wasn't understanding the method correctly until I caught that part of the interface doc. At one point IntelliJ weirdly wanted me to apply the method to a boolean.. but it's not now. Not sure why it was at the time. I've removed the check and logged the necessary sets after the call was made, and so far they all work correctly.

Once I verify each facet of the override is doing what it should, I'll probably remove the logging altogether- with the exception for when a spec is returned null by its id- just in case it ever changes for some reason.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on July 17, 2020, 10:14:09 AM
Is it possible to get a hullmod to remove/unequip specific fighter wings on the refit screen when certain conditions are met? I am able to remove fighter bays, but the fighters stay equipped and hidden, taking up OP.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mondaymonkey on July 17, 2020, 10:22:47 AM
Is it possible to get a hullmod to remove/unequip specific fighter wings on the refit screen when certain conditions are met? I am able to remove fighter bays, but the fighters stay equipped and hidden, taking up OP.

stats.getVariant().clear();

Spoiler
Joke
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on July 17, 2020, 10:53:58 AM
Is it possible to get a hullmod to remove/unequip specific fighter wings on the refit screen when certain conditions are met? I am able to remove fighter bays, but the fighters stay equipped and hidden, taking up OP.

stats.getVariant().clear();

Spoiler
Joke
[close]

Aye try that lol

Or rather, stats.getVariant() has various 'getWing' and 'setWing' functions, and can return what I assume is an indexed list of wings, or set a specific index.   

I haven't tried it myself but that looks like what you need?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on July 17, 2020, 11:08:01 AM

stats.getVariant().clear();

Spoiler
Joke
[close]
I'm this close to doing that lol. Map out the whole ship, clear the variant, and rebuild it again minus one wing...there's got to be a better way.

Or rather, stats.getVariant() has various 'getWing' and 'setWing' functions, and can return what I assume is an indexed list of wings, or set a specific index.   

I haven't tried it myself but that looks like what you need?


Having sifted through there, I could only find ways to remove hullmods and clear weapon slots.
Edit: Let me see, I'll try setting wing ID to an empty string.
Edit2: You're right, this is just what I needed, it's working. Thanks!
Edit3: Scratch that. It's removing the wings from the game entirely, not unequipping them.
Edit4: Heck it, I can add the LPC back into the player's inventory manually. Yeah, that'll work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mondaymonkey on July 17, 2020, 11:18:36 AM
I could only find ways to remove hullmods and clear weapon slots.

maybe setWingId(int index, String wingId);?

What will happen if id set to null? (or which is default "empty" value?)

EDIT: I am late...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 17, 2020, 12:29:20 PM
Edit4: Heck it, I can add the LPC back into the player's inventory manually. Yeah, that'll work.

(Yeah, you'd need to do that. Variants are not directly tied to the player inventory.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mondaymonkey on July 17, 2020, 12:38:01 PM
Quote
Reply #6666

That is a sign! I just have to ask it right now.

Projectile files can have engine slots. Can they have weapon slots/fighter bays?

P.S. Ya! The BFG10K!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on July 17, 2020, 12:44:04 PM
Well, it's not going to work after all. Can't really mess with majicking LPCs up when they might be getting bought from a market and refunded. I'm going to try getVariant().clear() for reals.

Edit: Doesn't look like that will work either. I can't find a way to equip wings from getVariant(). Best I can do is remove all wings and reset everything else...I can settle for that.
Edit2: No, that won't work either. Seems clear() also deletes stuff outright instead of unequipping them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 17, 2020, 07:42:28 PM
Well, it's not going to work after all. Can't really mess with majicking LPCs up when they might be getting bought from a market and refunded. I'm going to try getVariant().clear() for reals.

Edit: Doesn't look like that will work either. I can't find a way to equip wings from getVariant(). Best I can do is remove all wings and reset everything else...I can settle for that.
Edit2: No, that won't work either. Seems clear() also deletes stuff outright instead of unequipping them.

Well, assuming you can get all the available ids from the variant, you could put them in a map and then manually add them to the player's inventory by getting the item by id. And then clear the variant. Or did you already try this?

See:

Code
            Global.getSector().getPlayerFleet().getCargo().addFighters(id, count);

For count, you could iterate through the variant and count the instances that the weapon/fighter appears.

Then, if you were wanting to put the weapons back on the variants in their correct slots, you could map the weapon ids to slot ids through:
Code
Iterator<String> slotIds = ShipVariantAPI.getNonBuiltInWeaponSlots().iterator();
Map<String, String> weaponMap = new HashMap();
String id;
while (slotIds.hasNext()) {
    id = slotIds.next();
    weaponMap.put(id, ShipVariantAPI.getWeaponId(id));
}
**Add Fighter Wings to Cargo Here!**
ShipVariantAPI.clear();
Iterator<String> weaponIterator = weaponMap.keySet().iterator();
while (weaponIterator.hasNext()) {
    id = weaponIterator.next();
    ShipVariantAPI.addWeapon(id, weaponMap.get(id));
}
   
- Similar things can be done with hullmods, vents/caps, ensuring properly set weapon groups, etc.
 - That's an example, but what you are attempting should be possible with the exception of adding the fighters back on. That's assuming setWingId() can't be used to add fighters rather than remove them.

If you need more examples, I can try and help further.

*Edit* Edited code for more clarity in terms of the original request and corrected a code typo. (getVariant() returns the ShipVariantAPI of the ship in question)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on July 18, 2020, 02:00:41 AM
Thanks Morrokain, I had tried a structure very similar to that. The problem came when attempting to do any refit with a market involved. With the wings being bought from the market, a player could trigger the refit (+1 LPC in inventory) and then click Undo and get a full refund for the LPC, while keeping it. Sell it back - free money exploit.

I did find a solution, which was to remove all bays entirely, then add them back. I noticed fighters are removed properly when a converted hangar is removed. I think this might be the only way to unequip fighters.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 18, 2020, 01:13:20 PM
Thanks Morrokain, I had tried a structure very similar to that. The problem came when attempting to do any refit with a market involved. With the wings being bought from the market, a player could trigger the refit (+1 LPC in inventory) and then click Undo and get a full refund for the LPC, while keeping it. Sell it back - free money exploit.

I did find a solution, which was to remove all bays entirely, then add them back. I noticed fighters are removed properly when a converted hangar is removed. I think this might be the only way to unequip fighters.

Ahh, ok I wouldn't have thought of that exploit that makes sense. Glad you figured out a way, anyway.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 18, 2020, 03:51:56 PM
I don't see an API hook for getKnownBlueprints() from the FactionAPI.

So the question is, is there any way for the player to get blueprint packages from raiding factions? Individual blueprints are not a concern because ships have UNBOARDABLE and things like "base_bp" and "rare_bp" have been removed. I want to keep the bp package tags for each item, though, since other mods like Nex and faction mods rely on giving out these packages at the start of a new campaign so I want their contents preserved - I just want them to be unavailable to get in the pure TC configuration.

The concern is that things like knownShips and knownWeapons accepts blueprint packages as a parameter. Since I'm no longer overriding faction files in their entirety, I am looking to prevent the case where the player can get access to vanilla blueprint packages (for instance an unmodified xiv_bp_package) by salvage or raiding unless they choose to by editing the settings configuration. The faction won't actually know the contents of the blueprint package since I remove that manually through another setting, but if the package drops then the player can still learn them. Especially since fleet composition isn't completely customize-able, that could really mess with player faction npc fleets.

I know that leaving some areas blank or changing some areas of the file overrides the array instead of merging it, so is that a factor here to allow me to perform that use case? I haven't checked for access to a BlueprintSpecAPI or anything yet, so maybe I can set the rarity of salvage to zero through that? Or add the no_drop tag and that will cover it in all cases?

Weapons, Fighters, Hullmods and Ships have all been configured and seem to work as intended. I just haven't added the skin ids yet to test that out. Blueprints are the last outstanding item to make the TC completely configurable for market and salvage items. I might even be able to do many things in the middle of a game instead of requiring a new game - such as enabling vanilla content in markets at the endgame if the player gets bored or wants to compare stats, etc.

After that, I need to deal with stations if I can. Not sure how possible that is though since iirc I can't actually prevent buildable station variants from showing up in the list when the industry is being selected to build. So even if I made unique station ids and manually changed the existing core worlds stations, the player could still build vanilla station variants (and be at a severe disadvantage since those have less modules/weapons/fighters)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2020, 12:01:37 PM
I don't see an API hook for getKnownBlueprints() from the FactionAPI.

I'm not sure I understand - FactionAPI.getKnownShips() etc is all there, right?

In the .faction files, being able to specify by tag (NOT by blueprint package) is just shorthand for populating the knownShips etc fields. Where a "knowing" a specific hull came from isn't information that's retained.

... but if the package drops then the player can still learn them. Especially since fleet composition isn't completely customize-able, that could really mess with player faction npc fleets.

Ah, I think I see - that's not a thing, raiding isn't going to drop blueprint packages. There's no concept of "a faction knowing a specific blueprint package". As I mentioned earlier, there's just tag-based shorthand for populating known ships etc via the .faction files, but even that isn't reliant on or aware of blueprint packages.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2020, 04:42:18 PM
I don't see an API hook for getKnownBlueprints() from the FactionAPI.

I'm not sure I understand - FactionAPI.getKnownShips() etc is all there, right?

In the .faction files, being able to specify by tag (NOT by blueprint package) is just shorthand for populating the knownShips etc fields. Where a "knowing" a specific hull came from isn't information that's retained.

... but if the package drops then the player can still learn them. Especially since fleet composition isn't completely customize-able, that could really mess with player faction npc fleets.

Ah, I think I see - that's not a thing, raiding isn't going to drop blueprint packages. There's no concept of "a faction knowing a specific blueprint package". As I mentioned earlier, there's just tag-based shorthand for populating known ships etc via the .faction files, but even that isn't reliant on or aware of blueprint packages.

Ok great that's one less thing to worry about. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 20, 2020, 05:54:43 AM
What's the AI difference of ships which have shield or not?
If I set the radius of shield to 0 in the combat, would the ship's act like the ship without shield?

And how to render weapons below the ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hiroyan495 on July 20, 2020, 06:12:43 AM
What files are affected by a ship being removed from a mod?

So far I removed it from "hulls", "variants" (folders), ship_data.csv, sim_opponents.csv, unique_bounty_data.csv and from the files in "factions".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mondaymonkey on July 20, 2020, 07:10:55 AM
and from the files in "factions".

In "factions" folder there are "default ship roles".

Also, descriptions and title screen variants, skins (if there are one for this hull), missions (if they use it) and I am not sure it's a full list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hiroyan495 on July 20, 2020, 07:57:31 AM
Thanks a lot!  8)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 20, 2020, 11:40:12 AM
What's the AI difference of ships which have shield or not?

Not very much - some minor differences, I think (I don't remember the details) but generally it's very similar. I think it might be more likely to vent in some circumstances.

If I set the radius of shield to 0 in the combat, would the ship's act like the ship without shield?

No, definitely not.

And how to render weapons below the ship?

I don't *think* that's possible, but someone please correct me if I'm wrong.

Basically, I think the approach would be to have a decorative weapon that looks like a portion of the hull render above the weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on July 21, 2020, 12:51:26 AM
I know there was a lot of discussion about convo highlights in this thread previously, but I can't find the answer I need.

Currently putting two strings into an addPara line then highlighting them:

textPanel.addPara("There are "+nowcreds+" Credits remaining, and this will take "+nowdays+" days to complete.");
textPanel.highlightInLastPara(HIGHLIGHT_COLOR, nowcreds, nowdays);

And this of course works fine with hard-coded strings I type. 

But when I use a formatter to make the strings from a float, this fails: the first string is highlighted but has extra whitespace in front, while the second string never highlights.  I have tried using a different formatter for each string etc, the other addPara highlight methods, and LabelAPI.setHighlight too.

How is the hardcode string different from the string made by the formatter? I thought they would be identical at the end.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 21, 2020, 09:33:23 AM
Hmm - it would help to see what you're doing in the case that doesn't work.

(In case it's relevant: highlights require whitespace or punctuation around them, so e.g. you couldn't highlight half of a word, or some such.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on July 21, 2020, 11:52:22 AM
Hmm - it would help to see what you're doing in the case that doesn't work.

(In case it's relevant: highlights require whitespace or punctuation around them, so e.g. you couldn't highlight half of a word, or some such.)

Alrighty then, here we go.  I'm pulling some data to calculate time and credits remaining, then displaying it to the user. The issue is the same when I access it later and the numbers change.

In this example I have manually set the strings at the end, so this displays how I want:

Spoiler

Code
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);
                           
                            // SET MANUALLY
                            fmt_days = "120";
                            fmt_creds = "50,000";

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);
                           
                            // SET MANUALLY
                            fmt_days = "120";
                            fmt_creds = "50,000";

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);

(https://drive.google.com/uc?export=view&id=1wTlYwOGksUNd0UTKs29Q48urHCIxEOXj)

[close]

Aaaand here is it not working:

Spoiler

Code
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);

                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);

(https://drive.google.com/uc?export=view&id=1vvnBN-Ej79PE0jN1mT4xfLlC2Pzou21d)

[close]

Extra space on the left of the first highlight, and no second highlight.

EDIT: whoops had the second image as private. fixed now
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 21, 2020, 12:14:24 PM
Hmm - the second image link seems broken.

formattera.format("%, d", (int)daysleft);

This seems like the issue has to do with how you're using the formatter. I'm not familiar with how the format string for it works, but provided you're getting the same output as the "manual" entered strings, the result would have to be the same. So if it's not, then the output isn't either... what you were saying about an extra space showing up seems to confirm that, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on July 21, 2020, 12:33:58 PM
Hmm - the second image link seems broken.

formattera.format("%, d", (int)daysleft);

This seems like the issue has to do with how you're using the formatter. I'm not familiar with how the format string for it works, but provided you're getting the same output as the "manual" entered strings, the result would have to be the same. So if it's not, then the output isn't either... what you were saying about an extra space showing up seems to confirm that, too.

Right on the money! cheers

It looks like the space I left in the Format string ("%, d") was the problem.  It caused the space to appear on the first highlight, and also stopped the second highlight entirely because reasons (???????)

Simply removing that space solved the issue:
formattera.format("%,d", (int)daysleft);

with that sorted, working code now shortened:
Spoiler
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);

                            String fmt_days = String.format("%,d", (int)daysleft);
                            String fmt_creds = String.format("%,d", (int)credsleft);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 21, 2020, 12:46:00 PM
Personally, I've had more success with using the LabelAPI returned from addParagraph() than I have with setting highlights during the addPara() just in general. It's been too long since I wrote that code to quite remember why though.

I think part of it is that I wanted to use an array of both highlights and highlight colors.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 21, 2020, 12:57:06 PM
Nice, glad you got it working!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 22, 2020, 06:34:48 AM
How do I change the background of a campaign battle? Calling MissionDefinitionAPI.setBackgroundSpriteName() in the BattleCreationPlugin doesn't seem to do anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 22, 2020, 10:17:30 AM
Hmm - vanilla uses this method and it seems to work. I just tried:

loader.setBackgroundSpriteName("graphics/ships/onslaught/onslaught_base.png");

in BattleCreationPluginImpl and it did it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 22, 2020, 01:03:07 PM
Why I can't deactivate my special defense system(right-click system) on a ship with modules?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 22, 2020, 01:18:55 PM
Can/did you try it on a ship without modules to see if that's actually the issue? It doesn't seem to me like the ship having modules would factor into the right-click system's operation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 22, 2020, 01:31:30 PM
Can/did you try it on a ship without modules to see if that's actually the issue? It doesn't seem to me like the ship having modules would factor into the right-click system's operation.
Well I tried to give vanilla phasecloak to the ship with modules, and it can't be deactivated too until the flux is full.
It seems that if there are entities(ships or modules) above the ship, PHASE_CLOAK won't be deactivated by player(gameplay in vanilla)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 22, 2020, 01:35:57 PM
Ah, yes, if it's a phase cloak, that'll be a problem. But if it's another type of right-click system, it would be fine.

A phase cloak isn't going to work with a ship with modules; among other things it's not going to phase the modules. But, yeah, it'll also be unable to unphase; let me change that on my end. If the modules were set to "fighter" it'd be able to unphase, btw, but that could be undesirable for other reasons...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 22, 2020, 06:20:10 PM
Hmm - vanilla uses this method and it seems to work. I just tried:

loader.setBackgroundSpriteName("graphics/ships/onslaught/onslaught_base.png");

in BattleCreationPluginImpl and it did it.
Seems that Onslaught background works, something like illustrations/bombardment_saturation.jpg works, but I can't get e.g. backgrounds/hyperspace_bg_cool.jpg to work (even if I travel to hyperspace before entering the battle).
Is this because of how the game handles system backgrounds?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Rohzdear on July 22, 2020, 07:59:20 PM
Reposting my question from a new thread into this one as it was suggested.

Quote
Hi there.

I am a novice in Starsector modding, and although I haven't released anything in the Forum yet I've done some small mods for personal use. I was planning on releasing a Portrait Pack with new portraits, but I was looking for a way to remove portraits added by the vanilla faction files into vanilla factions (without editing the original ones) so that, for example, Hegemony Factions characters do not appear with non-Hegemony portraits, like portrait13.png,  portrait15.png, etc.
I was unsure if there was a way to do this, as with the Portrait mod that I made all that I do is add new portraits into a custom Hegemony.FACTION file.

Thanks for the help in advance.  :D
 If this thread doesn't belong here I ask that it's moved where it'd be appropriate.

I was advised that this could be done by means of replacing the original .FACTION file with the following line in the mod_info.json file:
Code
 "replace":["data\\world\\factions\\hegemony.faction"]
Or that I could try to somehow do it through a script, but I have no idea on how to go through with that. If anyone could help me with this It'd be greatly appreciated.

Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 23, 2020, 06:02:42 AM
Ah, yes, if it's a phase cloak, that'll be a problem. But if it's another type of right-click system, it would be fine.

A phase cloak isn't going to work with a ship with modules; among other things it's not going to phase the modules. But, yeah, it'll also be unable to unphase; let me change that on my end. If the modules were set to "fighter" it'd be able to unphase, btw, but that could be undesirable for other reasons...
Fine ok, but I have another problem. If I wrote ai script for this right-click system, it seems that the f system won't be controlled by AI.

Spoiler
Code: json
{
"id":"FOB_starfavor",
"type":"STAT_MOD",
"aiType":"PHASE_CLOAK",
"statsScript":"data.shipsystems.scripts.FOB_StarFavorStats",
"aiScript":"data.shipsystems.scripts.ai.FOB_CustomAI"
"runScriptWhilePaused":true, # only for the player's ship
"runScriptWhileIdle":true,  # this means unapply() never gets called
"blockActionsWhileChargingDown":false,

"clampTurnRateAfter":true,
"clampMaxSpeedAfter":true,

"useSound":"FOB_phase_start",
#"deactivateSound":"system_phase_cloak_deactivate",
#"deactivateSound":"system_phase_cloak_deactivate",
#"outOfUsesSound":"system_phase_cloak_collision",
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SwissArmyKnife on July 23, 2020, 06:19:00 AM
Trying to create a big old beam cannon but I'm getting an NullPointerException whenever I try to fire it.

.wpn file:
Spoiler
Code
{
    "specClass":"beam",
    "id":"diableavionics_eldos",
    "type":"ENERGY",
    "size":"LARGE",
    "displayArcRadius":1200,
    "turretSprite":"graphics/da/weapons/diableavionics_eldos_turret_base.png",
    "turretGlowSprite":"graphics/da/weapons/diableavionics_eldos_turret_glow.png",
    "hardpointSprite":"graphics/da/weapons/diableavionics_eldos_hardpoint_base.png",
    "hardpointGlowSprite":"graphics/da/weapons/diableavionics_eldos_hardpoint_glow.png",
    "turretOffsets":[30, 0],
    "turretAngleOffsets":[0],
    "hardpointOffsets":[65, 0],
    "hardpointAngleOffsets":[0],   
    "fringeColor":[41,15,155,255],
    "coreColor":[238,255,239,255],
    "darkCore":false,
    "width":40.0,
    "textureType":LASER,
    "textureScrollSpeed":292.0,
    "pixelsPerTexel":5.0,
    "pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF,FIGHTER],
    "glowColor":[225,60,0,255],
        "animationType":"GLOW",
    "fireSoundOne":"da_eldos_start",
    "fireSoundTwo":"da_eldos_loop",
}
[close]

weapon_data.csv entry:
Spoiler
Code
Eldos Energy Furnace,diableavionics_eldos,3,0.01,32500,1400,950,,,75,4,40,,,,ENERGY,,950,1,2,,,,,,,6000,,,,,,"beam12, energy11, diable_adv_bp, rare_bp",,Diable Avionics,,Siege Artillery,,,,,,,,,,
[close]

And the NPE I get every time:
Spoiler
Code
46372 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
    at com.fs.starfarer.combat.entities.ship.A.void0000Unknown Source)
    at com.fs.starfarer.combat.entities.ship.A.void.createBeam(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.class.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.O0OO.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.O0OO.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.class.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.A.void.advance(Unknown Source)
    at com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
    at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
    at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
    at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
    at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
    at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
    at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
    at com.fs.state.AppDriver.begin(Unknown Source)
    at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
[close]

Checked all the usual suspects, names match, offsets look good, nothing was saved in the Ship & Weapon Editor. Sprites and sound files (ogg) all look fine. Kind of out of ideas, anything jump out to anyone or run into something similar?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 23, 2020, 11:57:44 AM
Seems that Onslaught background works, something like illustrations/bombardment_saturation.jpg works, but I can't get e.g. backgrounds/hyperspace_bg_cool.jpg to work (even if I travel to hyperspace before entering the battle).
Is this because of how the game handles system backgrounds?

Huh. Looked into this some, and, yeah, you're right. This is weird; now I'm more surprised that the onslaught background works (and it doesn't, quite - it messes up the background once you come back to the campaign) than I am surprised that the method doesn't work with regular backgrounds. I'm not really able to dig into this right now, but from what I can see this doesn't work for some fundamental reasons and wouldn't be a super straightforward fix.

(What appears to be happening is the system background overwrites the background texture during the fade into combat. But why this doesn't happen for the Onslaught texture, at this point, I have no idea.)



I was advised that this could be done by means of replacing the original .FACTION file with the following line in the mod_info.json file:
Code
 "replace":["data\\world\\factions\\hegemony.faction"]
Or that I could try to somehow do it through a script, but I have no idea on how to go through with that. If anyone could help me with this It'd be greatly appreciated.

Thanks in advance.

Right, that would work, but would also make your mod incompatible with other mods that change the hegemony.faction file.

The code solution would be - in your ModPlugin.onNewGame(), probably - to use FactionAPI.getPortraits(Gender gender) and modify the WeightedRandomPicker it returns.

(See javadoc here (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/campaign/FactionAPI.html#getPortraits(com.fs.starfarer.api.characters.FullName.Gender)).)

In the next release, you'll be able to clear out th default Hegemony portraits by simply including "core_clearArray" as the first element in the portrait array of your .faction file, without needing to "replace" the entire faction file.


Fine ok, but I have another problem. If I wrote ai script for this right-click system, it seems that the f system won't be controlled by AI.

Code: json
{
"aiType":"PHASE_CLOAK",
"aiScript":"data.shipsystems.scripts.ai.FOB_CustomAI"

You need "CUSTOM" for the AI type, otherwise aiScript doesn't get used at all.

Trying to create a big old beam cannon but I'm getting an NullPointerException whenever I try to fire it.

...

Checked all the usual suspects, names match, offsets look good, nothing was saved in the Ship & Weapon Editor. Sprites and sound files (ogg) all look fine. Kind of out of ideas, anything jump out to anyone or run into something similar?

Hmm - nothing jumps out immediately as being wrong. I'd suggest copy-pasting a vanilla weapon's .wpn file / csv row / etc one at a time, so you can narrow down where the problem is, and then progressively change things until you know exactly what breaks it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 23, 2020, 12:12:24 PM
Trying to create a big old beam cannon but I'm getting an NullPointerException whenever I try to fire it.

.wpn file:
Spoiler
Code
{
    "specClass":"beam",
    "id":"diableavionics_eldos",
    "type":"ENERGY",
    "size":"LARGE",
    "displayArcRadius":1200,
    "turretSprite":"graphics/da/weapons/diableavionics_eldos_turret_base.png",
    "turretGlowSprite":"graphics/da/weapons/diableavionics_eldos_turret_glow.png",
    "hardpointSprite":"graphics/da/weapons/diableavionics_eldos_hardpoint_base.png",
    "hardpointGlowSprite":"graphics/da/weapons/diableavionics_eldos_hardpoint_glow.png",
    "turretOffsets":[30, 0],
    "turretAngleOffsets":[0],
    "hardpointOffsets":[65, 0],
    "hardpointAngleOffsets":[0],   
    "fringeColor":[41,15,155,255],
    "coreColor":[238,255,239,255],
    "darkCore":false,
    "width":40.0,
    "textureType":LASER,
    "textureScrollSpeed":292.0,
    "pixelsPerTexel":5.0,
    "pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER,MISSILE_FF,MISSILE_NO_FF,FIGHTER],
    "glowColor":[225,60,0,255],
        "animationType":"GLOW",
    "fireSoundOne":"da_eldos_start",
    "fireSoundTwo":"da_eldos_loop",
}
[close]

weapon_data.csv entry:
Spoiler
Code
Eldos Energy Furnace,diableavionics_eldos,3,0.01,32500,1400,950,,,75,4,40,,,,ENERGY,,950,1,2,,,,,,,6000,,,,,,"beam12, energy11, diable_adv_bp, rare_bp",,Diable Avionics,,Siege Artillery,,,,,,,,,,
[close]

And the NPE I get every time:
Spoiler
Code
46372 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
    at com.fs.starfarer.combat.entities.ship.A.void0000Unknown Source)
    at com.fs.starfarer.combat.entities.ship.A.void.createBeam(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.class.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.O0OO.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.O0OO.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.trackers.class.o00000(Unknown Source)
    at com.fs.starfarer.combat.entities.ship.A.void.advance(Unknown Source)
    at com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
    at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
    at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
    at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
    at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
    at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
    at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
    at com.fs.state.AppDriver.begin(Unknown Source)
    at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
[close]

Checked all the usual suspects, names match, offsets look good, nothing was saved in the Ship & Weapon Editor. Sprites and sound files (ogg) all look fine. Kind of out of ideas, anything jump out to anyone or run into something similar?

Are the sounds registered in sounds.JSON? (Essentially a link to your sounds directory ogg files with some volume/pitch settings.)

The other thing is either put animationType above glowColor or remove it altogether and see if that solves the problem. That's the only thing that stands out to me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 23, 2020, 12:19:09 PM
The order of entries in the .wpn file shouldn't matter, btw. Thank you for chiming in, though; good point about the sounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 23, 2020, 03:07:17 PM
The order of entries in the .wpn file shouldn't matter, btw. Thank you for chiming in, though; good point about the sounds.

Ah yeah that makes sense I'm sure it is just called by key. Sometimes I kind of forget those files are just JSON files and so should work like any other JSONObject. lol  8)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SwissArmyKnife on July 23, 2020, 05:06:39 PM
Hmm - nothing jumps out immediately as being wrong. I'd suggest copy-pasting a vanilla weapon's .wpn file / csv row / etc one at a time, so you can narrow down where the problem is, and then progressively change things until you know exactly what breaks it.

Figured it out, I was calling da_eldos_start for the sound file in .wpn when it should have been the diableavionics_eldos_start I'd set in sounds.json. Naming conventions get me every time!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 23, 2020, 08:32:58 PM
You need "CUSTOM" for the AI type, otherwise aiScript doesn't get used at all.

Oh I uploaded the wrong code.
Yes I filled in "CUSTOM", and the right-click system work as I wish. But F system doesn't work any more.(I mean it won't be triggered by AI)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 24, 2020, 10:08:10 AM
Ah. I... don't actually know, then, I don't have much - any, really - experience with right-click systems other than the phase cloak.

Maybe someone that does have experience could chime in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on July 24, 2020, 08:36:30 PM
Ori, are you specifying aiHints for your right-click ship systems? I uh... Vaguely recall from work on Exigency long ago. That putting those on right-click systems causes various anomalous issues but I cannot for the life of me recall what they were, sorry.

I hope you *are* doing that, then is an easy fix and so that also it doesn't mean my old mod is turbo-*** as it will be coming back when time!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 24, 2020, 09:31:58 PM
Ah. I... don't actually know, then, I don't have much - any, really - experience with right-click systems other than the phase cloak.

Maybe someone that does have experience could chime in?
....fine okay I will try to find the answer by myself
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 24, 2020, 11:50:25 PM
Ah. I... don't actually know, then, I don't have much - any, really - experience with right-click systems other than the phase cloak.

Maybe someone that does have experience could chime in?
....fine okay I will try to find the answer by myself
And I give my f system an auto-use ai script, but its init() function even won't be called if I have a right-click system with ai script.
Both type is 'STAT_MOD'.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 25, 2020, 09:14:30 AM
Hmm, that doesn't make much sense - the code looks like those would be independent from each other, but it's possible I'm missing something. If you're able to create a minimal mod to demonstrate this (i.e. with no dependencies etc), I can take a look!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 27, 2020, 11:20:25 AM
I'd like to check if an Industry is available to build on a market, without adding it.
MarketAPI doesn't have a method for that, any good way to do this?

thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2020, 12:17:14 PM
What you'd need to do is:
Industry ind = market.instantiateIndustry(id)

And then:
ind.isAvailableToBuild()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 27, 2020, 12:21:12 PM
What you'd need to do is:
Industry ind = market.instantiateIndustry(id)

And then:
ind.isAvailableToBuild()

Hm, won't that cause the industry itself to be considered for the check?
edit - Nevermind, it won't - since it doesn't add itself to the industry list like this.

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2020, 12:23:18 PM
No, that doesn't add it to the market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 27, 2020, 04:05:20 PM
Not really a modding question but someone asked about it on my mod thread:

Is raiding a market to get a blueprint seeded? So that save scumming doesn't give you the same results?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2020, 05:19:01 PM
IIRC yes but the seed changes after... some time period. Now that I think about it, actually, it might've also been bugged and not actually seeded; if that's the case this is fixed for the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 29, 2020, 03:25:34 AM
I'm trying to add an industry that can only be built as an upgrade, but does not have a downgrade.

the issue I am running into is that isAvailibleToBuild() runs before CreateTooltip(), which causes this:

Code
isAvailableToBuild  -  -  -  currTTMode = null
this defaults to "false", because ToolTipMode is not "UPGRADE" - it's the check that determines if the industry is buildable.
Code
isAvailableToBuild  -  -  -  currTTMode = UPGRADE
This is a frame later, the check is now true since TTMode has been set and is no longer null - but it's too late, the check for IsAvailableToBuild has already run. The tooltip now displays the wrong information, and the button is greyed out.

is there a way to check the current toolTipMode before isAvailibleToBuild() runs the first time on being instantiated for upgrade tooltip creation?


Got it to work in a slightly roundabout way. I'd like to use this moment to ask for some API methods to specify buildability (upgrade only, downgrade only, normal only...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2020, 09:04:38 AM
Hmm - basing whether it's available to build on currTooltipMode seems, well, very wrong. There's no guarantee that currTooltipMode would be set (as you ran into) or that, indeed, the method would be called in a context where showing the tooltip even makes sense. Whether it's available - in your case - should I think more "correctly" be based on whether the industry it's an upgrade from is currently present on the market. Tooltip mode is ultimately something derived from market state for the purpose of showing the tooltip, and only that. Definitely don't rely on it elsewhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 30, 2020, 11:29:32 AM
Thanks for the explanation regarding Tooltip mode!

My goal was to have an industry that:
-is never visible in industry selection
-has no downgrade
-can be upgraded to

I solved my problem by specifying an upgrade in the .csv, but setting it null via IndustrySpec by overriding both init() and getSpec() in the industry class.
This prevents it from showing up in the selector (because it is an upgrade), but also removes the ability to downgrade it.

Not clean at all, but it's why I requested ways to specify availability.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2020, 12:18:23 PM
Shouldn't this already be doable? Stuff like Orbital Works doesn't show up in the industry list - the only difference seems to be that it's downgradeable-from, but that seems like it would just be a matter of clearing the "downgrade" column. What am I missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 30, 2020, 12:48:46 PM
Clearing the downgrade column results in the industry being buildable via the normal industry selection, which is not desireable in this case.

This might give more insight:
Spoiler
(https://i.imgur.com/oSXDT1t.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2020, 12:54:58 PM
Ah, gotcha, that's the part I was missing.

But - wouldn't overriding BaseIndustry.showWhenUnavailable() to return false resolve this? Provided that isAvailableToBuild() checked your specific prerequisites etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 30, 2020, 01:05:47 PM
I already use that to hide the Industries from selection.

Provided that isAvailableToBuild() checked your specific prerequisites etc.
That's the problem though - my prerequisite is that the current Industry instance was created from an IndustrySpecAPI.getUpgradePluginInstance() call, which I can't check for in the class (to my knowledge).
Hence the strange workaround

It needs to be buildable as upgrade if super.isAvailableToBuild() is true, but it must be unavailable (and hidden) if the normal industry selection menu gets called.
edit - without having an actual downgrade, or upgrade, specified anywhere in the .csv, since I do it all via code
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2020, 01:09:39 PM
Ahh, ok, ok - I finally get it :) Thank you for explaining.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 31, 2020, 03:20:54 AM
question
is there any way to completely disable all death effects for a given ship?
i made a copy of "reduced explosion" hullmod with radius and damage multipliers set to 0
and set  "baseCombatExplosionColor":[0,0,0,0], in hull style
and there is still this yellow smoke thing on death:
Spoiler
(https://i.imgur.com/2HZ7UkH.png)
[close]
what is the source of it? is there any way to  change it's color or remove it entirely?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2020, 12:45:59 PM
Checked into, and looks like that's hardcoded, I don't think there's any way to avoid that.

... well, I think setting the collision  radius to zero might, actually, but I'm not sure that there's a hook where you'd be able to do that at the right point in time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 01, 2020, 05:20:35 PM
How can I tell whether a course is laid in?

PersistentUIDataAPI.getCourseTarget() doesn't work because null is a valid target.

EDIT: To be more specific, the course target is null when no course is selected, but it is also null when a course is set to an arbitrary point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: connortron7 on August 01, 2020, 09:24:52 PM
how does one go about making a custom phase glow color?

EDIT: got on the right track.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cabbs on August 03, 2020, 02:01:45 PM
Hey!

Can anyone briefly explain part of the WeaponAPI to me?

More specifically, I want a hullmod to modify the stats of individual weapons on a ship, like their (missile) damage or fire rate.  Messing with missile weapons for my mod, and will be messing with other things later.

- I assume this would need to happen in applyEffectsAfterShipCreation
- But it does not look like fire rate can be changed outside of MutableStats
- It looks like I can't clone a set of MutableStats to apply to each weapon?

Have searched high and low but looks like I'm missing something.

EDIT: alright, after due diligence I am giving up on this half-formed idea - can see why this isn't possible, at least for me.

I was attempting to create a hullmod that provides 50% missile ammo rather than 100%, and manage 1-shot missiles with additional downsides, as their ammo would need to round up to 2.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 04, 2020, 07:56:08 PM
IIRC per-weapon stats configuration is coming in next version.

Question: How are ships sold on a submarket named? There's a minor text bug in Nexerelin (see here (http://fractalsoftworks.com/forum/index.php?topic=9175.msg295554#msg295554) and the next two posts) where when a market and its submarkets are transferred to another faction, the ships for sale use the previous owner's ship name prefix.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 04, 2020, 08:36:09 PM
It's based on this in BaseSubmarketPlugin, iirc:
this.cargo.initMothballedShips(submarket.getFaction().getId());

But calling that method again will do nothing since the mothballed ships FleetDataAPI is already inited. So you'd need to make a copy of the cargo and init the copy's mothballed ships... but "cargo" is a private variable in BaseSubmarketPlugin (urgh, sorry - just changed it to protected and added a setter.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 06, 2020, 07:33:26 PM
How can I tell whether a course is laid in?

PersistentUIDataAPI.getCourseTarget() doesn't work because null is a valid target.

EDIT: To be more specific, the course target is null when no course is selected, but it is also null when a course is set to an arbitrary point.

Huh, looks like I was wrong and arbitrary points are a waypoint SectorEntityToken, not null as I thought. That is good news!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 08, 2020, 06:38:41 AM
I'm drawing some things in the campaign UI with OpenGL, at a position relative to the player fleet. This is done in the advance() method of an EveryFrameScript.
When I press Shift to speed up time, the drawing is duplicated and moved based on the player's motion. This effect goes away when the game is paused.
How do I fix?
(https://i.imgur.com/avmMv1r.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 08, 2020, 10:16:15 AM
Yeah, that's... probably not the only problem you'd have trying to do rendering in the advance() method. It's not a good idea. I wouldn't be surprised if this could, say, cause a crash during saving or loading.

I'd suggest using a custom campaign entity plugin instead as that has a proper render() method and you can specify which layer you want in the custom_entities.json definition of your custom entity. Since it's a UI thing, you might need to scale things to invert the zoom factor and do some coordinate translation, but given what you've described, that sounds doable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 09, 2020, 02:44:59 AM
Ah, I see. (Common Radar mod seems to work fine rendering in advance() though, in terms of not having crashes attributed to it)

I'll try creating a custom entity and moving it around to "stick" to the player. For the future, perhaps we could get an interface for campaign layer rendering without a sector entity?



Bug report, found while experimenting with a script to mirror weapons on the left/right sides of the ship (based on Wyvern's code here (https://pastebin.com/iGeKBP3u)):

After calling WeaponSpecAPI.ensureClonedSpec(), modifying the weapon's fire offsets still affects all weapons of that type. Angle offset works correctly.
I'm guessing this is because the spec cloning does a shallow copy on the fire offsets (a list of Vector2fs)?

Sample EveryFrameWeaponPlugin code (https://pastebin.com/iGeKBP3u)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 09, 2020, 09:45:49 AM
Ah, I see. (Common Radar mod seems to work fine rendering in advance() though, in terms of not having crashes attributed to it)

Ah, good to know. Interesting!

I'll try creating a custom entity and moving it around to "stick" to the player. For the future, perhaps we could get an interface for campaign layer rendering without a sector entity?

Yeah, I can see adding a callback for UI rendering; I'll keep it in mind. An entity is probably the best bet for in-engine-coordinates rendering, though, especially since layer control etc is already there.

Btw - as far as moving the entity - maybe you're already planning it this way, but based on what you're saying, it sounds like you might not be, so I thought I'd mention it:

(I'd suggest using its advance() method to make sure it's always in the player's current LocationAPI, and not worrying about the coordinates too much - using the player fleet's coordinates directly for any rendering, and having getRenderRange() return some absurdly high value to make sure it's always rendered if it's in the current location. Apologies if this is obvious!)

Bug report, found while experimenting with a script to mirror weapons on the left/right sides of the ship (based on Wyvern's code here (https://pastebin.com/iGeKBP3u)):

After calling WeaponSpecAPI.ensureClonedSpec(), modifying the weapon's fire offsets still affects all weapons of that type. Angle offset works correctly.
I'm guessing this is because the spec cloning does a shallow copy on the fire offsets (a list of Vector2fs)?

Sample EveryFrameWeaponPlugin code (https://pastebin.com/iGeKBP3u)

Thank you! ... checking the SVN history, it looks like I actually fixed this some number of months ago, so it must've come up. Ah, I vaguely remember noticing this while looking at something semi-related. And, yeah, the clone() method wasn't deep-copying the fire offsets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: N1MH on August 09, 2020, 10:11:02 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
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WarStalkeR 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: N1MH 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BeyondTheHorizon 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
(https://i.imgur.com/fdIjr5c.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Potkin 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne 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....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne 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!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne 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
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 18, 2020, 10:20:24 PM
Hah, that's the kind of creativity I like to see :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Julio Montega 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?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine 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 (https://bitbucket.org/modmafia/underworld/src/0d05504823da1399a11caafdf3c4f79650052cf5/src/data/scripts/world/underworld/UW_Styx.java#lines-97:112) 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 23, 2020, 12:35:30 AM
how to directly render on campaign UI? I remember I have done it once but I forgot how I did it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: N1MH on August 23, 2020, 10:13:42 PM
What's the equivalent of "BeamWeaponRangeBonus" for energy projectile weapons specifically?

And where can I find the other things? Things as in "BeamWeaponRangeBonus" and the one for energy projectiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mondaymonkey on August 23, 2020, 10:50:04 PM
What's the equivalent of "BeamWeaponRangeBonus" for energy projectile weapons specifically?

And where can I find the other things? Things as in "BeamWeaponRangeBonus" and the one for energy projectiles.

You should seek it in API. For the "BeamWeaponRangeBonus", you probably mean the one from  "stats.getBeamWeaponRangeBonus().modifyFlat" from advanced optics? So you should read MutableShipStatsAPI.java in starfarer.api\com\fs\starfarer\api\combat (that would be iside the .zip). And the answer is: getEnergyWeaponRangeBonus().

BTW, you can read an IntegratedTargetingUnit.java to see how it works.

EDIT: Hold on. I misread your post. You need only projectile energy range bonus? That would be harder, as getEnergyWeaponRangeBonus() is applied for all energy weapons, including beams. You should manually set range bonuses to different weapons in that case.

EDIT2: Or you can perform a trick. Modify getEnergyWeaponRangeBonus() and then give negative reverse bonus to getBeamWeaponRangeBonus() to return it to normal.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 23, 2020, 10:54:44 PM
how to directly render on campaign UI? I remember I have done it once but I forgot how I did it
Like in here (http://fractalsoftworks.com/forum/index.php?topic=5061.msg295855#msg295855)? You can do stuff with OpenGL in an every frame script's advance(), although using a campaign entity seems to be more recommended.
I dunno about stuff like menus though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 24, 2020, 06:18:13 PM
Is settings.json only loaded once when the game opens?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 24, 2020, 07:05:20 PM
IIRC loaded twice - once when the launcher is starting up, and then one more time. It's not loaded again at any point once the game is up and running, though, if that's what you're asking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: N1MH on August 25, 2020, 08:21:11 PM
https://pastebin.com/ts8sdQGU

Anyone know why the flux part doesn't work? Kinda new to scripting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 26, 2020, 12:54:10 AM
https://pastebin.com/ts8sdQGU

Anyone know why the flux part doesn't work? Kinda new to scripting.

I see a lone ";" on line 22. That is likely causing a crash. Try deleting that and see if it works as intended. I don't see anything else wrong from a once-over of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 26, 2020, 08:44:38 AM
The flux modification looks like it should work, it is just too small a change for you to eyeball it in-game. Try testing with 90% reduction instead of 10% to make sure it works.

BTW x1.1 does not quite cancel out x0.9. You need like x1.11, so 11 instead of 10 for your variable.

An empty statement (the lone semicolon) is harmless. You get crashes when you are missing semicolons. An IDE like Netbeans or Eclipse will stop you from making that mistake.

I suggest putting your comments above the relevant code because then you can tell what the code is meant to do before you read it. Also, your variable names and code layout are a little confusing. Other than that, looks like you are off to a good start at coding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 26, 2020, 08:59:31 AM
how to directly render on campaign UI? I remember I have done it once but I forgot how I did it
Like in here (http://fractalsoftworks.com/forum/index.php?topic=5061.msg295855#msg295855)? You can do stuff with OpenGL in an every frame script's advance(), although using a campaign entity seems to be more recommended.
I dunno about stuff like menus though.
Thx!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 26, 2020, 09:01:49 AM
Is there any way to block the mouse input when the cursor is in some specific area?
I don't want to make fleet move to the place I clicked
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 26, 2020, 10:37:17 AM
Not specifically - you'd have to somehow detect this and override the player fleet's movement destination. But it'd still interrupt things like a laid-in course etc. It sounds like you're trying to make a custom campaign-layer UI? That'll, unfortunately, pretty much have to be a bit clunky with these kinds of aspects.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 26, 2020, 09:08:42 PM
Not specifically - you'd have to somehow detect this and override the player fleet's movement destination. But it'd still interrupt things like a laid-in course etc. It sounds like you're trying to make a custom campaign-layer UI? That'll, unfortunately, pretty much have to be a bit clunky with these kinds of aspects.
Well, I think of a new way, not click it, just move the mouse over it and hold on for a second to trigger what I want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BeyondTheHorizon on September 03, 2020, 07:13:03 PM
Anyone know why each time I get the hull style with Global.getCombatEngine().getPlayerShip().getHullStyleId() gives me "MIDLINE", no matter the true style is HIGH_TECH or custom hull style.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helixic on September 05, 2020, 05:45:37 PM
what's the difference between turrets and hardpoints?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 05, 2020, 06:00:26 PM
Hardpoints have different sprite sets, slower traverse, and more hit points.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 05, 2020, 07:42:23 PM
Also: hardpoints have halved recoil per shot and halved maximum inaccuracy, for weapons where that's applicable. And missile weapons mounted in hardpoints don't turn at all, but that's just a minor mostly cosmetic point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: maplealvon on September 13, 2020, 11:21:42 PM
How one find out:
1. markets managed by the player
2. industries on a market
3. cores/items attached to the industries
4. industries known by the player (like the red shield, the default industries, or even modded industries)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 14, 2020, 01:54:14 PM
How one find out:
1. markets managed by the player
Code
Misc.getFactionMarkets(Global.getSector().getPlayerFaction());
2. industries on a market
Code
market.getIndustries();
3. cores/items attached to the industries
Depends on the industry - for vanilla, it's simply:
Code
        market.getIndustry("industry_Id").getSpecialItem();
        market.getIndustry("industry_Id").getAICoreId();
Modded industries might not work that way.
4. industries known by the player (like the red shield, the default industries, or even modded industries)
Code
Global.getSector().getPlayerFaction().getKnownIndustries();
Modded industries do not need to conform to this and might have a different way of handling availability.


I am trying to check what cargo was dropped as salvage after a fleet encounter with a Campaign Fleet I have a Fleet listener on.
Fleet cargo/EconomyRouteData.cargo doesn't seem to update on fleet size change, so that's not an option apparently.

In short - I gotta update the cargo of a fleet if it lost stuff to the player.
Any way I can do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2020, 02:28:51 PM
In short - I gotta update the cargo of a fleet if it lost stuff to the player.
Any way I can do that?

Hmm - if the stuff was lost as a result of a battle and the other fleet had it in its actual cargo, that should already be handled in FleetEncounterContext.handleCargoLooting(). Stuff that was in the other fleet's cargo and that was dropped for the player is removed from the other fleet's cargo. Barring bugs, that is.

(Edit: thank you for answering maplealvon's questions, by the way! Much appreciated.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 15, 2020, 06:58:28 AM
Hmm - if the stuff was lost as a result of a battle and the other fleet had it in its actual cargo, that should already be handled in FleetEncounterContext.handleCargoLooting(). Stuff that was in the other fleet's cargo and that was dropped for the player is removed from the other fleet's cargo. Barring bugs, that is.

(Edit: thank you for answering maplealvon's questions, by the way! Much appreciated.)

Fell victim to my own spaghetti code - refreshing fleet cargo to the target cargo via fleet AI implementation, then wondering why the fleet cargo didn't update to reflect dropped loot for the listener.
Seems to work as intended when using fleet cargo, but I'm not completely done - will see if I run into something else.

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 17, 2020, 04:24:51 PM
Using fleet cargo worked without issue in the end.
Got another question though - I want to apply an industry to a market immediately after it is converted from a conditionMarket.

The industry I spawn via apply/advance from a market condition only shows up after re-docking at the planet.
Any way to have industries show up immediately on opening the panel?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2020, 04:26:34 PM
Hmm - EconomyAPI.tripleStep() or some such? Maybe I'm misunderstanding the question.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 17, 2020, 08:24:21 PM
Will a market always sell a ship that they use in the fleet? I wonder if it's possible to make a ship never sold at all, but used a lot in their fleet composition.

Also, there's no way to make a skin revert back to another skin is there? Example for reference

Code
	"baseHullId":"enforcer_xiv", //this is originally a skin
"skinHullId":"enforcer_xiv_mk2",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 18, 2020, 09:35:39 AM
I think a "no_sell" tag ought to do it. Not 100% sure if it'll work in the current release but I *think* it will. Definitely in the next release, though.

Also, there's no way to make a skin revert back to another skin is there? Example for reference

Code
	"baseHullId":"enforcer_xiv", //this is originally a skin
"skinHullId":"enforcer_xiv_mk2",

Not sure what you mean by "revert". Do you mean base the skin on another skin? I don't know off the top of my head, actually - this may be load-order dependent, i.e. it might work if the original skin is loaded first, since under the hood is skin a very much a hull. But, yeah, not sure actually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 18, 2020, 05:30:57 PM
How do i set the priority in which module of a multi-module ship appear on top of the other modules?

ok found out its the order of the module slots in .ship file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 19, 2020, 12:21:18 PM
Is there a guide on how to set up Submarkets on existing worlds? I wanna make a special shop that only sell a few specific ships on some core worlds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 19, 2020, 03:38:38 PM
Is there a guide on how to set up Submarkets on existing worlds? I wanna make a special shop that only sell a few specific ships on some core worlds.

I don't think so, but to get you started:

1) Make a new class that extends BaseSubmarketPlugin and create the logic to do what you want. For an example, see: com\fs\starfarer\api\impl\campaign\submarkets\BlackMarketPlugin.java (This is a good reference point for doing lots of things with the BaseSubmarketPlugin.)

2) Add an entry in Submarkets.csv (starsector-core\data\campaign) which points to your plugin. (Note: Your version of the csv from a mod standpoint must match the path of vanilla's csv and share the same name in order to merge into the games list of submarkets.)

3) Now the submarket is available with an id. My recommendation would be to add that id to the Submarkets enum in case you need it in enum form for other methods, but for adding a submarket to the MarketAPI of an entity you can just use the id I believe.

4) Create a script to find the markets you want through their entity ids and add the new submarket to them.

5) Add the script to your mod plugin - onNewGameAfterEconomyLoad() or onNewGame() is probably the best place.

(EDIT: More informative in this format and I may expand it. For any details of any component of the explanation - or any additional clarification - post here or PM me!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 20, 2020, 07:48:22 AM
That helped a lot Morrokain, i just need now a sample code on how to search for markets and add the submarket during the onNewGameAfterEconomyLoad()
I looked for mods that have special submarkets, i know of Tahlan for GH shop, but i can't find where in the plugin code is the part where the submarket is added.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 20, 2020, 08:32:09 AM
MarketAPI.addSubmarket() IIRC
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 20, 2020, 09:31:12 AM
That helped a lot Morrokain, i just need now a sample code on how to search for markets and add the submarket during the onNewGameAfterEconomyLoad()
I looked for mods that have special submarkets, i know of Tahlan for GH shop, but i can't find where in the plugin code is the part where the submarket is added.

Here is code I use to remove a submarket. Just switch it with the add method like SafariJohn already mentioned and use the id you added to the spreadsheet.

Code:
Spoiler
Code
package archeus.campaign.world.factions;

        import com.fs.starfarer.api.Global;
        import com.fs.starfarer.api.campaign.SectorAPI;
        import com.fs.starfarer.api.campaign.SectorEntityToken;
        import com.fs.starfarer.api.campaign.StarSystemAPI;
        import com.fs.starfarer.api.campaign.econ.MarketAPI;
        import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
        import org.apache.log4j.Logger;

public class RemoveSubmarketsForLuddicChurchStations {

    private static final Logger LOG = Global.getLogger(RemoveSubmarketsForLuddicChurchStations.class);

    public void set(SectorAPI sector, boolean logInfo) {
        StarSystemAPI system = sector.getStarSystem("canaan");
        if (system == null) {
            if (logInfo) {
                LOG.info("Canaan system was not found.");
            }
            return;
        }
        SectorEntityToken fortress = system.getEntityById("gilead_fortress");
        if (fortress == null) {
            if (logInfo) {
                LOG.info("Entity gilead_fortress was not found in the " + system.getId() + " system.");
            }
            return;
        }
        MarketAPI market = fortress.getMarket();
        if (market == null) {
            if (logInfo) {
                LOG.info("A market was not found for " + fortress.getId() + " in the " + system.getId() + " system.");
            }
            return;
        }
        market.removeSubmarket(Submarkets.SUBMARKET_OPEN);
        market.removeSubmarket(Submarkets.SUBMARKET_BLACK);
        if (logInfo) {
            LOG.info("Removed open market and black market from " + fortress.getId() + " in the " + system.getId() + " system.");
        }
    }
}
[close]

And here is how its implemented in the mod plugin:

Spoiler
Code
    @Override
    public void onNewGameAfterEconomyLoad() {
        SectorAPI sector = Global.getSector();

        // Removes submarkets for restricted faction markets like Gilead Fortress.
        new RemoveSubmarketsForLuddicChurchStations().set(sector, LOG_INFO);
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 20, 2020, 09:48:52 AM
thanks, got it

But now how do i make it so the market only sell pristine quality ships?

-edit-

I think i found out what i was doing wrong, i copied the submarket script from another mod, now I am looking at it properly. Ok fixed, wonderful!

(https://i.imgur.com/DESnWDb.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 20, 2020, 02:43:12 PM
How do i start a quest from an unique NPC or by entering a system instead of using random bar events?
I wanna make Wurgandal unique by making it so you can only gain it in a quest, but i want it to be easy to start the quest, just hard to do.

My plan is having the player going to a high danger [Redacted] system, either finding it randomly or having an unique NPC tell him about it (talk to the NPC in the comms of a station)
Finds a wreck, fight a huge [Redacted] armada, and get the ship core
Go to a special NPC, deliver the core and earn 500k as reward or pay extra 10 million to get the ship instead
Later if the player regrets choosing the money he can buy the ship for 15 million.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: N1MH on September 22, 2020, 08:00:09 PM
What would be the difficulty level of modifying the entropy amplifier system into making it lower a ships time acceleration like the scarabs system but for the enemy?

Only know how to modify code, not make my own yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 23, 2020, 07:52:44 AM
What would be the difficulty level of modifying the entropy amplifier system into making it lower a ships time acceleration like the scarabs system but for the enemy?

Only know how to modify code, not make my own yet.
Simple, you can check my code (Ed shipyards) in the spatial swap system I boost the defenses of the ally being swapped before the swap happens, you could instead of applying a buff to an ally, apply a debuff an enemy, save the debuffed enemy and unapply the debuff after the duration of the system ends (remember to check if the debuffed enemy is still alive when doing so)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 23, 2020, 09:09:52 AM
How do i start a quest from an unique NPC or by entering a system instead of using random bar events?
I wanna make Wurgandal unique by making it so you can only gain it in a quest, but i want it to be easy to start the quest, just hard to do.

By entering a system: you'd need to have a script that checks for this, and once the conditions are met, starts the mission removes itself.

From a unique NPC: you'd probably want to write a custom rule command to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on September 23, 2020, 10:05:33 AM
How do i start a quest from an unique NPC or by entering a system instead of using random bar events?
I wanna make Wurgandal unique by making it so you can only gain it in a quest, but i want it to be easy to start the quest, just hard to do.

By entering a system: you'd need to have a script that checks for this, and once the conditions are met, starts the mission removes itself.

From a unique NPC: you'd probably want to write a custom rule command to do it.
After looking at bar events they seem better than expected, I will try a bar event first.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on September 29, 2020, 02:45:01 PM
Until now, I have been building my mod using libs from Starsector directly. As I want to set up a CI pipeline for my mod I don't have those available, and downloading whole Starsector each commit just to extract few JARs is bad. Fortunately all of those (other than starfarer.api.jar) are available in a Maven repo. So far this works (compiles fine) but I'd want to use exact versions Starsector uses (these are slighly modified from 0.8.1a).

Thanks!

Code
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
    implementation group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: '2.9.3'
    implementation group: 'org.lwjgl.lwjgl', name: 'lwjgl_util', version: '2.9.3'
    implementation group: 'log4j', name: 'log4j', version: '1.2.9'
    implementation group: 'org.json', name: 'json', version: '20170516'
    implementation group: 'net.java.jinput', name: 'jinput', version: '2.0.7'
    implementation group: 'org.codehaus.janino', name: 'janino', version: '3.0.7'
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2020, 03:31:27 PM
  • Could you tell what versions of libraries Starsector uses?

Ah, I'm sorry, I don't remember offhand! That info is probably buried in commit comments somewhere but, if we're being perfectly honest, I'm not really up for digging through it to hunt it all down.

  • Could you host just starfarer.api.jar so integration becomes easier please (AWS or Maven repository)?

I'd prefer not to add another item to my release checklist...

  • Alternatively, are you fine with bundling starfarer.api.jar in a mod repo (again, for build / pipeline ease)?

Sure, feel free!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 01, 2020, 06:53:19 PM
I am trying to make a ship system that hijacks enemy missiles, i got them to stop hitting my ships and targeting the enemy that they came from, but they seem to have lost their collision, they just circle the enemy until they timeout phasing through it instead of hitting.

Code
if (missile.getOwner() != ship.getOwner()) {
   missile.setOwner(ship.getOwner());
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2020, 06:57:29 PM
Ah - this is probably because a missile can't hit the ship it came from until it flames out. Let me add get/setSource() methods to MissileAPI.

In the meantime, your best bet might be to spawn a new missile and place it in the same exact location... though I don't recall offhand if you can set the flight time etc so this wouldn't "refuel" it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 01, 2020, 07:18:43 PM
Ah - this is probably because a missile can't hit the ship it came from until it flames out. Let me add get/setSource() methods to MissileAPI.

In the meantime, your best bet might be to spawn a new missile and place it in the same exact location... though I don't recall offhand if you can set the flight time etc so this wouldn't "refuel" it.
that was the problem, it works now, thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BeyondTheHorizon on October 01, 2020, 08:44:49 PM
How does getDamageTarget() work for missile? The code below works for other projectiles with DamagingProjectileAPI but not for missiles.
Code
for (MissileAPI m : missiles) {
if (m.getDamageTarget() == ship) {
flux.increaseFlux(m.getDamageAmount() * m.getDamageType().getShieldMult(), true);
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 02, 2020, 08:31:52 AM
Offhand that seems like it'd be fine. Hmm. I'd suggest maybe stepping through with a debugger/adding some print statements to figure out exactly what's not working here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: L:atte Mint on October 02, 2020, 03:04:25 PM
Hello there! I'm currently working on a mod that may required something very wierd, like a special, unique item (or commodity), that will be dropped only once and later maybe giving some special story with them. Frankly I didn't know how I may achive this, and this may beyond my knowledge scope. Is there anything (file, mod) specific that I could looked into?  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 02, 2020, 06:05:23 PM
Hello there! I'm currently working on a mod that may required something very wierd, like a special, unique item (or commodity), that will be dropped only once and later maybe giving some special story with them. Frankly I didn't know how I may achive this, and this may beyond my knowledge scope. Is there anything (file, mod) specific that I could looked into?  ;)

Check out com\fs\starfarer\api\impl\campaign\procgen\themes\MiscellaneousThemeGenerator.java

That details how you can seed one or otherwise limited instances of an item (Legion). From there you would have to generate a mission upon picking up/otherwise interacting with the item. Depending upon what the item is, this can be done multiple ways depending upon if you are using a script, rules or some combination of the two.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BeyondTheHorizon on October 02, 2020, 07:01:23 PM
Offhand that seems like it'd be fine. Hmm. I'd suggest maybe stepping through with a debugger/adding some print statements to figure out exactly what's not working here.
Found the problem, m.getDamageTarget() did return null, just don't know why other projectiles return the correct entity except for missiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: L:atte Mint on October 02, 2020, 09:08:12 PM
Hello there! I'm currently working on a mod that may required something very wierd, like a special, unique item (or commodity), that will be dropped only once and later maybe giving some special story with them. Frankly I didn't know how I may achive this, and this may beyond my knowledge scope. Is there anything (file, mod) specific that I could looked into?  ;)

Check out com\fs\starfarer\api\impl\campaign\procgen\themes\MiscellaneousThemeGenerator.java

That details how you can seed one or otherwise limited instances of an item (Legion). From there you would have to generate a mission upon picking up/otherwise interacting with the item. Depending upon what the item is, this can be done multiple ways depending upon if you are using a script, rules or some combination of the two.

Thanks for reply! Gonna check this out asap ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 03, 2020, 11:41:15 AM
Is there a easy way to make a logistics ship that grants more repair speed, CR recovery, higher recovery chance or something similar for only frigs and destroyers in the fleet? (without ugly workarounds I mean)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 03, 2020, 12:12:40 PM
When I put weapons into custom submarket that extends StoragePlugin they no longer are seen as "owned". If I put a weapon to vanilla storage, they are "seen", e.g. tooltip on that weapon shows "You own a total of x...". My class extends StoragePlugin, and submarkets.csv has "player" as faction.

Is there a way to make custom submarkets count towards player-owned weapons? Because an image is worth 1000 words: https://imgur.com/a/MZu9vd5 (https://imgur.com/a/MZu9vd5)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 03, 2020, 08:41:16 PM
Code
    @Override
    public void onGameLoad(boolean newGame) {
        Global.getSector().addTransientListener(new CommissionCheckMarket());
    }

I'm unfamiliar with transient listener. Am I supposed to remove them everytime the player saves? I feel like if this code is in, it'll keep readding and readding itself.

Also is there a way to add a cooldown like.. wait 5 days before re-checking again or something in reportPlayerOpenedMarket? I'm really unfamiliar with how listener works overall. I think having to run a very performance-intensive code everytime a player dock(and they may dock several time) is unfriendly to toaster PCs as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 04, 2020, 07:22:55 AM
Transient stuff is not saved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2020, 07:46:25 AM
If you want to add a cooldown, probably save the current timestamp (via Global.getSector().getClock().getTimestamp()) and then only check if clock.getElapsedDaysSince(timestamp) > 5f. But if it's a transient listener, then it won't save the timestamp when you save, so that wouldn't be good since you'd get inconsistent behavior if you reload vs if you don't.

I'd also question how performance intensive what you're doing actually is. Oftentimes things seem intensive but aren't, really.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 05, 2020, 11:13:39 AM
If you want to add a cooldown, probably save the current timestamp (via Global.getSector().getClock().getTimestamp()) and then only check if clock.getElapsedDaysSince(timestamp) > 5f. But if it's a transient listener, then it won't save the timestamp when you save, so that wouldn't be good since you'd get inconsistent behavior if you reload vs if you don't.

I'd also question how performance intensive what you're doing actually is. Oftentimes things seem intensive but aren't, really.
Thanks! I only want a 1 day cooldown at most or something really short.  I think my code is always loading up a spreadsheet to call from and this spreadsheet gets bigger, the more modded factions they are.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 05, 2020, 01:48:38 PM
If you want to add a cooldown, probably save the current timestamp (via Global.getSector().getClock().getTimestamp()) and then only check if clock.getElapsedDaysSince(timestamp) > 5f. But if it's a transient listener, then it won't save the timestamp when you save, so that wouldn't be good since you'd get inconsistent behavior if you reload vs if you don't.

I'd also question how performance intensive what you're doing actually is. Oftentimes things seem intensive but aren't, really.
Thanks! I only want a 1 day cooldown at most or something really short.  I think my code is always loading up a spreadsheet to call from and this spreadsheet gets bigger, the more modded factions they are.

Are you actually doing loading from a file in reportPlayerOpenedMarket()? Unless there are extenuating circumstances, that's really not a good idea. Generally speaking, the "right" way to do this would be to load it once on application load - into some kind of data structure - and then refer to this when actually using it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 06, 2020, 02:25:33 AM
I want to transplant a ship from a mod so that I can use the ship without the rest of the mod in-game. What files do I need to collect, and what other processes do I need to do for this? I can generally understand the game files, but my modding experience is very limited.

Files I've collected so far:
The .ship file
The description file
The variant files (All of which need to be edited for vanilla guns)
And the graphics files

I've made a portrait mod before, so I understand some general principles...
You need to look into ship and variants and transplant all weapons and fighters as well (data and graphics and sometimes custom scripts). You also need default roles defined, or ships will not show up. Then you also need to create ship_data.csv and wing_data.csv files with all entries you have transplanted. Then look at special systems for ships and fighters and either change them to something vanilla or transplant scripts.

Transplanting weapon/wing/system scripts will be tricky as it requires some Java knowledge regarding naming, ideally you'd build yourself a jar file with all ship/fighter systems you need. I am probably missing something. All in all I think you're better off creating a mod to blacklist what you don't want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 07, 2020, 04:41:00 PM
I wanna make a ship system eat away CR and PP, is this the right way to do both or just CR?

Code
stats.getCRLossPerSecondPercent().modifyMult(id, 4f);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 07, 2020, 04:51:38 PM
That's just CR after PPT runs out.

Edit: let me add ShipAPI.setTimeDeployed(); right now that's not exposed...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 07, 2020, 05:01:05 PM
That's just CR after PPT runs out.

Edit: let me add ShipAPI.setTimeDeployed(); right now that's not exposed...
would this work to lower peak performance? (internals of 10 sec)
stats.getPeakCRDuration().modifyFlat(id, -10);
also what happens if i .unmodify this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 07, 2020, 05:10:38 PM
Oh, hey, that's a good idea! I thought that wouldn't work (it wouldn't if that's only computed once when the ship is created), but it should work, since it's not doing that.

If you .umodify() it it'll give it back the peak time that was subtracted. So you actually wouldn't just do -10 every time - you'd want to keep track of how long and modify by the *total* time every time, if that makes sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 07, 2020, 05:27:18 PM
Oh, hey, that's a good idea! I thought that wouldn't work (it wouldn't if that's only computed once when the ship is created), but it should work, since it's not doing that.

If you .umodify() it it'll give it back the peak time that was subtracted. So you actually wouldn't just do -10 every time - you'd want to keep track of how long and modify by the *total* time every time, if that makes sense.
So i could make it so the player loses 10 seconds every time the system is used, but if the player fulfill some sort of objective i could do the .unmodify and recover the lost time right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 07, 2020, 05:36:25 PM
Yep!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 07, 2020, 05:46:37 PM
Noice! Thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 08, 2020, 06:58:23 AM
Do fleets without the Officer Management skill have their officer count pruned? If so, where is this happening in the code?

tl;dr version of the post
Is there some hidden factor controlling the number of officers a fleet can have, that I'm failing to notice in FleetFactoryV3?

I set the doctrines of the major factions to 5-1-1 (same as Hegemony), started a new game, and ran the following code:

Spoiler
Code: java
	public static void run(String factionId) {
final FactionAPI faction = Global.getSector().getFaction(factionId);

int numOfficers = 0, numShips = 0, sumLevel = 0, sumFP = 0;
int numFleets = 100;
for (int i=0; i<numFleets; i++) {
CampaignFleetAPI fleet = createFleet(faction, 100);
sumFP += fleet.getFleetPoints();
for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy())
{
numShips++;

if (member.getCaptain().isDefault())
continue;

numOfficers++;
sumLevel += member.getCaptain().getStats().getLevel();
}
}
FactionDoctrineAPI doctrine = faction.getDoctrine();
String str = String.format("Generated %s fleets for faction %s, doctrine %s-%s-%s", numFleets,
faction.getDisplayName(), doctrine.getOfficerQuality(), doctrine.getShipQuality(),
doctrine.getNumShips());

Console.showMessage(str);
Console.showMessage("  Number of officers: " + numOfficers);
Console.showMessage("  FP sum: " + sumFP);
Console.showMessage("  Avg. officers per fleet: " + String.format("%.2f", (float)numOfficers/numFleets));
Console.showMessage("  Officers per ship: " + String.format("%.2f", (float)numOfficers/numShips));
Console.showMessage("  Average officer level: " + String.format("%.2f", (float)sumLevel/numOfficers));
}

public static CampaignFleetAPI createFleet(FactionAPI faction, int fp)
{
final int totalFP = (int)(fp * InvasionFleetManager.getFactionDoctrineFleetSizeMult(faction));
final FleetParamsV3 params = new FleetParamsV3(
Global.getSector().getPlayerFleet().getLocationInHyperspace(),
faction.getId(), // Faction ID
null, // Quality override (null disables)
FleetTypes.PATROL_LARGE, // Fleet type
totalFP, // Combat FP
0, // Freighter FP
0, // Tanker FP
0, // Transport FP
0, // Liner FP
0, // Utility FP
0f); // Quality bonus
params.ignoreMarketFleetSizeMult = true;

final CampaignFleetAPI fleet = FleetFactoryV3.createFleet(params);

// Update combat readiness
fleet.getFleetData().sort();
fleet.forceSync();
for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy())
{
final RepairTrackerAPI repairs = member.getRepairTracker();
repairs.setCR(repairs.getMaxCR());
}
return fleet;
}
[close]

Result:
Code
Generated 100 fleets for faction Hegemony, doctrine 5-1-1
  Number of officers: 847
  FP sum: 9888
  Avg. officers per fleet: 8.47
  Officers per ship: 0.82
  Average officer level: 15.00
Generated 100 fleets for faction Luddic Church, doctrine 5-1-1
  Number of officers: 404
  FP sum: 9921
  Avg. officers per fleet: 4.04
  Officers per ship: 0.32
  Average officer level: 15.00
Generated 100 fleets for faction Persean League, doctrine 5-1-1
  Number of officers: 910
  FP sum: 9922
  Avg. officers per fleet: 9.10
  Officers per ship: 0.76
  Average officer level: 14.95
Generated 100 fleets for faction Sindrian Diktat, doctrine 5-1-1
  Number of officers: 876
  FP sum: 9844
  Avg. officers per fleet: 8.76
  Officers per ship: 0.87
  Average officer level: 15.01
Generated 100 fleets for faction Tri-Tachyon, doctrine 5-1-1
  Number of officers: 310
  FP sum: 9845
  Avg. officers per fleet: 3.10
  Officers per ship: 0.39
  Average officer level: 15.01
Why are Luddic Church and TT getting less than half as many officers as the other factions, but at the same level?

...wait, I see something. The other factions have Officer Management as the first skill in their doctrine commanderSkills array, while Church and TT have something else. Is that what's causing it?
[close]

EDIT: Also, NPC fleet commanders can only have 2 fully leveled fleetwide skills at the most, and usually closer to 1 or less (especially for the factions that only have 1 commander skill defined)?
- That seems to be going pretty easy on the player.
- With most factions having zero shuffle chance on their commander skills, a lot of factions have commander skills defined that they never actually use.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 08, 2020, 08:42:26 AM
When it adds the commander, it updates the number of officers, from inside the loop. See:
int officerNumLimit = person.getStats().getOfficerNumber().getModifiedInt();
And some lines after that.

So fleets w/o OM don't have officers *pruned* - they just obey the same max number of officer rules.

EDIT: Also, NPC fleet commanders can only have 2 fully leveled fleetwide skills at the most, and usually closer to 1 or less (especially for the factions that only have 1 commander skill defined)?
- With most factions having zero shuffle chance on their commander skills, a lot of factions have commander skills defined that they never actually use.

Correct-ish. There may be a flag that randomizes commander skill picks, though, which may make any of the skills get used.

Ah - it's "commanderSkillsShuffleProbability".

- That seems to be going pretty easy on the player.

It's a hidden bonus and I'd rather generally keep it consistent based on what the faction is than randomly sprinkle a ton of bonuses to try to increase the difficulty. I think there are better options for doing that that are more apparent to the player.  It's just one possible knob (of many) to turn regarding difficulty, right?

(There are a few cases in the next releases where fleets get a bunch of leadership skills, but they're special cases...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 08, 2020, 09:44:30 AM
When I put weapons into custom submarket that extends StoragePlugin they no longer are seen as "owned". If I put a weapon to vanilla storage, they are "seen", e.g. tooltip on that weapon shows "You own a total of x...". My class extends StoragePlugin, and submarkets.csv has "player" as faction.

Is there a way to make custom submarkets count towards player-owned weapons? Because an image is worth 1000 words: https://imgur.com/a/MZu9vd5 (https://imgur.com/a/MZu9vd5)
I think this got lost among other questions that day, could you shed some light on this please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 08, 2020, 09:47:56 AM
Ah, yeah, apologies!

Only stuff in a submarket with id == Submarkets.SUBMARKET_STORAGE gets counted for this, so you might be out of luck there, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 08, 2020, 10:46:59 AM
- That seems to be going pretty easy on the player.

It's a hidden bonus and I'd rather generally keep it consistent based on what the faction is than randomly sprinkle a ton of bonuses to try to increase the difficulty. I think there are better options for doing that that are more apparent to the player.  It's just one possible knob (of many) to turn regarding difficulty, right?

(There are a few cases in the next releases where fleets get a bunch of leadership skills, but they're special cases...)

Seems like that would be pretty easy to show using the officer skills display you added when hiring an officer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 08, 2020, 11:52:52 AM
Yeah, had been thinking of doing that some time ago! Not entirely clear how to smoothly fit it into the interaction flow, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 09, 2020, 09:10:08 AM
I have a class that implements BaseIntelPlugin and uses large description only (hasSmallDescription -> false, createSmallDescription() not overridden). When I call `IntelUIAPI.recreateIntelUI()` the first intel on the list gets automatically selected and displayed. This all is fine if the intel uses small description. If the intel uses large description it still displays small one (empty in this case) even though `hasSmallDescription()` returns false. If I change it to true (so intel has BOTH small and large descriptions) the small one will be displayed (or in my case complains to override it).
Is there a way to force recreateIntelUI() to display large description instead of small after the call?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 09, 2020, 09:27:31 AM
Hmm, doesn't look like it. Is there a reason you're calling recreateIntelUI() instead of updateUIForItem(this)? The latter wouldn't hide the current intel, so that may be an option. Let me also make it so that the updateUIForItem() call will show the item's large description if it has one...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 09, 2020, 11:16:41 AM
Is there a reason you're calling recreateIntelUI() instead of updateUIForItem(this)?
My large intel is managing collections of small intel - the number of those changes as buttons are pressed:
(https://i.imgur.com/z5z2vg8h.png)
Need to test if it would work if I was calling updateUIForItem() for each small intel that changed + large intel. I feel like it should work for adding new intel, not sure about removing intel from IntelManager and then calling updateUIForItem() on item that was removed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 09, 2020, 11:50:32 AM
Ah - yeah, it wouldn't work for adding/removing intel items, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 09, 2020, 12:50:02 PM
Ah - yeah, it wouldn't work for adding/removing intel items, unfortunately.
Let's try and hack around it. Is there a way to bring intel screen programmatically? I just noticed if I do my changes without UI update call and then press E I end up with the correct refresh logic. So I hacked this working solution:
Code
        try {
            new Robot().keyPress(KeyEvent.VK_E);
        } catch (AWTException exception) {
        }
But obviously would prefer something more native to Starsector...

Robot, KeyEvent, AWTException all lives in java.awt.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 09, 2020, 01:03:52 PM
<holds nose, gives thumbs up>
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 11, 2020, 01:30:37 PM
Any idea what would cause this? On the surface is seems like a hullmod issue with the variant or the hull... but I wasn't editing much before this happened and I cannot for the life of me figure out what I did to cause it.

20424 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.loading.specs.HullVariantSpec.isDHull(Unknown Source)
   at com.fs.starfarer.codex.CodexData.Object(Unknown Source)
   at com.fs.starfarer.codex.CodexData.<init>(Unknown Source)
   at com.fs.starfarer.codex.super.<init>(Unknown Source)
   at com.fs.starfarer.codex.super.Ô00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

*EDIT* Nvm I just had to perform the ancient spell of posting here after hours of searching in order for the issue to immediately present itself to me... lol I added a prefix to a hullmod definition that did not need it because I don't override it. So it was searching for a hullmod that didn't exist. That's why I wasn't finding any JSON typos - because their weren't any! And the hullmods all looked good since most require the prefix so that was far outside of my mind of being a potential problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 11, 2020, 01:48:14 PM
I gotta remove an entry from a Jumpoint "Nearby Objects" tooltip (https://i.imgur.com/paZRuvi.png (https://i.imgur.com/paZRuvi.png))
jumpPoint.removeDestination(entity); didn't do it...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2020, 03:31:17 PM
As long as the jump point has an exit, it's going to show markets and planets near that exit, so I don't think what you want is possible here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 11, 2020, 03:35:09 PM
The thing is - that planet does not exist in the system anymore. I timed it out, and removed the market and the entity - and it still gets displayed, but only in that single tooltip, nowhere else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2020, 03:38:43 PM
Are you sure you removed the market from the economy?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 11, 2020, 03:41:36 PM
I removed it from the economy, cleaned up the entity in the old system, then re-added a copy of the planet in another system (generating a new planet, carry over planet spec settings), and re-applied the (old) market to the new planet in another location.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2020, 03:51:18 PM
Hmm, looking at the code, it's hard to see how that could be possible. I'd check to make doubly sure that getEconomy().getMarketsCopy() doesn't have this market in it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 11, 2020, 04:44:48 PM
it does - but the market, and it's primary entity, are no longer in that system.

I'll run advance(1f) and check if that updates the tooltip while the market is de-registered during the transition
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 11, 2020, 04:45:27 PM
double-post...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2020, 04:50:21 PM
Ah - then you need to remove the market from the economy via EconomyAPI.removeMarket().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Iridescens on October 12, 2020, 01:37:21 AM
Hi, comrades!
As quick API check yielded no results, I'll ask here - Is there some vanilla (or lazy/magic) method to know whether Playerfleet has changed Location recently (e.g, jumped to/from Hyperspace or Transverse jumped)? Apparently, I could inject some 'thing' in hyper-dialog, but what about Transverse J?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2020, 09:24:19 AM
There's no event for it, so the easiest thing to do would be to have a script that periodically checks to see if playerFleet.getContainingLocation() has changed. Depending on the check interval and what you need, this *could* miss a quick jump out and back into the same system; to never miss that you'd need to check every frame. Which, with the check being so cheap - a simple == - should still be alright provided it's done carefully.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 12, 2020, 09:39:04 AM
I got a problem on my mod, my Wurg bar event is not showing up on long campaigns, but if i start a new game and get the requirements filled with console command it does work

What could be stopping the event from appearing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 12, 2020, 04:05:40 PM
Is there a way to get the same inflated fleet using only the DefaultFleetInflaterParams.seed and the variant IDs of the original uninflated ships? If not, what other information is required?

I've tried saving those values using writeTextFileToCommon and later recreating them by making a new CampaignFleetAPI fleet with the same members and original variants, but then the inflated variants end up different even with the same seed.

EDIT: Got it, the ships also needed to have the same ship name.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2020, 04:37:23 PM
I got a problem on my mod, my Wurg bar event is not showing up on long campaigns, but if i start a new game and get the requirements filled with console command it does work

What could be stopping the event from appearing?

If your getBarEventTimeoutDuration() was super long, that might do it. Nothing much else comes to mind, though. Hmm - you could try putting some breakpoints in BarEventManager to see what's going on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2020, 04:37:39 PM
EDIT: Got it, the ships also needed to have the same ship name.

(Nice!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 12, 2020, 10:40:13 PM
It seems that MissionDefinitionAPI.initMap can only make battlespaces with heights and widths that are multiples of 1000 pixels - do I have that right?

For instance, if I try to create a battlespace with 9000 height and width via api.initMap(-4500f, 4500f, -4500f, 4500f), it will only create a battlespace with 8000 pixels in height and width.

I guess the followup would be whether or not that is intended behavior. It certainly makes the tactical map prettier, but it seems like it's less intuitive than, say, the positive part rounding up and the negative part rounding down, or something to that effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 13, 2020, 09:03:07 AM
I have an BaseIntelPlugin that uses large description, and can grow in size. It simply uses panel given by the callee and adds many UI elements (panel.createUIElement, add something in resulting TooltipMakerAPI like one button or paragraph, finally addUIElement). It all works nicely until I reach defined height, at which point next "rows" spill over: https://i.imgur.com/XTa1Fyb.png (https://i.imgur.com/XTa1Fyb.png)
Pseudocode:
Code
public void createLargeDescription(CustomPanelAPI panel, float width, float height) {
  TooltipMakerAPI tooltip = panel.createUIElement(...);
  tooltip.addButton(...);
  panel.addUIElement(tooltip).inTL(0, height+10);
}

I tried adding an outer element, that would have custom panel, and then use that custom panel to add elements, which works fine: https://i.imgur.com/7QcelBd.png (https://i.imgur.com/7QcelBd.png)
Pseudo code:
Code
    public void createLargeDescription(CustomPanelAPI panel, float width, float height) {
        TooltipMakerAPI outer = panel.createUIElement(width, height, true);
        CustomPanelAPI inner = panel.createCustomPanel(width, height, new ButtonHandlerFactory());
        TooltipMakerAPI tooltip = panel.createUIElement(...);
        tooltip.addButton(...);
        inner.addUIElement(tooltip).inTL(0, height+10);
        inner.getPosition().setSize(width, height+10);
        outer.addCustom(inner, 0);
        panel.addUIElement(outer).inTL(0, 0);
}
Unfortunately, now no Button callbacks are handled now. I looked into CustomUIPanelPlugin, but processEvents events are low level, and from what I see I'd have to be looking at mouse clicks and comparing it with the location the actual buttons are rendered on intel screen... Or I could make a class for each button and implement CustomUIPanelPlugin, thus letting it handle own callbacks. Which means rewriting most of my row-col rendering logic, which by itself is fine unless there is something easier.
Is there an easier way to get a scroll on panel or am I forced to use customPanel and redoing part of my render logic?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 13, 2020, 09:42:32 AM
It seems that MissionDefinitionAPI.initMap can only make battlespaces with heights and widths that are multiples of 1000 pixels - do I have that right?

For instance, if I try to create a battlespace with 9000 height and width via api.initMap(-4500f, 4500f, -4500f, 4500f), it will only create a battlespace with 8000 pixels in height and width.

I guess the followup would be whether or not that is intended behavior. It certainly makes the tactical map prettier, but it seems like it's less intuitive than, say, the positive part rounding up and the negative part rounding down, or something to that effect.

Honestly, this is one of those where I'll go with "whichever way it works is what's intended". I'm not sure if -4500 etc actually results in a battlefield being that size and just the visible map grid being smaller, or if it gets rounded, but regardless, I'd say it looks like only multiples of 1000 are supported.

@Jaghaimo: ahh, that's a bug! It came up a bit back, and is fixed for the next release. I mean, the part about button callbacks not getting called if it's added to an outer element - which would indeed be the "right" way to handle this, if it worked. My apologies!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 14, 2020, 07:27:27 PM
Basically, I wanted to create a more aggressive type of support wing that doesn't hide behind carrier and also doesn't fly directly on top of enemy because they won't survive. On top of that, ships don't seem to use fighter ability like targeting feed on support fighter if all wings consist of them ( intentional?)

So I set the support wing to bomber type, so they will immediately try to reload when ammo runs out instead of loitering like fighters do, and set engagement range to very low value (<1000)

It seems that AI recognizes that they have to get close to use the wings, so no problems there, but is there anything i'd be breaking doing this otherwise?
Would this cause any issue with a ship that has different bombers/fighters with different engage distance, and if I leave the support tag will autofit still assign the wing as if it were a support-type one despite having BOMBER role ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 14, 2020, 08:32:07 PM
Basically, I wanted to create a more aggressive type of support wing that doesn't hide behind carrier and also doesn't fly directly on top of enemy because they won't survive. On top of that, ships don't seem to use fighter ability like targeting feed on support fighter( intentional?)

So I set the support wing to bomber type, so they will immediately try to reload when ammo runs out instead of loitering like fighters do, and set engagement range to very low value (<1000)

It seems that AI recognizes that they have to get close to use the wings, so no problems there, but is there anything i'd be breaking doing this otherwise?
Would this cause any issue with a ship that has different bombers/fighters with different engage distance, and if I leave the support tag will autofit still assign the wing as if it were a support-type one despite having BOMBER role ?

Anyone chime in and correct me if this is inaccurate, but I seem to remember that the low range will will likely cause other wings to not be sent out even if they have higher range - though this could have been fixed since I last encountered it. The carrier will wait until all wings can attack unless it is being threatened while REGROUP is active.

Autofit should consider it a support wing, yes, the role only affects how hullmods/skills/ship systems affect it and how the AI uses the wing during a strike.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 15, 2020, 11:44:09 AM
On top of that, ships don't seem to use fighter ability like targeting feed on support fighter if all wings consist of them ( intentional?)

That sounds like a bug, made a note - thanks!

I'm unsure about whether low range will make other wings not get sent out - that may indeed be the case if it's not SUPPORT.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 15, 2020, 01:23:10 PM
Thanks guys  :)

I tested with disparate engagement ranges, and it seems to work fine. It seemed like the fighters with shorter range actually move further out when paired with another wing that has higher engagement range, but im not 100% sure thats what I actually was seeing.

Last question for now - is there a way to dynamically assign a fighter wing to an arbitrary ship? I was looking at the FighterWing API, and there is an option to set an owner, but it accepts an int. Is owner in this context the side, like player/enemy/ally ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 15, 2020, 03:44:10 PM
i'm trying to prohibit building specific Vanilla Structures/Industries on a planet.
I'll take super dodgy solutions at this point, since I'm kinda running out of options :/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on October 15, 2020, 03:56:37 PM
i'm trying to prohibit building specific Vanilla Structures/Industries on a planet.
I'll take super dodgy solutions at this point, since I'm kinda running out of options :/

Iirc I don't think this is possible as industry hardcap/structure hardcap mechanics (not the amount in the case of industries, just the build prevention mechanics) is hardcoded and not exposed. I've never tried before, though, so I very well could be wrong.

You could try procedurally removing the structure if it exists, refunding the player, and giving them an intel alert explaining what happened, but preventing building specifically from the structure interface is currently impossible, I believe.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 16, 2020, 04:19:16 AM
My take on that would be for your mod to extend the base industry you want to prohibit, then replace base industry with your extended class (data/campaign/industry.csv). Then override isAvailableToBuild() with your logic.
Example: com.fs.starfarer.api.impl.campaign.econ.impl.Farming
Code
package i.hate.farms;

import com.fs.starfarer.api.impl.campaign.econ.impl.Farming;

public class MyFarming extends Farming {
   @Override
   public boolean isAvailableToBuild() {
      return false;
   }
}
And in your data/campaing/industries.csv:
Code
farming,Farming,15,60,,1,,,"farming, industry, rural",,graphics/icons/industry/farming.png,i.hate.farms.MyFarming,"Agriculture is a trade and technology as old as civilization itself; for thousands of cycles Humanity has harnessed the power of natural, modified, and artificial biological machines for sustenance. So it has always been, so it shall be so long as humans are human.",200

This is all theoretical code...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 16, 2020, 04:41:14 AM
That would directly override Vanilla .csv values, which is not something I want to do due to compatibility issues - but I thank you for the pointers!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 16, 2020, 08:35:21 AM
(That's the only way that comes to mind, yeah. Hmm...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 16, 2020, 12:13:29 PM
Trying to change a fighter's variant to another version in combat.

It works...but it also overwrites that variant for every other wing in the game.

Any ideas? I've tried cloning the variant and assigning it to the wing using fleetmember, which doesn't seem to do anything either =/
Code
			if(parent != null)
{
CombatEngineAPI engine = Global.getCombatEngine();
List<FighterWingAPI> wings = parent.getAllWings();

for(FighterWingAPI wing : wings)
{
if(!wing.getWingId().equals("armaa_bit_wing"))
{
continue;
}
//wing.setVariantId("custom");
//List<ShipAPI> fighters = wing.getWingMembers();
ShipAPI fighter = wing.getLeader();
//for(ShipAPI fighter : fighters)
//{
//fighter.getMutableStats().getVariant().setHullVariantId("variant"+ship.getName());
MutableShipStatsAPI stats = fighter.getMutableStats();
ShipVariantAPI newVariant = stats.getVariant().clone();
stats.getVariant().setOriginalVariant(null);
fighter.getFleetMember().setVariant(newVariant,false,true);


stats.getVariant().clearSlot("WS0001");
stats.getVariant().addWeapon("WS0001",ship.getVariant().getWeaponId("WS0001"));
fighter.setHitpoints(0f);
ship.setHitpoints(0f);

//}


}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 16, 2020, 12:17:37 PM
Ah - that's basically just never going to work. The ship is created from the variant once, and if you change the variant's weapons, that's not going to re-create the ship. You'd need to spawn another ship and replace this one with it, though that might have implications e.g. for things already targeting the "old" version etc, though in theory that should work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 16, 2020, 05:35:32 PM
That's actually exactly what I did, I changed the variant then forced the fighter to redock, which let it spawn in with the new weapons.

Alas, i'll just take this since i can't find a better  solution. This is for a ship that isn't very common anyway so it's probably fine
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tokanova on October 16, 2020, 06:48:56 PM
Hi there, I was just wondering, why are there such strict modding guidelines?
IE, why all the effort to try and balance mods?
I was just wondering, because I was thinking of getting into modding and just making OP BS for the heck if it,  and when I read the 'guidelines' thread I was a bit worried.

These are just mods right? Can't users decide if they themselves want to play with OP mods or not, instead of putting the burden of balance on the modders?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 16, 2020, 07:04:20 PM
Hi! The guidelines are for if you want to make a mod that "fits in" nicely with vanilla/other mods and is balanced etc, so it's there to help you do that *if you want*, not to restrict what you can do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 16, 2020, 07:24:20 PM
If you know you are making OP BS and that is your goal, then I say go for it! There is quite a bit of silly stuff lurking around the modiverse.

The guidelines thread is to help new modders avoid breaking things, because if you push stats, systems, etc. too far then the ship or whatever becomes boring or the AI can't use it or what-not.

The idea of balancing mods is to keep vanilla and "balanced" mod content at the same relative power. For example, if every mod makes their capital ship the same strength as the Paragon battleship, then the Paragon stops being special because it is not relatively strong anymore.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 17, 2020, 10:10:27 AM
Trying to make a hullmod that increases range of modules on a ship

Code
        List<ShipAPI> children = ship.getChildModulesCopy();
        if(children != null && !children.isEmpty()) {
        for (ShipAPI module : children) {
        module.getMutableStats().getBallisticWeaponRangeBonus().modifyMult(id, 1 + RANGE_MULT);
        }
        }

Does not work when put in applyEffectsAfterShipCreation, but does in advanceInCombat

I don't want it in advanceInCombat because it becomes more combat bloat, how to fix it? using customdata to make it run once also doesn't help because the game still has to check for the custom value and in the end also becomes bloat
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 17, 2020, 03:45:43 PM
Well, the game handles this sort of thing by putting the hullmod on all the modules. See for example the "Targeting Supercomputer" that stations have, which is built into every station module that has guns, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ed on October 17, 2020, 08:00:48 PM
Well, the game handles this sort of thing by putting the hullmod on all the modules. See for example the "Targeting Supercomputer" that stations have, which is built into every station module that has guns, etc.
I want to reuse the modules on different ships, and not all of them will have this hullmod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 17, 2020, 08:13:10 PM
Hmm - then you can either:
1) Use the advanceInCombat() method, which will have minimal impact if, say, you set a flag once you've applied the stats change and check this flag and exit out early, or
2) Make multiple variants of these modules

Ah, I see you said this regarding #1:
I don't want it in advanceInCombat because it becomes more combat bloat, how to fix it? using customdata to make it run once also doesn't help because the game still has to check for the custom value and in the end also becomes bloat

If you just put a boolean into customdata and check if it's present, that's nothing to be concerned about at all unless you're doing it thousands of times (or perhaps considerably more) every frame. A single check like that, you really, really don't need to worry about! That's pretty much a standard approach to "not doing things".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 17, 2020, 08:27:17 PM
The hullmod could automatically propagate itself to the modules (and remove itself from modules if the parent hull no longer has it). A bit like how the Interferences modded hullmod automatically adds itself when needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 20, 2020, 02:52:20 PM
Code
				

for(DamagingProjectileAPI proj : explodingProjectiles)
{
if(interval2.intervalElapsed())
{
DamagingProjectileAPI newProj = (DamagingProjectileAPI)
engine.spawnProjectile(ship, null, "armaa_einhanderGunS",proj.getLocation(), shotAngle, proj.getVelocity());
engine.spawnProjectile(ship, null, "armaa_einhanderGunS",proj.getLocation(), shotAngle2, proj.getVelocity());
shotAngle+=30;
shotAngle2+=30;
}


if(proj.isFading())
{
toRemove.add(proj);

}
}

explodingProjectiles.removeAll(toRemove);

I have this running in a for loop for a list of projectiles.
So it spawns bullets in a certain pattern until it starts to fade, then I add it to another arraylist to be deleted once the loop ends. Once the projectile gets removed, the engine stops spawning bullets at its location.

BUT

if the projectile hits something first, it just spawns bullets endlessly. So clearly it isn't being removed from the array because it never faded. My question is, what can I evaluate to remove an "expired" bullet from the arraylist? I tried checking if proj == null to no success :(


fix:onHit script that just deletes bullet
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 21, 2020, 10:32:14 PM
weapon.getCooldownRemaining() works fine normally, but when  I use it to check cooldown time is 0 on something under some type of time mod (say temporal shell) it starts firing off inconsistently. Is there something extra I need to do for those cases?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arngrim on October 22, 2020, 04:16:31 PM
Hey, I was wondering if it´s possible to make animated projectiles? Let´s say the projectile is a circle and I want to make it rotate as it travels.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PureTilt on October 26, 2020, 05:07:06 AM
i want to make option to change portrait mid game, is it possible to use portrait picking window from new game menu?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2020, 03:07:41 PM
weapon.getCooldownRemaining() works fine normally, but when  I use it to check cooldown time is 0 on something under some type of time mod (say temporal shell) it starts firing off inconsistently. Is there something extra I need to do for those cases?

(Sorry for the delay!)

Hmm, that's not really enough info. What's "inconsistently", vs what are your expectations? It would also help to see your code - or, rather, a minimal snippet that produces the behavior.


Hey, I was wondering if it´s possible to make animated projectiles? Let´s say the projectile is a circle and I want to make it rotate as it travels.

It's possible, but the details... I'm not 100% sure on off the top of my head, maybe someone more versed in modding this stuff in can chime in. The good news is it'll be significantly easier in the next release - there are plugins more or less explicitly for that sort of thing.


i want to make option to change portrait mid game, is it possible to use portrait picking window from new game menu?

I don't think this is exposed via the API, no. You'd have to code up a custom selector - doable (see: com.fs.starfarer.api.impl.campaign.ExampleCustomUIPanel), but some work.


What are the odds of having a `beforeGameLoad` hook added to `ModPlugin`?

The use case I'm thinking of is detecting save-breaking mod updates and showing an user-friendly message before the save file is deserialized and blows up.

The game already shows a "mod compatibility warning" when you try to load the game (I'm not 100% sure if this is in 0.9.1a, actually), and will also show the saved with/current versions for all the mods involved in the save game's tooltip, so I think this should be covered?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 26, 2020, 03:43:45 PM


(Sorry for the delay!)

Hmm, that's not really enough info. What's "inconsistently", vs what are your expectations? It would also help to see your code - or, rather, a minimal snippet that produces the behavior.



Hi, and no worries! Here's a video of what im talking about https://imgur.com/a/9OSiZ7e
You can see the first time I shoot, I think all the bullets spawn correctly. But the next time I use the system, only one bullet is spawned in while firing.

So I have a weapon that fires a burst of 8 shots. The ship this issue is on has a system that replaces these shots with a stronger version of them.
To prevent bullets appearing when they shouldn't, I added (if(weapon.getCooldownRemaining() <= 0)) as a condition, which works flawlessly..or almost always, anyway. BUT when time dilation effect is active, sometimes bullets will spawn, and sometimes they wont.

Puretilt actually helped me with this, because he had a similar issue, and well, I will post my code, and then the conclusion he came to. This is in an every frame weapon effect script.
Code: java
				

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {


for (DamagingProjectileAPI proj : engine.getProjectiles())
{
//if this is one of our projectiles and hasn't been accounted for
if (weapon == proj.getWeapon() && !registeredProjectiles.contains(proj) && !explodingProjectiles.contains(proj))
{
//add it (prevent infinite bullet works)
registeredProjectiles.add(proj);

//If the weapon can actually fire
if(weapon.getCooldownRemaining() <= 0)
{
FluxTrackerAPI fluxLevel = weapon.getShip().getFluxTracker();
//Spawn the new projectile
DamagingProjectileAPI newProj = (DamagingProjectileAPI) engine.spawnProjectile(ship, weapon, "armaa_einhanderGun2", proj.getLocation(), proj.getFacing(), ship.getVelocity());

if(fluxLevel.getCurrFlux()+weapon.getFluxCostToFire() > fluxLevel.getMaxFlux())
{
fluxLevel.forceOverload(0f);
}

else
fluxLevel.setCurrFlux(fluxLevel.getCurrFlux()+weapon.getFluxCostToFire());

//ad the new proj for fx stuff later
explodingProjectiles.add(newProj);
Global.getSoundPlayer().playSound("plasma_cannon_fire", 1f, 0.7f, newProj.getLocation(), newProj.getVelocity());
}
//remove old bullet
Global.getCombatEngine().removeEntity(proj);
}
}
}


I don't 100% remember the specifics of the issue now, but it seemed like there is a delay with spawning bullets under time dilation? What tilt did was add a 2 frame delay to his script, which fixed his issue, but I just disabled being able to use this specific ships right click to get around it for the time being
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2020, 03:57:43 PM
Ah, ok - yeah, the conclusion makes sense. Fast-time ships will advance() several times in a row without the rest of the engine advancing, so stuff like adding/removing projectiles might not get processed if it's done in a system script for a ship that's in fast-time. I forget the details - they're hairy - but, yeah, this doesn't sound unreasonable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 27, 2020, 08:04:02 AM
(I split the more suggestion-themed discussion regarding mod versioning into a separate thread (http://fractalsoftworks.com/forum/index.php?topic=19304.0).)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 27, 2020, 09:15:25 PM
Thanks!

I noticed fighters will sometimes leave behind a hulk like disabled ships, or straight out be vaporized.
Is there any way to make them always become hulks/husks?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 28, 2020, 10:23:28 AM
Ah, there isn't, sorry! It's hardcoded to 50% for fighters.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 28, 2020, 11:52:38 AM
Is there a way to get the intersection of two CargoAPI objects easily? Right now I use brute force and go over each cargo stack in both CargoAPIs, check if it's the same item, take one stack, and adjust size to min of the two sizes.

I could also use mathematical approach (pseudocode, for simplicity assume it returns new CargoAPI, in actuality would need to use to multiple copies):
Code
aLessB = cargoA.removeAll(cargoB);// left side of union
bLessA = cargoB.removeAll(cargoA);// right side of union
aPlusB = cargoA.addAll(cargoB);// union
intersection = aPlusB.removeAll(aLessB).removeAll(bLessA);// center of union, intersection, but need to accommodate for duplicates (stacks have sizes which mutate due to addAll/removeAll, lets treat them as duplicates), every stack needs to be halfed (got napkin math to cover that)
Actual quantity in intersection is: in bLessA: max(0, qB - qA), in aLessB: max(0, qA - qB), in aPlusB: qA + qB, in intersection: qA + qB - max(0, qB - qA) - max(0, qA - qB), solve for A > B, A < B, A = B) to see quantity is doubled in each case.

Edit: Actual Java code doesn't seem too terrible:
Code
    public CargoAPI getCommonCargo(CargoAPI cargoA, CargoAPI cargoB) {
        CargoAPI aLessB = cargoA.createCopy();
        aLessB.removeAll(cargoB);
        CargoAPI bLessA = cargoB.createCopy();
        bLessA.removeAll(cargoA);
        CargoAPI intersection = cargoA.createCopy();
        intersection.addAll(cargoB);
        intersection.removeAll(aLessB);
        intersection.removeAll(bLessA);
        halveQuantities(intersection);
        return intersection;
    }

    private void halveQuantities(CargoAPI cargo) {
        for (CargoStackAPI cargoStack : cargo.getStacksCopy()) {
            float size = cargoStack.getSize();
            cargoStack.setSize(size / 2);
        }
    }
Even with having to create those copies this code is vastly simpler to what I actually ended up with (the two nested loops), it is even simpler than one helper function I use (below)! I worry about performance (and calls to addAll, removeAll) though.

Is there an easier way to check if two cargo stacks are the same item (disregarding quantities)? I stole this from Misc.isSameCargo():
Code
    private boolean isSameCargoStack(CargoStackAPI s1, CargoStackAPI s2) {
        if ((s1 == null || s2 == null) && s1 != s2) {
            return false;
        }
        if (s1.getType() != s2.getType()) {
            return false;
        }
        if ((s1.getData() == null || s2.getData() == null) && s1.getData() != s2.getData()) {
            return false;
        }
        if (!s1.getData().equals(s2.getData())) {
            return false;
        }
        return true;
    }
This one helper function is already comparable to the whole code using addAll/removeAll. Curious, how would you find the common part of two cargos?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 28, 2020, 12:50:13 PM
What you're doing seems fine! Depending, might want to throw in a .sort() for each of the starting cargos; that'd - iirc - compress any multiple stacks of something into a single stack. (Careful if doing this to player cargo, since that'd also nuke any special custom stacking/ordering they might have done.)

I think the more important question, performance-wise, is whether worrying about the performance on this makes sense or not. For example, if this code runs in response to a UI interaction (i.e. inside some dialog or similar), then it likely doesn't matter. If it can run in the background while the player is flying around, then it might matter if the cargo size could be pretty large or you need to do this a lot for some reason, but if not, then again it probably doesn't matter how optimized that is.

Edit: regarding the "are the stacks the same" question, your code looks good to me. Are you concerned about performance or code length? The former seems like it'd be very good for this method, and the latter it doesn't seem like there's an easy/obvious way to cut down on it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 28, 2020, 01:14:28 PM
Ah, there isn't, sorry! It's hardcoded to 50% for fighters.

thanks  :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 05, 2020, 11:09:29 AM
What's the difference between getVisualBounds() and getExactBounds()?

Ah, there isn't, sorry! It's hardcoded to 50% for fighters.

thanks  :'(
I don't know if you've already tried this (I haven't) but if you turn a fighter into a frigate, or change its collision class, right as it dies, the hulk might stick around?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 05, 2020, 11:15:45 AM
getExactBounds() is used for collisions. getVisualBounds() is used for rendering ship pieces after they've been split apart, the ship sprite is stenciled to an area defined by the bounds, weapons outside it are discarded, etc. I forget what the difference is in how the two are generated, but in terms of what they're for, that's it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boogie on November 09, 2020, 02:11:57 PM
Could anyone please give me a direction to dig infor this error?
I'm trying to run a basic ship mod following the wiki intro to modding guide. there should be nothing creating this.
Never mind I'm an actual idiot, I forgot to enable lazy lib with the console command mod for testing.
Code
12695 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]
java.lang.RuntimeException: Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]
at com.fs.starfarer.loading.scripts.ScriptStore.new(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.OO0000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Krelian on November 09, 2020, 06:16:48 PM
Hello. Just curious, are non-orignal mods (as in from popular culture) frowned upon on this comunity? I ask because there is a TON of awesome mods, but most impressive of all is that almost all of them are original ideas, besides the unavoidable starwars one, one from gundam iron brooded, and one from homeworld (that comes from the top of my mind). The "original" mod ratio is extremelly high; and with a game that is a perfect fit for a ton of popular culture sci-fy, I just cant but wonder why is that.

More to the point, I had been toying with the idea of implementing certain sci-fy I would like a lot to play with, but now I fear it could be rejected by the comunity because of my previous point.

Regards
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 10, 2020, 03:41:44 AM
Translating an existing IP into Starsector is more difficult and less rewarding than creating an original work. Not to mention the risk of getting C&Ded — all your work down the drain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on November 10, 2020, 03:48:28 PM
You're unlikely to get either help or hindrance in creating whatever IP mod you want to exist. The problem with most IP mods is that someone with beginner skills shows up, does a little bit of work, and then expects the rest of the forum to pitch in to complete it with/for them. Then the mod gets abandoned. Rinse, repeat.

Regarding C&Ds; generally it's not worth the negative publicity hit for a rights-holder to issue those for tiny fan projects unless the fan project is seeing as being in direct competition with an official project. But you have no functional way of knowing what might be in the works at any given time; you could chug along on your mod for years and get it all nullified at once because someone decided in a closed meeting to greenlight a game, and the legal staff is doing a sweep for competing fan projects. And; the game they greenlit might never see the light of day; you might just get your work tanked because Legal is doing their due diligence.

There are lots of pseudo-legal arguments about copyright and trademark violations being magically legal if you're not charging money or if you change a certain percentage of pixels, and those are all garbage arguments with no legal basis. In the former case, it's just not worth the time and expense to go after you; in the latter, disguising what you're doing just improves the chances of getting away with it. But assuming a rights-holder has deep pockets and a single-minded desire to chase after you, none of that is legal; it just might be beneath notice, or lack a basis for action.

So it's less 'frowned upon' and more 'given the high barriers to entry in modding Starsector at all, low-effort IP mods don't get very far compared to original work'. The exceptions are all pretty unique - dating back to when the game was much less complex, putting a unique spin on the IP, or directly copying functionality from other, more complex original mods. Nothing is actively stopping you from being another exception.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Krelian on November 10, 2020, 07:56:29 PM
I see the point, thanks for the thoughtful answers
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 11, 2020, 05:35:00 AM
getExactBounds() is used for collisions. getVisualBounds() is used for rendering ship pieces after they've been split apart, the ship sprite is stenciled to an area defined by the bounds, weapons outside it are discarded, etc. I forget what the difference is in how the two are generated, but in terms of what they're for, that's it.
Alright - thanks!

Is it possible to change the maximum industry count for a given planet, without affecting other planets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 11, 2020, 06:01:48 AM
No, it's hardcoded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 13, 2020, 09:48:26 AM
Ah, too bad.

I want to make a weapon barrel that recoils forwards instead of backwards. Putting a negative number in the recoil field doesn't work. Am I out of luck?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harpuea on November 13, 2020, 11:31:25 AM
I am trying to make a shuttle land in the hangar bay, but I have to reference a fighter craft nearby. There may be a problem if there are no fighters nearby. How do I get a ship with carrier bay landing location directly if only the carrier is present?

Code
    	    for (ShipAPI fighterAI : CombatUtils.getShipsWithinRange(ship.getLocation(), 4000.0F)) { //Check for fighters nearby to use their landing bay.
          if (fighterAI.getOwner() != fighterAI.getOwner() || !fighterAI.isFighter() || !fighterAI.getWing().getSourceShip().isAlive()) {
                  continue;
                }
          if (fighterAI.getOwner() == ship.getOwner()) {
                if (ship == playerShip) //If it is the player, display the text.
                Global.getCombatEngine().maintainStatusForPlayerShip("SystemAlert", "graphics/ui/icons/icon_retreat2.png","RALLY POINT",
                                fighterAI.getWing().getSourceShip().getName() ,false);
                }
                       
        if (fighterAI != null) {
        fightersource = fighterAI;
        carrier = fighterAI.getWing().getSourceShip();
        target = carrier;
            targetOffset = StolenUtils.toRelative(carrier, fighterAI.getWing().getSource().getLandingLocation(fighterAI));
        }
        break;
       
        }


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 13, 2020, 12:00:37 PM
I want to make a weapon barrel that recoils forwards instead of backwards. Putting a negative number in the recoil field doesn't work. Am I out of luck?

... since that's what I was about to suggest - probably, yeah.


@Harpuea: I'm not sure I understand the question. Why couldn't you iterate over the ships nearby and find a carrier that way?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harpuea on November 13, 2020, 12:40:37 PM
Quote
@Harpuea: I'm not sure I understand the question. Why couldn't you iterate over the ships nearby and find a carrier that way?

I can get the location of the center of the carrier, but not the hangar bay. The shuttle lands in the middle of the carrier if I just get carrier location. So I have to iterate a fighter that is present to get the exact hangar bay location. Don't how to get the hangar bay location directly from the carrier. Thank you for the quick reply.



[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 13, 2020, 02:00:12 PM
Ah - I'd take a look at this:
ShipAPI -> List<FighterLaunchBayAPI> getLaunchBaysCopy();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on November 13, 2020, 05:37:58 PM
Is there a simple way to check if a ship is the only one left on its side, with no remaining reserves?
I don't know if you've already tried this (I haven't) but if you turn a fighter into a frigate, or change its collision class, right as it dies, the hulk might stick around?
I tried to with a baseeveryframecombatplugin but it seems to fire after the ship decides it will go poof or stick around, unfortunately :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 13, 2020, 05:49:46 PM
Is there a simple way to check if a ship is the only one left on its side, with no remaining reserves?

Iterating over getDeployed()/getReserves() from the respective CombatFleetManagerAPI would be the way to go here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on November 13, 2020, 06:12:23 PM
Thanks! I actually thought of something else while working on this.

Quote
Added fighter wing tags:
rapid_reform - lagging wing members catch up more quickly
leader_no_swarm - leader will start a new attack run on reaching target
wingmen_no_swarm - wing members will keep their position in the wing on reaching target
match_leader_facing - wing members will not face towards target but will match wing leader
attack_at_an_angle - aim to pass near target instead of directly over it, based on weapon range
independent_of_carrier - combat won't end when only these are left on the field

With 0.95, If I stuck this tag on a ship that had it's hullsize changed to fighter, would it be properly evaluated? I was also thinking I could just add the tag to it using ship.getWing().getSpec(), but I guess im not sure how it works behind the scenes. I've noticed that ships targetting anything that had its hullsize changed appends "Wing" to the variant name, so i'm assuming it wouldn't evaluate to null?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 17, 2020, 01:35:52 AM
Is it possible to change the way monthly salaries are calculated? For example, could I make a type of crew that gets paid less or more than normal crew?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 17, 2020, 06:18:44 PM
Is it possible to change the way monthly salaries are calculated? For example, could I make a type of crew that gets paid less or more than normal crew?

See: CoreScript.reportEconomyTick(); you could have a CampaignEventListener registered that could do this sort of thing. Where you'd run into problems though is making a different type of crew; the game will not use anything other than "crew" for things like crewing ships, colonization, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Feuerholz on November 18, 2020, 02:47:13 PM
Is there a way to modify the stats of the base hull in a .skin file?

I'm new to this, but i already created a separate Colossus tanker in order to fill the gap between destroyer and capital. However as i went through the files i realized that this should also work as just a "skin", but i don't find any info on how to change base hull stats like cargo and fuel in a .skin file.

Is this possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 18, 2020, 02:55:19 PM
You'd have to do it using a built-in hullmod. I'm not sure offhand if it's possible to change the ship's type designation (i.e. "Colossus-class Freighter") through the skin file. All in all it sounds like doing this with a separate ship hull is the right way to go.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Feuerholz on November 18, 2020, 03:26:45 PM
Thanks for the answer Alex. I already thought this might only be possible with a hullmod, if at all. However i did not think about the type designation, what relevance does this have?
So i'll stick with the new ship. Maybe for future updates it might be a cool idea to have the ability to create modified clones via skins. I could be wrong though, i'm rather new at this. ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 18, 2020, 03:30:15 PM
Ah - the relevance is that when the ship shows up in-game, its designation will no longer reflect its role :) You wouldn't want a "Colossus-class Freighter" to be a tanker.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BanjoJohn on November 20, 2020, 09:02:10 AM
So I modded  a ship into the game. It has shields. It's working in the game. I can turn the shields on when I directly control the ship. When I fight pirates who have the same ship I modded into the game, they can turn the shields on.  I do not notice the other ships in my fleet that are the same ship that I modded into the game ever turning on their shields.   

The base Ship_Data line that I copied and changed to make my ship was the Hammerhead,  is there anything I might be missing that I need to add to make sure that whatever controls the ships in my fleet know how to turn the shield on when needed?

Help me moddy-wan kenobi, you're my only hope.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2020, 09:16:41 AM
No, there's nothing you need to do. Hmm - I suspect it might be confirmation bias on your part? The enemy AI would be using it the same way your AI is, there's no difference there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BanjoJohn on November 20, 2020, 09:53:20 AM
I guess I'll just need to increase my sample size to see if it is just my bias.   

Here's another little question, what exactly goes in to calculating the supplies used per day when ships are damaged/repairing? My current playing around with values in my mod has made the supplies used per day jump up from normal to +50 supplies used a day with only one ship in the fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2020, 10:09:35 AM
It's based on the "supplies to recover from deployment" stat, combined with the rate of CR recovery. So if say it's a 10% recovery rate, 20% CR per deployment, and 5 supplies for recovery, that means it costs 5 supplies to recover 20% CR/perform similar hull/armor repairs, and since that takes 2 days at 10%/day, it'll cost 2.5 supplies per day to perform repairs and CR recovery.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BanjoJohn on November 20, 2020, 10:32:07 AM
Thanks, Alex!  I'll set up some formulas and check the values I have when I get back home.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Feuerholz on November 20, 2020, 11:19:17 AM
So i added the Colossus tanker as a new ship as mentioned above, but now that i wanted to build it i found a peculiar behavior i can't explain. So at the end of the month i'm being deducted 200k credits for production (custom production orders) as if i would use the entire industry i have at my disposal right now, despite the ship costing 40k only. Also the ship is never delivered and is not removed from the production line, so it's being produced every month, for 200k, without results. The "Income" screen also shows 200k costs but does not show a ship, just a bunch of goods, from waystation i guess.

I tried this several times making sure my production capacity isn't used by something else, to no avail. Same behavior every time i want to produce this ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2020, 01:34:50 PM
Ah - you need to add the variant to default_ship_roles.json

(This won't be necessary for production to work in the next release, btw, but generally speaking you want to do this anyway so the ship gets used by AI fleets.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 23, 2020, 05:30:31 PM
Are there any unintended side effects to changing a projectile's collision class to MISSILE_NO_FF so that it doesn't hit allied ships? I'm trying to create support weapons that can fire through allies that the AI is aware of. Would PROJECTILE_FIGHTER be better maybe?

Also is there a way to add something to the pierce set that would allow ship-based beams to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 23, 2020, 08:21:01 PM
Guardian/Paladin PD in vanilla can fire over friendlies. I think it uses:
   "collisionClass":"RAY_FIGHTER",
   "collisionClassByFighter":"RAY_FIGHTER",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 23, 2020, 08:50:23 PM
Thanks!

I've done some testing (my word the AI does not like to be in your LOS so this is very difficult to actually test haha) and it seems that is the way to go for energy weapons and PROJECTILE_FIGHTER is the way to go for ballistics.

There is a PROJECTILE_NO_FF option that has the same effect, but the difference is that the AI will still hesitate to use the weapon if an ally is in LOS. With PROJECTILE_FIGHTER it doesn't seem to care much.

I looked at the CollisionClass in the API and I didn't think it was possible for beams so knowing that this is used by the Paladin is great! Thanks again I'll take a look at the implementation.

*EDIT* Wow yeah it is as simple as adding that to the weapon file for beams. I thought it would also require some fancy projectile editing and changing the spec class or something. Why did I think that I tried that before and it didn't work?? Well anyway it does so awesome.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on November 29, 2020, 04:09:45 PM
can i have some clarification about how exactly "minTimeToSplit":2, works? testing results are inconclusive. it's in the mirv missile behavior spec
thanks in advance
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2020, 04:13:03 PM
IIRC a mirv will split if within a certain range of the target, but not until minTimeToSplit seconds have passed since it was launched.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on November 29, 2020, 04:55:47 PM
yes, i thought so too
i tried setting it to 20 and 200 and 2000 and i didn't notice any difference whatsoever, it just splits almost immediately upon launch(or upon being armed?). is it actually seconds?
tried changing hurricane too, directly in vanilla files, no effect as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2020, 05:31:08 PM
Ah - looking at the code, it also checks if the main body of the missile has an eta to target that's less than the remaining "until split" time, and if the eta is less than that, then it can also split.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on November 29, 2020, 06:02:32 PM
that's sad. so is there no way to make a mirv missile impact directly if the target is too close? without scripts, i mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2020, 06:08:30 PM
I don't think so, no - you'd need a custom missile AI. I mean, it's basically coded specifically *not* to do that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on November 30, 2020, 05:24:29 AM
I want to make a star system with three equidistant planets, all on the same orbit, and moving at the same speed. Arrayed somewhat like the blades of a fan. Is this possible? I can create the first planet, but how do I make the second and third have the same orbit period and not start in the same location?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 30, 2020, 12:10:13 PM
Check the parameters of addPlanet(), one of them is the starting angle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on December 02, 2020, 09:15:17 AM
I can't seem to get the correct Demand and Available values for commodity. From MarketAPI object I fetch CommodityOnMarketAPI object and then what? Both getDemandValue() and getAvailable() return wrong values (the former is too large, later is usually 0 or some single digit number). I want to have the same values as shown on the tooltip when you F1 over a commodity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2020, 10:06:39 AM
You want these:
int getDeficitQuantity();
int getExcessQuantity();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on December 02, 2020, 10:53:29 AM
Right, I do have those. It's the Available and Demand fields that I struggle with:

(https://i.imgur.com/NcdbvhI.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2020, 12:43:57 PM
Ah, right, sorry. Was going too fast and didn't pay enough attention.

For the available value it'd be something like:
int available = OpenMarketPlugin.getApproximateStockpileLimit(com);
available += com.getPlayerTradeNetQuantity();

For demand, it'd be:
int demandIcons = com.getMaxDemand();
if (!com.getCommodity().isPrimary()) {
    CommodityOnMarketAPI primary = market.getCommodityData(com.getCommodity().getDemandClass());
    demandIcons = primary.getMaxDemand();
}
int demand = (int) (com.getCommodity().getEconUnit() * demandIcons);
demand -= com.getPlayerTradeNetQuantity();

Except in the non-dev version, the CommodityIconCounts class isn't exposed, so you'd need to use
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on December 02, 2020, 01:53:13 PM
Thank you. I wouldn't be able to figure out the logic behind this myself.

Two observations / questions:
- Availability is based on OpenMarket alone, but there MAY be a better place to buy (lower price, see the lower section of the image in the spoiler) in Military or Black markets. You are actively discarding places that have no stock in OpenMarket (in F1 tooltip) - shouldn't it at least consider Military market since it's also a legal source of procurement?
- Demand can be 0 (upper section of the image in the spoiler), and yet market will pay for goods. Not sure how to interpret that, if there is no demand shouldn't market refuse to procure more stock? What happens if I sell enough to cover demand?
- The F1 tooltip sometimes show "Price / 100", "Price / 200" or "Price / 500" - how does the game decide which quantity to use for price approximation?

Spoiler
(https://i.imgur.com/Of4zNZS.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2020, 03:30:03 PM
- Availability is based on OpenMarket alone, but there MAY be a better place to buy (lower price, see the lower section of the image in the spoiler) in Military or Black markets. You are actively discarding places that have no stock in OpenMarket (in F1 tooltip) - shouldn't it at least consider Military market since it's also a legal source of procurement?

That's just where the static method happens to live. Open, military, and black markets essentially divvy up this value between them - not explicitly, but based on how their getStockpileLimit() methods are coded. All of them are based on getBaseStockpileLimit() and then get a fraction of that based on stability etc.


- Demand can be 0 (upper section of the image in the spoiler), and yet market will pay for goods. Not sure how to interpret that, if there is no demand shouldn't market refuse to procure more stock? What happens if I sell enough to cover demand?

They'll pay a lot less for it than its value in both of these cases. Basically even if they don't need something, they'll buy it for super cheap (to presumably re-sell?).

- The F1 tooltip sometimes show "Price / 100", "Price / 200" or "Price / 500" - how does the game decide which quantity to use for price approximation?

That value comes from CommoditySpecAPI.getEconUnit(), which is basically how many cargo-units an icon's worth of a commodity corresponds to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 03, 2020, 07:57:59 PM
Can anyone who has worked with modules tell me if they automatically die if the parent ship dies? Or do they need a hullmod or something for that?

Nvm, it showed a blue circle even without a designated png sprite so I know the module died when the parent ship died. I can just make it never detach to avoid the circles causing confusion. So now the question is what does vast_bulk actually do? Just make the module invincible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 07, 2020, 03:12:56 PM
i'm sory if this is too much to ask but is it possible to modify max relationship points and minimum relationship points? I dislike the idea of -100 / 100 when relationship points can be so easily manipulated and I feel some decimal points are lost when this is done as well. maybe for next update if this is possible ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AlexAtheos on December 17, 2020, 07:38:20 AM
Is there any way to randomize a ui graphic every time it is loaded?

An example would be having a randomized graphic for starsector_title_alpha so a mod could add randomized backgrounds for the initial loading screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2020, 10:58:11 AM
There isn't, no - it's going to use that specific graphic every time. (Well, that, or the replacement for it from a mod, but no way to add any flow control to that.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on December 19, 2020, 03:40:40 AM
Is it possible to open a custom panel in the campaign UI? You can render a custom panel as part of a large intel screen, but what if I wanted to open a custom panel rendered on-top of an existing screen? Just like this in-game example:(https://i.imgur.com/Qzs8AyL.png)



Is it possible to add to another tab to intel screen (e)?



Is it possible to enable (in next version) rendering both small and large intel screens (currently if both hasSmall and hasLarge returns true, only large is rendered)?



And finally, should I keep on adding requests to API request thread, or just write a comprehensive list of UI requests in own thread (nothing new, just releasing what already is in-game in the form of API)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2020, 12:12:50 PM
Is it possible to open a custom panel in the campaign UI? You can render a custom panel as part of a large intel screen, but what if I wanted to open a custom panel rendered on-top of an existing screen? Just like this in-game example:(https://i.imgur.com/Qzs8AyL.png)

It's not possible. Generally speaking, where the UI *is* moddable, it's moddable in very specific places/ways.

Is it possible to add to another tab to intel screen (e)?

It's not.

Is it possible to enable (in next version) rendering both small and large intel screens (currently if both hasSmall and hasLarge returns true, only large is rendered)?

Ahh, I don't think so - or, rather, it's probably *possible*, but it'd be a significant enough effort on my end and since it's not a path vanilla uses, there's a solid chance it wouldn't quite work right or I'd unintentionally break it at some later point etc.

It seems like you might be able to call the createSmallDescription method yourself, though, no? With a TooltipMakerAPI you've created to pass into that? Maybe I'm missing a piece that's not exposed that'd make this work...


And finally, should I keep on adding requests to API request thread, or just write a comprehensive list of UI requests in own thread (nothing new, just releasing what already is in-game in the form of API)?

The API requests thread is good! It may seem like I'm ignoring it, but that's not the case. I'll do my best to look through it and add what I'm able to add before the next release. Mostly it'll be the low-hanging fruit, in all likelihood - but then that sounds like exactly what you're talking about here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 21, 2020, 03:25:31 PM
Are custom highlight colors supported in the customPrimary and customAncillary columns of the weapon data csv? If so, what is the syntax/is there an example?

I was told Approlight has some custom highlights but, ah, it's not in my language.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2020, 04:27:34 PM
Custom colors aren't supported there, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 21, 2020, 04:33:39 PM
Custom colors aren't supported there, sorry!

Oh well, it's not a big deal. The standard HL is good enough for what I'm doing. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on December 23, 2020, 02:30:48 PM
So I'm doing this:

SectorThemeGenerator.generators.add(1, new JunkPiratesAnarchistThemeGenerator());

In my mods generator file.

All is good, and it's working great. At least first time round.

Except I'm trying to build a statistical picture of how my generator is working, and I am finding that every time I create a new sector (without physically exiting the game) I get a new generator added on top of the one I added last game (and statistically the same additional new amount of worlds etc. added until I am effectively saturating all candidate worlds within the sector after about ... say ... 6-8 new games without physically exiting the game).

So why doesn't it flush out my generator between games, while the game is still open? What have I missed? Can I do that, selectively? Or is there a sensible check I could put in at this stage of generation to determine if the collection on generators has one of my types of generators in it - and therefore not add it? (Anything I've tried so far hasn't had the desired effect ...)

Any help is appreciated on this one, hope that makes sense!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2020, 02:53:30 PM
Basically SectorThemeGenerator.generators is a static and the best way to think of adding something to it is as of making a configuration change (as in, "the set of theme generators is now this"), not as part of generating a new Sector. What you want to do is add your theme generator in your ModPlugin's onApplicationLoad() method.

Also, of note: since the generator will persist across multiple games and is not reset in any way, it's important not to store references to *anything* in the created Sector in its data members. In fact, really, any data members in your theme generator class are a potential red flag/issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on December 23, 2020, 03:05:15 PM
Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haka on December 26, 2020, 01:35:19 AM
Is it possible to somehow cause fighters to return to the ship with a toggleable ship system that uses regular fighter launch bays, in other words not a drone launcher system?

Think basically of a Battlecarrier that leans more towards a pure carrier but the system calls all its wings back in and gives buffs to put it more inline with a Battlecruiser/ship.

Also, is there a way to use a shipsystem to change a ship's shield type for a shipsystems duration/while toggled ON?
For instance, take a ship with say 160° OMNI shields, then when the system is switched on part of it locks the shield to the front in a 90°/120°/small arc.

There's more to these systems than what I have listed, simple stuff like weapon buffs, weapon shutdown via 10000% flux cost, copying Manuvering Jets and reducing the buff, etc. My coding is SUPER rusty and basic logic and repurposing other code is about my depth at the moment. Those parts i've figured out and gotten to work in game using MutableShipStatsAPI, but the others I am not sure which Interfaces or Classes I can call in the java file and have it work, if possible at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2020, 10:39:42 AM
For the fighters, this seems like it'd be doable, but with some scripting. You'd want to, probably, do something like what the Astral's Recall Device does, and then prevent the fighters from re-launching somehow - probably by setting the fighter replacement rate really high temporarily, or some such. And then undoing the change.

For shields, the AI wouldn't become aware of the shield type changing, so I don't think it'd work. It might just crash it, actually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haka on December 26, 2020, 01:00:45 PM
Quote
You'd want to, probably, do something like what the Astral's Recall Device does, and then prevent the fighters from re-launching somehow
For some reason I totally forgot that existed while trying all of this. I'll give it a shot, Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on December 26, 2020, 01:11:42 PM
Is there a way to hide a fighter wing in the Codex? The HIDE_IN_CODEX tag doesn't work like it does for ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2020, 02:42:39 PM
Hmm - pretty sure that HIDE_IN_CODEX on the fighter's entry in ship_data.csv should do the job. If not, it definitely will in the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 30, 2020, 12:48:23 AM
Is there any way to detect the generation of an officer?
I want to add a Memory data to the specific officers that generated in markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 30, 2020, 10:25:54 AM
There isn't any event for that, no. Hmm. I think the best you could do would be to add a Tags.MARKET_NO_OFFICER_SPAWN tag to the market and spawn the officers there from your own code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 30, 2020, 03:34:27 PM
Standard markets are in economy group 0, correct?

The assumption is that Global.getSector().getEconomy().getMarketsInGroup("0"); should get me all the non-special/hidden markets so I can iterate over all of them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 30, 2020, 03:38:43 PM
It's null, not "0".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 30, 2020, 04:52:15 PM
Ah thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 30, 2020, 07:03:51 PM
fine...Is there any better way to detect if a fleet member exists? There is a problem that if I record a FleetMemberAPI, the member would be strong reference that won't be removed from the save.
Now I use member == null || member.getFleetData() == null to check. And another way I think is to use WeakReference, though it will take several lines in the save.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 30, 2020, 08:35:31 PM
Using member.getFleetData() == null sounds reasonable, yeah. You might also check - if that's not null - whether getFleetData().getFleet() is also null, and if not, whether the fleet .isAlive().

You could use a weak reference, too. If it's only used occasionally the extra lines in the save don't matter very much, but if it's a commonplace thing with tens/hundreds or more uses, then it might be a concern.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 30, 2020, 08:40:03 PM
Using member.getFleetData() == null sounds reasonable, yeah. You might also check - if that's not null - whether getFleetData().getFleet() is also null, and if not, whether the fleet .isAlive().

You could use a weak reference, too. If it's only used occasionally the extra lines in the save don't matter very much, but if it's a commonplace thing with tens/hundreds or more uses, then it might be a concern.
What I wanna add is only in player's fleet and player's ship. hmm, maybe I could first not use weak reference and have a try.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 01, 2021, 03:51:16 PM
2 Questions:

1) Having some trouble with:

Code
float count = submarket.getQuantity(CargoAPI.CargoItemType.NULL, hullmod);

I've tried all the CargoAPI.CargoItemType options other than FIGHTER_CHIP and WEAPONS. I assumed SPECIAL would be the correct one for hullmods but it doesn't seem like it. "hullmod" is the hullmod id string in the hullmods csv. "submarket" is a CargoAPI gotten from an existing submarket in the campaign's eceonomy.

I've verified that the id is correct and the market in question has a single copy of safetyoverrides, but when I use this code count is still coming up as 0.0

Is there a way to detect and remove hullmods from markets using the API? Weapons and fighters were comparatively very easy to adjust.

2) Does setting the hull frequency to 0 also prevent a ship from spawning in the market as well as fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2021, 04:07:26 PM
The getQuantity method won't work quite how you want. The second parameter is the id of the special item *type*, so something like:
getQuantity(CargoItemType.SPECIAL, Items.MODSPEC)

Would get you the total number of mod specs in the cargo, but not for a specific modspec.

You'd want to do something like this:

for (CargoStackAPI stack : cargo.getStacksCopy()) {
   SpecialItemData data = stack.getSpecialDataIfSpecial();
   if (data != null && data.getData().equals(hullmod)) {
      count++;
   }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2021, 04:07:52 PM
2) Does setting the hull frequency to 0 also prevent a ship from spawning in the market as well as fleets?

(Oh, and this: ... I don't actually remember. I *think* so?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 01, 2021, 05:30:21 PM
Ah ok. Can I remove them using: submarket.removeItems(CargoAPI.CargoItemType.SPECIAL, hullmod, count);?

2) Does setting the hull frequency to 0 also prevent a ship from spawning in the market as well as fleets?

(Oh, and this: ... I don't actually remember. I *think* so?)

It at least seems to. But I assume the BPs are still raid-able since the faction still technically knows them. I need to test raiding a bit more.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2021, 06:05:01 PM
It'd be something like:

cargo.removeItems(CargoAPI.CargoItemType.SPECIAL, new SpecialItemData(Items.MODSPEC, hullmod), count)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 02, 2021, 01:00:07 AM
^Thanks! I tested it out and the code works now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on January 02, 2021, 11:43:25 AM
It'd be something like:

cargo.removeItems(CargoAPI.CargoItemType.SPECIAL, new SpecialItemData(Items.MODSPEC, hullmod), count)
How can I modify this code to remove a specific wing LPC from the player's cargo?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2021, 11:47:48 AM
Something like:
cargo.removeItems(CargoAPI.CargoItemType.FIGHTER_CHIP, wingId, count)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on January 02, 2021, 12:23:34 PM
Something like:
cargo.removeItems(CargoAPI.CargoItemType.FIGHTER_CHIP, wingId, count)
Thank You Very Much!!! I'm 90% there.
Where can I place this call so it will run whenever a Hullmod is removed? Or maybe somewhere else like where a wing is dropped out of a bay during Refit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 02, 2021, 05:33:22 PM
Is there any plan to add something to API that allows us to pass an arbitrary amount of time?

I feel like this was asked before, and you said it'd be a pain to do, but I can't seem to find where so I don't know if im imagining things
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2021, 05:59:33 PM
Thank You Very Much!!! I'm 90% there.
Where can I place this call so it will run whenever a Hullmod is removed? Or maybe somewhere else like where a wing is dropped out of a bay during Refit?

Ah, but that's the hard part! Offhand I'm not sure that there are good places to do that.

Is there any plan to add something to API that allows us to pass an arbitrary amount of time?

I feel like this was asked before, and you said it'd be a pain to do, but I can't seem to find where so I don't know if im imagining things

No plans for that, no. It's not easily doable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on January 02, 2021, 06:57:57 PM
Thank You Very Much!!! I'm 90% there.
Where can I place this call so it will run whenever a Hullmod is removed? Or maybe somewhere else like where a wing is dropped out of a bay during Refit?

Ah, but that's the hard part! Offhand I'm not sure that there are good places to do that.

I found one, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 02, 2021, 08:08:59 PM
Thank You Very Much!!! I'm 90% there.
Where can I place this call so it will run whenever a Hullmod is removed? Or maybe somewhere else like where a wing is dropped out of a bay during Refit?

Ah, but that's the hard part! Offhand I'm not sure that there are good places to do that.

Is there any plan to add something to API that allows us to pass an arbitrary amount of time?

I feel like this was asked before, and you said it'd be a pain to do, but I can't seem to find where so I don't know if im imagining things

No plans for that, no. It's not easily doable.

good to know, thanks  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flacman3000 on January 05, 2021, 10:34:16 PM
How does one create a hull mod just from descriptions and lore sake? For all examples, Do I have to have a script file? Which I wouldn't want to make unless it had an effect, is there a way to make a script null or avoid making a script with effects?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 05, 2021, 11:57:20 PM
assuming that i understand you correctly, you want to make a hullmod that does nothing at all, except display description to the player?
vanilla game already has such a hullmod you can look at - Shielded Cargo Holds
it does literally nothing, the only effect it has is triggered externally, in dialogue, when scanning for contraband, which works by checking whether a ship has a hullmod with a specific ID
change that ID and you have a dud
this is it's entire script:
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;

public class ShieldedCargoHolds extends BaseHullMod {
// nothing to do, just a marker hullmod
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 06, 2021, 10:54:31 PM
question

is it possible to attach flare's missile attraction effect to something else, like heatseeker type missile?
or alternatively
make a flare type missile to behave like some other missile type instead of just spinning around in circles?

i'm asking about strictly .proj file configs, not script magic or custom ai.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 07, 2021, 01:25:36 AM
"missileType":"FLARE_JAMMER",

"missileType":"FLARE_SEEKER",

However, these also change the AI behaviors; in Vanilla, these things are not severable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 07, 2021, 08:58:40 AM
Right, yeah - the flare attraction behavior is handled by its custom AI script which also handles its movement.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 07, 2021, 10:05:12 PM
Is there a way to add modules to a skin file?

the base hull has them and spawns with them attached, but the skin doesn't even though I have another variant for it with the modules on it. Do I need to specify something in the skin file itself? I tried looking through core data but I couldn't see any examples that did anything with modules.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 08, 2021, 09:55:14 AM
The modules are specified in a variant, not for a specific ship. A skin file is essentially shorthand for defining a new ship, so that doesn't specify modules either. Though it sounds like you're saying you do have a variant - of the skin hull - with modules in it, and that's not working? Offhand, I'm not sure why that might be, hmm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on January 08, 2021, 01:11:47 PM
Is there any way to stop a weapon or projectile from making an impact sound, or merely override the hit sound?

Code
	
"noImpactSounds":true,
"noShieldImpactSounds":true,
"noNonShieldImpactSounds":true,

These are left in the Chaingun's JSON, but I don't think they work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 08, 2021, 01:57:20 PM
Hmm - if those don't work, then no, but IIRC they should work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on January 08, 2021, 03:03:10 PM
Is there any way to add background music/sound to an Abandoned Station? The dead silence makes me sad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 08, 2021, 05:45:20 PM
Is there any way to add background music/sound to an Abandoned Station? The dead silence makes me sad.

The only way I know of would be to make a script that uses the music player to play a specific track and then override the rules interaction component of the station and have it add that script when the player docks. Depending upon how that portion of the rules are structured it may not require an override but could be added alongside without any mod incompatibilities.

I don't *think* there is any place in the settings file or faction files, etc, that allows this to be added in easily.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 08, 2021, 10:46:01 PM
Does the cargo picker dialog work in new game dialog? I tried it and it throws this NPE on either confirming or cancelling the selection:
49133 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.ui.o0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.twConfirm(Unknown Source)
   at com.fs.starfarer.campaign.ui.o0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.confirmTransaction(Unknown Source)
   at com.fs.starfarer.ui.newui.Y.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.I.?00000(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 09, 2021, 10:23:40 AM
Looked at the code - yeah, it looks like that has some campaign dependencies under the hood. Sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flacman3000 on January 10, 2021, 11:12:31 AM
Hi guys, I wanted to mod and make a weapon that's special but I do not know how to implement my idea, I wanted to implement a mine that gets launched at a slow velocity (by how fast your ship is going) to then contact anything and explode with expanding ring of damage. How would I incorporate this into a large missile mount weapon? I already have sprites some new some already in the game and changed in color. As far I know the imperium atom bomb ship is the closest thing I have to an example without all the debris I just want an image of a ring expanding. until it dissipates with set damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 11, 2021, 11:56:11 PM
Is there any way to refresh the cargo UI? I mean, I need to make some commodities to be illegal or legal after trading, but the red background which shows illegal won't be removed or added dynamically seems like it is not refreshed every frame.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 12, 2021, 10:33:53 AM
Hi guys, I wanted to mod and make a weapon that's special but I do not know how to implement my idea, I wanted to implement a mine that gets launched at a slow velocity (by how fast your ship is going) to then contact anything and explode with expanding ring of damage. How would I incorporate this into a large missile mount weapon? I already have sprites some new some already in the game and changed in color. As far I know the imperium atom bomb ship is the closest thing I have to an example without all the debris I just want an image of a ring expanding. until it dissipates with set damage.

That's a tough one - nice visuals are hard to just give a "do this" kind of answer for. MagicLib (http://fractalsoftworks.com/forum/index.php?topic=13718.0) may be a good place to start looking but I'm not really sure what your level of comfort with coding is, and this would take some scripting.


Is there any way to refresh the cargo UI? I mean, I need to make some commodities to be illegal or legal after trading, but the red background which shows illegal won't be removed or added dynamically seems like it is not refreshed every frame.

Ah - looking at the code, yeah, this isn't refreshed every frame, and I don't see a way to force it to refresh. Sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 15, 2021, 06:33:57 AM
(https://i.imgur.com/H1CAW80.png)
Is there any way to make these boxed contents disabled?
What I know is, the abandoned station condition could clear those things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2021, 09:16:33 AM
Checking the code - the stability, ship quality, etc widget is hidden if the market has the "abandoned_station" condition, so that's hardcoded.

The button is disabled if the market has only 1 submarket and that submarket has the id "storage". So, again, hardcoded.

Let me add a "no_market_info" tag for the next release to let this behavior happen in other cases. There, done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 15, 2021, 10:17:01 AM
I'm trying to make a sabot that explodes immediately and without targetting, like a shotgun. I can't really find a way to do this, since sabots only explode when theyre capable of hitting their targeted ship. Would I have to make a custom missle type to get this to work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on January 15, 2021, 11:31:22 AM
@NikoTheGuyDude
IIRC you are in danger of shooting your own ship with the missile if your range is close to 0. You know the collision radius of a .SHIP file? Well if any effects happen inside that range, they either hit your ship or have unpredictable results.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 15, 2021, 11:52:53 AM
@NikoTheGuyDude
IIRC you are in danger of shooting your own ship with the missile if your range is close to 0. You know the collision radius of a .SHIP file? Well if any effects happen inside that range, they either hit your ship or have unpredictable results.

What kind of unpredictable results?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 15, 2021, 02:01:33 PM
I'm trying to make a sabot that explodes immediately and without targetting, like a shotgun. I can't really find a way to do this, since sabots only explode when theyre capable of hitting their targeted ship. Would I have to make a custom missle type to get this to work?

can't you just make a gun that shoots the sabot projectiles? Unless im missing something, it'd have same effect.

If for some reason you wanted to keep it a missile, you can just make a dumbfire one that doesn't track and shoots directly where aimed
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 15, 2021, 02:47:25 PM
I'm trying to make a sabot that explodes immediately and without targetting, like a shotgun. I can't really find a way to do this, since sabots only explode when theyre capable of hitting their targeted ship. Would I have to make a custom missle type to get this to work?

can't you just make a gun that shoots the sabot projectiles? Unless im missing something, it'd have same effect.

If for some reason you wanted to keep it a missile, you can just make a dumbfire one that doesn't track and shoots directly where aimed

I can't use [RENDER_LOADED_MISSILES] with projectiles, or else the game will crash, and [RENDER_LOADED_MISSILES] is sort of integral to my envisionment of this weapon.

Also, I've succeeded in making it dumbfire by removing all turning capabilities, but I can't find a way to make it explode instantly. It only seems to explode when an enemy ship is within its arc and range. When I aim it an an enemy, though, it has the intended effect, as I made it burn out instantly... until it starts drifting off and fires while burnt out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 15, 2021, 05:27:33 PM
Use a script that detects the first stage and replaces it with the second stage instantly/after a delay/whatever. That is how some of the mod-shotgun weapons work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 15, 2021, 07:42:14 PM
Use a script that detects the first stage and replaces it with the second stage instantly/after a delay/whatever. That is how some of the mod-shotgun weapons work.

Do you know of a specific modded shotgun that does this, so I can reference it (fairly new to modding)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyber Von Cyberus on January 16, 2021, 08:10:31 AM
Hello, I would like to change the music for the player's colony and use my own, I'd like some help on how to do it since the game seems to crash when I modify the \starsector-core\data\world\factions\player
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 16, 2021, 05:40:01 PM
I have a ship that keeps getting too close to enemy ships (usually cruiser+) and getting killed as a result. It flies far ahead of other ships, and oftentimes ends up behind the enemy line.  im assuming this has to do with it just being faster, but it doesn't seem to react to building flux as quickly as other ships for some reason and will fly straight in front of a ship at like 99% flux trying to kill it.

So my idea is to just set an ai flag to make it back off after a certain flux threshold

would setting AI flag 'BACK_OFF"  when that criteria is met acheive this?

Also what does NEEDS_HELP do? API says "Whether the ship wants to be escorted by nearby friendlies."  Are you able to tell me what that means behind the scenes? When I tried it on a ship it seems like the ship I put the flag on would linger around friendlies more itself, and not that the othe AI ships were being directed towards it, if that makes any sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 16, 2021, 07:32:25 PM
So my idea is to just set an ai flag to make it back off after a certain flux threshold

would setting AI flag 'BACK_OFF"  when that criteria is met acheive this?

It should, yeah.

Also what does NEEDS_HELP do? API says "Whether the ship wants to be escorted by nearby friendlies."  Are you able to tell me what that means behind the scenes? When I tried it on a ship it seems like the ship I put the flag on would linger around friendlies more itself, and not that the othe AI ships were being directed towards it, if that makes any sense.

I forget the details but basically what it says. But, how to explain... it's a situational thing, not something where "if you set this flag it will reliably result in behavior X". That flag results in being a consideration in a few places under the hood, both for whether the ship that has it should try to escort other ships that it otherwise might, and whether other ships will try to escort it if they're so inclined.

BACK_OFF, on the other hand, should be pretty reliable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 17, 2021, 03:42:30 PM
Where, in the files/code, is it decided which intel is restricted to comm relays? I know that "boolean isPlayerInRangeOfCommRelay()" is a thing, I just don't know where in the code specific pieces of intel are bound by this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on January 18, 2021, 12:13:26 PM
Where, in the files/code, is it decided which intel is restricted to comm relays? I know that "boolean isPlayerInRangeOfCommRelay()" is a thing, I just don't know where in the code specific pieces of intel are bound by this.
Check intel manager - if you add intel it will show up immediately, and if you queue it will show up once within comms array range. This interface also has the method you are after.

https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/campaign/comm/IntelManagerAPI.html
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 18, 2021, 12:49:19 PM
Where, in the files/code, is it decided which intel is restricted to comm relays? I know that "boolean isPlayerInRangeOfCommRelay()" is a thing, I just don't know where in the code specific pieces of intel are bound by this.
Check intel manager - if you add intel it will show up immediately, and if you queue it will show up once within comms array range. This interface also has the method you are after.

https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/campaign/comm/IntelManagerAPI.html

Thanks! I had already found that interface, but I wasn't entirely clear on the mechanics of queueing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 23, 2021, 02:35:03 AM
Why does farming continue to produce food after I call removeCondition, reapplyConditions, reapplyIndustries on the market?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2021, 10:20:24 AM
Hmm - this is a bit tricky. Basically the "supply" in BaseIndustry needs to be persistent (and not reset by, say, reapplying the industry) because things like market conditions need to be able to affect it. Otherwise you could have a market condition affecting it, then industries getting reapplied and this discarding the effect of the market condition. That's why e.g. just blanketly having supply.clear() in the industry's unapply() method wouldn't work.

I don't remember all the details here, just that there are a number of potential interactions/combinations and it's, again, tricky.

It looks like "removing a ResourceDepositsCondition from a market" is not a directly supported use case. However, you could probably iterate over the results of industry.getAllSupply() and clear out the modifiers for getQuantity(), after removing a condition, and I think that'd do the trick. Something like:

Code
for (MutableCommodityQuantity q : industry.getAllSupply()) {
q.getQuantity().clear();
}

Provided the getAllSupply() method is in the current release, that is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 30, 2021, 11:13:54 PM
You know those interactions where the AIs hail you and the entire game pauses. Is it possible for an interaction to not pause the game? I'd like to make a mini-game where the player can play blackjack and poker with themselves when waiting for those long-distance bounty trips.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 31, 2021, 06:53:22 AM
Is the BaseSpecialItemPlugin only inited each time I open the cargo dialog?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on January 31, 2021, 07:43:10 AM
Hello, a follow-up to the hyperspace system hiding:
The script
Code
    
@Override
    public void onNewGameAfterProcGen() {
        for (SectorEntityToken token : Global.getSector().getHyperspace().getAllEntities()) {
            token.setDiscoverable(true);
            token.setSensorProfile(2000f);
        }
    }

Here's a plugin that I've been working on:

Spoiler
package data.scripts.plugins;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;


public class bgo_ModPlugin extends BaseModPlugin {
   private static float Paxis = 0.25f; // major & minor axis of ellipse is default >> 50% << of that of the field - then div by 2 to change axis to >> semi-axis << - already simplified
   private static float ASqu = (Paxis * 164000f * Paxis * 164000f); // is the a^2 in the ellipse formula -  width of sector field factored by P and then squared
   private static float BSqu = (Paxis * 104000f * Paxis * 104000f); // is the b^2 in the ellipse formula -  height of sector field factored by P and then squared

@Override
   public void onNewGameAfterProcGen() {
// The formula of an ellipse that has a horizontal major axis
// (x^2/a^2) + (y^2/b^2) = 1
// granted that (x,y) are coordinates on the line; a is the major semi-axis and b is the minor semi-axis
// semi-axis means half the axis
// Vanilla values for sector field:
// sectorWidth:164000
// sectorHeight:104000
// as Paxis is increased, the ellipse gets bigger, revealing more stars.
   for (SectorEntityToken token : Global.getSector().getHyperspace().getAllEntities()) {
      if ((token instanceof JumpPointAPI) && ((JumpPointAPI) token).isStarAnchor() && ((JumpPointAPI) token).getDestinationVisualEntity().getStarSystem().isProcgen()) {
//         float XSqu; // is the x^2 in the ellipse formula -  X coordinate squared
//         float YSqu; // is the y^2 in the ellipse formula -  Y coordinate squared
//         ((JumpPointAPI)token).getLocation((float) XSqu,(float) YSqu);
//         XSqu = XSqu(XSqu);
//         YSqu = YSqu(YSqu);
//         if (((XSqu/ASqu) + (YSqu/BSqu)) > 1) {
            token.setDiscoverable(true);
            token.setSensorProfile(2000f); //            token.setProcgen(false);
//          }
      }
   }
}
}
[close]

What I want to know is : How can I get the coordinates of the system to compare it to the (0,0) center? I tried SectorEntityToken but it only has a Vector value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2021, 08:53:13 AM
You know those interactions where the AIs hail you and the entire game pauses. Is it possible for an interaction to not pause the game? I'd like to make a mini-game where the player can play blackjack and poker with themselves when waiting for those long-distance bounty trips.

I don't know - sounds like a mod thing? But, to answer your question: you can unpause the game, but I don't think it's a good idea. Consider cases where a dialog might need to pop up during travel (such as, say, from encountering a fleet). Those sorts of complications would not be possible to handle.


Is the BaseSpecialItemPlugin only inited each time I open the cargo dialog?

I think it's inited when the cargo stack is created. At least, looking at the code it's called from the cargo stack constructor. Something else to note is the plugin is transient, meaning it will not be saved to the savefile, and will instead be re-inited when the game is loaded.

What I want to know is : How can I get the coordinates of the system to compare it to the (0,0) center? I tried SectorEntityToken but it only has a Vector value.

Hmm, I don't understand the question - a Vector2f *is* a coordinate pair. It has fields x and y.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 31, 2021, 09:17:16 AM
I think it's inited when the cargo stack is created. At least, looking at the code it's called from the cargo stack constructor. Something else to note is the plugin is transient, meaning it will not be saved to the savefile, and will instead be re-inited when the game is loaded.
Okay, I think I understood. BTW, who to get the time multiplier in the campaign(The speed up after pressing shift)? I use EveryFrameScript which would run while paused as a timer for some UI elements, but it seems that the amount is affected by the time multiplier or something else.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2021, 09:50:33 AM
Hmm - looking at the code, I don't think that's directly possible. The advance() method just gets called the number of times the speedup multiplier is.

A way to kind of get around this might be to use SectorAPI.getCampaignUI().getSharedFader() - that'll be .isFadedIn() every real-world second, regardless of the campaign speedup.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on January 31, 2021, 04:27:12 PM
Hmm - looking at the code, I don't think that's directly possible. The advance() method just gets called the number of times the speedup multiplier is.

A way to kind of get around this might be to use SectorAPI.getCampaignUI().getSharedFader() - that'll be .isFadedIn() every real-world second, regardless of the campaign speedup.
Fine, I use System.nanoTime to get the elapsed time now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2021, 06:14:10 PM
Fine, I use System.nanoTime to get the elapsed time now.

Oh yeah! Forgot that it doesn't have to use something from the API, hah - that's a completely legitimate way of doing it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on February 01, 2021, 03:13:09 AM
(https://i.imgur.com/JLAKM2v.png)

Hey I'm a bit stuck as to why my rules don't seem to be registering a particular memory flag. Can anyone give some clues for debugging this?

I'm happy with formatting, have tried changing variable name, tried deleting the rules which are overriding. Basically, as far as I can tell, I've done the simple checks a few times each, and ran through on the Discord with Nicke to try and make sure I was being as sensible as I can be,

The implementation I am using is the same in another part of my mod, and it works fine there, for different custom fleet types (which get the flag assigned in the same way, using getMemoryWithoutUpdate().set($tag, true) etc. )

Are there certain things I need to be aware of to avoid that might make a memory flag become invisible or something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2021, 10:11:31 AM
I think you just need to use the flags like so:

$entity.XYZJnkPirateExplorers

Etc. In OpenCommLink (and the rest of the conversation), the "local" memory becomes the person's memory, and the formerly-local entity memory is shunted off to the $entity. context. That's probably the single trickiest bit about rules, keeping that in mind when say adding a conversation - the same basic rule in BeginFleetEncounter (entity is in local context) and OpenCommLink (entity is in $entity, person is local) will use the variables without/with the prefix.

Edit:
Also, I'd add a score to that condition, like so:
$entity.XYZJnkPirateExplorers score:1000

Just to make sure that this "special" interaction takes precedence over, say, the standard greeting text, which may have the same number (or more) conditions. Rules with more conditions get higher priority (i.e. the more specific the rule, the higher priority it has), but the " score" affix can change the weight of each condition. The default weight is 1 score point per condition.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on February 01, 2021, 11:10:32 AM
Thanks Alex,

I did try $entity.tag and score=1000 independently; but haven't tested $entity.tag robustly (as I said the implementation works fine for different rules in very similar context).

Will try some more robust tests around above and let you know how I get on.

Cheers
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2021, 11:24:20 AM
Another thing would be to turn on devMode and check the log - it should tell you what conditions are failing for what rule.

If that's not printing somehow make sure DebugFlags.PRINT_RULES_DEBUG_INFO is set to true, though IIRC in 0.9.1a devMode it should be set to true by default.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on February 01, 2021, 01:20:28 PM
Hey, that worked!

I knew it was me, I just couldn't see quite what detail I had missed this time!

So what I think I might have done wrong, is not robustly tested the 'score' thing. I strongly suspect when I did that I formatted it wrong or something, as for some reason I kept reading it as a requirement to put score=1000 and NOT score:1000 (even though I have used this in a few of my own rules, and was explicitly told to use the colon etc. but there you go)

And I switched into devmode using console commands, which didn't light up the 'playtesting' flag, and it wasn't then popping out any rules errors. So obviously, doing it properly, I noticed straight away that my score override wasn't working.

I'm happy now, but I'm still not 100% clear on how priorities get assigned! (will at least remember about the proper implementation of score:1000 now, at least!)


This fella:
greetingAspItemsFriendly   OpenCommLink   $aspCourierFleetITEMS $faction.friendlyToPlayer

Was (as per design) getting triggered in preference to this fella:

greetingAspFriendly   OpenCommLink   $faction.id == syndicate_asp $faction.friendlyToPlayer !$aspCourierFleetITEMS !$aspCourierFleetVIP !$aspCourierFleetPRISONER !$aspCourierFleetMONEY


Whereas this fella:
greetingJUNKExplorerNeutral   OpenCommLink   $entity.junkPiratesExplorer $faction.neutralToPlayer


was getting forgotten about for this fella:
greetingJUNKFriendly   OpenCommLink   $faction.id == junk_pirates $faction.friendlyToPlayer !$entity.junkPiratesExplorer



Would it have been happy coincidence because I set up 4 different memory flags, that it made the ASP case much more clearly specifically wrong?

(Regardless I've set them all up with high scores now!)

Thanks again!

EDIT:

Related; I noticed my TradePanelFlavourText wasn't showing up ... well, it is, but about 50%-60% of the time? Sometimes being over-ridden by the default market flavour text.

It's enough to fix it by putting a score of 2 on my rule market id (with a faction.id unscored) but I'm vaguely concerned in modded games with faction switching this might then persist, and could break elements of immersion, and seems difficult to accurately control? (Theoretically, I am competing against a single score rule ... $global.tradePanelMode == Market, against - this; plus faction check; plus market check, yet which rule wins is apparently about 50/50 or 60/40 in favour of mine?)

It's obviously not a game-breaker by any stretch, but thought I should at least mention it.

(I'll leave you alone now, ha!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2021, 03:25:55 PM
Glad you got it working!

The only time a rule is picked randomly is when multiple rules match with the same exact score. So, if you're seeing a rule with less conditions (or, rather, a lower score) get picked in place of rule with a higher score, it means that the rule with the higher score is in fact failing some of its conditions.

Also, perhaps this needs to be clarified: ALL of the rule's conditions must match; if any conditions fail it will not be picked.

Re: trade panel flavor, as long as the conditions are specific enough, I'd say just give it a score:1000 to ensure it gets picked for the market you want it to show up on. It showing up where you don't want is not a risk unless the conditions match things you don't want them to. I.E. if you were to add $market.id to the conditions, they'd never match another market, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on February 01, 2021, 04:58:43 PM
EDIT:
Related; I noticed my TradePanelFlavourText wasn't showing up ... well, it is, but about 50%-60% of the time? Sometimes being over-ridden by the default market flavour text.

This is actually something I ran into with FPE; trade panel flavour text tends to depend on the stability of the market. I'm not entirely sure why that is, but I find that for consistent market flavour output you need to add lines accommodating stability = 1 and stability = 0. Give that a try if $market.id doesn't work, and using tags doesn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 01, 2021, 05:16:38 PM
EDIT:
Related; I noticed my TradePanelFlavourText wasn't showing up ... well, it is, but about 50%-60% of the time? Sometimes being over-ridden by the default market flavour text.

This is actually something I ran into with FPE; trade panel flavour text tends to depend on the stability of the market. I'm not entirely sure why that is, but I find that for consistent market flavour output you need to add lines accommodating stability = 1 and stability = 0. Give that a try if $market.id doesn't work, and using tags doesn't work.

The generic low stability flavor texts have weight 2. The generic flavor text for small, stable ports is weight 3.  A faction-specific flavor text has to have weight 4 or more to always appear at every colony that faction has.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 02, 2021, 01:08:36 AM
i read in rules.csv there's no way to detect a commissioned status of the player to a faction, could you possibly make a hook 4 it so I could possibly make new hegemony interaction text to how those fleets interact with the player based on their commission status  ;D ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 02, 2021, 10:44:09 AM
You can call "Commission hasFactionCommission" to see if the player is commissioned with the current person's faction. Otherwise you can write your own command to get that info.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 02, 2021, 06:19:35 PM
I'm looking for a FireAll hook in Rules for opening the comm link.

I don't want to override any faction dialogue specifically, so would the best way to go about this be to add a rule under the OpenCommLink trigger with an extremely high weight - like 100000 - that calls the FireAll script I need to, and then re-call FireBest OpenCommLink?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 02, 2021, 06:22:14 PM
Yeah, that sounds like the way to go. Vanilla does this kind of "do something then redirect it back" thing in a number of places. Just make sure you set a flag (probably with a zero expiration, so it goes away after the game is unpaused?) that prevents the rule from firing *again* when you call OpenCommLink from it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 02, 2021, 07:44:42 PM
Yeah, that sounds like the way to go. Vanilla does this kind of "do something then redirect it back" thing in a number of places. Just make sure you set a flag (probably with a zero expiration, so it goes away after the game is unpaused?) that prevents the rule from firing *again* when you call OpenCommLink from it.

Oh I didn't think of that! Thanks yeah that's what I'll do then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 04, 2021, 12:28:28 PM
Edit 2: My code is bad and I should feel bad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 04, 2021, 01:45:23 PM
*EDIT*
Can be deleted.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 05, 2021, 06:05:51 AM
So the sprite of a test ship I made wont load.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 05, 2021, 06:44:01 AM
I don't think anyone can help you with essentially no informaton to go off of.
Does the game crash on load, do you have a log of the crash if so, etc?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 05, 2021, 08:08:38 AM
I don't think anyone can help you with essentially no informaton to go off of.
Does the game crash on load, do you have a log of the crash if so, etc?

the game loads
i can add the ship via console
everything but the sprite loads (like mounts and stuff)

edit: also a few engines dont load which isnt my biggest problem rn
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 05, 2021, 09:12:40 AM
Is it possible to make a beam weapon that, after hitting armor/hull uninterrupted for a period of time, causes an event to happen (ex. an explosion)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2021, 01:30:03 PM
the game loads
i can add the ship via console
everything but the sprite loads (like mounts and stuff)

Hmm - one thing is to check that your png is saved as 24-bit, and *not* 8-bit.

Is it possible to make a beam weapon that, after hitting armor/hull uninterrupted for a period of time, causes an event to happen (ex. an explosion)?

See the Ion Beam's plugin for an example of something similar. You'd have to adapt it but the basic things you'd need to use are there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 05, 2021, 01:34:52 PM
Is it possible to make a beam weapon that, after hitting armor/hull uninterrupted for a period of time, causes an event to happen (ex. an explosion)?

See the Ion Beam's plugin for an example of something similar. You'd have to adapt it but the basic things you'd need to use are there.
[/quote]

Nice, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sqiurmo on February 05, 2021, 04:16:25 PM
Is there a value I can change to modify the max custom blueprints being built at the same time? It's already limited by the credit capacity, so I figure I should be able to queue as many as I want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 05, 2021, 04:52:06 PM
Question: "How do I use java to add sorted dialogue options to a fleet interaction using OptionPanelAPI.addOption()?"

Solution: I decided to approach the sorting method in a different way and it works with only one caveat: dev mode options disappear during any part of the conversation that uses this logic. Hopefully that won't be an issue later down the line. My problem earlier was that I was attempting to match a string (cast to an object) to a reference to an undefined object with far more values (of which the string is merely a component of the total object) - which obviously isn't going to work.

Assumption: The added dialogue option will always be the last index of the list - since it was the last one added.

Instead of matching the objects to sort the list (since I can't), I used the target index of the list and the above assumption to sort each option.

Sorting code:
Spoiler
Code
    /**
     * Sorts the list of options.
     *  Takes the last option on the list and sorts it according to the target index in the list.
     *  Places any remaining options below the target option while preserving options above the target index.
     */
    private static List sortOptionsList(List list, Object optionData, int optionIndex) {
        List sortedList = new ArrayList();
        Object sortItem;
        Object swap;
        if (LOG_INFO) {
            LOG.info("Options list prior to sorting: -- " + list.toString());
        }
        // Retrieve the recently added option to be sorted - should always be the last option on the list.
        sortItem = list.get(list.size() - 1);
        // Remove the option to be sorted from the unsorted list so it won't be added back in later.
        // Adding two instances of the same option makes weird things happen in the UI.
        boolean removed = list.remove(sortItem);
        if (LOG_INFO) {
            LOG.info("Option data representing target option to sort: " + optionData.toString());
            LOG.info("Actual option object to sort: -- " + sortItem.toString());
            if (removed) {
                LOG.info("Successfully removed target option: " + optionData + " from unsorted list");
                LOG.info("New unsorted list: -- " + list.toString());
            } else {
                LOG.info("Failed to remove target option: " + optionData + " -- from unsorted list: -- " + list.toString());
                LOG.info("Option object that could not be removed: -- " + sortItem.toString());
            }
        }
        // Iterate through the list looking for the target index for the added option.
        for (int index = 0; index < list.size(); index++) {
            if (index != optionIndex) {
                // If the current index is not the target index, add the next option from the list to the sorted list.
                sortedList.add(index, list.get(index));
                if (LOG_INFO) {
                    LOG.info("Sorted options list after adding next indexed option: -- " + sortedList.toString());
                }
            } else {
                // If the current index matches the target index for the added option, swap out the current option -
                // - for the target option and add the current option to the next index in the sorted list.
                swap = list.get(index);
                if (LOG_INFO) {
                    LOG.info("Option to be swapped: -- " + swap.toString());
                }
                sortedList.add(index, sortItem);
                sortedList.add(index + 1, swap);
                index++;
                if (LOG_INFO) {
                    LOG.info("Sorted options list after option swap: -- " + sortedList.toString());
                }
            }
        }
        return sortedList;
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 06, 2021, 04:51:39 AM
Im getting "Fatal: JSONObject["id"] not found." when i start the game with my own mod. (only content is a ship)

Here is the log.

2333 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.new(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.new(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.%u048F0000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 06, 2021, 08:45:41 AM
Proposal: A way to pop up a CustomPanelAPI from within an interaction dialog, which we could then add UI elements to. Would allow more powerful GUIs than what the base interaction dialog can do, especially if it needs to show a lot of options at once.

Im getting "Fatal: JSONObject["id"] not found." when i start the game with my own mod. (only content is a ship)

Here is the log.

2333 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.new(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.new(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.%u048F0000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Check your definition files (ship_data.csv, the .ship and .variant files). Make sure all the files exist and their filenames and internal IDs are correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 06, 2021, 09:03:05 AM
Proposal: A way to pop up a CustomPanelAPI from within an interaction dialog, which we could then add UI elements to. Would allow more powerful GUIs than what the base interaction dialog can do, especially if it needs to show a lot of options at once.

Im getting "Fatal: JSONObject["id"] not found." when i start the game with my own mod. (only content is a ship)

Here is the log.

2333 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: JSONObject["id"] not found.
org.json.JSONException: JSONObject["id"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.LoadingUtils.o00000(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.new(Unknown Source)
   at com.fs.starfarer.loading.LoadingUtils.new(Unknown Source)
   at com.fs.starfarer.loading.ShipHullSpreadsheetLoader.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.%u048F0000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Check your definition files (ship_data.csv, the .ship and .variant files). Make sure all the files exist and their filenames and internal IDs are correct.

i checked it a few times already
they should be named corretly but if you want to look over it for me ill attach the files

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2021, 09:07:38 AM
Proposal: A way to pop up a CustomPanelAPI from within an interaction dialog, which we could then add UI elements to. Would allow more powerful GUIs than what the base interaction dialog can do, especially if it needs to show a lot of options at once.

Hmm - could you be more specific? That is, do you want this showing up as a modal dialog on top of the interaction dialog?

In the next release, btw, VisualPanelAPI's showCustomPanel method will have this signature:
CustomPanelAPI showCustomPanel(float width, float height, CustomUIPanelPlugin plugin);
Giving you a custom panel to add UI elements etc to. So, not a modal dialog, but a way to heavily customize the base interaction dialog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 06, 2021, 03:24:14 PM
EDIT: nevermind im blind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 06, 2021, 05:07:49 PM
i checked it a few times already
they should be named corretly but if you want to look over it for me ill attach the files
I put the attached files in a test mod (as ship_data.csv and mcnavy_tachi.ship) and it worked fine (game boots, ship appears in codex) once I changed the sprite to a vanilla one. I think the error lies somewhere else.

Proposal: A way to pop up a CustomPanelAPI from within an interaction dialog, which we could then add UI elements to. Would allow more powerful GUIs than what the base interaction dialog can do, especially if it needs to show a lot of options at once.

Hmm - could you be more specific? That is, do you want this showing up as a modal dialog on top of the interaction dialog?

In the next release, btw, VisualPanelAPI's showCustomPanel method will have this signature:
CustomPanelAPI showCustomPanel(float width, float height, CustomUIPanelPlugin plugin);
Giving you a custom panel to add UI elements etc to. So, not a modal dialog, but a way to heavily customize the base interaction dialog.
Yeah I was thinking of a modal dialog (like the cargo and industry pickers).
Although doing it in the visual panel was also something I had in mind (albeit it's useful for different things, it has limited space but doesn't get in the way of normal dialog use). Thanks for implementing that!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 07, 2021, 03:34:15 AM
i checked it a few times already
they should be named corretly but if you want to look over it for me ill attach the files
I put the attached files in a test mod (as ship_data.csv and mcnavy_tachi.ship) and it worked fine (game boots, ship appears in codex) once I changed the sprite to a vanilla one. I think the error lies somewhere else.

anyway thanks for trying

edit: i seem to have found the problem. i may have edited a file in the main game by accident. %uD83D%uDE2C
but i have another question: i have a hidden pilum on the ship but the missiles themself are still visible. what should i do about this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 07, 2021, 06:24:57 AM
Are there any differences in threat evaluation for module ships vs regular ships?

So testing things further with the last post I made about a destroyer-classed AI controlled module ship that wouldn't back down and flew extremely close to enemies, I noticed this behavior stopped as soon as its modules were destroyed - at which point it seemed to favor self preservation a lot more than it normally would.

I can't figure out how having modules would make it act this way, though. It's the only correlation I can make at the moment, so just curious. Could overlapping collision circles, or a module "behind" an AI ship alter any kind of AI behavior? Just spitballing at this point  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 07, 2021, 09:04:01 AM
but i have another question: i have a hidden pilum on the ship but the missiles themself are still visible. what should i do about this?

You'd need to make your own copy of the pilum weapon file without the RENDER_LOADED_MISSILES hint. Missiles will - as you saw - render in hidden slots as well. (For an example of why this is desired, see: torpedo bombers, etc.)

Are there any differences in threat evaluation for module ships vs regular ships?

So testing things further with the last post I made about a destroyer-classed AI controlled module ship that wouldn't back down and flew extremely close to enemies, I noticed this behavior stopped as soon as its modules were destroyed - at which point it seemed to favor self preservation a lot more than it normally would.

I can't figure out how having modules would make it act this way, though. It's the only correlation I can make at the moment, so just curious. Could overlapping collision circles, or a module "behind" an AI ship alter any kind of AI behavior? Just spitballing at this point  :-\

I'm guessing you don't have any weapons on the main body of the ship? It only uses weapons on the main body for range-finding. So (from vague recollections) I think what's happening is it assumes it's a combat ship while it has modules, but doesn't know a range to fight at, so closes in as much as possible. When the modules are gone, it stops considering itself a combat ship and behaves like a civilian, backing off quite a ways.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 07, 2021, 11:39:35 AM
Unfortunately the ship has two built-ins and 3 mounts, its the modules that have no weapons.

It's extremely weird, even giving the ship a missiles will have it close to knife-fighting range with a capital, and every time I pop the modules at the start of combat it will revert to hanging back with the missile weapon like you'd expect..

does the main ship factor anything about module status into its decision making?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 07, 2021, 12:53:38 PM
Hmm - does the ship have the SHIP_WITH_MODULES hint? That's required for... I don't remember what, exactly, but some AI things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 07, 2021, 01:34:44 PM
Yeah I was thinking of a modal dialog (like the cargo and industry pickers).
Although doing it in the visual panel was also something I had in mind (albeit it's useful for different things, it has limited space but doesn't get in the way of normal dialog use). Thanks for implementing that!

Wasn't too bad, so, did it.

Added to InteractionDialogAPI:
   void showCustomDialog(float customPanelWidth, float customPanelHeight, CustomDialogDelegate delegate);
CustomDialogDelegate has:
   void createCustomDialog(CustomPanelAPI panel);
   boolean hasCancelOption();
   String getConfirmText();
   String getCancelText();
   void customDialogConfirm();
   void customDialogCancel();
   CustomUIPanelPlugin getCustomPanelPlugin();
CustomUIPanelPlugin: added renderBelow() method
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 07, 2021, 11:21:15 PM
Hmm - does the ship have the SHIP_WITH_MODULES hint? That's required for... I don't remember what, exactly, but some AI things.

Yeah, it has that tag too.  :(

I'll try to make a variant of a vanilla ship and just put modules on it to see if I can reproduce the behavior, at least then i'll have a bit more details to provide
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 08, 2021, 03:39:17 AM
How do you prevent weapons form spawning on markets? The built-in weapons I made are quite op and I only want them to be in the ships I made.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 08, 2021, 06:11:06 AM
So I went and made a quick mod+ mission to test module ships to see if I can reproduce the behavior, and it looks like it's consistently a thing:

Scenario:
6 Module Medusa's vs 6 Medusa's, both fleet under AI control

Variant: All use Attack variant,

The module I used for the medusa's was just a brawler strapped to the back of the ship, the only differences outside of this is the moduled medusa having SHIP_WITH_MODULES tag. Retreats were counted as a loss of the ship

Round 1:
Module side - 100% losses
Side 2 - 16% losses

Round 2:
Module side -100% losses
Side 2 - All ships survived

Round 3:
Modules: 100% losses
Side 2 - 16% losses

Round 4:
Modules: 66% losses
Side 2 - 83% losses
Victory by CR degradation

Round 5:
Modules: 100% losses
Side 2 - 50% losses

The moduled ships seem to get crushed consistently. I use medusa because of their ship system, which they normally would use to get away from particularly hot situations; in the case of the moduled medusa, while they -did- use them in the same way, it was far less often from my observation, and at times they'd often try to 'strafe' with the skim instead, teleporting to the side of the ship instead of retreating like the unmoduled ships would. They seem to mirror the behavior I saw in my modded ship as well:

-seemingly ignoring their overall flux, and pressing on attacks despite it
-flying into dense concentrations of enemies and getting picked apart from multiple angles, very prone to 'wandering off alone'

Not sure what it means..should I test with other scenarios also?



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 08, 2021, 07:52:32 AM
How do I make a variable that can be displayed as a string of text/an integer/float in a rules.csv dialogue thing? More specifically, how I inject demand data from a persons parent station into their dialogue in rules.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 08, 2021, 08:01:00 AM
https://fractalsoftworks.com/forum/index.php?topic=14911.msg242194

I'm not sure whether this bug is still present.. when using Better Colonies with it, people have reported this bug is still present. I'm unsure this is because

Code
		if (starfortress) {
return MathUtils.getRandomNumberInRange(Global.getSettings().getInt("tier2StationOfficerLevel"), Global.getSettings().getInt("tier3StationOfficerLevel"));
} else if (battlestation) {
return MathUtils.getRandomNumberInRange(Global.getSettings().getInt("tier1StationOfficerLevel"), Global.getSettings().getInt("tier2StationOfficerLevel"));
}
return MathUtils.getRandomNumberInRange(0, Global.getSettings().getInt("tier1StationOfficerLevel"));
}
This code for OrbitalStation got changed to allow randomizing of officer levels in station when getting the commander level.. could this be the case?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2021, 08:43:20 AM
How do you prevent weapons form spawning on markets? The built-in weapons I made are quite op and I only want them to be in the ships I made.

If you add the SYSTEM hint in the .csv, that should do it.

How do I make a variable that can be displayed as a string of text/an integer/float in a rules.csv dialogue thing? More specifically, how I inject demand data from a persons parent station into their dialogue in rules.csv?

You can make a custom command that puts this stuff into that person's memory with an expiration of zero. The Commission command might be a reasonable one to look at - it does other things, too, but does this at least in one place.


@shoi - hmm. If you can provide a mini-mod with this scenario, I might be able to take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 08, 2021, 11:39:34 AM
I think this should work (https://mega.nz/file/ScEEjLIa#XkZf0mDdxTpGbKXp8p2F2O1VnsaCB_dYsPeqUMP3JGk), the mission is called "modules vs no modules"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 08, 2021, 12:33:10 PM
I'm having a problem with my code and rules.csv: I have a variable defined as such:  int demandData = dialog.getInteractionTarget().getMarket().getCommodityData(SUPPLIES).getDeficitQuantity();
Another, as float demandDataValue = dialog.getInteractionTarget().getMarket().getDemand(SUPPLIES).getDemandValue();


And it is implemented like this:
Spoiler
if (command.equals("marketExploitableByInsider")) {
            if (marketStab <= 5) //placeholder value for debugging {
                memory.set("$SDE_demandData", demandData, 0);
                memory.set("$SDE_demandDataValue", demandDataValue, 0);
                return true;
            }
            else return false;
[close]

And command is  String command = params.get(0).getString(memoryMap);, with memory being getEntityMemory(memoryMap)

When I select the dialogue option I've made that has this text: $SDE_demandData $SDE_demandDataValue $faction, only $faction and $SDE_demandDataValue work. The output is this: (https://i.imgur.com/2YIFxke.png)

I can't figure out why it's doing this. If anyone could help, that'd be nice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 08, 2021, 01:57:47 PM
I'm having a problem with my code and rules.csv: I have a variable defined as such:  int demandData = dialog.getInteractionTarget().getMarket().getCommodityData(SUPPLIES).getDeficitQuantity();
Another, as float demandDataValue = dialog.getInteractionTarget().getMarket().getDemand(SUPPLIES).getDemandValue();


And it is implemented like this:
Spoiler
if (command.equals("marketExploitableByInsider")) {
            if (marketStab <= 5) //placeholder value for debugging {
                memory.set("$SDE_demandData", demandData, 0);
                memory.set("$SDE_demandDataValue", demandDataValue, 0);
                return true;
            }
            else return false;
[close]

And command is  String command = params.get(0).getString(memoryMap);, with memory being getEntityMemory(memoryMap)

When I select the dialogue option I've made that has this text: $SDE_demandData $SDE_demandDataValue $faction, only $faction and $SDE_demandDataValue work. The output is this: (https://i.imgur.com/2YIFxke.png)

I can't figure out why it's doing this. If anyone could help, that'd be nice.

Try:

Code
memoryMap.get(MemKeys.LOCAL).set("$SDE_demandData", demandData, 0);

And then you can reference it in your rules through: $SDE_demandData

You will need MemKeys when referencing stored data using code as well. For instance:

Code
int demandData = (int) memoryMap.get(MemKeys.LOCAL).getFloat("$SDE_demandData");

So if you are seeing it under a specific category when dumping memory in devmode, such as "$faction.SDE_demandData" - you have to use MemKeys.FACTION in place of MemKeys.LOCAL, if that makes sense.

Since you are dealing with markets, I'd say MemKeys.MARKET and MemKeys.SOURCE_MARKET will be relevant to what you are doing. LOCAL seems to store the data either without a prefix at all or under "entity".

*EDIT* Oh, also you don't have to get the memoryMap from params. If you are overriding the execute method the memory map should be available without passing it in as a parameter.

Code
    @Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 08, 2021, 02:58:56 PM
Well I hate to say it, but even when I replace the memory.set("$SDE_demandData", demandData, 0); with memoryMap.get(MemKeys.MARKET).set("$SDE_demandData", demandData, 0);, it still doesn't show up, not in the output nor memdump. So I'm really confused as to why this isn't working, especially when, via assigning the MARKET memkey to $SDE_demandDataValue, it *still* works and even reassigns to MARKET.

Also, not sure what you mean on the last part; I don't have to use params, the variable, object, whatever? As in, get(0).getString(memoryMap); would work?

EDIT: ok, for SOME reason, int commoditySurplus = dialog.getInteractionTarget().getMarket().getCommodityData(SUPPLIES).getExcessQuantity();,                 memoryMap.get(MemKeys.MARKET).set("$SDE_commoditySurplus", commoditySurplus, 0);, and then using that in my dialogue works. But not Deficit. Why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 08, 2021, 03:33:21 PM
Well I hate to say it, but even when I replace the memory.set("$SDE_demandData", demandData, 0); with memoryMap.get(MemKeys.MARKET).set("$SDE_demandData", demandData, 0);, it still doesn't show up, not in the output nor memdump. So I'm really confused as to why this isn't working, especially when, via assigning the MARKET memkey to $SDE_demandDataValue, it *still* works and even reassigns to MARKET.

Also, not sure what you mean on the last part; I don't have to use params, the variable, object, whatever? As in, get(0).getString(memoryMap); would work?

EDIT: ok, for SOME reason, int commoditySurplus = dialog.getInteractionTarget().getMarket().getCommodityData(SUPPLIES).getExcessQuantity();,                 memoryMap.get(MemKeys.MARKET).set("$SDE_commoditySurplus", commoditySurplus, 0);, and then using that in my dialogue works. But not Deficit. Why?

Ah I think I misunderstood what you were doing at first. So you can ignore that part about the params. What I was saying is that you can use the memoryMap that comes from overriding execute in a rule command to store mem variables. That's how I do it anyway.

But I've noticed that memory variables can be a little tricky to get to work sometimes as you've no doubt also noticed. Sometimes it takes a lot of trial and error.

For what you are doing, if MARKET doesn't work I'd put the data under LOCAL instead and see if it can be done that way. The only issue is that could attach the data to the InteractionTargetAPI or something like that so it could change from person to person if the market condition changed from say buying the surplus then talking to someone else. Not sure if that would be a problem for you are not.

Also it is worth noting that there needs to be a rule call between setting something into memory and calling it through a variable or code. It can't be done within the same rule.

It could also be that the variable in rules would have to change to $market.SDE_demandData but if its not showing up in a memdump then that probably wouldn't work anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 08, 2021, 04:38:23 PM
Putting it under LOCAL doesn't help either... I'll try all the data flags.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2021, 05:02:06 PM
I think this should work (https://mega.nz/file/ScEEjLIa#XkZf0mDdxTpGbKXp8p2F2O1VnsaCB_dYsPeqUMP3JGk), the mission is called "modules vs no modules"

Thank you! Gave this a try, and, hmm - I'm seeing the Meduas-with-modules win (though it looks very even/symmetrical). So it's likely that whatever issue you're seeing now is fixed for the next release, which, good news.


Putting it under LOCAL doesn't help either... I'll try all the data flags.

Try changing the variable names. IIRC there are some cases where it could be finicky if one variable starts with the same exact string that's the name of another variable. Not sure this is actually a problem here, but it'd be good to rule that out just in case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 08, 2021, 05:07:10 PM
I think this should work (https://mega.nz/file/ScEEjLIa#XkZf0mDdxTpGbKXp8p2F2O1VnsaCB_dYsPeqUMP3JGk), the mission is called "modules vs no modules"

Thank you! Gave this a try, and, hmm - I'm seeing the Meduas-with-modules win (though it looks very even/symmetrical). So it's likely that whatever issue you're seeing now is fixed for the next release, which, good news.


Putting it under LOCAL doesn't help either... I'll try all the data flags.

Try changing the variable names. IIRC there are some cases where it could be finicky if one variable starts with the same exact string that's the name of another variable. Not sure this is actually a problem here, but it'd be good to rule that out just in case.

...I added a line of code that logged it... and... it works now. It just gets added to the log. That's all that I did.

Added public static Logger log = Global.getLogger(SDE_determineStealableCommodities.class); above execute in the value/variable storage section (what do people call the place you store your class variables?), and log.info("deficit is " + demandDeficit); to
Spoiler
if (command.equals("marketExploitableByInsider")) {
            if (marketStab <= 5) //placeholder value for debugging {
                log.info("deficit is " + demandDeficit);
                memoryMap.get(MemKeys.MARKET).set("$SDE_demandDeficit", demandDeficit, 0);
                memoryMap.get(MemKeys.MARKET).set("$SDE_commoditySurplus", commoditySurplus, 0);
                memoryMap.get(MemKeys.MARKET).set("$SDE_demandDataValue", demandDataValue, 0);
            return true;
            }
[close]


it doesnt even look like it logs it when i look in the log
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 08, 2021, 05:11:57 PM
What does your rules look like? I'd need more info to give more suggestions. Maybe a screenshot of the memdump too.

For me, this works:

Code
tokenChanceValue = memoryMap.get(MemKeys.FACTION).getFloat(TOKEN_BRIBE_VALUE_MEMKEY);

Where TOKEN_BRIBE_VALUE_MEMKEY = "$c:tokenBribeChance_ChangeByValue" (Which is populated by:"tokenBribeChance_ChangeByValue":10.0, - in the custom section of the faction file.)

And, this works as a condition in rules:

$AidRequest_fireChance <= 150

Which is populated through:

Code
memoryMap.get(MemKeys.LOCAL).set("$AidRequest_fireChance", fireChance, 1);

 - In CommodityRequestCalc - which is a script called in the rule prior to the one that has the condition check. fireChance is an int that is defined and manipulated in the script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 08, 2021, 05:20:54 PM
Oh my GOD I feel like such an idiot, I REVERSED MY MORE OR EQUAL TO OPERATOR WHICH WAS BREAKING IT AAAAAAAAAAAAGH!!!!!!!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 08, 2021, 05:25:44 PM
Nice! Glad you got it working. :)

(And no worries I do that kind of thing all the time, hehe.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 08, 2021, 10:05:56 PM
I think this should work (https://mega.nz/file/ScEEjLIa#XkZf0mDdxTpGbKXp8p2F2O1VnsaCB_dYsPeqUMP3JGk), the mission is called "modules vs no modules"

Thank you! Gave this a try, and, hmm - I'm seeing the Meduas-with-modules win (though it looks very even/symmetrical). So it's likely that whatever issue you're seeing now is fixed for the next release, which, good news.


Thats good to hear! Thank you for checking for me  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on February 09, 2021, 06:48:51 AM
Does anyone know of a good way to get the current level of pirate activity affecting a market/the status of luddic path cells, specifically, if they're active/inactive/disrupted?

I'm trying this
Spoiler
PirateBaseIntel originTierPirate = new PirateBaseIntel(system, factionId, tier);
        String getPirateBaseTier = String.valueOf(originTierPirate.getTier());
[close]
but I don't know if it will work.

I could also use some help on checking to see if a market's specific industry is disrupted or not, or better yet, checking to see if any markets with a specific *tag* (specifically HEAVY_INDUSTRY) are disrupted.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 09, 2021, 11:39:57 AM
Is there an up to date guide for making Factions? I only found this one (https://fractalsoftworks.com/forum/index.php?topic=1282.0) from 2012.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 10, 2021, 07:51:22 AM
Does anyone know of a good way to get the current level of pirate activity affecting a market/the status of luddic path cells, specifically, if they're active/inactive/disrupted?

Loop over the market's conditions and use the conditions' plugins to find the info you need.

Code: java
// First get the levels of activity
PirateBaseIntel.PirateBaseTier pirateTier = null; // use the enum, there's no reason to get it as a string
String pathActivity = ""; // using the name of the condition because there is nothing else

for (MarketConditionAPI cond : market.getConditions()) {
    if (cond.getPlugin() instanceof PirateActivity) {
        PirateActivity plugin = (PirateActivity) cond.getPlugin();

        pirateTier = plugin.getIntel().getTier();
    }

    if (cond.getPlugin() instanceof LuddicPathCells) {
        LuddicPathCells plugin = (LuddicPathCells) cond.getPlugin();

        pathActivity = plugin.getName();
    }
}


// Handle pirate activity
if (pirateTier != null) {
    // switch on tier and do your stuff, or use several if cases
} else {
    // if it is still null, then there is no pirate activity
}


// Handle Path cells - I got the names from LuddicPathCellsIntel, which is where the LuddicPathCells plugin gets them
if (pathActivity.isEmpty()) {} // no path activity
if (pathActivity.equals("Luddic Path Cells - Sleeper")) {}
if (pathActivity.equals("Luddic Path Cells - Active")) {}
if (pathActivity.equals("Luddic Path Cells - Disrupted")) {}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 12, 2021, 04:58:45 PM
i think there's some weirdness going on with mirv configs
or, more likely, i'm just dumb
(https://i.imgur.com/BYLlHTF.png)
there's these parameters
spreadSpeed, which controls at which velocitysubmunitions are launched
projectileRange, which controls how far submunitions will travel if they are not missile-type projectiles
and the spreadSpeedRange, which is a complete blackbox mystery to me so far. by the name i'd guess it should introduce randomness into submunition launch velocity, which it does. but it also throws spread range completely off the rocker, and i can't seem to figure out in which way.
people on discord say that maybe it just fails to recalculate projectile life time.

so, can i get a clarification on how exactly is it supposed to work, and how much of it is intended behavior?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 12, 2021, 06:50:21 PM
There were some bugs with it; I forget the details. Search the patch notes for "spreadSpeedRange" - it'll have some info but probably not enough to make it make complete sense. The good news is it should all work properly in the next release.

And, yes, in theory the speed of the projectile is:
spreadSpeed + (random number between 0 and 1) * spreadSpeedRange

("Range" in the mathematical sense of "distance from this number to that number", not like weapon range etc.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 12, 2021, 06:54:30 PM
There were some bugs with it; I forget the details. Search the patch notes for "spreadSpeedRange" - it'll have some info but probably not enough to make it make complete sense. The good news is it should all work properly in the next release.
ahhh
thanks for clarification
should've looked in patchnotes first tbh
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 12, 2021, 07:16:19 PM
speaking of missiles
Quote
Fixed issue causing ships with only missile weapons to close in to point-blank range regardless of weapon range
is there a way to induce this kind of behavior deliberately, in non-missile weapons? or will there be in the next version, since this is being fixed?
as in, make AI, both using and opposing said weapon, to ignore it's range when approaching or kiting an enemy
for the purpose of making LRM-equivalent weapons in other than missile slots
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 17, 2021, 02:17:29 PM
Sorry that im asking again, but...
is there an up to date guide for making Factions and Systems?
I am not good at coding or reverse-engineering lol
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 17, 2021, 03:16:22 PM
Sorry that im asking again, but...
is there an up to date guide for making Factions and Systems?
I am not good at coding or reverse-engineering lol

For a star system, yes - see this thread (http://fractalsoftworks.com/forum/index.php?topic=14905.0). It has a lot of important modding info on how to set up any mod as well. Basic things like the mod plugin, how to generate your system, etc.

For a faction itself? I don't believe so. For a brief summary you will need:

1) Faction file with your faction ID and the factions' details. These files are found under data/world/factions. Your faction ID must also be added to the factions.csv spreadsheet in your mod which will merge with vanilla's spreadsheet.

2) If you aren't adding markets with code, you can use the economy JSON files and either merge with existing systems (not recommended for mod compatibility afaik) or once you create your own you can designate a JSON file with your custom market info and give it resources, industries, conditions, etc. These files can be found under data/campaign/econ and remember to add any systems you create to the starmap JSON file under data/campaign. This will determine at what location the system will spawn.

That should get you started. My advice is to make your faction similar to an existing one at first, and then slowly make changes to see how things work. Start with making the star system and getting that to spawn in your mod before even bothering with faction specifics. Everything builds on top of that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 17, 2021, 03:44:17 PM
No documentation that I can find on this, so what does ShipAPI.isDefenseDisabled() mean? Is this when a ship is overloading?

If I'm creating a custom ship system AI, do I need to check for that in the first place?


The curse of posting here literally a second before I answer my own question is potent...

Nvm, I found it under FluxTrackerAPI. So I assume the above means something else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2021, 04:10:58 PM
speaking of missiles
Quote
Fixed issue causing ships with only missile weapons to close in to point-blank range regardless of weapon range
is there a way to induce this kind of behavior deliberately, in non-missile weapons? or will there be in the next version, since this is being fixed?
as in, make AI, both using and opposing said weapon, to ignore it's range when approaching or kiting an enemy
for the purpose of making LRM-equivalent weapons in other than missile slots

Hmm, I don't *think* so. You could probably set the DO_NOT_BACK_OFF flag and do something with that, but... it gets into custom AI territory pretty quickly.

No documentation that I can find on this, so what does ShipAPI.isDefenseDisabled() mean? Is this when a ship is overloading?

If I'm creating a custom ship system AI, do I need to check for that in the first place?


The curse of posting here literally a second before I answer my own question is potent...

Nvm, I found it under FluxTrackerAPI. So I assume the above means something else.

It returns true when the ship's defenses - that is, phase cloak or shields - is disabled due to the ship having reached 0 CR.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 17, 2021, 04:21:01 PM
It returns true when the ship's defenses - that is, phase cloak or shields - is disabled due to the ship having reached 0 CR.

Ah ok that makes sense. Thanks for the answer. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Finnfinn on February 18, 2021, 05:56:54 AM
Howdy folks, new guy here! I'd like to play around with modding after my exams and would like your opinion on a little something.

I love Egosoft's X series of space sims. It would make for some great modding material (ship mods, faction mods, maybe even more) and the ship classes are easily mapped to their Starsector equivalents... except for M5 (scouting vessels), M4/M4+ (interceptors), M3/M3+ (fighters) and M8 (bombers).
I know that by name, these are prime candidates for wings to stick on carriers and I'd agree with some of them, especially with the scouts.
However, many of them have an impressive amount of customizability in terms of hardpoints, with the M3 Argon Nova offering 8 frontal hardpoints, one rear slot suitable for point defense and a missile launcher that can fire missiles suitable for inflicting considerable damage even to larger ships. They are more equivalent to Starsector frigates in terms of customizability and agility, making them simple wings wouldn't do them justice at all.

What do you think? Can one slap that amount of ordnance on wings without breaking the feel of the game in half? Will I need a major ship class overhaul? Or should I just dumb those classes down to a wide variety of fighters and call it a day? I hope I provided enough information, if something needs clarification go ahead and ask.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on February 18, 2021, 09:11:30 AM
X3 and Starsector are different games following different rules. If you want to make a mod based on an existing game, interpretation is key: where do you want to stick to the original IP, where can you take liberties because doesn't really matter, where does the gameplay must go first. The closer you try to stay from the original IP, the less playable your mod will be by virtue of not following the proper set of rules.

Here is a thread about common modding guidelines (http://fractalsoftworks.com/forum/index.php?topic=9052.0) that when followed produce a seamless experience with Vanilla. You can then make your own informed decisions about where and how much to deviate from them in your mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 18, 2021, 01:38:22 PM
When setting a ShipwideAIFlag, is duration in frames or in seconds?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 18, 2021, 02:46:48 PM
Seconds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 18, 2021, 03:45:51 PM
Thanks. Got that part working as intended.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BeyondTheHorizon on February 19, 2021, 03:20:14 AM
Is there any way to get shipsystem's type? I want to determine if it's "TELEPORTER" type.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 20, 2021, 12:37:46 PM
Does:

Code
ShipwideAIFlags.setFlag(ShipwideAIFlags.AIFlags.DO_NOT_VENT, amount);

 - prevent the ship from venting in all situations or just some? (amount is the same amount between each time the script runs so theoretically it should always be on under that situation.)

I set that flag whenever hard flux is above 50% and there are still times where the AI will vent when surrounded and above 50% hard flux - leading to the instant death of the ship when it could have survived had it not done so.

Is there any way to absolutely prevent the AI from venting?
Or, alternatively, is there a way to manually cancel a vent in progress so that a ship system can activate?

*Edit* Ah, wait, strike the first part. I forgot that the script won't run if the system's ammo is zero or its on cooldown so that's why that is happening. I will have to set it even during those scenarios and hope that won't impact performance much.

Second question still stands, however, as that would actually be a better solution for this use case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 20, 2021, 04:56:38 PM
Hey so i followed this tutorial (https://bit.ly/3dz0874) (i took his stuff on github) and got this error

Quote
16655 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.McrnPlugin'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.McrnPlugin' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on February 21, 2021, 01:23:52 PM
Hey so i followed this tutorial (https://bit.ly/3dz0874) (i took his stuff on github) and got this error

Quote
16655 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.McrnPlugin'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.McrnPlugin' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more

You should post your code, it'll be easier to help.

That error is saying that you need a class called "McrnPlugin" in your file. If it's called anything else, it'll crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 21, 2021, 03:22:27 PM
Hey so i followed this tutorial (https://bit.ly/3dz0874) (i took his stuff on github) and got this error

Quote
16655 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.McrnPlugin'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.McrnPlugin' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more

You should post your code, it'll be easier to help.

That error is saying that you need a class called "McrnPlugin" in your file. If it's called anything else, it'll crash.

Not sure if this is relevant for your situation but just in case:

If the plugin is an EveryFrameCombatPlugin, then I believe it must also be defined in your settings file as well. Example:

Code
	# this section is meant to eventually replace the "magical" data/scripts/plugins directory
# add EveryFrameCombatPlugins here (with unique keys)
"plugins":{
"AO_CombatEnginePlugin":"data.scripts.plugins.AO_CombatEnginePlugin",
},

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: godream on February 22, 2021, 12:00:43 AM
Hi all, just started modding some basics here and added 2 simple ships (frigate and destroyer) and they seem to work fine (I followed the basic guide on the wiki and the forums here...just 2 hulls with their sprites/variants) I have replace a the player ship and a handful of AI ships in a mission file to test them in combat etc and I constantly seem to get a null error crash at some point in the battle.

I have a 64-bit windows system with 8GB of Ram and a GTX 1060 8GB vram card...no additional mods on a clean install....just curious what might be causing this? it's just a handful of ships in the mission so I don't think it's a memory leak...I'd really appreciate any insight into what might be causing this :)

-Note I don't seem able to post using the code or spoiler commands to put the dozen or so lines of error code so as a workaround I've taken a screengrab and stuck it on imgur :/

here is the last few dozen lines of the log file that seem to reference the crash:
https://imgur.com/a/4NHIZse (https://imgur.com/a/4NHIZse)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mendonca on February 22, 2021, 12:16:13 AM
Hi, that might be an issue with your ships bounds (searching up 'Tesselator' on the forums shows a similar looking error here: LINK (http://fractalsoftworks.com/forum/index.php?topic=17433.msg284992#msg284992))

Does that sound likely? Do you know if you have set up the bounds for your ship files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: godream on February 22, 2021, 01:22:57 AM
oh wow yes you're right for some reason I must have removed the bounds at some point while troubleshooting....that did the trick! thanks a ton :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on February 22, 2021, 06:04:08 AM
Hey so i followed this tutorial (https://bit.ly/3dz0874) (i took his stuff on github) and got this error

Quote
16655 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.McrnPlugin'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.McrnPlugin' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more

You should post your code, it'll be easier to help.

That error is saying that you need a class called "McrnPlugin" in your file. If it's called anything else, it'll crash.


yeah the class was still called sth else lol thanks


edit: so now that i finally managed to get my system running how do i prevent the hyperspace cancer from spawning on my system?
edit2: so i got another error

Code
16742 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/McrnPlugin.java', Line 95, Column 27: Cannot determine simple type name "EconomyAPI"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/McrnPlugin.java', Line 95, Column 27: Cannot determine simple type name "EconomyAPI"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5398)
at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5207)
at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5188)
at org.codehaus.janino.UnitCompiler.access$12600(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$16.visitReferenceType(UnitCompiler.java:5119)
at org.codehaus.janino.Java$ReferenceType.accept(Java.java:2880)
at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
at org.codehaus.janino.UnitCompiler.getLocalVariable(UnitCompiler.java:1877)
at org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:2552)
at org.codehaus.janino.UnitCompiler.access$4300(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:2434)
at org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:2508)
at org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:2437)
at org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:2395)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2250)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
... 5 more
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Plasmatic on February 26, 2021, 11:40:08 AM
Nevermind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 26, 2021, 12:57:03 PM
edit2: so i got another error

It looks like you aren't importing the EconomyAPI class in your class.

Sorry if I am assuming too much, but this leads me to believe you are not using an IDE to compile your code since it generally wouldn't compile the code in the first place without an import statement. I would highly recommend setting one up if possible. It will save you a lot of time and effort dealing with things like this. It points out syntax errors and lets you know when variables you create aren't used, when objects could potentially cause nullpointers, etc. I use IntelliJ. There is a tutorial (https://fractalsoftworks.com/forum/index.php?topic=10057.0) to set that up though it is a little dated by now.

For this specific case, it would have made your EconomyAPI object unusable and when you mouse over it the IDE tells you that you need the import statement. You can then hold alt + left click and select "import class" and it would add the statement for you without you even having to scroll up.

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

*EDIT*
Ahh, ok I don't think the IntervalUtil being static was the factor. The issue was actually because I was running 2+ IntervalUtils and so they had to elapse simultaneously for the logic to work properly. I just need to preserve the isElapsed boolean in another variable and run the logic when that variable returns true.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AcaMetis on February 27, 2021, 01:54:16 AM
Can capital ships not have the Ill-Advised Modifications D-Mod? If I add it to the builtInMods list of a capital ship it just doesn't show up ingame, with no message or warning telling me as much.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vexant on February 27, 2021, 06:54:35 AM
Hi Guys,
I am very new to modding and any kind of coding. I’ve tried to follow tutorials and watch videos, even did a few online courses to learn java but I feel like ive gone backwards and almost ready to give up. So far I have successfully created a very overpowered (on accident) ship, created a star system from the tutorial. So yes, I can follow tutorial instructions :P. BUT as soon as I try to experiment with anything I can’t seem to get it to work.  Ive spent about 15 hours now trying to change the texture on my star (in my new star system) firstly I tried to add a whole new star into planets.json and ids/startypes but that was a big fail. So then I tried to change a blue giants texture. Failed at that.. then tried to change my planets texture… you guessed it.. fail.. so im here to have one last ditch effort or im gunna quit and just play the game instead of spending countless hours trying and failing to mod.

so here is what I have
//Bla bla bla import this and that ect…

    @Override
    public void onNewGame() {   
      SectorAPI sector = Global.getSector();
      StarSystemAPI system = sector.createStarSystem("Eureka");
system.setBackgroundTextureFilename("graphics/mas/backgrounds/longwall_background.jpg");
PlanetAPI star = system.initStar(   "eureka","star_blue_giant",500, -400, -9400, 250);
system.setLightColor(new Color(201, 174, 123, 60));
PlanetAPI tfMuck = system.addPlanet("muck", star, "Muck", "gas_giant", 0, 229, 1000, 20);
Misc.initConditionMarket(tfMuck);
//Etc…….

where and how can I change the stars texture and the planets texture, any help would be great. Also is there a file that lists all the different attributes I can alter?

thanx, Vex
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vexant on February 27, 2021, 06:54:50 AM
Well it took 3 days to find but finally success.. thank God for unknown skies.. :) .. still havnt worked out planet skins yet but im hoping US is my saviour once again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 27, 2021, 10:59:10 AM
What is "com.fs.starfarer.combat.entities.MovingRay"?



I have a ship system that flips hostile missiles to the ships side when used. It works for vanilla but some mods use custom missile AI that makes them continue to fruitlessly try to blow up the ships that are now on the same "side" as it.

So I thought a clever solution would be to just delete the original missile and spawn a new one in its place. Works for the most part, but during testing a got a crash

java.lang.ClassCastException: com.fs.starfarer.combat.entities.MovingRay cannot be cast to com.fs.starfarer.api.combat.MissileAPI


Is there anything I can do to circumvent this? I'm not sure what the root is since im specifically checking for missiles, and even checking again to see if m is an instance of MissileAPI does not seem to prevent it
Here is the code snippet in question.

Code
	for (MissileAPI m : CombatUtils.getMissilesWithinRange(ship.getLocation(), 600f))
{
if(m.getSource().getOwner() == ship.getOwner()) continue;

if(m.getSource().getOwner() != ship.getOwner())
{
if(m.isGuided())
{
                                                /*crash here*/
                                      MissileAPI newM = (MissileAPI)engine.spawnProjectile(ship,m.getWeapon(),m.getWeapon().getId(),m.getLocation(),m.getFacing(),m.getVelocity());
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2021, 08:08:07 PM
What is "com.fs.starfarer.combat.entities.MovingRay"?

It's a projectile spawned by a weapon whose shot type is BALLISTIC_AS_BEAM or BEAM - iirc Vulcans, Pulse Laser, that sort of thing. So this means the weapon you're firing off here isn't actually spawning a missile. Which is weird because you're using the missile's weapon to spawn a new missile so you'd expect the new shot to also be a missile. Offhand I'm not sure what the issue is there.

(Also, this isn't an NPE - an NPE is a NullPointerException. If you're indeed seeing an NPE, then the cause of that would be different than the bolded part in your post.)


@vexant: if you're looking to change planet textures, you might have a look at data/config/planets.json; creating a new planet/star type might be easier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 27, 2021, 08:57:41 PM
Yeah, you are right. I edited that bit of my post but not fast enough, haha. It indeed was not an NPE but the cast exception I bolded.

I'm gonna guess its just a mod issue. If I just cast the missiles to projectiles, it also works, so I'll just do that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on February 27, 2021, 09:33:09 PM
I have a ship system that flips hostile missiles to the ships side when used. It works for vanilla but some mods use custom missile AI that makes them continue to fruitlessly try to blow up the ships that are now on the same "side" as it.

So I thought a clever solution would be to just delete the original missile and spawn a new one in its place. Works for the most part, but during testing a got a crash
While this is not the question you asked Shoi? I would *strongly* recommend against remove and replace to do what you are doing. That will have innumerable issues some of which can be solved easily, some with great difficulty, and some not at all. Not going to list off specifically what is what as there is a much more correct way of fixing your issue and I don't want to effort post right now anyways...
- The problem you found
- Missile hitpoints
- Missile engine state
- Missile engine lifetime
- Missile fuze time (especially custom scripted ones)
- Missile EMP arc resistance
- Continuously spawned submunitions on some mod missiles
- And a bunch of other things...
Code: java
                    if (thisProj instanceof MissileAPI)
                    {
                        MissileAPI asMissile = (MissileAPI) thisProj;
                        exigency_MissileJammerPlugin.unhackMissile(asMissile);

                        if (asMissile.getMissileAI() instanceof GuidedMissileAI)
                        {
                            ((GuidedMissileAI) asMissile.getMissileAI()).setTarget(null);
                        }
                    }
Do something like that instead, and then the missile will retarget as you want it to. Source? Heh, legends of my past insanity...
(https://i.imgur.com/1Effrtz.gif)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 28, 2021, 07:43:39 AM
How do hullmods like Makeshift Shield Generator and Converted Hangar remove their effects?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2021, 09:18:13 AM
How do hullmods like Makeshift Shield Generator and Converted Hangar remove their effects?

Hullmods generally speaking don't remove their effects - the ship / ship stats are created anew and the installed hullmods are applied.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 28, 2021, 10:34:52 AM
Hullmods generally speaking don't remove their effects - the ship / ship stats are created anew and the installed hullmods are applied.

Oh, right. Forgot. I was trying to make a hullmod that changes built-in wings on some ships, so I had to find a way to change the variant back when the hullmod is removed. Was having some trouble, but I seem to have it working now.

Ended up moving the logic to a built-in hullmod on the relevant ships and checking if the switching hullmod was installed from there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2021, 11:30:06 AM
Ah, yeah, that makes sense - built-in hullmods are a good way to go with this sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on March 01, 2021, 06:46:40 AM
edit2: so i got another error

It looks like you aren't importing the EconomyAPI class in your class.

Sorry if I am assuming too much, but this leads me to believe you are not using an IDE to compile your code since it generally wouldn't compile the code in the first place without an import statement. I would highly recommend setting one up if possible. It will save you a lot of time and effort dealing with things like this. It points out syntax errors and lets you know when variables you create aren't used, when objects could potentially cause nullpointers, etc. I use IntelliJ. There is a tutorial (https://fractalsoftworks.com/forum/index.php?topic=10057.0) to set that up though it is a little dated by now.

For this specific case, it would have made your EconomyAPI object unusable and when you mouse over it the IDE tells you that you need the import statement. You can then hold alt + left click and select "import class" and it would add the statement for you without you even having to scroll up.

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

*EDIT*
Ahh, ok I don't think the IntervalUtil being static was the factor. The issue was actually because I was running 2+ IntervalUtils and so they had to elapse simultaneously for the logic to work properly. I just need to preserve the isElapsed boolean in another variable and run the logic when that variable returns true.

yeah i use intellj too but i am not well versed in codeing and stuff. anyway i figured out that i didnt import the economyapi. it all works now (althought how do you slow down the orbit time of planet?) and i tried to add the planet to my faction but i am getting an compiling error.
Quote
16523 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
java.lang.RuntimeException: Error compiling [data.scripts.McrnPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.McrnPlugin'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/McrnPlugin.java', Line 34, Column 27: '(' expected instead of '.'
   at org.codehaus.janino.Parser.compileException(Parser.java:3125)
   at org.codehaus.janino.Parser.read(Parser.java:2822)
   at org.codehaus.janino.Parser.parseFormalParameters(Parser.java:999)
   at org.codehaus.janino.Parser.parseMethodDeclarationRest(Parser.java:916)
   at org.codehaus.janino.Parser.parseClassBodyDeclaration(Parser.java:565)
   at org.codehaus.janino.Parser.parseClassBody(Parser.java:515)
   at org.codehaus.janino.Parser.parseClassDeclarationRest(Parser.java:481)
   at org.codehaus.janino.Parser.parsePackageMemberTypeDeclaration(Parser.java:269)
   at org.codehaus.janino.Parser.parseCompilationUnit(Parser.java:168)
   at org.codehaus.janino.JavaSourceIClassLoader.findCompilationUnit(JavaSourceIClassLoader.java:203)
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:146)
   ... 7 more

i add this
Code
public class McrnPlugin implements SectorGeneratorPlugin {

public abstract void com.fs.starfarer.api.campaign.SectorGeneratorPlugin.generate(com.fs.starfarer.api.campaign.SectorAPI){
FactionAPI mcrn = sector.getFaction("mcrn");
}}
to my code because i assume (from looking at other mods) thats how you add a faction
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bad_Idea on March 01, 2021, 11:50:26 PM
So i've been working on a fun little mod that does a fair bit of stuff with hyperspace clouds. Whilst the general function of the mod works just fine i'm having an annoying issue: whenever you use nebulaeditor tiles[ ][ ] to change a cell into a hyperspace cloud it's always given the same sprite.

https://i.imgur.com/3dKpkFn.jpg (https://i.imgur.com/3dKpkFn.jpg)
As seen in this image the clouds are all the same sprite, just rotated at random. If there's no way of directly affecting this that'd be fine (mod itself does work, after all), but it'd be really nice if there was!
possibly solved, didn't realize the tile value probably corresponds to which cloud is spawned
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 03, 2021, 08:04:05 AM

While this is not the question you asked Shoi? I would *strongly* recommend against remove and replace to do what you are doing. That will have innumerable issues some of which can be solved easily, some with great difficulty, and some not at all. Not going to list off specifically what is what as there is a much more correct way of fixing your issue and I don't want to effort post right now anyways...
- The problem you found
- Missile hitpoints
- Missile engine state
- Missile engine lifetime
- Missile fuze time (especially custom scripted ones)
- Missile EMP arc resistance
- Continuously spawned submunitions on some mod missiles
- And a bunch of other things...
Code: java
                    if (thisProj instanceof MissileAPI)
                    {
                        MissileAPI asMissile = (MissileAPI) thisProj;
                        exigency_MissileJammerPlugin.unhackMissile(asMissile);

                        if (asMissile.getMissileAI() instanceof GuidedMissileAI)
                        {
                            ((GuidedMissileAI) asMissile.getMissileAI()).setTarget(null);
                        }
                    }
Do something like that instead, and then the missile will retarget as you want it to. Source? Heh, legends of my past insanity...

This was EXACTLY what I was trying to figure out how to do! Thanks a ton Meso!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on March 05, 2021, 11:08:56 AM
is it possible to modify "TextureScrollSpeed" from a Beam or Weapon API
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2021, 11:13:55 AM
is it possible to modify "TextureScrollSpeed" from a Beam or Weapon API

I don't think so - it's a property of the beam spec, not an individual weapon.

You could in theory do weaponensureClonedSpec() and then change the spec, but the relevant methods for texture scroll speed are not in WeaponSpecAPI since non-beam weapons don't have it.

(So, basically, this *could* be doable, but currently isn't... sorry!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 10, 2021, 02:26:32 AM
How does ConstellationGen.SpringSystem actually work?

More specific form of the question
So, Nexerelin's random sector uses a modified StarSystemGenerator to create a single large constellation in the middle of the map during the new game sector generation.
Nex and other mods can also add manually defined and placed star systems at this point; in the screenshot below, they're the Sitnalta nebula to the left and Styx and Antioch star systems to the right.
(click to enlarge)
(https://i.imgur.com/VPVjAqN.png)

Now as you can see, one of the procgen star systems is overlapping Sitnalta. So I figure, I can try to the list of systems passed to ConstellationGen.doConstellationLayout, the idea being that the "springs" will gently push the systems apart.

Instead it completely changed the shape of the constellation, with Sitnalta pushed to the bottom (new sector generated with the same seed):

(https://i.imgur.com/xC9Jx4V.png)

Given that I don't want Sitnalta to drift too far from the approximate center of the map (due to its intended role as a trade stop in the middle of the sector), is there a better way to avoid the overlap issue?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2021, 11:17:41 AM
I'd suggest using the SectorProcGen.blotOut() method. IIRC stuff marked with that will not get constellation placed there during the rest of procgen, if you do it early enough. E.G. if you look at SectorProcGen.generate(), it does blotOut() for the hand-made core system areas (and a few other places) before proceeding with procgen.

(The SpringSystem stuff, as you've found, will radically alter the shape of the constellation. It's only meant to be used on stars within one constellation at a time, though; I'm guessing you added more stars than that? I'm not sure why it'd move Sitnalta so far away otherwise.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on March 10, 2021, 11:51:04 AM
<WeaponAPI>.getSpec().getTurretFireOffsets().get(0)

on a weapon with a single offset, returns randomly one of four points on a slowly rotating circle whose radius is equal to the actual turretoffset length. I'am a bit confused as to why.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2021, 12:02:49 PM
My guess is something is writing to that weapon's turret offset array. This could be from another weapon; weapon specs are shared across all weapons unless you call WeaponAPI.ensureClonedSpec() for that weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 11, 2021, 01:22:55 PM
What's the difference between getFluxLevel() and getCurrFlux()?

I want to say one of them returns a float between 0-1, but im not sure if im thinking of something else.

edit: it says in the api, i am a derp
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 12, 2021, 06:14:38 AM
I'm looking to check if a Hullmod is legal to apply to a ShipVariant.
Is there a way to even do that?

I can't find an option to create a ShipAPI object from a ShipVariantAPI obj. to use HullModSpecAPI.getEffect().isApplicableToShip(ShipAPI) since ShipAPI does not exist out of combat.

I'd appreciate the help.
Thank you -
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 12, 2021, 11:47:44 AM
It's not possible, yeah.

Consider stuff like Omni Shield Emitter - it doesn't apply to a Hound, unless the Hound also has Makeshift Shield Generator installed. But the effect of MSG only happens when it's applied to a ship; there's no way to tell from the variant whether it adds a shield or not. Other interactions of this general nature are possible, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 12, 2021, 12:03:38 PM
Makes sense, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on March 13, 2021, 02:36:03 PM
What determines a ship's contrail on the campaign map?

Is there a way for a ship with all angled engines (non 180 degrees) to have a normal 180 degree contrail?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kakroom on March 13, 2021, 06:57:56 PM
I'm looking for the ground_support .java in starsector-core\data\hullmods. I'm trying to make a very small mod, with one hullmod that you can choose to apply to a carrier/s that gives your fleet a bonus to raid effectiveness based on its size, because I want to pretend I'm sending in my fighters to bomb stuff. I know very, very little about scripting, so I was hoping to learn some from Ground Support Package's script since that's the only other vanilla one that affects raid strength... but I can't find it. Is it located somewhere else?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2021, 07:08:05 PM
What determines a ship's contrail on the campaign map?

Is there a way for a ship with all angled engines (non 180 degrees) to have a normal 180 degree contrail?

It's an algorithmically simplified version of the ship's normal contrails. Fairly sure the answer to the second question is "no".

I'm looking for the ground_support .java in starsector-core\data\hullmods. I'm trying to make a very small mod, with one hullmod that you can choose to apply to a carrier/s that gives your fleet a bonus to raid effectiveness based on its size, because I want to pretend I'm sending in my fighters to bomb stuff. I know very, very little about scripting, so I was hoping to learn some from Ground Support Package's script since that's the only other vanilla one that affects raid strength... but I can't find it. Is it located somewhere else?

It's compiled into a jar file. The source can be found in the starfarer.api.zip archive. (Note: since it's compiled, changing that code won't change the game. But it can be good for what you're looking for, i.e. an example to start with.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sinosauropteryx on March 13, 2021, 09:16:28 PM
It's an algorithmically simplified version of the ship's normal contrails.
If the ship's engines are symmetrical, shouldn't they simplify into a 180 degree contrail? Why bias one side or the other?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 14, 2021, 06:31:42 AM
I've got an issue where MarketAPI.getDemandPrice for a commodity X doesn't update after I modify the supply of X using CommodityOnMarketAPI.addTradeModPlus, until I unpause the game for a moment and then return to the dialog where I'm checking the demand price. (Screenshot (https://cdn.discordapp.com/attachments/310517733458706442/820507619910877214/screenshot607.png))
Sometimes the price does go down for one or more iterations, but then reverts to its original value.

Yet when I go to the actual trade screen and try to sell the same commodity, the price does reflect the added supply.

Calling the following doesn't help:
Code: java
market.getCommodityData(commodity).getTradeModPlus().advance(0.001f);
market.getCommodityData(commodity).reapplyEventMod();
market.advance(0.001f);
Is there something else I should be doing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 14, 2021, 10:03:49 AM
If the ship's engines are symmetrical, shouldn't they simplify into a 180 degree contrail? Why bias one side or the other?

... actually, looking at the code, this will be moot in the next release - there'll just be a single trail facing directly back from the ship, regardless of the angles.


I've got an issue where MarketAPI.getDemandPrice for a commodity X doesn't update after I modify the supply of X using CommodityOnMarketAPI.addTradeModPlus, until I unpause the game for a moment and then return to the dialog where I'm checking the demand price. (Screenshot (https://cdn.discordapp.com/attachments/310517733458706442/820507619910877214/screenshot607.png))
Sometimes the price does go down for one or more iterations, but then reverts to its original value.

Yet when I go to the actual trade screen and try to sell the same commodity, the price does reflect the added supply.

Calling the following doesn't help:
Code: java
market.getCommodityData(commodity).getTradeModPlus().advance(0.001f);
market.getCommodityData(commodity).reapplyEventMod();
market.advance(0.001f);
Is there something else I should be doing?

Hmm, I'm not sure. This *seems* like it ought to work, even without anything other than just doing addTradeModPlus() - so I'm probably missing something. Are you able to put together a minimal mod that reproduces the issue?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 15, 2021, 02:45:16 AM
Hmm, I'm not sure. This *seems* like it ought to work, even without anything other than just doing addTradeModPlus() - so I'm probably missing something. Are you able to put together a minimal mod that reproduces the issue?
Test mod (https://www.dropbox.com/s/x1ngxfj3pm4eq5x/testmod.zip?dl=1)
Dock at a market and click "Test commodity supply" in the main menu a bunch of times.

Code: java
	@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
MarketAPI market = dialog.getInteractionTarget().getMarket();
String commodity = params.get(0).getString(memoryMap);
TextPanelAPI text = dialog.getTextPanel();
Color h = Misc.getHighlightColor();
float amountToAdd = 100;

CommodityOnMarketAPI comapi = market.getCommodityData(commodity);

float basePrice = market.getDemandPrice(commodity, amountToAdd, true);
float tradeModQuantity = comapi.getCombinedTradeModQuantity();
text.setFontSmallInsignia();
text.addPara("Demand price of %s %s: %s", h, amountToAdd + "", commodity, Misc.getDGSCredits(basePrice));
text.addPara("Trade mod quanitity: %s", h, tradeModQuantity + "");

comapi.addTradeModPlus("commodity_add_" + Misc.genUID(), amountToAdd, BaseSubmarketPlugin.TRADE_IMPACT_DAYS);
text.addPara("Added %s units of %s to market", h, amountToAdd + "", commodity);

basePrice = market.getDemandPrice(commodity, amountToAdd, true);
tradeModQuantity = comapi.getCombinedTradeModQuantity();
text.addPara("Demand price of %s %s: %s", h, amountToAdd + "", commodity, Misc.getDGSCredits(basePrice));
text.addPara("Trade mod quanitity: %s", h, tradeModQuantity + "");
text.setFontInsignia();
return true;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2021, 10:30:23 AM
Thank you! Hmm - getting this output:
Demand price of 100.0 supplies: 8,439¢
Trade mod quanitity: 0.0
Added 100.0 units of supplies to market
Demand price of 100.0 supplies: 8,356¢
Trade mod quanitity: 100.0
Which is what you'd want to happen, and which isn't happening for you, right? If so: this likely means that this was a bug, fixed for the upcoming release. I vaguely remember touching some related code now (a *while* back) so it's a distinct possibility.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 15, 2021, 05:54:57 PM
The amount usually goes down initially, but then loops around. e.g. with 100 supplies per iteration on Jangala
8,150
7,962
8,150
7,962
8,150

(with 100 food at a time, it seemed to loop every 5 transfers)

If that doesn't happen any longer in dev, then great!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2021, 08:37:39 PM
Aha! It does loop around after a while. Thank you for clarifying, I'll take a closer look tomorrow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 16, 2021, 02:01:53 PM
@Histidine: alright, so what happens is that tradeMod only uses the remainder after dividing it by the econUnit for that particular commodity (in the case of food, it's 2000). The reason is that it assumes that the non-fractional part of tradeMod was applied to the stockpile already, by the economy. So, what you need to do is, after each transaction, call:

Global.getSector().getEconomy().nextStep()

This will apply changes from tradeMod into the stockpile, and the calculation of "actual stockpile for pricing = stockpile plus tradeMod % econUnit" will  be correct.

Note: this method is slow enough that you only want to call it from UI interactions, not from any sort of script running in the background. You can, however, assume that the economy will be nextStep()'ed when the player opens the tradescreen etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 18, 2021, 08:55:15 AM
I've forgotten: which type of object should I use to store a ship from an AI fleet without leaking the fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2021, 09:10:04 AM
Anything non-static and not referenced by anything static. So for example if you have a campaign script, it's fine to hang on to that there. If it's a hullmod, it's not since those exist per-application not per-save-game. If a hullmod needs to store data like this, SectorAPI.getPersistentData() is a possible place to store stuff in. Or a custom script. Or an entity's memory, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 18, 2021, 09:28:20 AM
I mean which kind of ship object. FleetMemberAPI? ShipAPI? The variant id?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2021, 10:22:37 AM
I mean which kind of ship object. FleetMemberAPI? ShipAPI? The variant id?

Not ShipAPI, but the other two should be fine. Well, possibly depending on exactly what you're doing...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 18, 2021, 10:33:31 AM
Moving flagships between fleets and sometimes holding them in stasis when there is no fleet available.

ShipAPI's out, as you said.

FleetMemberAPI has a FleetData reference, so I think it's out.

Just holding the variant id seems risky - the actual variant might not make it across saves.

ShipVariantAPI seems like the best bet. Need to make sure it holds any modules' variants, too.

There aren't any other possible classes are there? My memory is fuzzy today.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2021, 11:47:55 AM
Ah - it's not really "leaking" a fleet, not long-term. Once you add that fleet member to another fleet - and iirc when you remove it from a fleet, also - that reference will be set to the new fleet / null.

ShipVariantAPI would be fine to save too, though - as long as it's not a VariantSource.STOCK, in which case you'd be pointing to a shared common variant... which might be ok unless you change it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 18, 2021, 12:43:20 PM
Okay, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: u2892 on March 20, 2021, 10:04:52 AM
Is there an upper limit on the number of ShipAPI instances that can be present in a single battle?

Is the mass of ships (CombatEntityAPI.getMass(), ShipAPI.getMassWithModules(), etc) in any particular unit? Tons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 20, 2021, 03:29:49 PM
Do the MutableStat.getWeaponDamageMult() methods effect EMP damage?

Is the mass of ships (CombatEntityAPI.getMass(), ShipAPI.getMassWithModules(), etc) in any particular unit? Tons?
It's the number in the mass column of ship_data.csv, but I don't think it's any particular unit, since the game conspicuously avoids discussing measurements of ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 20, 2021, 03:48:32 PM
IIRC weapon damage modifiers apply to both EMP and non-EMP damage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 20, 2021, 10:07:49 PM
@Histidine: alright, so what happens is that tradeMod only uses the remainder after dividing it by the econUnit for that particular commodity (in the case of food, it's 2000). The reason is that it assumes that the non-fractional part of tradeMod was applied to the stockpile already, by the economy. So, what you need to do is, after each transaction, call:

Global.getSector().getEconomy().nextStep()

This will apply changes from tradeMod into the stockpile, and the calculation of "actual stockpile for pricing = stockpile plus tradeMod % econUnit" will  be correct.

Note: this method is slow enough that you only want to call it from UI interactions, not from any sort of script running in the background. You can, however, assume that the economy will be nextStep()'ed when the player opens the tradescreen etc.
Thanks, this worked perfectly. (The modulo explains the price looping around...)

New question:
- Is there a way to tell the game to load specified images, other than specifying them in someplace like settings.json?
- Is there a way to do this other than at runtime? (I don't need to do this, just curious)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2021, 09:22:46 AM
New question:
- Is there a way to tell the game to load specified images, other than specifying them in someplace like settings.json?

There isn't that I can think of. If you've got a specific use case in mind that might help jog my memory, but, right, probably not.

- Is there a way to do this other than at runtime? (I don't need to do this, just curious)

I'm assuming you mean on "on startup"? The game does do this for backgrounds - it uses the same OpenGL texture and replaces the data with a new background when it changes, since those are quite large - but it's done in a very, let's say, not-general-purpose way. One could probably do the same sort of thing by writing the code to replace the texture by loading an image and using SpriteAPI.getTextureId(), but aside from that...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 21, 2021, 06:45:46 PM
I want to make an IntelPlugin that can switch between large desc and small desc. My switching code works, but calling IntelUIAPI.recreateIntelUI() only works correctly when going from large to small. When I try to go from small to large the small desc disappears, but the starmap remains; the large desc does not appear until I click on the intel item on the left again.

Am I doing something wrong (besides switching between small and large mode, lol) or is this a bug?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2021, 08:49:14 PM
Hmm - I want to say it's probably a bug. I seem to recall fixing something related fairly recently, though, so it might just work in the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 22, 2021, 02:26:14 AM
I don't really have a use case for the image loading thing, it's just a bit annoying to have to define the same image path in two different places.


Somewhat different question: Is there a way to make method calls from a pre-compiled script (i.e. in a .jar) to a Janino runtime-compiled script?

I need my code to call the star system generators (e.g. new Galatia().generate(sector);). Right now I'm bundling copies of the generator scripts in my .jar, but someone wants to modify the vanilla scripts and Nexerelin is disregarding their changes.

I tried adding the starsector-core folder as a library in NetBeans, but it still can't find the packages involved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 22, 2021, 09:30:00 AM
I don't really have a use case for the image loading thing, it's just a bit annoying to have to define the same image path in two different places.

Checking a bit more, there's SettingsAPI.loadTexture(). Using that a lot might be dodgy, though, since this stuff would add to the loading time but would not be accounted for in the loading progress bar.

Somewhat different question: Is there a way to make method calls from a pre-compiled script (i.e. in a .jar) to a Janino runtime-compiled script?

I need my code to call the star system generators (e.g. new Galatia().generate(sector);). Right now I'm bundling copies of the generator scripts in my .jar, but someone wants to modify the vanilla scripts and Nexerelin is disregarding their changes.

I tried adding the starsector-core folder as a library in NetBeans, but it still can't find the packages involved.

Hmm - I don't see offhand why it wouldn't work. Might help to see that actual error; at a guess though it's probably some kind of project configuration issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 23, 2021, 10:17:28 AM
I've got a rather strange issue- I have a ship where autofit will not put any weapon with the STRIKE tag in the broadside mounts. This applies both when applying a variant in the fitting screen and for ships that spawn in NPC fleets; variants have STRIKE weapons replaced. It has a hullmod that reduces OP costs for large energy weapons, but I know this is specifically occurring with broadside mounts and not a hullmod issue, because I have a unique variant with the same hullmod and forward-facing mounts that does not have the same issue.

Sprite (https://github.com/theDragn/HTE/blob/main/HTE/graphics/ships/equality.png)
.ship (https://github.com/theDragn/HTE/blob/main/HTE/data/hulls/drg_equality.ship)

EDIT: I've managed to resolve the issue, though I suppose it's still a bug. Turning the weapon arcs forwards (out of a direct 90 degree sideways angle) allows autofit to work fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ItsErisGaming on March 23, 2021, 10:10:56 PM
Is there a custom flag player faction template (Not the flags, only template how to add one) as I am planning to make a custom player flags from Hearts of Iron 4's The New Order?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 24, 2021, 04:12:10 PM
Is there a way in the API to display a mini version of the intel map for an intel using a large description?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: u2892 on March 25, 2021, 08:42:16 AM
I have this code in my EveryFrameCombatPlugin:

Code
  private static boolean done = false;
  private CombatEngineAPI engine; /* initialized in init() method */

  @Override
  public void advance(float amount, List events) {

    if(engine == null || !engine.isInCampaign()) {
      return;
    }
   
    if(engine.isCombatOver() && !done) {
      doSomething();
      done = true;
    }

  }
I want to doSomething() exactly once at the end of a battle, but this only seems to work reliably when the combat auto-ends because only one side is left on the field. When I press Escape and claim victory, doSomething() is often not called at all.

Is this the proper way to check if combat has finished? Searched this thread and found engine.isEnemyInFullRetreat() as an option, but it doesn't fit my purposes (you can continue mopping up the enemy after the "press escape" prompt appears).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 25, 2021, 10:39:17 AM
EDIT: I've managed to resolve the issue, though I suppose it's still a bug. Turning the weapon arcs forwards (out of a direct 90 degree sideways angle) allows autofit to work fine.

Hm, yeah. There should be a fix to autofit in the upcoming release that'll a least have it place the exact weapon in the target variant in those kinds of slots. But I'm actually not 100% sure if it'll apply here or not...

Is there a way in the API to display a mini version of the intel map for an intel using a large description?

There isn't, no.

I want to doSomething() exactly once at the end of a battle, but this only seems to work reliably when the combat auto-ends because only one side is left on the field. When I press Escape and claim victory, doSomething() is often not called at all.

Is this the proper way to check if combat has finished? Searched this thread and found engine.isEnemyInFullRetreat() as an option, but it doesn't fit my purposes (you can continue mopping up the enemy after the "press escape" prompt appears).

You know, I actually have no idea. I'd be curious to know how mods handle this, since I'm pretty sure they do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 25, 2021, 11:08:26 AM
I want to doSomething() exactly once at the end of a battle, but this only seems to work reliably when the combat auto-ends because only one side is left on the field. When I press Escape and claim victory, doSomething() is often not called at all.

Is this the proper way to check if combat has finished? Searched this thread and found engine.isEnemyInFullRetreat() as an option, but it doesn't fit my purposes (you can continue mopping up the enemy after the "press escape" prompt appears).

You know, I actually have no idea. I'd be curious to know how mods handle this, since I'm pretty sure they do.

There's FleetEventListener? I can think of other stuff that might work, but the listener is the surest and safest way AFAIK.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 25, 2021, 01:26:33 PM
[ooops]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 25, 2021, 05:51:20 PM
Is there a custom flag player faction template (Not the flags, only template how to add one) as I am planning to make a custom player flags from Hearts of Iron 4's The New Order?
No template that I know of, but you can just copy the format of one of the existing flag packs. The flag definitions are simple, just a nested table in the player.faction file with a bunch of file paths.

Somewhat different question: Is there a way to make method calls from a pre-compiled script (i.e. in a .jar) to a Janino runtime-compiled script?

I need my code to call the star system generators (e.g. new Galatia().generate(sector);). Right now I'm bundling copies of the generator scripts in my .jar, but someone wants to modify the vanilla scripts and Nexerelin is disregarding their changes.

I tried adding the starsector-core folder as a library in NetBeans, but it still can't find the packages involved.

Hmm - I don't see offhand why it wouldn't work. Might help to see that actual error; at a guess though it's probably some kind of project configuration issue.
There wasn't any error with adding the library; the IDE or compiler just refused to recognize e.g. data.scripts.world.corvus.Corvus as a valid import afterwards.

I think it just doesn't like referencing uncompiled Java files in a library? I worked around it by making a new project with the contents of data/scripts, compiling it, and using the resulting .jar as the library.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: u2892 on March 26, 2021, 12:07:42 AM
I want to doSomething() exactly once at the end of a battle, but this only seems to work reliably when the combat auto-ends because only one side is left on the field. When I press Escape and claim victory, doSomething() is often not called at all.

Is this the proper way to check if combat has finished? Searched this thread and found engine.isEnemyInFullRetreat() as an option, but it doesn't fit my purposes (you can continue mopping up the enemy after the "press escape" prompt appears).

You know, I actually have no idea. I'd be curious to know how mods handle this, since I'm pretty sure they do.

There's FleetEventListener? I can think of other stuff that might work, but the listener is the surest and safest way AFAIK.

I think I got it, thanks all for the help... was only interested in getting the final CombatDamageData after the battle, looks like BaseCampaignEventListener.reportPlayerEngagement(EngagementResultAPI result) is the proper way to do it.

[Edit] While implementing this, ran into the error "Failed to find script of class com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl" described here: https://fractalsoftworks.com/forum/index.php?topic=15573.0

Solved it by setting the target version for my compiled code to 7, it seems that Janino doesn't like anything greater than that. Is this a known issue?

[Edit] More informative error message in 0.95a "Compiled for the wrong version of Java, change the compile target to Java 7"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on March 27, 2021, 02:19:55 AM
Hi, I'm trying to make some hullmods unbuilt-in with story points since they should not be for good reasons(they're 0 OP cost, no point to build in but can't factor in the fact the player might just build it in for some reason), but I can't find any reference that prevents them from being built-in. Is there any line that I am missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 27, 2021, 04:08:03 AM
Was there something changed with drone AI? I have a drone system using the DRONE_LAUNCHER_PD type that causes a NPE now in 0.95a. The ship has a PHASE type defense ID. Could that be the cause?

Code
java.lang.NullPointerException
at com.fs.starfarer.combat.ai.H.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.system.oOOo.super(Unknown Source)
at com.fs.starfarer.combat.ai.system.drones.DroneAI$1.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.system.drones.DroneAI.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: u2892 on March 27, 2021, 05:22:07 AM
Thanks for the release Alex , having lots of fun with the new DamageListener. Noticed some things while logging all damage events:

- Beams hitting cause many 0-damage events of type OTHER to be generated
- If a large ship dies and goes nova, the ship that got the last hit is credited as dealing a large amount of explosive damage to the already dead ship (see below - Wasp is a fighter, Ultimatum is an Atlas-class superfreighter). However, the actual killing shot does not seem to be recorded

Are these intended? Just curious about the underlying logic behind these.

Code
204959 [0] Wasp -> [1] SIM Ultimatum : [OTHER] ??0 damage?? (47.41/8000 hp - alive)
204959 [0] Wasp -> [1] SIM Ultimatum : [OTHER] ??0 damage?? (47.41/8000 hp - alive)
204959 [0] Xyphos -> [1] SIM Ultimatum : [ENERGY-DPS] shields:5 (47.41/8000 hp - alive)
204975 [0] Aspect -> [1] SIM Ultimatum : [ENERGY] hull:39.38 emp:200 (8.03/8000 hp - alive)
204975 [0] ISS All Under Sky -> [1] SIM Ultimatum : [OTHER] ??0 damage?? (8.03/8000 hp - alive)
204975 [0] ISS All Under Sky -> [1] SIM Ultimatum : [OTHER] ??0 damage?? (8.03/8000 hp - alive)
204975 [0] ISS All Under Sky -> [1] SIM Ultimatum : [OTHER] ??0 damage?? (8.03/8000 hp - alive)
204976 [0] Wasp -> [1] SIM Ultimatum : [ENERGY-DPS] hull:5.61 (2.43/8000 hp - alive)
204976 [0] Wasp -> [1] SIM Ultimatum : [OTHER] ??0 damage?? (2.43/8000 hp - alive)
204979 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1993.77 (0/8000 hp - dead)
204979 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1375.62 armor:36.56 (0/8000 hp - dead)
204980 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1870.68 armor:2.95 (0/8000 hp - dead)
204980 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1237.42 armor:19.61 (0/8000 hp - dead)
204980 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1397.61 (0/8000 hp - dead)
204980 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1365.56 (0/8000 hp - dead)
204980 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1996.21 armor:22.88 (0/8000 hp - dead)
204981 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1695.68 armor:96.57 (0/8000 hp - dead)
204981 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1444.01 armor:50 (0/8000 hp - dead)
204981 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:1170.82 armor:133.33 (0/8000 hp - dead)
204981 [0] Wasp -> [1] SIM Ultimatum : [HIGH_EXPLOSIVE] hull:2446.18 (0/8000 hp - dead)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 27, 2021, 05:35:22 AM
Alright, I was testing the new dependency system in the launcher and I have to say it is WAY too strict, to the point of unusable. If I have a mod that requires a library version 1.2, but the library update to 1.3, the mod is no longer loadable. iirc this shouldn't be the case though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2021, 11:02:12 AM
Hi, I'm trying to make some hullmods unbuilt-in with story points since they should not be for good reasons(they're 0 OP cost, no point to build in but can't factor in the fact the player might just build it in for some reason), but I can't find any reference that prevents them from being built-in. Is there any line that I am missing?

I don't think it's possible, no.

Was there something changed with drone AI? I have a drone system using the DRONE_LAUNCHER_PD type that causes a NPE now in 0.95a. The ship has a PHASE type defense ID. Could that be the cause?

Yeah, definitely phase-related, but I'm not sure exactly what the issue is. If you can get me a minimal mode that reproduces it, I can take a look.


Are these intended? Just curious about the underlying logic behind these.

Probably not intended. It's one of those things where unless vanilla relies on a specific behavior here, it'll always be a bit vague.

Alright, I was testing the new dependency system in the launcher and I have to say it is WAY too strict, to the point of unusable. If I have a mod that requires a library version 1.2, but the library update to 1.3, the mod is no longer loadable. iirc this shouldn't be the case though.

Hmm - the library should *not* change its version in such a way then, no? A "major" version change is an intentional indicator that things that depended on this can no longer be relied on to work.

I'd recommend setting the version in json format, like so:
{"major":1, "minor":3, "patch":0}

To be explicit about what's major and minor. Otherwise the game tries to parse it out of the version string.

But, actually, going from 1.2 to 1.3 would be a "minor" change, I think? And should result in a warning (yellow text), not "red text you can't enable it"... so maybe there's something else going on here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 27, 2021, 12:35:01 PM
I think the changes made to MIRV projectile spec broke something. Changing the projectileRange field for a projectile-creating MIRV missile no longer has any effect whatsoever, as far as I can tell.
On a related note, is there a way to specify a maximum lifetime for projectiles created by a MIRV?

I am absolutely loving the onFireEffect functionality, though. Should be an enormous performance boost to anything that used projectile plugins.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2021, 01:36:48 PM
I think the changes made to MIRV projectile spec broke something. Changing the projectileRange field for a projectile-creating MIRV missile no longer has any effect whatsoever, as far as I can tell.
On a related note, is there a way to specify a maximum lifetime for projectiles created by a MIRV?

Hmm - projectileRange  is used by the vanilla sabot, no? And that works.

Re: lifetime, not sure offhand, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2021, 02:14:22 PM
(Btw: check the patch notes, it should talk about some mirv parameter changes, there were some bugs with them and different ranges of values are now appropriate...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 27, 2021, 03:25:52 PM
Hmm - projectileRange  is used by the vanilla sabot, no? And that works.

I did check this- reducing or increasing projectileRange, even in the vanilla sabot, doesn't change the range of the projectiles. I tried setting the sabot's projectileRange to 75, and 7500 (from default of 750) and the projectiles still always traveled the same distance (or at least, very similar distances- certainly not 7500).

I think I might have misunderstood what these parameters did when I went to fix the parameters after the 0.95 changes. My assumption was that spreadSpeed was the initial speed of the projectiles, a random number between 0 and spreadSpeedRange was added onto that to randomize the velocity, and ProjectileRange was how far they'll travel from the split point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2021, 03:32:31 PM
Uhh - on further checking, it was kind of using it, but then prior to spawning the shots, hardcoding it to 600. Ooops? Glad you caught this; fixed for the hotfix.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 27, 2021, 04:17:41 PM


Was there something changed with drone AI? I have a drone system using the DRONE_LAUNCHER_PD type that causes a NPE now in 0.95a. The ship has a PHASE type defense ID. Could that be the cause?

Yeah, definitely phase-related, but I'm not sure exactly what the issue is. If you can get me a minimal mode that reproduces it, I can take a look.




Here's a tiny mod with a mission]Here's a tiny mod with a mission  (https://mega.nz/file/7JsgxQAL#q-91SObOKhOogklAbZzQlanHg6lXpXtiGv6iikvgLnU)

I added a broadsword with phase, and a drone system using thise phase-based broadswords. One of the condors in the mission has regular broadswords, which I probably should have removed, but mousing over the LPC will confirm its the right one

Reproducing fighter w/ phase crash:
refit one of the condors, run simulation. Should crash

Reproducing drone w/ phase crash:
refit one of the wolves, run simulation, activate system

Thanks for looking at this for me :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2021, 04:35:18 PM
Thank you! Will have a look tomorrow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on March 28, 2021, 12:01:25 AM
I'm confused how this works or maybe I'm misunderstanding.

MutableShipStatsAPI.getFighterWingRange()

What I'm trying to do is add a safety override version to carriers that applies to fighters, which would limit its wing ENGAGEMENT (not weapon) range to 2000

Code
    @Override
    public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
        float spookyranges = fighter.getWing().getRange();
        if (spookyranges > 2000f) {
            fighter.getMutableStats().getFighterWingRange().modifyFlat(id, -(spookyranges - 2000));
        }
    }
So what this code should do is that if a fighter's range is above 2000 (just the value I don't mind if they count the bonuses or not), set it to 2000 (at least with this just one hullmod).

Now I know there is like a +1000/-500 variation, so I tried to make sure the fighters tried to extend itself beyond 3000 range and it still could.. am I doing something wrong here or is there a much bigger variation that I'm not aware of?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on March 28, 2021, 01:55:59 AM
Since nothing in vanilla uses it; for the column 'autofireAccBonus' in weapons_data.csv, how should I format a bonus (IE, is it out of 100, or decimalized? What values will make the game puke?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on March 28, 2021, 01:21:08 PM
Was there something changed with drone AI? I have a drone system using the DRONE_LAUNCHER_PD type that causes a NPE now in 0.95a. The ship has a PHASE type defense ID. Could that be the cause?

Yeah, definitely phase-related, but I'm not sure exactly what the issue is. If you can get me a minimal mode that reproduces it, I can take a look.

I'll just chime in that I'm having the same experience with my otherwise pretty basic phase fighters, CTD for presumably a missing AI the moment after they launch from the carrier. shoi's repro steps sound like they cover the same issue.

Here's a stack trace, fwiw.
Spoiler
97646 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.null.super(Unknown Source)
   at com.fs.starfarer.combat.ai.system.S.super(Unknown Source)
   at com.fs.starfarer.combat.ai.FighterAI$1.super(Unknown Source)
   at com.fs.starfarer.combat.ai.FighterAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 28, 2021, 02:24:16 PM
Was there something changed with drone AI? I have a drone system using the DRONE_LAUNCHER_PD type that causes a NPE now in 0.95a. The ship has a PHASE type defense ID. Could that be the cause?

Yeah, definitely phase-related, but I'm not sure exactly what the issue is. If you can get me a minimal mode that reproduces it, I can take a look.

I'll just chime in that I'm having the same experience with my otherwise pretty basic phase fighters, CTD for presumably a missing AI the moment after they launch from the carrier. shoi's repro steps sound like they cover the same issue.

Here's a stack trace, fwiw.
Spoiler
97646 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.null.super(Unknown Source)
   at com.fs.starfarer.combat.ai.system.S.super(Unknown Source)
   at com.fs.starfarer.combat.ai.FighterAI$1.super(Unknown Source)
   at com.fs.starfarer.combat.ai.FighterAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

I can confirm this exact stack trace on my phase interceptors. No scripts or drone system context involved, just setting the ship data shield type column to PHASE with phasecloak as the defense id will cause the crash on combat start if a ship has the wing equipped.

If I had to guess, I'd say something in the updated phase AI is checking for something by hullsize and there isn't a case for fighters. An object that is supposed to be built as a result is null and one of the methods is being called.

(Hopefully this helps and doesn't just tell you what you already know, heh.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 28, 2021, 09:23:52 PM
What do the new Ship CSV columns do?

c/s   c/f   f/s   f/f   crew/s   crew/f

And travel drive ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sotanaht on March 29, 2021, 02:30:02 AM
Is it possible to modify the male/female npc/officer generation ratio? I basically just one to use one or more of the available anime girl portrait packs exclusively.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on March 29, 2021, 02:39:40 AM
And travel drive ???
Added "travel drive" column to ship_data.csv
Can be used to specify custom system for travel drive
Defaults to "traveldrive" is not specified
System must perform the same basic function in the same basic way
Toggleable, same/extremely similar speed bonus, etc
Mainly useful for setting up custom sounds and visuals for the system

Too lazy to fix the formatting to match the patch notes, oh well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jwarper on March 29, 2021, 07:02:13 AM
I am trying to make a lightweight mod that modifies one stat, but there doesn't seem to be a lot of documentation on skills and other non-ship attributes.  This is my first time modding Starsector, and I spent several hours in netbeans yesterday sifting through code but just couldn't seem to find any static values for skills.  I believe it is related to MAX_CR_BONUS within com.fs.starfarer.api.impl.campaign.skills package.  I cannot find where the static value is stored however (circled in red in the screenshot below)  Any help to point me in the right direction would be greatly appreciated!

(https://i.imgur.com/8Fb1KEv.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 29, 2021, 08:08:21 AM
That circled value is AUTOMATED_POINTS_THRESHOLD in com.fs.starfarer.api.impl.campaign.skills.BaseSkillEffectDescription.

It's public static (and non-final), so you can have mod code modify it from outside (rather than trying to get the game to use a modified version of the skill class).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jwarper on March 29, 2021, 08:18:08 AM
That circled value is AUTOMATED_POINTS_THRESHOLD in com.fs.starfarer.api.impl.campaign.skills.BaseSkillEffectDescription.

It's public static (and non-final), so you can have mod code modify it from outside (rather than trying to get the game to use a modified version of the skill class).

Thank you! I probably should have deduced this package by its obvious name, but it was late last night when I went through everything.  You probably saved me a few more hours of playing whack-a-mole so thank you  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2021, 12:13:11 PM
Here's a tiny mod with a mission]Here's a tiny mod with a mission  (https://mega.nz/file/7JsgxQAL#q-91SObOKhOogklAbZzQlanHg6lXpXtiGv6iikvgLnU)

I added a broadsword with phase, and a drone system using thise phase-based broadswords. One of the condors in the mission has regular broadswords, which I probably should have removed, but mousing over the LPC will confirm its the right one

Reproducing fighter w/ phase crash:
refit one of the condors, run simulation. Should crash

Reproducing drone w/ phase crash:
refit one of the wolves, run simulation, activate system

Thanks for looking at this for me :)

Thank you! Fixed both for the next hotfix.



I'm confused how this works or maybe I'm misunderstanding.

MutableShipStatsAPI.getFighterWingRange()

What I'm trying to do is add a safety override version to carriers that applies to fighters, which would limit its wing ENGAGEMENT (not weapon) range to 2000

Code
    @Override
    public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
        float spookyranges = fighter.getWing().getRange();
        if (spookyranges > 2000f) {
            fighter.getMutableStats().getFighterWingRange().modifyFlat(id, -(spookyranges - 2000));
        }
    }
So what this code should do is that if a fighter's range is above 2000 (just the value I don't mind if they count the bonuses or not), set it to 2000 (at least with this just one hullmod).

Now I know there is like a +1000/-500 variation, so I tried to make sure the fighters tried to extend itself beyond 3000 range and it still could.. am I doing something wrong here or is there a much bigger variation that I'm not aware of?

Hmm - there's two problems. One is this code will get called every time a fighter spawns. Two, you want to be modifying getFighterWingRange() on the *carrier*, not the fighter.


Since nothing in vanilla uses it; for the column 'autofireAccBonus' in weapons_data.csv, how should I format a bonus (IE, is it out of 100, or decimalized? What values will make the game puke?)

Fairly sure 1.0 is "max bonus", so it's scaled on that.


What do the new Ship CSV columns do?

c/s   c/f   f/s   f/f   crew/s   crew/f

Just some internal efficiency spreadsheet formulas used for balance, these values are not actually used by the game.


Is it possible to modify the male/female npc/officer generation ratio? I basically just one to use one or more of the available anime girl portrait packs exclusively.

Pretty sure it's just hardcoded.


I am trying to make a lightweight mod that modifies one stat, but there doesn't seem to be a lot of documentation on skills and other non-ship attributes.  This is my first time modding Starsector, and I spent several hours in netbeans yesterday sifting through code but just couldn't seem to find any static values for skills.  I believe it is related to MAX_CR_BONUS within com.fs.starfarer.api.impl.campaign.skills package.  I cannot find where the static value is stored however (circled in red in the screenshot below)  Any help to point me in the right direction would be greatly appreciated!

See: BaseSkillEffectDescription.AUTOMATED_POINTS_THRESHOLD

In particular, see the static {} code block that actually sets it to 30. You can set it to whatever you want in your ModPlugin.


That circled value is AUTOMATED_POINTS_THRESHOLD in com.fs.starfarer.api.impl.campaign.skills.BaseSkillEffectDescription.

It's public static (and non-final), so you can have mod code modify it from outside (rather than trying to get the game to use a modified version of the skill class).

(Right! Ninja'ed.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 29, 2021, 12:34:13 PM
Is there a reliable way to ensure an destroyed/disabled enemy ship is recoverable after battle? Things I've tried:
My old method of just slapping reinforced bulkheads on there doesn't seem to be reliable any more.

Aside: I'm really enjoying scrapping a bunch of my old hacks thanks to API improvements  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2021, 12:40:46 PM
I don't think there's any way to be 100% sure for an enemy ship - the maximum number of recoverable ships is 16 (well, 32 - 16 normal, and 16 "difficult" and ships beyond that get discarded. Is that what you're seeing? In cases where there's less ships available, method 3) should do the job. AHH! It's "INDIVIDUAL_SHIP_RECOVERY_MOD", not "SHIP_RECOVERY_MOD". The latter is - confusingly - only for a fleetwide stat for the player's fleet, which I believe is currently not even used anywhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 29, 2021, 01:17:59 PM
Ah! Thanks, Alex! The 16/32 limit shouldn't be an issue in the vast majority of circumstances. I'll try INDIVIDUAL_SHIP_RECOVERY_MOD

Looks like SHIP_RECOVERY_MOD is used for the Recovery Operations skill, which I'm pretty sure is where I got it from. Makes perfect sense as a fleetwide stat in that case.
Spoiler
(https://i.imgur.com/OZCCZxw.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 29, 2021, 02:33:44 PM
@Alex: Not much luck using INDIVIDUAL_SHIP_RECOVERY_MOD, sadly. Looking at Misc.isShipRecoverable and FleetEncounterContext.getRecoverableShips, the chance of recoverability is capped at 100% before being multiplied by a value that will be lower than 1 if the ship is destroyed (stats.getBreakProb().modifyMult(id, 0f) doesn't seem to prevent that?) or the player contributed to the battle only partially. Given that, it looks like my options are to override FleetEncounterContext (a cure worse than the disease), or try to find a way to manually insert ships into the list of recoverable ships at the right moment. For now I'll take another crack at that method, but later I might beg you for a simple and clean way to guarantee enemy ship recoverability. I know of at least two other (outdated) mods that needed the same thing.

Edit: Looks like there's also a chance to negate the result of Misc.isShipRecoverable later on as well:
Spoiler
Quote
         if (!own && (storyRecovery || normalRecovery)) {
            float per = Global.getSettings().getFloat("probNonOwnNonRecoverablePerDMod");
            float perAlready = Global.getSettings().getFloat("probNonOwnNonRecoverablePerAlreadyRecoverable");
            float max = Global.getSettings().getFloat("probNonOwnNonRecoverableMax");
            int dmods = DModManager.getNumDMods(data.getMember().getVariant());
            
            float assumedAddedDmods = 3f;
            assumedAddedDmods += Global.getSector().getPlayerFleet().getStats().getDynamic().getValue(Stats.SHIP_DMOD_REDUCTION, 0) * 0.5f;
            
            float recoveredSoFar = 0f;
            if (storyRecovery) recoveredSoFar = storyRecoverableShips.size();
            else recoveredSoFar = result.size();
            
            if (random.nextFloat() < Math.min(max, (dmods + assumedAddedDmods) * per) + recoveredSoFar * perAlready) {
               noRecovery = true;
            }
         }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on March 29, 2021, 02:39:48 PM
This is pretty much exactly why I made this thread:
http://fractalsoftworks.com/forum/index.php?topic=20155.0
A way to ensure a ship is always recoverable would be more than welcome. Or at least always recoverable if Flagship if you are concerned with going beyond the 16 ships limit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 29, 2021, 02:46:27 PM
Yeah, a hint like that would be ideal for IBB and HVB ships. In my case it wouldn't do the trick though, as the ships I need to make recoverable don't have unique hull specs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2021, 03:07:56 PM
Made a note. A possible alternative approach: spawn the ship hulk post-battle, make it always recoverable, and flag is as important.

See (bit of a campaign spoiler):
Spoiler
The TTBlackSite class, the Ziggurat encounter works like this...
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on March 29, 2021, 03:08:42 PM
Hmm - there's two problems. One is this code will get called every time a fighter spawns. Two, you want to be modifying getFighterWingRange() on the *carrier*, not the fighter.

Hmm.. the 1st code would be bad performance-wise? May I ask for something like getWeaponRangeThreshold(), but in the code of getFighterWingRangeThreshold() ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2021, 03:10:57 PM
No not performance-wise, just it might run more times than you'd want and depending on exactly how your code does the calculation it *could* become incorrect as a result.

May I ask for something like getWeaponRangeThreshold(), but in the code of getFighterWingRangeThreshold() ?

I'll keep that in mind, but honestly, chances are a bit low. What you're doing seems like it ought to work, anyway!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 29, 2021, 03:24:16 PM
Made a note. A possible alternative approach: spawn the ship hulk post-battle, make it always recoverable, and flag is as important.
Ah, that makes sense. I'll probably do that since there's vanilla precedent. I'll have to see how those spoilerey things work first though...
Thanks again!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 30, 2021, 01:13:24 AM
Thanks alex!

I didn't see anything in the changelog, what does "hist1t" do for wings in wing_data tag?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sordid on March 30, 2021, 11:45:14 AM
I'm not sure if this question turns out to be minor or not, but here goes: Is there an easy way to dial down the scaling of fleet sizes as the game goes on?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 30, 2021, 04:34:03 PM
This is a bit of a weird one- hotfixes are breaking my modded saves, but not my vanilla ones. The error log indicates that it's my custom submarket (I think), but I have no issues loading saves otherwise. Not a big deal at the end of the day, but since this is the first update I've experienced, I'm wondering if it's simply a consequence of how savefiles work or if it's something I can fix. This only happens with saves from a previous hotfix version, starting a new save in the most current hotfix allows me to save and load the new save without issues.

Errors:
Spoiler
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : com.fs.starfarer.loading.specs.g
class               : java.util.ArrayList
required-type       : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
line number         : 173295
class[1]            : com.fs.starfarer.api.util.WeightedRandomPicker
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : plugins.drgSvarogMarketPlugin
class[3]            : com.fs.starfarer.campaign.econ.Submarket
class[4]            : com.fs.starfarer.campaign.econ.Market
class[5]            : com.fs.starfarer.campaign.CustomCampaignEntity
class[6]            : com.fs.util.container.repo.ObjectRepository
class[7]            : com.fs.starfarer.campaign.StarSystem
class[8]            : com.fs.starfarer.campaign.CampaignPlanet
class[9]            : com.fs.starfarer.campaign.CircularOrbit
class[10]           : com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment
class[11]           : com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteData
class[12]           : com.fs.starfarer.api.impl.campaign.fleets.RouteManager
class[13]           : com.fs.starfarer.campaign.fleet.CampaignFleet
class[14]           : com.fs.starfarer.campaign.ai.NavigationModule$AvoidData
class[15]           : com.fs.starfarer.api.util.TimeoutTracker$ItemData
class[16]           : com.fs.starfarer.api.util.TimeoutTracker
class[17]           : com.fs.starfarer.campaign.ai.NavigationModule
class[18]           : com.fs.starfarer.campaign.ai.ModularFleetAI
class[19]           : com.fs.starfarer.loading.specs.FactionProduction
class[20]           : com.fs.starfarer.campaign.Faction
class[21]           : com.fs.starfarer.campaign.econ.reach.ReachEconomy
class[22]           : com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper
class[23]           : com.fs.starfarer.campaign.econ.Economy
class[24]           : com.fs.starfarer.campaign.StarSystem$UpdateFromHyperspaceLocation
class[25]           : com.fs.starfarer.campaign.BaseLocation$LocationToken
class[26]           : com.fs.starfarer.campaign.Hyperspace
class[27]           : com.fs.starfarer.campaign.CampaignEngine
converter-type[2]   : com.fs.starfarer.campaign.save.I
version             : not available
-------------------------------
com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : com.fs.starfarer.loading.specs.g
class               : java.util.ArrayList
required-type       : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
line number         : 173295
class[1]            : com.fs.starfarer.api.util.WeightedRandomPicker
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : plugins.drgSvarogMarketPlugin
class[3]            : com.fs.starfarer.campaign.econ.Submarket
class[4]            : com.fs.starfarer.campaign.econ.Market
class[5]            : com.fs.starfarer.campaign.CustomCampaignEntity
class[6]            : com.fs.util.container.repo.ObjectRepository
class[7]            : com.fs.starfarer.campaign.StarSystem
class[8]            : com.fs.starfarer.campaign.CampaignPlanet
class[9]            : com.fs.starfarer.campaign.CircularOrbit
class[10]           : com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment
class[11]           : com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteData
class[12]           : com.fs.starfarer.api.impl.campaign.fleets.RouteManager
class[13]           : com.fs.starfarer.campaign.fleet.CampaignFleet
class[14]           : com.fs.starfarer.campaign.ai.NavigationModule$AvoidData
class[15]           : com.fs.starfarer.api.util.TimeoutTracker$ItemData
class[16]           : com.fs.starfarer.api.util.TimeoutTracker
class[17]           : com.fs.starfarer.campaign.ai.NavigationModule
class[18]           : com.fs.starfarer.campaign.ai.ModularFleetAI
class[19]           : com.fs.starfarer.loading.specs.FactionProduction
class[20]           : com.fs.starfarer.campaign.Faction
class[21]           : com.fs.starfarer.campaign.econ.reach.ReachEconomy
class[22]           : com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper
class[23]           : com.fs.starfarer.campaign.econ.Economy
class[24]           : com.fs.starfarer.campaign.StarSystem$UpdateFromHyperspaceLocation
class[25]           : com.fs.starfarer.campaign.BaseLocation$LocationToken
class[26]           : com.fs.starfarer.campaign.Hyperspace
class[27]           : com.fs.starfarer.campaign.CampaignEngine
converter-type[2]   : com.fs.starfarer.campaign.save.I
version             : not available
[close]

plugins.drgSvarogMarketPlugin is the submarket plugin. It doesn't add any data to a save beyond whatever the base submarket plugins do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2021, 04:40:56 PM
Thanks alex!

I didn't see anything in the changelog, what does "hist1t" do for wings in wing_data tag?

It means the historian you meet at the bar will offer the location of this wing, potentially, as a at tier 1 (hence t1). There are 3 tiers as you give him more credits for research. So, hist1t, hist2t, and hist3t.

This is a bit of a weird one- hotfixes are breaking my modded saves, but not my vanilla ones. The error log indicates that it's my custom submarket (I think), but I have no issues loading saves otherwise. Not a big deal at the end of the day, but since this is the first update I've experienced, I'm wondering if it's simply a consequence of how savefiles work or if it's something I can fix. This only happens with saves from a previous hotfix version, starting a new save in the most current hotfix allows me to save and load the new save without issues.

cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException

The bolded part would indicate to me that this is an issue with the game not being able to find that class. I don't *think* it's hotfix-related.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 30, 2021, 05:36:21 PM
The bolded part would indicate to me that this is an issue with the game not being able to find that class. I don't *think* it's hotfix-related.

After some discussion on the modding discord, the issue appears to be that some objects in my custom market plugin (instances of WeightedRandomPicker<ShipHullSpecAPI>) were getting serialized and stored in saves, and then when the version changed, the serialization of the obfuscated class changed and the game failed to find a class with the same data members. Marking them as transient has resolved the issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2021, 05:41:03 PM
Ah, ok, that makes sense. Definitely not a good idea to store that kind of thing in savefiles, so: probably a good thing it crashed :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 30, 2021, 08:17:34 PM
In 0.95
The cargo picker still not have a scroll bar...
Could that area not only be text panel but CustomPanelAPI?

BTW, I mentioned that the nebula particles(or others?) seems use something like Tex/4 to locate the Sprite texture(I think that's something like Atlas sheet)
So, If I use sprites like that, combine several images into one image, will there be appearent performance improvement?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 31, 2021, 10:08:39 AM
In 0.95
The cargo picker still not have a scroll bar...
Could that area not only be text panel but CustomPanelAPI?

I can take a look at some point, but honestly, right now there's a lot of other stuff I need to focus on :(

BTW, I mentioned that the nebula particles(or others?) seems use something like Tex/4 to locate the Sprite texture(I think that's something like Atlas sheet)
So, If I use sprites like that, combine several images into one image, will there be appearent performance improvement?

Right, yeah. If you do this for particle effects it can be helpful. Basically, binding a texture has a performance cost - higher for larger textures, too. So if you *can* bind a texture atlas before doing all your drawing, it can help. It helps more if you do a lot of drawing, like for a particle effect. I wouldn't worry about it too much unless you're really drawing a lot of things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on March 31, 2021, 09:42:01 PM
Right, yeah. If you do this for particle effects it can be helpful. Basically, binding a texture has a performance cost - higher for larger textures, too. So if you *can* bind a texture atlas before doing all your drawing, it can help. It helps more if you do a lot of drawing, like for a particle effect. I wouldn't worry about it too much unless you're really drawing a lot of things.
Well, so when the "binding the texture" will happen? I mean, actually starsector would bind all the textures while loading right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 01, 2021, 05:38:39 AM
How do I actually use a Janino-compiled script from precompiled code? As in, this crashes the game on start:

Spoiler
Code: java
	@Override
public void onApplicationLoad() throws Exception {
try {
String className = "data.scripts.world.systems.Galatia";
Global.getLogger(this.getClass()).info("Class loader loading class");
Global.getLogger(this.getClass()).info("Class name: " + Global.getSettings().getScriptClassLoader().loadClass(className).getName());
Global.getLogger(this.getClass()).info("Trying Class.forName");
Class test = Class.forName(className);
} catch (ClassNotFoundException cex) {
throw new RuntimeException(cex);
}
}
19437 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Class loader loading class
19437 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Class name: data.scripts.world.systems.Galatia
19437 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Trying Class.forName
19481 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: java.lang.ClassNotFoundException: data.scripts.world.systems.Galatia
java.lang.RuntimeException: java.lang.ClassNotFoundException: data.scripts.world.systems.Galatia
   at org.histidine.testmod.plugins.TestModPlugin.onApplicationLoad(TestModPlugin.java:41)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.world.systems.Galatia
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at org.histidine.testmod.plugins.TestModPlugin.onApplicationLoad(TestModPlugin.java:39)
   ... 6 more

[close]
(Context of what I'm trying to do (http://fractalsoftworks.com/forum/index.php?topic=5061.msg309372#msg309372). Not sure if this problem surfaced in Starsector 0.95a, and don't feel like reinstalling to find out)

UPDATE: Applied a hammer to this screw.
Spoiler
Code: java
	public static void generateSystemsJanino() {
List<String> inputList = new ArrayList<>();
String[] sysNames = {"Galatia", "Askonia", "Eos", "Valhalla", "Arcadia",
"Magec", "Aztlan", "Samarra", "Penelope", "Yma", "Hybrasil", "Duzahk",
"TiaTaxet", "Canaan", "AlGebbar", "Isirah", "KumariKandam", "Naraka",
"Thule", "Mayasura", "Zagan", "Westernesse", "Tyle"};

inputList.add("import com.fs.starfarer.api.campaign.SectorAPI;\r\n");
inputList.add("SectorAPI sector = com.fs.starfarer.api.Global.getSector();\r\n");
inputList.add("new data.scripts.world.corvus.Corvus().generate(sector);\r\n");
for (String systemName : sysNames) {
String entry = "new data.scripts.world.systems." + systemName + "().generate(sector);\r\n";
inputList.add(entry);
}

ScriptEvaluator eval = new ScriptEvaluator();
eval.setReturnType(void.class);
eval.setParentClassLoader(Global.getSettings().getScriptClassLoader());

StringBuilder sb = new StringBuilder();
for (String input : inputList) sb.append(input);
Global.getLogger(VanillaSystemsGenerator.class).info("Output: " + sb.toString());
try
{
eval.cook(sb.toString());
eval.evaluate(null);
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2021, 09:43:32 AM
How do I actually use a Janino-compiled script from precompiled code? As in, this crashes the game on start:

Hmm - I mean, this sounds like a it's probably an IDE configuration issue? I'm not seeing why it wouldn't work if the resulting class file properly refers to the Janino-compiled class (i.e. right package etc). As long as it's not called before that class is compiled. That said, this doesn't happen in vanilla, so maybe there's a larger issue here that I'm just not seeing, perhaps due to how the classloaders are hooked up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 01, 2021, 03:19:16 PM
I cannot for the life of me find the thread where it was mentioned and I don't see it in the patch notes, but - did the "Don't ever target fighters" weapon hint make it into the release?

If so, what is the hint?

(Or am I just crazy and dreamed that was going to be a thing?)

*EDIT*

Ah I finally found the thread! Looking at the discussion again I think maybe I was misunderstanding? I was going off of:

Fair enough, yeah.

Edit: added "NO_TURN_RATE_BOOST_WHEN_IDLE" weapon hint.
That plus a ignore fighters tag? Whooooo this is great, thanks a lot. Combined with a smarter autofire decision AI, it should help a LOT when dealing with ships supported by fighters.

So maybe I saw this and thought both were added to the dev version when in actuality only the specifically mentioned one was?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on April 01, 2021, 07:22:02 PM
Is the code that handles integrating an AI core officer obfuscated? I've poked around the api source and haven't managed to stumble into it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 01, 2021, 07:40:08 PM
These seem relevant:

com.fs.starfarer.api.campaign.AICoreOfficerPlugin

CampaignPlugin.pickAICoreOfficerPlugin()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on April 01, 2021, 07:46:56 PM
These seem relevant:

com.fs.starfarer.api.campaign.AICoreOfficerPlugin

CampaignPlugin.pickAICoreOfficerPlugin()

Those are used to generate the AI core officers- but I'm looking for the stuff that handles integrating an AI core officer into an automated ship (the option that uses a story point). Specifically, integrating an AI officer into a ship blocks command transferring- even if I redo the Automated Ship hullmod to not block command transfer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ArneHD on April 02, 2021, 09:08:04 AM
Hi, can I make the character screen wider? I tried adding a skill after tier 5, but it went off screen there, and I don't know where to find the UI files or, for that matter, how the UI works.

Any help would be appreciated, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on April 02, 2021, 09:16:38 AM
Is there any API method (or way, period) to make PD not target a specific missile/fighter? I'm trying to make a shielded missile (it'll be pretty hackjob, I think) but one of the potential design concerns is PD getting confused and firing at it when it shouldn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Warnoise on April 02, 2021, 09:23:17 AM
Hi, is it possible to modify existing ships? For example adding built in mods, modifying op, armor, etc...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2021, 11:00:26 AM
So maybe I saw this and thought both were added to the dev version when in actuality only the specifically mentioned one was?

Yeah, that sounds right - sorry :)

Those are used to generate the AI core officers- but I'm looking for the stuff that handles integrating an AI core officer into an automated ship (the option that uses a story point). Specifically, integrating an AI officer into a ship blocks command transferring- even if I redo the Automated Ship hullmod to not block command transfer.

See: Misc.isUnremovable(); setting that flag is what integrating the AI core does. But the core code that does it is not directly moddable, no.


Is there any API method (or way, period) to make PD not target a specific missile/fighter? I'm trying to make a shielded missile (it'll be pretty hackjob, I think) but one of the potential design concerns is PD getting confused and firing at it when it shouldn't.

There isn't, I don't think. But doesn't it give you a scrollbar? Or does that only work vertically if you add more aptitudes? I don't actually remember.

Is there any API method (or way, period) to make PD not target a specific missile/fighter? I'm trying to make a shielded missile (it'll be pretty hackjob, I think) but one of the potential design concerns is PD getting confused and firing at it when it shouldn't.

I don't believe so, no. Well, if you set its collision class to NONE, that might do it, but that'd have other effects, too.

Hi, is it possible to modify existing ships? For example adding built in mods, modifying op, armor, etc...

Yeah - you can edit the corresponding .ship file (for built-in mods) and the corresponding ship_data.csv row for editing their stats.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 02, 2021, 12:15:59 PM
So maybe I saw this and thought both were added to the dev version when in actuality only the specifically mentioned one was?

Yeah, that sounds right - sorry :)


No worries thanks for clarifying!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 02, 2021, 07:07:54 PM
Given a float representing % bonus XP from story point use (say, 0.5), how do I determine the bonus XP amount I should pass to MutableCharacterStatsAPI.addBonusXP?

(I'm doing a thing where player can spend one SP on an action and get X% bonus XP back, then if they cancel that action they get the other (100-X)% bonus XP as a refund)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 02, 2021, 07:14:19 PM
Ah - let me add long getBonusXPForSpendingStoryPointBeforeSpendingIt() to MutableCharacterStatsAPI.

It's a bit involved; here's the actual method. It *should* be correct - I did a pretty good amount of testing on it. But it might not handle some edge case like, say, the bonus XP exceeding a single level's total XP.

Code
	public long getBonusXPForSpendingStoryPointBeforeSpendingIt() {
LevelupPlugin plugin = ScriptStore.getPlugin(LevelupPlugin.class);
int per = plugin.getStoryPointsPerLevel();


// what we want to do is figure out exactly how much bonus XP is needed to gain 1 story point
// if the bonus XP crosses over to the next level - so part of the bonus XP is based on the XP
// for the current level, and part for the next.
int levelWithBonusXP = 1;
while (plugin.getXPForLevel(levelWithBonusXP + 1) <= xp + bonusXp * 2L) {
levelWithBonusXP++;
if (levelWithBonusXP >= plugin.getMaxLevel()) break;
}

if (levelWithBonusXP < plugin.getMaxLevel() - 1) {
long currLevelStart = plugin.getXPForLevel(levelWithBonusXP);
long currLevelEnd = plugin.getXPForLevel(levelWithBonusXP + 1);
long nextLevelEnd = plugin.getXPForLevel(levelWithBonusXP + 2);

currLevelEnd -= currLevelStart;
nextLevelEnd -= currLevelStart;

float fraction = (float)(xp + bonusXp * 2L - currLevelStart) / (float) currLevelEnd;
float fractionPerPt = 1f / (float) per;
float fractionAfter = fraction + fractionPerPt * 2f; // * 2 because it'll be gained alongside real XP

float xpForThisLevel = Math.max(0f, Math.min(1f, fractionAfter) - fraction) * currLevelEnd;
float xpForNextLevel = Math.max(0f, fractionAfter - 1f) * (nextLevelEnd - currLevelEnd);

return (long)Math.round((xpForThisLevel + xpForNextLevel) * 0.5f); // * 0.5f to undo the earlier doubling
}

int level = this.level + 1;
level = Math.min(level, plugin.getMaxLevel() + 1);
long neededForPrevLevel = plugin.getXPForLevel(level - 1);
long neededForSPLevel = plugin.getXPForLevel(level);

return ((neededForSPLevel - neededForPrevLevel) / per);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Warnoise on April 02, 2021, 11:27:05 PM
So what if, for example, I want to modify the XIV variant of the onslaught only (not the regular one), for example I want to add a built in mode for the xiv variant only, how can I do that?

I checked the .ship files and I only found the base versions of said ships, I couldn't find the xiv variants in . ship files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on April 03, 2021, 12:37:10 AM
So what if, for example, I want to modify the XIV variant of the onslaught only (not the regular one), for example I want to add a built in mode for the xiv variant only, how can I do that?

I checked the .ship files and I only found the base versions of said ships, I couldn't find the xiv variants in . ship files.
cuz they are a .skin file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 03, 2021, 08:28:21 PM
Great, thanks Alex!

Now I'm trying to make a custom bounty where the target is an existing route-spawned fleet.

- How do I get the instance of MilitaryCustomBounty, to call setTestMode on it?
(edit: oh, right, I can just wipe the existing creator list and leave only my own)

- To make this work, I'm forcing the route to spawn the fleet, via route.getSpawner().spawnFleet(route) and route.getActiveFleet().setNoAutoDespawn(true).
I set noAutoDespawn back to null in notifyCompleted and notifyFailed.
But what if I never take the mission, does the fleet stick around forever? Hmm, I'll try not setting the auto despawn until the mission is actually accepted.

EDIT: RIP, spawnFleet doesn't actually set the route's active fleet and there's no way to manually assign it...
Guess this idea goes back on the shelf.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boeduur on April 04, 2021, 06:53:13 AM
Hi all,

Had a comb through the settings.json to see where the Range is set on a tracking fleet's interference with the Players interactions (salvage and survey, etc). Couldn't find it in there.

Any ideas?

Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Golde on April 04, 2021, 05:00:50 PM
There is now a jitter / glow effect on energy weapon offsets related to the EW mastery skill (at high flux levels) that could be useful for creating other effects. I dissected the skill.java but there doesn't seem to be anything responsible for triggering the effect.

Has anyone else looked into this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2021, 06:03:28 PM
Great, thanks Alex!

Now I'm trying to make a custom bounty where the target is an existing route-spawned fleet.

- How do I get the instance of MilitaryCustomBounty, to call setTestMode on it?
(edit: oh, right, I can just wipe the existing creator list and leave only my own)

- To make this work, I'm forcing the route to spawn the fleet, via route.getSpawner().spawnFleet(route) and route.getActiveFleet().setNoAutoDespawn(true).
I set noAutoDespawn back to null in notifyCompleted and notifyFailed.
But what if I never take the mission, does the fleet stick around forever? Hmm, I'll try not setting the auto despawn until the mission is actually accepted.

EDIT: RIP, spawnFleet doesn't actually set the route's active fleet and there's no way to manually assign it...
Guess this idea goes back on the shelf.

Ah - let me make a note to make force-spawning things like this possible.



Hi all,

Had a comb through the settings.json to see where the Range is set on a tracking fleet's interference with the Players interactions (salvage and survey, etc). Couldn't find it in there.

Any ideas?

Thanks

That's actually hardcoded in a few places. Good news is I've got a TODO item to make tiny fleets not interfere with these kinds of operations!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boeduur on April 04, 2021, 08:45:55 PM
Ah! Awesome. Thanks, Alex
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ithiloneth on April 05, 2021, 06:42:21 AM
Update 2:

We have a winner and some wisdom!
When testing the behavior of a .child script, deploy the entire ship.

Working code:
Code
if (child.getFluxTracker().getFluxLevel() >= 0.75) {
            child.giveCommand(ShipCommand.VENT_FLUX, null, 0);
        }

Update:
Turns out my testing methodology might have been a factor here; I launched the simluator with just the module and not the entire ship. I am now able to get it to vent; but it seems to do so much too frequently...

I am trying to make a ship with modules force the modules to vent their flux when the modules reach a certain level of flux (preferred if the value is a percentage of MaxFlux rather than a static value of current flux.
E.x 0.5 vs 350.

I have tried a few options but so far no luck.
This is my first edit to a mod where I am actively adding code; I don't really know Java so likely that is the problem here.
Been trying to use the API to the best of my ability ^^

Based on what's in there getFluxLevel seems the best option but I can't get it to work.

Code
getFluxLevel
float getFluxLevel()
Returns:
    flux level, from 0 to 1


Code
if (child.getFluxTracker().getCurrFlux() > 0.75f) {
            child.giveCommand(ShipCommand.VENT_FLUX, null, 0);
        }

Code
if (child.getFluxTracker().getFluxLevel() >= 0.75) {
            child.giveCommand(ShipCommand.VENT_FLUX, null, 0);
        }

Thoughts?

My reason for doing this is that I've found that the modules will not, generally speaking, vent flux when they need to - if an enemy ship has the module under it's guns. Since the module is not providing a shield it venting is however not a problem - it should vent so it can keep firing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on April 05, 2021, 09:57:29 PM
Code
market.getPlanetEntity().getTypeId();
and
Code
market.getPlanetEntity().setTypeId("water");
seems to be doing nothing for me. Everytime I run the code on any of the planets down. The planet still returns whatever it was instead of making it identify as a water planet (just the tooltip itself doesn't seem to show). I have called market.getPlanetEntity().applySpecChanges() after doing my code which updates the graphic change perfectly.

For example this is my code
Code
    @Override
    public void onNewGameAfterEconomyLoad() {
    MarketAPI market = Global.getSector().getEconomy().getMarket("chitagupta");
    market.getPlanetEntity().setTypeId("water");
}
All it has to do is just make Chiptagupta see itself as a water world... but instead (there are other code at work that are changing its visuals, but I care more about why is it still identifying itself as a barren type)
(https://i.imgur.com/4tmovS0.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 06, 2021, 10:34:16 AM
Is there any way to set Ship AI to a fighter or frigate? I see there is a setShipAI method but I am unsure of what I should pass in as a parameter, if any.
Also, is there any way to check if the player ship is being autopiloted but not with the UI up? (I'm assuming    isUIAutopilotOn() is explicitly when the command UI is visible?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Reviire on April 06, 2021, 05:43:36 PM
Hi there. I want to replace the behaviour in the BattleCreationPluginImpl class, but I'm not sure how to do that (in a way that'll work when giving people the mod to put in their mod folder). I need help figuring out how to override or replace a vanilla class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 06, 2021, 09:44:16 PM
@Reviire:  Unfortunately, you can only replace that class via CoreCampaignPluginImpl... which you can replace via SectorGen.  In short, it will work, but it will basically break compatibility with anything else that depends on either thing being <some special way>.



Meanwhile... I'm having a very odd problem with DamageDealtModifier.modifyDamageDealt().  I've been converting an EveryFrameScript over to a DamageListener and the behavior's just kind of odd; I'm wondering if there's something special going on under the hood here.

The issue is with Burst Beams; they're behaving like they're doing the full damage every frame, rather than the full damage * the amount of time every frame.

However, I'm also having problems with the DamageAPI setDamage() function; when I give it a number, and the param is instanceof BeamAPI... it seems to set the final damage to zero. Sooooo... yeah.  Can't get Burst Beams to behave themselves, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 06, 2021, 11:47:45 PM
OK, I think I figured this Beam thing out. 

Beams... are weird. 

They give a "correct" result to the DamageListener on the first frame, but after that, zero! 

So... Burst Beams, because they're doing that first-frame behavior a lot, are giving one value, and it's really high (the way I'm computing it right now); continuous beams are doing something entirely else.  I'll post code when I have something that actually works correctly; the head-scratching behavior finally makes some sense now that I've tested a few things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Reviire on April 07, 2021, 12:48:39 AM
@Reviire:  Unfortunately, you can only replace that class via CoreCampaignPluginImpl... which you can replace via SectorGen.  In short, it will work, but it will basically break compatibility with anything else that depends on either thing being <some special way>.
How do I do that exactly? That's another thing I'm not entirely clear on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Venomfx on April 07, 2021, 03:31:18 AM
Where does getAllowZeroFluxAtAnyLevel get checked for zero flux boost? I'm trying to understand and tinker with the helmsmanship elite bonus.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Twogs on April 07, 2021, 07:05:44 AM
How do you make fighters spawn from defined launch bays instead of just in the middle of the ship?

I defined two launchbays, yet the fighter wings just spawn at the center of the ship and ignore them completely
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2021, 09:43:40 AM
Thoughts?

Hard to say - what you're doing seems like it should work conceptually. I'd suggest adding some debugging print statements or connecting with a debugger.

@Reviire:  Unfortunately, you can only replace that class via CoreCampaignPluginImpl... which you can replace via SectorGen.  In short, it will work, but it will basically break compatibility with anything else that depends on either thing being <some special way>.

(Ah, that's incorrect - you can add your own campaign plugin and return a BattleCreationPlugin version with a higher priority than the default campaign one.)


Where does getAllowZeroFluxAtAnyLevel get checked for zero flux boost? I'm trying to understand and tinker with the helmsmanship elite bonus.

In core code that's not directly accessible.

How do you make fighters spawn from defined launch bays instead of just in the middle of the ship?

I defined two launchbays, yet the fighter wings just spawn at the center of the ship and ignore them completely

Hmm - I don't think you can. It's somewhere in the "modding requests" pile...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Twogs on April 07, 2021, 12:21:14 PM
How do you make fighters spawn from defined launch bays instead of just in the middle of the ship?

I defined two launchbays, yet the fighter wings just spawn at the center of the ship and ignore them completely

Hmm - I don't think you can. It's somewhere in the "modding requests" pile...

Ok thanks for the answer : )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 07, 2021, 12:44:52 PM
Okay, I've got a bit of a weird issue with my custom industries and I'm not sure how to fix it. Basically I'm not able to install the special items that I've got set up; the basic setup for the industry is very similar to the default Heavy Industry setup, with some specific stuff to account for the industry in question (Modular Fabricators) being able to be changed to a number of specialized sub-variants, for which I've got a number of yet to be tested special items which should hopefully be usable to start the process of upgrading the facility.

However, the Fabricators lack the option to install special items, being limited to story point linked output improvement, adding AI Cores, and shutting it down; it's not very clear why this should be the case, since the game is definitely finding the special item data (and indeed, I had to set up localized versions of GenericSpecialItemPlugin and ItemEffectsRepo in order to avoid getting Null Errors) so I figured I might as well ask here and see if anyone had any ideas. It's a little hard to be specific when it comes down to it though, since the game isn't giving me a lot to go on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on April 07, 2021, 12:58:35 PM
Looks like the relevant code for that is in BaseIndustry.java:
Code
	public boolean wantsToUseSpecialItem(SpecialItemData data) {
if (special != null) return false;
SpecialItemSpecAPI spec = Global.getSettings().getSpecialItemSpec(data.getId());
String [] industries = spec.getParams().split(",");
Set<String> all = new HashSet<String>();
for (String ind: industries) all.add(ind.trim());
return all.contains(getId());
}
Which suggests that you need the industry ID in the plugin params field of special_items.csv - assuming that your industry doesn't override that particular method?

If that doesn't work, for a first cut at making this do anything, I might try overriding that method in your industry with a simple "return true;" and see if that does the expected thing of letting you install any item.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2021, 01:04:39 PM
Right! You need the id (or ids, comma-separated) in the plugin params column.

The BaseIndustry.getInstallableItems() method is the relevant here, btw - wantsToUseSpecialItem() actually determines whether the industry will slot this item in if it's sold to the colony by the player.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 07, 2021, 01:22:26 PM
I do have the plugin params set up correctly, so my best guess given what you've said is that my implementation is somehow bypassing that. Time to go through and do a comparison I guess.

E: Okay, the only one of the BaseIndustry methods I was using that looks for plugin params was wantsToUseSpecialItem, but even commenting that out didn't actually resolve the issue; I may have to just abandon trying to use the vanilla implementation entirely =/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2021, 01:39:00 PM
Ah, taking another look - your item effect needs to be added to ItemEffectsRepo.ITEM_EFFECTS.

See: GenericInstallableItemPlugin.isInstallableItem()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 07, 2021, 01:50:41 PM
... so, just like extend ItemEffectsRepo and change the existend item effects map I have to ITEM_EFFECTS or something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on April 07, 2021, 01:53:55 PM
Ah, interesting - I missed that stuff too. (Been taking a look at what I'd need to do to mod the required resources for the shunt tap or the orbital furnace down to a more reasonable 8. Don't have it working yet, though.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2021, 02:10:57 PM
... so, just like extend ItemEffectsRepo and change the existend item effects map I have to ITEM_EFFECTS or something?

No, just add your item effect to ITEM_EFFECTS - it's a public static data member, so you don't need to extend the class to access it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 07, 2021, 03:32:20 PM
Ah, Alex, out of curiosity it seems like this is the sort of thing that can be merged into the existing class with a static {}, but that delivers nulls on starting a new game; is that a bug or did you have a different approach in mind?

E: Specifically a null at super.apply(), to be clear.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2021, 03:35:06 PM
That should indeed work in a static block. I'd need to see the exception to say more; based on what you're saying I don't think the error is related to the static block where you add the effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 07, 2021, 04:02:25 PM
Quote
(Ah, that's incorrect - you can add your own campaign plugin and return a BattleCreationPlugin version with a higher priority than the default campaign one.)
Oh, OK!

So, Reviire, sorry to provide incorrect info there. You can create a CampaignPlugin (and turn it on via settings.json) and then use:

Code
	public PluginPick<BattleCreationPlugin> pickBattleCreationPlugin(SectorEntityToken opponent) {

return new PluginPick<BattleCreationPlugin>(new BattleCreationPlugin_YOU_WROTE_HERE(), PickPriority.MOD_SPECIFIC);
}

Just use BattleCreationPluginImpl as a base (I presume you already have) and you're good.

That's nice and simple :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MShadowy on April 07, 2021, 04:14:36 PM
Weird; it works inside the onNewGame() method though, which seems a little strange. Also probably not the ideal method to apply it.

Checking the log more closely gives an error starting at line 22 of BoostIndustryInstallableItemEffect, which indicates it's somehow not getting the supply bonus, which is causing the super to fail in the very next step. I'm not sure why that would be the case though, since the variables are all pretty clearly set up.

E: It may be a result of the industry having its supply outputs all be variables effected by a bunch of if statements, not supplyBonuses, derp.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on April 07, 2021, 05:48:21 PM
I have a stupid question. I'm aware of creating planets and adding market conditions and industries. I was wondering if it was possible to add special_items to the planet market. Say for instance, I have farming as industry for the planet in the json. Is it possible to also have soil_nanites installed in the market, the same as the farming industry?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2021, 06:00:27 PM
Like so in the .json file for the star system:
["orbitalworks", "pristine_nanoforge"],

The above is taken from aztlan.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on April 07, 2021, 09:21:10 PM
@Alex, Thank you! I really appreciate it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FelixG on April 07, 2021, 11:48:48 PM
Question: I am trying to mod carriers to be not terrible anymore, but I can't find the replenishment time/ability anywhere to reference, does anyone know where to find it so I can mess with it?

Edit: I found this string that possibly points to the code for it, but I have no idea where to locate it

com.fs.starfarer.api.impl.hullmods.ExpandedDeckCrew

Edit2: Found it in starfarer.api.zip in the Starsector\starsector-core folder
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 08, 2021, 12:36:43 PM
I can't find the replenishment time/ability anywhere to reference, does anyone know where to find it so I can mess with it?

Look in the wing_data spreadsheet under "data\hulls" and mess with the values under the "refit" column. That will probably be a lot easier than attempting to use a hullmod/code for each carrier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 08, 2021, 01:08:32 PM
how the heck do I get a ships remaining PPT?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 08, 2021, 01:13:07 PM
Subtract ship.getTimeDeployedForCRReduction() from its max peak time (which you'd get from the ship's stats).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: beargasm on April 08, 2021, 02:29:01 PM
Hi all! Was hoping for a little assistance implementing LazyLib's CollectionUtil.filter method. I am having trouble setting up a filter.

Code
protected List<String> filters = Arrays.asList("comm_relay", "sensor_array", "nav_buoy")
protected void init(SectorEntityToken entity) {
        this.entity = entity;
        this.entityFaction = entity.getFaction();

        /* We get the tags off of the entity calling the function and then discard all tags but
        comm_relay, sensor_array, nav_buoy */
        tags = entity.getTags();
        tags.retainAll(filters);
 
       /* We make a list of all entities globally with a matching tag and then sort by proximity */
        nearby = Global.getSector().getEntitiesWithTag(tags.iterator().next());
        Collections.sort(nearby, new SortTokensByDistance(this.entity.getLocation()));

        /* And now we filter? */
        nearby = CollectionUtils.filter(nearby,
                new CollectionUtils.CollectionFilter<SectorEntityToken>() {
                    @Override
                    public boolean accept(SectorEntityToken sectorEntityToken) {
                        return sectorEntityToken.getFaction()==entityFaction;
                    }
                });
}
I think this is correct implementation, but that @override is confusing me. Also confusing is why I start getting syntax errors when I attempt to implement CollectionUtils.CollectionFilter. I thought that interfaces needed to be implemented by the class... It has been ~16 years since I used Java, so I am a little rusty.

Any info would be great. And if there is any feedback on why the above is messed up, inefficient, or if there are better ways to get a list of hackable entities of the same type and faction as the one being interacted with.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 09, 2021, 02:12:43 AM
Subtract ship.getTimeDeployedForCRReduction() from its max peak time (which you'd get from the ship's stats).

Huzzah! I have it working,but.... got a few questions about this...

pptMax = ship.getVariant().getHullSpec().getNoCRLossTime();

This nets me the max PPT of the hull combined with any hullmods that boost it, but how do I calculate the true value that includes PPT bonuses from skills?

I looked through com.fs.starfarer.api.impl.campaign.ids.Stats, but I can't seem to find anything that boosts PPT. Should I be checking ids.Skills instead?
If it is Skills, i'm not sure how I can access the PPT value specifically.


edit: seems its tracking the right value after all, I must have flubbed some numbers or something
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on April 09, 2021, 10:01:42 AM
Sorry to be a bother, but I've been digging and digging to try to understand Orbital Stations. Not going to put up a front here, I don't really know Java. I can do just enough to get a desired result. So I do get lost quite a bit when scrolling through code.

My issue right now is understanding how the OrbitalStation api is referencing a ship variant ID. For the life of me, I can't wrap my head around it. I wanted to add my own. Station for my faction. If it's beyond my level of understanding, that's cool. Just a question though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 09, 2021, 07:54:28 PM
Sorry to be a bother, but I've been digging and digging to try to understand Orbital Stations. Not going to put up a front here, I don't really know Java. I can do just enough to get a desired result. So I do get lost quite a bit when scrolling through code.

My issue right now is understanding how the OrbitalStation api is referencing a ship variant ID. For the life of me, I can't wrap my head around it. I wanted to add my own. Station for my faction. If it's beyond my level of understanding, that's cool. Just a question though.
It's specified in industries.csv data column.
e.g. midline orbital station
Code: json
{
radius:55,
variant:station1_midline_Standard,
fleetName:Orbital Station,
}
The weapons/fighter loadout is configured by the NPC autofitter ingame.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on April 09, 2021, 08:56:24 PM
@Histidine, I feel like a complete idiot. I don't know how many times I've went in the industries.csv looking for the variant ID! It never occurred to me stretch the fields to see if their was more information. The only thing I do is auto-fit the width. Sorry for wasting your time!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on April 10, 2021, 02:19:55 AM
Has comm directory generation (officer_for_hire / freeAdmin) changed to on-demand l(on-dock) like submarket (cargo / ships)?

Trying my HyperNET on 0.95a, and I seem to find officers/admins only in the system I am in. Any way to force generation? I am looking at entries of comms directory of each market.

Edit: Or is it so rare to find officers / admins early game now?

Edit 2: I am almost sure it's generated on-dock now. Had nothing in a planet, docked saw an officer, refreshed my intel and here he was...

Edit 3: Hist shown me OfficerManagerEvent.reportPlayerOpenedMarket which does the trick. Just need to fetch via listener manager as otherwise it keeps on adding new people every call :)

So um, solved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 10, 2021, 04:22:45 PM
Yeah, it's generated on-dock now, to make it easier to provide a reasonable selection of officers.

I'm not sure that using OfficerManagerEvent.reportPlayerOpenedMarket() to force generation here is a great idea. One of the benefits/consequences of doing it on-dock is that you no longer have to worry about keeping a "manageable" total number of officers. I guess it's probably ok with the numbers involved here? But offhand I don't know. Also, force-generating it vs just going there to check may produce different results since the RNG uses the current month as one of the seed components. Not necessarily a big deal...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on April 10, 2021, 05:09:06 PM
In the
Code
DamageListener.reportDamageApplied()
method is there a way to get the WeaponAPI or DamagingProjectileAPI?  So far all the testing I've done shows it as just a ShipAPI.  I don't think it's possible to track a unit of damage back to the originating weapon (or ship system) with the listener, but I wanted to verify that's correct before I start doing anything silly to try and tie it together.  Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 10, 2021, 05:14:01 PM
I think you're right, yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flacman3000 on April 11, 2021, 02:02:55 AM
assuming that i understand you correctly, you want to make a hullmod that does nothing at all, except display description to the player?
vanilla game already has such a hullmod you can look at - Shielded Cargo Holds
it does literally nothing, the only effect it has is triggered externally, in dialogue, when scanning for contraband, which works by checking whether a ship has a hullmod with a specific ID
change that ID and you have a dud
this is it's entire script:
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;

public class ShieldedCargoHolds extends BaseHullMod {
// nothing to do, just a marker hullmod
}

So essentially I leave the java file alone itself I leave that code alone and I just change the id and file name to something else is that what you mean? In the hullmod data file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 11, 2021, 02:21:46 AM
Is there anyway to use like a damagelistener to see when incoming damage will be fatal and use that to perform some operations prior to the ship actually being destroyed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on April 11, 2021, 06:17:51 AM
Is there anyway to use like a damagelistener to see when incoming damage will be fatal and use that to perform some operations prior to the ship actually being destroyed?

DamageListener (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/listeners/DamageListener.html) only reports when damage has already been applied.

Checking if a ship is reduced to low life after a hit is possible though, would this work for your purposes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 11, 2021, 06:25:35 AM
Damn, unfortunately not. I need to switch a ships collisionclass before it's actually destroyed. Checking for low life works, but not against stuff that would kill it outright or overkill before it reaches that threshold ( getting instagibbed with a reaper at 1000 hull or something like that)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on April 11, 2021, 07:12:06 AM
Hmm, there is also DamageTakenModifier (http://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/listeners/DamageTakenModifier.html) (which looks like it allows you to modify the target too), maybe you can use this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on April 11, 2021, 08:01:00 AM
How do the CONSERVE_4, CONSERVE_FOR_ANTI_ARMOR, and other CONSERVE_ tags actually affect AI behavior? Just wondering what the difference is between DO_NOT_CONSERVE, normal behavior, and CONSERVE is in concrete terms (if such a thing exists for the obviously very complex AI).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrMax on April 11, 2021, 08:49:29 AM
Hello, apologies if this has been asked before but is there any way to edit the effect of special items, specifically the range of the Hypershunt Tap?

Couldn't find anything in settings...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 11, 2021, 04:50:50 PM
How do the CONSERVE_4, CONSERVE_FOR_ANTI_ARMOR, and other CONSERVE_ tags actually affect AI behavior? Just wondering what the difference is between DO_NOT_CONSERVE, normal behavior, and CONSERVE is in concrete terms (if such a thing exists for the obviously very complex AI).

From my experience: (obviously no exact knowledge of the code involved here this is just what I've observed over time)

DO_NOT_CONSERVE allows the AI ship to empty the entire missile rack once a target in range is acquired. There was a small bug in 0.91a that has been corrected in 0.95a where the ship would still conserve one or two missiles but now it empties everything asap from what I see. The only thing keeping the AI from firing a missile under DO_NOT_CONSERVE is guidance/firing arcs vs the maneuverability of the target ship. So essentially it won't fire the rocket/torpedo if it doesn't think it can actually hit the target ship.

CONSERVE_ + number means the AI will operate under normal missile firing protocols until it reaches the designated number threshold and then it will be more strict with the remaining missiles. I'm not completely sure of the specifics about what triggers the AI to use a missile past the threshold except that I know a ship that is "panicked" (flanked by strong opponents - under attack by a large number of fighters, actively taking hull damage, etc) is more willing to fire them and is less picky about targets. The target ship being "vulnerable" (overloaded/high hard flux/lots of weapons disabled, etc) probably also factors in heavily here while under the CONSERVE behavior threshold.

CONSERVE treats the entire missile rack in the above way instead of setting a threshold.

CONSERVE_FOR_ANTI_ARMOR is new and I haven't tested it but I'd imagine the Breach SRM is the primary special case for it and the AI won't use the missile against shields at all - probably with a few caveats like being "panicked" just like how CONSERVE works.

Normal missile behavior seems to mean "fire if it makes sense" which roughly translates to: 1) can the target be hit? 2) Is it likely the hit will be efficient damage-type-wise? So for instance the AI ship with a Sabot under normal behavior would only fire enough sabots to win the flux war whereas an AI ship with a Sabot under CONSERVE might wait until its own flux is high or its being flanked and an AI ship with a Sabot under DO_NOT_CONSERVE just fires all the Sabots.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Midnight Kitsune on April 11, 2021, 06:18:49 PM
How do I prevent a ship from being used in my faction fleets while still allowing it to be built by my factories? Even with the ship weight at like .00001, I'm still seeing not only the ship in fleets, but multiples of them... >.<
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 11, 2021, 07:00:45 PM
Uhhh, well this is strange. I'm getting:

110  [main] INFO  com.fs.starfarer.settings.StarfarerSettings  - Loading settings
110  [main] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/config/settings.json)]
141  [main] ERROR com.fs.starfarer.StarfarerLauncher  - java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
   at java.lang.ClassLoader.loadLibrary(Unknown Source)
   at java.lang.Runtime.loadLibrary0(Unknown Source)
   at java.lang.System.loadLibrary(Unknown Source)
   at org.lwjgl.Sys$1.run(Sys.java:72)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
   at org.lwjgl.Sys.loadLibrary(Sys.java:87)
   at org.lwjgl.Sys.<clinit>(Sys.java:117)
   at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
   at com.fs.graphics.DisplayManager.Ò00000(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.detectResolutions(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.<init>(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.createUI(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Starting Starsector 0.95a-RC12 launcher
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Running in C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - OS: Windows 8.1 6.3
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Java version: 1.7.0_79 (64-bit)

 - When trying to launch Starsector. (I launched it fine just last night without any problems.)

So I have no idea what could be causing this. I saw this thread (http://fractalsoftworks.com/forum/index.php?topic=11605.0) which had something similar but the weird thing is that to my knowledge there has been 0 changes that would suddenly make this happen.

No graphics driver updates.

No windows updates.

No changes to Java.

Any ideas for what I should try? (I've restarteda couple of times and double checked that Windows Defender isn't stealing all my ram.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on April 12, 2021, 01:43:46 AM
141  [main] ERROR com.fs.starfarer.StarfarerLauncher  - java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
Is your lwjgl64.dll still in the proper location? (Something like <install directory>\starsector-core\native\windows\lwjgl64.dll)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on April 12, 2021, 01:53:13 AM
I would like to use some of the components in the custom production screen for a mod. Particularly interested in being able to put images in table cells, and sort the table on header click - are these possible with the current UI component APIs?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on April 12, 2021, 02:20:58 AM
How to check if Button in tooltipapi is clicked if it's not in an intel plugin?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on April 12, 2021, 05:18:31 AM
question
making custom campaign terrain
is it possible to make AI prefer to travel over that terrain? there doesn't seem to be any positive terrain ai flag. is creation of new terrain ai flags possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2021, 09:56:36 AM
Hello, apologies if this has been asked before but is there any way to edit the effect of special items, specifically the range of the Hypershunt Tap?

Couldn't find anything in settings...

It's not in settings, but there's a variable: ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS

The best way to modify it would be via your ModPlugin's onApplicationLoad() method.


How do I prevent a ship from being used in my faction fleets while still allowing it to be built by my factories? Even with the ship weight at like .00001, I'm still seeing not only the ship in fleets, but multiples of them... >.<

Hmm - that probably means it's the only ship for that role, in some circumstances? Or the only ship that's low-enough FP at some stage of fleet generation, possibly. Would setting its hullFrequency - in the .faction file - to 0 not do the job, though?

Uhhh, well this is strange. I'm getting:

110  [main] INFO  com.fs.starfarer.settings.StarfarerSettings  - Loading settings
110  [main] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/config/settings.json)]
141  [main] ERROR com.fs.starfarer.StarfarerLauncher  - java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
...
Any ideas for what I should try? (I've restarteda couple of times and double checked that Windows Defender isn't stealing all my ram.)

Have you tried reinstalling the game? I'd also check event viewer for errors just in case something on the system is going bad.

I would like to use some of the components in the custom production screen for a mod. Particularly interested in being able to put images in table cells, and sort the table on header click - are these possible with the current UI component APIs?

I don't believe that's possible, no - at least not without some kind of "render on top of the screen" hacking, or entirely custom UI components. (The latter *is* technically possible via CustomPanelAPI etc, but it's a ton of work.)

How to check if Button in tooltipapi is clicked if it's not in an intel plugin?

Fairly sure that the button won't even be clickable when it's not in an intel plugin, as by default tooltips don't process those kinds of events.
... ah, never mind that, you can call setForceProcessInput(true) so they would be.

Hmm - I don't think there's a very easy way. I think the best you could do is check for changes in its isChecked() status since that should change on each click, regardless of what kind of button it is.


question
making custom campaign terrain
is it possible to make AI prefer to travel over that terrain? there doesn't seem to be any positive terrain ai flag. is creation of new terrain ai flags possible?

I don't believe so - the best you could do, I think, would be to tell the NavigationModulePlugin to strategically avoid things that make it go into this terrain. While technically I think you could pass in anything for terrain flags, the AI wouldn't be aware of any new ones. It *is* possible to write a custom AI module that would be, but that's a whole other thing...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 12, 2021, 10:20:29 AM
Is it possible to reset a Ship using custom AI back to the base game implementation using ship.setShipAI()? I'm kinda stumped on what I would be passing in as a parameter if so
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2021, 10:23:23 AM
You can pass in the previous AI it was using, which you can retrieve using getShipAI().

Edit: to be a bit more clear, you'd want to save off the ship AI it was using before setting it to use a custom AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 12, 2021, 04:31:12 PM
Thanks for the replies!

Arrg! Turns out that I must have accidently click dragged the native directory into the graphics directory by mistake and not noticed - probably when I was deleting the log file. I moved it back to starsector-core and everything seems fine now. Phew!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on April 12, 2021, 05:50:22 PM
question
is it possible to change a point around which the drones from drone active system orbit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 12, 2021, 05:57:28 PM
So I tried adding a new effect to a skill (which worked in 0.9.1):
Code: java
	public static class AgentBonus implements CharacterStatsSkillEffect {
public static final int BONUS_AGENTS = 1;

@Override
public void apply(MutableCharacterStatsAPI stats, String id, float level) {
Global.getLogger(this.getClass()).info("Applying to " + id + ", " + stats.isPlayerStats());
stats.getDynamic().getStat("nex_max_agents").modifyFlat(id, BONUS_AGENTS);
}

@Override
public void unapply(MutableCharacterStatsAPI stats, String id) {
Global.getLogger(this.getClass()).info("Unapplying to " + id + ", " + stats.isPlayerStats());
stats.getDynamic().getStat("nex_max_agents").unmodify(id);
}

Result: After I learn either Officer Management or Officer Training, it absolutely spams my log with unapply messages, but the apply message is never shown:
854377 [Thread-3] INFO  exerelin.campaign.skills.NexSkills$AgentBonus  - Unapplying to officer_training_stats_4, false
854377 [Thread-3] INFO  exerelin.campaign.skills.NexSkills$AgentBonus  - Unapplying to officer_management_stats_3, false
854377 [Thread-3] INFO  exerelin.campaign.skills.NexSkills$AgentBonus  - Unapplying to officer_training_stats_4, false
854377 [Thread-3] INFO  exerelin.campaign.skills.NexSkills$AgentBonus  - Unapplying to officer_management_stats_3, false
854377 [Thread-3] INFO  exerelin.campaign.skills.NexSkills$AgentBonus  - Unapplying to officer_training_stats_4, false
854377 [Thread-3] INFO  exerelin.campaign.skills.NexSkills$AgentBonus  - Unapplying to officer_management_stats_3, false

EDIT: the messages appear even without me learning the skill, but if I do learn it I can get a version with the log message ending in true instead of false, also printed repeatedly

I tried creating two subclasses of AgentBonus and assigning one each to Officer Training and Officer Management (rather than them sharing the superclass). That didn't help.

Am I doing something wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 12, 2021, 06:10:25 PM
You can pass in the previous AI it was using, which you can retrieve using getShipAI().

Edit: to be a bit more clear, you'd want to save off the ship AI it was using before setting it to use a custom AI.

Okay, got it! Is there a way to see what key the player has bound for autopilot? I want to substitute it in a string (right now I have a status that says "Press U" for autopilot, but this won't be very helpful if it happens to have been changed... )I'm so close to getting this working exactly the way I want  :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2021, 06:39:12 PM
So I tried adding a new effect to a skill (which worked in 0.9.1):
...
EDIT: the messages appear even without me learning the skill, but if I do learn it I can get a version with the log message ending in true instead of false, also printed repeatedly

I tried creating two subclasses of AgentBonus and assigning one each to Officer Training and Officer Management (rather than them sharing the superclass). That didn't help.

Am I doing something wrong?

Hmm - I'm not sure - maybe something going wrong in the .skill file, like the wrong effect type? I don't think anything's changed that would prevent what you're doing from working; it's pretty much all the same stuff as far as how it's hooked up.


Okay, got it! Is there a way to see what key the player has bound for autopilot? I want to substitute it in a string (right now I have a status that says "Press U" for autopilot, but this won't be very helpful if it happens to have been changed... )I'm so close to getting this working exactly the way I want  :'(

SettingsAPI.getControlStringForEnumName("C2_TOGGLE_AUTOPILOT");

Should get you the string.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sozzer on April 12, 2021, 06:45:05 PM
Is there any way to make a custom item function as crew or marines?
I've been poking at the concept on and off for a while, but everything I've come up with just doesn't work, no matter what I do to it. I'm coming to be quite sure it's impossible, at least short of replacing every script calling for crew or marines to just call for commodities with the "crew" and "marines" tags respectively (which I don't want to do for... obvious reasons, seeing as that is TC territory), but I figure this would be the place to ask if I've overlooked something.

I realise this has been asked at least once before in this thread, but I'm hoping that some way may have been added with 0.95.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 12, 2021, 06:56:51 PM
How do I prevent a ship from being used in my faction fleets while still allowing it to be built by my factories? Even with the ship weight at like .00001, I'm still seeing not only the ship in fleets, but multiples of them... >.<

Setting the hull frequency to 0 in player.faction stops you from producing it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 12, 2021, 07:31:13 PM
Found my problem, needed to make the skills not have a requiredSkillLevel > 1. Welp.

Is there any way to make a custom item function as crew or marines?
I've been poking at the concept on and off for a while, but everything I've come up with just doesn't work, no matter what I do to it. I'm coming to be quite sure it's impossible, at least short of replacing every script calling for crew or marines to just call for commodities with the "crew" and "marines" tags respectively (which I don't want to do for... obvious reasons, seeing as that is TC territory), but I figure this would be the place to ask if I've overlooked something.

I realise this has been asked at least once before in this thread, but I'm hoping that some way may have been added with 0.95.
My recollection of Alex's past posts is that this is indeed straight up impossible, the references to crew and marines are hardcoded by ID in many places.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on April 12, 2021, 08:50:38 PM
What's the best way to block a ship or ship skin from appearing as an option for the military nanoforge production? Just HIDE_IN_CODEX isn't doing it, and I'm not seeing from tags, etc. how vanilla is blocking stuff like the Ziggurat. Is anything with rare_bp or another blueprint tag just... fair game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on April 13, 2021, 12:46:48 AM
Fairly sure that the button won't even be clickable when it's not in an intel plugin, as by default tooltips don't process those kinds of events.
... ah, never mind that, you can call setForceProcessInput(true) so they would be.

Hmm - I don't think there's a very easy way. I think the best you could do is check for changes in its isChecked() status since that should change on each click, regardless of what kind of button it is.
Great! that's a easy way for me LOL
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2021, 08:49:53 AM
What's the best way to block a ship or ship skin from appearing as an option for the military nanoforge production? Just HIDE_IN_CODEX isn't doing it, and I'm not seeing from tags, etc. how vanilla is blocking stuff like the Ziggurat. Is anything with rare_bp or another blueprint tag just... fair game?

If you add a "no_sell" tag that'll cover the military bar contact production contract. The "no_dealer" tag will cover the arms dealer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on April 13, 2021, 12:07:06 PM
How do I remove that Ziggurat thing always make me recognized by others?

How do I add a ship from an outdated mod?  I won't publish it, just want to use it myself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silveressa on April 13, 2021, 04:41:58 PM
I'm trying to mod the pristine nano forge to remove the pollution debuff it gives to planets, which file has the actual nano forges stats?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: azmodii on April 13, 2021, 09:35:05 PM
Hi all,

I'm wondering if there is a way to bypass the initial "launcher" screen (you know, the one with the "Play Starsector" button).

I'm building a launcher that can update mods automatically and browse mods and install them from within the launcher, and it works well enough but it looks like the main entry process executes some code to start the game and I can't for the life of me replicate that code.

Any help would be appreciated!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 14, 2021, 02:28:03 AM
How do I remove that Ziggurat thing always make me recognized by others?

How do I add a ship from an outdated mod?  I won't publish it, just want to use it myself.
For Ziggurat, see here (http://fractalsoftworks.com/forum/index.php?topic=20361.msg312065#msg312065)
(there's no way to do it in defs, since the tag is only added when the recoverable ship is created for player)

Adding a ship from an old mod (i.e. porting it to a new mod) should go about the same as adding a completely new ship to the new mod, see the wiki guide (https://starsector.fandom.com/wiki/Modding) or ask on Discord if you need help with that.

I'm trying to mod the pristine nano forge to remove the pollution debuff it gives to planets, which file has the actual nano forges stats?
There's some stats stuff in ItemEffectsRepo.java, but the pollution effect is handled by the heavy industry class (HeavyIndustry.java).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CoreWolff on April 14, 2021, 03:36:27 AM
Hi,

So, I have searched through the forums before asking this, they may have been asked before but I couldn't find definitive answers.

What's the correct way to calculate beam damage in an EveryFrameCombatPlugin?

if you're using advance with a float "amount", I've seen in different scripts:

beam.getDamage().computeDamageDealt(amount);
beam.getWeapon().getDamage().getDamage() * amount;
beam.getDamage().getDamage() * amount;

Or intervals and checking every 0.1f with getDerivedStats:
float interval_dmg = beam.getWeapon().getDerivedStats().getDps() / 10f;

I've seen one post earlier saying computeDamageDealt is unreliable, so don't use that. I've seen others saying the getDamage might not be taking into account skills etc either? So.... very confused!


Also, separate to the above but related, if you want to modify the damage of a beam is this the correct way to do that below? Some of the skill e.g. RangedSpecialization seem to do it this way.

DamageAPI damage = beam.getDamage();
String id = "damage_increase";
float DAMAGE_BONUS = 30f;
damage.getModifier().modifyPercent(id, DAMAGE_BONUS);


setMultiplier() also seems to manipulate the final damage but I wasn't sure of the differences there, is that meant to be related to different damage types vs armor, shields, etc?

Appreciate any answers to the above!  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 14, 2021, 08:37:46 AM
Hi all,

I'm wondering if there is a way to bypass the initial "launcher" screen (you know, the one with the "Play Starsector" button).

I'm building a launcher that can update mods automatically and browse mods and install them from within the launcher, and it works well enough but it looks like the main entry process executes some code to start the game and I can't for the life of me replicate that code.

Any help would be appreciated!

Ah - offhand, I'm not sure if it's possible or not. These parameters to the JVM should make it skip the launcher, but I'm not sure if it'll actually work or not. That code path is ancient and hasn't been trod in many a year.

-DlaunchDirect=true -DstartRes=1280x768 -DstartFS=false -DstartSound=true

You'd also have to save all the mod-related things in the right places in the registry, along with the other settings the launcher lets you manage...

What's the correct way to calculate beam damage in an EveryFrameCombatPlugin?

beam.getDamage().computeDamageDealt(amount);

That's the one you want. The amount passed in doesn't matter; it *should* return the accumulated damage on the frames the beam does deal damage, and 0 otherwise. And it should also correctly factor in the source ship's damage modifiers.

setMultiplier() also seems to manipulate the final damage but I wasn't sure of the differences there, is that meant to be related to different damage types vs armor, shields, etc?

It accounts for 1) frames where the beam isn't dealing damage (set to zero there) and otherwise, the charge level/brightness of the beam.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silveressa on April 14, 2021, 11:34:54 AM

There's some stats stuff in ItemEffectsRepo.java, but the pollution effect is handled by the heavy industry class (HeavyIndustry.java).
[/quote]

Thanks, and which folder do I look in to find that file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 14, 2021, 12:33:54 PM
There's some stats stuff in ItemEffectsRepo.java, but the pollution effect is handled by the heavy industry class (HeavyIndustry.java).

Thanks, and which folder do I look in to find that file?

Both are in: Starsector\starsector-core\starfarer.api.zip\com\fs\starfarer\api\impl\campaign\econ\impl
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CoreWolff on April 14, 2021, 12:54:34 PM

What's the correct way to calculate beam damage in an EveryFrameCombatPlugin?

beam.getDamage().computeDamageDealt(amount);

That's the one you want. The amount passed in doesn't matter; it *should* return the accumulated damage on the frames the beam does deal damage, and 0 otherwise. And it should also correctly factor in the source ship's damage modifiers.

setMultiplier() also seems to manipulate the final damage but I wasn't sure of the differences there, is that meant to be related to different damage types vs armor, shields, etc?

It accounts for 1) frames where the beam isn't dealing damage (set to zero there) and otherwise, the charge level/brightness of the beam.

Thank you, appreciate the answers!  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: azmodii on April 14, 2021, 03:38:15 PM
Hi all,

I'm wondering if there is a way to bypass the initial "launcher" screen (you know, the one with the "Play Starsector" button).

I'm building a launcher that can update mods automatically and browse mods and install them from within the launcher, and it works well enough but it looks like the main entry process executes some code to start the game and I can't for the life of me replicate that code.

Any help would be appreciated!

Ah - offhand, I'm not sure if it's possible or not. These parameters to the JVM should make it skip the launcher, but I'm not sure if it'll actually work or not. That code path is ancient and hasn't been trod in many a year.

-DlaunchDirect=true -DstartRes=1280x768 -DstartFS=false -DstartSound=true

You'd also have to save all the mod-related things in the right places in the registry, along with the other settings the launcher lets you manage...


Thanks Alex, worked like a charm! Appreciate the response
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 15, 2021, 02:20:27 AM
If I wanted to have an IntervalUtil used for a specific instance of a hull, what would be the best way to go about doing that? I've tried storing and retrieving one using customData tied to ships unique ID but this doesn't seem to work (i suspect because it's a hullmod script and im still setting the intervalUtil to a variable in the script, so every single ship with hullmod has access to it..) as when two ships of the same type fulfill the condition for the intervalutil to advance, it starts incrementing at 2x speed. I have a snippet below showing what i am currently doing:

Code
				engine.getCustomData().put("armaa_strikecraftRefitTime"+ship.getId(),DockingAI.getCarrierRefitRate());
engine.getCustomData().put("armaa_strikecraftIntervalUtil"+ship.getId(),new IntervalUtil(20f,20f));
float refitMod = (float)engine.getCustomData().get("armaa_strikecraftRefitTime"+ship.getId());

if(engine.getCustomData().get("armaa_strikecraftIntervalUtil"+ship.getId()) instanceof IntervalUtil)

if(BASE_REFIT == null)
BASE_REFIT =(IntervalUtil)engine.getCustomData().get("armaa_strikecraftIntervalUtil"+ship.getId());

BASE_REFIT.advance((amount*(ship.getHullLevel()*1.5f)*refitMod));
engine.getCustomData().put("armaa_strikecraftIntervalElapsed"+ship.getId(),BASE_REFIT.getElapsed());
BASE_REFIT.setElapsed((float)engine.getCustomData().get("armaa_strikecraftIntervalElapsed"+ship.getId()));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haka on April 16, 2021, 12:25:29 AM
When I set my doctrine to use my modded weapons from my own mod i'm working on them they just don't. Everything is checked, my ships populate the fleet lists, but the weapons are nowhere to be seen.

Same thing happens with auto-fit, including variants i've made that uses my custom weapons. When I use them it just ignores those slots completely despite me having the weapons in storage and listing them as being part of the variant. I can even outfit a ship with all my custom weapons and then save a new autofit variant, and when I go to assign it it will simply leave everythign blank.

On the other hand, doctrine uses the ships fine and so do the pirates after me giving them my full BP package as well.

I have no clue what I need to do to make the game actually use my weapons actually after assigning them to my doctrines/variants/load-outs
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 16, 2021, 10:42:17 AM
Is the dialogue/interaction bit that appears when you come across two fleets in a battle that don't trust you modifiable? Would I be able to say, add an option that consumes a story point to it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 17, 2021, 12:48:37 AM
I'm currently debugging an issue where newly formed NPC colonies in Nexerelin get from size 3 to size 4 almost immediately.

After hacking CoreImmigrationPluginImpl to print some debug messages, I found some strange behavior.
About half a day after the colony is formed (at next economy tick?), ImmigrationTask.doNextBatch calls CoreImmigrationPluginImpl.advance many times in a row, resulting in years of growth squeezed into a single frame.
Pastebin (https://pastebin.com/DAVw5jGN)
(the "<number> time" bit is the value of f in that advance call)

So, like, how do I make it not do that?

When I set my doctrine to use my modded weapons from my own mod i'm working on them they just don't. Everything is checked, my ships populate the fleet lists, but the weapons are nowhere to be seen.

Same thing happens with auto-fit, including variants i've made that uses my custom weapons. When I use them it just ignores those slots completely despite me having the weapons in storage and listing them as being part of the variant. I can even outfit a ship with all my custom weapons and then save a new autofit variant, and when I go to assign it it will simply leave everythign blank.

On the other hand, doctrine uses the ships fine and so do the pirates after me giving them my full BP package as well.

I have no clue what I need to do to make the game actually use my weapons actually after assigning them to my doctrines/variants/load-outs
Quick guess: Do your weapons have their autofit tags set? Like LMG has "pd6, kinetic3, SR"

Is the dialogue/interaction bit that appears when you come across two fleets in a battle that don't trust you modifiable? Would I be able to say, add an option that consumes a story point to it?
It's part of FleetInteractionDialogPluginImpl. So: moddable, but will have conflicts with the several other mods that change the fleet interaction dialog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on April 17, 2021, 03:39:45 AM
I was unable to find an answer elsewhere so here's a question:

Is there a way to slow down campaign speed/time compression? There's a "speed up" function in game, and it can be edited, but from what I see it can only speed up and at a minimum of 2x.

Other people want to make things faster but in my case, I want to make things slower.

Thank you in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 17, 2021, 12:17:27 PM
If I wanted to have an IntervalUtil used for a specific instance of a hull, what would be the best way to go about doing that? I've tried storing and retrieving one using customData tied to ships unique ID but this doesn't seem to work (i suspect because it's a hullmod script and im still setting the intervalUtil to a variable in the script, so every single ship with hullmod has access to it..) as when two ships of the same type fulfill the condition for the intervalutil to advance, it starts incrementing at 2x speed. I have a snippet below showing what i am currently doing:

See: com.fs.starfarer.api.impl.hullmods.SharedFluxSink for an example. Basically you want all your data to be stored in customdata and none of it in member variables, for the reason you say.


Is the dialogue/interaction bit that appears when you come across two fleets in a battle that don't trust you modifiable? Would I be able to say, add an option that consumes a story point to it?

Not super easily. It *is* modifiable but not in a way that makes it easy for multiple mods to make changes the it. The best bet might might to show a custom interaction dialog on that interaction (via CampaignPlugin.pickInteractionDialogPlugin()) and then restarting the interaction... somehow.


I'm currently debugging an issue where newly formed NPC colonies in Nexerelin get from size 3 to size 4 almost immediately.

After hacking CoreImmigrationPluginImpl to print some debug messages, I found some strange behavior.
About half a day after the colony is formed (at next economy tick?), ImmigrationTask.doNextBatch calls CoreImmigrationPluginImpl.advance many times in a row, resulting in years of growth squeezed into a single frame.
Pastebin (https://pastebin.com/DAVw5jGN)
(the "<number> time" bit is the value of f in that advance call)

So, like, how do I make it not do that?

Hmm - I'm guessing you have a custom plugin in Nex? Since this isn't a problem in vanilla.

The "uiUpdateOnly" parameter for the plugin should be true when it's called like that, I suspect. The plugin should not actually add to the population growth when this is true, but should only update the various stats that impact it so that the tooltips etc can show up-to-date values.

I was unable to find an answer elsewhere so here's a question:

Is there a way to slow down campaign speed/time compression? There's a "speed up" function in game, and it can be edited, but from what I see it can only speed up and at a minimum of 2x.

Other people want to make things faster but in my case, I want to make things slower.

Thank you in advance.

I don't think so. You could make fleets move more slowly, but not actually make time pass more slowly. There *is* an internal core variable - CampaignClock.SECONDS_PER_GAME_DAY - so you might be able to set it with a code call, but it's in obfuscated code so I hesitate to suggest it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xeno056 on April 17, 2021, 07:24:36 PM
So this is more "tweaking existing files" as opposed to plugins, but is there any way to fiddle around with the spawn rate of planets and/or system sizes? I keep getting single cat five planets with nary even a barren world to industrialize. I changed around some values in the planet generation csv but didn't get anything tangable from other old systems I made when starting a new game. So 1, it's in code deep and dark enough that the big boys haven't bother to mod it or 2, It's easy enough to tweak that no one has made a mod about it or 3, other.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 17, 2021, 07:51:33 PM
I have gotten into the proc-gen code and I can tell you it is arcane. You can mod the /campaign/procgen files pretty easily, but they work in broad strokes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xeno056 on April 17, 2021, 08:45:51 PM
I have gotten into the proc-gen code and I can tell you it is arcane. You can mod the /campaign/procgen files pretty easily, but they work in broad strokes.
Yeah I figured as much. Looks like my problem was editing the wrong value:habOffsetMin and not frequency, which is what I assume I want to change. D'oh. Any way to change number of planets in system from there that I'm missing? Or is that the .jsons? Either way thank you very much.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 17, 2021, 08:55:42 PM
Hmm - I'm guessing you have a custom plugin in Nex? Since this isn't a problem in vanilla.

The "uiUpdateOnly" parameter for the plugin should be true when it's called like that, I suspect. The plugin should not actually add to the population growth when this is true, but should only update the various stats that impact it so that the tooltips etc can show up-to-date values.
I haven't modified CoreImmigrationPluginImpl or PopulationComposition beyond the debug messages though, that's the thing. One of the other mods I'm using might have done it, but I don't know who'd even want to do so.

Testing notes:
The above results were from a game played with Nexerelin (and other mods) from the start, colony created in cycle 214. Has bug.
New Nex game (no other major mods), colony created in cycle 206: No bug. (EDIT: Actually no, it does reach 100% growth progress, Nex just wasn't increasing colony size in response)
Loaded Nex (and no other major mods) into existing vanilla save, colony created in cycle 213: Bug.

Which supports my vague hypothesis that some class in the call stack (ReachEconomyStepper?) sees that a market has been added multiple cycles in the game and calls the immigration task repeatedly in order to "catch up". But eyeballing ReachEconomyStepper and ImmigrationTask didn't suggest a place where this would be happening.

EDIT: No, that's not it. It's also happening in the cycle 206 colony and I have no idea why aaaa

Well, I already have a workaround in mind (if colony growth progress reaches 100% within X days of founding, reset it) which I'll try.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 18, 2021, 10:29:29 AM
I'm trying to manually set a growth limit to a single colony - as in, not letting it grow past a specified size.

Am I missing an obvious function, or is there no way to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 18, 2021, 11:24:01 AM
Use an EveryFrameScript and do:

Code: java
market.getPopulation().setWeight(getWeightForMarketSizeStatic(desiredSize));
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 18, 2021, 11:28:51 AM
Thanks a lot!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on April 18, 2021, 12:45:10 PM
Is there any easy way of making a ship system spawn a drone at a target location instead of from the ship's hull?

I basically want to spawn a drone/autonomous ship like one places a doom mine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haka on April 18, 2021, 03:47:26 PM
Quick guess: Do your weapons have their autofit tags set? Like LMG has "pd6, kinetic3, SR"
Derp.

Thanks, and thanks for all the work, especially with the quick update turn around on Nex.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on April 19, 2021, 07:31:05 AM
Code: java
public class PLIntel extends BaseIntelPlugin {
public void createLargeDescription(CustomPanelAPI panel, float width, float height) {
TooltipMakerAPI info = panel.createUIElement(width, height, false);
panel.addUIElement(info).inTL(0, 0);

// sorry
info.addPlaythroughDataPanel(width, height);
}
}
Oh... well, it's Ok, Alex, I understand. But, just to make sure, is there any way for us to use the great looking elements on display in the playthrough log intel?

Is there any easy way of making a ship system spawn a drone at a target location instead of from the ship's hull?

I basically want to spawn a drone/autonomous ship like one places a doom mine.
Sounds like you might want to check out Global.getCombatEngine().getFleetManager().spawnShipOrWing()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on April 19, 2021, 09:31:16 AM
In the
Code
DamageListener.reportDamageApplied()
method is there a way to get the WeaponAPI or DamagingProjectileAPI?  So far all the testing I've done shows it as just a ShipAPI.  I don't think it's possible to track a unit of damage back to the originating weapon (or ship system) with the listener, but I wanted to verify that's correct before I start doing anything silly to try and tie it together.  Thanks!
I think you're right, yes.

I'm able to parse apart what's happening with the DamageListener when the damage comes from a DamagingProjectileAPI but when the damage comes from a BeamAPI I'm having trouble.  From what I can tell with beams, multiple damages caused by the same type of weapon are usually only reported once (like if you have an Eagle with 3 gravitron beams hitting the same target, there will be only one DamageListener event.)  But even when there are many dissimilar beams hitting the same target, if all the beams do the same damage type, most of the time there will be only one reported event to the DamageListener. 

Maybe there's a bug in the listener code with regards to beams?  Also regarding the DamageListener interface, if the reportDamageApplied method could also include the WeaponAPI that caused the damage, not only would it make the stuff I'm doing in my mods easier it might enable other mod authors to do some weird on-hit stuff with some weapons.  (If there's not already a way to do that sort of thing)

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on April 19, 2021, 02:04:29 PM
Hello Alex. How would you decrease the quality of ships (fleets and submarket) globally? I'd love to make pristine ships very rare but have no idea where to start looking at.

Found it - qualityPerDmods setting - set it to something low.

Also, how can I change the buying price of d-modded ships? We have "hullWithDModsSellPriceMult" but not "hullWithDModsBuyPriceMult" (seems to be hardcoded to 0.8 per d-mod).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2021, 03:18:01 PM
EDIT: No, that's not it. It's also happening in the cycle 206 colony and I have no idea why aaaa

Well, I already have a workaround in mind (if colony growth progress reaches 100% within X days of founding, reset it) which I'll try.

Hmm, weird! Nothing comes to mind as far as any sort of "catch up" code in vanilla. Well - let me know if there's anything you want me to have a look at?



Is there any easy way of making a ship system spawn a drone at a target location instead of from the ship's hull?

I basically want to spawn a drone/autonomous ship like one places a doom mine.

I'm not sure if there's  an elegant-er way of doing it, but at a minimum you could probably have a script that detects when the drone spawns and moves it wherever you like.


Code: java
public class PLIntel extends BaseIntelPlugin {
public void createLargeDescription(CustomPanelAPI panel, float width, float height) {
TooltipMakerAPI info = panel.createUIElement(width, height, false);
panel.addUIElement(info).inTL(0, 0);

// sorry
info.addPlaythroughDataPanel(width, height);
}
}
Oh... well, it's Ok, Alex, I understand. But, just to make sure, is there any way for us to use the great looking elements on display in the playthrough log intel?

Ah - not to repeat the comment, but - sorry :(



In the
Code
DamageListener.reportDamageApplied()
method is there a way to get the WeaponAPI or DamagingProjectileAPI?  So far all the testing I've done shows it as just a ShipAPI.  I don't think it's possible to track a unit of damage back to the originating weapon (or ship system) with the listener, but I wanted to verify that's correct before I start doing anything silly to try and tie it together.  Thanks!
I think you're right, yes.

I'm able to parse apart what's happening with the DamageListener when the damage comes from a DamagingProjectileAPI but when the damage comes from a BeamAPI I'm having trouble.  From what I can tell with beams, multiple damages caused by the same type of weapon are usually only reported once (like if you have an Eagle with 3 gravitron beams hitting the same target, there will be only one DamageListener event.)  But even when there are many dissimilar beams hitting the same target, if all the beams do the same damage type, most of the time there will be only one reported event to the DamageListener. 

Maybe there's a bug in the listener code with regards to beams?  Also regarding the DamageListener interface, if the reportDamageApplied method could also include the WeaponAPI that caused the damage, not only would it make the stuff I'm doing in my mods easier it might enable other mod authors to do some weird on-hit stuff with some weapons.  (If there's not already a way to do that sort of thing)

Thanks!

Maybe you're just seeing the beam damage events reported every 1/10th of a second, and they don't line up on the same frame? Haven't looked at the code, but it's *really* hard to imagine how beam damage from multiple beams would accidentally get aggregated and/or only reported once. That'd take some real work and a bunch of code.

Re: passing in a WeaponAPI: duly noted! Would involve passing it through a bunch of method calls that currently don't have it, though. ... perhaps adding it to DamageAPI might be the way to go. I'll make a note.


Hello Alex. How would you decrease the quality of ships (fleets and submarket) globally? I'd love to make pristine ships very rare but have no idea where to start looking at.

Found it - qualityPerDmods setting - set it to something low.

That's not quite what you want, I don't think. E.G. if you set it to 0.05 then a ship with 0.8 quality would get 4 d-mods. But a ship with 1.0 quality would still have 0-1 d-mods, and so on.

Some fleets spawned by the game just have a fixed quality, too, so they wouldn't be affected.

I think the best way to do this would be to apply a quality modifier to all colonies. Something like what PopulationAndInfrastructure does:

float stabilityQualityMod = FleetFactoryV3.getShipQualityModForStability(stability);
market.getStats().getDynamic().getMod(Stats.FLEET_QUALITY_MOD).modifyFlatAlways(getModId(0), stabilityQualityMod, "Stability");

That'd... affect just about everything, except fleet spawns where quality is fixed.


Also, how can I change the buying price of d-modded ships? We have "hullWithDModsSellPriceMult" but not "hullWithDModsBuyPriceMult" (seems to be hardcoded to 0.8 per d-mod).

I don't think you can; there's just a mult the ship buy price, but whether it has d-mods doesn't look like it's factored in at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on April 19, 2021, 05:06:12 PM
In the
Code
DamageListener.reportDamageApplied()
method is there a way to get the WeaponAPI or DamagingProjectileAPI?  So far all the testing I've done shows it as just a ShipAPI.  I don't think it's possible to track a unit of damage back to the originating weapon (or ship system) with the listener, but I wanted to verify that's correct before I start doing anything silly to try and tie it together.  Thanks!
I think you're right, yes.

I'm able to parse apart what's happening with the DamageListener when the damage comes from a DamagingProjectileAPI but when the damage comes from a BeamAPI I'm having trouble.  From what I can tell with beams, multiple damages caused by the same type of weapon are usually only reported once (like if you have an Eagle with 3 gravitron beams hitting the same target, there will be only one DamageListener event.)  But even when there are many dissimilar beams hitting the same target, if all the beams do the same damage type, most of the time there will be only one reported event to the DamageListener. 

Maybe there's a bug in the listener code with regards to beams?  Also regarding the DamageListener interface, if the reportDamageApplied method could also include the WeaponAPI that caused the damage, not only would it make the stuff I'm doing in my mods easier it might enable other mod authors to do some weird on-hit stuff with some weapons.  (If there's not already a way to do that sort of thing)

Thanks!

Maybe you're just seeing the beam damage events reported every 1/10th of a second, and they don't line up on the same frame? Haven't looked at the code, but it's *really* hard to imagine how beam damage from multiple beams would accidentally get aggregated and/or only reported once. That'd take some real work and a bunch of code.

Re: passing in a WeaponAPI: duly noted! Would involve passing it through a bunch of method calls that currently don't have it, though. ... perhaps adding it to DamageAPI might be the way to go. I'll make a note.

Ah, that makes a bit more sense  Any thoughts on the best way of when to check for if a beam should have done damage during a frame?  There's BeamAPI.didDamageThisFrame() but I haven't noticed that lining up with the data in the listeners, but I'll look at it again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 19, 2021, 05:32:30 PM
Any way to change number of planets in system from there that I'm missing? Or is that the .jsons?

Number of planets in a system is determined by minOrbits and maxOrbits in star_gen_data.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on April 19, 2021, 06:25:06 PM
Way to modify value of exploration missions?
Like derelict/station scan or surveying a planet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 20, 2021, 02:50:38 AM
Alright, so I got an Industry that can change its upgrade dynamically (including into most every vanilla building).
The goal is to seed this thing on worlds with ruins, and have it be "repairable" into another building at half cost/time.

Is there a way to override upgrade cost and time for the specific upgrade instance?


Edit - successfully circumvented the issue, all is well!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zudgemud on April 20, 2021, 08:22:47 AM
Is there any easy way of making a ship system spawn a drone at a target location instead of from the ship's hull?

I basically want to spawn a drone/autonomous ship like one places a doom mine.

I'm not sure if there's  an elegant-er way of doing it, but at a minimum you could probably have a script that detects when the drone spawns and moves it wherever you like.

Sounds like you might want to check out Global.getCombatEngine().getFleetManager().spawnShipOrWing()

Thanks for the answers, more complicated than I would like but I will look into it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 20, 2021, 12:03:03 PM
Way to modify value of exploration missions?
Like derelict/station scan or surveying a planet?

<checks> these look like they're actually hardcoded; apologies. The only way to modify their value would be to provide an alternate implementation of them. I should really extract the reward parameters at some point...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 20, 2021, 07:57:53 PM
Is getNumFighterBays(FleetMemberAPI data) from BaseSkillEffectDescription called anywhere in the source code outside of skills?

Use case for context:
Spoiler
I'm extending BaseSkillEffectDescription for my TC to do the following: (among other things)

When calculating the number of fighter bays to match against the total bay threshold, I want to skip any ships that are not carriers or have built in bays - similar to how the code already skips mothballed ships in the calculation.

The problem is that getNumFighterBays(FleetMemberAPI data) is a static method and so cannot be directly overridden by my child class due to java's rules on polymorphism.

I can circumvent this by overloading the method (I think anyway I haven't tried) or more simply/safely creating my own private method in my child class to do the same thing and call that method in the overridden non-static methods of the super class instead.

When viewing usages of getNumFighterBays(FleetMemberAPI data) I only see two and both are on the table to be overridden. My potential problem could be if that method has other calls obscured in the source code that could break things or return unexpected results somehow... though to be honest I can't quite think of a scenario in which that would happen.

Anyway, just trying to play it safe or at the very least know what I am getting myself into, heh.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on April 21, 2021, 01:58:06 AM
Way to modify value of exploration missions?
Like derelict/station scan or surveying a planet?

<checks> these look like they're actually hardcoded; apologies. The only way to modify their value would be to provide an alternate implementation of them. I should really extract the reward parameters at some point...

(https://i.imgur.com/aB63iU9.jpg)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haka on April 21, 2021, 09:19:28 PM
I've got a ship system that is meant to functionally turn a capitol carrier into a deployable mobile station, but i'm wondering if there is ANY existing AI that would make it move to a more populated area before deploying, instead of activating it immediately at the back of the map and sitting there. At the moment it is a pure toggle (Unlimited Duration) with a short but non-instant start-up and a considerable cooldown.

Just wondering if there's anything existing that would work or if i'm going to have to learn how to do a custom AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Commonwheat on April 22, 2021, 09:14:54 AM
where can i take a look at the BURN_DRIVE aiType script? or other ship system aiTypes for that matter
i want to do a custom AI because a ship system i have just won't work with any of the existing ones i tried in the hands of the AI, so i wanted to take a look at how some of the existing AIs work as reference but i just can't find them
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 22, 2021, 03:38:38 PM
I've got a ship system that is meant to functionally turn a capitol carrier into a deployable mobile station, but i'm wondering if there is ANY existing AI that would make it move to a more populated area before deploying, instead of activating it immediately at the back of the map and sitting there. At the moment it is a pure toggle (Unlimited Duration) with a short but non-instant start-up and a considerable cooldown.

Just wondering if there's anything existing that would work or if i'm going to have to learn how to do a custom AI.

You're probably going to have to write a custom AI. I can get you started a bit though.

1) Create a script that extends ShipSystemAIScript and provide an implementation of the "advance" method. This method runs roughly every frame, so you will need to set up an IntervalUtil to track how often the script is run. This will save on performance.

2) Point your ship system AI to the new script.

3) In the script, determine what to analyze in order to determine whether to use the system. LazyLib's CombatExtensionsKit has a method to get all enemy ships within a range that you can determine. The higher the range the more iterations so I would be prudent for performance. I set up a rudimentary weight system to determine how threatening the ships are based upon their deployment cost. The system also weights by hullsize so that capitals are considered a greater threat than frigates. Here is an example: (Keep in mind that copy pasting this won't work out of the box. You will have to adjust things and create your own implementation. This is just for a general reference to start.)

Spoiler
    private static boolean assessNearbyThreats(ShipAPI ship, ShipwideAIFlags flags, float noVentDuration) {

        List<ShipAPI> shipList = CombatExtensionsKt.getNearbyEnemies(ship, nearbyShipAssessmentRange);
        double weight = 0;
        for(ShipAPI enemyShip : shipList) {
            switch (enemyShip.getHullSize()) {
                case FIGHTER:
                    break;
                case FRIGATE:
                    weight += (frigateWeight * enemyShip.getMutableStats().getSuppliesToRecover().getBaseValue());
                    break;
                case DESTROYER:
                    weight += (destroyerWeight * enemyShip.getMutableStats().getSuppliesToRecover().getBaseValue());
                    break;
                case CRUISER:
                    weight += (cruiserWeight * enemyShip.getMutableStats().getSuppliesToRecover().getBaseValue());
                    break;
                case CAPITAL_SHIP:
                    weight += (capitalWeight * enemyShip.getMutableStats().getSuppliesToRecover().getBaseValue());
                    break;
                default:
                    break;
            }
        }
        if (weight >= weightThreshold) {
            flags.setFlag(ShipwideAIFlags.AIFlags.DO_NOT_VENT, noVentDuration);
            flags.setFlag(ShipwideAIFlags.AIFlags.KEEP_SHIELDS_ON, noVentDuration);
            if (LOG_INFO) {
                DecimalFormat round = new DecimalFormat("#.##");
                LOG.info("Threat assessment returned true. NearbyFleetStrength: " + Double.valueOf(round.format(weight))
                        + " ---- Ship won't vent flux AI flag: " + flags.hasFlag(ShipwideAIFlags.AIFlags.DO_NOT_VENT)
                        + " ---- Ship keeps shields up AI flag: " + flags.hasFlag(ShipwideAIFlags.AIFlags.KEEP_SHIELDS_ON));
            }
            return true;
        } else {
            if (weight >= (weightThreshold / weightThresholdNoVentDivisor)) {
                flags.setFlag(ShipwideAIFlags.AIFlags.DO_NOT_VENT, noVentDuration);
            }
            if (weight >= (weightThreshold / weightThresholdKeepShieldsRaisedDivisor)) {
                flags.setFlag(ShipwideAIFlags.AIFlags.KEEP_SHIELDS_ON, noVentDuration);
            }
            if (LOG_INFO) {
                DecimalFormat round = new DecimalFormat("#.##");
                LOG.info("Threat assessment returned false. NearbyFleetStrength: " + Double.valueOf(round.format(weight))
                        + " ---- Ship won't vent flux AI flag: " + flags.hasFlag(ShipwideAIFlags.AIFlags.DO_NOT_VENT)
                        + " ---- Ship keeps shields up AI flag: " + flags.hasFlag(ShipwideAIFlags.AIFlags.KEEP_SHIELDS_ON));
            }
            return false;
        }
    }
[close]

This AI isn't a toggle and I also track other things like hull damage, etc, so yours will definitely look different. My advice is to measure nearby enemies and perform a threat assessment like above, and then when the value falls below the assessment threshold you would toggle the system back to the carrier. That's just what I would do though. You might have more nuanced ideas and it's pretty fun to play around with use cases in my experience. Also you can ignore the AI flag part of the code since that is the AI making a determination about whether to vent or keep its shields up based upon a lower threshold than system activation.

4) When your above implementation of the script returns true, first check if the ship is in station mode (to prevent infinite toggling) and if it isn't - toggle the system using: ShipAPI.useSystem();

5) When your implementation of the script returns false (threats have left or been destroyed), check if the ship is in carrier mode and if not, toggle the system.

That's a very rough overview of how I would approach what you are trying to do. The extra details you will need will have to come from trial and error.  :)

Hope that helps!

where can i take a look at the BURN_DRIVE aiType script? or other ship system aiTypes for that matter
i want to do a custom AI because a ship system i have just won't work with any of the existing ones i tried in the hands of the AI, so i wanted to take a look at how some of the existing AIs work as reference but i just can't find them

I think the only example that is available is the FastMissileRacksAI under shipsystems\scripts\ai but that will get you started on the basics of how to set up an AI in the first place, and then you can create your own.

It probably doesn't need to be said that AI is very complicated. My use case is essentially "Ship in trouble? Activate super system!" and the AI to perform that relatively simple analysis is like 500 lines of code with a fair amount of moving parts.

My advice to you and the above poster - Log log log! It will save you a lot of time. ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2021, 04:19:52 PM
Is getNumFighterBays(FleetMemberAPI data) from BaseSkillEffectDescription called anywhere in the source code outside of skills?

It only gets called from FighterUplink, looks like.


Re: ship system AI scripts: there's:

data.shipsystems.scripts.ai.FastMissileRacksAI

That's not actually used but is there as an example that might help you get started.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 22, 2021, 05:43:16 PM
Is getNumFighterBays(FleetMemberAPI data) from BaseSkillEffectDescription called anywhere in the source code outside of skills?

It only gets called from FighterUplink, looks like.


Thanks good to know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Flacman3000 on April 23, 2021, 12:44:55 AM
I'm still in my infancy but I have no idea how to make a dud hull mod that does literally nothing but have text on it and an image of said icon. I was told to look at the shielded cargo holds for a solid example but after changing the name and descriptions I always got an error even after correcting obvious issues. Can anyone give me some pointers?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 23, 2021, 07:38:55 AM
I'm still in my infancy but I have no idea how to make a dud hull mod that does literally nothing but have text on it and an image of said icon. I was told to look at the shielded cargo holds for a solid example but after changing the name and descriptions I always got an error even after correcting obvious issues. Can anyone give me some pointers?
Might be easier to ask in the #modder_bootcamp channel on Discord. But first thing you do when you get an error is look at starsector.log, that'll usually identify the problem.

Fairly sure that the button won't even be clickable when it's not in an intel plugin, as by default tooltips don't process those kinds of events.
... ah, never mind that, you can call setForceProcessInput(true) so they would be.

Hmm - I don't think there's a very easy way. I think the best you could do is check for changes in its isChecked() status since that should change on each click, regardless of what kind of button it is.
So I tried doing this, but I can't figure a good way to detect when the button is pressed. When clicking on a regular button (but notably, not an AreaCheckbox), no mouse down/up event is passed to my custom panel plugin's processInput method. Thus, the plugin doesn't realize it's supposed to check the button state (specifically, call ButtonAPI.isChecked() for all buttons and compare it to the cached value).
Whether or not I call setForceProcessInput on the button's containing TooltipMakerAPI doesn't seem to affect it.

Should I just bite the bullet and do the state check in advance?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2021, 07:57:34 AM
Should I just bite the bullet and do the state check in advance?

Yeah, definitely. It's not a performance concern.

(You wouldn't get the mouse up/down events passed in because they'd be .consume()'d by the button when it reacts to them, btw.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on April 23, 2021, 08:13:45 AM
Is there a way to find out after a battle (specifically, in BaseCampaignEventListener.reportPlayerEngagement()) if there was a bounty on the enemy fleet? Looked in PersonBountyIntel and related classes but could not find any reference to the bounty target.

Checking the enemy CampaignFleetAPI.getEventListeners() for instances of MilitaryCustomBounty, PirateSystemBounty, etc. seems like an option, but it does not feel quite proper.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haka on April 23, 2021, 09:17:21 PM
My advice to you and the above poster - Log log log! It will save you a lot of time. ;D
You mean using starsector.log or having an editing/development log, logging progress, changes, etc. or something else?
I've definitely got a few notebooks with sketches and notes in them, but nothing as in-depth as a coder's log. I have previously kept logs for modding but so far I haven't for Starsector or for scripting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on April 23, 2021, 11:24:11 PM
Are visible, turret weapons supported for fighters?  All of the examples I have checked of vanilla fighters have them all hidden.  I was attempting to make a specific fighter turret weapon (extra small) but would like to know if it is possible to put this type of weapon on a fighter class ship.  Thx.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MesoTroniK on April 24, 2021, 12:24:29 AM
Are visible, turret weapons supported for fighters?  All of the examples I have checked of vanilla fighters have them all hidden.  I was attempting to make a specific fighter turret weapon (extra small) but would like to know if it is possible to put this type of weapon on a fighter class ship.  Thx.
Yes they are and done on some vanilla fighters even. A notable low hanging fruit example is the Gladius.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on April 24, 2021, 01:08:40 AM
Is there a way to render below all weapons(like decorative weapons)...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on April 24, 2021, 06:09:52 AM
I am trying to use the WeaponGroupAPI.removeWeapon(Int: index)-method.
However, when I supply an index smaller than the number of weapons in the group, the method always returns null and the number of elements in the weapon group doesn't change.
Just for fun I tried to supply an index larger than the number of weapons, which produces an OutOfBounds (or so) Exception.
I assume this is not the correct behavior?
Or am I doind something wrong?

Update:
I was also wondering: I want my mod to do stuff when ALT+WeaponGroupKey (e.g. ALT+3) gets pressed. But when the Event for 3 "arrives" in my mod, it has already been consumed (presumably by the base game). Is there any other way I can get the information that 3 has been pressed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on April 25, 2021, 01:37:37 PM
My advice to you and the above poster - Log log log! It will save you a lot of time. ;D
You mean using starsector.log or having an editing/development log, logging progress, changes, etc. or something else?
I've definitely got a few notebooks with sketches and notes in them, but nothing as in-depth as a coder's log. I have previously kept logs for modding but so far I haven't for Starsector or for scripting.

I was talking about setting up a logger in your code to send information to starsector.log so you can track the information in the AI while it is running. Example:

Spoiler
    // Logger.
    private static final Logger LOG = Global.getLogger(AO_FluxConverterAI.class);
    private static final boolean LOG_INFO = false;

             if (LOG_INFO ) {
                 if (system.getAmmo() == system.getMaxAmmo() && nearbyThreats) {
                        LOG.info("Ship was at maximum charges and nearby threats were significant.");
                    }
                    if (hullDamageActivatesSystem) {
                        LOG.info("System was activated from hull damage.");
                    }
                }
[close]
- Stuff like this is important to track data, code logic workflow, etc. For context from the example, my system was designed so that the first charge can be used offensively and the remaining charges are used defensively. The log lets me know that this is working correctly because I should ideally see the statement about max charges in the start of a simulation battle - and then I shouldn't see it afterwards unless enough time passes that the system gets back to full charges. If I do, something has gone awry that I need to investigate. This gets more important as the complexity of the code increases.

Logging each component of when the system activates lets me know why the system activated so I can analyze the battle context to ensure that the AI is working as intended. I set up tracking so that if the ship is taking continuous damage it activates the system. If I see the ship take a bunch of hits to hull and the system doesn't activate, I can look at the log to see details of why. Is it not reaching that part of the code? Is the counter not being increased? Stuff like that.

Final note:
The if (LOG_INFO) is important because logging messages every few frames will fill up the logs very, very quickly. So its a good idea to set up the logging to only log things when you, yourself are testing everything out. After you know its working well, you can just change the boolean to no longer log all the details. That is a good courtesy for other modders. What you do and do not log consistently is something of a judgement call. I generally try and only log errors that ideally shouldn't happen in a release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 26, 2021, 02:04:50 AM
If I want a person mission to not show up again for some time after being accepted, I should increase the min timeout and max timeout columns in the CSV, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 26, 2021, 09:21:00 AM
I am trying to use the WeaponGroupAPI.removeWeapon(Int: index)-method.
However, when I supply an index smaller than the number of weapons in the group, the method always returns null and the number of elements in the weapon group doesn't change.
Just for fun I tried to supply an index larger than the number of weapons, which produces an OutOfBounds (or so) Exception.
I assume this is not the correct behavior?
Or am I doind something wrong?

Update:
I was also wondering: I want my mod to do stuff when ALT+WeaponGroupKey (e.g. ALT+3) gets pressed. But when the Event for 3 "arrives" in my mod, it has already been consumed (presumably by the base game). Is there any other way I can get the information that 3 has been pressed?

Ahh! Looks like that method was bugged; fixed it up. Basically it was doing the index check backwards and only trying to remove the weapon if the index was out of bounds.

Re: ALT + etc - you could use:
Keyboard.isKeyDown(Keyboard.KEY_LMENU)

Though that's looking at keyboard state not events. But if the e.g. "3" is consumed by the base game, that means it's already acted on it (in this case, probably by selecting a weapon group) and you couldn't undo that.

If I want a person mission to not show up again for some time after being accepted, I should increase the min timeout and max timeout columns in the CSV, right?

That should do it, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick XR on April 26, 2021, 10:45:25 AM
What's the best way to check if a campaign simulation has ended?  I don't see any events to tap into (Like the reportPlayerEngagement method), and the game would be paused so I don't think there's an advance I could check either.  There are state variables I could check, but I would need the checking function to be called on the refit screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on April 26, 2021, 01:41:28 PM
Ahh! Looks like that method was bugged; fixed it up. Basically it was doing the index check backwards and only trying to remove the weapon if the index was out of bounds.

Re: ALT + etc - you could use:
Keyboard.isKeyDown(Keyboard.KEY_LMENU)

Though that's looking at keyboard state not events. But if the e.g. "3" is consumed by the base game, that means it's already acted on it (in this case, probably by selecting a weapon group) and you couldn't undo that.

Awesome, thanks a lot for the reply!
Then I'll wait till the next RC comes out to implement weapon group merging =)

About the keyboard controls: I think I found an alternative solution (use the NUMPAD instead) for this. But that info might still proove valuable later, so thanks!

Two more short questions, if anyone happens to know:

For some reason, when I run Starsector on my virtual Linux machine and press e.g. ALT+NUMPAD3, I get an unconsumed event (with getEventChar=='3' and isAltKeyDown()==true). However, when I run it on my Windows machine, I don't get an unconsumed event (both with 0.95a-RC14 and no other mods except mine and LazyLib). Any idea why that could be?

When calculating the target for Vector2f AutofireAIPlugin.getTarget() (in advance()), how can I access the current target leading accuracy? And how should I factor that into my calculations?

Update: Is my assumption that the values acceleration and deceleration (CombatEntityAPI/ShipAPI) refer to maximum possible rather than current acceleration and deceleration correct?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sodyaler on April 26, 2021, 10:04:04 PM
Would anyone kindly name the mod that shows the amount of "danger stars" a fight is going to be during the ship selection screen? I used to rely on that so I'm not always throwing all my ships at a fight because I'm still relatively new to Starsector. I've been searching but I can't remember which mod it was part of
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 27, 2021, 12:18:22 PM
Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on April 27, 2021, 01:24:55 PM
Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?

I know of an easy way, but I don't think it's a good/reliable way:
Check if it's angularVelocity is very high xD Usually missiles spin like crazy when they collide with something.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 27, 2021, 01:25:41 PM
For some reason, when I run Starsector on my virtual Linux machine and press e.g. ALT+NUMPAD3, I get an unconsumed event (with getEventChar=='3' and isAltKeyDown()==true). However, when I run it on my Windows machine, I don't get an unconsumed event (both with 0.95a-RC14 and no other mods except mine and LazyLib). Any idea why that could be?

Not sure, sorry!

When calculating the target for Vector2f AutofireAIPlugin.getTarget() (in advance()), how can I access the current target leading accuracy? And how should I factor that into my calculations?

ship.getMutableStats().getAutofireAimAccuracy().getModifiedValue()

Range is something like -0.5 to 1.

1f means aim at the correct predicted point. 0 means assume shots are twice as fast as they actually are, so, lag behind the target a bit.

Of note: the vanilla autofire AI will improve its aim with time spent firing on the same target.

Update: Is my assumption that the values acceleration and deceleration (CombatEntityAPI/ShipAPI) refer to maximum possible rather than current acceleration and deceleration correct?

Hmm - are you mixing up acceleration and speed, maybe? The acceleration is a fixed value. The speed has a current and maximum value. Well, the speed doesn't really have a current value, the velocity does...


Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?

I don't think so, afaikr this isn't tracked.

Would anyone kindly name the mod that shows the amount of "danger stars" a fight is going to be during the ship selection screen? I used to rely on that so I'm not always throwing all my ships at a fight because I'm still relatively new to Starsector. I've been searching but I can't remember which mod it was part of

I don't know. It *might* have been one of Sundog's mods, though? I seem to remember him doing stuff with the deployment dialog, though it might have been something else.

I know of an easy way, but I don't think it's a good/reliable way:
Check if it's angularVelocity is very high xD Usually missiles spin like crazy when they collide with something.

Haha, that'd actually do it, especially for dumbfire missiles!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 27, 2021, 03:56:59 PM
Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?

I know of an easy way, but I don't think it's a good/reliable way:
Check if it's angularVelocity is very high xD Usually missiles spin like crazy when they collide with something.

lol, this is brilliant. well, it works well enough, and checking if angular velocity is like 5 is enough to trigger reliably. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 28, 2021, 12:52:38 AM
Is there a way to add XP to marines in storage, that don't already have XP?

Like, when I have 200 marines with zero XP in cargo, I toss them in Jangala's storage, then call the following:
Code: java
runcode MarketAPI market = Global.getSector().getCampaignUI().getCurrentInteractionDialog().getInteractionTarget().getMarket();
com.fs.starfarer.api.impl.PlayerFleetPersonnelTracker.getInstance().getDroppedOffAt("marines", market.getPrimaryEntity(), market.getSubmarket("storage"), true).data.addXP(10000);
the stored marines still have no rank icons, and they dilute the XP of any marines I have in my own fleet.
But if it works if I earn some XP for those marines before storing them, they become elite after running that code.

Would anyone kindly name the mod that shows the amount of "danger stars" a fight is going to be during the ship selection screen? I used to rely on that so I'm not always throwing all my ships at a fight because I'm still relatively new to Starsector. I've been searching but I can't remember which mod it was part of
Pretty sure that's Ruthless Sector by Sundog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on April 28, 2021, 10:46:18 AM
Is there an easy way to check if a missile that hasn't been armed yet (the stage where you fire it but it basically bounces off stuff) has collided with something?

[...]

lol, this is brilliant. well, it works well enough, and checking if angular velocity is like 5 is enough to trigger reliably. Thanks!

I believe the angular velocity is in degrees/second, so 5°/s is actually not very much. I'd say somewhere around 90-180 starts counting as very high.


Not sure, sorry!


I might have to get an IDE running on my Windows machine then...
Thanks anyways =)


ship.getMutableStats().getAutofireAimAccuracy().getModifiedValue()

Range is something like -0.5 to 1.

1f means aim at the correct predicted point. 0 means assume shots are twice as fast as they actually are, so, lag behind the target a bit.

Of note: the vanilla autofire AI will improve its aim with time spent firing on the same target.

Awesome, that helps a lot! Thanks!
So, essentially,
Code
virtualProjectileSpeed = actualProjectileSpeed * (2-targetLeading)
I might use
Code
virtualProjectileSpeed = actualProjectileSpeed * (1.5 - targetLeading/2)
though, as my AIs are specific Fighters-Only and Missile-Only AIs and I feel like it makes sense that if your gunners only have to focus on one type of target they'll do a slightly better job at it.

Funnily enough, I hadn't even though of heavily encouraging weapons to stick to the same target. Turns out, when you do, weapons spend a lot less time erratically turning around and a lot more time actually firing xD

Hmm - are you mixing up acceleration and speed, maybe? The acceleration is a fixed value. The speed has a current and maximum value. Well, the speed doesn't really have a current value, the velocity does...
Ok, I guess I was just thinking too complicated xD
In "real world" physics, acceleration is the time-derivative of the velocity (in the same way that the velocity is the time derivative of the location) and thus a variable vector. But I agree, that's probably overkill for a (non-racing) game engine.
But that still answers my question: I think I simply won't include the acceleration into my target leading calculations xD

Thanks a bunch for all your answers! That certainly did help!

Edit: I pulled a sneaky edit on my post :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 28, 2021, 10:59:34 AM
Is there a way to add XP to marines in storage, that don't already have XP?

Like, when I have 200 marines with zero XP in cargo, I toss them in Jangala's storage, then call the following:
Code: java
runcode MarketAPI market = Global.getSector().getCampaignUI().getCurrentInteractionDialog().getInteractionTarget().getMarket();
com.fs.starfarer.api.impl.PlayerFleetPersonnelTracker.getInstance().getDroppedOffAt("marines", market.getPrimaryEntity(), market.getSubmarket("storage"), true).data.addXP(10000);
the stored marines still have no rank icons, and they dilute the XP of any marines I have in my own fleet.
But if it works if I earn some XP for those marines before storing them, they become elite after running that code.

Hmm, I'm not sure - that seems like it should work. Maybe put a breakpoint in getRankIconName() and see what's going wrong there?

Also: might be worth calling .update() after doing addXP(). I'm not 100% on the specifics, this was a while ago.

Ok, I guess I was just thinking too complicated xD
In "real world" physics, acceleration is the time-derivative of the velocity and thus a variable vector (e.g., if you drive a car and push the accelerator pedal to the max, your linear acceleration is higher than if you only push it 50%. Similarly, if you turn your steering wheel, you have a lateral acceleration, even if your linear speed doesn't change).
But that still answers my question: I think I simply won't include the acceleration into my target leading calculations xD
Thanks!

Yep!  (And, well, it's tough to press a keyboard button at 50% :) )
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: charmingthree on April 28, 2021, 11:55:53 AM
don't know if this is the right place to ask but I've been wondering: would it be feasible to break up the worlds of the Independent faction into their own respective polities? or would it break the balance of the game if there's suddenly, like, nine more factions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on April 29, 2021, 04:30:56 AM
Is there a way to get the number of crew lost after a battle? Preferably on a per-ship basis, but per battle side would be OK too.

I've tried monitoring FleetMemberAPI.getCrewFraction(), but the value is the same before and after a battle.

I have found FleetEncounterContextPlugin.DataForEncounterSide.getCrewLossesDuringLastEngagem ent() in the API, but the only way I've found to get there is via BaseCampaignEventListener.reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot), which seems not guaranteed to be called (no loot generated if you lose - is this correct?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on April 29, 2021, 10:40:34 AM
im trying to spawn a muzzle flash on a weapon from another weapon.

engine.spawnMuzzleFlashOrSmoke(weapon.getShip(),
                    weapon.getSlot(),
                    muzzleSource2,
                    counter,
                    weapAngle + currentAngle);

where weapon is the weapon calling advance on a everyframeeffect and muzzlesource2 is the weaponSpecApi of another weapon that has the same turret/barrel offset. On a hardpoint the flash seems to line up properly, but turreted has the muzzle flash with a strong offset from the actual position. Why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 30, 2021, 08:23:55 AM
Figured out my problem with the marine XP, needed to set the personnel data's num as well as its XP.

New question: What would be the best way to make a faction (Remnants, specifically) chase a transponder-off, hostile player without knowing who the player is? Setting pirateBehavior flag in the faction file looks like it'd do the job, but with a bunch of side effects.

(This came up recently because Nex lets players be neutral or friendly to Remnants. Which works fine except when a player triggers a TransmitterTrapSpecial, which is currently bugged and doesn't actually make the responding fleet low-rep-impact (https://fractalsoftworks.com/forum/index.php?topic=8558.msg323679#msg323679).)

don't know if this is the right place to ask but I've been wondering: would it be feasible to break up the worlds of the Independent faction into their own respective polities? or would it break the balance of the game if there's suddenly, like, nine more factions?
Well, you'd need to do a lot of work to keep the subfactions synced in terms of blueprints they know, their relations with other factions, etc. etc. Really more work than I think it's worth without proper base game support.
(There's a 4chan mod that experimented with this, but I don't know how much progress it made)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on April 30, 2021, 10:08:53 AM
Is it possible to somehow figure out which Ship has been selected in the Command UI (TAB-Key in Combat)?

Is it okay to redistribute the starfarer .jars? I was thinking about creating a Docker to build mods in the CI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 30, 2021, 01:28:22 PM
Is there a way to get the number of crew lost after a battle? Preferably on a per-ship basis, but per battle side would be OK too.

I've tried monitoring FleetMemberAPI.getCrewFraction(), but the value is the same before and after a battle.

I have found FleetEncounterContextPlugin.DataForEncounterSide.getCrewLossesDuringLastEngagem ent() in the API, but the only way I've found to get there is via BaseCampaignEventListener.reportEncounterLootGenerated(FleetEncounterContextPlugin plugin, CargoAPI loot), which seems not guaranteed to be called (no loot generated if you lose - is this correct?)

Hmm - you know what, I'm not actually sure. That is, I think you're right about the loot method not being called on defeat, but as to how to get at this, nothing comes to mind.

im trying to spawn a muzzle flash on a weapon from another weapon.

engine.spawnMuzzleFlashOrSmoke(weapon.getShip(),
                    weapon.getSlot(),
                    muzzleSource2,
                    counter,
                    weapAngle + currentAngle);

where weapon is the weapon calling advance on a everyframeeffect and muzzlesource2 is the weaponSpecApi of another weapon that has the same turret/barrel offset. On a hardpoint the flash seems to line up properly, but turreted has the muzzle flash with a strong offset from the actual position. Why?

Hmm - probably because the slot type of weapon and muzzleSourc2 doesn't match up? Hardpoints and turrets have different fire offsets.

New question: What would be the best way to make a faction (Remnants, specifically) chase a transponder-off, hostile player without knowing who the player is? Setting pirateBehavior flag in the faction file looks like it'd do the job, but with a bunch of side effects.

(This came up recently because Nex lets players be neutral or friendly to Remnants. Which works fine except when a player triggers a TransmitterTrapSpecial, which is currently bugged and doesn't actually make the responding fleet low-rep-impact (https://fractalsoftworks.com/forum/index.php?topic=8558.msg323679#msg323679).)

Hmm - am I missing something? Or did you mean "non-hostile"? Because I'm fairly sure they already chase transponder-off hostile players.


Is it possible to somehow figure out which Ship has been selected in the Command UI (TAB-Key in Combat)?

I don't think it's possible.

Is it okay to redistribute the starfarer .jars? I was thinking about creating a Docker to build mods in the CI.

Thank you for asking - ah, it's not ok, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 30, 2021, 06:39:52 PM
New question: What would be the best way to make a faction (Remnants, specifically) chase a transponder-off, hostile player without knowing who the player is? Setting pirateBehavior flag in the faction file looks like it'd do the job, but with a bunch of side effects.

(This came up recently because Nex lets players be neutral or friendly to Remnants. Which works fine except when a player triggers a TransmitterTrapSpecial, which is currently bugged and doesn't actually make the responding fleet low-rep-impact (https://fractalsoftworks.com/forum/index.php?topic=8558.msg323679#msg323679).)

Hmm - am I missing something? Or did you mean "non-hostile"? Because I'm fairly sure they already chase transponder-off hostile players.
Yeah, they chase, but this is because they know who the player is. I want to make them no longer know the player's identity but continue to chase.
(Well, I don't think this is possible without side effects or manually issuing fleet assignments. Is it?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 30, 2021, 08:43:21 PM
Aaaah, right! Forgot about that, long time since I'd set that up. I don't think this is easily doable, no, but it's possible I'm not thinking of some combination of flags that would do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 01, 2021, 07:59:58 AM
I'd like to alter the description of things (ship initially). Got the descriptionId from the ship hull, get the actual Description from Global.getSettings.getDescription, modify using setters and... nothing.

8 years ago the answer was no, is this possible (or could be made possible) now?

https://fractalsoftworks.com/forum/index.php?topic=7144
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 01, 2021, 10:05:20 AM
Hmm - it seems like generally-speaking using setters for the text members should work (i.e. setText1() etc) but setting the type/id would absolutely not. I'm not sure exactly what you're trying to do - there are lots of possibilities here, i.e. I think what you're doing sounds very different than what the thread talks about? - so, need more info.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 01, 2021, 11:49:34 AM
I want to append a text to ship descriptions (as displayed when hovering over it in submarkets, or codex, etc.). I have a hull mod id, so:
        Description desc = Global.getSettings().getDescription(id, Type.SHIP); // is not null so I got it
And add my text to it:
        desc.setText1("Text 1"); desc.setText2("Text 2"); desc.setText3("Text 3");

And... NOW IT WORKED. Ah, only text1 is used in ship description ("Text 2" and "Text 3" does not show), and I was trying to use text3 before.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 01, 2021, 11:55:57 AM
Ah! Yeah, which of those are used are specific to the description in question, they have a different meaning depending on context. (For example for weapons, text3 (I think?), if present, shows a "quote-style" description, that sort of thing.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sallymoronic on May 02, 2021, 01:26:27 AM
Hello, new. Been messing around with a mod (BSG Revived) since I got the game. Adding the ships into my own game using the wikis modding guide. I've managed to get the ships to show as blueprints, the weapons as well. I can spawn the ships using their variants and they come fully locked and loaded. I have the ability to construct them at my colonies but my issue is the game isnt reading the variant files (more accurately I messed up somewhere and it *cant* read them) so these ships are included in patrol fleets but show as having no armament. I have the ships in the default_shiproles, that file is in the folders its meant to be in. Got the ship_data sorted, wings as well. Weapons_data, a-ok as far as I can see. I tagged all relevant ships and weapons as rare_bp rather than the bsg_bp tag it originally came with because I wasnt including the original mods faction in my universe.

And umm...dunno really, gone through all the ships in the shipeditor, made sure the variants are all lined up nice and neat. Sorry if this is a rambling mess, I havent ever fiddled with the guts of a mod (or made one) before. Any pointers would be helpful!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 02, 2021, 09:13:16 AM
In BaseHubMission.setPersonMissionRef, when/where is the ref then unset from memory?

Hello, new. Been messing around with a mod (BSG Revived) since I got the game. Adding the ships into my own game using the wikis modding guide. I've managed to get the ships to show as blueprints, the weapons as well. I can spawn the ships using their variants and they come fully locked and loaded. I have the ability to construct them at my colonies but my issue is the game isnt reading the variant files (more accurately I messed up somewhere and it *cant* read them) so these ships are included in patrol fleets but show as having no armament. I have the ships in the default_shiproles, that file is in the folders its meant to be in. Got the ship_data sorted, wings as well. Weapons_data, a-ok as far as I can see. I tagged all relevant ships and weapons as rare_bp rather than the bsg_bp tag it originally came with because I wasnt including the original mods faction in my universe.

And umm...dunno really, gone through all the ships in the shipeditor, made sure the variants are all lined up nice and neat. Sorry if this is a rambling mess, I havent ever fiddled with the guts of a mod (or made one) before. Any pointers would be helpful!
Check if the mod's weapons have their autofit tags set (e.g. vanilla LMG has "pd6, kinetic3, SR"). Also try adding the "no_autofit" tag to one or more ships; if those ships then spawn with weapons, that makes it clear where the problem is.

If that doesn't fix it, post the mod and I might have time to look for obvious issues.

here's the .skin file, could someone throw me a hand on this?
Wild guess: Remove the manufacturer tag with its empty string.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 02, 2021, 11:04:36 AM
In BaseHubMission.setPersonMissionRef, when/where is the ref then unset from memory?

When abort() is called, either because the mission wasn't accepted, or because it was completed. See:
changes.add(new VariableSet(person.getMemoryWithoutUpdate(), key, true));
and VariableSet.abort()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sallymoronic on May 02, 2021, 11:52:06 AM
In BaseHubMission.setPersonMissionRef, when/where is the ref then unset from memory?

Hello, new. Been messing around with a mod (BSG Revived) since I got the game. Adding the ships into my own game using the wikis modding guide. I've managed to get the ships to show as blueprints, the weapons as well. I can spawn the ships using their variants and they come fully locked and loaded. I have the ability to construct them at my colonies but my issue is the game isnt reading the variant files (more accurately I messed up somewhere and it *cant* read them) so these ships are included in patrol fleets but show as having no armament. I have the ships in the default_shiproles, that file is in the folders its meant to be in. Got the ship_data sorted, wings as well. Weapons_data, a-ok as far as I can see. I tagged all relevant ships and weapons as rare_bp rather than the bsg_bp tag it originally came with because I wasnt including the original mods faction in my universe.

And umm...dunno really, gone through all the ships in the shipeditor, made sure the variants are all lined up nice and neat. Sorry if this is a rambling mess, I havent ever fiddled with the guts of a mod (or made one) before. Any pointers would be helpful!
Check if the mod's weapons have their autofit tags set (e.g. vanilla LMG has "pd6, kinetic3, SR"). Also try adding the "no_autofit" tag to one or more ships; if those ships then spawn with weapons, that makes it clear where the problem is.

If that doesn't fix it, post the mod and I might have time to look for obvious issues.

here's the .skin file, could someone throw me a hand on this?
Wild guess: Remove the manufacturer tag with its empty string.

You're a bloody star! That did the job of the ships coming with weapons now I just need to figure out how to have the mods weapons set as priority for the mod ships. I went through the vanilla weapons_data and chose tags that sorta matched the modded weapons and set those to 20 (kinetic20 and missile20, in this case). Am I understanding right that the higher the number the "better" a weapon is for any given role as read by the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on May 02, 2021, 10:13:43 PM
In drop groups, can we call the new mixed-type weapons by the mount type they fit in? IE:
Code
wpn_:{tier:3, tags:[<REDACTED>, !restricted], weaponType:HYBRID}
Or does the game call them by their base type in the weapon file for this purpose?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 03, 2021, 08:28:01 AM
im trying to spawn a muzzle flash on a weapon from another weapon.

engine.spawnMuzzleFlashOrSmoke(weapon.getShip(),
                    weapon.getSlot(),
                    muzzleSource2,
                    counter,
                    weapAngle + currentAngle);

where weapon is the weapon calling advance on a everyframeeffect and muzzlesource2 is the weaponSpecApi of another weapon that has the same turret/barrel offset. On a hardpoint the flash seems to line up properly, but turreted has the muzzle flash with a strong offset from the actual position. Why?

Hmm - probably because the slot type of weapon and muzzleSourc2 doesn't match up? Hardpoints and turrets have different fire offsets.


muzzlesource2 is a weaponSpecApi. I cant specify if its hardpoint or turret. Weapon.getSlot() gets me the slot of the weapon im currently in the everyFrameEffect. MuzzleFlash2 is the spec of a weapon I got from global.getsettings. It,s a copy of the spec of weapon, except it has muzzle flash definition. The goal is to spawn a muzzle flash for a beam weapon.

What the problem look ingame is the flash always come out of the position of the unrotated turret barrel
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bob888w on May 04, 2021, 07:33:48 PM
Not necessarily about coding, but I need help finding a mod I was previously interested in... I recalled that the mod included a paragon turned orbital farm and thats about it. Can anyone provide me a name?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on May 04, 2021, 07:39:06 PM
Not necessarily about coding, but I need help finding a mod I was previously interested in... I recalled that the mod included a paragon turned orbital farm and thats about it. Can anyone provide me a name?

I don't know about anybody else, but if this thread got clogged up with this sort of question, it would be dramatically less useful to me. I've set up a new thread over here (https://fractalsoftworks.com/forum/index.php?topic=21496.0) for what-was-that-mod questions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on May 04, 2021, 11:19:16 PM
Is there any way for a mod to interact with the ship refit screen (specifically the weapon group settings)?

I searched the API Doc (https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html) but didn't find anything promising.

Ideally, I would like to add another GUI-element to that screen. But being able to listen for InputEvents and having access to the FleetMember-API would also do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 05, 2021, 07:33:14 AM
Does Reinforced Bulkheads make enemy ships always recoverable? Without story points?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 05, 2021, 03:54:42 PM
1) I know WeaponSpecAPI is shared among all weapons of that spec. But I can't remember if WeaponAPI is - or if that is unique to the WeaponSlotAPI of the ShipAPI.

In other words, if I iterate through WeaponAPIs on a ship under the apply method of a skill, will it only affect that ship's weapons?

2) "apply" from implementing ShipSkillEffect is only ran once at the start of combat correct? It's not run every frame is it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 05, 2021, 04:00:04 PM
Is there any way for a mod to interact with the ship refit screen (specifically the weapon group settings)?

I searched the API Doc (https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html) but didn't find anything promising.

Ideally, I would like to add another GUI-element to that screen. But being able to listen for InputEvents and having access to the FleetMember-API would also do.

I don't believe this is possible, at least not easily. I don't *think* the information as to what fleet member is selected for refit is exposed at all.

Does Reinforced Bulkheads make enemy ships always recoverable? Without story points?

It should, but there've been some reports of "always recoverable" ships ending up in story recovery; not sure what might be going wrong there but it could also affect this sometimes.

1) I know WeaponSpecAPI is shared among all weapons of that spec. But I can't remember if WeaponAPI is - or if that is unique to the WeaponSlotAPI of the ShipAPI.

In other words, if I iterate through WeaponAPIs on a ship under the apply method of a skill, will it only affect that ship's weapons?

2) "apply" from implementing ShipSkillEffect is only ran once at the start of combat correct? It's not run every frame is it?

1) A WeaponAPI is made for the ship.
2) Neither! It's run whenever the ship's captain changes. So for example if you transfer command.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 05, 2021, 04:04:41 PM
1) A WeaponAPI is made for the ship.
2) Neither! It's run whenever the ship's captain changes. So for example if you transfer command.

Ah thanks and that answers my third question too - which was do I have to unapply WeaponAPI changes? - looks like is a definite yes.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Retry on May 05, 2021, 09:41:30 PM
Hello, once again I find myself trying to be too clever for my own good.

I'm currently trying to experiment with a hullmod that converts Phase Ships into conventional omni-shielded warships, where the stats of the shield is dependent on the stats of the original phase cloak.  I'm not entirely sure if it's actually feasible in practice (in terms of gameplay balance), but that's why I want to try it out.

I know going from shielded to phase is practically impossible since that requires glow sprites that normal ships don't have, but I've been having issues with getting the omni-shield part working in the first place, so I'm beginning to wonder if it's just my lack of experience or if going from phase->shields is also impossible.

I currently want to try making the shield's upkeep directly dependent on the ship's original cloak upkeep as the shield upkeep, use activation cloak cost efficiency (which is Activation Cost/Vent Rate iirc?) as part of a function to calculate shield efficiency, and the cloak cooldown time (or some other metric) to calculate shield arc (which doesn't matter much in Vanilla but might be relevant with mod-added ships).

The relevant part of the script is below, in the "ApplyEffectsAfterShipCreation" section:

(https://media.discordapp.net/attachments/824910699415207937/839336697678266388/unknown.png?width=1352&height=884)

(The exact formulas used for the shield attributes are WIP)

When used on an actual phase ship, it looks like this:

(https://media.discordapp.net/attachments/310517733458706442/839644960664191006/screenshot200.png?width=786&height=442)

Some of the values look odd, but the new system stats in the UI appear as if it were a shielded vessel now.  However, the ship still functions like a phase ship when tested in battle; right clicking causes the modified Afflictor to phase instead of activate a shield despite the presence of the hullmod.  I thought it had something to do with the ridiculous flux upkeep from my messed-up formula, but when I switched it manually to a reasonable number (ex: 0.5f -> 50% shield dissipation), the Afflictor still Phases instead of Shields.  The shield part not working at all is currently the biggest roadblock, I'm not sure what I'm overlooking here, could I get a few pointers on how to get that part functioning (if it's possible at all)?

Additionally to that, is there a way to grab the base value (unmodified by officers, other hullmods, caps/vents, scripted battlefield shenanigans, etc) of attributes off a ship, such as:
-Phase Activation Cost & Phase Upkeep
-Flux Dissipation (can't find anything in the FluxTrackerAPI or ShipAPI, perhaps I'm looking in the wrong place?)
-Phase Cooldown (iirc there's a skill that reduces this, and I'd prefer that skills or hullmods not accidentally buff (or nerf) the shield conversion)
-[OPTIONAL] Getting the efficiencies directly, if possible (a lot of the ship.csv data for phase stuff is written as ratios already, so that'd allow me to simplify stuff slightly if I can pull them)

The current method I'm using from the ShipAPI grabs the current flux stats, which means currently means when I adjust certain attributes by, say, adding flux or vents, the shield's efficiency will change with it, which is extremely amusing but not intentional.  I was hoping there was a better way that I'm overlooking to do this, which is less volatile to external changes from other hullmods and officers?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 06, 2021, 12:43:43 AM
I'm encountering several weird issues while fixing up an abandoned mod.

Namely, SOME ships cost 0CP to deploy in combat, despite having a defined Fleet Point cost and not being civillian. I checked, double-checked and tripple-checked the hull file and the ship_data and I can't find anything that would cause this.

Another issue is that a ship that should spawn with a built-in weapon does not. No errors, and I can see the weapon equipped on the ship in the codex. However, in actual combat the mount is empty. Weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 06, 2021, 02:41:07 PM
I'm encountering several weird issues while fixing up an abandoned mod.

Namely, SOME ships cost 0CP to deploy in combat, despite having a defined Fleet Point cost and not being civillian. I checked, double-checked and tripple-checked the hull file and the ship_data and I can't find anything that would cause this.

Make sure that "supplies/rec" is not 0 in ship_data. That is what determines DP - not fleet points. The weapon thing I'm not sure about. Maybe a script is at work there? Or also check for a skin file changing built in weapons if that were to exist.



If I check for Global.getSector().getPlayerFleet().getBattle() being null, is that a reliable way of ensuring the player fleet is not currently in combat when the script is running? Or is there a way to do that at all?

Context:
I'm testing out a skill that changes OP costs for bombers by adding/removing a hullmod. I am trying to prevent an exploit where the player sets his/her character on a ship, assigns the extra OP - and then assigns the character to another ship. I am handling this by simply removing all non-built in fighters (assuming clearing the list even does that) and returning the wings back to the player's inventory.

But! I don't want to do that if the player is switching flagships in combat because the AI ship would lose all the wings (is the theory). I only want this to occur if the player is in the refit screen - with the reasoning that once the battle is over the player character is in the same flagship as when the battle started even they switch ships during battle.


Warning: DO NOT TRY THIS!

*EDIT*

Errr, ok it looks like "apply" and "unapply" are both called when you change the piloted ship in the refit screen??

I have:                 ship.getVariant().clear();

under "unapply"

 - And when I switch ships it immediately clears the variant of the ship I'm switching to rather than the one I am switching from. So I'm pretty confused at this point haha.  ;D

*EDIT 2*
Ok yikes yeah the behavior is really inconsistent. Sometimes it calls:                ship.getVariant().removePermaMod("archeus_warship_bays_high");

 - and sometimes it doesn't. It also clears the variant but doesn't seem to update the UI or finalize things until moving to a different screen? So if I switch to a different ship with my character it clears the variant and adds the hullmod - if I immediately switch to another ship it sometimes preserves the variant and sometimes doesn't but it seems to consistently remove the hullmod.

However, if I switch to a ship and then go out of the refit screen then it finalizes the variant clear and updates the UI - but if I switch again it doesn't remove the hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on May 06, 2021, 09:36:00 PM
I'm making something to keep a log of all my fights:
 
(https://i.imgur.com/HxlYDGa.png)

Would the potentially unbounded amount of non-expiring intel items and stored data (each logged battle adds ~40 KB of XML, 5.7 MB in this save) be a performance concern?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on May 07, 2021, 03:57:29 AM
,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 08, 2021, 03:07:35 AM
Is there any kind of weapon hint that allows a beam weapon to ignore range bonuses? Kind of like the cyroflamers "unaffectedByProjectileRangeBonuses" ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 09, 2021, 08:29:57 AM
Spoiler
If I check for Global.getSector().getPlayerFleet().getBattle() being null, is that a reliable way of ensuring the player fleet is not currently in combat when the script is running? Or is there a way to do that at all?

Context:
I'm testing out a skill that changes OP costs for bombers by adding/removing a hullmod. I am trying to prevent an exploit where the player sets his/her character on a ship, assigns the extra OP - and then assigns the character to another ship. I am handling this by simply removing all non-built in fighters (assuming clearing the list even does that) and returning the wings back to the player's inventory.

But! I don't want to do that if the player is switching flagships in combat because the AI ship would lose all the wings (is the theory). I only want this to occur if the player is in the refit screen - with the reasoning that once the battle is over the player character is in the same flagship as when the battle started even they switch ships during battle.


Warning: DO NOT TRY THIS!

*EDIT*

Errr, ok it looks like "apply" and "unapply" are both called when you change the piloted ship in the refit screen??

I have:                 ship.getVariant().clear();

under "unapply"

 - And when I switch ships it immediately clears the variant of the ship I'm switching to rather than the one I am switching from. So I'm pretty confused at this point haha.  ;D

*EDIT 2*
Ok yikes yeah the behavior is really inconsistent. Sometimes it calls:                ship.getVariant().removePermaMod("archeus_warship_bays_high");

 - and sometimes it doesn't. It also clears the variant but doesn't seem to update the UI or finalize things until moving to a different screen? So if I switch to a different ship with my character it clears the variant and adds the hullmod - if I immediately switch to another ship it sometimes preserves the variant and sometimes doesn't but it seems to consistently remove the hullmod.

However, if I switch to a ship and then go out of the refit screen then it finalizes the variant clear and updates the UI - but if I switch again it doesn't remove the hullmod.
[close]

Sorry for the late response - yeah, unapply() and apply() will both be called.

Just in general, this seems like a bad idea - I'd suggest trying to find a different way to express the skill. As, yeah, things that change OP costs based on what pilot is currently on the ship - that's asking for trouble, basically.

(I'm not sure why you'd be tracking/doing this *in combat*, though.)


I'm making something to keep a log of all my fights:
 
...

Would the potentially unbounded amount of non-expiring intel items and stored data (each logged battle adds ~40 KB of XML, 5.7 MB in this save) be a performance concern?

Cool! ... but, yeah, that'd be a huge problem. I mean, how many battles is the player going to have in a playthrough? For a longer one, the answer could easily be "hundreds" and then we're talking a huge amount of added savefile size, memory requirements, game save/load time, etc. I'd suggest limiting it to the last 10 battles or something (perhaps unless the player flags it as "important"), combined with trying to compress the per-battle data.


Is there any kind of weapon hint that allows a beam weapon to ignore range bonuses? Kind of like the cyroflamers "unaffectedByProjectileRangeBonuses" ?

Ah, I don't believe so. For the cryoflamer, btw, it's "unaffectedByProjectileSpeedBonuses", not range. (Reason that's there is increased projectile speed ruins the visual cohesion of the flame...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 09, 2021, 04:26:23 PM
Is it possible to tell an AI fleet to search for a salvage entity like it does for the player who breaks contact?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 10, 2021, 11:34:18 AM

Ah, I don't believe so. For the cryoflamer, btw, it's "unaffectedByProjectileSpeedBonuses", not range. (Reason that's there is increased projectile speed ruins the visual cohesion of the flame...)

whoops, broke my own weapon. Thanks for letting me know!

Also, with Reserve Deployment: what makes the replacement rate instantly decrease on use of the ship system( Ex. When I used it with two claw lpcs at 100% replacement rate reduces it by 25%, to 75%)?
Code
	public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
ship = (ShipAPI) stats.getEntity();
} else {
return;
}

if (effectLevel == 1) {
for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
if (bay.getWing() == null) continue;

bay.makeCurrentIntervalFast();
FighterWingSpecAPI spec = bay.getWing().getSpec();

int addForWing = getAdditionalFor(spec);
int maxTotal = spec.getNumFighters() + addForWing;
int actualAdd = maxTotal - bay.getWing().getWingMembers().size();
actualAdd = Math.min(spec.getNumFighters(), actualAdd);
if (actualAdd > 0) {
bay.setFastReplacements(bay.getFastReplacements() + addForWing);
bay.setExtraDeployments(actualAdd);
bay.setExtraDeploymentLimit(maxTotal);
bay.setExtraDuration(EXTRA_FIGHTER_DURATION);
}
}
}
}
Is bay.makeCurrentIntervalFast() basically "do this instantly" and the replacement time needed to spawn the extra craft just occurs super fast, hence the immediate drop?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 10, 2021, 11:47:44 AM
Is it possible to tell an AI fleet to search for a salvage entity like it does for the player who breaks contact?

Not directly - you'd have to write a custom assignment.

Also, with Reserve Deployment: what makes the replacement rate instantly decrease on use of the ship system( Ex. When I used it with two claw lpcs at 100% replacement rate reduces it by 25%, to 75%)?

It looks like you're looking at old code somehow. The latest code has this bit in it:
float rate = Math.max(minRate, bay.getCurrRate() - RATE_COST);
bay.setCurrRate(rate);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on May 10, 2021, 11:50:28 AM

Ah, I don't believe so. For the cryoflamer, btw, it's "unaffectedByProjectileSpeedBonuses", not range. (Reason that's there is increased projectile speed ruins the visual cohesion of the flame...)

whoops, broke my own weapon. Thanks for letting me know!

Also, with Reserve Deployment: what makes the replacement rate instantly decrease on use of the ship system( Ex. When I used it with two claw lpcs at 100% replacement rate reduces it by 25%, to 75%)?
Code
	public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
ship = (ShipAPI) stats.getEntity();
} else {
return;
}

if (effectLevel == 1) {
for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
if (bay.getWing() == null) continue;

bay.makeCurrentIntervalFast();
FighterWingSpecAPI spec = bay.getWing().getSpec();

int addForWing = getAdditionalFor(spec);
int maxTotal = spec.getNumFighters() + addForWing;
int actualAdd = maxTotal - bay.getWing().getWingMembers().size();
actualAdd = Math.min(spec.getNumFighters(), actualAdd);
if (actualAdd > 0) {
bay.setFastReplacements(bay.getFastReplacements() + addForWing);
bay.setExtraDeployments(actualAdd);
bay.setExtraDeploymentLimit(maxTotal);
bay.setExtraDuration(EXTRA_FIGHTER_DURATION);
}
}
}
}
Is bay.makeCurrentIntervalFast() basically "do this instantly" and the replacement time needed to spawn the extra craft just occurs super fast, hence the immediate drop?
For some reason your code is missing the reduce rate part. Are you using up to date API library reference?

And yes it immediately spawns current fighter. For this ship system it’s a one-off effect to force the set fast spawn able to spawn immediately, otherwise the additional fighters can only be spawned after current under construction fighter gets deployed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 10, 2021, 02:30:44 PM
haha, embarassing. I have an 0.91 install in the same directory as 0.95 and I probably opened up the working folder for it instead of the latest version. Thanks, either way!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 10, 2021, 03:51:12 PM
Sorry for the late response - yeah, unapply() and apply() will both be called.

Just in general, this seems like a bad idea - I'd suggest trying to find a different way to express the skill. As, yeah, things that change OP costs based on what pilot is currently on the ship - that's asking for trouble, basically.

(I'm not sure why you'd be tracking/doing this *in combat*, though.)

Np at all I know you are likely super busy after a new release.

And yeah I definitely came to that conclusion due to all the complications after implementing it. I might technically be able to get it to work, but the downsides (such as clearing variants which would be annoying/tedious for the player) make it not at all worth it.

The combat part was just because of the script being ran when a player switched flagships in combat. Its intended runtime was for the refit screen, but I was trying to make sure I accounted for all places it ran. Well, unless I'm misunderstanding something and there would be an obviously better way to do this or something like that.

I'm just going to have to come up with a different bonus of some kind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ermacia91 on May 11, 2021, 12:44:07 PM
I am looking for a way to modify the way the Trade UI behaves (like adding a button for moving all objects, autosort, etc.). Has anyone been able to understand how is the UI being handled? Can't wrap my head around it, honestly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ermacia91 on May 11, 2021, 12:45:35 PM
Also, is there a way to make the game very verbose about the actions for better understanding of its moving parts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 11, 2021, 01:22:58 PM
I am looking for a way to modify the way the Trade UI behaves (like adding a button for moving all objects, autosort, etc.). Has anyone been able to understand how is the UI being handled? Can't wrap my head around it, honestly.
All UI is non-moddable (in obfuscated code, you are in for lots of pain if you want to play with it anyway). You can add listeners and perform some action in the background (see Grand Colonies (https://fractalsoftworks.com/forum/index.php?topic=20986.0)), or implement some actions using Intel UI (see my mod, in signature), or use interaction plugin for dialog-based actions.

Also, is there a way to make the game very verbose about the actions for better understanding of its moving parts?
Edit `data/config/settings.json` and enable dev mode.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on May 11, 2021, 01:31:51 PM
How does the game handle replacement rate of a bay if I explicitly set it to below minimum?
Does it just bounce back magically? Or does it simply stop dropping from lost fighter ticks?

I ask this because in my Modern Carriers mod there is a hullmod Load Balancer that shifts the replacement rates around different bays. It strucks me when I think of the possibility of deliberately leaving a empty bay to fuel other bays’ replacement rate. If the game allows replacement rate lower than minimum for regular bays, there is some incentive to sacrifice a bay for other bays to remain peak replacement using such hull mod and provide some interesting strategies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ermacia91 on May 11, 2021, 04:20:37 PM
I was able to create a mod that autosorts my stuff with EveryFrameScript - would you be interested in using it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 12, 2021, 11:30:48 AM
I have a beam weapon spawning an explosion with engine.spawnDamagingExplosion. I would like this explosion damage to be scaled with the captain's skills.
can I use engine.applyDamageModifiersToSpawnedProjectileWithNullWeapon(..) after spawning the explosion? And if yes, how do I get the proper damageAPi from the explosion.

if that doesn't work, how do I get all modifier that apply on a damage type if I want to scale the damage before calling spawnDamagingExplosion.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2021, 12:10:32 PM
How does the game handle replacement rate of a bay if I explicitly set it to below minimum?
Does it just bounce back magically? Or does it simply stop dropping from lost fighter ticks?

I ask this because in my Modern Carriers mod there is a hullmod Load Balancer that shifts the replacement rates around different bays. It strucks me when I think of the possibility of deliberately leaving a empty bay to fuel other bays’ replacement rate. If the game allows replacement rate lower than minimum for regular bays, there is some incentive to sacrifice a bay for other bays to remain peak replacement using such hull mod and provide some interesting strategies.

IIRC leaving a bay empty in vanilla will actually help with the replacement rate somewhat since that bay will count as if it had a wing that hadn't suffered any losses.

But, yes, if the rate is set below the minimum it will get clamped up to that basically immediately (or a frame later).

I have a beam weapon spawning an explosion with engine.spawnDamagingExplosion. I would like this explosion damage to be scaled with the captain's skills.
can I use engine.applyDamageModifiersToSpawnedProjectileWithNullWeapon(..) after spawning the explosion? And if yes, how do I get the proper damageAPi from the explosion.

if that doesn't work, how do I get all modifier that apply on a damage type if I want to scale the damage before calling spawnDamagingExplosion.

That should work, yes! You can call getDamage() on the return value of spawnDamagingExplosion(). I'd suggest checking out the javadoc; it makes it easier to look up answers to those sorts of questions.

https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 12, 2021, 12:29:19 PM
I have a beam weapon spawning an explosion with engine.spawnDamagingExplosion. I would like this explosion damage to be scaled with the captain's skills.
can I use engine.applyDamageModifiersToSpawnedProjectileWithNullWeapon(..) after spawning the explosion? And if yes, how do I get the proper damageAPi from the explosion.

if that doesn't work, how do I get all modifier that apply on a damage type if I want to scale the damage before calling spawnDamagingExplosion.

That should work, yes! You can call getDamage() on the return value of spawnDamagingExplosion(). I'd suggest checking out the javadoc; it makes it easier to look up answers to those sorts of questions.

https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

in the javadoc the only comment for getDamage() is "Do not call for explosions." So I am a bit confused, isnt the DamagingProjectileAPI returned from spawnDamagingExplosion an Explosion?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2021, 12:51:38 PM
Ah - I think that comment may be out of date, actually. I'd give it a shot and see if it works correctly or not. In general that's probably a good thing to do...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 13, 2021, 03:06:20 PM
Can ELECTRONIC_WARFARE_PENALTY_MULT be modified mid-combat or only before ship creation?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2021, 03:08:38 PM
Ah, I don't actually remember offhand; seems like it'd be reasonably easy to test though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 13, 2021, 03:12:18 PM
Testing indicated it doesn't. Which seems kinda odd for a "dynamic" stat, but I guess dynamic just means "not hardcoded" in this context.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2021, 03:19:42 PM
Yeah, "dynamic" just means that in this context.

Looking at the script, though (ElectronicWarfareScript), it looks like it would be applied based on the current value of the stat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 13, 2021, 03:48:40 PM
My bad. Did a test with properly extreme conditions (Gauss Cannon go!) and it does modify dynamically. Discovered I accidentally inverted my EW reduction so it worked better the worse it was supposed to be ;D Math is hard.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 13, 2021, 10:38:22 PM
Has DELIVER_CREW (and a bunch of other assignments I tried, including ORBIT_PASSIVE, FOLLOW and INTERCEPT) stopped working as a way to tell a fleet to go to player fleet in another star system?

The fleet generated by the following code just flies in a circle if player is not in the same system, or stays perfectly still if player is:
Code: java
runcode 
import com.fs.starfarer.api.impl.campaign.fleets.FleetParamsV3;
import com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3;
StarSystemAPI thule = Global.getSector().getStarSystem("Thule");
Vector2f locInHyper = thule.getLocation();
FleetParamsV3 params = new FleetParamsV3(locInHyper,
"persean", null, "patrolMedium",
50,0f,0f,0f,0f,0f,0f);
CampaignFleetAPI fleet = FleetFactoryV3.createFleet(params);
thule.addEntity(fleet);
fleet.setLocation(2000, 2000);
fleet.addAssignment(FleetAssignment.DELIVER_CREW, Global.getSector().getPlayerFleet(), 1000);
If this is intended, what's the new assignment to order a fleet to go to player in a different system (preferably without stopping to engage random enemies along the way)?

EDIT: While I'm here, a couple more questions:
- Can the Janus jump destination window be repurposed for another feature?
- Is there a way to mark a ship as unable to be refitted or sold/scuttled/stored?

EDIT 2: Bug report. If you add a button to the TooltipMakerAPI created by a beginImageWithText call, the button doesn't respond to mouse input.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 14, 2021, 11:28:19 AM
Getting this error when I try to fire a weapon:

Code
4359460 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.entities.ship.super.G.ÖO0000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.super.G.createBeam(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.class.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.String.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.String.o00000(Unknown Source)
at com.fs.starfarer.combat.entities.ship.trackers.class.super(Unknown Source)
at com.fs.starfarer.combat.entities.ship.super.G.advance(Unknown Source)
at com.fs.starfarer.combat.systems.G.advanceLinked(Unknown Source)
at com.fs.starfarer.combat.systems.G.advance(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


The weapon in question:
Code
{
"specClass":"beam",
"id":"vns_reflex_cannon",
"type":"ENERGY",
"size":"LARGE",
"displayArcRadius":2000,

"turretUnderSprite":"",
"turretSprite":"graphics/weapons/animated/vns_reflexcannon/vns_reflex_Cannon_00.png",
"turretGlowSprite":"",
"hardpointSprite":"graphics/weapons/animated/vns_reflexcannon/vns_reflex_Cannon_00.png",
"hardpointGlowSprite":"",

"numFrames":12,
"frameRate":10,
"interruptibleBurst":true,
"turretOffsets":[12, 0],
"turretAngleOffsets":[0],
"hardpointOffsets":[12, 0],
"hardpointAngleOffsets":[0],

"fringeColor":[250,250,0,100],
"coreColor":[5,0,10,155],
"glowColor":[220,180,0,0],
"width":100.0,
#"textureType":ROUGH,
"textureType":["graphics/fx/vns_beam_core_1.png","graphics/fx/plasmabeam.png"],
"textureScrollSpeed":-100.0,
"pixelsPerTexel":5.0,

"animationType":"GLOW",  # NONE, GLOW, MUZZLE_FLASH, SMOKE
"pierceSet":[PROJECTILE_FF,PROJECTILE_NO_FF,PROJECTILE_FIGHTER],
"fireSoundOne":"Macross_beam_warmup",
"fireSoundTwo":"Macross_beam_cycle",
"fireSoundThree":"Macross_beam_powerdown",
}


It has 12 numbered sprites for the fire squence. What gives?


EDIT:
Fixed it.
IT was teh sound. Turn out the sounds have a different name in the sounds.json file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 14, 2021, 11:47:32 AM
Is it possible to make a weapon or certain hullmod only avaible to player?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 14, 2021, 11:52:42 AM
Has DELIVER_CREW (and a bunch of other assignments I tried, including ORBIT_PASSIVE, FOLLOW and INTERCEPT) stopped working as a way to tell a fleet to go to player fleet in another star system?

Looks like it has, yeah - the AI no longer "knows" what location the player is in unless it's seen them jump. It freezing up when the player is in-system is a bug, though; fixed up that aspect of it.

If this is intended, what's the new assignment to order a fleet to go to player in a different system (preferably without stopping to engage random enemies along the way)?

I don't think any assignment would help; the only thing that comes to mind is creating a location token and making that stick to the player fleet via a script.


- Can the Janus jump destination window be repurposed for another feature?

I believe so - IIRC it's a pretty configurable way to let the player pick some kind of entity. It's even possible to have multiple entities per star system; they're shown in a dropdown).

See: GateCMD.selectDestination() for the vanilla implementation of the plugin it takes.

- Is there a way to mark a ship as unable to be refitted or sold/scuttled/stored?

There's Tags.SHIP_CAN_NOT_SCUTTLE (which should be added to the variant, iirc), but I don't believe there's anything for preventing sold/stored.

EDIT 2: Bug report. If you add a button to the TooltipMakerAPI created by a beginImageWithText call, the button doesn't respond to mouse input.

Did you call .setForceProcessInput(true) on that TooltipMakerAPI?



Getting this error when I try to fire a weapon:

Hard to say what the issue is. I'd suggest narrowing it down by editing the weapon file until it goes away to identify exactly what causes the problem.

(From the stack trace, it looks like it crashes trying to create the beam, but that could probably be caused by different things...)


Is it possible to make a weapon or certain hullmod only avaible to player?

Just not making it available to factions should do the job. isAlwaysUnlocked() hullmods will be known to all factions, though - but unless their variants use it, they're not just going to randomly start using it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on May 14, 2021, 03:23:15 PM
So if officer_manager is commented out in the events.json

Does that mean officer_manager can no longer be touched or is there an alternative way? A pity if so.  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Special_Eddies on May 14, 2021, 06:38:34 PM
Tried adding a ship to the game and came out with this error, wanted to see if anyone had any pointers as to what i've done wrong

at com.fs.util.Object.Object(Unknown Source)
   at com.fs.util.Object.Ô00000(Unknown Source)
   at com.fs.graphics.TextureLoader.String(Unknown Source)
   at com.fs.graphics.TextureLoader.super(Unknown Source)
   at com.fs.graphics.TextureLoader.super(Unknown Source)
   at com.fs.graphics.TextureLoader.super(Unknown Source)
   at com.fs.graphics.H.o00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)




Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 15, 2021, 04:45:31 AM
Has DELIVER_CREW (and a bunch of other assignments I tried, including ORBIT_PASSIVE, FOLLOW and INTERCEPT) stopped working as a way to tell a fleet to go to player fleet in another star system?

Looks like it has, yeah - the AI no longer "knows" what location the player is in unless it's seen them jump. It freezing up when the player is in-system is a bug, though; fixed up that aspect of it.

If this is intended, what's the new assignment to order a fleet to go to player in a different system (preferably without stopping to engage random enemies along the way)?

I don't think any assignment would help; the only thing that comes to mind is creating a location token and making that stick to the player fleet via a script.
Thanks; worked something out with a location token.
Although it might be nice to have an easy way for fleets to cheat and know where the destination fleet is anyway, perhaps based on assignment type (the DELIVERs) or a memory flag?

Quote
- Can the Janus jump destination window be repurposed for another feature?
I believe so - IIRC it's a pretty configurable way to let the player pick some kind of entity. It's even possible to have multiple entities per star system; they're shown in a dropdown).

See: GateCMD.selectDestination() for the vanilla implementation of the plugin it takes.
Wow this is great, thanks! Only thing it needs is an arg to have the location highlight be configurable (possibly allowing multiple highlights) instead of always being at the player's current location, and maybe optionally drawing an arrow line (intel screen style) between them.

Quote
EDIT 2: Bug report. If you add a button to the TooltipMakerAPI created by a beginImageWithText call, the button doesn't respond to mouse input.

Did you call .setForceProcessInput(true) on that TooltipMakerAPI?
That makes the button react to mouse input, but clicking it does nothing, in that IntelInfoPlugin.buttonPressConfirmed etc. don't get called.
(I considered working around this by putting it in a custom panel whose plugin would handle the input, but wasn't sure how to do the intel confirmation prompts)

Might be related to the bug reported for 0.9.1 where buttons within a custom panel didn't do anything?

Tried adding a ship to the game and came out with this error, wanted to see if anyone had any pointers as to what i've done wrong

at com.fs.util.Object.Object(Unknown Source)
   at com.fs.util.Object.Ô00000(Unknown Source)
   at com.fs.graphics.TextureLoader.String(Unknown Source)
   at com.fs.graphics.TextureLoader.super(Unknown Source)
   at com.fs.graphics.TextureLoader.super(Unknown Source)
   at com.fs.graphics.TextureLoader.super(Unknown Source)
   at com.fs.graphics.H.o00000(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
At a guess, your ship sprite hasn't been assigned correctly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 15, 2021, 10:16:30 AM
So if officer_manager is commented out in the events.json

Does that mean officer_manager can no longer be touched or is there an alternative way? A pity if so.  :-\

It's just added as a script now.

Although it might be nice to have an easy way for fleets to cheat and know where the destination fleet is anyway, perhaps based on assignment type (the DELIVERs) or a memory flag?

Hmm - if you set FleetAIFlags.SEEN_TARGET_JUMPING_FROM in the fleet's memory, to the ID of the current containingLocation, that may do the trick. But as soon as it jumped, it'd need to be re-set.

Wow this is great, thanks! Only thing it needs is an arg to have the location highlight be configurable (possibly allowing multiple highlights) instead of always being at the player's current location, and maybe optionally drawing an arrow line (intel screen style) between them.

Made a note.

Quote
EDIT 2: Bug report. If you add a button to the TooltipMakerAPI created by a beginImageWithText call, the button doesn't respond to mouse input.

Did you call .setForceProcessInput(true) on that TooltipMakerAPI?
That makes the button react to mouse input, but clicking it does nothing, in that IntelInfoPlugin.buttonPressConfirmed etc. don't get called.
(I considered working around this by putting it in a custom panel whose plugin would handle the input, but wasn't sure how to do the intel confirmation prompts)

Might be related to the bug reported for 0.9.1 where buttons within a custom panel didn't do anything?

Ah yes, you're right! The fix there only applied CustomPanelAPI.createUIElement(), not TMAPI.beginImageWithText(). Basically these just needed to pass through the button action listener; fixed it up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Special_Eddies on May 15, 2021, 11:17:40 AM
Wasn't that but i figured it out, i was making a phase vessel and didn't realize that it needed glow images, so i made them for the ship, now it works perfectly

thanks for the assist though, now once i get home im gonna draw up some ship sprites and use what i make
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 16, 2021, 02:20:25 PM
Is there some way to modify a fighters target (for either attacking or defending)? I tried setting it via their ShipAPIs with fighter.setShipTarget(otherShip.getShipTarget();, to seemingly no effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 16, 2021, 03:25:23 PM
Is it possible to do something like the Breach OnHitEffect with a BeamEffectPlugin?

Looking at the source it seems like it would be, but I'm wondering about the difference between when onHit is called vs advance. Specifically, onHit seems like it would be called once while advance is called the entire time the beam is firing.

Should I perform the armor calculation throughout the entire duration of the beam to have the same effect?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 16, 2021, 06:20:45 PM
Is there some way to modify a fighters target (for either attacking or defending)? I tried setting it via their ShipAPIs with fighter.setShipTarget(otherShip.getShipTarget();, to seemingly no effect.

Hmm - you might try setting AIFlags.CARRIER_FIGHTER_TARGET in ship.getAIFlags(). I'm not 100% sure whether that would get overridden by the AI or not, though.

Is it possible to do something like the Breach OnHitEffect with a BeamEffectPlugin?

Looking at the source it seems like it would be, but I'm wondering about the difference between when onHit is called vs advance. Specifically, onHit seems like it would be called once while advance is called the entire time the beam is firing.

Should I perform the armor calculation throughout the entire duration of the beam to have the same effect?

I mean, it depends on what exactly you want to do! It's definitely possible. You might want to code it to only proc when the beam damage ticks, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 16, 2021, 06:49:44 PM
Is there some way to modify a fighters target (for either attacking or defending)? I tried setting it via their ShipAPIs with fighter.setShipTarget(otherShip.getShipTarget();, to seemingly no effect.

Hmm - you might try setting AIFlags.CARRIER_FIGHTER_TARGET in ship.getAIFlags(). I'm not 100% sure whether that would get overridden by the AI or not, though.

Is it possible to do something like the Breach OnHitEffect with a BeamEffectPlugin?

Looking at the source it seems like it would be, but I'm wondering about the difference between when onHit is called vs advance. Specifically, onHit seems like it would be called once while advance is called the entire time the beam is firing.

Should I perform the armor calculation throughout the entire duration of the beam to have the same effect?

I mean, it depends on what exactly you want to do! It's definitely possible. You might want to code it to only proc when the beam damage ticks, though.

How would I set the target? Would I use

setFlag(ShipwideAIFlags.AIFlags flag, float duration, java.lang.Object custom)

With custom being  the CombatEntity?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 16, 2021, 06:54:41 PM
Sorry to double post, but this is separate enough from the earlier inquiry to warrant it I think:

I've been digging into the skills code for a bit now, and something really confuses me about the implementation of edits to MutableShipStatsAPI from either the ship itself or its equipped wings.

Notably: Strike Commander edits stats directly from apply and unapply at level 2 and 4 respectively. Normally, this applies to the officered ShipAPI directly and not the wings. An example of an alternate implementation to impact wings would be something like:

Code
            ShipAPI ship = null;
            if (stats.getEntity() instanceof ShipAPI) {
                ship = (ShipAPI) stats.getEntity();
            } else {
                return;
            }
            for (ShipAPI fighter : getFighters(ship)) {
                if (fighter.isHulk()) continue;
                MutableShipStatsAPI fStats = fighter.getMutableStats();

                fStats.getDamageToFighters().modifyMult(id, DAMAGE_MULT);
                fStats.getDamageToMissiles().modifyMult(id, DAMAGE_MULT);
                fStats.getDamageToCruisers().modifyMult(id, DAMAGE_MULT);
                fStats.getDamageToCapital().modifyMult(id, DAMAGE_MULT);
            }

So why do some skills only effect the ship itself and some only effect the wings? The implementation seems the same. I must be missing something, but I've tested the behavior and it holds true to the description.



I mean, it depends on what exactly you want to do! It's definitely possible. You might want to code it to only proc when the beam damage ticks, though.

Basically I want to replace the effects of High Scatter Amplifier to increase beam damage to armor directly rather than just damage. I would base this off of the beams dps per fire. So outside of the obvious edits to the damage calculation, I was wondering how often I would have to call the calculation from BeamEffectPlugin. I'm assuming every time advance is called but I haven't tested out any implementations yet.

(For instance, setForceHardFlux(true) only needs to be called once afaik. I'd think this would be different but I'm not 100% sure.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 16, 2021, 07:00:37 PM
How would I set the target? Would I use

setFlag(ShipwideAIFlags.AIFlags flag, float duration, java.lang.Object custom)

With custom being  the CombatEntity?

That sounds right, yeah.

So why do some skills only effect the ship itself and some only effect the wings? The implementation seems the same. I must be missing something, but I've tested the behavior and it holds true to the description.

See for example point_defense.skill:

{"type":"SHIP", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level1"},
{"type":"SHIP", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level2"},
{"type":"SHIP_FIGHTERS", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level1"},
{"type":"SHIP_FIGHTERS", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level2"},

Note how it's even able to apply the same effect both to the ship and to its fighters.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 16, 2021, 07:48:47 PM
See for example point_defense.skill:

{"type":"SHIP", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level1"},
{"type":"SHIP", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level2"},
{"type":"SHIP_FIGHTERS", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level1"},
{"type":"SHIP_FIGHTERS", "script":"com.fs.starfarer.api.impl.campaign.skills.PointDefense$Level2"},

Note how it's even able to apply the same effect both to the ship and to its fighters.

Ah ok that makes more sense thanks! I was looking in the wrong file (stats script itself) and probably originally thought that was more for category reference purposes and/or description related things.
Title: Thoughts on salvage and how it should be balanced.
Post by: HungwellHamburger on May 16, 2021, 08:32:57 PM
Would it be possible to limit or prohibit a player from salvaging stations, ships, planetary ruins, etc. based on acquired knowledge and beliefs or whatever, which I was thinking could be handled in the same way as blueprints, or acquired directly through player skills in the appropriate trees.
My thinking was that it makes little sense that your average scavver knows his way around high-tech ships well enough to not destroy the more delicate bits, and a Pather would be more inclined to blow it to bits then accept it for their own use. This could be extended to faction ships, where someone commissioned to a specific faction knows how to disengage self-destruct protocols or whatever. In the reverse, a white-glove TT exec wouldn't stoop to feeding off of pirate scrap, and would likely blow it up due to having no familiarity with jury-rigged starship gear.

I'm currently working on ways of making pure scavenger runs more white-knuckle, starting with experimenting with everything Derelict, that's something I could conceivably do on my own starting out and pounding my head against a wall, but I dont know how to answer the first questions and this one; Would players even find this fun?

EDIT: Its occured to me that alot of these could be player RP choices for those disciplined enough to follow them, so I suppose the question is whether or not this could be made interesting in a gameplay sense, my thought is yes. Although to make this question more appropriate for the thread...

Can individual nodes in the skill tree be treated as branching trees, programatically speaking, each one a mini-skill tree dedicated to the main node. It could use story points or literally any other rebalance of skill points. The actual selection could be handled in the same way that officer promotions are handled.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 17, 2021, 06:38:05 AM
Hello Alex, just wanted to verify a changed mechanic here.

Submarket contents are refreshed when player docks via "updateCargoPrePlayerInteraction". In 0.9.1a the submarket was considered "stale" if it last has updated in previous months (even if it was visited on the last day of the month). In 0.95a this seems to be behaving differently, and each market has been given its own cooldown. It seems to be updating circa 30 days after last update has happened which is a great change.

Is this correct, and what is the grace period between the updates?

Just read more of BaseSubmarketPlugin - all is there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 17, 2021, 03:54:41 PM
Is it possible to do something like the Breach OnHitEffect with a BeamEffectPlugin?

I have this mostly working as intended (I think anyway - haven't tested all the beams just the mining laser) with one major problem. It will still damage the armor through shields when the beam is hitting a shield. I also haven't checked what happens when the beam is damaging multiple targets at once since it passes through fighters and missiles.

Anyway, how do I acquire the boolean that determines whether the damage this tick of advance was on a shield? It is passed into the OnHitEffectPlugin's onHit method: boolean shieldHit but not BeamEffectPlugin.

I've already checked the beam target's ShieldAPI and nothing seems useful there. Can I somehow get it from the combat engine? Not very familiar with it other than adding custom data.


Nvm there is a section of the TachyonLanceEffect that does this since it can penetrate shields. Back to testing then.  :)

Full code so far:
Spoiler
public class ArcheusBeamHardFluxEffect implements BeamEffectPlugin {

   private boolean done = false;

    private static final Logger LOG = Global.getLogger(ArcheusBeamHardFluxEffect.class);
   
   public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {

        if (beam.getSource().getVariant().hasHullMod("archeus_high_scatter_amp")) {
            dealArmorDamage(beam, amount);
        }

      if (done) return;
      beam.getDamage().setForceHardFlux(true);
      done = true;
   }

    public static void dealArmorDamage(BeamAPI beam, float amount) {
        CombatEngineAPI engine = Global.getCombatEngine();
        ShipAPI target;
        Vector2f point;
        if (beam.getDamageTarget() instanceof ShipAPI){
            target = (ShipAPI) beam.getDamageTarget();
        } else {
            LOG.info("Target wasn't a ship.");
            return;
        }
        if (beam.didDamageThisFrame()) {
            point = beam.getTo();
        } else {
            LOG.info("Beam did not do damage this frame.");
            return;
        }

        boolean hitShield = target.getShield() != null && target.getShield().isWithinArc(beam.getTo());
        if (hitShield) return;

        ArmorGridAPI grid = target.getArmorGrid();
        int[] cell = grid.getCellAtLocation(point);
        if (cell == null) return;

        int gridWidth = grid.getGrid().length;
        int gridHeight = grid.getGrid()[0].length;

        float damageTypeMult = DisintegratorEffect.getDamageTypeMult(beam.getSource(), target);

        // Damage this round of 'advance' multiplied by the High Scatter Amplifier hullmod's bonus multiplier.
        // This way the bonus to the beam's armor penetration scales based upon the original stat.
        // This prevents the hullmod from being more valuable on kinetic beams than standard beams due to a flat bonus.
        // Assumption: HE beams like the Terminator would have already destroyed the armor cell in the majority of cases. Bonus impact low.
        float bonusDamageBeforeAdjustments = beam.getDamage().computeDamageDealt(amount) * ArcheusHighScatterAmp.ARMOR_DAMAGE_MULTIPLIER;

        // Apply damage over nearby armor cells.
        float damageDealt = 0f;
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if ((i == 2 || i == -2) && (j == 2 || j == -2)) continue; // skip corners

                int cx = cell[0] + i;
                int cy = cell[1] + j;

                if (cx < 0 || cx >= gridWidth || cy < 0 || cy >= gridHeight) continue;

                float damMult = 1/30f;
                if (i == 0 && j == 0) {
                    damMult = 1/15f;
                } else if (i <= 1 && i >= -1 && j <= 1 && j >= -1) { // S hits
                    damMult = 1/15f;
                } else { // T hits
                    damMult = 1/30f;
                }

                float armorInCell = grid.getArmorValue(cx, cy);
                float damage = bonusDamageBeforeAdjustments * damMult * damageTypeMult;
                damage = Math.min(damage, armorInCell);
                if (damage <= 0) continue;

                target.getArmorGrid().setArmorValue(cx, cy, Math.max(0, armorInCell - damage));
                damageDealt += damage;
            }
        }

        if (damageDealt > 0) {
            if (Misc.shouldShowDamageFloaty(beam.getSource(), target)) {
                engine.addFloatingDamageText(point, damageDealt, Misc.FLOATY_ARMOR_DAMAGE_COLOR, target, beam.getSource());
            }
            target.syncWithArmorGridState();
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Retry on May 17, 2021, 09:20:51 PM
Is there a way to arbitrarily adjust weapon RoF to specific weapons through a hullmod, but without blanket changes via applyEffectsBeforeShipCreation stat change?

I'm trying to make a hullmod whose effects should only apply to energy projectile weapons, and not touch beams whatsoever.  There's mutable stats that separate Beam and Energy weapons for the purpose of damage and flux consumption, but not for Rate of Fire.  I found a way to set arbitrarily ammo charge rates using advanceInCombat (projectile-based charge weapons like Autopulse receive a reduced charge rate, while beam-based Burst PD is unaffected), but I don't know if I can do base Fire Rate from a similar method?  If I use getEnergyRoFMult().modifyMult in applyEffectsBeforeShipCreation instead, the charge rate for burst Beams like Phase Lance will be impacted, which is not desired.

(Sorry, code's a bit of a mess; it's been a long day)
(https://cdn.discordapp.com/attachments/310517733458706442/844031212879085572/unknown.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 17, 2021, 11:41:57 PM
Is there any way to change the location of a launch bay in combat? Like making a fighter wing (appear) to take off/land somewhere other than its mother ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 18, 2021, 10:10:42 AM
Extra stupid question.
I want to play a weapon sound on the ship trough a script, and for that I need a location of the ship.

I have:
Global.getSoundPlayer().playSound("mytestaudio", 1f, 1f, point, ZERO);


So do I get the ship location into the point variable?

EDIT: Ignore me, I am ***. I should have just used weapon.GetLocation().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 18, 2021, 01:37:22 PM
Is there a way to arbitrarily adjust weapon RoF to specific weapons through a hullmod, but without blanket changes via applyEffectsBeforeShipCreation stat change?

Unless Lazylib or Magiclib has some special spell I'm not aware of, the only way I think you might be able to do this would be to set up an EveryFrameCombat script that checks for:

Code
WeaponAPI.getCooldown() == WeaponAPI.getRemainingCooldown()

And then setting the cooldown using something like:

Code
WeaponAPI.setRemainingCooldownTo(WeaponAPI.getCooldown() * COOLDOWN_MALUS_MULT) 
-- Which could be 0.8 for 20%, etc.

You'd have to iterate through all the ships in combat to find ones who have the hullmod equipped though. That might get a little resource intensive assuming it even works. Not sure what edge cases you might run into if, for instance, you didn't run the script every frame.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 18, 2021, 05:22:36 PM
What does the "restricted", "req_military" and "merc" tags do?

I'm assuming "hist1t" and "hist2t" are story related to the historian and what types of blueprints are available from him/her. And "auto_rec" is what ships can be recovered from Automated Ships?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 18, 2021, 07:01:57 PM
Is there any way to change the location of a launch bay in combat? Like making a fighter wing (appear) to take off/land somewhere other than its mother ship?

I don't *think* so, and from looking at the code, I'm not seeing how you'd do it. But I could be wrong.

Unless Lazylib or Magiclib has some special spell I'm not aware of, the only way I think you might be able to do this would be to set up an EveryFrameCombat script that checks for:
...

(That sounds about right, yeah.)

What does the "restricted", "req_military" and "merc" tags do?

I'm assuming "hist1t" and "hist2t" are story related to the historian and what types of blueprints are available from him/her. And "auto_rec" is what ships can be recovered from Automated Ships?

restricted is for hiding things in the Codex, missions, and the campaign menu dialog.

hist1t/2t, yeah, you got it - it's the tier of item for the historian, determined by how many times you've donated to him or her.

And, correct re: auto_rec.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on May 18, 2021, 07:05:03 PM
Unless I'm misreading the drop groups, 'restricted' also blocks most salvage apart from specific drop groups from dropping that item; the Omega weapons have drop groups that ignore 'restricted' but not 'no_drop'.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 18, 2021, 07:24:45 PM
^ Thanks to you both!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 18, 2021, 11:34:15 PM
Thing I noticed recently:

In 0.9.1, and IIRC 0.95a-RC12 and earlier (although I think Tartiflette had this problem in the first RCs of 0.95a), I was able to attach the NetBeans debugger to Starsector and let it run while playing. This was pretty convenient for dev work, because I can just edit my code and hit Apply Code Changes whenever I want to make live changes to my mod.

In 0.95a-RC15, when the debugger is running the game slows to a crawl (low single-digit FPS). So I have to stop debugging once I've made my changes, which is pretty annoying if I have to make and check a bunch of changes in quick succession.

What caused the change, and is there a way to fix it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 18, 2021, 11:42:31 PM
How do I get the sound to loop and not re-start ever frame?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 19, 2021, 05:04:05 AM
Thing I noticed recently:

In 0.9.1, and IIRC 0.95a-RC12 and earlier (although I think Tartiflette had this problem in the first RCs of 0.95a), I was able to attach the NetBeans debugger to Starsector and let it run while playing. This was pretty convenient for dev work, because I can just edit my code and hit Apply Code Changes whenever I want to make live changes to my mod.

In 0.95a-RC15, when the debugger is running the game slows to a crawl (low single-digit FPS). So I have to stop debugging once I've made my changes, which is pretty annoying if I have to make and check a bunch of changes in quick succession.

What caused the change, and is there a way to fix it?

Check how many breakpoints you have. More than 2-3 across all your open projects in Netbeans can cause horrible performance.

EDIT: Windows -> Debugging -> Breakpoints to see all your breakpoints.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on May 19, 2021, 06:56:56 AM
How do I get equipped wing spec in applyEffectAfterShip method?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on May 19, 2021, 08:22:46 AM
I'm in the process of updating my mod. For some reason, one of the three solar systems added, should appear south-west of Eos star. Instead, it falls next to Hybrasil star. I tried change the coordinates in starmap.json to no avail. The system addition predate the current 0.95 version, and have always been working fine. Have any idea of what may be wrong?

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2021, 08:28:18 AM
How do I get equipped wing spec in applyEffectAfterShip method?

Probably ship.getLaunchBaysCopy() and go from there.


Thing I noticed recently:

In 0.9.1, and IIRC 0.95a-RC12 and earlier (although I think Tartiflette had this problem in the first RCs of 0.95a), I was able to attach the NetBeans debugger to Starsector and let it run while playing. This was pretty convenient for dev work, because I can just edit my code and hit Apply Code Changes whenever I want to make live changes to my mod.

In 0.95a-RC15, when the debugger is running the game slows to a crawl (low single-digit FPS). So I have to stop debugging once I've made my changes, which is pretty annoying if I have to make and check a bunch of changes in quick succession.

What caused the change, and is there a way to fix it?

Hmm, it's hard to imagine what might have done that. I haven't changed anything that should have any impact here.


I'm in the process of updating my mod. For some reason, one of the three solar systems added, should appear south-west of Eos star. Instead, it falls next to Hybrasil star. I tried change the coordinates in starmap.json to no avail. The system addition predate the current 0.95 version, and have always been working fine. Have any idea of what may be wrong?

Thanks!

Maybe your code is setting the location directly, so the locations in starmap.json get overridden?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on May 19, 2021, 08:42:33 AM
How do I get equipped wing spec in applyEffectAfterShip method?

Probably ship.getLaunchBaysCopy() and go from there.
So the issue is, it does get the correct array size but the getWing() returns null.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2021, 09:16:15 AM
Ah, right, right! The wing is only initialized when the ship is deployed. Something like this, then:

Code
for (String wingId : ship.getVariant().getFittedWings()) {
FighterWingSpecAPI spec = Global.getSettings().getFighterWingSpec(wingId);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on May 19, 2021, 11:30:48 AM

I'm in the process of updating my mod. For some reason, one of the three solar systems added, should appear south-west of Eos star. Instead, it falls next to Hybrasil star. I tried change the coordinates in starmap.json to no avail. The system addition predate the current 0.95 version, and have always been working fine. Have any idea of what may be wrong?

Thanks!

Maybe your code is setting the location directly, so the locations in starmap.json get overridden?

Haha that's very kind of you to think I can do that by I don't have this kind a skill :)
I dug a bit on the problem. It seems the system is actually landing at the 0,0 x,y coordinate on the star map. I tested with an old version of my mod and generate the same problem. Since it never happened before, my guess is it seems related to the 0.95 version of Starsector, but I have no idea why.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 19, 2021, 11:41:13 PM
As I'm fixing up a mod and goig trough the log files, I find errors liek these:

Code
519913 [Thread-3] WARN  com.fs.starfarer.ui.impl.CargoTooltipFactory  - Error figuring out MIRV spec details for [mis-uin-frag-med]
org.json.JSONException: JSONObject["emp"] not found.
at org.json.JSONObject.get(JSONObject.java:406)
at org.json.JSONObject.getDouble(JSONObject.java:445)
at com.fs.starfarer.ui.impl.CargoTooltipFactory.o00000(Unknown Source)
at com.fs.starfarer.ui.impl.CargoTooltipFactory$4.createImpl(Unknown Source)
at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.create(Unknown Source)
at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.beforeShown(Unknown Source)
at com.fs.starfarer.ui.o00O.showTooltip(Unknown Source)
at com.fs.starfarer.ui.Objectsuper.o?0000(Unknown Source)
at com.fs.starfarer.ui.Objectsuper.processInput(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.campaign.ui.trade.CargoDataGridView.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.e$Oo.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.e.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.campaign.ui.oOoO.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.coreui.k.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.newui.class.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.Oo0O.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.newui.K.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.Oo0O.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.newui.Stringsuper.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.processInput(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The strange this that the weapon does not have EMP damage, (in the weapon_data) nor does the word emp show up in the weapon file or the projectile file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 19, 2021, 11:59:13 PM
I'm in the process of updating my mod. For some reason, one of the three solar systems added, should appear south-west of Eos star. Instead, it falls next to Hybrasil star. I tried change the coordinates in starmap.json to no avail. The system addition predate the current 0.95 version, and have always been working fine. Have any idea of what may be wrong?

Thanks!

I'm having the same issue.
2 of my systems just show up in wrong places.

I checked all of the scripts and the ONLY place coordiantes are ever mentioned is starmap.json
The gen script just imports the individual system files, generates them, and assigns faction relations.

The game dumps 3 systems into one pace, so it gets crowded.

Code
		"vns_vaynar": [10000,15000],
"vns_gammadraconis": [8000,17000],
"isa_argos": [13000,13000],
"isa_shington": [15000,15000],
"rsf_lomonosov": [11000,18000],
"rsf_barnard": [14000,19000],
"rsf_vega": [12000,21000],
"uin_centronom": [6500,13000],
"uin_achiles": [7500,15000],
"xle_procyon": [5000,21000],   <---- these two basically end up close to Mayasura, overlaping that TRi-tach system to it's upper right.
"xle_uomoz": [6000,19000],
"ffs_impalo": [2000,14000],
"ffs_kores": [1000,16000], <--- these two

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 20, 2021, 12:21:42 AM
I'm on a roll, so another question:

I have the modPlugin script that also sets this up:

Code
   @Override
    public void onNewGameAfterEconomyLoad() {
        MarketAPI market = Global.getSector().getEconomy().getMarket("avalon");
        if (market != null) {
            PersonAPI admin = Global.getFactory().createPerson();
            admin.setFaction("VNS");
            admin.setGender(Gender.MALE);
            admin.setPostId(Ranks.POST_FACTION_LEADER);
            admin.setRankId(Ranks.FACTION_LEADER);
            admin.getName().setFirst("Gabriel");
            admin.getName().setLast("Algar");
            admin.setPortraitSprite("graphics/portraits/prt_vns_algar.png");

            market.setAdmin(admin);
            market.getCommDirectory().addPerson(admin, 0);
            market.addPerson(admin);
        }
    }


It works, but the portrait does not show up.
The portrait's path is correct, it's the same format as all others...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on May 20, 2021, 05:42:19 AM
What does the "restricted", "req_military" and "merc" tags do?
I'm assuming "hist1t" and "hist2t" are story related to the historian and what types of blueprints are available from him/her. And "auto_rec" is what ships can be recovered from Automated Ships?
restricted is for hiding things in the Codex, missions, and the campaign menu dialog.
hist1t/2t, yeah, you got it - it's the tier of item for the historian, determined by how many times you've donated to him or her.
And, correct re: auto_rec.
I'm sorry if I missed it but was there an answer to what "req_military" and "merc" tags do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2021, 09:41:57 AM
Haha that's very kind of you to think I can do that by I don't have this kind a skill :)
I dug a bit on the problem. It seems the system is actually landing at the 0,0 x,y coordinate on the star map. I tested with an old version of my mod and generate the same problem. Since it never happened before, my guess is it seems related to the 0.95 version of Starsector, but I have no idea why.

Hmm - nothing else comes to mind, unfortunately. I'd suggest maybe finding the simplest mod you can that does this successfuly and trying to figure out what the difference is.


519913 [Thread-3] WARN  com.fs.starfarer.ui.impl.CargoTooltipFactory  - Error figuring out MIRV spec details for [mis-uin-frag-med]
org.json.JSONException: JSONObject["emp"] not found.

This means that the "emp" field is missing in the mirv split definition for that weapon, in the .proj file for the first stage.


It works, but the portrait does not show up.
The portrait's path is correct, it's the same format as all others...

Probably because the portrait isn't actually loaded by the game. It needs to either be present in a .faction file, or in one of the subsections in the "graphics" section of settings.json, for it to actually be loaded by the game.


I'm sorry if I missed it but was there an answer to what "req_military" and "merc" tags do?

Ah no, I just missed it.

"merc" is a tag used by the mercenary faction, so stuff tagged with that is available to it. Generally only the top-tier stuff is flagged with this. This faction is used for some of the fleets you encounter during the story, and for some of the top-end bounties.

"req_military" means a hull is sold *only* on military submarkets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 20, 2021, 11:00:29 AM
This means that the "emp" field is missing in the mirv split definition for that weapon, in the .proj file for the first stage.

Thanks, odd, since no EMP damage is defined. I'll check.

OK, I've done NOTHING and the warnings in the log are no more....


Quote
It works, but the portrait does not show up.
The portrait's path is correct, it's the same format as all others...

Probably because the portrait isn't actually loaded by the game. It needs to either be present in a .faction file, or in one of the subsections in the "graphics" section of settings.json, for it to actually be loaded by the game.

from my (well, not "mine" mine, I'm fixing an abandoned mod) settings.json, under graphics:

      "characters":{
         "algar":"graphics/portraits/prt_vns_algar.png",
         "forsythe":"graphics/portraits/prt_vns_m_22.png",
      },   


I guess I should just cal "algar" in the script?


And to go back to my earlier question - I call a sound from everyFrame, since I'm checking special weapon animation and callig weapon sounds from the weapon file doesn't work in this case. How do I force it to play until the end before re-starting?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 20, 2021, 05:54:56 PM
Is there a way to make a ship unable to capture objectives?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MajorTheRed on May 21, 2021, 07:24:07 AM
Quote
Quote from: MajorTheRed on May 19, 2021, 11:30:48 AM

    Haha that's very kind of you to think I can do that by I don't have this kind a skill :)
    I dug a bit on the problem. It seems the system is actually landing at the 0,0 x,y coordinate on the star map. I tested with an old version of my mod and generate the same problem. Since it never happened before, my guess is it seems related to the 0.95 version of Starsector, but I have no idea why.


Hmm - nothing else comes to mind, unfortunately. I'd suggest maybe finding the simplest mod you can that does this successfuly and trying to figure out what the difference is.

Alex, I found the problem, here is the solution just in case:

It very silly: in the name.java file in data/script/world/systems/ there was a caps missing in the following line:
      PlanetAPI byzos_star = system.initStar("byzos", // unique id for this star
In my case, "Byzos" was initially missing a caps on the "b", so I ended up with something like that:
      PlanetAPI byzos_star = system.initStar("Byzos", // unique id for this star

Please note that I make some tries with the Nakara system file just to check where was the problem. It has the same spelling problem.

Thanks again for the support!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2021, 12:03:04 PM
from my (well, not "mine" mine, I'm fixing an abandoned mod) settings.json, under graphics:

      "characters":{
         "algar":"graphics/portraits/prt_vns_algar.png",
         "forsythe":"graphics/portraits/prt_vns_m_22.png",
      },   


I guess I should just cal "algar" in the script?

What you're doing looks right, so I'm not sure. You would *not* pass in "algar" to that method. You might instead pass in Global.getSettings().getSpriteName("characters", "algar") but that would be the same as just passing in the path to the sprite. Make sure the sprite actually exists, I guess, and is named exactly what's type into the other files, including capitalization?

And to go back to my earlier question - I call a sound from everyFrame, since I'm checking special weapon animation and callig weapon sounds from the weapon file doesn't work in this case. How do I force it to play until the end before re-starting?

If you want to play a loop, you'd call playLoop(). Or if your sound doesn't loop, you could track how long it's been and play it every so often instead of on every frame.


Is there a way to make a ship unable to capture objectives?

I don't think so.

Alex, I found the problem, here is the solution just in case:

It very silly: in the name.java file in data/script/world/systems/ there was a caps missing in the following line:
      PlanetAPI byzos_star = system.initStar("byzos", // unique id for this star
In my case, "Byzos" was initially missing a caps on the "b", so I ended up with something like that:
      PlanetAPI byzos_star = system.initStar("Byzos", // unique id for this star

Please note that I make some tries with the Nakara system file just to check where was the problem. It has the same spelling problem.

Thanks again for the support!

Ah, thanks! Naraka is fine because it's lowercased both in starmap.json and as the id. Doesn't matter which way you go, as long as it's consistent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on May 22, 2021, 02:04:04 AM
Skins:These are just a shorthand for defining new hulls. The game takes the .skin file and creates a new hull based on that; for almost every purpose within the game, it's treated as an entirely separate hull. You can't change skins for a ship once you have it, for example. "Skin" might be slightly misleading as it encompasses more than just appearance. Skins can, for example change/remove weapon and engine slots, change the OP/deployment points/price, add/remove built in hull mods and weapons. Skins can not change the bounds or weapon slot locations, and also can't change the ship's system (the latter, at least for the moment).
So.. reading this.. how do I change deployment points on a .skin ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Aramoro on May 22, 2021, 10:57:14 AM
Hey any1 know how i can add Blueprints to a factions military base/shop?



Quote
So.. reading this.. how do I change deployment points on a .skin ship.
that is a good question

as far as i know its under "supplies/rec" in the .csv, but will it work in skins too?

try:

"supplies/rec" :insert_number ,

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 22, 2021, 12:48:07 PM
So.. reading this.. how do I change deployment points on a .skin ship.

Doesn't look like you can, actually, either directly in the skin or with a hullmod.

Hey any1 know how i can add Blueprints to a factions military base/shop?

You'd want to add them directly to the military submarket's cargo, probably by using a SubmarketInteractionListener (and adding it to SectorAPI.getListenerManager().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Aramoro on May 22, 2021, 03:57:12 PM
So.. reading this.. how do I change deployment points on a .skin ship.
Doesn't look like you can, actually, either directly in the skin or with a hullmod.
looks like u need to add the skin as a new ship instead, the colossus II and III are added like this too, they have different dp costs, now we know wy

Hey any1 know how i can add Blueprints to a factions military base/shop?

You'd want to add them directly to the military submarket's cargo, probably by using a SubmarketInteractionListener (and adding it to SectorAPI.getListenerManager().

thx, but i was thinking there was an easier way, still its wort looking into, it could be useful for a lot of things
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inhilicon on May 22, 2021, 06:40:04 PM
Can you have a low-tech or midline ship use Plasma Jets and can you have a high-tech ship use Burn Drive? What are the colors of the jets for low-tech and midline ships?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 22, 2021, 07:38:50 PM
Can you have a low-tech or midline ship use Plasma Jets and can you have a high-tech ship use Burn Drive? What are the colors of the jets for low-tech and midline ships?

You can, yeah. IIRC Burn Drive keeps the engine color being whatever it is, while Plasma Jets shifts it towards green, regardless of the ship's normal engine color. You can check the relevant .system file for details (Plasma Jets is defined in microburn.system, btw.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inhilicon on May 23, 2021, 07:53:00 AM
Can you have a low-tech or midline ship use Plasma Jets and can you have a high-tech ship use Burn Drive? What are the colors of the jets for low-tech and midline ships?

You can, yeah. IIRC Burn Drive keeps the engine color being whatever it is, while Plasma Jets shifts it towards green, regardless of the ship's normal engine color. You can check the relevant .system file for details (Plasma Jets is defined in microburn.system, btw.)

Very cool! Thank you very much, Alex. I will fiddle with it for my mod and maybe come up with something cool!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 23, 2021, 09:31:53 AM
Have fun :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 23, 2021, 02:37:42 PM
Ran into a strange crash while testing when the AI fleet I was following attacked a pirate scav fleet:

Spoiler
527810 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.winningPath(FleetInteractionDialogPluginImpl.java:1977)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.optionSelec ted(FleetInteractionDialogPluginImpl.java:1481)
   at com.fs.starfarer.ui.newui.Stringsuper.dismiss(Unknown Source)
   at com.fs.starfarer.ui.Oo0O.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.Stringsuper.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.processInput(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

I have no idea what could have caused this. Did I configure something wrong when spawning the AI fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 23, 2021, 02:55:16 PM
Just for future reference, since this came up a bit earlier here: added ability to specify suppliesToRecover and suppliesPerMonth in .skin files.


Ran into a strange crash while testing when the AI fleet I was following attacked a pirate scav fleet:

Spoiler
527810 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.winningPath(FleetInteractionDialogPluginImpl.java:1977)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.optionSelec ted(FleetInteractionDialogPluginImpl.java:1481)
   at com.fs.starfarer.ui.newui.Stringsuper.dismiss(Unknown Source)
   at com.fs.starfarer.ui.Oo0O.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.Stringsuper.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.processInput(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

I have no idea what could have caused this. Did I configure something wrong when spawning the AI fleet?

The crash is in plugin code the source of which you can view, btw. So, huh - this means the dialog member variable in the plugin is somehow null, which is odd, because that should be set when the plugin is initialized, in the init() method, and isn't set anywhere else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 24, 2021, 01:22:07 AM
Alex, I found the problem, here is the solution just in case:

It very silly: in the name.java file in data/script/world/systems/ there was a caps missing in the following line:
      PlanetAPI byzos_star = system.initStar("byzos", // unique id for this star
In my case, "Byzos" was initially missing a caps on the "b", so I ended up with something like that:
      PlanetAPI byzos_star = system.initStar("Byzos", // unique id for this star

Please note that I make some tries with the Nakara system file just to check where was the problem. It has the same spelling problem.

Thanks again for the support!


I actually tried this for my own issue. Still not solved.

I've compared the files of systems that spawn correctly with the ones that don't, and I just can't figure out why ONLY these two (Procyon and Kores) spawn over Hybrasil, instead of their supposed location.

If anyone can take a look, files are here:  (just core files)
https://www.nexusmods.com/starsector/mods/56
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on May 24, 2021, 06:44:23 AM
https://fractalsoftworks.com/forum/index.php?topic=21538.0

my ships are named <missing name>. what did i do wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Aramoro on May 24, 2021, 03:31:24 PM
https://fractalsoftworks.com/forum/index.php?topic=21538.0

my ships are named <missing name>. what did i do wrong?

(https://i.ibb.co/Xb66ZVH/screenshot016.png) (https://ibb.co/FKccbnp)

here i "FIXED" it for u ;D

no, for real...

open the:
ship_data.csv in ur Open office or whatever, click save, CSV format yes yes, done

probably a bug...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 24, 2021, 07:00:42 PM
Turns out my debugging lag issue was indeed as SafariJohn said, I had one (1) undeleted breakpoint and removing it made the issue go away. Whoops!

Alex, I found the problem, here is the solution just in case:

It very silly: in the name.java file in data/script/world/systems/ there was a caps missing in the following line:
      PlanetAPI byzos_star = system.initStar("byzos", // unique id for this star
In my case, "Byzos" was initially missing a caps on the "b", so I ended up with something like that:
      PlanetAPI byzos_star = system.initStar("Byzos", // unique id for this star

Please note that I make some tries with the Nakara system file just to check where was the problem. It has the same spelling problem.

Thanks again for the support!
I actually tried this for my own issue. Still not solved.

I've compared the files of systems that spawn correctly with the ones that don't, and I just can't figure out why ONLY these two (Procyon and Kores) spawn over Hybrasil, instead of their supposed location.

If anyone can take a look, files are here:  (just core files)
https://www.nexusmods.com/starsector/mods/56
If you're going to provide a mod for testing, at least make it work from the start without CTDs and not require the person to manually arrange folders from two different zips.

Anyway the issue seems to be that the starmap.json locations aren't being used at all, the star system IDs in it don't match what they're spawned with. The other systems spawn fine anyway because their location is set in the script, e.g.
Code: java
system.getLocation().set(24000, 16000);   	
Set those two star systems' locations in the script as well. Changing the ID of their stars to match the starmap.json entries would also work, but requires a bit of find/replace work.

(I think every single major mod with a starmap.json that I checked also has non-matching IDs that rely on in-script location setting, except DME)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 25, 2021, 12:24:45 AM
OH hell, how did I miss that?  :-[
Thanks, you're a life saver!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 25, 2021, 04:40:54 AM
A question I have to ask again - sounds control.

Any way to check if a sound is currently playing, or if it finished playing?
I have a weapon that I have to control fully trough scripts, including sounds - and while the warmup and powerdown are simple (just check in which charge state I am, play it and set a boolean so it's not triggered again on next frame update), but fire does not have a 100% set duration (it has a maximum, but it can be shorter), so the sound has to be looped.
Right now it just keeps getting re-started every frame, so it sounds bad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stealth on May 25, 2021, 05:47:04 AM
https://fractalsoftworks.com/forum/index.php?topic=21538.0

my ships are named <missing name>. what did i do wrong?

(https://i.ibb.co/Xb66ZVH/screenshot016.png) (https://ibb.co/FKccbnp)

here i "FIXED" it for u ;D

no, for real...

open the:
ship_data.csv in ur Open office or whatever, click save, CSV format yes yes, done

probably a bug...

Thank you very much
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on May 25, 2021, 06:04:56 PM
Is the FluxTrackerAPI.getCurrFlux() the sum of hard and soft flux or soft flux only?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 25, 2021, 07:18:49 PM
Is the FluxTrackerAPI.getCurrFlux() the sum of hard and soft flux or soft flux only?

The sum of hard and soft flux.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 25, 2021, 09:32:47 PM
Two mod bug questions:

- LazyLib contains this method:
Spoiler
Code: java
/**
     * Spawns a ship directly onto the battle map, bypassing the fleet reserves.
     *
     * <b>NOTE: this method will not work out of the box in the campaign (.6.2a)
     * due to an after-battle crash in the default FleetEncounterContextPlugin
     * caused by spawned ships not being registered with the fleet.</b>
     *
     * @param variantId       The ID of the ship variant to spawn.
     * @param type            Whether this is a ship or a fighter wing.
     * @param side            What side of the battle this ship should fight on.
     * @param combatReadiness The CR the ship should start with.
     * @param location        The location on the battle map the ship should
     *                        spawn at.
     * @param facing          The initial facing of the ship on the battle map.
     *
     * @return The {@link ShipAPI} that was spawned by this method.
     *
     * @since 1.9
     */
    public static ShipAPI spawnShipOrWingDirectly(String variantId,
                                                  FleetMemberType type, FleetSide side, float combatReadiness,
                                                  Vector2f location, float facing)
    {
        FleetMemberAPI member = Global.getFactory().createFleetMember(type, variantId);
        member.getCrewComposition().addCrew(member.getNeededCrew());
        ShipAPI ship = Global.getCombatEngine().getFleetManager(side)
                .spawnFleetMember(member, location, facing, 0f);
        ship.setCRAtDeployment(combatReadiness);
        ship.setCurrentCR(combatReadiness);
        ship.setOwner(side.ordinal());
        ship.getShipAI().forceCircumstanceEvaluation();
        return ship;
    }
[close]
Example usage:
Code: java
runcode CombatUtils.spawnShipOrWingDirectly("mudskipper_Hull", FleetMemberType.SHIP, FleetSide.ENEMY, 0.7f, new Vector2f(0, 0), 0);
Here's the thing: I can use this to spawn a ship on the enemy side, as per the above console command. But when it dies, the "<shipname> disabled" message in the top-left uses the green color of friendly ships. Is this a bug in the base game's combat engine?

- Could this bug be looked at (https://fractalsoftworks.com/forum/index.php?topic=21619.0)? I realize it's a pretty rare issue specific to particular mod circumstances, but the crash log indicates it's happening within base game code.

A question I have to ask again - sounds control.

Any way to check if a sound is currently playing, or if it finished playing?
I have a weapon that I have to control fully trough scripts, including sounds - and while the warmup and powerdown are simple (just check in which charge state I am, play it and set a boolean so it's not triggered again on next frame update), but fire does not have a 100% set duration (it has a maximum, but it can be shorter), so the sound has to be looped.
Right now it just keeps getting re-started every frame, so it sounds bad.
Doesn't seem like the sound player API has a way to do that.

Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 26, 2021, 12:01:47 AM
A question I have to ask again - sounds control.

Any way to check if a sound is currently playing, or if it finished playing?
I have a weapon that I have to control fully trough scripts, including sounds - and while the warmup and powerdown are simple (just check in which charge state I am, play it and set a boolean so it's not triggered again on next frame update), but fire does not have a 100% set duration (it has a maximum, but it can be shorter), so the sound has to be looped.
Right now it just keeps getting re-started every frame, so it sounds bad.
Doesn't seem like the sound player API has a way to do that.

Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.

I don't see how that would be any better, I would still need some way to check when to paly the next part. Hmmm... a timer?
IF I know my looping fire sounds is 2 seconds, I can make a timer that counts frames and only isses the "play sound" after 2 seconds. How many frames is 2 seconds?



And another question - any example of fleet spawning script? Can someone point me to a mod that has scripts that spawn fleets that are viewable (I know a few, but all the scripts are in a .jar)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on May 26, 2021, 09:37:37 AM
In variant, if I don’t set target variant to true, can they still spawn?
I want a challenging merc specific variant but doesn’t want to bloat the player shown suggested variant list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2021, 10:27:45 AM
- LazyLib contains this method:
...
Here's the thing: I can use this to spawn a ship on the enemy side, as per the above console command. But when it dies, the "<shipname> disabled" message in the top-left uses the green color of friendly ships. Is this a bug in the base game's combat engine?

Hmm - I think the LazyLib method is missing something like:
if (side == FleetSize.PLAYER) {
   member.setOwner(0);
} else {
   member.setOwner(1);
}

- Could this bug be looked at (https://fractalsoftworks.com/forum/index.php?topic=21619.0)? I realize it's a pretty rare issue specific to particular mod circumstances, but the crash log indicates it's happening within base game code.

Fixed both up. I'm not honestly sure why it was crashing there - didn't dig into it enough. It's something to do with showing a fleet info panel in the new game dialog sequence, though, when a campaign engine doesn't yet exist. I'm not 100% that another similar crash might not crop up, but this specific sequence, at least, now goes through fine.


Doesn't seem like the sound player API has a way to do that.

Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.

Hmm - I think SoundAPI.stop() should do it? And the various playSound() methods return a SoundAPI.

In variant, if I don’t set target variant to true, can they still spawn?
I want a challenging merc specific variant but doesn’t want to bloat the player shown suggested variant list.

Yes, that should be fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on May 26, 2021, 04:41:25 PM
And another question - any example of fleet spawning script? Can someone point me to a mod that has scripts that spawn fleets that are viewable (I know a few, but all the scripts are in a .jar)

Check out "src\archeus\campaign\tutorial\AOGuardMiscFleetManager in my mod (https://fractalsoftworks.com/forum/index.php?topic=13183.0).

It has a few examples of this. Bear in mind that this code isn't actually used at the moment since I haven't finished the tutorial so there is a chance it won't work as expected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 26, 2021, 11:44:17 PM
Doesn't seem like the sound player API has a way to do that.

Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.

Hmm - I think SoundAPI.stop() should do it? And the various playSound() methods return a SoundAPI.

I'm not sure you understand - starting a sound or playing it isn't the real issue - making the sound loop naturally is.
Basically, within an EveryFrame scrip, and within the main fire squence (powerup and powerdown work) I have to know when the sound finished playing to start playing it again, for as long as the weapon is fireing.

The weapon itself can fire for 10 seconds (or less, depending on flux level). Since it's a builtin weapon, I COULD just  remove any ties to flux and make it so it will ALWAYS fire for 10 seconds, but I don't like that solution.
I could also edit the fire sound ot be exactly 10 second long and only play it once, but again...seems like a bad solution.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on May 27, 2021, 06:27:58 AM
Doesn't seem like the sound player API has a way to do that.

Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.

Hmm - I think SoundAPI.stop() should do it? And the various playSound() methods return a SoundAPI.

I'm not sure you understand - starting a sound or playing it isn't the real issue - making the sound loop naturally is.
Basically, within an EveryFrame scrip, and within the main fire squence (powerup and powerdown work) I have to know when the sound finished playing to start playing it again, for as long as the weapon is fireing.

The weapon itself can fire for 10 seconds (or less, depending on flux level). Since it's a builtin weapon, I COULD just  remove any ties to flux and make it so it will ALWAYS fire for 10 seconds, but I don't like that solution.
I could also edit the fire sound ot be exactly 10 second long and only play it once, but again...seems like a bad solution.

If a looping sound is what you're after, you should look into
Code
Global.getSoundPlayer().playLoop()
and its overloads. These all allows a looping sound to be played on command, and you can change their properties such as pitch and volume as they loop. Needs to be called once per frame to keep the loop going, but otherwise it sounds like exactly what you're looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on May 27, 2021, 06:33:40 AM
Is there a method for getting unassigned officers?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 27, 2021, 08:29:58 AM
Doesn't seem like the sound player API has a way to do that.

Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.

Hmm - I think SoundAPI.stop() should do it? And the various playSound() methods return a SoundAPI.

I'm not sure you understand - starting a sound or playing it isn't the real issue - making the sound loop naturally is.
Basically, within an EveryFrame scrip, and within the main fire squence (powerup and powerdown work) I have to know when the sound finished playing to start playing it again, for as long as the weapon is fireing.

The weapon itself can fire for 10 seconds (or less, depending on flux level). Since it's a builtin weapon, I COULD just  remove any ties to flux and make it so it will ALWAYS fire for 10 seconds, but I don't like that solution.
I could also edit the fire sound ot be exactly 10 second long and only play it once, but again...seems like a bad solution.

If a looping sound is what you're after, you should look into
Code
Global.getSoundPlayer().playLoop()
and its overloads. These all allows a looping sound to be played on command, and you can change their properties such as pitch and volume as they loop. Needs to be called once per frame to keep the loop going, but otherwise it sounds like exactly what you're looking for.

So I need to replace this: Global.getSoundPlayer().playSound("vns_Reflex_fire", 1f, 1f, point, ZERO);

with the below?

void    playLoop(java.lang.String id, java.lang.Object playingEntity, float pitch, float volume, Vector2f loc, Vector2f vel)


What would be a playingEntity? I'm not sure what goes there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 27, 2021, 09:22:20 AM
Is there a method for getting unassigned officers?

Not as such, but you can figure it out by calling playerFleet.getFleetData().getOfficerData() and then seeing which if them are, in fact, not assigned to any of the player's ships.



(Right, yes, playLoop - I was assuming you didn't want to use that for some reason, and since you said you had a fixed maximum duration for the sound...

You should just pass in the ship for the playing entity. The game uses that parameter to track what's playing the loop so that it knows that the subsequent playLoop calls on other frames in fact refer to the same loop being played and aren't a new looping sound to play.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nicke535 on May 27, 2021, 11:07:48 AM
Doesn't seem like the sound player API has a way to do that.

Mega gross workaround I thought of: Break up the sound into chunks (say 0.5 seconds each).
In the weapon script, at each interval, check if we should continue playing the overall sound effect. If yes, play the next sound in the sequence, if not, reset and leave.

Hmm - I think SoundAPI.stop() should do it? And the various playSound() methods return a SoundAPI.

I'm not sure you understand - starting a sound or playing it isn't the real issue - making the sound loop naturally is.
Basically, within an EveryFrame scrip, and within the main fire squence (powerup and powerdown work) I have to know when the sound finished playing to start playing it again, for as long as the weapon is fireing.

The weapon itself can fire for 10 seconds (or less, depending on flux level). Since it's a builtin weapon, I COULD just  remove any ties to flux and make it so it will ALWAYS fire for 10 seconds, but I don't like that solution.
I could also edit the fire sound ot be exactly 10 second long and only play it once, but again...seems like a bad solution.

If a looping sound is what you're after, you should look into
Code
Global.getSoundPlayer().playLoop()
and its overloads. These all allows a looping sound to be played on command, and you can change their properties such as pitch and volume as they loop. Needs to be called once per frame to keep the loop going, but otherwise it sounds like exactly what you're looking for.

So I need to replace this: Global.getSoundPlayer().playSound("vns_Reflex_fire", 1f, 1f, point, ZERO);

with the below?

void    playLoop(java.lang.String id, java.lang.Object playingEntity, float pitch, float volume, Vector2f loc, Vector2f vel)


What would be a playingEntity? I'm not sure what goes there.

The playingEntity would be your weapon or ship (don't remember, someone correct me here); it's used so that two of the same "source" with a looping sound doesn't result in two different sounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on May 28, 2021, 05:48:52 AM
how would I get all the stats affecting spread and accuracy of weapons? I have an inaccurate beam I do via script, and I wanted to apply these stats to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 28, 2021, 10:45:09 AM
MutableShipStatsAPI:
public MutableStat getMaxRecoilMult();
public MutableStat getRecoilPerShotMult();
public MutableStat getRecoilDecayMult();
MutableStat getRecoilPerShotMultSmallWeaponsOnly(); <- not actually used by anything in vanilla, but still respected by the weapons
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on May 30, 2021, 12:22:24 AM
So if officer_manager is commented out in the events.json

Does that mean officer_manager can no longer be touched or is there an alternative way? A pity if so.  :-\
It's just added as a script now.

So this means I would have to use it with mod_file.json's replace to replace the file?  :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ElPresidente on May 30, 2021, 09:16:27 AM
Advice wanted. I have a shipsystem that doubles the range of all weapons, but the ship cannot move nor have shields raised while it's active.

Works great for he player, but the AI turns on the system...and never turn it off... Thus cannot move.
The aiType used is weapon boost. Didn't write my own AI because I struggle with even basic code, let alone writing AI.

Code
{
"id":"sc_gunboost",
"type":"STAT_MOD",
"aiType":"WEAPON_BOOST",

"statsScript":"data.shipsystems.scripts.sc_gunboost",

#"weaponGlowColor":[0,0,50,100],
#"weaponTypes":[BALLISTIC],

"useSound":"system_ammo_feeder",
"outOfUsesSound":"gun_out_of_ammo",
}

This is the ship_systems.scv entry:
Gunbooster,sc_gunboost,2,,,,,0.25,,0.05,0.5,20,0.5,20,,,,,,,TRUE,TRUE,TRUE,,graphics/icons/hullsys/missile_autoforge.png

Any suggestions on how to best address it? I'm not sure what half the values do anymore.


EDIT: Seem the last change I made (removed toggle TRUE and added duration) made the AI not derp.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 30, 2021, 08:10:34 PM
Does copying an entity's memory copy its tags or are they stored separately?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on May 30, 2021, 08:43:11 PM
I made a comment in this thread once, and ever since i have had this on my 'new replies to my posts' page every time i log, and cannot find any way to stop it. hell, i couldnt even delete my posts to see if that worked.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on May 30, 2021, 10:41:20 PM
I made a comment in this thread once, and ever since i have had this on my 'new replies to my posts' page every time i log, and cannot find any way to stop it. hell, i couldnt even delete my posts to see if that worked.
In your profile (under Modify Profile) there is a Notifications and Email section.
There should be a Current Topic Notifications section there, where you should be able to checkmark the topic and select Unsubscribe at the bottom.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on May 31, 2021, 12:06:11 AM
I made a comment in this thread once, and ever since i have had this on my 'new replies to my posts' page every time i log, and cannot find any way to stop it. hell, i couldnt even delete my posts to see if that worked.
In your profile (under Modify Profile) there is a Notifications and Email section.
There should be a Current Topic Notifications section there, where you should be able to checkmark the topic and select Unsubscribe at the bottom.

i can only find the option to disable all of em, which i dont want to do. this is the only thread i dont want to keep following.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 31, 2021, 04:19:44 AM
Next to "reply", it should say "unnotify"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on May 31, 2021, 04:54:47 AM
it says 'notify', and if i choose it will send me more notificaitons. the place this is showing up is the 'show new replies to your posts' next to your username. seems odd to me you cant opt out of one thread, without opting out of all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: L:atte Mint on May 31, 2021, 07:58:32 PM
I'm thinking about creating a submarket, that giving player designed item when player sells their items (for example, AI core),
but I got no idea how to build it with current submarketplugin interface or BaseSubmarketPlugin
I know that I should determine player's action with TransferAction.PLAYER_SELL, but not sure where to implement this...
 ;) Any idea?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 31, 2021, 08:42:23 PM
Does copying an entity's memory copy its tags or are they stored separately?

They're separate.


I'm thinking about creating a submarket, that giving player designed item when player sells their items (for example, AI core),
but I got no idea how to build it with current submarketplugin interface or BaseSubmarketPlugin
I know that I should determine player's action with TransferAction.PLAYER_SELL, but not sure where to implement this...
 ;) Any idea?

You'd probably want to create a custom submarket plugin, and define a new submarket using it in data/campaign/submarkets.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: L:atte Mint on May 31, 2021, 08:53:32 PM
You'd probably want to create a custom submarket plugin, and define a new submarket using it in data/campaign/submarkets.csv
Thx for the reply ;), is that the function named reportPlayerMarketTransaction I need to implement?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on June 01, 2021, 06:30:31 AM
How to add extra industry or structure to a existing market as a mod?
Or change their faction allegiance?
I am taking about modifications that affect campaign start.
I know how to add it by modifying the files in main game folders(and it works well) but when I try to make it a separate mod(by taking file, add extra stuff) then I get wild results.
Like when switching faction ownership say from Path to pirate it still show as Path on big map and still spawn Path fleets instead of pirate one.
If any industry/structure is added it drop both production and accessibility to zero.

Also the Galatia system is missing from econ folder.
Can anyone help?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clouden on June 01, 2021, 11:20:06 AM
Hi!

What would be the best way to double the Automated fleet point limit of 30 on the Automated Ships skill?
Is it easier to change a parameter in the starfarer.api.impl.campaign.skills file or would you recommend another way to bump up the ammount of AI ships I can tag along with decent CR?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 01, 2021, 11:22:54 AM
Hi!

What would be the best way to double the Automated fleet point limit of 30 on the Automated Ships skill?
Is it easier to change a parameter in the starfarer.api.impl.campaign.skills file or would you recommend another way to bump up the ammount of AI ships I can tag along with decent CR?
The easiest way would probably be to download the Adjustable Skill Thresholds mod here: https://fractalsoftworks.com/forum/index.php?topic=20265.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Clouden on June 01, 2021, 11:35:28 AM
Hi!

What would be the best way to double the Automated fleet point limit of 30 on the Automated Ships skill?
Is it easier to change a parameter in the starfarer.api.impl.campaign.skills file or would you recommend another way to bump up the ammount of AI ships I can tag along with decent CR?
The easiest way would probably be to download the Adjustable Skill Thresholds mod here: https://fractalsoftworks.com/forum/index.php?topic=20265.0

That is indeed the easiest way possible :D

Thank you so so much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on June 01, 2021, 03:55:13 PM
would there be a way to add Cargo to any salvageable entity (research stations, mining stations etc., and their debris) without modifying drop groups? i'm trying not to affect the quantity of pristine nanoforges/other special items that one normally gets from salvaging these entities
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 01, 2021, 06:27:07 PM
Thx for the reply ;), is that the function named reportPlayerMarketTransaction I need to implement?

That sounds right, yeah. You can take a look at the vanilla implementations for examples/to get a handle on what those methods normally do.


How to add extra industry or structure to a existing market as a mod?
Or change their faction allegiance?
I am taking about modifications that affect campaign start.
I know how to add it by modifying the files in main game folders(and it works well) but when I try to make it a separate mod(by taking file, add extra stuff) then I get wild results.
Like when switching faction ownership say from Path to pirate it still show as Path on big map and still spawn Path fleets instead of pirate one.
If any industry/structure is added it drop both production and accessibility to zero.

That's going to need more detail as to specifically what you're doing and what you expect the results to be!


Also the Galatia system is missing from econ folder.

That's not a question :) But: the colonies there get added to the economy by code. See TutorialMissionEvent.endGalatiaPortionOfMission()


would there be a way to add Cargo to any salvageable entity (research stations, mining stations etc., and their debris) without modifying drop groups? i'm trying not to affect the quantity of pristine nanoforges/other special items that one normally gets from salvaging these entities

See this static method in BaseSalvageSpecial:
void addExtraSalvage(SectorEntityToken entity, CargoAPI cargo)

It should add stuff in the cargo to what the entity drops. You could also create your own drop group and do entity.addDropRandom() to have the entity pick from it in addition to its default drop groups.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on June 01, 2021, 07:27:25 PM
would there be a way to add Cargo to any salvageable entity (research stations, mining stations etc., and their debris) without modifying drop groups? i'm trying not to affect the quantity of pristine nanoforges/other special items that one normally gets from salvaging these entities

See this static method in BaseSalvageSpecial:
void addExtraSalvage(SectorEntityToken entity, CargoAPI cargo)

It should add stuff in the cargo to what the entity drops. You could also create your own drop group and do entity.addDropRandom() to have the entity pick from it in addition to its default drop groups.

to take advantage of this method, i'm trying to use an ExtraSalvageShownListener, however upon salvaging a research station i don't see my method (public void reportExtraSalvageShown(SectorEntityToken entity)) being called. is there another place i should be using it?

edit:
for those in the future, i used a ShowLootListener which has
public void reportAboutToShowLootToPlayer(CargoAPI loot, InteractionDialogAPI dialog)

from there i generate my own CargoAPI based on the dialog's interaction target's drop value and drop randoms, along with that of its salvage entity spec, and merge it with the loot passed to the listener.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 01, 2021, 09:31:41 PM
Is it possible to implement both FleetStatsSkillEffect and ShipSkillEffect within the same skill?

I was trying to add increased ground operations effectiveness to Target Analysis and I am getting a cast exception when it tries to cast the skill to a MarketSkillEffect.

I am assuming it is something to do with the SkillSpecAPI not being built the way it needs to be in order to be cast to a MarketSkillEffect if it was first cast to a ShipSkillEffect earlier in the code when generating the descriptions?

Exception log:

Spoiler
47311 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException: data.scripts.skills.ArcheusTargetAnalysis$Level6 cannot be cast to com.fs.starfarer.api.characters.MarketSkillEffect
java.lang.ClassCastException: data.scripts.skills.ArcheusTargetAnalysis$Level6 cannot be cast to com.fs.starfarer.api.characters.MarketSkillEffect
   at com.fs.starfarer.loading.SkillSpec$SkillEffectSpec.float(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2$3.createImpl(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.create(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2Expandable.beforeShown(Unknown Source)
   at com.fs.starfarer.coreui.U.new(Unknown Source)
   at com.fs.starfarer.ui.k.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.coreui.Ooo0.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.coreui.AptitudeRow.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Oo0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO$Oo.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Oo0oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.coreui.intnew.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.coreui.oo0o.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.D.oooO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.N.advanceImpl(Unknown Source)
   at com.fs.starfarer.campaign.save.O0oO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.ui.oO00OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.interface.advance(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on June 01, 2021, 11:23:04 PM
is it possible to have mercenaries needing credits instead of story points to renew contracts, WITHOUT removing the need to spend a point to hire em?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on June 02, 2021, 04:07:23 AM
is it possible to have mercenaries needing credits instead of story points to renew contracts, WITHOUT removing the need to spend a point to hire em?
yes all in the settings
you can change their wage and how long contract last and how much sp points is refunded
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on June 02, 2021, 04:23:31 AM
is it possible to have mercenaries needing credits instead of story points to renew contracts, WITHOUT removing the need to spend a point to hire em?
yes all in the settings
you can change their wage and how long contract last and how much sp points is refunded

but not the cost for extending contracts, or any way to convert that to credits that i could find. to be clear; i want to spend a story point to hire a merc, but keep them after the contract expires with only credits.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 02, 2021, 05:06:25 AM
How to add extra industry or structure to a existing market as a mod?
Or change their faction allegiance?
I am taking about modifications that affect campaign start.
I know how to add it by modifying the files in main game folders(and it works well) but when I try to make it a separate mod(by taking file, add extra stuff) then I get wild results.
Like when switching faction ownership say from Path to pirate it still show as Path on big map and still spawn Path fleets instead of pirate one.
If any industry/structure is added it drop both production and accessibility to zero.
I suspect the econ files aren't merging properly; since the entries in star system economy JSONs don't have IDs (they're just placed in an array), the market is being duplicated instead of overriden.
You can use the replace tag in mod_info.json (look at Archean Order for an example) to make the game not load the vanilla JSON for the system, so only your file takes effect. The other way is to do the modifications to the market in code.

is it possible to have mercenaries needing credits instead of story points to renew contracts, WITHOUT removing the need to spend a point to hire em?
You'd need to override the rules.csv entries for merc contract extension. Look at the mercs_leavingOptions and mercs_convincedOpt rows.
Could remove the SetStoryOption call from that first rule (instead add a tooltip that displays the credit cost of extending the contract), then use AddCredits in the second rule to deduct the credits on selecting the option.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on June 02, 2021, 05:33:30 AM

You'd need to override the rules.csv entries for merc contract extension. Look at the mercs_leavingOptions and mercs_convincedOpt rows.
Could remove the SetStoryOption call from that first rule (instead add a tooltip that displays the credit cost of extending the contract), then use AddCredits in the second rule to deduct the credits on selecting the option.

ah, crap. that is beyond my skills. about the extent of what i do is tweak text files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 02, 2021, 05:41:26 AM
Just had an awesome qol mod idea:  setting different weapon groups to a specific button (for those of us that just HAVE to pilot smaller ships)

It would be nice to be able to fire weapon group 2 and 3 with the extra buttons on the mouse.

Is this even possible without seriously overhauling what's currently in place?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2021, 09:18:16 AM
Is it possible to implement both FleetStatsSkillEffect and ShipSkillEffect within the same skill?

You need to specify the right "type" for the skill effect in the .skill file.

to take advantage of this method, i'm trying to use an ExtraSalvageShownListener, however upon salvaging a research station i don't see my method (public void reportExtraSalvageShown(SectorEntityToken entity)) being called. is there another place i should be using it?

edit:
for those in the future, i used a ShowLootListener which has
public void reportAboutToShowLootToPlayer(CargoAPI loot, InteractionDialogAPI dialog)

from there i generate my own CargoAPI based on the dialog's interaction target's drop value and drop randoms, along with that of its salvage entity spec, and merge it with the loot passed to the listener.

(Right! And the first part was a bit backwards - ExtraSalvageShownListener would get called *when this extra salvage is shown to the player*.)


Just had an awesome qol mod idea:  setting different weapon groups to a specific button (for those of us that just HAVE to pilot smaller ships)

It would be nice to be able to fire weapon group 2 and 3 with the extra buttons on the mouse.

Is this even possible without seriously overhauling what's currently in place?

Ah, the game actually can't handle mouse buttons beyond two, due to some underlying library limitations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 02, 2021, 09:49:28 AM
Is it possible to implement both FleetStatsSkillEffect and ShipSkillEffect within the same skill?

You need to specify the right "type" for the skill effect in the .skill file.

to take advantage of this method, i'm trying to use an ExtraSalvageShownListener, however upon salvaging a research station i don't see my method (public void reportExtraSalvageShown(SectorEntityToken entity)) being called. is there another place i should be using it?

edit:
for those in the future, i used a ShowLootListener which has
public void reportAboutToShowLootToPlayer(CargoAPI loot, InteractionDialogAPI dialog)

from there i generate my own CargoAPI based on the dialog's interaction target's drop value and drop randoms, along with that of its salvage entity spec, and merge it with the loot passed to the listener.

(Right! And the first part was a bit backwards - ExtraSalvageShownListener would get called *when this extra salvage is shown to the player*.)


Just had an awesome qol mod idea:  setting different weapon groups to a specific button (for those of us that just HAVE to pilot smaller ships)

It would be nice to be able to fire weapon group 2 and 3 with the extra buttons on the mouse.

Is this even possible without seriously overhauling what's currently in place?

Ah, the game actually can't handle mouse buttons beyond two, due to some underlying library limitations.



is it possible to (in the far, far future, perhaps even in a galaxy far away) convert starsector into a more versatile coding language?
or, rather, is that something that would be doable from a manpower perspective?  i have actually wondered about this frequently
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2021, 09:58:20 AM
is it possible to (in the far, far future, perhaps even in a galaxy far away) convert starsector into a more versatile coding language?
or, rather, is that something that would be doable from a manpower perspective?  i have actually wondered about this frequently

Ah, this doesn't actually have anything to do with the language it's written in. And, no, it's not at all feasible! But on the bright side, it's also not desirable; there's no realistic benefit to be had there.

(If you have a more specific question about the "whys" of this, I'd be happy to answer.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on June 02, 2021, 10:31:13 AM
How to add extra industry or structure to a existing market as a mod?
Or change their faction allegiance?
I am taking about modifications that affect campaign start.
I know how to add it by modifying the files in main game folders(and it works well) but when I try to make it a separate mod(by taking file, add extra stuff) then I get wild results.
Like when switching faction ownership say from Path to pirate it still show as Path on big map and still spawn Path fleets instead of pirate one.
If any industry/structure is added it drop both production and accessibility to zero.
I suspect the econ files aren't merging properly; since the entries in star system economy JSONs don't have IDs (they're just placed in an array), the market is being duplicated instead of overriden.
You can use the replace tag in mod_info.json (look at Archean Order for an example) to make the game not load the vanilla JSON for the system, so only your file takes effect. The other way is to do the modifications to the market in code.

Thanks for pointer.
The Replace line help and it work now perfectly.


How to add extra industry or structure to a existing market as a mod?
Or change their faction allegiance?
I am taking about modifications that affect campaign start.
I know how to add it by modifying the files in main game folders(and it works well) but when I try to make it a separate mod(by taking file, add extra stuff) then I get wild results.
Like when switching faction ownership say from Path to pirate it still show as Path on big map and still spawn Path fleets instead of pirate one.
If any industry/structure is added it drop both production and accessibility to zero.

That's going to need more detail as to specifically what you're doing and what you expect the results to be!


Also the Galatia system is missing from econ folder.

That's not a question :) But: the colonies there get added to the economy by code. See TutorialMissionEvent.endGalatiaPortionOfMission()

Thanks for answer.
Cheers
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 02, 2021, 10:36:39 AM
Time permitting I would absolutely love an in depth explanation.


One more question: I have edited the bounty rewards but the modded factions still only give the default 1000 per frigate.  Do I need to edit each modded faction?

Thanks for you time.

Long Burns
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 02, 2021, 04:05:07 PM
You need to specify the right "type" for the skill effect in the .skill file.

Ah ok I was looking at the wrong level for the example and thought it was GOVERNED_COLONY instead of FLEET. Works fine now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 02, 2021, 10:44:40 PM
(Sorry for all the questions lately. I've been doing a lot of experimenting with skills.)

Under what object would I call dynamic and edit the stat mod: COORDINATED_MANEUVERS_MAX? Is that the correct way to adjust the nav rating speed bonus?

Purpose:
I'm trying to add an effect to a skill that would reduce the maximum speed bonus possible from the nav rating for the enemy fleet if the flagship has the skill. Preferably I'd like to cut it in half. This is intended to not effect the nav rating ratio in any way but only the max bonus and only for the enemy fleet if possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on June 03, 2021, 12:09:36 AM
I've been trying to do some loadout shenanigans that aren't exactly supported by the refit screen, so I'd like to know if it is possible to trigger the hull "refresh" that occurs when selecting a different ship? That would make my life easier when I modify the ship variant with hullmods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on June 03, 2021, 02:38:32 AM
how difficult would it be to disable scaling? and have missions be offered at any possible 'level'? always felt odd to me when a game scales with you. from a gameplay perspective i understand why the decision was made, but it just feels... wrong
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 03, 2021, 03:10:49 AM
Nothing scales with your character level AFAIK
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on June 03, 2021, 03:12:21 AM
scales with fleet size, doesnt it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on June 03, 2021, 04:21:21 AM
I'm looking for methods to edit a factions' colour and music list in-game.
As far as I can see, I can get the music via .getFaction().getMusicMap(), returning a transient map that I could, in theory, edit.
Colour, however, doesn't seem to be exposed - or am I missing something?

thanks again,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 03, 2021, 04:27:07 AM
always felt odd to me when a game scales with you.
Why wouldn't they only offer missions that they feel you're capable of? To do otherwise would just be throwing away money.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on June 03, 2021, 04:41:31 AM
always felt odd to me when a game scales with you.
Why wouldn't they only offer missions that they feel you're capable of? To do otherwise would just be throwing away money.

why should the galaxy know what i am capable of?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 03, 2021, 09:36:22 AM
always felt odd to me when a game scales with you.
Why wouldn't they only offer missions that they feel you're capable of? To do otherwise would just be throwing away money.

why should the galaxy know what i am capable of?
They have FTL communication and they aren't blind, they just look you up on the net.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 03, 2021, 09:43:30 AM
Or they just look at the fleet you literally just sailed up to them with :P


Unrelated to that, I have an actual question for the thread:
Is it possible to change a ship's non-officer aggression level via hullmod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arcagnello on June 03, 2021, 09:54:54 AM
Or they just look at the fleet you literally just sailed up to them with :P


Unrelated to that, I have an actual question for the thread:
Is it possible to change a ship's non-officer aggression level via hullmod?

Yes, it is. Look into a mod called "Automatic Orders" by Blothorn! https://fractalsoftworks.com/forum/index.php?topic=15128.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SCC on June 03, 2021, 10:08:12 AM
Is there a way to know if the skills is being applied to the player or to an officer, if I want to give the player some unique bonus?
Edit: perhaps there's a way to prevent officers from getting that skill at all. Removing TRUE from combat officer column in skill_data.csv and leaving it empty (or not adding there anything in the first place, I suppose) should prevent any officers from getting that skill? Am I guessing correctly?
And if I am right, is there a way to hide a skill tree from the player?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on June 04, 2021, 06:16:21 AM
Any way to reduce radius or strength or both of explosion of disabled/destroyed ships?
I am tired of ships getting blasted when enemy explode because they hug him to close.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 04, 2021, 06:28:11 AM
How does load order work again?
(I'm thinking of making a "core" mod full of dummy assets, which would be overridden by my other mods, so that my mods can effectively be disabled without ruining save files.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 04, 2021, 12:01:03 PM
(Sorry for all the questions lately. I've been doing a lot of experimenting with skills.)

Under what object would I call dynamic and edit the stat mod: COORDINATED_MANEUVERS_MAX? Is that the correct way to adjust the nav rating speed bonus?

Purpose:
I'm trying to add an effect to a skill that would reduce the maximum speed bonus possible from the nav rating for the enemy fleet if the flagship has the skill. Preferably I'd like to cut it in half. This is intended to not effect the nav rating ratio in any way but only the max bonus and only for the enemy fleet if possible.

I'm not sure what you mean by this. You can have a look at com.fs.starfarer.api.impl.campaign.skills.CommandAndControl.java for an example, though.

(Generally speaking, "show references" in your IDE is your friend for this kind of thing!)

I've been trying to do some loadout shenanigans that aren't exactly supported by the refit screen, so I'd like to know if it is possible to trigger the hull "refresh" that occurs when selecting a different ship? That would make my life easier when I modify the ship variant with hullmods.

Hmm, it's not. If it was, though, it would nuke the ability to "undo" changes.


scales with fleet size, doesnt it?

Nope! A few shipping-type missions use your cargo capacity to influence what to offer, but that's about it.


Is there a way to know if the skills is being applied to the player or to an officer, if I want to give the player some unique bonus?
Edit: perhaps there's a way to prevent officers from getting that skill at all. Removing TRUE from combat officer column in skill_data.csv and leaving it empty (or not adding there anything in the first place, I suppose) should prevent any officers from getting that skill? Am I guessing correctly?
And if I am right, is there a way to hide a skill tree from the player?

Yeah, you can do that. Also: "npc_only" for skills that don't show up on the character tab.

You could also check if the stats the skill is being applied to is the same object as the player character's stats. Actually, there's even a handy method to do that:
MutableCharacterStatsAPI.isPlayerStats()

Any way to reduce radius or strength or both of explosion of disabled/destroyed ships?

You could give ships the built-in "reduced_explosion" hullmod, or you could write a script that does this dynamically so you don't have to do it to every hull. See ReducedExplosion.java for the relevant stats.


How does load order work again?
(I'm thinking of making a "core" mod full of dummy assets, which would be overridden by my other mods, so that my mods can effectively be disabled without ruining save files.)

IIRC it's alphabetical by the mod's name? But I forget if it's last or first that wins. Could be wrong here, honestly, been a while since I dug into it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: michail on June 04, 2021, 12:03:04 PM
I'm taking this waaaay to seriously, but: I'd like to set up a gitlab CI pipeline for a silly mod I'm making. It needs the API jar to compile, of course. Am I correct assuming that the terms of LICENSE.txt make it's a no-go?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on June 04, 2021, 12:58:36 PM
goddam Alex. yer an answer spitting machine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on June 04, 2021, 01:46:42 PM
Any way to reduce radius or strength or both of explosion of disabled/destroyed ships?

You could give ships the built-in "reduced_explosion" hullmod, or you could write a script that does this dynamically so you don't have to do it to every hull. See ReducedExplosion.java for the relevant stats.

Thanks. That is what I was looking for.
Any way to hide it from displaying on ship cards?(for avoiding extra clutter)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 04, 2021, 01:55:15 PM
IIRC it's already set to "hiddenEverywhere" so shouldn't show up!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on June 04, 2021, 04:03:08 PM
I'm looking for methods to edit a factions' colour and music list in-game.
As far as I can see, I can get the music via .getFaction().getMusicMap(), returning a transient map that I could, in theory, edit.
Colour, however, doesn't seem to be exposed - or am I missing something?

thanks again,
heya, in case you missed it - I'm still looking for a way to do this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sarissofoi on June 04, 2021, 04:21:49 PM
IIRC it's already set to "hiddenEverywhere" so shouldn't show up!
That is great to hear.
Thanks for help.
Cheers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 04, 2021, 07:09:52 PM
I'm looking for methods to edit a factions' colour and music list in-game.
As far as I can see, I can get the music via .getFaction().getMusicMap(), returning a transient map that I could, in theory, edit.
Colour, however, doesn't seem to be exposed - or am I missing something?

thanks again,
heya, in case you missed it - I'm still looking for a way to do this.

Ah, sorry, I did miss it! Taking a quick look, I don't believe changing the colors like this is possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Chozo on June 05, 2021, 12:39:40 AM
REMOVED: am dumb
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 05, 2021, 01:17:26 PM
(Sorry for all the questions lately. I've been doing a lot of experimenting with skills.)

Under what object would I call dynamic and edit the stat mod: COORDINATED_MANEUVERS_MAX? Is that the correct way to adjust the nav rating speed bonus?

Purpose:
I'm trying to add an effect to a skill that would reduce the maximum speed bonus possible from the nav rating for the enemy fleet if the flagship has the skill. Preferably I'd like to cut it in half. This is intended to not effect the nav rating ratio in any way but only the max bonus and only for the enemy fleet if possible.

I'm not sure what you mean by this. You can have a look at com.fs.starfarer.api.impl.campaign.skills.CommandAndControl.java for an example, though.

(Generally speaking, "show references" in your IDE is your friend for this kind of thing!)

Thanks yeah the example shows that MutableCharacterStats is what I want here. Though I think I may need to reference the script that applies the bonuses (CoordinatedManeuversScript I think is what its called but its not in front of me at the moment) for what I want to do because I'm assuming the stats that are passed into the apply method of a skill script are the player's/officer's stats when I'm looking to adjust the enemy fleet's max coordinated maneuvers bonus.

In Intellij, "show references" is called "find usages" I think and right yeah I should be better about that before asking and not assume its hidden source or that I won't be able to find it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 06, 2021, 06:59:13 AM
IIRC it's alphabetical by the mod's name? But I forget if it's last or first that wins. Could be wrong here, honestly, been a while since I dug into it.
Did a simple test with two mods with CSVs identical bar the price of a blueprint package:
The higher in the (alphabetical?) list gets the priority.

Oddly, it works based on the mod's Name not it's ID.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 06, 2021, 10:40:12 AM
Is it possible to check if a hullmods is s-modded?

Edit: Also, are default_ship_roles loaded on each start-up, or are they per-save?
If I remove the file from a mod, will that ship's mods stop spawning?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 06, 2021, 11:37:53 AM
Spoiler
5338348 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.intel.SurveyPlanetMissionIntel  - Created SurveyPlanetMissionIntel: Bhelxiope, faction: Mayasura
5340199 [Thread-3] INFO  sound.oo0O  - Cleaning up music with id [Seeking_Answers.ogg]
5340207 [Thread-7] INFO  sound.oo0O  - Cleaning up music with id [Sovereignty.ogg]
5340314 [Thread-9] INFO  sound.oo0O  - Creating streaming player for music with id [Ambush.ogg]
5340319 [Thread-9] INFO  sound.OooO  - Playing music with id [Ambush.ogg]
5341292 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment.isInSystem(RouteManager.java:141)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteData.getInterpolatedHyperLocation(RouteManager.java:379)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.shouldSpawn(RouteManager.java:651)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:617)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
   at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:128)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

got the above error when the bounty i was after was about to show up in campaign
i cant tell by looking what may be causing the error
was hoping someone else could point me in the right direction
i have a LOT of mods so......shot in the dark

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 06, 2021, 11:50:58 AM
Is it possible to check if a hullmods is s-modded?
ShipVariantAPI (https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipVariantAPI.html) has a getSMods() method, so you could presumably do a check against that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 06, 2021, 11:52:16 AM
Is it possible to check if a hullmods is s-modded?

Edit: Also, are default_ship_roles loaded on each start-up, or are they per-save?
If I remove the file from a mod, will that ship's mods stop spawning?

variant.getSMods().contains(mod id)

I believe it's loaded on each startup!

Spoiler
5338348 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.intel.SurveyPlanetMissionIntel  - Created SurveyPlanetMissionIntel: Bhelxiope, faction: Mayasura
5340199 [Thread-3] INFO  sound.oo0O  - Cleaning up music with id [Seeking_Answers.ogg]
5340207 [Thread-7] INFO  sound.oo0O  - Cleaning up music with id [Sovereignty.ogg]
5340314 [Thread-9] INFO  sound.oo0O  - Creating streaming player for music with id [Ambush.ogg]
5340319 [Thread-9] INFO  sound.OooO  - Playing music with id [Ambush.ogg]
5341292 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment.isInSystem(RouteManager.java:141)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteData.getInterpolatedHyperLocation(RouteManager.java:379)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.shouldSpawn(RouteManager.java:651)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:617)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
   at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:128)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

got the above error when the bounty i was after was about to show up in campaign
i cant tell by looking what may be causing the error
was hoping someone else could point me in the right direction
i have a LOT of mods so......shot in the dark

Ahh, can't really say what mod it might be from. This looks like it's caused by a RouteSegment whose "from" entity was removed from the Sector entirely, which means it was probably a non-permanent object such as a fleet. Fixed up that particular crash on my end, but, right, impossible to tell from the stack trace what mod might've caused it, or, indeed, if it was a combination of mods, or a mod plus vanilla. For example, it looks like a mod doing seeming something unrelated (such as dynamically removing a planet) could cause this.

Is it possible to check if a hullmods is s-modded?
ShipVariantAPI (https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipVariantAPI.html) has a getSMods() method, so you could presumably do a check against that.

(Right! Ninja'ed - I appreciate you taking the time to answer, that really helps me a lot.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on June 06, 2021, 11:56:05 AM
I'm taking this waaaay to seriously, but: I'd like to set up a gitlab CI pipeline for a silly mod I'm making. It needs the API jar to compile, of course. Am I correct assuming that the terms of LICENSE.txt make it's a no-go?
You are fine, already asked Alex for that, and he said OK: https://fractalsoftworks.com/forum/index.php?topic=5061.msg298924#msg298924 (https://fractalsoftworks.com/forum/index.php?topic=5061.msg298924#msg298924)

Also, I have some pipelines set up in my template (uses Gradle, fetches all deps automatically and bundles starsector.api.jar): https://github.com/jaghaimo/starsector-mod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 06, 2021, 11:58:45 AM
(Oh, I missed this one - apologies!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 06, 2021, 12:22:39 PM
Thanks!
Follow-up question: Is there a way to have a hullmod uninstall itself from a ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 06, 2021, 12:33:30 PM
Thanks!
Follow-up question: Is there a way to have a hullmod uninstall itself from a ship?
ShipVariantAPI also has the methods removeMod(), removePermaMod(), and removeSuppressedMod() which all take the mod id as a String.

The online API (https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html) is pretty convenient to search through even if you don't have access to an IDE (or haven't set one up).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: michail on June 06, 2021, 12:36:16 PM
I'm taking this waaaay to seriously, but: I'd like to set up a gitlab CI pipeline for a silly mod I'm making. It needs the API jar to compile, of course. Am I correct assuming that the terms of LICENSE.txt make it's a no-go?
You are fine, already asked Alex for that, and he said OK: https://fractalsoftworks.com/forum/index.php?topic=5061.msg298924#msg298924 (https://fractalsoftworks.com/forum/index.php?topic=5061.msg298924#msg298924)

Also, I have some pipelines set up in my template (uses Gradle, fetches all deps automatically and bundles starsector.api.jar): https://github.com/jaghaimo/starsector-mod

Awesome, thank you. I can't use your template because I'm using a different build tool (just... couldn't bring myself to use gradle in my spare time), but will snatch dependencies' versions from it.

(Oh, I missed this one - apologies!)

It'd be very wrong of me to complain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 06, 2021, 12:38:13 PM
Thanks! Final final question: Adding story points, possible?
(All together, this should give me a way to refund story points for "uninstalled" hullmods of mine that had been S-Mod'd.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 06, 2021, 01:35:32 PM
A hullmod that removes itself is easy. Getting a hullmod to add itself, now that would be a clever trick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 06, 2021, 01:41:14 PM
Well I'm aiming for a particularly clever trick myself:
A content mod that you can, to the surface user, disable without breaking saves!

S-Mods are just the last hurdle.

EDIT: Right, so what I got is this:
Code
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.rulecmd.AddStoryPoints;

public class YunruDummy extends BaseHullMod {

    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
        if (ship.getVariant().hasHullMod("YunruDummy")) {
            if (ship.getVariant().getSMods().contains("YunruDummy")) {
                AddStoryPoints(1);
            }
            ship.getVariant().removeMod("YunruDummy");
        }
    }
But VSCode is telling me this:
"The method AddStoryPoints(int) is undefined for the type"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 06, 2021, 04:06:58 PM
Use:
Code: java
Global.getSector().getPlayerStats().addStoryPoints(1);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 06, 2021, 04:26:54 PM
But VSCode is telling me this:
"The method AddStoryPoints(int) is undefined for the type"

Also, if you need to use a rule command in code at any point in the future, it's a bit more complicated.

This:

Code
AddStoryPoints(1);

Should be:

Code
AddStoryPoints addStoryPoints = new AddStoryPoints();
addStoryPoints.execute();

"execute()" requires a ruleId String, the dialogue interaction's InteractionDialogueAPI (which can be null I think if nothing in the rule uses it), the List<Token> of whatever parameters you would put into the rule call (This will vary by the rule itself. Some have none.), and finally, it also requires the memory map from the interaction dialogue (iirc that's where you can get it).

So example assuming you don't need the interaction dialogue or memory map:

Code
                List<Misc.Token> list = new LinkedList<>();
                Misc.Token token = new Misc.Token("1", Misc.TokenType.LITERAL);
                list.add(0, token);
                addStoryPoints.execute("id", null, list, null);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 06, 2021, 06:19:42 PM
A much more concise example of using a rule command in code:

Code: java
new EndConversation().execute(null, dialog, Misc.tokenize("NO_CONTINUE"), memoryMap);

Most commands require a dialog and a memory map or they will NPE
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 06, 2021, 10:57:52 PM
I'm afraid all of that went right over my head, especially given the differing complexities of the answers received.

EDIT:
I've also discovered something confusing going on. Here is my code:
Code: java
package data.scripts;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class YunruDummyRefinedPropellant extends BaseHullMod {

    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
        if (ship.getVariant().hasHullMod("yunru_refined_propellant")) {
            if (ship.getVariant().getSMods().contains("yunru_refined_propellant")) {
                Global.getSector().getPlayerStats().addStoryPoints(1);
            }
            ship.getVariant().removeMod("yunru_refined_propellant");
            ship.getVariant().removePermaMod("yunru_refined_propellant");
            ship.getVariant().removeSuppressedMod("yunru_refined_propellant");
        }
    }
   
    @Override
    public String getDescriptionParam(int index, HullSize hullSize) {
        if (index == 0) return "";
        return null;
    }
}
And yet, when it runs, I end up with three extra story points instead of one?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harpuea on June 07, 2021, 05:41:41 AM
How do I make a ship disappear from the player fleet on the campaign map? The ship is a shuttle that should be stored within the carrier, therefore it shouldn't show to be cruising around along with the player fleet.

I tried using mod plugin and set alpha color to 0, but that didn't work. There's also the issue of the engine trail too.

Code
public class cdm_modplugin
  extends BaseModPlugin{

public PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship) {    
    if (ship.getVariant().hasHullMod("combat_docking_module")) {
    ship.setAlphaMult(0f); //Invisible?
      return new PluginPick<ShipAIPlugin>(new combat_docking_AI(ship), CampaignPlugin.PickPriority.MOD_GENERAL);
    }
    return super.pickShipAI(member, ship);
  }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 07, 2021, 12:08:17 PM
EDIT:
I've also discovered something confusing going on. Here is my code:
SNIP
And yet, when it runs, I end up with three extra story points instead of one?
In the API, applyEffectsAfterShipCreation says:
 Effects applied here should NOT affect ship stats as this does not get called from the campaign. Apply stat changes in applyEffectsBeforeShipCreation() instead, as that does affect the campaign.

So maybe try putting it in applyEffectsBeforeShipCreation instead?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 07, 2021, 02:19:00 PM
I'm afraid all of that went right over my head, especially given the differing complexities of the answers received.

SafariJohn's example is the best for your use case. I was more breaking it down part by part for learning purposes.

(Well, that and it gets more appealing to build the list the more parameters needed for the rule, but iirc most vanilla rules have only one parameter anyway. I have one that has like 7 or 8 and for that the concise way would not be very readable.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 07, 2021, 05:18:57 PM
The 3 SP being added issue is because a hullmod's apply methods are called 3 or more times when a ship is created to make sure everything is in order. You need to use some sort of check to make sure that code is only executed once. I don't have time to provide an example right now, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on June 07, 2021, 05:32:49 PM
How do I get wing's base speed from FighterWingSpecAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 07, 2021, 06:06:30 PM
How do I make a ship disappear from the player fleet on the campaign map? The ship is a shuttle that should be stored within the carrier, therefore it shouldn't show to be cruising around along with the player fleet.

I tried using mod plugin and set alpha color to 0, but that didn't work. There's also the issue of the engine trail too.

Code
public class cdm_modplugin
  extends BaseModPlugin{

public PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship) {    
    if (ship.getVariant().hasHullMod("combat_docking_module")) {
    ship.setAlphaMult(0f); //Invisible?
      return new PluginPick<ShipAIPlugin>(new combat_docking_AI(ship), CampaignPlugin.PickPriority.MOD_GENERAL);
    }
    return super.pickShipAI(member, ship);
  }
}

The code you're running there would affect the in-combat ship. The ship is a fighter in a fighter bay, right? I don't think there's any way to hide those in the campaign, at least not that I can think of, unfortunately.

How do I get wing's base speed from FighterWingSpecAPI?

Something like wing.getVariant().getHullSpec(). ... huh, it doesn't look like that's actually exposed there! Let me add a .getEngineSpec() method.

That wouldn't give you the true in-combat speed necessarily, though, if it was modified for that variant via a hullmod. If you're doing this in combat, you'd want to ultimately get hold of a ShipAPI for one of the fighters and get it from that.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 07, 2021, 09:54:01 PM
hey i was trying to do something crazy with hull mods.
in fact i was trying to do a few things.
dose anyone know how to:
make a hullmod place other hullmods on a ship when it is install.
    -i saw a mod that added a hullmod, forget its name, that only installed when equipping a gun on ship, so i know this is possable. no idea were to find it though, so i cant use it as a base
tell when a given hullmod is 'built in' (with story points) on a ship.

make a hullmod interface with a fleet to add crew to it (for calculating things like planet surveys, or salvaging), but not be real crew?

plz don't tell me its a bad idea. life is a bad idea but I'm going to do it anyway. i just wanna roll play, and i dont have the imagination to pretend that the crew im doing everything with is not crew
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 07, 2021, 11:30:24 PM
hey i was trying to do something crazy with hull mods.
in fact i was trying to do a few things.
dose anyone know how to:
make a hullmod place other hullmods on a ship when it is install.
    -i saw a mod that added a hullmod, forget its name, that only installed when equipping a gun on ship, so i know this is possable. no idea were to find it though, so i cant use it as a base
tell when a given hullmod is 'built in' (with story points) on a ship.
Most of the functions you're looking for are in the ShipVariantAPI (https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipVariantAPI.html) (link is to the online API).
The addMod/addPermaMod and getSMods functions, in particular.

When making a hullmod you can access the ShipVariantAPI from the MutableShipStatsAPI found in the applyEffectsBeforeShipCreation function by using stats.getVariant()
If you want some specific functionality demonstrated, I could write up an example when I have free time later.

make a hullmod interface with a fleet to add crew to it (for calculating things like planet surveys, or salvaging), but not be real crew?
Making fake crew that only function for certain events would require something along the lines of setting up a dynamic stat and rewriting the corresponding plugins to take it into account.
It would probably be easier to just reduce the requirements/cost instead.
In regards to surveying it unfortunately doesn't take crew into account outside of the total multiplier, but if you don't mind reducing every cost it would work as-is.

I haven't looked into the salvaging functions very much, so I can't help with that part.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on June 08, 2021, 12:05:46 AM
How do I get wing's base speed from FighterWingSpecAPI?

Something like wing.getVariant().getHullSpec(). ... huh, it doesn't look like that's actually exposed there! Let me add a .getEngineSpec() method.

That wouldn't give you the true in-combat speed necessarily, though, if it was modified for that variant via a hullmod. If you're doing this in combat, you'd want to ultimately get hold of a ShipAPI for one of the fighters and get it from that.

Thanks!

I was trying to add tooltip regarding if certain bonuses apply. For context, to determine if a bomber is a bomb-bay type (Flash, Piranha). To cover mod fighters I tried using derived weapon ROF, max ammo to see how long it takes to deplete the arsenal, and compare it against the weapon range divided by bomber base speed. If bombing would take something like 75% of the travel time through full range it qualifies as a bay bomber and get additional bonuses, etc etc.

I want to display this info to player so they are well informed about these additions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 08, 2021, 12:30:24 AM
I'm trying to make a custom star system. My original attempt failed miserably, so I tried to start from scratch and just make a simple star.
But even that was too hard for me, apparently.

I have the code below, but the star still isn't spawning in vanilla. My other files (WorldGen, AddMarketPlace, and ModPlugin.java) don't seem to be the issue, I compared them to other mods and they seem to be about the same.

package data.scripts.world;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Entities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.impl.campaign.ids.Items;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.ids.Terrain;
import com.fs.starfarer.api.impl.campaign.procgen.NebulaEditor;
import com.fs.starfarer.api.impl.campaign.procgen.PlanetConditionGenerator;
import com.fs.starfarer.api.impl.campaign.procgen.StarAge;
import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceTerrainPlugin;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;


public class UNSCStar {

   public void generate(SectorAPI sector) {
        StarSystemAPI system = sector.createStarSystem("ABCD");
        system.getLocation().set(1000,1000);
        PlanetAPI ABCD_star = system.initStar("UNSCStar",
                "star_orange",//set star type, the type IDs come from starsector-core/data/campaign/procgen/star_gen_data.csv
                900, //set radius, 900 is a typical radius size
                1000); //radius of corona terrain around star
            

   system.autogenerateHyperspaceJumpPoints(true, true);

    }



}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 08, 2021, 04:05:20 AM
Apologies for the inconvenience, but I have another script I'm having trouble.

I pieced this together to do two things: Double the OP cost of fighters, and double the wing size of fighters. Unfortunately, while it doesn't crash, it also doesn't do either of those things.
Code
package data.scripts;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.FighterLaunchBayAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.loading.FighterWingSpecAPI;

public class YunruTwinWings extends BaseHullMod {
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

        stats.getDynamic().getMod(Stats.ALL_FIGHTER_COST_MOD).modifyMult(id, 2);

        ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
ship = (ShipAPI) stats.getEntity();
} else {
return;
}
       
        for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
            if (bay.getWing() == null) continue;
           
            FighterWingSpecAPI spec = bay.getWing().getSpec();
           
            int newWings = 2*spec.getNumFighters();

            bay.getWing().getSpec().setNumFighters(newWings);
        }
    }
   
    @Override
public boolean affectsOPCosts() {
return true;
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on June 08, 2021, 07:40:19 AM
Apologies for the inconvenience, but I have another script I'm having trouble.

I pieced this together to do two things: Double the OP cost of fighters, and double the wing size of fighters. Unfortunately, while it doesn't crash, it also doesn't do either of those things.
Code
package data.scripts;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.FighterLaunchBayAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.loading.FighterWingSpecAPI;

public class YunruTwinWings extends BaseHullMod {
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

        stats.getDynamic().getMod(Stats.ALL_FIGHTER_COST_MOD).modifyMult(id, 2);

        ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
ship = (ShipAPI) stats.getEntity();
} else {
return;
}
       
        for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
            if (bay.getWing() == null) continue;
           
            FighterWingSpecAPI spec = bay.getWing().getSpec();
           
            int newWings = 2*spec.getNumFighters();

            bay.getWing().getSpec().setNumFighters(newWings);
        }
    }
   
    @Override
public boolean affectsOPCosts() {
return true;
}
}

I tried doing that but modifying the fighter count in spec would affect all wing of same type across the game. It also doesn’t work for setting fighter count larger than 6 the game just crashes.

Ah, right, right! The wing is only initialized when the ship is deployed. Something like this, then:

Code
for (String wingId : ship.getVariant().getFittedWings()) {
FighterWingSpecAPI spec = Global.getSettings().getFighterWingSpec(wingId);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 08, 2021, 02:02:48 PM
I'm trying to make a custom star system. My original attempt failed miserably, so I tried to start from scratch and just make a simple star.
But even that was too hard for me, apparently.

I have the code below, but the star still isn't spawning in vanilla. My other files (WorldGen, AddMarketPlace, and ModPlugin.java) don't seem to be the issue, I compared them to other mods and they seem to be about the same.

You have something like:

Code
new UNSCStar().generate(Global.getSector());

 - in your ModPlugin file correct?

You'd need it under:

Code
    @Override
    public void onNewGame()

Or, if you have it in your WorldGen file, then make sure you call that generate(sector) in your mod plugin under the same place.

Here is an example of mine:

ModPlugin:
Code
    @Override
    public void onNewGame() {
        initArcheus();
}

private static void initArcheus() {
    new archeusGen().generate(Global.getSector());
}

archeusGen file:
Code
    @Override
    public void generate(SectorAPI sector) {
        new Mordreath().generate(sector);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 08, 2021, 04:13:43 PM
Spoiler
Is it possible to check if a hullmods is s-modded?

Edit: Also, are default_ship_roles loaded on each start-up, or are they per-save?
If I remove the file from a mod, will that ship's mods stop spawning?

variant.getSMods().contains(mod id)

I believe it's loaded on each startup!

Spoiler
5338348 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.intel.SurveyPlanetMissionIntel  - Created SurveyPlanetMissionIntel: Bhelxiope, faction: Mayasura
5340199 [Thread-3] INFO  sound.oo0O  - Cleaning up music with id [Seeking_Answers.ogg]
5340207 [Thread-7] INFO  sound.oo0O  - Cleaning up music with id [Sovereignty.ogg]
5340314 [Thread-9] INFO  sound.oo0O  - Creating streaming player for music with id [Ambush.ogg]
5340319 [Thread-9] INFO  sound.OooO  - Playing music with id [Ambush.ogg]
5341292 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment.isInSystem(RouteManager.java:141)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteData.getInterpolatedHyperLocation(RouteManager.java:379)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.shouldSpawn(RouteManager.java:651)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:617)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
   at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:128)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

got the above error when the bounty i was after was about to show up in campaign
i cant tell by looking what may be causing the error
was hoping someone else could point me in the right direction
i have a LOT of mods so......shot in the dark

Ahh, can't really say what mod it might be from. This looks like it's caused by a RouteSegment whose "from" entity was removed from the Sector entirely, which means it was probably a non-permanent object such as a fleet. Fixed up that particular crash on my end, but, right, impossible to tell from the stack trace what mod might've caused it, or, indeed, if it was a combination of mods, or a mod plus vanilla. For example, it looks like a mod doing seeming something unrelated (such as dynamically removing a planet) could cause this.

Is it possible to check if a hullmods is s-modded?
ShipVariantAPI (https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipVariantAPI.html) has a getSMods() method, so you could presumably do a check against that.

(Right! Ninja'ed - I appreciate you taking the time to answer, that really helps me a lot.)
[close]

ah so i guess i will just have to check for updates and do some more testing
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 08, 2021, 06:10:59 PM
Spoiler
I'm trying to make a custom star system. My original attempt failed miserably, so I tried to start from scratch and just make a simple star.
But even that was too hard for me, apparently.

I have the code below, but the star still isn't spawning in vanilla. My other files (WorldGen, AddMarketPlace, and ModPlugin.java) don't seem to be the issue, I compared them to other mods and they seem to be about the same.

You have something like:

Code
new UNSCStar().generate(Global.getSector());

 - in your ModPlugin file correct?

You'd need it under:

Code
    @Override
    public void onNewGame()

Or, if you have it in your WorldGen file, then make sure you call that generate(sector) in your mod plugin under the same place.

Here is an example of mine:

ModPlugin:
Code
    @Override
    public void onNewGame() {
        initArcheus();
}

private static void initArcheus() {
    new archeusGen().generate(Global.getSector());
}

archeusGen file:
Code
    @Override
    public void generate(SectorAPI sector) {
        new Mordreath().generate(sector);
}
[close]

I... think?

My ModPlugin (UNSCModPlugin) has:

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

public class UNSCModPlugin extends BaseModPlugin

{

    public void onNewGame() {
        Global.getLogger(this.getClass()).info("Hooray My mod plugin in a jar is loaded! (UNSC)");
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UNSC");
        initUNSC();
    }

private static void initUNSC() {
        new UNSCWorldGen().generate(Global.getSector());
    }

}

And my gen file (UNSCWorldGen) goes as:

Code
package data.scripts.world;



import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

public class UNSCWorldGen implements SectorGeneratorPlugin {
@Override
    public void generate(SectorAPI sector) {
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UNSC");
       
new UNSCStar().generate(sector);

    }



}

(And then my UNSCStar File)
Code
package data.scripts.world;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Entities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.impl.campaign.ids.Items;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.ids.Terrain;
import com.fs.starfarer.api.impl.campaign.procgen.NebulaEditor;
import com.fs.starfarer.api.impl.campaign.procgen.PlanetConditionGenerator;
import com.fs.starfarer.api.impl.campaign.procgen.StarAge;
import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceTerrainPlugin;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;


public class UNSCStar {

   public void generate(SectorAPI sector) {
        StarSystemAPI system = sector.createStarSystem("ABCD");
        system.getLocation().set(1000,1000);
        PlanetAPI ABCD_star = system.initStar("UNSCStar",
                "star_orange",//set star type, the type IDs come from starsector-core/data/campaign/procgen/star_gen_data.csv
                900, //set radius, 900 is a typical radius size
                1000); //radius of corona terrain around star


system.autogenerateHyperspaceJumpPoints(true, true);

    }



}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 08, 2021, 07:03:24 PM
I... think?

Looks right.

Only other things I can think of is that you haven't added the modPlugin file to the mod_info.json but then I'm not sure if the mod would even show up. The other thing would be needing to set the StarSystem type by:

Code
		system.setType(StarSystemType.NEBULA);

- before you call initStar().

I'm out of ideas after that sorry.  :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 08, 2021, 09:51:45 PM
I... think?

Looks right.

Only other things I can think of is that you haven't added the modPlugin file to the mod_info.json but then I'm not sure if the mod would even show up. The other thing would be needing to set the StarSystem type by:

Code
		system.setType(StarSystemType.NEBULA);

- before you call initStar().

I'm out of ideas after that sorry.  :(

It turns out that I forgot to add the modPlugin to the modinfo file. It runs now, but then crashes with the following error:

Fatal: Error loading [data.scripts.UNSCModPlugin]
Cause: File 'data/scripts/UNSCModPlugin.java', Line 18, Column 25:
Cannot determine simple type name 'UNSCWorldGen'
Check starsector.log for more info.

Where the log says:
Spoiler
java.lang.RuntimeException: Error loading [data.scripts.UNSCModPlugin]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/UNSCModPlugin.java', Line 18, Column 25: Cannot determine simple type name "UNSCWorldGen"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/UNSCModPlugin.java', Line 18, Column 25: Cannot determine simple type name "UNSCWorldGen"
   at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
   at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5398)
   at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5207)
   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5188)
   at org.codehaus.janino.UnitCompiler.access$12600(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$16.visitReferenceType(UnitCompiler.java:5119)
   at org.codehaus.janino.Java$ReferenceType.accept(Java.java:2880)
   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5675)
   at org.codehaus.janino.UnitCompiler.access$15000(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$16.visitNewClassInstance(UnitCompiler.java:5144)
   at org.codehaus.janino.Java$NewClassInstance.accept(Java.java:4082)
   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7333)
   at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3873)
   at org.codehaus.janino.UnitCompiler.access$6900(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:3263)
   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
   at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:3290)
   at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:4368)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2662)
   at org.codehaus.janino.UnitCompiler.access$4400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$7.visitMethodInvocation(UnitCompiler.java:2627)
   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2654)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1643)
   at org.codehaus.janino.UnitCompiler.access$1100(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java:936)
   at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:2097)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
   at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
   at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
   at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
   ... 5 more
[close]

I'm using Notepad++ right now, which seems to be an issue that has popped up in other threads...

EDIT
Guess which chucklenut forgot to add "import data.scripts.world.UNSCWorldGen;" to the ModPlugin file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 08, 2021, 11:20:49 PM
hey i was trying to do something crazy with hull mods.
in fact i was trying to do a few things.
dose anyone know how to:
make a hullmod place other hullmods on a ship when it is install.
    -i saw a mod that added a hullmod, forget its name, that only installed when equipping a gun on ship, so i know this is possable. no idea were to find it though, so i cant use it as a base
tell when a given hullmod is 'built in' (with story points) on a ship.
Most of the functions you're looking for are in the ShipVariantAPI (https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipVariantAPI.html) (link is to the online API).
The addMod/addPermaMod and getSMods functions, in particular.

When making a hullmod you can access the ShipVariantAPI from the MutableShipStatsAPI found in the applyEffectsBeforeShipCreation function by using stats.getVariant()
If you want some specific functionality demonstrated, I could write up an example when I have free time later.

make a hullmod interface with a fleet to add crew to it (for calculating things like planet surveys, or salvaging), but not be real crew?
Making fake crew that only function for certain events would require something along the lines of setting up a dynamic stat and rewriting the corresponding plugins to take it into account.
It would probably be easier to just reduce the requirements/cost instead.
In regards to surveying it unfortunately doesn't take crew into account outside of the total multiplier, but if you don't mind reducing every cost it would work as-is.

I haven't looked into the salvaging functions very much, so I can't help with that part.

thank you for the help and advice. because of this, my fist hullmod is about 95% complete. have not tried anything with the crew hullmod yet though.

regardless, I wish to ask this forums help once more. I have need of, in my hullmod script, getting the remaining OP that the ship has available, but i have no idea how to do so.

i found a function that might do what I want, but I have no idea how to use it
   getUnusedOP(MutableCharacterStatsAPI)
i found it in the ShipVariantAPI that was shown to me.
if anyone knows how to use it, or something else, to get unused op on a ship, i would be very grateful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 09, 2021, 07:19:15 AM
regardless, I wish to ask this forums help once more. I have need of, in my hullmod script, getting the remaining OP that the ship has available, but i have no idea how to do so.

i found a function that might do what I want, but I have no idea how to use it
   getUnusedOP(MutableCharacterStatsAPI)
i found it in the ShipVariantAPI that was shown to me.
if anyone knows how to use it, or something else, to get unused op on a ship, i would be very grateful.
I don't know if this is the most concise way to do it, but here's an example for use on a hullmod that I got working:
int unusedOP = stats.getVariant().getUnusedOP(Global.getSector().getCharacterData().getPerson().getFleetCommanderStats());
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 09, 2021, 12:46:58 PM
@AppleMarineXX If you are trying to add a nebula system, go download my Roider Union mod and look at my src/scripts/world/systems/Roider_Kiska.java code. You should copy the createNebula() and finalizeNebula() methods and use them in your system gen class the same way I did.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 09, 2021, 02:32:14 PM
regardless, I wish to ask this forums help once more. I have need of, in my hullmod script, getting the remaining OP that the ship has available, but i have no idea how to do so.

i found a function that might do what I want, but I have no idea how to use it
   getUnusedOP(MutableCharacterStatsAPI)
i found it in the ShipVariantAPI that was shown to me.
if anyone knows how to use it, or something else, to get unused op on a ship, i would be very grateful.
I don't know if this is the most concise way to do it, but here's an example for use on a hullmod that I got working:
int unusedOP = stats.getVariant().getUnusedOP(Global.getSector().getCharacterData().getPerson().getFleetCommanderStats());
would that work on not player fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 09, 2021, 03:23:49 PM
would that work on not player fleets?
No, you'd need to figure out where the MutableCharacterStatsAPI for that specific fleet is at, and then pass it into the getUnusedOP call from the ShipVariantAPI in question.
Something like this, maybe?
Code
int unusedOP = stats.getVariant().getUnusedOP(stats.getFleetMember().getFleetCommanderForStats().getFleetCommanderStats());
I haven't tested this, so I don't know if it works offhand.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 09, 2021, 04:10:46 PM
would that work on not player fleets?
No, you'd need to figure out where the MutableCharacterStatsAPI for that specific fleet is at, and then pass it into the getUnusedOP call from the ShipVariantAPI in question.
Something like this, maybe?
Code
int unusedOP = stats.getVariant().getUnusedOP(stats.getFleetMember().getFleetCommanderForStats().getFleetCommanderStats());
I haven't tested this, so I don't know if it works offhand.

it dose in fact, not work.
i think its the 'getFleetMember sometimes returns null'.
and sometimes seems like 100% of the time when it causes instant crash.
im going to try and reroot the comand around it somehow. but if you have a better idea, im going to be neck deep in the API to try and get this to work
(and thank you for the help regardless. this gives me an idea of how to do this, so its not all to wast)

EDIT: i have no idea what im doing help
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 09, 2021, 04:48:46 PM
Ooh, another quick question. How do I add an AI Core to a station?

I'm thinking of using the 'add item to industry' function, like:
Code
ordelia_market.addIndustry(Industries.ORBITALWORKS,
new ArrayList<String>(Arrays.asList(Items.CORRUPTED_NANOFORGE)));

But I'm not sure if it'll work the same way. That, and I don't know the item ID's of the AI Cores.

SOLVED (But explained for people in the future that might be googling this problem.)

How do I add an AI core to an industry for a custom star system?

First, make sure you have
Code
import com.fs.starfarer.api.campaign.econ.Industry;

For a planet with the ID "earth", with the corresponding market ID "earthmarket"

Code
Industry earthfort = earth.getMarket().getIndustry(Industries.STARFORTRESS_MID); 
earthfort.setAICoreId("alpha_core");

Where "earthfort" is an arbitrary name you set for the Star Fortress on Earth.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on June 10, 2021, 08:13:02 AM
Phase ship grab the specialy named glow sprite automatically. Is there a way to access the part of the code where it is done? Like If I wanted to change the glow effect? Or If I wanted to put animated sprite for the glow base?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 10, 2021, 07:41:33 PM
ok, so i have ran into a second difficulty:
i find myself wanting to make a hullmod that changes crew cost of survey, like the survey equipment mod, but for crew.
the difficulty is that the crew cost seems to be a little not effected by modifiers
plugin located at com.fs.starfarer.api.impl.campaign.SurveyPluginImpl


the difficulty is that when it sets the required crew cost, it dose not even ask the fleet to get the getSurveyCostReductionId for it.
it just maths it right there and then.
i guess what im asking is if there is a way around this. is it possible to make a script that modifies / replaces this function? or is it possible to make a script that simply changes the cost of the survey site itself, without needing this? or anything truly.

function that has the difficulty: (located in com.fs.starfarer.api.impl.campaign.SurveyPluginImpl)
Quote
public Map<String, Integer> getRequired() {
   Map<String, Integer> result = new LinkedHashMap<String, Integer>();
   
   float mult = getCostMult().getModifiedValue();
   
   int machinery = (int)Math.round(BASE_MACHINERY * mult);
   machinery -= (int) Misc.getFleetwideTotalMod(fleet, Stats.getSurveyCostReductionId(Commodities.HEAVY_MACHINERY), 0);
   machinery = Math.round(machinery / 10f) * 10;
   if (machinery < MIN_SUPPLIES_OR_MACHINERY) machinery = MIN_SUPPLIES_OR_MACHINERY;
   
   result.put(Commodities.CREW, (int)Math.round((int)(BASE_CREW * mult) / 10f) * 10);
   result.put(Commodities.HEAVY_MACHINERY, machinery);
   
   return result;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 10, 2021, 07:55:22 PM
You should be able to do it the exact same way SurveyingEquipment does, except passing Commodities.CREW to Stats.getSurveyCostReductionId(), of course.

The cost mods are applied in the Init() method of SurveyPluginImpl, that's why you are not seeing it in getRequired().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 10, 2021, 08:25:12 PM
You should be able to do it the exact same way SurveyingEquipment does, except passing Commodities.CREW to Stats.getSurveyCostReductionId(), of course.

The cost mods are applied in the Init() method of SurveyPluginImpl, that's why you are not seeing it in getRequired().

that dose not seem to be the cause in my tests so far.
can you give an example of what your doing to make this work?
i have tried:
stats.getDynamic().getMod(Stats.getSurveyCostReductionId(Commodities.CREW)).modifyFlat(id, 500);
stats.getDynamic().getMod(Stats.getSurveyCostReductionId(Commodities.CREW)).modifyFlat(id, -500);
stats.getDynamic().getMod(Stats.getSurveyCostReductionId(Commodities.CREW)).modifyMult(id,0f);
stats.getDynamic().getMod(Stats.getSurveyCostReductionId(Commodities.CREW)).modifyMult(id,0);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 10, 2021, 09:42:58 PM
Writing an Ship System AI for a system that replaces right click - how do I get AI to use this system specifically since Ship.useSystem() doesn't work (or rather, AI just tries to use F system) ?

I'd imagine I need to do something with getPhaseCloak(), but while there is a method to deactivate it, I don't see one to activate.

Edit: I got it to work by using
ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK, new Vector2f(),0);

Is this the most efficient way to go about it, though?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 11, 2021, 02:29:24 PM
Is there a way to get the ID of a hullmod from within it's script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2021, 03:48:33 PM
Phase ship grab the specialy named glow sprite automatically. Is there a way to access the part of the code where it is done? Like If I wanted to change the glow effect? Or If I wanted to put animated sprite for the glow base?

I don't believe so, no. You could however have an empty sprite for that and do your custom rendering in a BaseCombatLayeredRenderingPlugin that you sync up the location and state of with the ship.

ok, so i have ran into a second difficulty:
i find myself wanting to make a hullmod that changes crew cost of survey, like the survey equipment mod, but for crew.
the difficulty is that the crew cost seems to be a little not effected by modifiers
plugin located at com.fs.starfarer.api.impl.campaign.SurveyPluginImpl

Right - the vanilla plugin doesn't support this. The only way around this that comes to mind is to provide your own version of SurveyPluginImpl.


Edit: I got it to work by using
ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK, new Vector2f(),0);

Is this the most efficient way to go about it, though?

Yep! Just about the only way, actually. Though I'm not sure you need to pass in a new vector for the param, you can probably just pass in null.

Is there a way to get the ID of a hullmod from within it's script?

I don't believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 11, 2021, 04:01:31 PM
For some reason, my Worldgen File is refusing to set the starting faction relationships.

My faction ID is "unsc" and I tried 3 different ways to try to set the faction relationships, but none of them seemed to apply when I started the game.
How should I go about coding it? I looked at other mods, and they seemed to have the same syntax.

Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.Global;

public class UNSCWorldGen implements SectorGeneratorPlugin {
@Override
    public void generate(SectorAPI sector) {
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("unsc");

//No Audere if Nex Enabled
if (Global.getSettings().getModManager().isModEnabled("nexerelin")) {
} else {
new UNSCStar().generate(sector);
}
//new UNSCStar().generate(sector);

    }

public static void initFactionRelationships(SectorAPI sector) {
        FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
FactionAPI pirates = sector.getFaction(Factions.PIRATES);
FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);
FactionAPI player = sector.getFaction(Factions.PLAYER);
FactionAPI diktat = sector.getFaction(Factions.DIKTAT);
        FactionAPI league = sector.getFaction(Factions.PERSEAN);
        FactionAPI UNSC = sector.getFaction("unsc");

//pirates.setRelationship("unsc", RepLevel.HOSTILE);
//unsc.setRelationship("LUDDIC_PATH", RepLevel.HOSTILE);
//unsc.setRelationship("HEGEMONY", RepLevel.SUSPICIOUS);
//unsc.setRelationship("LUDDIC_CHURCH", RepLevel.SUSPICIOUS);
//unsc.setRelationship("PERSEAN", RepLevel.FAVORABLE);
//unsc.setRelationship("TRITACHYON", RepLevel.FAVORABLE);
//unsc.setRelationship("INDEPENDENT", RepLevel.FAVORABLE);

//UNSC.setRelationship(hegemony.getId(), -0.2f);
//UNSC.setRelationship(pirates.getId(), -0.6f);
//UNSC.setRelationship(church.getId(), -0.2f);
//UNSC.setRelationship(tritachyon.getId(), 0.2f);
//UNSC.setRelationship(independent.getId(), 0.2f);
//UNSC.setRelationship(league.getId(), 0.2f);
//path.setRelationship(UNSC.getId(), -0.6f);

UNSC.setRelationship(Factions.PERSEAN, RepLevel.FAVORABLE);
UNSC.setRelationship(Factions.INDEPENDENT, RepLevel.FAVORABLE);
UNSC.setRelationship(Factions.TRITACHYON, RepLevel.FAVORABLE);
UNSC.setRelationship(Factions.HEGEMONY, RepLevel.SUSPICIOUS);
UNSC.setRelationship(Factions.LUDDIC_CHURCH, RepLevel.SUSPICIOUS);
UNSC.setRelationship(Factions.PIRATES, RepLevel.HOSTILE);
UNSC.setRelationship(Factions.LUDDIC_PATH, RepLevel.HOSTILE);
    }

}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2021, 04:44:18 PM
Are you actually calling initFactionRelationships() anywhere? That's not a method in any of the interfaces and it doesn't get called automatically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 11, 2021, 04:56:13 PM
Right - the vanilla plugin doesn't support this. The only way around this that comes to mind is to provide your own version of SurveyPluginImpl.

so how exactly would i do something like that? would i need to simply make a script named SurveyPluginImpl? i will start setting this up regardless, but i have no idea how to make a script to replace another script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 11, 2021, 06:03:02 PM
Are you actually calling initFactionRelationships() anywhere? That's not a method in any of the interfaces and it doesn't get called automatically.

I got this part, I think I have the syntax right?

Code
	public static void initFactionRelationships(SectorAPI sector) {
                FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);

(https://i.imgur.com/jy3sz2b.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 11, 2021, 06:26:50 PM
You need to actually call the initFactionRelationships method. Something like this:

Code: java
    public void generate(SectorAPI sector) {
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("unsc");

/* No Audere if Nex Enabled */
if (Global.getSettings().getModManager().isModEnabled("nexerelin")) {
} else {
new UNSCStar().generate(sector);
}
initFactionRelationships(sector);
    }

Right - the vanilla plugin doesn't support this. The only way around this that comes to mind is to provide your own version of SurveyPluginImpl.

so how exactly would i do something like that? would i need to simply make a script named SurveyPluginImpl? i will start setting this up regardless, but i have no idea how to make a script to replace another script.
settings.json:
Code: json
	"plugins":{
"surveyPlugin":"com.fs.starfarer.api.impl.campaign.SurveyPluginImpl",
},
Replace the specified plugin (that one's the vanilla version) with your own/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 11, 2021, 06:43:09 PM
thank you for the help histidine, and all the others that helped me so far. someday this will be a truly AOK mod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 11, 2021, 07:11:33 PM
You need to actually call the initFactionRelationships method. Something like this:

Code: java
    public void generate(SectorAPI sector) {
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("unsc");

/* No Audere if Nex Enabled */
if (Global.getSettings().getModManager().isModEnabled("nexerelin")) {
} else {
new UNSCStar().generate(sector);
}
initFactionRelationships(sector);
    }

Yep, that did the trick!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 11, 2021, 09:17:38 PM
ok so I have one more question, for all you helpful, wonderful people.
I find myself wanted to change the crew cost of salvage operations, however I have not the slightest clue of how to do this.
dose anyone have any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on June 12, 2021, 12:47:43 AM
https://fractalsoftworks.com/forum/index.php?topic=21957.0

I liked idea of this mod, I like being able to put more stuff on vessels and especially its buffes pirate and other ships with low OP ships, so they can be potentially be both more useful to player and more dangerous foe? and it more honest than putting extra OP via skill, but adjusting rest of mods to same formula takes a lot time, interesting, its possible to do something like that but using scripts? I have idea, but I don't know if its possible to do with StarSector API:

Hullmods can add OP's, like Extreme Modifications from SWP and Junker Hullmods in HMI do, but i'm not sure if possible to add OP's in "insides" off hullmod, I think one of ideas is make scripts which add special hullmod to all ships, like Second Wave Options do, its adds special hullmod to all of ships via script. And this hullmod first negates all OP of ship to zero, then it checks all available slots where player can add weapons and fighters via loop, excluding any build-ins, and then adds some OP's on top depending of ship class, adds bonus OP if hullmod XIV battlegroup hullmod, and removes some if ship have build ins like Overrides or Civilian Grade Ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 14, 2021, 12:26:03 AM
How to check if a ship with wings is on regroup/attack mode?



Also, is there any alternate way to check when a fighter is returning to a carrier for refit? I tried this: fighterBay.getWing().isReturning(fighter), but it doesn't seem to trigger when, for instance, a bomber has dropped payload and is on the way back to a carrier.
EDIT: this didn't work because returning wing members are removed from the wingmembers list and added to the returning fighter list, so iterating over that instead is the solution
Code
if(bay.getWing() != null)
{
for(int i = 0; i < bay.getWing().getWingMembers().size();i++)
{
ShipAPI fighter =  bay.getWing().getWingMembers().get(i);
if(fighter == null)
continue;
if(fighter != null)
{
f(bay.getWing().isReturning(fighter))
{


}
}
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 14, 2021, 12:18:19 PM
Is there a way to get the AI to be more wasteful with their missiles?
I'm looking at Loadout for an Alpha Core Guardian, and it'll just sit there not firing it's missiles even when just holding fire results in total victory.

I've tried ALWAYS_PANICS, but it seems to change little.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 14, 2021, 03:46:19 PM
ok so I have one more question, for all you helpful, wonderful people.
I find myself wanted to change the crew cost of salvage operations, however I have not the slightest clue of how to do this.
dose anyone have any ideas?

You can either provide your own implementation of SurveyPlugin, or adjust SurveyPluginImpl.BASE_CREW from your ModPlugin.

How to check if a ship with wings is on regroup/attack mode?

ship.isPullBackFighters()

Is there a way to get the AI to be more wasteful with their missiles?
I'm looking at Loadout for an Alpha Core Guardian, and it'll just sit there not firing it's missiles even when just holding fire results in total victory.

I've tried ALWAYS_PANICS, but it seems to change little.

It should be "ALWAYS_PANIC" (no S on the end) and that should work. But the thing with missiles is they won't autofire, so it still has to prefer that group for manual fire, so that'll limit how often they're fired compared to other groups which generally will autofire at least when flux is low. You might try splitting other groups up to make the missile group more attractive in comparison.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Chozo on June 14, 2021, 11:19:36 PM
I want to check (and run a script) every time the player's fleet composition changes: something along the lines of how player skills that depend on certain stats in the player's fleet (DP by certain categories, number of fighter bays, etc.) do.  However, as far as I can tell the listener(s) that the player skills use are not in the API.

1. Am I missing something, or is there something in the API that provides similar functionality?

2. On a related note, .95 skills are broken up into three "tiers" in the .skill file: requiredSkillLevel 0 (no points), 1, and 2 (skill point + story point).  What are the restrictions of what scripts that can be placed in each tier?  If I place a non-description type script in a requiredSkillLevel 0 declaration, will it actually run or be ignored?  A kludge alternative solution I'm considering is creating a dummy player skill, or piggybacking the script on an existing skill.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AppleMarineXX on June 15, 2021, 12:00:23 AM
Nevermind, I inexplicably fixed it by renaming the build artifact from UNSCJar.jar to UNSC.jar

Spoiler
I'm trying to stuff my scripts stuff into a .jar file for the first time, and it's been quite a headache.

My latest issue comes with this odd error thrown when I run the game.

Code
16878 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.scripts.UNSCModPlugin]
java.lang.RuntimeException: Error loading [data.scripts.UNSCModPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.UNSCModPlugin
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

I'm currently running Intellij with Java SDK 16, but with the Project Language Level set to 7.

My WorldPluginCode goes:
Code
package data.scripts;

/*import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;*/

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.FullName;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.impl.campaign.ids.Ranks;
import com.fs.starfarer.api.impl.campaign.ids.Skills;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import com.fs.starfarer.api.loading.HullModSpecAPI;

import data.scripts.world.UNSCWorldGen;
import org.apache.log4j.Logger;

public class UNSCModPlugin extends BaseModPlugin
{

    public static Logger log = Global.getLogger(UNSCModPlugin.class);

    public void onNewGame()
    {
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("unsc");
        initUNSC();
    }

private static void initUNSC()
    {
        new UNSCWorldGen().generate(Global.getSector());
    }

}

One odd thing I've noticed is that it claims my "UNSCModPlugin" class is never used, though I'm not sure if that's an issue or not.

(https://i.imgur.com/OflMXyQ.png)

What's going wrong here?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 15, 2021, 01:35:51 PM
@AppleMarineXX

Just generally, if you are declaring a class using JSON such as is the case with your mod plugin then your IDE isn't going to be able to recognize that and will say that the class isn't used. It would be the same with skill classes for instance since their scripts are ran in the skill JSON file instead of a java file.

The IDE is looking for usages in your code for that determination rather than in every project file.

@Chozo

Take a look at BaseSkillEffectDescription.java under "com\fs\starfarer\api\impl\campaign\skills".

That handles the threshold part of skills. It isn't a listener so much as a calculation of the relevant values each time the player mouses over the skill which runs the description script. Similarly, it calculates the same values each time the skill is applied.

So assuming I am understanding what you are trying to do, you could theoretically check the fleet composition each time the description and apply script is executed and display whatever your effects would be based upon what you would find at that moment. The easiest way to do this would be to extend BaseSkillEffectDescription with your own class so you have access to all the methods and variables that other skills have. Then extend your custom class in the skill that needs the composition check. Your custom class can also override BaseSkillEffectDescription's methods as needed while preserving all the other skills implementations. Hopefully that makes sense. I can give a couple examples if needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 15, 2021, 05:08:21 PM
If I want a hullmod only unlocked by a skill, do I set: no_drop, no_sell in its tags? Setting Hidden to true prevents it from being equipped in the refit screen even when it is unlocked by the skill.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 16, 2021, 06:29:59 AM
It should be "ALWAYS_PANIC" (no S on the end) and that should work. But the thing with missiles is they won't autofire, so it still has to prefer that group for manual fire, so that'll limit how often they're fired compared to other groups which generally will autofire at least when flux is low. You might try splitting other groups up to make the missile group more attractive in comparison.
Apologies, that was autocorrect.
As you can see, even with ALWAYS_PANIC, the ship prefers even to close in and use it's flak guns rather than fire the *** missiles that would end the encounter in literal seconds:
Spoiler
(https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/9d676854-ca16-4cea-9099-fd954e997e6d/delmgfo-fbd7822b-75de-45fa-afcc-f3a94e0c9d8e.png/v1/fill/w_1280,h_720,q_80,strp/screenshot006_by_blacktemplegaurdian_delmgfo-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9NzIwIiwicGF0aCI6IlwvZlwvOWQ2NzY4NTQtY2ExNi00Y2VhLTkwOTktZmQ5NTRlOTk3ZTZkXC9kZWxtZ2ZvLWZiZDc4MjJiLTc1ZGUtNDVmYS1hZmNjLWYzYTk0ZTBjOWQ4ZS5wbmciLCJ3aWR0aCI6Ijw9MTI4MCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19.mele6zFcxPlO2ivOoI2twEyIohgtspt9p9bgyg4F__I)
[close]

EDIT: I attempted to do a test (by stripping all non-missile weapons) to see how often the AI fired the missiles. I started the stop watch on the first salvo.

After 18 seconds (during which it had plenty of ammo, and no cooldowns) it finally fired a single salvo again. I then gave up after recording two and a half minutes of the Guardian just sitting in missile range doing nothing except tanking shots. I'll clear a profile of all but console commands to do a clean test (both with and without ALWAYS_PANIC) and post it on bug report because that's just... not right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 16, 2021, 06:49:27 AM
I would hazard a guess that the AI thinks the hardpoints will miss because the target is not actually in line with either of them, so it won't fire them. And the AI doesn't know how to turn to line up offset/off-angle hardpoints AFAIK
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JManu15 on June 16, 2021, 10:09:01 AM
Hello, i dont know much of programming but im trying to make a hullmod only usable if the ship is low tech. this is what i tried changing, i dont know if its good but when i try it, it gives me an error that the method "getManufacturer" is not declared

import com.fs.starfarer.api.combat.ShipHullSpecAPI;
public boolean isApplicableToShip(ShipAPI ship) {
      return ship != null &&
         (!ship.getManufacturer().contains("Low Tech"));
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 16, 2021, 11:10:45 AM
That handles the threshold part of skills. It isn't a listener so much as a calculation of the relevant values each time the player mouses over the skill which runs the description script. Similarly, it calculates the same values each time the skill is applied.

Right! And skills should recalculate when the player fleet changes. So this should cover it. Try to make sure the calculation isn't too expensive, though, since it will be performed *a lot*.


I would hazard a guess that the AI thinks the hardpoints will miss because the target is not actually in line with either of them, so it won't fire them. And the AI doesn't know how to turn to line up offset/off-angle hardpoints AFAIK

Having looked into it, yeah, that's correct.

Hello, i dont know much of programming but im trying to make a hullmod only usable if the ship is low tech. this is what i tried changing, i dont know if its good but when i try it, it gives me an error that the method "getManufacturer" is not declared

import com.fs.starfarer.api.combat.ShipHullSpecAPI;
public boolean isApplicableToShip(ShipAPI ship) {
      return ship != null &&
         (!ship.getManufacturer().contains("Low Tech"));
}

Hi - it's probably a good idea to check out the javadoc, here:
https://fractalsoftworks.com/forum/index.php?topic=7164.0
To see what methods are actually available!

In your case, you probably want:
!ship.getHullStyleId().equals("LOW_TECH")

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 16, 2021, 01:45:44 PM
Code
pilot = OfficerManagerEvent.createOfficer(Global.getSector().getFaction("player"),1, true);

If I create officer this way using a local variable in a basehullmod script, is there any danger of save bloat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 16, 2021, 03:01:23 PM
Local variable? Should be fine. Member variable would be a problem because the hull mod effect script in instantiated once per application run and so is shared between saves.

So, no risk of *save bloat* either way, but high risk of bugs/memory leaks if using a member variable to store that person.

It kind of sounds like you might mean member variable rather than local, just based on it being "pilot = " and not "PersonAPI pilot = "...

So, for clarity: local means declared in the function. Member means declared in the class, i.e. something like "private PersonAPI pilot".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 16, 2021, 03:21:42 PM
Thanks for the extra info..so just to be sure, is basically how it works?
Code
public class armaa_wingCommander extends BaseHullMod {

private PersonAPI pilot; // Member Variable


@Override
    public void addPostDescriptionSection(TooltipMakerAPI tooltip, ShipAPI.HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
{
   PersonAPI pilot = null; // Local Variable
   pilot = OfficerManagerEvent.createOfficer(Global.getSector().getFaction("player"),1, true);
        }
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 16, 2021, 03:25:52 PM
Right, yes.

(Note: if you actually had both like that, the result of "createOfficer()" would get assigned to the local variable.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 16, 2021, 09:39:38 PM
hey all
I find myself wanting to have an industry, that when built, makes AI fleets with a home market that has this industry install a certain hullmod onto all there ships. I have learned how to make industries after mush work, but I have no idea how to effect spawned fleets in this manner.
I would also like to have this industry change the fleet's captions portraits and names, if possible, but the hullmod is the main thing.
thanks to all who chose to help in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 17, 2021, 01:41:50 PM
Ummm, hey Alex...

Did you make:       

Code
stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_LEVEL * 0.01f);

Now remove the boost when shields are up or fighters are engaged? Like:

Code
stats.getAllowZeroFluxAtAnyLevel()

- If so, you completely broke my mod. Any chance that these can be separated out so the old version of the behavior is still possible?

Huh strange... well nvm this is only occurring on a couple of ships. The majority keep the old behavior. I must be doing something weird on my end though I'm not sure what yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 17, 2021, 02:55:48 PM
Right, yes.

(Note: if you actually had both like that, the result of "createOfficer()" would get assigned to the local variable.)

awesome. thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrescentQuill on June 18, 2021, 03:56:35 PM
This is probably a smoothbrain question, but how do you add new portraits to the game? I can't find any information on it in any of the modding resource threads, and my attempts to figure it out have only let me replace portraits rather than add them.  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 18, 2021, 04:30:03 PM
This is probably a smoothbrain question, but how do you add new portraits to the game? I can't find any information on it in any of the modding resource threads, and my attempts to figure it out have only let me replace portraits rather than add them.  ???

Look at the faction files. There is a section for portraits. Copy and past the entire line and then change the png name to the name of the portrait you want to add. You can either do this in a mod format or add the portrait to the game's relevant graphics folder if its for personal use.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on June 19, 2021, 09:23:29 AM
i have a hullmod that depends on some FleetMemberAPI values, and to get that i would usually use MutableShipStatsAPI.getFleetMember(). when i added a "affectsOPCosts" override set to true, the method applyEffectsBeforeShipCreation was called twice, and the second time has a MutableShipStatsAPI that doesn't have a fleet member assigned to it. (as a side note: i'm pretty sure this MutableShipStatsAPI object is the one that you can find under ShipVariantAPI.getStatsForOpCosts())

is there a way to easily get the fleetmember that doesn't involve looping through every single ship in a fleet and its variant and all of its modules' variants to look for a specific MutableShipStatsAPI object? if i have the hullmod on a lot of ships (tried with 8 ) the game noticably hitches whenever these hullmods run applyEffectsBeforeShipCreation because of the method.

this is what i needed to do as a result, and what also causes the hitching
Spoiler
Code
if(stats.getFleetMember() != null)
            return stats.getFleetMember();

        if(stats.getEntity() instanceof ShipAPI) {
            ShipAPI ship = (ShipAPI) stats.getEntity();
            if(ship.getFleetMember() != null) {
                return ship.getFleetMember();
            }
        }

        FleetMemberAPI fm = null;
        for(FleetMemberAPI member : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
            if(member.isFighterWing()) continue;

            if(member.getStats() == stats) {
                fm = member;
            } else if (member.getVariant().getStatsForOpCosts() != null) {
                if (member.getVariant().getStatsForOpCosts() == stats) {
                    fm = member;
                } else if (member.getVariant().getStatsForOpCosts().getEntity() != null && member.getVariant().getStatsForOpCosts().getEntity() == stats.getEntity()) {
                    fm = member;
                }
            }

            if(fm != null) break;

            if (member.getVariant().getModuleSlots() != null && !member.getVariant().getModuleSlots().isEmpty()) {
                for(String variantId : member.getVariant().getModuleSlots()) {
                    ShipVariantAPI variant = member.getVariant().getModuleVariant(variantId);
                    if(variant.getStatsForOpCosts() == stats) {
                        fm = member;
                    } else if (member.getVariant().getStatsForOpCosts().getEntity() != null && stats.getEntity() == variant.getStatsForOpCosts().getEntity()) {
                        fm = member;
                    }

                    if(fm != null) break;
                }
            }

            if(fm != null) break;
        }
[close]

i worked around this issue by using a Map that i clear when the player exits the market, but it's still annoying that i had to go through so much effort.
i'm having an issue now where the fleet screen shows i have free OP (https://i.imgur.com/7JqHb7D.png) after applying the hullmod through a dialog, but clicking into the refit screen does not show the free OP (https://i.imgur.com/Rs28siP.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 19, 2021, 05:33:31 PM
I can't find where this is implemented, so:

Is:    public static final String AUXILIARY_EFFECT_ADD_PERCENT = "auxiliary_effect_add_percent";

 - Hardcoded to only work with the vanilla implementation of Militarized Subsystems and the two package hullmods? In other words, if I replaced Militarized Subsystems with my own version, will that character stat not do anything to it?

*EDIT*

I guess the other thing to ask here since I've never done it would be, if the above is true, then if I made the variables of my militarized subsystems public and modified them directly using the skill script would that work?


I swear every time I ask something here I answer my own question 30 seconds after posting it. Ugh lol sorry! I see the relevant part in the militarized subsystems hullmod itself. The problem was my implementation was outdated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrescentQuill on June 20, 2021, 10:19:41 AM
This is probably a smoothbrain question, but how do you add new portraits to the game? I can't find any information on it in any of the modding resource threads, and my attempts to figure it out have only let me replace portraits rather than add them.  ???

Look at the faction files. There is a section for portraits. Copy and past the entire line and then change the png name to the name of the portrait you want to add. You can either do this in a mod format or add the portrait to the game's relevant graphics folder if its for personal use.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: keantmp on June 20, 2021, 11:49:59 AM
I have a couple questions -

Is there a listener for when a player opens up a colony management screen?

Are the hullmods really spread out half inside starfarer.api.jar and half in /data/hullmods?

Where is the build-in of modules for story points handled?

And a much dumber question: which .java files can be replaced? I can't just replace any class I want in starfarer.api.jar right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 22, 2021, 04:30:08 AM
Is it possible to set a hullmod such that it can't be S-Mod'd a la Saftey Overrides?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 22, 2021, 08:15:52 AM
Are fighter wing IDs required to end in "_wing"? Asking because of this issue (https://github.com/Histidine91/Nexerelin/issues/20); the IDs are correct as far as I can tell.

Is it possible to set a hullmod such that it can't be S-Mod'd a la Saftey Overrides?
Add the no_build_in tag to the hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 22, 2021, 12:02:54 PM
Is there a listener for when a player opens up a colony management screen?

Not specifically, but there's a listener for when the player interacts with the colony, opens some submarkets, etc. You can check the ListenerUtil and CampaignEventListener classes for what's available.

Are the hullmods really spread out half inside starfarer.api.jar and half in /data/hullmods?

Yes. The ones in data/hullmods are mostly back when you couldn't bundle jars with the game and the hullmod code was compiled on startup using Janino.

Where is the build-in of modules for story points handled?

In core code.

And a much dumber question: which .java files can be replaced? I can't just replace any class I want in starfarer.api.jar right?

They can be if they're under data/. Stuff in starfarer.api.zip is just source code provided for reference - usually the way to go there would be to provide your own implementation and plug it in using whatever means is appropriate for that specific bit of code (say, via CampaignPlugin.pickXXXPlugin, or via settings.json, etc - you'd want to check how the thing you're replacing is referenced in order to know how to insert your version of it instead).

Are fighter wing IDs required to end in "_wing"? Asking because of this issue (https://github.com/Histidine91/Nexerelin/issues/20); the IDs are correct as far as I can tell.

Yes! The game needs to know whether a variant is a ship or a wing in a few places just from the string...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 22, 2021, 02:00:46 PM
This is throwing up a null error, and I'm not sure why:
Code
package data.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.loading.WeaponSlotAPI;

public class YunruPhaseMounting {
   
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, ShipAPI ship, String id) {
for (WeaponAPI w : ship.getAllWeapons()) {
WeaponSlotAPI m = w.getSlot();
if (m.isTurret() != true) continue;
float arc = m.getArc();
arc = arc*1.5f;
m.setArc(arc);
}
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 22, 2021, 04:00:33 PM
i keep getting this error
Spoiler
5341292 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment.isInSystem(RouteManager.java:141)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteData.getInterpolatedHyperLocation(RouteManager.java:379)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.shouldSpawn(RouteManager.java:651)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:617)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
   at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:128)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]


not sure where to begin on fixing this other than asking if anyone knows of any conflictions with the mods i have causing this
any help at all would be appreciated
i have no direction really to speak of in fixing this
i can type out an actual list of my mods if that helps, but i figured this would work


Spoiler
{"enabledMods": [
  "pantera_ANewLevel40",
  "adjustable_skill_thresholds",
  "Adjusted Sector",
  "idx_as_ships",
  "anotherportraitpack",
  "ARSWP",
  "armaa",
  "raccoonarms",
  "automatedcommands",
  "battlefleets",
  "beyondthesector",
  "BSC",
  "HMI_brighton",
  "Csp",
  "charmingly_wearisome",
  "combat_docking_module",
  "timid_commissioned_hull_mods",
  "lw_console",
  "domain_mship_controllable",
  "diyplanets",
  "DetailedCombatResults",
  "diableavionics",
  "exshippack",
  "XLU",
  "sun_flux_reticle",
  "gladiatorsociety",
  "GrandColonies",
  "HHE",
  "HMI_SV",
  "gaaius_hpw",
  "HMI",
  "gunnyhegexpeditionary",
  "hte",
  "hiigaran_descendants",
  "holyludd",
  "hm_barratry",
  "hullmod_specialization",
  "sun_hyperdrive",
  "IndEvo",
  "kadur_remnant",
  "kazeron",
  "keruvim_shipyards",
  "kingdomofterra",
  "lw_lazylib",
  "leadingPip",
  "ArkLeg",
  "logisticsNotifications",
  "low_maintenance",
  "luddenhance",
  "gaaius_mhp",
  "mag_protect",
  "MagicLib",
  "Mayasuran Navy",
  "yunru_midline_expansion",
  "su_CarrierHullmod",
  "mir",
  "more_ship_names",
  "Musashimanufactor",
  "nexerelin",
  "kayse_phaseships",
  "OcuA",
  "Ocutek",
  "luddandlions",
  "old_hyperion",
  "ORA",
  "console_overlord_additionalcommands",
  "pn",
  "paraqueeght",
  "wisp_perseanchronicles",
  "plight_of_the_valkyries",
  "PulseIndustry",
  "QualityCaptains",
  "m561_ramscoop",
  "rebalanced_doom",
  "remnant_command_transfer",
  "repdec",
  "rotcesrats",
  "roider",
  "sun_ruthless_sector",
  "tahlan_scalartech",
  "SCY",
  "secretsofthefrontieralt",
  "SEEKER",
  "shadow_ships",
  "PT_ShipDirectionMarker",
  "simpleplayerflags",
  "solsystem",
  "speedUp",
  "sputnik",
  "sw",
  "smc",
  "starpocalypse",
  "sun_starship_legends",
  "Steelclad",
  "stelnet",
  "hakkari",
  "timid_supply_forging",
  "surveycorpssp",
  "tahlan",
  "exalted",
  "star_federation",
  "TORCHSHIPS",
  "trulyautomatedships",
  "underworld",
  "UNSC",
  "US",
  "ungp",
  "unpackblueprints",
  "UGH",
  "vanidad",
  "vayrashippack",
  "XhanEmpire",
  "audio_plus",
  "astroidships",
  "prv",
  "ifonly",
  "shaderLib"
]}
[close]

i apologize for doing it this way but this was the most expedient way i could think of to post my mod list
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 22, 2021, 05:38:02 PM
"req_military" means a hull is sold *only* on military submarkets.

Was there ever a bug with this?

I have added this to several ships and this does not seem to be the case. Iirc I'm on RC12. They are still showing up in both the open market and black markets often as pristine hulls.

Paragon,archean_paragon,Battleship,High Tech,archean_highenergyfocus,31,40000,2000,50000,30000,1350,525,4,40,20,25,4,10,3500,FRONT,,360,0.7,0.6,,,450,1000,500,200,8,50,7,600000,5,5,900,0.5,42,10,,,,,,,,"archean_ultra_rare_bp, no_autofit, req_military, hist3t",0.1,0.6,4,6,,6

Astral,archean_astral,Supercarrier,High Tech,archean_fortressshield,29,30000,800,40000,15000,950,500,10,20,20,25,4,10,3000,FRONT,,360,0.8,0.6,,,350,1000,450,300,7,150,7,500000,7,7,820,0.25,38,10,,,,,,,CARRIER,"archean_ultra_rare_bp, no_autofit, req_military",0.1,0.6,3,4,,2

Aurora,archean_aurora,Cruiser,High Tech,archean_highenergyfocus,13,14000,800,22000,18000,620,230,2,60,40,40,15,13,1800,FRONT,,360,0.6,0.6,,,75,200,100,120,4,50,7,200000,8,8,680,0.5,17,5,,,,,,,,"rare_bp, archean_tritachyon_bp, no_autofit, req_military",0.35,0.6,2,3,,13

Tempest,archean_tempest,Frigate,High Tech,archean_flarelauncher_active,6,5000,200,9000,2813,380,50,1,100,200,175,50,110,200,OMNI,,120,0.8,0.85,,,10,25,40,15,1,10,10,36000,12,12,450,1,6,1,,,,,,,,"rare_bp, archean_tritachyon_bp, no_autofit, req_military, hist1t",0.33,0.5,2,2,,24

Spoiler
(https://i.imgur.com/vIxRrA6.png)
(https://i.imgur.com/dlYcTBN.png)
(https://i.imgur.com/JzYzgTy.png)
(https://i.imgur.com/3nLaLZO.png)
[close]

*EDIT*

I updated to RC15 and reproduced this in vanilla. I added the tag to the Wolf, Wolf(H), Enforcer, Eagle, Lasher, and Brawler. They also show up in the black market. They do seem to be a bit rarer.

Spoiler
(https://i.imgur.com/wuaTITB.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 22, 2021, 06:27:30 PM
This is throwing up a null error, and I'm not sure why:

Need to see the stack trace! It'll tell you the line where the NPE is, which you can then look at and see what's null where you're not expecting it to be.

i keep getting this error
Spoiler
5341292 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment.isInSystem(RouteManager.java:141)
[close]
Hmm, this should probably go in the modded bug reports subforum. Actually, there's another thread with the same (or what looks like the same) issue:
https://fractalsoftworks.com/forum/index.php?topic=21603.msg327174#msg327174

Was there ever a bug with this?

*facepalm* looking at the code, what it was actually doing is making sure those ships spawned anywhere except for military submarkets. Fixed that up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 22, 2021, 07:25:08 PM
*facepalm* looking at the code, what it was actually doing is making sure those ships spawned anywhere except for military submarkets. Fixed that up.

Ah good to know! Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 22, 2021, 11:32:07 PM
Ah okay, here we go (crash occurs when clicking to bring up hullmod list when the hullmod in question is known):

EDIT: So... this happens when you forget to extend BaseHullMod...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 22, 2021, 11:54:13 PM
Ah okay, here we go (crash occurs when clicking to bring up hullmod list when the hullmod in question is known):

We need more information.

This gives very little. At the very least a mod list is required, but ideally it should be narrowed down further.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on June 23, 2021, 12:27:35 AM
This is throwing up a null error, and I'm not sure why:
Maybe it's because you used this:
Code
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, ShipAPI ship, String id)
Instead of this?:
Code
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 23, 2021, 01:04:39 AM
Ah okay, here we go (crash occurs when clicking to bring up hullmod list when the hullmod in question is known):

We need more information.

This gives very little. At the very least a mod list is required, but ideally it should be narrowed down further.
I don't know what more to give? It's that script that's causing the issue. I know it is because, well, before I tried to implement it, there was no crash.

... Aaaand looking over it I can already see something wrong: It neither imports nor extends BaseHullMod.

EDIT: Yup, that was the source of the crash. New problem: The hullmod doesn't actually do anything (it was supposed to increase turret arcs).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 23, 2021, 07:28:27 AM
it seems as though the issue was indeed using random sector nex alongside the industry rev mod
i guess my youtube playthrough will be standard sector!
ive been itching to get it going, and i think i will have my first episode ready within a week.
FINGERS CROSSED
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 23, 2021, 12:53:15 PM
I don't know what more to give?

Ah ok I didn't see the first post only the second one with the error - which was vague without any useful information because unfortunately errors can sometimes not really give you much. Glad you figured it out though!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: HiddenPorpoise on June 23, 2021, 09:04:17 PM
If I were making a system that makes guns use a secondary damage type without losing the primary where would I look in the documentation?

The end goal is an attack destroyer with a system that gives its guns bonus HE damage but slashes its range while active.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 24, 2021, 02:13:21 AM
Where would I look at to try to replicate the Story Point Officer Promotion event that sometimes pops up and lasts a few months?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 24, 2021, 09:28:04 AM
Where would I look at to try to replicate the Story Point Officer Promotion event that sometimes pops up and lasts a few months?

You are looking for com.fs.starfarer.api.impl.campaign.intel.PromoteOfficerIntel.java in starfarer.api.zip. The intel events are created in com.fs.starfarer.api.impl.campaign.FleetEncounterContext.java on line 2038.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2021, 10:14:48 AM
If I were making a system that makes guns use a secondary damage type without losing the primary where would I look in the documentation?

The end goal is an attack destroyer with a system that gives its guns bonus HE damage but slashes its range while active.

You'd probably want to have a look at DamageDealtModifier and have the system add/remove that to the ship. RangedSpecialization (the implementation of the skill) might be a decent starting point to look at.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 24, 2021, 01:04:49 PM
Where would I look at to try to replicate the Story Point Officer Promotion event that sometimes pops up and lasts a few months?

You are looking for com.fs.starfarer.api.impl.campaign.intel.PromoteOfficerIntel.java in starfarer.api.zip. The intel events are created in com.fs.starfarer.api.impl.campaign.FleetEncounterContext.java on line 2038.

oof, thats  a meaty script! Thanks for going out of your way to give me the line number, even  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 24, 2021, 10:25:34 PM
I find myself wanting to make a button that can basically do exactly what the 'establish a colony' button can do, so i can have some different requirements for this button, however am having some troubles. the colony i make
dose not display faction name,
dose not show up on the players colony menu,
i don't know if the player gets any income from said colony, but is no income/upkeep visible
i cant build industry or structures, nor can i add administrators.


in short, i think im doing something wrong, but i have no idea were to even start.
here is my code, its adapted from something in Nexerelin, as it was recommended to me.
yes i know its a mess, but at this point I'm sick of guessing what's wrong, and trying to adapt something pointlessly.
Code
    public static void createColonyStatic(MarketAPI market, PlanetAPI planet,
                                          FactionAPI faction)
    {
        String factionId = faction.getId();

        market.setSize(3);
        market.addCondition("population_3");
        market.setFactionId(factionId);
        market.setPlanetConditionMarketOnly(false);
        //market.getMemoryWithoutUpdate().set(MEMORY_KEY_COLONY, true);
        //market.getMemoryWithoutUpdate().set(ExerelinConstants.MEMKEY_MARKET_STARTING_FACTION, factionId);

        // rename generic-name worlds
        if (market.getName().startsWith(planet.getStarSystem().getBaseName() + " ")) {
            String tag = NameGenData.TAG_PLANET;
            if (planet.isMoon()) tag = NameGenData.TAG_MOON;
            String newName = ProcgenUsedNames.pickName(tag, null, null).nameWithRomanSuffixIfAny;
            market.setName(newName);
            planet.setName(newName);
            ProcgenUsedNames.notifyUsed(newName);
        }

        if (market.hasCondition(Conditions.DECIVILIZED))
        {
            market.removeCondition(Conditions.DECIVILIZED);
            market.addCondition(Conditions.DECIVILIZED_SUBPOP);
        }
        market.addIndustry(Industries.POPULATION);

        // set growth level to 0%
        if (!faction.isPlayerFaction()) {
            ImmigrationPlugin plugin = getImmigrationPlugin(market);
            float min = plugin.getWeightForMarketSize(market.getSize());
            market.getPopulation().setWeight(min);
            market.getPopulation().normalize();
            market.getMemoryWithoutUpdate().set("$nex_delay_growth", true, 10);
        }

        //NexFactionConfig config = NexConfig.getFactionConfig(factionId);
        //if (config.freeMarket)
        //{
        //    market.getMemoryWithoutUpdate().set("$startingFreeMarket", true);
        //    market.setFreePort(true);
        //}
        //REMOVED TEST 0
        //market.getTariff().modifyFlat("generator", Global.getSector().getFaction(factionId).getTariffFraction());
        //NexUtilsMarket.setTariffs(market);

        // submarkets
        //SectorManager.updateSubmarkets(market, Factions.NEUTRAL, factionId);
        //REMOVED TEST 0
        //market.addSubmarket(Submarkets.SUBMARKET_STORAGE);
        market.setSurveyLevel(MarketAPI.SurveyLevel.FULL);
        for (MarketConditionAPI cond : market.getConditions())
        {
            cond.setSurveyed(true);
        }

        Global.getSector().getEconomy().addMarket(market, true);
        market.getPrimaryEntity().setFaction(factionId); // http://fractalsoftworks.com/forum/index.php?topic=8581.0

        //if (!fromDeciv) {
        //    NexUtilsMarket.addPerson(Global.getSector().getImportantPeople(),
        //            market, Ranks.CITIZEN, Ranks.POST_ADMINISTRATOR, true);
            //market.setImmigrationIncentivesOn(true);
        //}
        //if (fromDeciv) {
            market.addIndustry(Industries.SPACEPORT);
        //}

        //ColonyManager.buildIndustries(market);
        //ColonyManager.getManager().processNPCConstruction(market);

        // planet desc change
        //MarketDescChanger.getInstance().reportMarketTransfered(market, faction,
                //Global.getSector().getFaction(Factions.NEUTRAL), false, false, null, 0);
    }
so anyone know to make something like this work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 25, 2021, 10:57:24 AM
One thing you need to do for a player-owned colony is:
market.setPlayerOwned(true)

Not sure if that'd cover everything you have going on, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 25, 2021, 01:16:24 PM
Is there a way to get missiles to use the mote ai?
I've been messing around (without an IDE, currently unable to use one) and tried setting a missile's type to "mote", then set a missile weapon to fire the existing mote projectile, although both times the resulting missiles don't move on their own - is it a part of the ziggurat's system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 25, 2021, 02:09:05 PM
So getting back to this code, now that it doesn't crash, I can't figure out why it simply does... Nothing. I'd thought/hoped it would increase the firing arc of any turret mounts, but both the refit screen and testing shows that it doesn't.

Code
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, ShipAPI ship, String id) {
for (WeaponAPI w : ship.getAllWeapons()) {
WeaponSlotAPI m = w.getSlot();
if (m.isTurret() != true) continue;
float arc = m.getArc();
arc = arc*1.5f;
m.setArc(arc);
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on June 26, 2021, 12:50:18 PM
So getting back to this code, now that it doesn't crash, I can't figure out why it simply does... Nothing. I'd thought/hoped it would increase the firing arc of any turret mounts, but both the refit screen and testing shows that it doesn't.

Code
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, ShipAPI ship, String id) {
for (WeaponAPI w : ship.getAllWeapons()) {
WeaponSlotAPI m = w.getSlot();
if (m.isTurret() != true) continue;
float arc = m.getArc();
arc = arc*1.5f;
m.setArc(arc);
}
}
Afaik weapons aren't made (BeforeShipCreation code-wise) so there's nothing for it to modify except built-ins or something. You have to use ApplyEffectsAfterShipCreation. Also I'm unaware if you can even add ShipAPI ship to the command.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 26, 2021, 02:01:21 PM
Afaik weapons aren't made (BeforeShipCreation code-wise) so there's nothing for it to modify except built-ins or something. You have to use ApplyEffectsAfterShipCreation. Also I'm unaware if you can even add ShipAPI ship to the command.

You should be able to cast the CombatEntityAPI that you get from the MutableShipStatsAPI.getEntity() to a ShipAPI.

Example:
Code
            ShipAPI ship = null;
            if (stats.getEntity() instanceof ShipAPI) {
                ship = (ShipAPI)stats.getEntity();
            }

            if (ship != null) {
               // Do the thing.
            }

If that has issues for some reason, then you could always use:

Code
	@Override
public void advanceInCombat(ShipAPI ship, float amount) {
}

 - and set/check for a static boolean to prevent the script from constantly running.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 26, 2021, 04:42:51 PM
So getting back to this code, now that it doesn't crash, I can't figure out why it simply does... Nothing. I'd thought/hoped it would increase the firing arc of any turret mounts, but both the refit screen and testing shows that it doesn't.
Afaik weapons aren't made (BeforeShipCreation code-wise) so there's nothing for it to modify except built-ins or something. You have to use ApplyEffectsAfterShipCreation. Also I'm unaware if you can even add ShipAPI ship to the command.

You can't add parameters to a method override. It creates a new method. Naturally, the core code will never call that new method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 27, 2021, 02:05:44 AM
Hmm, both before and after don't have an effect (even calling the method with the correct number of parameters, heh).

Is there any examples of advanceInCombat other than PeriodicMissileReload?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NinjaSiren on June 27, 2021, 05:51:51 AM
Good day! I am adding a new weapon for my mod (a large particle/laser weapon) and every time I test it in game this happens:

Spoiler
117873 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.ship.A.G.this.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.G.createBeam(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.E.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.O0OO.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.E.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.G.advance(Unknown Source)
   at com.fs.starfarer.combat.systems.G.o00000(Unknown Source)
   at com.fs.starfarer.combat.systems.G.advance(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

Here is the weapon's .wpn code:
Spoiler
{
  "id": "hs_polaris_projector",
  "specClass": "beam",
  "type": "ENERGY",
  "size": "LARGE",
  "collisionClass": "RAY",
  "collisionClassByFighter": "RAY_FIGHTER",
  "turretSprite": "graphics/weapons/polaris_projector_turret_base.png",
  "turretGlowSprite": "graphics/weapons/polaris_projector_turret_glow.png",
  "hardpointSprite": "graphics/weapons/polaris_projector_hardpoint_base.png",
  "hardpointGlowSprite": "graphics/weapons/polaris_projector_hardpoint_glow.png",
  "glowColor": [185, 157, 230, 96],
  "hitGlowRadius": 0,
  "turretOffsets": [3, 0],
  "turretAngleOffsets": [ 0 ],
  "hardpointOffsets": [15,0],
  "hardpointAngleOffsets": [ 0 ],
  "beamFireOnlyOnFullCharge": true,
  "fringeColor": [179, 141, 238, 128],
  "coreColor": [80, 51, 125, 192],
  "darkCore": true,
  "width": 25,
  "textureType": CHUNKY,
  "textureScrollSpeed": 292,
  "pixelsPerTexel": 5,
  "fireSoundOne": "hs_polaris_start",
  "fireSoundTwo": "hs_polaris_shot"
}
[close]

What causes it to do a NullPointerException?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 27, 2021, 06:24:06 AM
Quote
"textureType": CHUNKY,
Isn't vanilla (according to the wiki anyhow), and if you're going for your own custom one, I think it'll need the file extension too?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NinjaSiren on June 27, 2021, 06:33:03 AM
Quote
"textureType": CHUNKY,
Isn't vanilla (according to the wiki anyhow), and if you're going for your own custom one, I think it'll need the file extension too?

Yes, I am only using vanilla, I don't know why it does not work.

UPDATE: I think this is an audio problem, I think I forgot to code the definitions for the new weapon's sound.  :-[  ;D

TY  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 27, 2021, 10:06:29 AM
Is there any examples of advanceInCombat other than PeriodicMissileReload?

Operations Center:

Code
	@Override
public void advanceInCombat(ShipAPI ship, float amount) {
CombatEngineAPI engine = Global.getCombatEngine();
if (engine == null) return;

CombatFleetManagerAPI manager = engine.getFleetManager(ship.getOriginalOwner());
if (manager == null) return;

DeployedFleetMemberAPI member = manager.getDeployedFleetMember(ship);
if (member == null) return; // happens in refit screen etc

boolean apply = ship == engine.getPlayerShip();
PersonAPI commander = null;
if (member.getMember() != null) {
member.getMember().getFleetCommander();
}
apply |= commander != null && ship.getCaptain() == commander;

if (apply) {
ship.getMutableStats().getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).modifyFlat(MOD_ID, RECOVERY_BONUS * 0.01f);
} else {
ship.getMutableStats().getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).unmodify(MOD_ID);
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on June 27, 2021, 10:29:05 AM
Has anyone ran into an issue where a weapon script causes a lot of lag during the simulation while selecting opponents and then the lag clears up once the opponents are selected and deployed?

It seems to happen irrelevant of the ship selected for the sim - which is a bit odd. But then again a lot of weapons share weapon effects so it could be coincidence I suppose.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 27, 2021, 07:32:21 PM
Is there any way to change characteristics of a wing in combat, such as reducing wing size?
I can do it using applyEffectsBeforeShipCreation, but only with the wingspec which affects every LPC

Also, is it possible to give a ship fighter AI? It seems like part of what's needed for the FighterAI constructor is obfuscated
(The parameters are, IIRC, Ship, and .. 'L') so i'm guessing this is a no, but figured i'd double check
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on June 28, 2021, 04:43:53 AM
question
i have 2 small missile weapons with unlimited ammo - one for HE damage and one for KN - both have DO_NOT_AIM, DO_NOT_CONSERVE hints
i have a ship that can mount three small missile hardpoints and one universal turret
that ship has mounted 2 KN small missiles and one HE - all in the same group, linked
when ship is on autopilot it will only ever fire _one_ missile weapon at a time, and at about 50% of it's max fire rate
but as soon as i take control of the ship those three weapons all start to fire at maximum fire rate
why does this happen ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cyan Leader on June 28, 2021, 04:47:42 AM
Is there an easy way to make the player be able to make unlimited permanent hullmods while limiting the number on AI fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on June 28, 2021, 05:39:45 PM
i have a hullmod that depends on some FleetMemberAPI values, and to get that i would usually use MutableShipStatsAPI.getFleetMember(). when i added a "affectsOPCosts" override set to true, the method applyEffectsBeforeShipCreation was called twice, and the second time has a MutableShipStatsAPI that doesn't have a fleet member assigned to it. (as a side note: i'm pretty sure this MutableShipStatsAPI object is the one that you can find under ShipVariantAPI.getStatsForOpCosts())

is there a way to easily get the fleetmember that doesn't involve looping through every single ship in a fleet and its variant and all of its modules' variants to look for a specific MutableShipStatsAPI object? if i have the hullmod on a lot of ships (tried with 8 ) the game noticably hitches whenever these hullmods run applyEffectsBeforeShipCreation because of the method.

this is what i needed to do as a result, and what also causes the hitching
Spoiler
Code
if(stats.getFleetMember() != null)
            return stats.getFleetMember();

        if(stats.getEntity() instanceof ShipAPI) {
            ShipAPI ship = (ShipAPI) stats.getEntity();
            if(ship.getFleetMember() != null) {
                return ship.getFleetMember();
            }
        }

        FleetMemberAPI fm = null;
        for(FleetMemberAPI member : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
            if(member.isFighterWing()) continue;

            if(member.getStats() == stats) {
                fm = member;
            } else if (member.getVariant().getStatsForOpCosts() != null) {
                if (member.getVariant().getStatsForOpCosts() == stats) {
                    fm = member;
                } else if (member.getVariant().getStatsForOpCosts().getEntity() != null && member.getVariant().getStatsForOpCosts().getEntity() == stats.getEntity()) {
                    fm = member;
                }
            }

            if(fm != null) break;

            if (member.getVariant().getModuleSlots() != null && !member.getVariant().getModuleSlots().isEmpty()) {
                for(String variantId : member.getVariant().getModuleSlots()) {
                    ShipVariantAPI variant = member.getVariant().getModuleVariant(variantId);
                    if(variant.getStatsForOpCosts() == stats) {
                        fm = member;
                    } else if (member.getVariant().getStatsForOpCosts().getEntity() != null && stats.getEntity() == variant.getStatsForOpCosts().getEntity()) {
                        fm = member;
                    }

                    if(fm != null) break;
                }
            }

            if(fm != null) break;
        }
[close]

i'm having an issue now where the fleet screen shows i have free OP (https://i.imgur.com/7JqHb7D.png) after applying the hullmod through a dialog, but clicking into the refit screen does not show the free OP (https://i.imgur.com/Rs28siP.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 29, 2021, 09:26:36 AM
Is there any way to change characteristics of a wing in combat, such as reducing wing size?
I can do it using applyEffectsBeforeShipCreation, but only with the wingspec which affects every LPC

I think you *might* be able to use bay.setExtraDeploymentLimit(<negative value>). That may not work, though - if it doesn't then you probably can't.

Also, is it possible to give a ship fighter AI? It seems like part of what's needed for the FighterAI constructor is obfuscated
(The parameters are, IIRC, Ship, and .. 'L') so i'm guessing this is a no, but figured i'd double check

I don't think so, and if you could, that'd cause all sorts of problems. For example it wouldn't avoid ship collisions, might try to find a carrier to land on, and so on.

question
i have 2 small missile weapons with unlimited ammo - one for HE damage and one for KN - both have DO_NOT_AIM, DO_NOT_CONSERVE hints
i have a ship that can mount three small missile hardpoints and one universal turret
that ship has mounted 2 KN small missiles and one HE - all in the same group, linked
when ship is on autopilot it will only ever fire _one_ missile weapon at a time, and at about 50% of it's max fire rate
but as soon as i take control of the ship those three weapons all start to fire at maximum fire rate
why does this happen ?

I'm not really clear on what you're saying - what do you mean by "all start to fire at maximum fire rate"? Like... they wouldn't just do that on their own, so maybe you mean you're able to fire them that way?

Regardless, though, hmm... if the group is linked and you're 100% sure of that, the only way for one of the weapons to fire individually is if the group is on autofire. But that wouldn't explain why it's firing at half the rate - though exactly when it fires would be up to the autofire AI at that point. However, it should be easy for you to see whether the group is on autofire, what group the ship AI has selected, and so on. There's a lot more info here to be had.

Is there an easy way to make the player be able to make unlimited permanent hullmods while limiting the number on AI fleets?

Change "maxPermanentHullmods" to something high! For AI fleets, it's not limited by that value but rather by some directives at fleet creation.


i have a hullmod that depends on some FleetMemberAPI values, and to get that i would usually use MutableShipStatsAPI.getFleetMember(). when i added a "affectsOPCosts" override set to true, the method applyEffectsBeforeShipCreation was called twice, and the second time has a MutableShipStatsAPI that doesn't have a fleet member assigned to it. (as a side note: i'm pretty sure this MutableShipStatsAPI object is the one that you can find under ShipVariantAPI.getStatsForOpCosts())

is there a way to easily get the fleetmember that doesn't involve looping through every single ship in a fleet and its variant and all of its modules' variants to look for a specific MutableShipStatsAPI object? if i have the hullmod on a lot of ships (tried with 8 ) the game noticably hitches whenever these hullmods run applyEffectsBeforeShipCreation because of the method.

this is what i needed to do as a result, and what also causes the hitching

Hmm - have you considered just bailing out if stats.getFleetMember() and stats.getEntity() both return null? IIRC that would only happen in some edge cases and it's more of a safety precaution to check for this rather than a case where it's required for things to work.

(I'm not sold on this code causing hitching, btw, especially not if we're just talking about the player's fleet. The code you've pasted just isn't doing a substantial amount of work - it *might* be a problem if like several hundred ships in non-player-fleets all had this mod and had it applied at the same time, but otherwise? It's hard to see.

It's just looping over the ships in the player's fleet, and doing a bit of additional looping within that only for ships with modules, and that just wouldn't amount to much. I mean, I still wouldn't do that without a good reason! But the game does tons of things much heavier than this every frame.)


i'm having an issue now where the fleet screen shows i have free OP (https://i.imgur.com/7JqHb7D.png) after applying the hullmod through a dialog, but clicking into the refit screen does not show the free OP (https://i.imgur.com/Rs28siP.png)

Not sure about this one. I vaguely recall running into something similar myself in the last month or so and (probably?) fixing it but the details escape me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pariah on June 29, 2021, 12:36:52 PM
I'm in the process of making some simple hulls that broke today. They worked fine yesterday, however today for some reason it kept crashing. I eventually stripped my mod back down to one hull and then it started to work again. I then slowly added everything back in and it still all worked. I couldn't find anything wrong with it and I didn't delete anything so I don't know what happened. If anyone has any ideas as to what I may have or may not have done that would be appreciated. As I am worried that its going to happen again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on June 29, 2021, 12:52:16 PM
I'm not really clear on what you're saying - what do you mean by "all start to fire at maximum fire rate"? Like... they wouldn't just do that on their own, so maybe you mean you're able to fire them that way?

Regardless, though, hmm... if the group is linked and you're 100% sure of that, the only way for one of the weapons to fire individually is if the group is on autofire. But that wouldn't explain why it's firing at half the rate - though exactly when it fires would be up to the autofire AI at that point. However, it should be easy for you to see whether the group is on autofire, what group the ship AI has selected, and so on. There's a lot more info here to be had.
case A: i'm piloting ship personally, have group1 selected, the missile weapons are in group2 with autofire enabled - all three of them fire constantly as soon as the target in range
case B: i'm not piloting the ship, it is deployed under ai control. the missile weapons are in group2 with autofire enabled. only one weapon is firing at a time, as you can see on video: https://streamable.com/4ankxz
ignore the weird ship behavior otherwise, it has been since identified to not be the cause, but i can't record another vid
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 29, 2021, 12:59:46 PM
Autofire behavior is identical between player and AI controlled ships, unless I suppose there's a custom weapon AI involved? In theory that'd also be the same but it's possible that one could be coded to behave differently if on a player ship.

What you want to look at is the ship info widget - in the bottom left - that shows the currently selected weapon group, group autofire status, etc. I kind of suspect that the AI turns off autofire and the group is not in fact linked; not much else comes to mind to explain this behavior. Well, again, apart from and odd custom autofire AI.


I'm in the process of making some simple hulls that broke today. They worked fine yesterday, however today for some reason it kept crashing. I eventually stripped my mod back down to one hull and then it started to work again. I then slowly added everything back in and it still all worked. I couldn't find anything wrong with it and I didn't delete anything so I don't know what happened. If anyone has any ideas as to what I may have or may not have done that would be appreciated. As I am worried that its going to happen again.

Hmm - not enough info to say conclusively! If you're compiling hullmods with an IDE/some kind of build process, it's possible that doing a clean build would have also resolved this. Otherwise, from experience, it sounds like one of your assumptions is wrong somewhere - either you weren't changing what was actually being used at one point, or the state it's in now is not the same as the state it was in when it wasn't working, etc.

Edit: *how* it broke would also be useful information...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 29, 2021, 01:13:16 PM
Autofire behavior is identical between player and AI controlled ships, unless I suppose there's a custom weapon AI involved? In theory that'd also be the same but it's possible that one could be coded to behave differently if on a player ship.
Didn't you say earlier the AI doesn't use autofire for missiles? In which case it would be a different AI, no?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on June 29, 2021, 01:16:15 PM
What you want to look at is the ship info widget - in the bottom left - that shows the currently selected weapon group, group autofire status, etc. I kind of suspect that the AI turns off autofire and the group is not in fact linked; not much else comes to mind to explain this behavior. Well, again, apart from and odd custom autofire AI.
yes, that's the problem, with ai turning off autofire
what i don't understand is why, and how to fix it
in the video it is literally sitting on top of target, why won't it fire?

Autofire behavior is identical between player and AI controlled ships, unless I suppose there's a custom weapon AI involved?
i can guarantee there is none, that's too complex for me to do
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 29, 2021, 01:24:22 PM
Didn't you say earlier the AI doesn't use autofire for missiles? In which case it would be a different AI, no?

Not normally! But if there's some kind of very high ammo or ammo-regenerating missile, it might (not 100% sure offhand) - or if it's a missile weapon that has a type of BALLISTIC, for example.

Regardless, though that doesn't say whether it'd be a different kind of AI or not, since the weapon autofire AI would only come into play once the ship AI decides to turn the group on autofire...


What you want to look at is the ship info widget - in the bottom left - that shows the currently selected weapon group, group autofire status, etc. I kind of suspect that the AI turns off autofire and the group is not in fact linked; not much else comes to mind to explain this behavior. Well, again, apart from and odd custom autofire AI.
yes, that's the problem, with ai turning off autofire
what i don't understand is why, and how to fix it
in the video it is literally sitting on top of target, why won't it fire?

... ah! It might've helped if that was, you know, the actual question to begin with :)

Checking the code, it looks like it doesn't autofire missile weapons unless they've 1) got >20 ammo *and* 2) they're unguided. I think the reason for the second condition is larger-capacity (but not unlimited) guided missile weapons would fire all the time and get used up quickly. Let me add a check for it also having unlimited ammo, so that those would be ok to autofire regardless.

Your best bet might be to add tags like STRIKE, USE_VS_FRIGATES and rely on the AI manually firing the linked group.

Edit: another option would be a script that turns autofire on for that group every frame, thus mostly overriding the autofire manager for the ship AI, which only runs this a couple of times a second.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 29, 2021, 01:46:39 PM
Checking the code, it looks like it doesn't autofire missile weapons unless they've 1) got >20 ammo *and* 2) they're unguided. I think the reason for the second condition is larger-capacity (but not unlimited) guided missile weapons would fire all the time and get used up quickly. Let me add a check for it also having unlimited ammo, so that those would be ok to autofire regardless.
Would it be possible to also have an external override for that, for use in things in the vein of the missile auto forge?

Edit: On a related note, is there a way to add tags to a weapon via hullmod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on June 30, 2021, 12:07:30 AM
What can mess with a Ship's BreakProb to be 100% guaranteed? I need a wing that self-destructs to break into 4 pieces, but no matter how much numbers I put in BreakProb it will sometimes just refuse to split apart.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on June 30, 2021, 03:20:04 AM
Is there any API hook to return what ship is selected/if a ship is selected in the command UI?
(the one where you can issue orders/retreat..not sure if that's the right name for it)

edit: also, ships with fighter bays but no carrier tag - do they default to COMBAT_CARRIER behavior?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on June 30, 2021, 03:34:19 PM
How much flux/s is it when a beam is charging up/down?
Is it proportional to level or straight up using full flux cost?
What about damage and hit strength? Are they proportional?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 01, 2021, 08:44:12 PM
Would it be possible to also have an external override for that, for use in things in the vein of the missile auto forge?

If you add the ALWAYS_PANIC ship hint that should achieve a similar if not identical result.

Edit: On a related note, is there a way to add tags to a weapon via hullmod?

There is not, no. No way to do it without affecting *all* weapons of that type.


Is there any API hook to return what ship is selected/if a ship is selected in the command UI?
(the one where you can issue orders/retreat..not sure if that's the right name for it)

There isn't, no. (Command UI is about right; I'm never quite sure what to call it, myself.)

edit: also, ships with fighter bays but no carrier tag - do they default to COMBAT_CARRIER behavior?

Yeah - well, "CARRIER, COMBAT" but yeah.

What can mess with a Ship's BreakProb to be 100% guaranteed? I need a wing that self-destructs to break into 4 pieces, but no matter how much numbers I put in BreakProb it will sometimes just refuse to split apart.

It can never be actually 100% guaranteed, let alone to break in exactly 4 pieces. It tries to find "valid" ways to break up the hull (which involves some RNG and tesselating the hull's bounds) and gives up after some number of failed attempts. Which is why for example you could see a ship be "destroyed" (rather than "disabled") but not break apart.

How much flux/s is it when a beam is charging up/down?
Is it proportional to level or straight up using full flux cost?
What about damage and hit strength? Are they proportional?

After checking: it looks to be the full flux cost during charge-up and active, and zero during charge-down. The damage and I believe hit strength are proportional to the charge level of the beam, though. Well, not exactly proportional, it's some sort of square function; I forget exactly why but it made some numbers work out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 02, 2021, 01:05:20 AM
If you add the ALWAYS_PANIC ship hint that should achieve a similar if not identical result.
Is there a way to add ship hints via hullmod?


Edit: A separate question: Are beams treated as a separate weapon to energy weapons, or as a subset of them?

If I wanted to half all energy weapon's flux cost, would I need to modify both  getBeamWeaponFluxCostMult and getEnergyWeaponFluxCostMult, or just the energy one?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 02, 2021, 09:09:41 AM
Is there a way to add ship hints via hullmod?

I don't think so.

Edit: A separate question: Are beams treated as a separate weapon to energy weapons, or as a subset of them?

If I wanted to half all energy weapon's flux cost, would I need to modify both  getBeamWeaponFluxCostMult and getEnergyWeaponFluxCostMult, or just the energy one?

That would actually be pretty easy to test - set the getEnergyWeaponFluxCostMult() to zero and see if beams still generate flux.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 02, 2021, 09:54:36 AM
That would actually be pretty easy to test - set the getEnergyWeaponFluxCostMult() to zero and see if beams still generate flux.
I... am dumb.
I was thinking of all these complex ways to test with various logging that I don't even know how to instigate, and then I could just do this.


Another another question (sorry):
What's the difference between ModifyPercent and ModifyMult (other than one taking a percentage and the other a float), and what's the order of operation for ModifyPercent/Mult/Flat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 03, 2021, 02:26:24 PM
Another another question (sorry):
What's the difference between ModifyPercent and ModifyMult (other than one taking a percentage and the other a float), and what's the order of operation for ModifyPercent/Mult/Flat?

It's: (base + base * (percent/100) + flat) * mult
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 03, 2021, 02:40:45 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 04, 2021, 08:52:52 AM
How can you tell if a ship module is still attached or not?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 04, 2021, 09:41:56 AM
How can you tell if a ship module is still attached or not?

module.getStationSlot() != null
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on July 04, 2021, 12:59:25 PM
i have a hullmod that depends on some FleetMemberAPI values, and to get that i would usually use MutableShipStatsAPI.getFleetMember(). when i added a "affectsOPCosts" override set to true, the method applyEffectsBeforeShipCreation was called twice, and the second time has a MutableShipStatsAPI that doesn't have a fleet member assigned to it. (as a side note: i'm pretty sure this MutableShipStatsAPI object is the one that you can find under ShipVariantAPI.getStatsForOpCosts())

is there a way to easily get the fleetmember that doesn't involve looping through every single ship in a fleet and its variant and all of its modules' variants to look for a specific MutableShipStatsAPI object? if i have the hullmod on a lot of ships (tried with 8 ) the game noticably hitches whenever these hullmods run applyEffectsBeforeShipCreation because of the method.

this is what i needed to do as a result, and what also causes the hitching

Hmm - have you considered just bailing out if stats.getFleetMember() and stats.getEntity() both return null? IIRC that would only happen in some edge cases and it's more of a safety precaution to check for this rather than a case where it's required for things to work.


i can't bail out here, unfortunately. the member data that i need determines whether to reduce OP costs of weapons or not, and the second call to "applyEffectsBeforeShipCreation" only happens if "affectsOPCosts" on the hullmod returns true. to help illustrate this i added some logging which shows that the first call doesn't have a stats.getFleetMember or a stats.getEntity return value, so it must loop:

Spoiler
Code
568942 [Thread-3] INFO  extrasystemreloaded.util.FleetMemberUtils  - finding member for stats
568942 [Thread-3] INFO  extrasystemreloaded.util.FleetMemberUtils  - must loop for variant stats!
568942 [Thread-3] INFO  extrasystemreloaded.util.FleetMemberUtils  - finding member for stats
568942 [Thread-3] INFO  extrasystemreloaded.util.FleetMemberUtils  - was in a fleet member
[close]

it seems the hitching isn't an issue any more, oddly enough, as i gave the upgrade to around 15 ships and didn't notice it while jumping around the market. the hitching was the main reason why i brought up this issue, however i still think it's weird the first stats object from the first call never has the fleet member set
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 04, 2021, 01:25:53 PM
Hmm, you're right, there looks to be an issue there. I'll make a note to have a look at some point; unfortunately it seems like something I'd have to change some API method signatures to make work properly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 04, 2021, 09:05:57 PM
Is there any API hook to return what ship is selected/if a ship is selected in the command UI?
(the one where you can issue orders/retreat..not sure if that's the right name for it)

There isn't, no. (Command UI is about right; I'm never quite sure what to call it, myself.)

argh..is this something that could possibly be added to the API in the future?
actually, even if it were possible, it probably wouldn't work for what I want
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 05, 2021, 09:39:30 AM
I'm getting a weird "Inconsistent constant value type" error with this:
Code
package data.scripts;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class YunruHeavyMissileIntegration extends BaseHullMod {

public static final float YUNRU_COST_REDUCTION  = 10;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_MISSILE_MOD).modifyFlat(id, -YUNRU_COST_REDUCTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + (int) YUNRU_COST_REDUCTION + "";
return null;
}

@Override
public boolean affectsOPCosts() {
return true;
}

}
What makes it weird is that it's identical to Heavy Ballistics Integration, just switched to missiles, with nothing else touched.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: michail on July 05, 2021, 09:49:54 AM
I'm getting a weird "Inconsistent constant value type" error with this:
<snip>
What makes it weird is that it's identical to Heavy Ballistics Integration, just switched to missiles, with nothing else touched.

Maybe your compiler is more picky than the one used to compile the API jar? Try "10.0f" for maximum pedantry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 05, 2021, 10:53:36 AM
Could be; currently it's a loose script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on July 06, 2021, 11:08:52 AM
Hi!

I need to get rid of weapon arcs of specific weapons in a EveryFrameWeaponEffectPlugin.
I mean the drawn weapon arc not the arcs of weapon mounts, in case that isn't clear.
Can anyone help me with this, in the best case with a code example?

Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 06, 2021, 12:46:00 PM
Ah, as far as I know, that's not possible. If it's a proper weapon that can be fired, the arcs are just a UI thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on July 06, 2021, 01:09:28 PM
Ah, as far as I know, that's not possible. If it's a proper weapon that can be fired, the arcs are just a UI thing.

okay, instead I would like to remove it from the weapons group but I'm having a hell of trouble with that.
here's my script so far: https://pastebin.com/JbXBJNwT (https://pastebin.com/JbXBJNwT)

"droneslot" has to be deleted from the weapon group it is in, the other one is a decorative and doesn't draw weapon arcs.
I got really far with this script, I'd really like to finish it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 06, 2021, 02:41:22 PM
okay, instead I would like to remove it from the weapons group but I'm having a hell of trouble with that.
here's my script so far: https://pastebin.com/JbXBJNwT (https://pastebin.com/JbXBJNwT)

"droneslot" has to be deleted from the weapon group it is in, the other one is a decorative and doesn't draw weapon arcs.
I got really far with this script, I'd really like to finish it

This line:

Code
mutableShipStatsAPI.getVariant().clearSlot("droneslot");

 - Might be your problem. That requires a slot id and it looks like you are passing in the weapon id from what I can see though its not 100% clear since you are hardcoding it by id. You can get the slot id from the relevant WeaponAPI I believe. Otherwise, seeing the .variant you are dealing with would be helpful.

*EDIT*

Ah nvm looking at it more closely it does seem to be a slot id at least in that you are using it for other parts of the script as a slot id. The only other thing I could think of is if you know the index of the weapon group you could try something like:

Code
stats.getVariant().getWeaponGroups().get(index).removeSlot("droneslot");

And then add it back in as needed.

Iterating through all seven groups and removing any of that slot you find is also possible though if you aren't sure of what the index would be. Other than that, I don't know, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 06, 2021, 04:04:27 PM
Just real quick:
ShipAPI.removeWeaponFromGroups(WeaponAPI weapon)
May be of interest.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on July 06, 2021, 04:05:52 PM
Thank you! That helped quite a lot.
The game adds the weapons back in again but at least I can make sure they are not in group 1.

Just real quick:
ShipAPI.removeWeaponFromGroups(WeaponAPI weapon)
May be of interest.

Oh nice! I'll try that. Thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 06, 2021, 04:07:02 PM
is it possible to have three way (or more) battles in starsector?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 06, 2021, 04:21:43 PM
 ::)
is it possible to have three way (or more) battles in starsector?

Technically maybe, with some ugly hackery and entirely custom ship AI and accepting that some things will be very rough around the edges. For practical purposes, though, it's just about a hard "no"...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 06, 2021, 06:59:29 PM
ha thats precisely what id expected
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on July 07, 2021, 11:01:37 AM
Hello there; is there documentation or even a brief post about upgrading mods from 91 to 95? Im sure im pretty late for the party so excuse me and thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 07, 2021, 11:05:09 AM
Standard MO seems to be "change the version number, see if it crashes, fix any crashes."
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on July 07, 2021, 11:11:06 AM
Hello there; is there documentation or even a brief post about upgrading mods from 91 to 95? Im sure im pretty late for the party so excuse me and thank you


You can have a look at 0.9.1a to 0.95a API diff: https://github.com/jaghaimo/starsector-api/commit/a8eb5000982512433042aa1f820b08d83e81fd4b
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 07, 2021, 01:33:51 PM
I'm trying to create a shotgun-esque weapon by basically having a sabot rocket that immediately detonates into it's second stage. It works really well, both in producing loose visual debris and all the shots being created at once.

The problem I'm having is if an enemy isn't in range, the first stage never detonates ruining the illusion. Worse still, if it comes within range of an enemy before it flames out, it'll detonate to its second stage, effectively doubling the range.

Is there a way to make sure it either detonates immediately regardless (preference), or flame out if it doesn't immediately find an enemy?

Edit: On a different topic, how do identically named jsons interact? Does one straight override the other, or is it more as with CSVs?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on July 07, 2021, 02:00:28 PM
I'm trying to create a shotgun-esque weapon by basically having a sabot rocket that immediately detonates into it's second stage. It works really well, both in producing loose visual debris and all the shots being created at once.

The problem I'm having is if an enemy isn't in range, the first stage never detonates ruining the illusion. Worse still, if it comes within range of an enemy before it flames out, it'll detonate to its second stage, effectively doubling the range.

Is there a way to make sure it either detonates immediately regardless (preference), or flame out if it doesn't immediately find an enemy?

Take a peek at Star Federation (FTL fanmod).
https://fractalsoftworks.com/forum/index.php?topic=19115.0

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 07, 2021, 02:17:01 PM
Take a peek at Star Federation (FTL fanmod).
https://fractalsoftworks.com/forum/index.php?topic=19115.0
I'm not seeing how that helps?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 07, 2021, 11:14:39 PM
what's the most reliable way to turn a ship into a hulk? i know applyDamage works, but it's unpredictable. is there some boolean toggle that can be flipped to say that this ship is no alive?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on July 08, 2021, 02:11:34 AM
Is there a way to determine in a BaseEveryFrameCombatPlugin if a ship has retreated from battle?

ShipAPI.isRetreating() returns true if a ship intends to retreat, but it can be destroyed or the battle can end before the retreat is completed.

[Edit] Got it - monitoring CombatEngineAPI.getFleetManager(FleetSide.ENEMY).getRetreatedCopy() for changes instead.

what's the most reliable way to turn a ship into a hulk? i know applyDamage works, but it's unpredictable. is there some boolean toggle that can be flipped to say that this ship is no alive?
ShipAPI.setHulk() (https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipAPI.html#setHulk(boolean))... haven't tried it myself but it looks like the right one
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on July 08, 2021, 02:08:42 PM
How do I get a left click input?

basically, if left click do this

I've tried this monstrosity but it does nothing at all
Spoiler
Code
    public void advance(float amount, WeaponAPI weapon, List<InputEventAPI> events) {

        boolean player;
        this.SHIP = weapon.getShip();
        List<FighterWingAPI> dronewings = this.SHIP.getAllWings();

        if (player = this.SHIP == Global.getCombatEngine().getPlayerShip()) {

            for (FighterWingAPI fighterWingAPI : dronewings) {

                this.FIGHTER = fighterWingAPI.getLeader();

                if (!fighterWingAPI.getWingId().equals("omm_weaponpod_wing")) {
                    continue;
                }

                this.FIGHTER.giveCommand(ShipCommand.HOLD_FIRE, null, 0);
            }
            for (InputEventAPI event : events) {
                if (event.isLMBEvent() || event.isLMBDownEvent()) {
                    this.FIGHTER.giveCommand(ShipCommand.FIRE, null, 0);
                }}}}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 09, 2021, 02:37:56 AM
So as to prevent this getting buried:
I'm trying to create a shotgun-esque weapon by basically having a sabot rocket that immediately detonates into it's second stage. It works really well, both in producing loose visual debris and all the shots being created at once.

The problem I'm having is if an enemy isn't in range, the first stage never detonates ruining the illusion. Worse still, if it comes within range of an enemy before it flames out, it'll detonate to its second stage, effectively doubling the range.

Is there a way to make sure it either detonates immediately regardless (preference), or flame out if it doesn't immediately find an enemy?

Edit: On a different topic, how do identically named jsons interact? Does one straight override the other, or is it more as with CSVs?

In more recent news, I am suffering the strangest... glitch? With skin variants.
I have a skin for the onslaught, but now the only autofit options for any onslaught (base, XIV, or mine) is the standard for a regular onslaught, or the standard for my skin.

I don't see this problem with the Falcon (P) (namely the other base variants no longer showing), so am confused where it's coming from.

I do, however, see this problem with the Brawler: the only variants listed are for the base hull, and the tritachyon variant isn't listed.

EDIT: This appears to be vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on July 10, 2021, 11:47:43 AM
Im so mad I have to ask this, I literally just asked a mod to delete my comments from this thread so I dont get notifications about it constantly; Is there a way to remove tags with hullmods? (https://fractalsoftworks.com/forum/index.php?topic=22260.msg335289#msg335289) trying to get a carrier to not think its a carrier, for, reasons



I'm trying to create a shotgun-esque weapon by basically having a sabot rocket that immediately detonates into it's second stage. It works really well, both in producing loose visual debris and all the shots being created at once.

The problem I'm having is if an enemy isn't in range, the first stage never detonates ruining the illusion. Worse still, if it comes within range of an enemy before it flames out, it'll detonate to its second stage, effectively doubling the range.

Is there a way to make sure it either detonates immediately regardless (preference), or flame out if it doesn't immediately find an enemy?

Edit: On a different topic, how do identically named jsons interact? Does one straight override the other, or is it more as with CSVs?

if the sabot method doesnt work out, check out the ravager mk3 weapon from the seeker mod, its literally just a shotty
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 10, 2021, 12:46:02 PM
what's the most reliable way to turn a ship into a hulk? i know applyDamage works, but it's unpredictable. is there some boolean toggle that can be flipped to say that this ship is no alive?

I think applyDamage is your best bet, regardless - especially since you'll want to damage the armor. There's a makeLookDisabled() method internally but it wasn't in the API; I've added it.

You could also ship.setHulk(true) and .setHitpoints(-1) but iirc that would not do all the necessary steps to make it *look* disabled.


[Edit] Got it - monitoring CombatEngineAPI.getFleetManager(FleetSide.ENEMY).getRetreatedCopy() for changes instead.

*thumbs up*


How do I get a left click input?

basically, if left click do this

I've tried this monstrosity but it does nothing at all

There are some other issues here (you need to check that the event is not event.isConsumed()) but that aside I'm not sure this method actually exists in any interface that would be called by core code?

public void advance(float amount, WeaponAPI weapon, List<InputEventAPI> events)


BaseEveryFrameCombatPlugin has:
advance(float amount, List<InputEventAPI> events)
and
public void processInputPreCoreControls(float amount, List<InputEventAPI> events)

Note the different method signatures (parameters etc).


Im so mad I have to ask this, I literally just asked a mod to delete my comments from this thread so I dont get notifications about it constantly; Is there a way to remove tags with hullmods? (https://fractalsoftworks.com/forum/index.php?topic=22260.msg335289#msg335289) trying to get a carrier to not think its a carrier, for, reasons

Hmm, "tags"? I think you don't actually mean tags but rather stuff in the "hints" column? But tags on variants are also a thing. Offhand though I don't think this is possible without affecting *every* ship of that type.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on July 10, 2021, 01:05:28 PM
There are some other issues here (you need to check that the event is not event.isConsumed()) but that aside I'm not sure this method actually exists in any interface that would be called by core code?

public void advance(float amount, WeaponAPI weapon, List<InputEventAPI> events)


BaseEveryFrameCombatPlugin has:
advance(float amount, List<InputEventAPI> events)
and
public void processInputPreCoreControls(float amount, List<InputEventAPI> events)

Note the different method signatures (parameters etc).

Thank you for looking into it!
In the end it was suprisingly easy:
Code
                            ShipAPI player = Global.getCombatEngine().getPlayerShip();
                            if (player == this.SHIP) {
                                FIGHTER.resetDefaultAI();
                            }
                            if (Mouse.isButtonDown(0)) {
                                FIGHTER.giveCommand(ShipCommand.FIRE, mousepos, 0);           //clicky left drone shooty
                            }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 10, 2021, 01:21:18 PM
Hmm - that might cause problems, for example what you wrote will trigger when the player is clicking on a menu button in the command interface or the "escape" menu.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on July 10, 2021, 01:48:19 PM
I'll keep an eye out if it causes too many problems, I'm happy this works well enough.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on July 10, 2021, 04:46:51 PM
Anybody know how to modify a ships OrdPoints with a hullmod?

I know the trick with using a negative value for the OP cost but that's not what I'm after.

The plan is to create a hullmod (Ordinance Storage) that increases OP by 8/12/16/20 based on hull size and reduces cargo capacity by x%.
The idea is to have the hull mod cost 4/6/8/10 so you only get access to the full value if you build it in.

Been playing around with the old getShipOrdnancePointBonus() from MutableCharacterStatsAPI but I can't seem to get it to work (used to be a character skill).

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on July 10, 2021, 06:02:31 PM
Anybody know how to modify a ships OrdPoints with a hullmod?
IDK. Whatever solution that you try, just be sure that the player can't "accidentally get a negative value of current OP. Once they are there, they have infinite OP.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 10, 2021, 06:26:06 PM
The other thing to get around somehow is the player installing the hullmod, using the extra OP, and then removing it. Generally speaking the game assumes that hullmods that modify OP costs are non-removable, and breaking that assumption puts it into "unsupported by the game" territory. Not to say it couldn't be made to work somehow, perhaps!

I don't know that this specific thing is doable, though. You can adjust the costs of weapons and fighter LPCs, but not hullmods, nor the base OP available on the hull - at least, there aren't any hooks for this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kenshkrix on July 10, 2021, 08:23:36 PM
The other thing to get around somehow is the player installing the hullmod, using the extra OP, and then removing it. Generally speaking the game assumes that hullmods that modify OP costs are non-removable, and breaking that assumption puts it into "unsupported by the game" territory. Not to say it couldn't be made to work somehow, perhaps!
I got a hacky implementation working, but it's not pretty.
Basically I have the negative OP hullmod add an invisible hullmod that re-adds the first hullmod if it's removed when the ship doesn't have enough OP available (otherwise removing both).
To make this actually matter I simply reduce the ship's speed to zero when it is 'invalid'.

It doesn't actually stop it from being exploitable, but if they're willing to ultra-slowboat around at 0 burn speed I won't bother stopping them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on July 10, 2021, 08:26:29 PM
The other thing to get around somehow is the player installing the hullmod, using the extra OP, and then removing it.

interestingly, theres a mod hullmod in one of the 63 mods i have that adds a Scaffolding hullmod to your ship at a cost of -100 OP that gives the ship a burn rate of 0, for adding stuff & building hullmods in without having to dance around the OP limit & the burn rate thing prevents you from leaving the hullmod on. It's not helpful, i just thought it was neat & clever

ANYWAY, doesnt the a_kite have more OP than the regular kite? Is the OP boost built into the hull & not from the auxiliary hullmod?

edit: how do you make hybrid weapons? I checked in the cvs but all the hybrid weapons are just marked as a single type like normal
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 11, 2021, 07:36:25 AM
Use "mountTypeOverride" in the .wpn file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dcong89 on July 11, 2021, 08:21:06 AM
sorry to ask but i got this error after combat refit ship and spawnfleet derelist to test after battle it crash to desktop :

[Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 4
java.lang.ArrayIndexOutOfBoundsException: 4
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus$ShipStatus.applyDamage(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus$ShipStatus.applyHullFractionDamage(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus.applyHullFractionDamage(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.applyDamageToFl eetMember(BattleAutoresolverPluginImpl.java:490)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.computeOutcomeF orFleetMember(BattleAutoresolverPluginImpl.java:690)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.resolveEngageme nt(BattleAutoresolverPluginImpl.java:333)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.resolve(BattleAutoresolverPluginImpl.java:243)
   at com.fs.starfarer.campaign.fleet.Battle.doAutoresolveRound(Unknown Source)
   at com.fs.starfarer.campaign.fleet.Battle.advance(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.advanceEvenIfPaused(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 11, 2021, 09:55:49 AM
This looks like it has something to do with a modular ship involved in an AI-vs-AI battle on the campaign map, but beyond that it's hard to say.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on July 11, 2021, 01:11:35 PM
The other thing to get around somehow is the player installing the hullmod, using the extra OP, and then removing it. Generally speaking the game assumes that hullmods that modify OP costs are non-removable, and breaking that assumption puts it into "unsupported by the game" territory. Not to say it couldn't be made to work somehow, perhaps!

 - at least, there aren't any hooks for this.

Thanks for the prompt response. Saved me floundering.

As far as adding and removing OP there was two schools of thought.

1 - OP is primarily a combat attribute, adding and removing the mod to exceed base OP without losing the cargo capacity has no bearing combat side. On the cargo side (logistics) it would have an impact but, generally speaking, there's easier ways to increase cargo capacity without cheesing the system.

2 - If the concept did prove abusable then I could have always made OP cost = OP bonus so the only way to get the bonus would to build it in which would prevent removal.


Which raises another question, is it possible to make a hull-mod behave differently depending on whether it's built in (or not). Haven't looked into this myself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on July 11, 2021, 01:15:39 PM
edit: how do you make hybrid weapons? I checked in the cvs but all the hybrid weapons are just marked as a single type like normal

In the .wpn file set

   "type":"HYBRID",

Worked for me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 11, 2021, 01:32:02 PM
Which raises another question, is it possible to make a hull-mod behave differently depending on whether it's built in (or not). Haven't looked into this myself.
Yup! Just check if the ship has a S-Mod with the hullmod's ID. If it does, have it do thing B, if not, thing A.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Deshara on July 11, 2021, 02:57:07 PM
what does projectile speed on missiles/bombs do? I added a 0 to the standard bomb bay's projectile speed & to the proximity launcher's launch speed and the prox launcher fired its bomb out like a railgun while the bomb bay appeared to be unchanged. I undid that, then changed the prox launcher's projectile speed to 0 then set the bomb's launch speed to 0, and the bomb didnt move when it came out but the prox charge was unchaged. It doesn't seem like it would do nothing since every missile's is different. Is it a deprecated stat for missiles that used to do something but got moved to launch speed?

also, while im here; the real thing i was toying with those numbers to figure out was, am I imagining that the proximity launcher's charges move faster right when they're fired and then slow down, or does it really do that? & if its not projectile speed being lower than launch speed doing it, where is that in the code? I want to toy with making the bombs come out faster but then slow down

also also, id been wanting to ask but hadnt yet; where does the special on-hit affect of, like, the breach missile live? I checked mods to see where they store weapon special affects but the core game's scripts folder is basically empty, & I cant find anything in the weapon or projectile files that might suggest it lives there. And I havent been able to find a weapon-modding tutorial that happens to mention where such a thing would live nvm i found it in the proj file. just overlooked it when i checked. Dunno where the code that onhit is calling lives tho, so im only closer to the answer edit: found it. now i just gotta learn to code java..

whats the deal with the use_on_frigates weapon hint? is it deprecated -- in the current build it seems like all it does is undo the strike tag
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dcong89 on July 11, 2021, 05:42:44 PM
This looks like it has something to do with a modular ship involved in an AI-vs-AI battle on the campaign map, but beyond that it's hard to say.

Thanks sir , maybe this error from new modular ship TC: Archean Order mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 11, 2021, 06:09:48 PM
Thanks sir , maybe this error from new modular ship TC: Archean Order mod.

There isn't any modular ships in Archean Order. Only stations have modules. Was it a station battle? (Assuming that error also applies to stations, anyway.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dcong89 on July 11, 2021, 09:30:58 PM
Thanks sir , maybe this error from new modular ship TC: Archean Order mod.

There isn't any modular ships in Archean Order. Only stations have modules. Was it a station battle? (Assuming that error also applies to stations, anyway.)

sorry Morrokain it's not error from your mod , i've used many mods which have modular ships like LowTech Armada,Kadur Remnant.... maybe i will disable one by one mods to find this error come from.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 11, 2021, 10:08:07 PM
sorry Morrokain it's not error from your mod , i've used many mods which have modular ships like LowTech Armada,Kadur Remnant.... maybe i will disable one by one mods to find this error come from.

No worries and yeah I'd say that is your best bet for finding out which mod is causing it. From what I can tell the error itself doesn't have any mod script references.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on July 14, 2021, 11:40:58 AM
Is there a convenient API for me to get all entities or just all ships within X radius instead of getting everything on field and parse distance one by one?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 14, 2021, 11:58:33 AM
what does projectile speed on missiles/bombs do? I added a 0 to the standard bomb bay's projectile speed & to the proximity launcher's launch speed and the prox launcher fired its bomb out like a railgun while the bomb bay appeared to be unchanged. I undid that, then changed the prox launcher's projectile speed to 0 then set the bomb's launch speed to 0, and the bomb didnt move when it came out but the prox charge was unchaged. It doesn't seem like it would do nothing since every missile's is different. Is it a deprecated stat for missiles that used to do something but got moved to launch speed?

also, while im here; the real thing i was toying with those numbers to figure out was, am I imagining that the proximity launcher's charges move faster right when they're fired and then slow down, or does it really do that? & if its not projectile speed being lower than launch speed doing it, where is that in the code? I want to toy with making the bombs come out faster but then slow down

It's their top speed. There's an... IIRC BOMB_WITH_SLOW AI type that will slow the bombs down; regular BOMB will just use the velocity at which it was launched.

whats the deal with the use_on_frigates weapon hint? is it deprecated -- in the current build it seems like all it does is undo the strike tag

It doesn't quite undo it, iirc it still won't fire on fighters and some other behaviors may be slightly different.

Is there a convenient API for me to get all entities or just all ships within X radius instead of getting everything on field and parse distance one by one?

See: CombatEngineAPI.getAiGridShips() and similar methods. You'd still have to do more exact checks but these can narrow down the initial set you do them against.

The overhead is probably comparable to just iterating over the set of all ships and doing a range check, though, especially if for what you're doing you don't care about fighters and so the maximum actual numbers of ships you do meaningful checks for is low. This sort of thing is more useful if you're looking at all projectiles, for example, since there can be a ton of those.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on July 14, 2021, 03:03:53 PM
Do listeners get automatically removed if they're no longer applicable? I was looking at the High Scatter Amplifier code and it doesn't remove the damage listener when the hullmod is unapplied (as far as I can tell), but obviously it turns off the beam hard flux when the hullmod isn't there any more.

Same question for listeners applied by weapon scripts- I have a gun that with an EveryFrameEffect that applies a listener at the start of combat (if the listener wasn't already there). Will this create a problem with a bunch of hanging listeners? I haven't run into any issues, but I'd like to be following best practices anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 14, 2021, 03:10:08 PM
ShipAPI does not persist between combats, and in refit, for example, a new one is created every time the variant changes - i.e. if you add a capacitor? New ShipAPI, etc. So broadly, this isn't something to worry about for hullmods if you're using the applyEffectsAfterShipCreation() method. It *is* something to worry about for personal combat skills, since the player can transfer command mid-combat.

Incidentally, this is why hullmods do not have an unapply() method and skills *do*.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on July 14, 2021, 03:37:31 PM
Ahh, okay, that was what I was worried about- saw the unapply stuff in the skill code and thought "oh crap do I need to be doing that?". Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 2_Wycked on July 15, 2021, 05:33:15 PM
Hi, just wondering why there are mods hosted here in this "Modding" area as well as the "Mods" section, when they seem similar? Is there a distinction between the two subforums maybe? Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on July 15, 2021, 05:54:52 PM
Hi, just wondering why there are mods hosted here in this "Modding" area as well as the "Mods" section, when they seem similar? Is there a distinction between the two subforums maybe? Thanks!

The way I see it:

Originally
Mods - Was for released and downloadable mods.
Modding - Was for discuss modding Starsector.

Then mods got locked.

Now:
Modding - Is for mods "under development"/not feature complete.
Mods - Is for mods that are effectively finished and, should, only be receiving minor/comparability updates.

Being that Mods is more visible and gets more attention this has unfortunately (as is common in the gaming industry) led to rat-race in which mods are being "published" in alpha status, which confuses the whole issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 15, 2021, 05:55:05 PM
The one's here are still very much in development, being moved to the mods section at the owner's request (usually only when they deem it stable enough).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2021, 05:57:57 PM
("Mods" was always locked. Generally speaking stuff will only be moved there when it's - at moderator discretion - warranted/is in good shape/is significant enough. But we've never actually hashed out any metrics for that.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 15, 2021, 06:29:38 PM
Is there a way to detach modules from a ship, like how they do when data is reloaded in devmode?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2021, 06:37:05 PM
Offhand - something like module.setStationSlot(null) should do it, I think?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 2_Wycked on July 15, 2021, 07:00:24 PM
Interesting, thanks yall. Thanks to all the modders, it's great seeing this community still going strong after so many years.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 15, 2021, 07:07:49 PM
what's the best way to force a (non-fighter) ship to exist in a different render layer - i.e. always render on top of other ships
or below, for that matter ?
how to ensure consistency? because just setting collision to FIGHTER does no always produce the same results, at least visually
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2021, 07:41:20 PM
Hmm - I don't think you can, actually. At least, no way (besides setting it to "fighter") comes to mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SonnaBanana on July 15, 2021, 09:41:09 PM
Alex, now that the new sanity checks on respeccing previously permanent skills are going to be in place, is there something similar modders can do for skills which grant increased OP on ships?

Like anything which checks if a ships has more assigned OP than it's total and makes players remove vents/caps/weaps/hullmods/wings?
Or just straight up assign maluses if that happens?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on July 16, 2021, 07:59:47 AM
I am making a new faction and would like to change the way its ships and officers are named.

Specifically, I would like names to be randomly generated from a set of syllables (instead of selected from a fixed list, as is done currently). Can this be done?

I have found com.fs.starfarer.api.impl.campaign.procgen.MarkovNames which seems somewhat related to this, but it is unused.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 16, 2021, 08:19:56 AM
Alex, now that the new sanity checks on respeccing previously permanent skills are going to be in place, is there something similar modders can do for skills which grant increased OP on ships?

Like anything which checks if a ships has more assigned OP than it's total and makes players remove vents/caps/weaps/hullmods/wings?

It's possible to add custom "skill change effects". But for this, you probably wouldn't actually need to - I've added one to vanilla, even though it doesn't need it. If a skill adds OP and is removed, ships that are over OP will have vents, capacitors, and hullmods (though not weapons/fighters - that gets tricky since they need to go somewhere, and it can't always be cargo or storage) removed.

I am making a new faction and would like to change the way its ships and officers are named.

Specifically, I would like names to be randomly generated from a set of syllables (instead of selected from a fixed list, as is done currently). Can this be done?

I have found com.fs.starfarer.api.impl.campaign.procgen.MarkovNames which seems somewhat related to this, but it is unused.

A few ways. The simplest would be to pre-generate your set of names with some code and paste that into the faction file. If you don't have too many syllables per name/too many syllables, that might be manageable.

A (probably better?) alternative would be to provide your own FleetInflater implementation (via CampaignPlugin.pickFleetInflater()) that does this in code. You'd likely want to extend DefaultFleetInflater and let it do most of the actual work, and only do the naming-related bits in yours.

I probably wouldn't use MarkovNames for this - it sounds like a different approach you'd want custom code for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SonnaBanana on July 16, 2021, 08:39:02 AM
Alex, now that the new sanity checks on respeccing previously permanent skills are going to be in place, is there something similar modders can do for skills which grant increased OP on ships?

Like anything which checks if a ships has more assigned OP than it's total and makes players remove vents/caps/weaps/hullmods/wings?

It's possible to add custom "skill change effects". But for this, you probably wouldn't actually need to - I've added one to vanilla, even though it doesn't need it. If a skill adds OP and is removed, ships that are over OP will have vents, capacitors, and hullmods (though not weapons/fighters - that gets tricky since they need to go somewhere, and it can't always be cargo or storage) removed.
And for the harebrained edge case of all of a ship's OP being taken up entirely by weapons and wings while not a single point is given to vents, caps and hullmods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 17, 2021, 06:23:41 AM
Is it possible to move a weapon's x and y position dynamically via code? I tried getSpite().setCenter() but this seems to only move the art and not the projectile spawns.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 17, 2021, 09:21:28 AM
Would like to know this too. Seems to only be acheivable with modules and a lot of hax
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 17, 2021, 09:27:33 AM
Hmm - to alter the projectile spawns, you could do:
weapon.ensureClonedSpec()
And then manipulate:
weapon.getSpec().getHardpointFireOffsets()
weapon.getSpec().getTurretFireOffsets()
Etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 17, 2021, 02:22:44 PM
just throwing this idea out there in case it helps:  in the future for missions (specifically bar events) it would be neat if the game checks for fleet strength (via deployment level/how many big ships you have) and either wont let you accept the mission, or perhaps not even show up at all

just food for thought going forward, and only in case it has yet to enter anyones mind.  cheers!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Spess Mahren on July 18, 2021, 01:04:25 AM
Where in the code is the "level" of autonomous defenses determined? I would like to make a personal mod to set the level to max right at game start, I just haven't had any luck finding out on my own.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: idiotekque on July 18, 2021, 10:14:02 AM
Hey, I'm curious if there a way to edit the functionality of the Field Repairs skill. Utterly fantastic skill, but after having it for awhile, arguably too fantastic. The "Chance to remove a d-mod every month" bit, in particular, seems to just trigger every month for me (maybe not EVERY month, but it sure does feel like it).

Is there any way to tweak the chance to be a bit lower? As much as I love the skill, it feels a bit OP for my preferences.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 18, 2021, 11:06:20 AM
Is there anything I should be mindful/wary of when storing data in PersistentData?

Right now im using it to store PersonAPIs for individual officers under under certain conditions. At worst I think at most 32 would be stored per save if every players officer met the condtions for them to be added, but I want to minimize save bloat. One thing I was unsure about was what happens to officers that are dismissed. Do they appear in play again, or are they deleted?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 18, 2021, 12:39:03 PM
Where in the code is the "level" of autonomous defenses determined? I would like to make a personal mod to set the level to max right at game start, I just haven't had any luck finding out on my own.

In SalvageGenFromSeed.

Something like:
Global.getSector().getMemoryWithoutUpdate().setFloat(SalvageGenFromSeed.DEFEATED_DERELICT_STR, 1000);

Should do what you're looking for.


Hey, I'm curious if there a way to edit the functionality of the Field Repairs skill. Utterly fantastic skill, but after having it for awhile, arguably too fantastic. The "Chance to remove a d-mod every month" bit, in particular, seems to just trigger every month for me (maybe not EVERY month, but it sure does feel like it).

Is there any way to tweak the chance to be a bit lower? As much as I love the skill, it feels a bit OP for my preferences.

It's 100%; the "chance" bit is just to account for situations where you remove from your fleet the ship that it was going to remove a d-mod from and it doesn't fire. But aside from that case it's guaranteed. You could try replacing FieldRepairsScript with a custom version that does what you want; you'd have to remove FieldRepairsScript on game load and add your version of it.


Is there anything I should be mindful/wary of when storing data in PersistentData?

Right now im using it to store PersonAPIs for individual officers under under certain conditions. At worst I think at most 32 would be stored per save if every players officer met the condtions for them to be added, but I want to minimize save bloat. One thing I was unsure about was what happens to officers that are dismissed. Do they appear in play again, or are they deleted?

Officers that are dismissed would not normally show up again. But there's no such thing as "deleting" them - if a script hangs out to a reference to one of them, they'd stick around forever there. I feel like what you're doing *should* be ok? One thing to keep in mind is that a person at a market has a reference to that market so if the market went away storing a person like that would prevent it from being cleaned up. But I'm not sure this really comes up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: idiotekque on July 18, 2021, 04:30:51 PM
It's 100%; the "chance" bit is just to account for situations where you remove from your fleet the ship that it was going to remove a d-mod from and it doesn't fire. But aside from that case it's guaranteed. You could try replacing FieldRepairsScript with a custom version that does what you want; you'd have to remove FieldRepairsScript on game load and add your version of it.

Aha, I figured. It certainly is a monumentally useful skill versus a lot of other ones. I don't know the last time I even actively used a ship with any d-mods because of it.

Unfortunately I haven't done any modding outside of json edits to this point, so I'm not sure how to go about that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 18, 2021, 06:14:13 PM
You could try replacing FieldRepairsScript with a custom version that does what you want; you'd have to remove FieldRepairsScript on game load and add your version of it.
Unfortunately I haven't done any modding outside of json edits to this point, so I'm not sure how to go about that.

I've actually done this funnily enough, so: (You put this in your mod plugin.)

Spoiler
public class ArcheusModPlugin extends BaseModPlugin {
    @Override
    public void onGameLoad(boolean newGame){
        // This ensures that d-mods won't be removed at level 1 of Field Repairs and instead requires the elite version.
        // See: ArcheusFieldRepairsScript.java under: src\data\scripts\skills
        EveryFrameScript script = null;
        List<EveryFrameScript> scriptList = Global.getSector().getScripts();
        for (EveryFrameScript temp : scriptList) {
            if (temp.getClass().getName().equalsIgnoreCase("com.fs.starfarer.api.impl.campaign.skills.FieldRepairsScript")) {
                script = temp;
            }
        }
        if (script != null) {
            Global.getSector().removeScript(script);
            LOG.info("Removed script: FieldRepairsScript -- from the sector's script list");
        }
        EveryFrameScript fieldRepairScrip = new ArcheusFieldRepairsScript();
        if (!Global.getSector().hasScript(fieldRepairScrip.getClass())) {
            Global.getSector().addScript(fieldRepairScrip);
            LOG.info("Adding new custom Field Repairs script to the sector's script list");
        }
    }
}
[close]

Then define your modplugin in the mod_info JSON:

   "modPlugin":"data.scripts.ArcheusModPlugin",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 18, 2021, 06:43:46 PM
Last version I was able to ensure my retrofit bar event was at the top of the bar list, but now there is no way to do that without breaking random events. Can we please get a way to add priority bar events?
Title: Modifying the content of bar mission dialog! is it even possible?
Post by: H.O on July 18, 2021, 07:23:06 PM
I may need some help figuring this thing out, so here we go ...

Can we manipulate the conversations text (replacing part of the text or adding highlights)? and if so how?

Basically what i am trying to do is the following; during the interaction/conversation dialog i want to be able to search and highlight the planets/star systems that are mentioned so they would indicate the faction they belong to. making it easy to decide whether to accept the missions or not. for instance in a raid mission against a planet that belongs to the pirate i would highlight the planet name in red (and maybe add its distance from current location). rather than getting the planet name and searching for it in the planets list then back again to accept the given mission.

While going throw the api i found some methods and techniques that may be in use but still i am not able to figure how to implement the whole thing

The farthest i was able to reach is to extend the BaseCampaignEventListener and override its reportShownInteractionDialog which enabled me to capture planet/colony dialog popup and from their i can manipulate only the last paragraph (overwriting its prior highlights in the process).
Next i want to be able to capture the conversations text such as bar missions, then manipulate all of its paragraphs while still preserving their original highlights.
Some techniques that i skimmed over hoping they would push me further but they didn't
BarEventDialogPlugin+BarCMD+RuleBasedInteractionDialogPluginImpl: which i suspect i can extend one of them then use it as alternative plugin to capture bar dialog, overriding one of its methods to perform the highlights. the problem i faced with them is that they seem to be focused on the options panel rather than the text panel, so the only way to manipulate the text panel would be getTextPanel() which only allow manipulating the last paragraph + overwrites the prior highlights + manipulations are done to the previous conversation message rather than the upcoming one (which makes sense, since option selection functionalities need to be taken care before text panel upcoming content get generated)

Just as an extra clarification here is what i am missing and trying to find
Spoiler
Code
paras = dialog.getTextPanel().[color=red]getAllParas()[/color]
foreach para in paras:
para.[color=red]setExtraHighlights[/color](Highlights... hs) // array of planet names along with their color
[close]
// OR
Spoiler
Code
class MyCustomTextPanelPlugin extends [color=red]CoreTextPanelPlugin[/color] {
@Override
LabelApi addPara(...) {
label = super(...);
label.setHighlight(highligts);
}
// somewhere else, register my custom text panel to handle/intercept addPara calls and highlight them as soon they are added via the addPara
Global.registerAlternativePlugin(MyCustomTextPanelPlugin);
}
[close]

P.S. the only post close to what i am trying to achieve was by the very active member @Morrokain, however i believe he -lucky him- was trying to manipulate content that he actually generate using addPara(), and i guess he ended applying highlights on a para by para bases. in my case however i am trying manipulate content generated by who knows how/where part of the code that i can't control or figure where it reside.

Ty in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 18, 2021, 07:40:19 PM

Officers that are dismissed would not normally show up again. But there's no such thing as "deleting" them - if a script hangs out to a reference to one of them, they'd stick around forever there. I feel like what you're doing *should* be ok? One thing to keep in mind is that a person at a market has a reference to that market so if the market went away storing a person like that would prevent it from being cleaned up. But I'm not sure this really comes up.

Thanks! Another question - is there a way to cancel assignments via the API? Like for example, I can assign a ship to light escort using the CombatTaskManagerAPI, but if I change their assignment, the previously created escort assignment remains and another ship just picks it up instead. I'm trying to remove it completely, like how you can by opening the Command UI and cancelling it there. Is this possible? There is removeObject in the combatengineapi but I don't know if that'd actually work, or had a chance to try it yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2021, 08:05:55 AM
Last version I was able to ensure my retrofit bar event was at the top of the bar list, but now there is no way to do that without breaking random events. Can we please get a way to add priority bar events?

Events added in the AddBarEvents trigger show up first, I believe. Not exactly what you're asking for, but might be good enough.

Thanks! Another question - is there a way to cancel assignments via the API? Like for example, I can assign a ship to light escort using the CombatTaskManagerAPI, but if I change their assignment, the previously created escort assignment remains and another ship just picks it up instead. I'm trying to remove it completely, like how you can by opening the Command UI and cancelling it there. Is this possible? There is removeObject in the combatengineapi but I don't know if that'd actually work, or had a chance to try it yet.

Ah, hmm - doesn't look like there is, actually. Let me add:
void removeAssignment(AssignmentInfo info);
To CombatTaskManagerAPI.


I may need some help figuring this thing out, so here we go ...

Can we manipulate the conversations text (replacing part of the text or adding highlights)? and if so how?
...

I don't think this is doable - there's too much stuff there that the API doesn't provide access to, and that the internal API doesn't, either. Like, modifying highlights isn't a thing that comes up generally, since those are just set when the paragraph is added, etc.

(On the bright side, I've got a TODO item to make some improvements in the general vein you're thinking...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: H.O on July 19, 2021, 11:26:55 AM
...
Can we manipulate the conversations text (replacing part of the text or adding highlights)? and if so how?
...

I don't think this is doable - ....

(On the bright side, I've got a TODO item to make some improvements in the general vein you're thinking...)

I see, well anyway glad to hear that it is on ur radar. please take ur time implementing it right, who knows maybe we could end up with highlightable, howeverable and clickable entities in our dialogs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2021, 02:06:30 PM
I'm getting reports like:

Quote
Ok, so I,ve found a few strange things. First I found a hammerhead for sale in an independent market which had medium ballistics-slots rather than hybrid. Also, during a pirate-fight, one of the-pirate ships (a standard kite ) showed up on the info-screen during combat as having no weapons installed even though I'm certain it had (showed up as armed on the pre-battle screen). Also, when I have come across people in bars which sold surplus-ships they seem to be vanilla-variants. For example, one guy sold a buffalo and it showed up on the info-screen with only one-energy-slot, which I think is the vanilla-variant unless I'm mistaken?

So I am going to start looking through the API to see how this is happening, but I figured I might as well post what I'm doing to prevent this in case I'm just missing something.

To start for every vanilla ship (by hull id or skin id) I first:

Spoiler
            Iterator<String> shipIterator = vanillaIDsDatabase.getOverriddenHullIDs().values().iterator();
            String id;
            while (shipIterator.hasNext()) {
                id = shipIterator.next();
                ShipHullSpecAPI ship = Global.getSettings().getHullSpec(id);
                if (!vanillaOverridesSettings.getBoolean(BLUEPRINT_CAN_DROP)) {
                    ship.getTags().remove("base_bp");
                    ship.getTags().remove("rare_bp");
                    ship.getTags().remove("remnant");
                    ship.getTags().remove("omega");
                    ship.getTags().remove("hist1t");
                    ship.getTags().remove("hist2t");
                    ship.getTags().remove("hist3t");
                    ship.addTag("no_drop");
                    ship.addTag("no_drop_salvage");
                }
                if (!vanillaOverridesSettings.getBoolean(SHIPS_CODEX_KEY)) {
                    ship.getHints().add(ShipHullSpecAPI.ShipTypeHints.HIDE_IN_CODEX);
                }
                if (!vanillaOverridesSettings.getBoolean(SHIPS_FOUND_KEY)) {
                    ship.getHints().add(ShipHullSpecAPI.ShipTypeHints.UNBOARDABLE);
                    ship.getTags().remove("merc");
                    ship.getTags().add("no_sell");
                }
            }
[close]

 - so the "no_drop", "no_drop_salvage", and "no_sell" tags should theoretically already do the job right? Just in case, however, I also:

Spoiler
            Iterator<FactionAPI> allFactions = Global.getSector().getAllFactions().iterator();
            Map<String, String> vanillaFactions = vanillaIDsDatabase.getFactionIDs();
            Map<String, String> tcFactions = totalConversionIDsDatabase.getTCFactionIDs();
            Iterator<String> vanillaShips = vanillaIDsDatabase.getOverriddenHullIDs().values().iterator();
            FactionAPI faction;
            while (allFactions.hasNext()) {
                faction = allFactions.next();
                if ((vanillaFactions.containsKey(faction.getId()) || tcFactions.containsKey(faction.getId())) &&
                        !vanillaOverridesSettings.getBoolean(SHIPS_FACTIONS_KEY)) {
                    while (vanillaShips.hasNext()) {
                        faction.getHullFrequency().put(vanillaShips.next(), 0f);
                    }
                    faction.getKnownShips().removeAll(vanillaIDsDatabase.getOverriddenHullIDs().values());
                    if (logInfo) {
                        LOG.info("Current known ships for: " + faction.getId() + " - " + faction.getKnownShips().toString());
                    }
                }
            }
[close]


 - and when checking the logs I confirm that vanilla ships are not known by any of the vanilla factions. I also double checked that all of the ids are present in the spreadsheet. Well, at the very least the reported ones are.

So just in case, am I missing something, or is there anything else I can do to prevent this from happening other than literally creating my own market code and overriding every single case in the game where a player can acquire a ship, weapon, hullmod, or blueprint? If that is even possible?

I errr, would rather not do that.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2021, 02:10:02 PM
It might help if you explained what your actual goal is :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2021, 02:13:52 PM
It might help if you explained what your actual goal is :)

Prevent access to any ships, weapons, blueprints, or hullmods that have their own TC versions - without locking out those versions by locking down the spreadsheet. (Such as using the replace array to replace ship_data.csv for instance - or replacing the hull directly in the replace array. The goal is to only replace the variants for now, and have those link to the TC ids.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2021, 02:20:45 PM
Hmm. You might consider adding the "restricted" tag. But it's kind of hard to say; you might want to have a look through BaseSubmarketPlugin.addShips() to see how it works and see what you might not be accounting for as far as its behavior.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2021, 02:45:03 PM
Hmm. You might consider adding the "restricted" tag. But it's kind of hard to say; you might want to have a look through BaseSubmarketPlugin.addShips() to see how it works and see what you might not be accounting for as far as its behavior.

Yeah I was thinking that as well, but looking at the plugin - it is generating a dummy fleet based upon faction doctrine - which presumably follows that if the faction doesn't know the ship, it wouldn't be included in the faction doctrine. However, it is doing this by variant id in some places rather than hull id. So possibly I'm missing a variant override so its being included in the doctrine that way?

Even still, however, once the dummy fleet is created the plugin iterates through each fleet member and checks for:

if (member.getHullSpec().hasTag(Tags.NO_SELL)) continue;

 - so it shouldn't be used if it has that tag. Which all of them should.

At this point I'm a little at a loss as to what could be going on. I'll have to check each submarket plugin too in case there are defaults there, or something.

Unless... hmm since the ship was in an independent market I wonder if it was using the mercenary faction's doctrine - which defaults to independent. Even though I remove the merc tag from everything, I don't actually know if I remove "knownShips" explicitly. That might be another lead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2021, 02:59:42 PM
An independent market should be using the independent faction's ship selection, unless that's changed by a mod.

Question: when are you doing this? onSaveLoad, right? IIRC actions will re-add ships from their .faction file in readResolve(), so if you're trying to remove stuff from knownShips etc you need to do it every time onSaveLoad().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2021, 03:13:40 PM
An independent market should be using the independent faction's ship selection, unless that's changed by a mod.

Question: when are you doing this? onSaveLoad, right? IIRC actions will re-add ships from their .faction file in readResolve(), so if you're trying to remove stuff from knownShips etc you need to do it every time onSaveLoad().

Ah ok now that makes sense. I'm doing it:

    @Override
    public void onNewGame()

and:

    @Override
    public void onGameLoad(boolean newGame)

 - but I'm checking for newGame to be false AND for a custom setting which is enabled by default but could technically be disabled. Looks like I need to remove that setting entirely.

Or is there another overridden method explicitly onSaveLoad()? Not seeing one in BaseModPlugin or ModPlugin.

Anyway, that still doesn't explain to me why "no_sell" wouldn't catch and remove the fleet member from selection before adding anything to the market. But I haven't looked at all of the submarket plugins yet.

One more thing, when is:

      CreateFleetPlugin plugin = Global.getSector().getGenericPlugins().pickPlugin(CreateFleetPlugin.class, params);
      if (plugin != null) {
         return plugin.createFleet(params);
      }

 - actually used? Is it for mod purposes or are there vanilla implementations? The code is obscured so I can't be sure that this wouldn't also cause problems if there is indeed a way to bypass the "no_sell" logic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2021, 03:19:26 PM
CreatFleetPlugin is used in FleetFactoryV3.createFleet()

Or is there another overridden method explicitly onSaveLoad()? Not seeing one in BaseModPlugin or ModPlugin.

onGameLoad, my bad.

Anyway, that still doesn't explain to me why "no_sell" wouldn't catch and remove the fleet member from selection before adding anything to the market. But I haven't looked at all of the submarket plugins yet.

Hmm, doesn't it? You'd need to make sure this alteration of ship hulls happened in every application session. Otherwise - if you re-run the game and load a save where this code of yours doesn't trigger - it'd have unmodified hulls. Hulls (and all other "specs") are per-application-session, not per savefile.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2021, 03:26:12 PM
CreatFleetPlugin is used in FleetFactoryV3.createFleet()

Sorry I don't think I was being very clear, I meant what are the circumstances where a plugin would actually be returned non-null? Because if it is, all of the below fleet creation logic is unused in FleetFavtoryV3.createFleet() and it uses the obscure plugin's creation logic instead and returns that CampaignFleetAPI immediately.

Quote
Hmm, doesn't it? You'd need to make sure this alteration of ship hulls happened in every application session. Otherwise - if you re-run the game and load a save where this code of yours doesn't trigger - it'd have unmodified hulls. Hulls (and all other "specs") are per-application-session, not per savefile.

I add the tags under:

    @Override
    public void onApplicationLoad()

 - So I am assuming that handles every application session since it is every time the game starts up? Or is there a time where an application session is restarted after the original application load?

Should I also do it during every onGameLoad just to be safe?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2021, 03:29:54 PM
Sorry I don't think I was being very clear, I meant what are the circumstances where a plugin would actually be returned non-null? Because if it is, all of the below fleet creation logic is unused in FleetFavtoryV3.createFleet() and it uses the obscure plugin's creation logic instead and returns that CampaignFleetAPI immediately.

There aren't any - you can see there is no implementation of CreateFleetPlugin.

You can see what plugins are added by looking at there SectorAPI.getGenericPlugins() is called.
In particular, see: CoreLifecyclePlugin.addScriptsIfNeeded(), which is where the game registers all the plugins etc.

I add the tags under:

    @Override
    public void onApplicationLoad()

 - So I am assuming that handles every application session since it is every time the game starts up? Or is there a time where an application session is restarted after the original application load?

Ah, that should be fine then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2021, 03:39:21 PM
There aren't any - you can see there is no implementation of CreateFleetPlugin.

You can see what plugins are added by looking at there SectorAPI.getGenericPlugins() is called.
In particular, see: CoreLifecyclePlugin.addScriptsIfNeeded(), which is where the game registers all the plugins etc.

...

Ah, that should be fine then.

Oh gotcha thanks for the info. That rules that out.

Well, then I have no clue as to how this could be happening. It all seems fine on the game's end and the mod's. Since I've never actually seen this occur iirc, I'm probably going to have to reproduce this explicitly and trace it from there based upon an exact context.

Otherwise it seems like a Ghost in the Machine kind of thing. The game has a mind of its own and is just messing with me for fun lol.
  :P

*EDIT*

Wow.. just... wow I am a gigantic moron it seems...  :-[

I decided to triple check the config files, and...

I didn't check for the damaged (D) version of hulls. I added all the faction skin ids like dominator_xiv - but there is no entry for hammerhead_d... so *ahem* that's probably it. Alex, thank you for the help and I am very sorry I wasted your valuable time on my idiocy. I deserve this:

(https://media.giphy.com/media/3og0INyCmHlNylks9O/giphy.gif)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 19, 2021, 04:16:57 PM
Oh, hmm - I don't think (D) versions of hulls are explicitly flagged as being available to factions - they're just kind of used when a hull has d-mods, so that's probably not it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 19, 2021, 06:15:24 PM
Oh, hmm - I don't think (D) versions of hulls are explicitly flagged as being available to factions - they're just kind of used when a hull has d-mods, so that's probably not it.

Ah ok. Well I'll have to test more then. Thanks for letting me know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 19, 2021, 08:51:36 PM
dont feel bad im even more of a gigantic idiot because i had something useful to add but i read yalls convo and ive been drinking so i forgot because i was excited by the discourse

as an addendum im beyond impressed by the professionalism and enthusiastism between like minded individuals in this thread.

SHOUT OUT TO THE ORIGINAL PERSON THAT MADE THIS THREAD!!

what a forward thinking individual
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 19, 2021, 09:09:20 PM
Is there a way to open a specific intel item from within an interaction dialog?

CampaignUIAPI.showCoreUITab seems to do nothing inside a dialog, and VisualPanelAPI.showCore doesn't take an intel arg.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 19, 2021, 11:47:05 PM
Hmm - to alter the projectile spawns, you could do:
weapon.ensureClonedSpec()
And then manipulate:
weapon.getSpec().getHardpointFireOffsets()
weapon.getSpec().getTurretFireOffsets()
Etc.
Thanks! Just tested this out and it works! Just one issue however - this solution doesn't seem to work with beam weapons - the beam line itself disappears when moving the projectile spawns this way.... I simply changed my plans and decided to move a projectile weapon instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 20, 2021, 03:39:49 AM
How to get the button input event(trigger after press the button) in CustomDialogDelegate?
And, is there anyway to refresh the whole panel manuelly? It seems there is no "remove" function here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 20, 2021, 06:35:32 AM
Ah, hmm - doesn't look like there is, actually. Let me add:
void removeAssignment(AssignmentInfo info);
To CombatTaskManagerAPI.

That will help me out a ton! Thanks so much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 20, 2021, 10:23:10 AM
SHOUT OUT TO THE ORIGINAL PERSON THAT MADE THIS THREAD!!

what a forward thinking individual

Haha, indeed!

Is there a way to open a specific intel item from within an interaction dialog?

CampaignUIAPI.showCoreUITab seems to do nothing inside a dialog, and VisualPanelAPI.showCore doesn't take an intel arg.

I don't *think* so? Let me add this to VisualPanelAPI:
void showCore(CoreUITabId tabId, SectorEntityToken other, Object custom, CoreInteractionListener listener);

Thanks! Just tested this out and it works! Just one issue however - this solution doesn't seem to work with beam weapons - the beam line itself disappears when moving the projectile spawns this way.... I simply changed my plans and decided to move a projectile weapon instead.

I'm pretty sure others have done this with beam weapons, hmm.

How to get the button input event(trigger after press the button) in CustomDialogDelegate?

I don't think you can - either customDialogConfirm() or customDialogCancel() gets called but the event isn't passed along.

And, is there anyway to refresh the whole panel manuelly? It seems there is no "remove" function here.

Oh, hmm. I don't think there is, actually, that's... a bit of an oversight. Let me add this to UIPanelAPI:
void removeComponent(UIComponentAPI component);

That will help me out a ton! Thanks so much!

*thumbs up*
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 20, 2021, 06:35:23 PM
I HATE to be that guy, however, it would be REALLY cool to have an "autopilot" that will fly you through hyperspace (by using the script the ai uses or something) where your fleet will auto slow through storms n such and possibly even seek out "high value" targets (configurably of course)

just a wish list sort of thing that hopefully will make it into the final release!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 20, 2021, 09:13:36 PM
Heya, I found another issue with getTurretFireOffsets() - at least in simulator mode, when ending a battle and then consecutively starting a new one, the offsetted values of the launch points are "saved" somehow, and the next time these are called:
                   gun.ensureClonedSpec();
                   gun.getSpec().getTurretFireOffsets().get(0);
...the original values start from the previously offsetted point - and the offset code will activate again from here placing it way off.

Is there a way to sort of refresh these values to the original?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 20, 2021, 09:20:25 PM
I HATE to be that guy, however, it would be REALLY cool to have an "autopilot" that will fly you through hyperspace (by using the script the ai uses or something) where your fleet will auto slow through storms n such and possibly even seek out "high value" targets (configurably of course)

just a wish list sort of thing that hopefully will make it into the final release!

Ahh, this isn't the right thread for general suggestions.

Heya, I found another issue with getTurretFireOffsets() - at least in simulator mode, when ending a battle and then consecutively starting a new one, the offsetted values of the launch points are "saved" somehow, and the next time these are called:
                   gun.ensureClonedSpec();
                   gun.getSpec().getTurretFireOffsets().get(0);
...the original values start from the previously offsetted point - and the offset code will activate again from here placing it way off.

Is there a way to sort of refresh these values to the original?

The elements in the arraylist returned by getTurretFireOffsets() are the same Vector2fs, only the list itself is cloned by ensureClonedSpec(). If you clear out the list and re-populate it with a copy of the vectors it should avoid this issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 20, 2021, 09:50:55 PM
Any idea why I'd be running into this on a new game start?

I can view the FleetFactoryV3 methods, but there is nothing about what that refresh method does in MutableCharacterStatsAPI or why it would generate a nullpointer. Maaybe I have an outdated and no longer used skill listed in the faction file for that faction?? I'll check for that.

*EDIT*
Yup sure enough, I had fighter_doctrine instead of fighter_uplink. Hopefully that prevents it from reoccurring. (And now I need to go over all my factions files' skill sections and double check them all for that.)

Code
1233638 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager  - Creating trade fleet of tier 6.0 for market [Lilith]
1233758 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.CharacterStats.refreshCharacterStatsEffects(Unknown Source)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderSkills(FleetFactoryV3.java:1276)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficersV2(FleetFactoryV3.java:1147)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficers(FleetFactoryV3.java:852)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.createFleet(FleetFactoryV3.java:411)
at com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager.createTradeRouteFleet(EconomyFleetRouteManager.java:627)
at com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager.spawnFleet(EconomyFleetRouteManager.java:487)
at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:619)
at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:128)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 20, 2021, 09:56:36 PM
Is there a way for a fighter's hullmod to interact with its "owner carrier."

I'm looking everywhere in the ShipAPI and I can see that if I have FighterLaunchBayAPI, then I can access the owner carrier but I'm having a hard time using a fighter to access the FighterLaunchBayAPI itself... I want to make it possible that for every Wing with this hullmod is on a carrier, it decreases the max armor of the carrier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 21, 2021, 09:23:24 AM
Is there a way for a fighter's hullmod to interact with its "owner carrier."

I'm looking everywhere in the ShipAPI and I can see that if I have FighterLaunchBayAPI, then I can access the owner carrier but I'm having a hard time using a fighter to access the FighterLaunchBayAPI itself... I want to make it possible that for every Wing with this hullmod is on a carrier, it decreases the max armor of the carrier.

Something like fighter.getWing().getSourceShip();

But checking for nulls at every point (i.e. fighter.getWing() != null etc)

If this is the info you're looking for?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 21, 2021, 02:29:33 PM
Is there a way for a fighter's hullmod to interact with its "owner carrier."

I'm looking everywhere in the ShipAPI and I can see that if I have FighterLaunchBayAPI, then I can access the owner carrier but I'm having a hard time using a fighter to access the FighterLaunchBayAPI itself... I want to make it possible that for every Wing with this hullmod is on a carrier, it decreases the max armor of the carrier.

Something like fighter.getWing().getSourceShip();

But checking for nulls at every point (i.e. fighter.getWing() != null etc)

If this is the info you're looking for?
I'm not sure then if I'm implementing it properly then since the fighter's hullmod doesn't seem to "add the hullmod" to its parent carrier when installed into a lanuch bay here is the code in question.
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;

public class free_carrier_forge extends BaseHullMod {
    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, java.lang.String id) {
        if (ship.getWing() != null && ship.getWing().getSourceShip() != null) ship.getWing().getSourceShip().getVariant().addMod("missile_reload");
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 21, 2021, 02:55:49 PM
The elements in the arraylist returned by getTurretFireOffsets() are the same Vector2fs, only the list itself is cloned by ensureClonedSpec(). If you clear out the list and re-populate it with a copy of the vectors it should avoid this issue.
Hmm... how should this be done? Like this?

Code
gun.ensureClonedSpec();
dglaunch = gun.getSpec().getTurretFireOffsets().get(0);

//Manitpulating dglaunch to move fire offsets
dglaunch.set(dglaunchX + (smoothedAnimLast*offsetFY), dglaunchY - (smoothedAnimFirst*offsetFX));

gun.getSpec().getTurretFireOffsets().clear();
gun.getSpec().getTurretFireOffsets().add(new Vector2f());

Also, one more thing - I found that when there are multiple units of the same one that has this offset code, it seems they all share the same offset - so if one activates the code, the offset of other units will adjust...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 21, 2021, 03:26:45 PM
Helping out another modder who is inexperienced, and I almost have the mod working, but I'm not compiling a jar in case that is relevant to this issue. Running into:

Caused by: java.lang.ClassNotFoundException: File 'data/scripts/skills/FieldRepairsNerfScript.java', Line 85, Column 11: Assignment conversion not possible from type "java.lang.Object" to type "com.fs.starfarer.api.fleet.FleetMemberAPI"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more

It seems like I am declaring a type though so where is it getting the idea that I'm trying to convert an object? This is pasted directly from the Field Repairs script, so I have a hunch that its a janino issue or something. Or am I missing something obvious? (Wouldn't be the first time.)

"picked = picker.pick();" is line 85 for refence.

*FIXED* Hmm, ok so apparently the class loader doesn't like it if you declare a type when initializing a new WeightedRandomPicker.

So: WeightedRandomPicker<FleetMemberAPI> picker = new WeightedRandomPicker<FleetMemberAPI>();

Should change to: WeightedRandomPicker<FleetMemberAPI> picker = new WeightedRandomPicker<>();


Nvm the compiler doesn't like that either. I guess it's not possible to use a WeightedRandomPicker without using a jar?? The reason this is important is because the user wants to play around with one of the static values for testing, and that won't be possible if the script is in a jar. They don't really know how to code and won't want to set up an IDE.

*EDIT* Ah screw it I compiled a jar and made the code read the value from settings so it is easily changed. Simple enough. Works now.

From:
Spoiler
Code
import com.fs.starfarer.api.fleet.FleetMemberAPI;

Code
	protected FleetMemberAPI picked = null;

Code
		CampaignFleetAPI fleet = Global.getSector().getPlayerFleet();
WeightedRandomPicker<FleetMemberAPI> picker = new WeightedRandomPicker<FleetMemberAPI>();
for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
if (member.getVariant().isStockVariant()) continue;
int dmods = DModManager.getNumNonBuiltInDMods(member.getVariant());
if (dmods > 0) {
picker.add(member, 1);
}
}
picked = picker.pick();
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 21, 2021, 05:53:14 PM
Last version I was able to ensure my retrofit bar event was at the top of the bar list, but now there is no way to do that without breaking random events. Can we please get a way to add priority bar events?

Events added in the AddBarEvents trigger show up first, I believe. Not exactly what you're asking for, but might be good enough.

Seems like this does what I want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 21, 2021, 06:26:39 PM
I HATE to be that guy, however, it would be REALLY cool to have an "autopilot" that will fly you through hyperspace (by using the script the ai uses or something) where your fleet will auto slow through storms n such and possibly even seek out "high value" targets (configurably of course)

just a wish list sort of thing that hopefully will make it into the final release!

Ahh, this isn't the right thread for general suggestions.



youre right i forgot about that my bad
Heya, I found another issue with getTurretFireOffsets() - at least in simulator mode, when ending a battle and then consecutively starting a new one, the offsetted values of the launch points are "saved" somehow, and the next time these are called:
                   gun.ensureClonedSpec();
                   gun.getSpec().getTurretFireOffsets().get(0);
...the original values start from the previously offsetted point - and the offset code will activate again from here placing it way off.

Is there a way to sort of refresh these values to the original?

The elements in the arraylist returned by getTurretFireOffsets() are the same Vector2fs, only the list itself is cloned by ensureClonedSpec(). If you clear out the list and re-populate it with a copy of the vectors it should avoid this issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on July 21, 2021, 10:27:50 PM
Hello!

How can I adjust the xp gain from battles? I'm getting a way too high xp bonus because the game thinks a battle is hard for my fleet but in reality it is a piece of cake.
Like 260% xp bonus for a battle no ship of mine got a scratch and I used mediocre stock variants.
Does it have anything to do with the civilian hint and/or hullmod? Because that's on all those ships.
I've tried upping fleet points in ship_data.csv but that did nothing.

Can I somehow fix that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 22, 2021, 01:23:31 AM
Does damageAPI.getDamage() return the base damage including any modifiers?
I'm using this to kill some ships with fighter hullsize in an attempt to get around the 50% chance of them poofing out of existence and not being disabled, and while it seems to work most of the time, there have been instances where it doesn't  seem to  trigger, and I can't figure it out for the life of me.
Quote
public String modifyDamageTaken(Object param,CombatEntityAPI target, DamageAPI damage, Vector2f point, boolean shieldHit)
      {
         
         if(!(target instanceof ShipAPI))
            return null;
         
         if(shieldHit)
            return null;
         
         if(damage.getDamage() > target.getHitpoints())
         {
            ShipAPI sc = (ShipAPI) target;
            sc.setHullSize(HullSize.FRIGATE);
            sc.setHitpoints(0f);
            
         }
            String id = "strikecraft_death";
            return id;
      }

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on July 22, 2021, 02:04:58 PM
Does damageAPI.getDamage() return the base damage including any modifiers?
I'm using this to kill some ships with fighter hullsize in an attempt to get around the 50% chance of them poofing out of existence and not being disabled, and while it seems to work most of the time, there have been instances where it doesn't  seem to  trigger, and I can't figure it out for the life of me.
Quote
public String modifyDamageTaken(Object param,CombatEntityAPI target, DamageAPI damage, Vector2f point, boolean shieldHit)
      {
         
         if(!(target instanceof ShipAPI))
            return null;
         
         if(shieldHit)
            return null;
         
         if(damage.getDamage() > target.getHitpoints())
         {
            ShipAPI sc = (ShipAPI) target;
            sc.setHullSize(HullSize.FRIGATE);
            sc.setHitpoints(0f);
            
         }
            String id = "strikecraft_death";
            return id;
      }


But you specified frigate instead of fighter?
There is also no guarantee that fighters poof on death.
Your best bet is actually phase the thing at death I think. Make the sprite transparent would work as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 22, 2021, 02:29:17 PM
They're frigates with fighter hullsize. Changing the hullsize to frigate is so they are disabled normally.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on July 22, 2021, 02:38:16 PM
They're frigates with fighter hullsize. Changing the hullsize to frigate is so they are disabled normally.
Anyways, you can refer to recall device script to learn how to poof a shipAPI from existing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on July 22, 2021, 10:35:27 PM
When do WeaponRangeModifier listeners (applied through a applyEffectsAfterShipCreation call) get evaluated, relative to other hullmods and skill effects?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 23, 2021, 11:54:18 AM
*EDIT* Ah screw it I compiled a jar and made the code read the value from settings so it is easily changed. Simple enough. Works now.

Probably needed a cast, like:
picked = (FleetMemberAPI) picker.pick();

But yeah JANINO can get weird where generics are involved.

Hello!

How can I adjust the xp gain from battles? I'm getting a way too high xp bonus because the game thinks a battle is hard for my fleet but in reality it is a piece of cake.
Like 260% xp bonus for a battle no ship of mine got a scratch and I used mediocre stock variants.
Does it have anything to do with the civilian hint and/or hullmod? Because that's on all those ships.
I've tried upping fleet points in ship_data.csv but that did nothing.

Can I somehow fix that?

The civilian ships might have something to do with it. You can change the max multiplier by setting
FleetEncounterContext.MAX_XP_MULT
To a smaller value in your mod's ModPlugin, probably in the onApplicationLoad() method.




Does damageAPI.getDamage() return the base damage including any modifiers?
I'm using this to kill some ships with fighter hullsize in an attempt to get around the 50% chance of them poofing out of existence and not being disabled, and while it seems to work most of the time, there have been instances where it doesn't  seem to  trigger, and I can't figure it out for the life of me.

         if(damage.getDamage() > target.getHitpoints())

Hmm - this seems fundamentally wrong since it doesn't account for armor reduction to damage.

You probably want to look at DamageListener, maybe?

When do WeaponRangeModifier listeners (applied through a applyEffectsAfterShipCreation call) get evaluated, relative to other hullmods and skill effects?

They're dynamic, so they get called every time a weapon on that ship fires.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 23, 2021, 01:56:26 PM
The elements in the arraylist returned by getTurretFireOffsets() are the same Vector2fs, only the list itself is cloned by ensureClonedSpec(). If you clear out the list and re-populate it with a copy of the vectors it should avoid this issue.
Hmm... how should this be done? Like this?

Code
gun.ensureClonedSpec();
dglaunch = gun.getSpec().getTurretFireOffsets().get(0);

//Manitpulating dglaunch to move fire offsets
dglaunch.set(dglaunchX + (smoothedAnimLast*offsetFY), dglaunchY - (smoothedAnimFirst*offsetFX));

gun.getSpec().getTurretFireOffsets().clear();
gun.getSpec().getTurretFireOffsets().add(new Vector2f());

Also, one more thing - I found that when there are multiple units of the same one that has this offset code, it seems they all share the same offset - so if one activates the code, the offset of other units will adjust...
Hi Alex, can you take a look at this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 23, 2021, 02:21:56 PM
The elements in the arraylist returned by getTurretFireOffsets() are the same Vector2fs, only the list itself is cloned by ensureClonedSpec(). If you clear out the list and re-populate it with a copy of the vectors it should avoid this issue.
Hmm... how should this be done? Like this?

Code
gun.ensureClonedSpec();
dglaunch = gun.getSpec().getTurretFireOffsets().get(0);

//Manitpulating dglaunch to move fire offsets
dglaunch.set(dglaunchX + (smoothedAnimLast*offsetFY), dglaunchY - (smoothedAnimFirst*offsetFX));

gun.getSpec().getTurretFireOffsets().clear();
gun.getSpec().getTurretFireOffsets().add(new Vector2f());

Also, one more thing - I found that when there are multiple units of the same one that has this offset code, it seems they all share the same offset - so if one activates the code, the offset of other units will adjust...
Hi Alex, can you take a look at this?

Ah - you're doing things in the wrong order. First you're modifying one of the Vector2f offsets (the one returned by .get(0) ), and then you're clearing out the array and adding a new vector to it. That doesn't make sense - you'll end up changing the shared offset, and then also setting the offset for the current weapon to a new Vector2f (so, 0,0).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 24, 2021, 05:36:49 AM
Ah - you're doing things in the wrong order. First you're modifying one of the Vector2f offsets (the one returned by .get(0) ), and then you're clearing out the array and adding a new vector to it. That doesn't make sense - you'll end up changing the shared offset, and then also setting the offset for the current weapon to a new Vector2f (so, 0,0).
Thanks a lot Alex! That did the trick for both issues!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 24, 2021, 08:45:22 AM
Glad to hear it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 24, 2021, 06:11:13 PM
edit: nvm  :-X
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 25, 2021, 12:41:03 AM
How are the arrows in the intel screen's map drawn?

I'm doing a custom UI panel and trying to draw arrows between two points. GL11.GL_LINES without anti-aliasing looks awful, and I'd prefer not to work out the trig needed to draw the arrowhead as a triangle :-X
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on July 25, 2021, 09:53:01 AM
Hello
Line of hullmod code
Code
List<String> wings = variant.getWings();
appears to be causing error:
Spoiler
Quote
21163 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.mm_droppod_Bonus]
java.lang.RuntimeException: Error loading [data.hullmods.mm_droppod_Bonus]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/mm_droppod_Bonus.java', Line 23, Column 15: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/mm_droppod_Bonus.java', Line 23, Column 15: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"
   at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
   at org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:9071)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1845)
   at org.codehaus.janino.UnitCompiler.access$2000(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitLocalVariableDeclarationStatement(UnitCompiler.java:945)
   at org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:2508)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:993)
   at org.codehaus.janino.UnitCompiler.access$1000(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitBlock(UnitCompiler.java:935)
   at org.codehaus.janino.Java$Block.accept(Java.java:2012)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1088)
   at org.codehaus.janino.UnitCompiler.access$1300(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitForStatement(UnitCompiler.java:938)
   at org.codehaus.janino.Java$ForStatement.accept(Java.java:2196)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
   at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
   at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
   at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
   ... 5 more
[close]

I dont even know what to ask beside "what do?"

thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 25, 2021, 11:18:18 AM
How are the arrows in the intel screen's map drawn?

I'm doing a custom UI panel and trying to draw arrows between two points. GL11.GL_LINES without anti-aliasing looks awful, and I'd prefer not to work out the trig needed to draw the arrowhead as a triangle :-X

Oh, funny - was just doing something with these arrows myself. It's... doing the trig! Using two "GL_TRIANGLE_FAN" - one for the body, one for the arrowhead. I've found that to be a pretty easy way to get a reasonable-looking "vagely-line-like-thing that starts out wider and gets narrower", especially with how that gets a texture mapped to it.

Let me just paste some code - you'd have to adapt it a bit to use API things. It's rendering each fan three times with slight offsets to get some, uh, budget anti-aliasing. Same reason for using the line32x32 texture.
Spoiler
Code
	private Texture texture = TextureStore.getTexture("graphics/hud/line32x32.png");
private void renderArrow(Vector2f from, Vector2f to, float startWidth, Color color, float maxAlpha) {
float dist = Utils.getDistance(from, to);
Vector2f dir = Vector2f.sub(from, to, new Vector2f());
if (dir.x != 0 || dir.y != 0) {
dir.normalise();
} else {
return;
}
float arrowHeadLength = Math.min(startWidth * 0.4f * 3f, dist * 0.5f);
dir.scale(arrowHeadLength);
Vector2f arrowEnd = Vector2f.add(to, dir, new Vector2f());

// main body of the arrow
renderFan(from.x, from.y, arrowEnd.x, arrowEnd.y, startWidth, startWidth * 0.4f, color,
//0f, maxAlpha * 0.5f, maxAlpha);
maxAlpha * 0.2f, maxAlpha * 0.67f, maxAlpha);
// arrowhead, tapers to a width of 0
renderFan(arrowEnd.x, arrowEnd.y, to.x, to.y, startWidth * 0.4f * 3f, 0f, color,
maxAlpha, maxAlpha, maxAlpha);
}


private void renderFan(float x1, float y1, float x2, float y2, float startWidth, float endWidth, Color color, float edge1, float mid, float edge2) {
//HudRenderUtils.renderFan(texture, x1, y1, x2, y2, startWidth, endWidth, color, edge1, mid, edge2, false);
edge1 *= 0.4f;
edge2 *= 0.4f;
mid *= 0.4f;
boolean additive = true;
//additive = false;
renderFan(texture, x1, y1, x2, y2, startWidth, endWidth, color, edge1, mid, edge2, additive);
renderFan(texture, x1 + 0.5f, y1 + 0.5f, x2 + 0.5f, y2 + 0.5f, startWidth, endWidth, color, edge1, mid, edge2, additive);
renderFan(texture, x1 - 0.5f, y1 - 0.5f, x2 - 0.5f, y2 - 0.5f, startWidth, endWidth, color, edge1, mid, edge2, additive);
}

public static void renderFan(Texture texture, float x1, float y1, float x2, float y2,
float startWidth, float endWidth, Color color,
float edge1, float mid, float edge2, boolean additive) {

GL11.glPushMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);

texture.bind();

GL11.glEnable(GL11.GL_BLEND);
if (additive) {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
} else {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}

Vector2f v1 = new Vector2f(x2 - x1, y2 - y1);
Utils.normalise(v1);
v1.set(v1.y, -v1.x);
Vector2f v2 = new Vector2f(v1);
v1.scale(startWidth * 0.5f);
v2.scale(endWidth * 0.5f);

GL11.glBegin(GL11.GL_TRIANGLE_FAN);
{
// center
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * mid));
GL11.glTexCoord2f(0.5f, 0.5f);
GL11.glVertex2f((x2 + x1) * 0.5f, (y2 + y1) * 0.5f);

// start
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * edge1));
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(x1 - v1.x, y1 - v1.y);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(x1 + v1.x, y1 + v1.y);

// end
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * edge2));
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(x2 + v2.x, y2 + v2.y);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(x2 - v2.x, y2 - v2.y);

// wrap back around to start
GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)((float)color.getAlpha() * edge1));
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(x1 - v1.x, y1 - v1.y);
}
GL11.glEnd();
GL11.glPopMatrix();
}
[close]

Hello
Line of hullmod code
Code
List<String> wings = variant.getWings();
appears to be causing error:
Quote
21163 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.mm_droppod_Bonus]
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/mm_droppod_Bonus.java', Line 23, Column 15: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"
I dont even know what to ask beside "what do?"

thanks

I think the easiest way to fix this would be to not use generics. So, just:
List wings = variant.getWings()
And then cast to String whenever you're using members of this list.

The long-term better way to go would be to set up an IDE and compile your stuff into jars so that you don't have to bother about exactly what Janino (the 3rd party compiler the game uses for loose scripts) supports or not, and what makes it bug out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on July 27, 2021, 12:53:19 AM
Is there any way to change the number of fighters in a squadron aside from the instant change that Reserve Deployment does? And preferably have it show up in the UI. I feel like I've seen it before, but I'm not sure where.

Figured the extra fighters part out- gotta do it every frame, not just once. Is there any way to get extra fighters to show up in the UI? (Also I'm not a total balance psychopath, it's a builtin hullmod and hopefully balanced for the effect.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2021, 11:57:10 AM
The number of fighters is capped to 6 for display purposes, if that's what you're asking; there's no way to override that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on July 27, 2021, 03:03:03 PM
What I meant was- the extra fighters deployed by the bay.extraDeployments() and associated methods- can those be made to show up on the UI, as long as I keep it at a max of 6 per squadron? Or are they temporary only?

On a different note, what's the difference between modifyPercentAlways() and modifyPercent()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2021, 03:11:49 PM
What I meant was- the extra fighters deployed by the bay.extraDeployments() and associated methods- can those be made to show up on the UI, as long as I keep it at a max of 6 per squadron? Or are they temporary only?

Ah - I don't think so, no.

On a different note, what's the difference between modifyPercentAlways() and modifyPercent()?

modifyPercent() won't apply a modifier if the value is 0. But sometimes it's useful to apply the modifier anyway - such as when there's also a description, and you're showing the description somewhere and want to indicate that <whatever> could be a factor even if it isn't just then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 29, 2021, 12:11:30 PM
Is there a rules.csv variable from the tutorial that I can use to detect if players did the tutorial or not?

Because I know there's a skip tutorial I'm not sure if those variables are picked up to be true automatically if the player skipped the tutorial since I don't want to make dialogue assume they saved Ancrya.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 29, 2021, 12:57:11 PM
Is there a rules.csv variable from the tutorial that I can use to detect if players did the tutorial or not?

Because I know there's a skip tutorial I'm not sure if those variables are picked up to be true automatically if the player skipped the tutorial since I don't want to make dialogue assume they saved Ancrya.

Code
return memory.getBoolean("$ngcSkipTutorial");

Put that in a rule command script under execute and call that script as a condition for whatever rules you are creating. That variable should stay in memory indefinitely iirc.

Alternatively I think you can have $ngcSkipTutorial as a condition, but I'm not sure if its under LOCAL or PLAYER in memory or if it will work just like that. It might take some trial and error.

*EDIT* code typo fixed  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PureTilt on July 30, 2021, 04:56:18 AM
(WeaponAPI).getAmmoPerSecond() and (WeaponAPI).getAmmoTracker().getAmmoPerSecond() both return base ammo regeneration. Is that a bug or there no real way to know when something modified ammo regeneration?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on July 30, 2021, 06:06:24 AM
(WeaponAPI).getAmmoPerSecond() and (WeaponAPI).getAmmoTracker().getAmmoPerSecond() both return base ammo regeneration. Is that a bug or there no real way to know when something modified ammo regeneration?
I thought that’s done by getting the tracker then manually add ammo using get and set in the advance() method? I don’t recall there’s a mutable stat to modify that.

——————

Is there a way to prevent a faction from giving survey missions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on July 30, 2021, 06:53:27 AM
What determines what colour shield a ship has?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 30, 2021, 08:07:43 AM
What determines what colour shield a ship has?
"style": "MIDLINE" in a .ship file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2021, 08:45:11 AM
(WeaponAPI).getAmmoPerSecond() and (WeaponAPI).getAmmoTracker().getAmmoPerSecond() both return base ammo regeneration. Is that a bug or there no real way to know when something modified ammo regeneration?
I thought that’s done by getting the tracker then manually add ammo using get and set in the advance() method? I don’t recall there’s a mutable stat to modify that.

Right! There will be in the next release, incidentally.

Is there a way to prevent a faction from giving survey missions?

Hmm, looking at SurveyPlanetMissionIntel, I don't think so.

Is there a rules.csv variable from the tutorial that I can use to detect if players did the tutorial or not?

Because I know there's a skip tutorial I'm not sure if those variables are picked up to be true automatically if the player skipped the tutorial since I don't want to make dialogue assume they saved Ancrya.

Code
return memory.getBoolean("$ngcSkipTutorial");

Put that in a rule command script under execute and call that script as a condition for whatever rules you are creating. That variable should stay in memory indefinitely iirc.

Alternatively I think you can have $ngcSkipTutorial as a condition, but I'm not sure if its under LOCAL or PLAYER in memory or if it will work just like that. It might take some trial and error.

*EDIT* code typo fixed  :P

Worth nothing, perhaps: the game assumes that the events in the tutorial happened, regardless of whether you did it this time around or not. You get extra rep with the Hegemony, can talk to the lieutenant at the bar at Coatl as if you met him during the events of the tutorial, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 30, 2021, 12:28:34 PM
Hmmm...

is there a good method in rules.csv to store variables inside the person interacted with? I don't want to use global variables.. unless that seems to be the only way?

For example, I interacted with Person A and I want to set a variable within Person A's memory that Player cannot talk to Person A until another time being. However when I talk to Person B, they seem to inherit Person A's memory, so I'm assuming $entity.DONOTINTERACT is not the right way to do it.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 30, 2021, 12:38:41 PM
When you're inside the conversation, just doing:
$variable = whatever
Will store it in the person's memory.

$entity.variable will store it in the memory of the entity you're interacting with. In the case of a typical market, this'll be the planet or station - which, of note, will depend on what the player clicked on to interact with it. So usually you'd use $market.variable if you wanted that sort of thing. But, right, you're looking for just $variable, I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 30, 2021, 12:42:33 PM
When you're inside the conversation, just doing:
$variable = whatever
Will store it in the person's memory.

$entity.variable will store it in the memory of the entity you're interacting with. In the case of a typical market, this'll be the planet or station - which, of note, will depend on what the player clicked on to interact with it. So usually you'd use $market.variable if you wanted that sort of thing. But, right, you're looking for just $variable, I think.
Oh wow that was easier than I thought, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 30, 2021, 12:51:54 PM
Hmmm...

is there a good method in rules.csv to store variables inside the person interacted with? I don't want to use global variables.. unless that seems to be the only way?

For example, I interacted with Person A and I want to set a variable within Person A's memory that Player cannot talk to Person A until another time being. However when I talk to Person B, they seem to inherit Person A's memory, so I'm assuming $entity.DONOTINTERACT is not the right way to do it.  ;D

Well, Alex ninjaed with an easier solution in this case (also didn't know that so good to know), but since I used this in the past to store unique information globally for various things I'll go ahead and post it.  ;D

What you might try doing is a bit of a hacky workaround:

The person has a unique name (presumably), so add the unique name to the variable in the entity (I still wouldn't do global unless there isn't a way around it.) Then, in the rule command script that is part of your condition, have a control part of the variable to check for, and then cross-reference that with the name of the PersonAPI the player is talking to to determine whether the condition is true or false.

Example:

PersonAPI name: Third Oberon

variable A: $entity.DONOTINTERACT - set it to true, then add

variable B: $entity.DONOTINTERACT_THIRDOBERON = true

Script:

Code
if (memory.getBoolean("$entity.DONOTINTERACT");) {
     String memKey = "$entity.DONOTINTERACT" + "_" + PersonAPI.getName().getFirstName().toUpperCase() + PersonAPI.getName().getLastName().toUpperCase();
     return memory.getBoolean(memKey);
} else {
     return false;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 30, 2021, 01:43:49 PM
Hmmm...

is there a good method in rules.csv to store variables inside the person interacted with? I don't want to use global variables.. unless that seems to be the only way?

For example, I interacted with Person A and I want to set a variable within Person A's memory that Player cannot talk to Person A until another time being. However when I talk to Person B, they seem to inherit Person A's memory, so I'm assuming $entity.DONOTINTERACT is not the right way to do it.  ;D

Well, Alex ninjaed with an easier solution in this case (also didn't know that so good to know), but since I used this in the past to store unique information globally for various things I'll go ahead and post it.  ;D

What you might try doing is a bit of a hacky workaround:

The person has a unique name (presumably), so add the unique name to the variable in the entity (I still wouldn't do global unless there isn't a way around it.) Then, in the rule command script that is part of your condition, have a control part of the variable to check for, and then cross-reference that with the name of the PersonAPI the player is talking to to determine whether the condition is true or false.

Example:

PersonAPI name: Third Oberon

variable A: $entity.DONOTINTERACT - set it to true, then add

variable B: $entity.DONOTINTERACT_THIRDOBERON = true

Script:

Code
if (memory.getBoolean("$entity.DONOTINTERACT");) {
     String memKey = "$entity.DONOTINTERACT" + "_" + PersonAPI.getName().getFirstName().toUpperCase() + PersonAPI.getName().getLastName().toUpperCase();
     return memory.getBoolean(memKey);
} else {
     return false;
}
Oh yeah, that code is definitely really useful when I think I need to have uhh "clones" of a certain person A around as an officer, administrator, and other various things...  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 30, 2021, 02:21:22 PM
Oh yeah, that code is definitely really useful when I think I need to have uhh "clones" of a certain person A around as an officer, administrator, and other various things...  ;)

Right I used it to store officer data globally. That way, even if the reference to the PersonAPI was destroyed for some reason, you could just build it back using the stored information - including skills. So even if the officer "left the fleet" for any reason, and you wanted to have them reappear in a story encounter, you could do so fairly easily.

It's really essentially to ensure that story characters are always available at any given encounter - though this was back in 0.8 so none of the new story framework was available so it might not even be necessary now or could be done more easily. Still, its nice to know its available.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 30, 2021, 06:08:34 PM
What determines... planet class? And can I do anything about it by setting it code-wise? I have this procgen planet with a size 1 but yet... very decent hazard rating and conditions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on July 31, 2021, 08:04:27 AM
Is there any way to show custom confirm dialog without using interaction dialog in the campaign layer?
What I know is:
boolean showConfirmDialog(String message, String ok, String cancel, float width, float height, Script onOk, Script onCancel);
It's not customizable, so will it be some customized functions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2021, 12:58:16 PM
What determines... planet class? And can I do anything about it by setting it code-wise? I have this procgen planet with a size 1 but yet... very decent hazard rating and conditions.

Hmm? I'm not sure I understand the question. "size 1"?

Is there any way to show custom confirm dialog without using interaction dialog in the campaign layer?
What I know is:
boolean showConfirmDialog(String message, String ok, String cancel, float width, float height, Script onOk, Script onCancel);
It's not customizable, so will it be some customized functions?

There isn't anything like this at the moment, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 31, 2021, 02:35:54 PM

Hmm? I'm not sure I understand the question. "size 1"?

There isn't anything like this at the moment, no.
I meant class 1-5, brainfart
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2021, 02:37:26 PM
I meant class 1-5, brainfart

Ahhh! Makes sense now.

See: SurveyPluginImpl.getSurveyDataType()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 31, 2021, 03:26:19 PM
I meant class 1-5, brainfart

Ahhh! Makes sense now.

See: SurveyPluginImpl.getSurveyDataType()

Hmm that returns a string, is there no method like SurveyPluginImpl.setSurveyDataType()?
(https://i.imgur.com/JXmh7nN.png)
Because this planet class of I on Chitagupta just annoys me a slight bit, because I prefer for it to be class II.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2021, 03:30:04 PM
You'd have to provide your own version of SurveyPluginImpl if you want to change its behavior; probably a bit of overkill for this. What I was saying is have a look at the method; you can then see what it's considering for the planet "class".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 31, 2021, 03:31:38 PM
You'd have to provide your own version of SurveyPluginImpl if you want to change its behavior; probably a bit of overkill for this. What I was saying is have a look at the method; you can then see what it's considering for the planet "class".
Ohh, okay thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on July 31, 2021, 11:32:11 PM
I've been testing out things a fair amount tonight, and I'm really stumped with how burst beams calculate damage in the stat card and combat:

Relevant values:

dps: 3500
burst size: 0.2
charge up: 0.05
charge down: 0.01
burst delay: 0.74 (cooldown)
beam speed: 10000

full CSV entry:
Heavy Burst PD Beam (AO),archean_heavyburst,3,0.3,3200,600,3500,,,0,500,13,8,0.5,4,ENERGY,,,0.05,0.01,0.2,0.74,,,,,10000,,,,,1,,PD,"pd13, utility12, archean_hightech_bp_tier2, rare_bp, archean_tritachyon_bp, merc",,Rare,,Burst Point Defense,10000,,,,"Deals %s shield damage. When the beam impacts a target, the spalling effect produces an explosion that deals up to %s points of %s damage to other nearby targets. Deals %s shield damage.",Soft Flux | 300 | fragmentation | Soft Flux,This weapon %s without harming them.,can fire through allied ships,,15

Stat card:
Spoiler
(https://i.imgur.com/LM5IrMY.png)
[close]

So this should deal over 700 damage per strike, correct??

It took 3 strikes to take a single member of this wing down:
Spoiler
(https://i.imgur.com/eZgm6w7.png)
[close]

The armor rating is 70 and the hull is 350.

770/2 - 70 or (770 - 70)/2 against 350...

It should have taken at most two strikes even before the extra 300 frag damage is added in and that should have made it a single strike in any scenario. It took 3. Can anyone direct me as to what I'm doing wrong here?? If I increase the burst beam damage by, say, triple, then it makes SO builds ridiculous against enemy ships especially in the player's hands. They are already very strong with the current damage as it is.

The stat card seems very misleading as to what the actual weapon performance is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on August 01, 2021, 06:33:19 AM
Is there a way to spawn beams from a coordinate like projectiles do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 01, 2021, 09:38:47 AM
@Morrokain: Hmm. One thing to keep in mind is that beams deal damage roughly every 0.1 seconds. So for burst beams the damage will never be 100% accurate, and in general it's probably a good idea to have chargeup/down values that are either 0 or at least 0.1. However, that doesn't explain the level of disparity you're seeing.

I'm not sure what's going wrong in this case. I did just confirm that the regular Heavy Burst Laser deals the damage you'd expect based on the stat card, though - 6-ish hits to take down a Broadsword. So copying all of its stats might be a good starting point. If e.g. you do that and then just up the DPS and don't see an expected increase in damage, that'd tell you something, etc. Also, that fighter has a built-in hullmod - looks like one of yours? Still. Might be better to test vs a vanilla Broadsword or some such.

(Your beam speed looks like it's 10k, which is good - otherwise, that'd probably be the problem. Beam travel time really cuts into burst beam damage if it's not ultra-high...)


Is there a way to spawn beams from a coordinate like projectiles do?

I don't believe so, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 01, 2021, 12:40:07 PM
@Morrokain: Hmm. One thing to keep in mind is that beams deal damage roughly every 0.1 seconds. So for burst beams the damage will never be 100% accurate, and in general it's probably a good idea to have chargeup/down values that are either 0 or at least 0.1. However, that doesn't explain the level of disparity you're seeing.

I'm not sure what's going wrong in this case. I did just confirm that the regular Heavy Burst Laser deals the damage you'd expect based on the stat card, though - 6-ish hits to take down a Broadsword. So copying all of its stats might be a good starting point. If e.g. you do that and then just up the DPS and don't see an expected increase in damage, that'd tell you something, etc. Also, that fighter has a built-in hullmod - looks like one of yours? Still. Might be better to test vs a vanilla Broadsword or some such.

(Your beam speed looks like it's 10k, which is good - otherwise, that'd probably be the problem. Beam travel time really cuts into burst beam damage if it's not ultra-high...)

Ugh! Well I feel really silly now. I completely forgot that a I reduce beam damage taken with the built in hullmod by 60% because all beams pierce and were too good otherwise. So, errr, mystery solved! ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 01, 2021, 12:53:09 PM
Ah, that'd do it :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Spess Mahren on August 01, 2021, 08:11:59 PM
How would you go about changing the probability of facing a autonomous defense fleet in SalvageGenFromSeed? I have a personal mod to set the strength of them to max at game start but with the change that lowered the probability of facing them if their strength is high I'm not fighting them as often as I like.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on August 01, 2021, 11:26:28 PM
is there a way to check if a personapi is a mercenary and not an officer (I.E. the ones you hire on for a year, or whatever the time period was)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 02, 2021, 09:02:55 AM
How would you go about changing the probability of facing a autonomous defense fleet in SalvageGenFromSeed? I have a personal mod to set the strength of them to max at game start but with the change that lowered the probability of facing them if their strength is high I'm not fighting them as often as I like.

You'd need to add your own implementation of SalvageDefenderModificationPlugin

to SectorAPI.getGenericPlugins()

Make sure that getHandlingPriority() returns a negative number for any defenses you don't want to modify. If you wanted to retain some of the vanilla behaviors, you could extend SalvageDefenderModificationPluginImpl.

is there a way to check if a personapi is a mercenary and not an officer (I.E. the ones you hire on for a year, or whatever the time period was)

Yep! Misc.isMercenary(person)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on August 02, 2021, 09:55:14 AM
How do I store a variant into engine mid-game instead of loading it at game launch? (Is it possible?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 02, 2021, 09:58:59 AM
How do I store a variant into engine mid-game instead of loading it at game launch? (Is it possible?)

In SettingsAPI:
   List<RoleEntryAPI> getEntriesForRole(String factionId, String role);
   void addEntryForRole(String factionId, String role, String variantId, float weight);
   void removeEntryForRole(String factionId, String role, String variantId);

Edit - and also:
   List<RoleEntryAPI> getDefaultEntriesForRole(String role);
   void addDefaultEntryForRole(String role, String variantId, float weight);
   void removeDefaultEntryForRole(String role, String variantId);

The latter if you don't want/need to do it for a specific faction but for all of them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on August 02, 2021, 10:18:53 AM
How do I store a variant into engine mid-game instead of loading it at game launch? (Is it possible?)

In SettingsAPI:
   List<RoleEntryAPI> getEntriesForRole(String factionId, String role);
   void addEntryForRole(String factionId, String role, String variantId, float weight);
   void removeEntryForRole(String factionId, String role, String variantId);

Edit - and also:
   List<RoleEntryAPI> getDefaultEntriesForRole(String role);
   void addDefaultEntryForRole(String role, String variantId, float weight);
   void removeDefaultEntryForRole(String role, String variantId);

The latter if you don't want/need to do it for a specific faction but for all of them.

Oh, I should’ve been more specific.
I mean like what player do in ship refit, they can store their current fit as a template for future autofit.
I want to generate variant procedurally and store them with dynamically created ID but follows a certain naming convention so the created variant can be identified and reused later.
For example, a wasp wing (since its really just a ship API), I want to dynamically generate a wasp but it uses lr pd laser instead of regular pd. I will create such variant on the fly and assign the ID of wasp_fighter_lrpd (or whatever weapon id). Oh, and also how do I dynamically add wing data, as each wing data ID maps to a variant and it only assigns wing ID for a ship’s fighter bay.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on August 03, 2021, 12:26:06 PM
How does one make a new bar mission available to be offered?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 03, 2021, 12:54:11 PM
How does one make a new bar mission available to be offered?

Check out bar_events.csv under data/campaign.

It has a frequency and probability column.

*EDIT*

 - Though a follow up question I would have would be how would one go about making faction-specific bar events? Would you just handle it in the mission script itself?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 03, 2021, 02:15:17 PM
- Though a follow up question I would have would be how would one go about making faction-specific bar events? Would you just handle it in the mission script itself?
Isn't that just setting a faction.id in the rules.csv finding out if the person is "from that faction" and what not?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 03, 2021, 02:30:14 PM
Isn't that just setting a faction.id in the rules.csv finding out if the person is "from that faction" and what not?

Ah yeah probably thanks. I forgot about the rules portion.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on August 03, 2021, 08:36:23 PM
In the DamageTakenModifier interface, what is the param object type when it's ramming damage?

Edit: Is there a way to get damage source ShipAPI regardless of damage type?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on August 03, 2021, 10:58:16 PM
Where are the values for required crew/supplies/machinery when establishing a colony?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 04, 2021, 10:37:28 AM
Oh, I should’ve been more specific.
I mean like what player do in ship refit, they can store their current fit as a template for future autofit.
I want to generate variant procedurally and store them with dynamically created ID but follows a certain naming convention so the created variant can be identified and reused later.
For example, a wasp wing (since its really just a ship API), I want to dynamically generate a wasp but it uses lr pd laser instead of regular pd. I will create such variant on the fly and assign the ID of wasp_fighter_lrpd (or whatever weapon id). Oh, and also how do I dynamically add wing data, as each wing data ID maps to a variant and it only assigns wing ID for a ship’s fighter bay.

Ah! I don't think this is possible, actually.


In the DamageTakenModifier interface, what is the param object type when it's ramming damage?

Edit: Is there a way to get damage source ShipAPI regardless of damage type?

I think the param will be null in that case, but that should be easy enough to check. And, I don't think so; you can only get it out of the param.

Where are the values for required crew/supplies/machinery when establishing a colony?

Looks like that's hardcoded in SurveyPluginImpl.getOutpostConsumed(). Not in static variables, unfortunately, so no easy way to change it aside from providing a custom implementation of the plugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on August 04, 2021, 10:51:26 AM
What does the mutablestats’s get entity return in the damage API?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 04, 2021, 12:39:19 PM
What triggers the Galatian Stipend when you are in the Tutorial? I can't seem to find it in rules.csv and I thought it was triggerable via it.

 I also would like to know if there's a quick way to get the # of nodes listed (such as storage fees, crew payment, administrator payment, commission bonus) all those things that you get on a monthly thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on August 05, 2021, 05:41:35 PM
I'm starting to go down a very hacky route and need to check to see if there's an easy way that I don't know about.

My goal is to show a bar event at all markets, conditional on some parameters only known after game load (after loading other files). The bar event will have an arbitrary number of options, also only known after game load.


My first approach was extending `BaseBarEventCreator` with `isPriority` true, a frequency weight of 100, and also having `isAlwaysShow()` return true in my `BarEvent`. But it still isn't showing up in all markets, maybe it only shows up in one at a time? It's also possible that I didn't wait long enough for the game to recalculate bar events for all markets...
Code: https://bitbucket.org/CodingTartiflette/magiclib/src/MagicBounties/src/data/scripts/util/bounty/

My second approach is to make a rule in `rules.csv` that triggers on `AddBarEvents`, with only the condition `$hasMarket`, and to fire a custom script that is a subclass of `AddBarEvent` where the `execute` decides whether the bar event should show up. However, next I need a way to have it fire my `BarEvent` subclass, which I guess has to happen from `FireBest`, and that's where I decided to stop and see if maybe there was a proper way to do this that doesn't involve working around vanilla code.


If it helps to visualize, it's a bounty board; so, something that all bars will have, and will always be on display as long as there are bounties to take.
Thanks, and sorry for the wall of text.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 05, 2021, 06:05:58 PM
What does the mutablestats’s get entity return in the damage API?

It should be the ship or the missile that the stats belongs to, but it may also be null. Best way to make would be to check at runtime.

What triggers the Galatian Stipend when you are in the Tutorial? I can't seem to find it in rules.csv and I thought it was triggerable via it.

 I also would like to know if there's a quick way to get the # of nodes listed (such as storage fees, crew payment, administrator payment, commission bonus) all those things that you get on a monthly thing.

For the first, you can look for all occurrences of GalatianAcademyStipend.

For the second, see: MonthlyReport, and SharedData.getCurrentReport()/getPreviousReport().

I'm starting to go down a very hacky route and need to check to see if there's an easy way that I don't know about.

My goal is to show a bar event at all markets, conditional on some parameters only known after game load (after loading other files). The bar event will have an arbitrary number of options, also only known after game load.


My first approach was extending `BaseBarEventCreator` with `isPriority` true, a frequency weight of 100, and also having `isAlwaysShow()` return true in my `BarEvent`. But it still isn't showing up in all markets, maybe it only shows up in one at a time? It's also possible that I didn't wait long enough for the game to recalculate bar events for all markets...
Code: https://bitbucket.org/CodingTartiflette/magiclib/src/MagicBounties/src/data/scripts/util/bounty/

My second approach is to make a rule in `rules.csv` that triggers on `AddBarEvents`, with only the condition `$hasMarket`, and to fire a custom script that is a subclass of `AddBarEvent` where the `execute` decides whether the bar event should show up. However, next I need a way to have it fire my `BarEvent` subclass, which I guess has to happen from `FireBest`, and that's where I decided to stop and see if maybe there was a proper way to do this that doesn't involve working around vanilla code.


If it helps to visualize, it's a bounty board; so, something that all bars will have, and will always be on display as long as there are bounties to take.
Thanks, and sorry for the wall of text.

Hmm - it seems like the way to do would be to add a custom rule command - e.g. "ShouldShowBountyBoard" or some such - and to add a call to that in the conditions column.

As far as using your BarEvent code, that sounds like a good place to use another custom command.  See: GateCMD for an example of a basic custom command that takes some parameters. MarketCMD also shows a possible approach to having some persistent data between invocations of that command; see: how it uses the TempData class.

Does that answer your questions? Happy to elaborate if needed!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on August 06, 2021, 06:16:12 PM
Does that answer your questions? Happy to elaborate if needed!

It got me there, thank you!

For anyone else who stumbles across this:

rules.csv
Code
id,trigger,conditions,script,text,options,notes
"#RULESET_NAME MagicLib (bounties)",,,,,,
magiclib_bountyboard_addevent,AddBarEvents,"ShouldShowMagicBountyBoard","AddBarEvent magiclib_bountyboard_selected ""Connect to the local unsanctioned bounty board.""  ""A subroutine from your implant informs you that this establishment is broadcasting an informal job board.""",,,
magiclib_bountyboard_selected,DialogOptionSelected,"$option == magiclib_bountyboard_selected","ShowMagicBountyBoardCmd",,,

Code
public class ShowMagicBountyBoardCmd extends BaseCommandPlugin {
    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {

        MagicBountyBarEvent event = new MagicBountyBarEvent();
        BarCMD cmd = (BarCMD) getEntityMemory(memoryMap).get("$BarCMD"); // This is pretty weird but it's how it's done in vanilla
        BarEventDialogPlugin plugin = new BarEventDialogPlugin(cmd, dialog.getPlugin(), event, memoryMap);
        dialog.setPlugin(plugin);
        plugin.init(dialog);
        return true;
    }
}


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 06, 2021, 06:28:57 PM
Nice, glad you worked it out! Dialog-plugin-substitution can get a little tricky :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on August 06, 2021, 11:00:14 PM
I'm doing some real hacky stuff with a shield that lets some damage bleed through to armor, and I've run into an issue with weapons/engines. I have to keep weapon/engine HP at a high level if it's under the shield arc, otherwise the bleedthrough damage can disable them. I can accomplish this by messing with the HP of weapons/engines under the shield arc, but sometimes a weapon or engine will get disabled and never turn back on, even if I set it to its maximum HP. How does the enable/disable logic work? And is there a way to re-enable engines, like WeaponAPI's repair() method?

Unrelated to the above, what's the normal calculation for replacement rate decay?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on August 08, 2021, 03:32:26 PM
any idea what could cause this?

(im building a 91a just because there are some mods that seem as though they will never get an update and i want to get a build together just in case)

53903 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoSuchMethodError: com.fs.starfarer.api.SettingsAPI.getScreenWidthPixels()F
java.lang.NoSuchMethodError: com.fs.starfarer.api.SettingsAPI.getScreenWidthPixels()F
   at org.dark.shaders.util.ShaderLib.init(ShaderLib.java:544)
   at data.scripts.ApproLightModPluginAlt.initShaderLib(ApproLightModPluginAlt.java:16)
   at data.scripts.ApproLightModPlugin.onApplicationLoad(ApproLightModPlugin.java:75)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 08, 2021, 05:19:01 PM
Putting this here too in case anyone has any insight. This is very strange and I don't think I've ever run into anything like it before. Things I've tried:

 - Rebuilding the module.

 - Rebuilding the project.

 - Deleting the module and dependencies and recreating them.

 - Resetting the src folder.

 - Invalidating caches and restarting the IDE.

I've added the jars as a module and global dependency in the project, but when I try and import:

Code
import org.lazywizard.lazylib.ext.combat.CombatExtensionsKt;

 - The IDE can't find it. But it will compile the jar just fine and the code works when I call:

Code
        List<ShipAPI> shipList = CombatExtensionsKt.getNearbyEnemies(ship, nearbyShipAssessmentRange);

 - Even though it shows the kit class as red like it isn't defined. And it works in game and measures nearby ships when I run the jar. However, a user just reported this:

Spoiler
just started a new game, ran into a cryosleeper and attempted to engage it. got this error message a few seconds after starting the fight. here's the log for the crash; tried updating lazylib to the newest version but that didn't fix it so i'm out of ideas

45233 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoClassDefFoundError: org/lazywizard/lazylib/ext/combat/CombatExtensionsKt
java.lang.NoClassDefFoundError: org/lazywizard/lazylib/ext/combat/CombatExtensionsKt
   at data.scripts.shipsystems.ai.AO_FluxConverterAI.assessNearbyThreats(AO_FluxConverterAI.java:166)
   at data.scripts.shipsystems.ai.AO_FluxConverterAI.advance(AO_FluxConverterAI.java:104)
   at com.fs.starfarer.loading.specs.M$1.super(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.lazywizard.lazylib.ext.combat.CombatExtensionsKt
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 12 more
[close]

They say they have v2.6. Any advice for what I am doing wrong? It worked just fine without any errors until about a month or two ago and I myself don't have any errors. Is this perhaps an operating system related thing?

Though it's weird that one day IntelliJ decided it could no longer find the imported class after finding it just fine for iirc over a year now.  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on August 08, 2021, 05:21:54 PM
noooooo i was wondering what happened to you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefinitelyNotDNA on August 08, 2021, 07:43:25 PM
I decided to give modding a try and followed a tutorial covering adding ships and weapons. Everything works except that the weapon's projectile I added doesn't deal damage, it goes through the shields and pushes against the enemy ship model until it either fades or keeps going. Where do I define what happens when a projectile hits an enemy, if I even have to?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 08, 2021, 08:18:15 PM
I decided to give modding a try and followed a tutorial covering adding ships and weapons. Everything works except that the weapon's projectile I added doesn't deal damage, it goes through the shields and pushes against the enemy ship model until it either fades or keeps going. Where do I define what happens when a projectile hits an enemy, if I even have to?

Welcome to the forums!

see:
   "specClass":"projectile",
   "spawnType":"BALLISTIC_AS_BEAM",
   "collisionClass":"RAY_FIGHTER",
   "collisionClassByFighter":"RAY_FIGHTER",

 - in the .proj file, for basic collision and projectile characteristics, but the damage type will also change things about how much damage is dealt to what defense type. That is defined in the weapon csv file under the "type" column.

Your issue sounds like you aren't defining a collisionClass or a specClass correctly though. You must define a specClass under both the weapon file and projectile file I think. I'd take a look at a vanilla example and see what you are missing. Missiles have different necessary JSON entries than projectiles or beams, for instance. I'm honestly surprised it didn't just crash outright so maybe I'm missing something obvious here though.


noooooo i was wondering what happened to you
(Yeah I'm waiting to see if I can fix this before releasing the update. It's otherwise ready I'd say, but I'd rather get all known bugs fixed first. Other feature suggestions can wait for implementation during balance testing.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DefinitelyNotDNA on August 08, 2021, 09:36:02 PM

see:
   "specClass":"projectile",
   "spawnType":"BALLISTIC_AS_BEAM",
   "collisionClass":"RAY_FIGHTER",
   "collisionClassByFighter":"RAY_FIGHTER",

 - in the .proj file, for basic collision and projectile characteristics, but the damage type will also change things about how much damage is dealt to what defense type. That is defined in the weapon csv file under the "type" column.

Your issue sounds like you aren't defining a collisionClass or a specClass correctly though. You must define a specClass under both the weapon file and projectile file I think. I'd take a look at a vanilla example and see what you are missing. Missiles have different necessary JSON entries than projectiles or beams, for instance. I'm honestly surprised it didn't just crash outright so maybe I'm missing something obvious here though.


Thanks, it works now! Turns out the problem was that I had collisionClass set to PROJECTILE when I needed RAY for an energy weapon

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on August 09, 2021, 07:24:32 AM
in the rules, I often see and have used:
Code
Call $variable updateData
Call $variable updateStage
first seems to call updateInteractionDataImpl() on the class instance in $variable
second seems to call addDescriptionForNonEndStage() on the same

is there other way to use "Call", for example to call some arbitrary method of the class instance?

In my case I wanted to make a fleet try to intercept the player in a bar mission (like ProComXX the procurement mission), however I didn't want to trigger it on "accept" but latter during the mission. So I though putting the code in a method I'd call latter. (should I call it in addDescriptionForNonEndStage?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 09, 2021, 10:16:28 AM
I'm doing some real hacky stuff with a shield that lets some damage bleed through to armor, and I've run into an issue with weapons/engines. I have to keep weapon/engine HP at a high level if it's under the shield arc, otherwise the bleedthrough damage can disable them. I can accomplish this by messing with the HP of weapons/engines under the shield arc, but sometimes a weapon or engine will get disabled and never turn back on, even if I set it to its maximum HP. How does the enable/disable logic work? And is there a way to re-enable engines, like WeaponAPI's repair() method?

Hmm, there's no matching repair() method for engine slots, looks like.

Unrelated to the above, what's the normal calculation for replacement rate decay?

The value you see is the average across all bays. IIRC it goes down linearly if a bay's wing's fighter count is at half or less of wing size, and bottoms out at 30%.


any idea what could cause this?

(im building a 91a just because there are some mods that seem as though they will never get an update and i want to get a build together just in case)

53903 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoSuchMethodError: com.fs.starfarer.api.SettingsAPI.getScreenWidthPixels()F
java.lang.NoSuchMethodError: com.fs.starfarer.api.SettingsAPI.getScreenWidthPixels()F

The cause is that, indeed, you're building with 0.9.1a. And whatever code is producing this error is using methods that are new to 0.95a and don't exist in 0.9.1a.


Putting this here too in case anyone has any insight. This is very strange and I don't think I've ever run into anything like it before. Things I've tried:

 - Rebuilding the module.

 - Rebuilding the project.

 - Deleting the module and dependencies and recreating them.

 - Resetting the src folder.

 - Invalidating caches and restarting the IDE.

Have you tried doing a "clean"? I'm not sure IntelliJ has an equivalent but in Eclipse there's a difference between just doing "build" and "clean".

Also worth trying: closing all the editor windows in the IDE and re-opening them. I know that's helped me for similar issues with Eclipse.



in the rules, I often see and have used:
Code
Call $variable updateData
Call $variable updateStage
first seems to call updateInteractionDataImpl() on the class instance in $variable
second seems to call addDescriptionForNonEndStage() on the same

is there other way to use "Call", for example to call some arbitrary method of the class instance?

In my case I wanted to make a fleet try to intercept the player in a bar mission (like ProComXX the procurement mission), however I didn't want to trigger it on "accept" but latter during the mission. So I though putting the code in a method I'd call latter. (should I call it in addDescriptionForNonEndStage?)

Call actually calls the callEvent() method of whatever CallableEvent $variable is referencing.

If you look at BaseHubMission, you can see its callEvent method handling various parameters. A snippet from that:
Code
if (action.equals("updateStage")) {
checkStageChangesAndTriggers(dialog, memoryMap);
} else if (action.equals("updateData")) {
checkStageChangesAndTriggers(dialog, memoryMap);
updateInteractionData(dialog, memoryMap);
}

You can also see that if it doesn't find any matches for the first param - the name of the action, i.e. "updateStage" - it will call the callAction() method.

So what you'll want to do - if you're using a BaseHubMission-derived class - is implement callAction() and do stuff there. You can see an example of this in HijackingMission.

However, there might be an easier way to do what you want. See: GACelestialObject for an example that scripts a hostile fleet spawning and intercepting the player when given conditions are met.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kiith on August 09, 2021, 02:56:17 PM
Not entirely sure this is a mod, but i started a new game where i am in the useless shuttle and have a debt to be repaid. Does the debt ever go away, or does it just keep increasing each month/cycle?

Like the idea of a debt to be repaid, but not one that goes on indefinitely. If indefinitely, any way to remove it (i.e. console commands)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 09, 2021, 10:16:14 PM
Putting this here too in case anyone has any insight. This is very strange and I don't think I've ever run into anything like it before. Things I've tried:

 - Rebuilding the module.

 - Rebuilding the project.

 - Deleting the module and dependencies and recreating them.

 - Resetting the src folder.

 - Invalidating caches and restarting the IDE.

Have you tried doing a "clean"? I'm not sure IntelliJ has an equivalent but in Eclipse there's a difference between just doing "build" and "clean".

Also worth trying: closing all the editor windows in the IDE and re-opening them. I know that's helped me for similar issues with Eclipse.

I tried both of those yeah. "Clean" is the same as "Invalidating Caches and Restart" for IntelliJ.

I noticed that the kit I'm using doesn't seem to exist in current LazyLib's jar when I look at it. There is a CombatUtil class that does roughly the same thing so I converted my code to use that and adjusted it to check for an enemy ship (this method seems more broad but its workable) but:

While it now recognizes the class itself which I believe is called statically since the constructor is private but the methods are public, it doesn't recognize one directory in the class's import path despite me visually confirming its there. Sigh...

I mean, it still works for me after the changes, but I'm not convinced it would make whatever is causing the user to get the error any better on their side. I guess I can just update the code and find out *shrug* but I'm still frankly unsure as to how it was working in the old implementation if that code no longer existed in the library jar. If it truly was an IDE issue then wouldn't it work for everyone as long as the jar actually compiles??

I might have to do some digging around on StackTrace. There has to be something I'm not understanding about this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Neb on August 10, 2021, 12:58:56 PM
Hello!

Quick noob question: My shield is way too big. how can I decrease its radius?
Edit: Nvm i found the answer myself.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 10, 2021, 02:06:27 PM
Could this:

Code
	int performRaid(CargoAPI loot, Random random, float lootMult, TextPanelAPI text);

 - From GroundRaidObjectivePlugin potentially cause an infinite loop somehow? (I don't do anything to change the process of this code or the Rules workflow so I'm assuming its either something in the core code or something I'm doing contextually with the market that is causing this to occur in the core code.)

For reference, I took screenshots of the memory dump of the colony and then the infinite loop occurring when "Launch Raid" is selected:

Spoiler
(https://i.imgur.com/EPzURC7.png)
(https://i.imgur.com/t9u4B48.png)
(https://i.imgur.com/ZofKMJ1.png)
(https://i.imgur.com/Rmmy0RF.png)
(https://i.imgur.com/d5Ec52v.png)
(https://i.imgur.com/p0FRbwq.png)
(https://i.imgur.com/vYAo0ey.png)
(https://i.imgur.com/jqeDBPB.png)
(https://i.imgur.com/LUhoogD.png)
(https://i.imgur.com/7Yi4jbH.png)
[close]

 - Assuming I am tracing the workflow correctly, it is coming somewhere from MarketCMD's raidConfirm(boolean secret) or raidConfirmContinue().

Looking through it I'm not seeing much that would cause an infinite loop. Most of the logic is if statements that would simply return unexpected results rather than something like that assuming there is a bug. ForEach statements wouldn't do it either. So my initial assumption is its somehwere in the above method (which only has an interface) or in the methods of:

CargoAPI.sort()
CargoAPI.updateSpaceUsed()


 - Or something is recalling a recursive method eternally and I haven't caught it yet.

I'm going to do a few more tests to see if it is isolated when attempting the raid the PatrolHQ or if raiding other infrastructure has a similar issue.

*EDIT*
Ah, ok more info.

This only occurs when raiding the Patrol HQ and the loop will also occur when the transponder is off and the "secret" option is selected using a story point when raiding the Patrol HQ. It doesn't occur when doing any other raid activity or disrupting the starport. It also doesn't occur when raiding the Patrol HQ or selecting the "secret" option on the nearby Independent market of Ilm.

It seems specifically tied to the Patrol HQ structure. It doesn't happen when raiding the Military Base or High Command structures. It isn't specific to one faction either. It only occurs with mod-added factions and only with 3 out of the 4 of them from what I can tell... just to make things extra complicated. ::) It does not occur with new markets of vanilla factions with a Patrol HQ added by the mod that wouldn't exist otherwise. It seems irrelevant to entity type. I'm going to guess it has something to do with the faction files though I have no idea how at the moment.

Mod-added faction files of the 3 where this occurs for reference:
https://www.dropbox.com/sh/duv6n1zui7n2al7/AACQMFFr1C4fmkaQ5pMQgy46a?dl=0 (https://www.dropbox.com/sh/duv6n1zui7n2al7/AACQMFFr1C4fmkaQ5pMQgy46a?dl=0)

And the one it doesn't occur in spoilers:
Spoiler
{
   id:"trader_guilds",
   "color":[136,167,85,255],
   "displayName":"Trader Guilds",
   "displayNameWithArticle":"The Trader Guilds",
   "displayNameLong":"Free Traders' Alliance of Guilds",
   "displayNameLongWithArticle":"The Free Traders' Alliance of Guilds",
   "logo":"graphics/factions/trader_guilds.png",
   "crest":"graphics/factions/crest_guilds.png",
   "shipNamePrefix":"TGS",
   "shipNameSources":{
      "BRITISH_NAVY":3,
      "MERCANTILE":2,
      "NORSE":1,
      "SPACE":1,
      "GENERAL":1,
   },
   "music":{
      "theme":"music_trader_guilds_encounter_friendly",
      "market_neutral":"music_trader_guilds_market_neutral",
      "market_hostile":"music_trader_guilds_market_hostile",
      "market_friendly":"music_trader_guilds_market_friendly",
      "encounter_neutral":"music_trader_guilds_encounter_neutral",
      "encounter_hostile":"music_trader_guilds_encounter_hostile",
      "encounter_friendly":"music_trader_guilds_encounter_friendly",
   },
   "internalComms":"trader_guilds_internal",
   "names":{
      "fringe":2,
      "modern":3,
      "world":1,
      "future":1,
      "myth":1,
   },
   # variantOverrides restricts hulls to listed variants and adjusts their probability
   "variantOverrides":{
         "tarsus_traderguilds_Standard":10,
         "valkyrie_Elite":10,
         "buffalo2_FS":10,
         "wolf_d_Attack":7,
         "lasher_Standard":12,
         "lasher_CS":10,
         "lasher_Overdriven":15,
         "hound_Overdriven":10,
         "cerberus_Overdriven":10,
         "cerberus_Hardened":10,
         "cerberus_Shielded":10,
         "rhino_Assault":5,
         "rhino_Assault2":10,
         "rhino_Strike":8,
         "rhino_FS":6,
         "rhino_PD":10,
         "monitor_Escort":10,
         "monitor_merc_Elite":10,
         "enforcer_Overdriven":13,
         "enforcer_Elite":8,
         "enforcer_CS":10,
         "sunder_Overdriven":12,
         "brawler_Assault":10,
         "brawler_merc_Elite":9,
         "brawler_merc_Elite2":10,
         "lancer_merc_Elite":10,
         "vigilance_merc_Elite":15,
         "vigilance_merc_Elite2":15,
         "vigilance_PD":7,
         "vigilance_Standard":10,
         "vigilance_Gunship":10,
         "centurion_Strike":10,
         "centurion_merc_Elite":5,
         "centurion_merc_CS":5,
         "centurion_merc_Strike":8,
         "centurion_merc_Assault":10,
         "centurion_merc_Assault2":10,
         "tempest_PD":10,
         "tempest_Starting":10,
         "tempest_Blaster":7,
         "tempest_Strike":1,
         "mule_merc_Elite":10,
         "crucible_FS":20,
         "crucible_Interdiction":20,
         "crucible_Elite":18,
         "crucible_Elite2":18,
         "hammerhead_Support":15,
         "wolverine_merc_Elite":15,
         "wolverine_lions_FS":10,
         "wolverine_lions_Strike":12,
         "drover_PD":15,
         "drover_lions_Interceptor":15,
         "drover_lions_Interceptor2":15,
         "drover_lions_Strike":15,
         "drover_lions_Gunship":15,
         "drover_lions_Gunship2":15,
         "havok_Assault2":10,
         "havok_Strike2":10,
         "havok_FS":8,
         "venture_merc_Assault":10,
         "venture_merc_FS":8,
         "venture_merc_Strike":10,
         "mora_Assault":7,
         "mora_Support":8,
         "mora_Strike":8,
         "mora_Strike2":8,
         "heron_Attack":10,
         "heron_PD":10,
         "heron_FS":10,
         "heron_merc_Elite":13,
         "heron_merc_Elite2":13,
         "heron_merc_Elite3":12,
         "dominator_Assault":10,
         "dominator_Strike":10,
         "dominator_AntiCV":12,
         "dominator_Support":5,
         "dominator_Fighter_Support":7,
         "atlas_mk2_Assault":10,
         "atlas_mk2_PD":10,
         "atlas_mk2_Elite":13,
         "conquest_Standard":10,
         "conquest_Assault":10,
         "conquest_Elite_LG":10,
         "conquest_Support":9,
         "conquest_FS":9,
         "legion_FS":8,
         "legion_Strike":10,
         "legion_Assault":10,
         "legion_Escort":8,
         "onslaught_Standard":12,
         "onslaught_Strike":14,
         "onslaught_Artillery":11,
         "onslaught_Elite":10,
   },
   
   # multiplier for how often hulls show up in the faction's fleets
   "hullFrequency":{
      "tags":{
         "archean_guilds_bp":1.5,
         "archean_lowtech_bp":0.75,
         "archean_lowtech_bp_tier2":1,
         "archean_lowtech_bp_tier3":1,
         "archean_midline_bp":1,
         "archean_midline_bp_tier2":0.75,
         "archean_midline_bp_tier3":0.5,
         "archean_hightech_bp":0,
         "archean_hightech_bp_tier2":0,
         "archean_hightech_bp_tier3":0,
      },
      "hulls":{
         "archean_buffalo2":0.1, # not common because its a weaker hull
         "archean_apogee":0, # too civilian.
         "archean_kite":2, # too civilian.
         "archean_shepherd":2, # too civilian.
         "archean_brawler":10,
         "archean_centurion":8,
         "archean_rhino":10,
         "archean_vigilance":8,
         "archean_osprey":6,
         "archean_mule":8,
         "archean_enforcer":10,
         "archean_havok":7,
         "archean_wolverine":9,
         "archean_heron":12, # a favorite of the viceroys.
         "archean_dominator":10,
         "archean_mora":10,
         "archean_venture":8,
         "archean_atlas_mk2":10,
         "archean_legion":10,
         "archean_onslaught":7, # unable to produce this hull, purchased from the Hegemony, so very rare.
         "archean_sunder":2, # more a diktat vessel.
      },
   },
   # ships the faction gets access to when importing S&W out-of-faction
   "shipsWhenImporting":{
      "tags":["base_bp", "archean_lowtech_bp", "archean_lowtech_bp_tier2", "archean_lowtech_bp_tier3", "archean_midline_bp", "archean_midline_bp_tier2", "archean_midline_bp_tier3", "archean_guilds_bp"],
      "hulls":[
         "archean_atlas",
         "archean_prometheus",
         "archean_gryphon",
         "archean_valkyrie",
         "archean_sunder",
      ],
   },
   "knownShips":{
      "tags":["base_bp", "archean_lowtech_bp", "archean_lowtech_bp_tier2", "archean_lowtech_bp_tier3", "archean_midline_bp", "archean_midline_bp_tier2", "archean_midline_bp_tier3", "archean_guilds_bp", "trader_guilds"],
      "hulls":[
         "archean_atlas",
         "archean_prometheus",
         "archean_gryphon",
         "archean_valkyrie",
         "archean_sunder",
      ],
   },
   # listing ships here will make the faction mostly use them even if other hulls become available
   "priorityShips":{
      "tags":["base_bp", "archean_lowtech_bp", "archean_lowtech_bp_tier2", "archean_lowtech_bp_tier3", "archean_midline_bp", "archean_midline_bp_tier2", "archean_midline_bp_tier3", "archean_guilds_bp"],
      "hulls":[
         "archean_atlas",
         "archean_prometheus",
         "archean_valkyrie",
      ],
   },
   "knownFighters":{
      "tags":["archean_guilds_bp"],
      "fighters":[
         "archean_cobra_wing",
         "archean_vanguard_wing",
         "archean_brute_wing",
         "archean_hellcat_wing",
         "archean_hydra_wing",
         "archean_retribution_wing",
      ],
   },
   "priorityFighters":{
      "tags":["archean_guilds_bp"],
      "fighters":[
         "archean_cobra_wing",
         "archean_vanguard_wing",
         "archean_brute_wing",
         "archean_hellcat_wing",
         "archean_hydra_wing",
         "archean_retribution_wing",
      ],
   },
   "knownWeapons":{
      "tags":["base_bp", "archean_lowtech_bp_tier2", "archean_lowtech_bp_tier3", "archean_midline_bp", "archean_midline_bp_tier2", "archean_hightech_bp", "archean_hightech_bp_tier2", "archean_missile_bp_tier2", "archean_missile_bp_tier3", "archean_guilds_bp", "trader_guilds"],
   },
   "priorityWeapons":{
      "tags":["base_bp", "archean_lowtech_bp_tier2", "archean_lowtech_bp_tier3", "archean_midline_bp", "archean_midline_bp_tier2", "archean_hightech_bp", "archean_hightech_bp_tier2", "archean_missile_bp_tier2", "archean_missile_bp_tier3", "archean_guilds_bp"],
   },
   "knownHullMods":{
      "tags":["base_bp", "trader_guilds"],
      "hullMods":[
         "advancedshieldemitter", # accelerated
         "archeus_advancedoptics",
         "archeus_turretgyros",
         "archeus_armoredweapons",
         "archeus_augmentedengines",
         "archeus_autorepair",
         "archeus_converted_hangar",
         "eccm",
         "ecm",
         "archeus_corrosive_warheads",
         "archeus_expanded_deck_crew",
         "archeus_magazines",
         "archeus_missleracks",
         "archeus_extendedshieldemitter",
         "archeus_frontemitter",
         "archeus_frontshield",  # makeshift
         "archeus_hardenedshieldemitter",
         "archeus_heavyarmor",
         "insulatedengine",
         "pointdefenseai",
         "archeus_targetingunit",
         "nav_relay",
         "archeus_adaptiveshields", # omni
         "archeus_operations_center",
         "recovery_shuttles",
         "fluxbreakers",
         "solar_shielding",
         "archeus_stabilizedshieldemitter",
         "surveying_equipment",
      ],
   },
   "factionDoctrine":{
      "warships":4,
      "carriers":2,
      "phaseShips":1,
      
      "officerQuality":3,
      "shipQuality":3,
      "numShips":2,
      
      "shipSize":3,
      
      "aggression":1,
      
      "combatFreighterProbability":0.1,                  # instead of some portion of the freighters in a fleet
      "combatFreighterCombatUseFraction":0,              # as part of the normal combat lineup
      "combatFreighterCombatUseFractionWhenPriority":0,   # as part of normal combat lineup, when marked as priority ship
      "autofitRandomizeProbability":0.1,
      "commanderSkillsShuffleProbability":0,
      "commanderSkills":[
         "officer_management",
         "officer_training",
         "auxiliary_support",
      ],
   },
   "illegalCommodities":[
      "ai_cores",
      "hand_weapons",
      "drugs",
      "organs",
   ],
   "portraits":{
      "standard_male":[
         "graphics/portraits/portrait_mercenary01.png",
         "graphics/portraits/portrait_mercenary03.png",
         "graphics/portraits/portrait_mercenary04.png",
         "graphics/portraits/portrait12.png",
         "graphics/portraits/portrait15.png",
         "graphics/portraits/portrait17.png",
         "graphics/portraits/portrait18.png",
         "graphics/portraits/portrait20.png",
         "graphics/portraits/portrait_pirate02.png",
         "graphics/portraits/portrait_pirate03.png",
         "graphics/portraits/portrait33.png",
         "graphics/portraits/portrait36.png",
         "graphics/portraits/portrait40.png",
         "graphics/portraits/app_001.png",
         "graphics/portraits/app_013.png",
         "graphics/portraits/app_017.png",
         "graphics/portraits/app_022.png",
         "graphics/portraits/app_024.png",
         "graphics/portraits/app_028.png",
         "graphics/portraits/app_029.png",
         "graphics/portraits/app_030.png",
         "graphics/portraits/app_044.png",
         "graphics/portraits/app_047.png",
         "graphics/portraits/app_048.png",
         "graphics/portraits/app_049.png",
         "graphics/portraits/app_052.png",
         "graphics/portraits/app_054.png",
         "graphics/portraits/app_058.png",
         "graphics/portraits/app_065.png",
         "graphics/portraits/app_068.png",
         "graphics/portraits/app_076.png",
         "graphics/portraits/app_081.png",
         "graphics/portraits/app_085.png",
         "graphics/portraits/app_086.png",
         "graphics/portraits/app_087.png",
         "graphics/portraits/app_104.png",
         "graphics/portraits/app_105.png",
         "graphics/portraits/app_113.png",
         "graphics/portraits/app_132.png",
         "graphics/portraits/app_135.png",
         "graphics/portraits/app_151.png",
         "graphics/portraits/app_152.png",
         "graphics/portraits/app_153.png",
         "graphics/portraits/app_195.png",
         "graphics/portraits/app_197.png",
         "graphics/portraits/Male(0).png",
         "graphics/portraits/Male(1).png",
         "graphics/portraits/Male(2).png",
         "graphics/portraits/Male(3).png",
         "graphics/portraits/Male(5).png",
         "graphics/portraits/Male(6).png",
         "graphics/portraits/Male(7).png",
         "graphics/portraits/Male(12).png",
         "graphics/portraits/Male(13).png",
         "graphics/portraits/Male(14).png",
         "graphics/portraits/Male(15).png",
         "graphics/portraits/Male(16).png",
         "graphics/portraits/Male(17).png",
         "graphics/portraits/Male(18).png",
         "graphics/portraits/Male(20).png",
         "graphics/portraits/Male(21).png",
         "graphics/portraits/Male(22).png",
         "graphics/portraits/Male(23).png",
         "graphics/portraits/Male(24).png",
         "graphics/portraits/Male(25).png",
         "graphics/portraits/Male(26).png",
         "graphics/portraits/Male(27).png",
         "graphics/portraits/Male(29).png",
         "graphics/portraits/Male(30).png",
         "graphics/portraits/Male(31).png",
         "graphics/portraits/Male(32).png",
         "graphics/portraits/Male(35).png",
         "graphics/portraits/Male(48).png",
         "graphics/portraits/Male(49).png",
         "graphics/portraits/Male(50).png",
         "graphics/portraits/Male(51).png",
         "graphics/portraits/Male(52).png",
         "graphics/portraits/Male(56).png",
         "graphics/portraits/interesting_portrait_luddic08.png",
         "graphics/portraits/interesting_portrait_luddic10.png",
         "graphics/portraits/interesting_portrait_luddic12.png",
         "graphics/portraits/interesting_portrait_luddic14.png",
         "graphics/portraits/interesting_portrait_luddic16.png",
         "graphics/portraits/interesting_portrait_luddic19.png",
         "graphics/portraits/interesting_portrait_luddic20.png",
         "graphics/portraits/interesting_portrait_luddic21.png",
         "graphics/portraits/interesting_portrait_luddic23.png",
         "graphics/portraits/interesting_portrait_luddic24.png",
         "graphics/portraits/interesting_portrait_luddic25.png",
         "graphics/portraits/interesting_portrait_luddic28.png",
         "graphics/portraits/interesting_portrait_luddic29.png",
         "graphics/portraits/interesting_portrait_luddic30.png",
         "graphics/portraits/interesting_portrait_luddic35.png",
         "graphics/portraits/interesting_portrait_luddic36.png",
         "graphics/portraits/interesting_portrait_luddic38.png",
         "graphics/portraits/interesting_portrait_luddic39.png",
         "graphics/portraits/interesting_portrait_luddic41.png",
         "graphics/portraits/interesting_portrait_luddic45.png",
         "graphics/portraits/interesting_portrait_luddic46.png",
         "graphics/portraits/interesting_portrait_luddic47.png",
         "graphics/portraits/interesting_portrait_luddic48.png",
         "graphics/portraits/interesting_portrait_independent01.png",
         "graphics/portraits/interesting_portrait_independent03.png",
         "graphics/portraits/interesting_portrait_independent04.png",
         "graphics/portraits/interesting_portrait_independent05.png",
         "graphics/portraits/interesting_portrait_independent07.png",
         "graphics/portraits/interesting_portrait_independent08.png",
         "graphics/portraits/interesting_portrait_independent09.png",
         "graphics/portraits/interesting_portrait_independent15.png",
         "graphics/portraits/interesting_portrait_independent17.png",
         "graphics/portraits/interesting_portrait_independent18.png",
         "graphics/portraits/interesting_portrait_independent20.png",
         "graphics/portraits/interesting_portrait_independent21.png",
         "graphics/portraits/interesting_portrait_independent22.png",
         "graphics/portraits/interesting_portrait_independent25.png",
         "graphics/portraits/interesting_portrait_independent27.png",
         "graphics/portraits/interesting_portrait_independent28.png",
         "graphics/portraits/interesting_portrait_independent29.png",
         "graphics/portraits/interesting_portrait_independent30.png",
         "graphics/portraits/interesting_portrait_independent33.png",
         "graphics/portraits/interesting_portrait_independent36.png",
         "graphics/portraits/interesting_portrait_independent37.png",
         "graphics/portraits/interesting_portrait_independent41.png",
         "graphics/portraits/interesting_portrait_independent42.png",
         "graphics/portraits/interesting_portrait_independent43.png",
         "graphics/portraits/interesting_portrait_independent44.png",
         "graphics/portraits/interesting_portrait_mercenary10.png",
         "graphics/portraits/interesting_portrait_mercenary11.png",
         "graphics/portraits/interesting_portrait_mercenary12.png",
         "graphics/portraits/interesting_portrait_mercenary13.png",
         "graphics/portraits/interesting_portrait_mercenary14.png",
         "graphics/portraits/interesting_portrait_mercenary15.png",
      ],
      "standard_female":[
         "graphics/portraits/portrait_mercenary02.png",
         "graphics/portraits/portrait_mercenary05.png",
         "graphics/portraits/portrait14.png",
         "graphics/portraits/portrait16.png",
         "graphics/portraits/portrait21.png",
         "graphics/portraits/portrait22.png",
         "graphics/portraits/portrait24.png",
         "graphics/portraits/portrait29.png",
         "graphics/portraits/portrait_pirate01.png",
         "graphics/portraits/portrait32.png",
         "graphics/portraits/portrait37.png",
         "graphics/portraits/portrait39.png",
         "graphics/portraits/app_002.png",
         "graphics/portraits/app_008.png",
         "graphics/portraits/app_012.png",
         "graphics/portraits/app_018.png",
         "graphics/portraits/app_023.png",
         "graphics/portraits/app_035.png",
         "graphics/portraits/app_037.png",
         "graphics/portraits/app_055.png",
         "graphics/portraits/app_066.png",
         "graphics/portraits/app_070.png",
         "graphics/portraits/app_073.png",
         "graphics/portraits/app_075.png",
         "graphics/portraits/app_077.png",
         "graphics/portraits/app_091.png",
         "graphics/portraits/app_092.png",
         "graphics/portraits/app_097.png",
         "graphics/portraits/app_099.png",
         "graphics/portraits/app_102.png",
         "graphics/portraits/app_110.png",
         "graphics/portraits/app_118.png",
         "graphics/portraits/app_185.png",
         "graphics/portraits/app_201.png",
         "graphics/portraits/female(0).png",
         "graphics/portraits/female(4).png",
         "graphics/portraits/female(11).png",
         "graphics/portraits/female(13).png",
         "graphics/portraits/female(14).png",
         "graphics/portraits/female(22).png",
         "graphics/portraits/female(28).png",
         "graphics/portraits/female(29).png",
         "graphics/portraits/female(31).png",
         "graphics/portraits/female(32).png",
         "graphics/portraits/female(34).png",
         "graphics/portraits/female(35).png",
         "graphics/portraits/female(39).png",
         "graphics/portraits/female(41).png",
         "graphics/portraits/female(42).png",
         "graphics/portraits/female(43).png",
         "graphics/portraits/female(50).png",
         "graphics/portraits/female(52).png",
         "graphics/portraits/female(64).png",
         "graphics/portraits/female(65).png",
         "graphics/portraits/female(66).png",
         "graphics/portraits/female(69).png",
         "graphics/portraits/female(70).png",
         "graphics/portraits/female(71).png",
         "graphics/portraits/female(72).png",
         "graphics/portraits/interesting_portrait_luddic09.png",
         "graphics/portraits/interesting_portrait_luddic11.png",
         "graphics/portraits/interesting_portrait_luddic13.png",
         "graphics/portraits/interesting_portrait_luddic15.png",
         "graphics/portraits/interesting_portrait_luddic17.png",
         "graphics/portraits/interesting_portrait_luddic18.png",
         "graphics/portraits/interesting_portrait_luddic22.png",
         "graphics/portraits/interesting_portrait_luddic26.png",
         "graphics/portraits/interesting_portrait_luddic27.png",
         "graphics/portraits/interesting_portrait_luddic31.png",
         "graphics/portraits/interesting_portrait_luddic32.png",
         "graphics/portraits/interesting_portrait_luddic33.png",
         "graphics/portraits/interesting_portrait_luddic34.png",
         "graphics/portraits/interesting_portrait_luddic37.png",
         "graphics/portraits/interesting_portrait_luddic40.png",
         "graphics/portraits/interesting_portrait_luddic42.png",
         "graphics/portraits/interesting_portrait_luddic43.png",
         "graphics/portraits/interesting_portrait_luddic44.png",
         "graphics/portraits/interesting_portrait_luddic49.png",
         "graphics/portraits/interesting_portrait_luddic50.png",
         "graphics/portraits/interesting_portrait_independent02.png",
         "graphics/portraits/interesting_portrait_independent06.png",
         "graphics/portraits/interesting_portrait_independent10.png",
         "graphics/portraits/interesting_portrait_independent11.png",
         "graphics/portraits/interesting_portrait_independent12.png",
         "graphics/portraits/interesting_portrait_independent13.png",
         "graphics/portraits/interesting_portrait_independent14.png",
         "graphics/portraits/interesting_portrait_independent16.png",
         "graphics/portraits/interesting_portrait_independent19.png",
         "graphics/portraits/interesting_portrait_independent23.png",
         "graphics/portraits/interesting_portrait_independent24.png",
         "graphics/portraits/interesting_portrait_independent26.png",
         "graphics/portraits/interesting_portrait_independent31.png",
         "graphics/portraits/interesting_portrait_independent32.png",
         "graphics/portraits/interesting_portrait_independent34.png",
         "graphics/portraits/interesting_portrait_independent35.png",
         "graphics/portraits/interesting_portrait_independent38.png",
         "graphics/portraits/interesting_portrait_independent39.png",
         "graphics/portraits/interesting_portrait_independent40.png",
         "graphics/portraits/interesting_portrait_mercenary08.png",
         "graphics/portraits/interesting_portrait_mercenary09.png",
      ],
   },
   "ranks":{
      "ranks":{
         "spaceSailor":{"name":"Thug"},
         "spaceChief":{"name":"Mercenary"},
         "spaceEnsign":{"name":"Elite Mercenary"},
         "spaceLieutenant":{"name":"Mercenary Lieutenant"},
         "spaceCommander":{"name":"Mercenary Commander"},
         "spaceCaptain":{"name":"Mercenary Captain"},
         "spaceAdmiral":{"name":"Viceroy"},
         "spaceMarshal":{"name":"Viceroy"},
      
         "groundPrivate":{"name":"Thug"},
         "groundSergeant":{"name":"Mercenary"},
         "groundLieutenant":{"name":"Elite Mercenary"},
         "groundCaptain":{"name":"Mercenary Lieutenant"},
         "groundMajor":{"name":"Mercenary Captain"},
         "groundColonel":{"name":"Viceroy"},
         "groundGeneral":{"name":"Viceroy"},
   
         "citizen":{"name":"Guild-Protected Citizen"},
         "agent":{"name":"Thug"},
      
         "pilot":{"name":"Pilot"},
      },
      "posts":{
         "patrolCommander":{"name":"Captain"},
         "fleetCommander":{"name":"Viceroy"},
         "baseCommander":{"name":"Viceroy"},
         "stationCommander":{"name":"Station Commander"},
         "outpostCommander":{"name":"Outpost Commander"},
         "portmaster":{"name":"Portmaster"},
      
         "supplyOfficer":{"name":"Quartermaster"},
         "supplyManager":{"name":"Supply Manager"},
         "medicalSupplier":{"name":"Medical Supplier"},
      
         "administrator":{"name":"Administrator"},
         "freeAdmin":{"name":"Freelance Administrator"},
      
         "trader":{"name":"Trader"},
         "merchant":{"name":"Merchant"},
         "investor":{"name":"Investor"},
         "commodities_agent":{"name":"Commodities Agent"},
      
         "shady":{"name":"Shady Character"},
         "gangster":{"name":"Gangster"},
         "smuggler":{"name":"Smuggler"},
         "fence":{"name":"Fence"},
      
         "citizen":{"name":"Citizen"},
      
         "mercenary":{"name":"Mercenary Officer"},
      
         "investigator":{"name":"Chief Investigator"},
         "agent":{"name":"Agent"},
      },
   },
   "voices":{
      "LOW":{
         "soldier":10,
         "business":8,
      },
      "MEDIUM":{
         "soldier":2,
         "aristo":3,
         "official":5,
         "business":10,
      },
      "HIGH":{
         "business":6,
         "aristo":10,
      },
   },
   "custom":{
      "allowsTransponderOffTrade":false,
      "offersCommissions":true,
      "engagesInHostilities":false,
      "buysAICores":true,
      "AICoreValueMult":2,
      "AICoreRepMult":0.5,
      "buysSurveyData":true,
      "hostilityImpactOnGrowth":true,
      "caresAboutAtrocities":false,
      "punitiveExpeditionData":{
         "vsCompetitors":true,
         "vsFreePort":true,
         "canBombard":false,
         "territorial":true,
      },
      "dreadAuraData":{
         "resistant":false,
         "immune":false,
         "isAIFaction":false,
         "saysText":true,
      },
   },
   "fleetTypeNames":{
      "trade":"Merchant Convoy",
      "tradeLiner":"Liner Convoy",
      "tradeSmuggler":"Hired Thugs",
      "smallTrader":"Trader",

      "patrolSmall":"Mercenary Patrol",
      "patrolMedium":"Mercenary Company",
      "patrolLarge":"Viceroy Guard",

      "inspectionFleet":"Viceroy Inspection Fleet",
      "taskForce":"Elite Mercenary Company",

      "foodReliefFleet":"Merchant Convoy",
   },

},
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 10, 2021, 03:36:12 PM
Edit: Nvm i found the answer myself.  :P

Was just about to answer, but: good on you :D

@Morrokain: I'd recommend connecting to the game using jvisualvm or some such and taking a thread (not heap, thread) dump. That should tell you what it's doing.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 10, 2021, 04:07:10 PM
@Morrokain: I'd recommend connecting to the game using jvisualvm or some such and taking a thread (not heap, thread) dump. That should tell you what it's doing.

Ok will do and I'll report my findings back here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on August 10, 2021, 06:47:18 PM
is there a way to change jump location/alter the star in a systems size cause ive got a jump point no one can get to in my home system on random sector mode
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 10, 2021, 08:09:36 PM
Ok will do and I'll report my findings back here.

Spoiler
It looks like a condition is waiting to be met where a JVM resource has some sort of contention with another resource in a referenced object that points to the same resource on multiple threads??

I was right on the method in question, but I don't completely understand because the thread is still considered Runnable. It also looks like it is attempting to read a file in some parts (my knowledge of this is based upon incredibly light research though... now my interest is peaked to be sure!  :D

Anyway that would make sense if the file was, for instance, in a shared folder or *possibly* if merging were present at the moment both the threads were run but that's a very, very loosely educated guess. And even still, its a mod-added faction so it wouldn't be file merging with a vanilla faction anyway... and those all work. But, that could be irrelevant to what's actually happening here and from what I've gather its very operating system dependent. I'm on windows 10 if that helps at all.

There is a seemingly good article about this I will read up on to find out more in case its helpful.

These seem like the most relevant parts:

"Thread-3" prio=6 tid=0x000000000c3bf800 nid=0x53e4 runnable [0x000000000d0ae000]
   java.lang.Thread.State: RUNNABLE
   at com.fs.starfarer.api.impl.campaign.graid.ShipWeaponsGroundRaidObjectivePluginIm pl.performRaid(ShipWeaponsGroundRaidObjectivePluginImpl.java:300)

"RMI Scheduler(0)" daemon prio=6 tid=0x000000004fcf6800 nid=0x8c08 waiting on condition [0x0000000011b4e000]
   java.lang.Thread.State: TIMED_WAITING (parking)
   at sun.misc.Unsafe.park(Native Method)
   - parking to wait for  <0x00000000a4389c78> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)

"Reference Handler" daemon prio=10 tid=0x0000000009eb6800 nid=0x3d08 in Object.wait() [0x000000000b25f000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000a060e458> (a java.lang.ref.Reference$Lock)
   at java.lang.Object.wait(Object.java:503)
   at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
   - locked <0x00000000a060e458> (a java.lang.ref.Reference$Lock)


Full Thread Dump:
Spoiler
"RMI TCP Connection(3)-192.168.1.84" daemon prio=6 tid=0x00000000163a5000 nid=0x2910 runnable [0x0000000024fce000]
   java.lang.Thread.State: RUNNABLE
   at java.net.SocketInputStream.socketRead0(Native Method)
   at java.net.SocketInputStream.read(Unknown Source)
   at java.net.SocketInputStream.read(Unknown Source)
   at java.io.BufferedInputStream.fill(Unknown Source)
   at java.io.BufferedInputStream.read(Unknown Source)
   - locked <0x00000000a45fa4c8> (a java.io.BufferedInputStream)
   at java.io.FilterInputStream.read(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.access$400(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - <0x00000000a45fa688> (a java.util.concurrent.ThreadPoolExecutor$Worker)

"JMX server connection timeout 27" daemon prio=6 tid=0x000000000c782000 nid=0x65e8 in Object.wait() [0x0000000024dcf000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000a4386408> (a [I)
   at com.sun.jmx.remote.internal.ServerCommunicatorAdmin$Timeout.run(Unknown Source)
   - locked <0x00000000a4386408> (a [I)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"RMI Scheduler(0)" daemon prio=6 tid=0x000000004fcf6800 nid=0x8c08 waiting on condition [0x0000000011b4e000]
   java.lang.Thread.State: TIMED_WAITING (parking)
   at sun.misc.Unsafe.park(Native Method)
   - parking to wait for  <0x00000000a4389c78> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
   at java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source)
   at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(Unknown Source)
   at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source)
   at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"RMI TCP Accept-0" daemon prio=6 tid=0x0000000017481000 nid=0x5de4 runnable [0x00000000010de000]
   java.lang.Thread.State: RUNNABLE
   at java.net.DualStackPlainSocketImpl.accept0(Native Method)
   at java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source)
   at java.net.AbstractPlainSocketImpl.accept(Unknown Source)
   at java.net.PlainSocketImpl.accept(Unknown Source)
   - locked <0x00000000a43a3e00> (a java.net.SocksSocketImpl)
   at java.net.ServerSocket.implAccept(Unknown Source)
   at java.net.ServerSocket.accept(Unknown Source)
   at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"Thread-8" prio=6 tid=0x000000000c731000 nid=0x23c waiting on condition [0x0000000010e2f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
   at java.lang.Thread.sleep(Native Method)
   at sound.OooO$2.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"Thread-4" daemon prio=6 tid=0x000000000bf5d000 nid=0x2b4c waiting on condition [0x000000000d59f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
   at java.lang.Thread.sleep(Native Method)
   at com.fs.starfarer.combat.CombatMain$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"Thread-3" prio=6 tid=0x000000000c3bf800 nid=0x53e4 runnable [0x000000000d0ae000]
   java.lang.Thread.State: RUNNABLE
   at com.fs.starfarer.api.impl.campaign.graid.ShipWeaponsGroundRaidObjectivePluginIm pl.performRaid(ShipWeaponsGroundRaidObjectivePluginImpl.java:300)
   at com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.performRaid(MarketCMD.java:1876)
   at com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.raidConfirm(MarketCMD.java:1735)
   at com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.execute(MarketCMD.java:346)
   at com.fs.starfarer.campaign.rules.super.execute(Unknown Source)
   at com.fs.starfarer.campaign.rules.C.runScript(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.applyRule(FireBest.java:106)
   at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.execute(FireBest.java:51)
   at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.fire(FireBest.java:57)
   at com.fs.starfarer.api.impl.campaign.RuleBasedInteractionDialogPluginImpl.fireBes t(RuleBasedInteractionDialogPluginImpl.java:177)
   at com.fs.starfarer.api.impl.campaign.RuleBasedInteractionDialogPluginImpl.optionS elected(RuleBasedInteractionDialogPluginImpl.java:210)
   at com.fs.starfarer.ui.newui.Stringsuper$1.o00000(Unknown Source)
   at com.fs.starfarer.ui.newui.OoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.Stringsuper.super(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"DestroyJavaVM" prio=6 tid=0x0000000002d60800 nid=0x48d8 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"AWT-Windows" daemon prio=6 tid=0x000000000c3c0800 nid=0x99f0 runnable [0x000000000d2ae000]
   java.lang.Thread.State: RUNNABLE
   at sun.awt.windows.WToolkit.eventLoop(Native Method)
   at sun.awt.windows.WToolkit.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"Java2D Disposer" daemon prio=10 tid=0x000000000c2b6800 nid=0x60d8 in Object.wait() [0x000000000ceae000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000a07bbaf8> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(Unknown Source)
   - locked <0x00000000a07bbaf8> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(Unknown Source)
   at sun.java2d.Disposer.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"Service Thread" daemon prio=6 tid=0x0000000009f0e000 nid=0x3cb4 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"C2 CompilerThread1" daemon prio=8 tid=0x0000000009efe800 nid=0xa408 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"C2 CompilerThread0" daemon prio=8 tid=0x0000000009efd000 nid=0x9b78 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"Attach Listener" daemon prio=10 tid=0x0000000009efc000 nid=0x91c8 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"Signal Dispatcher" daemon prio=10 tid=0x0000000009ef9000 nid=0x8778 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"Finalizer" daemon prio=8 tid=0x0000000009ec0800 nid=0x95d0 in Object.wait() [0x000000000b45e000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000a060e838> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(Unknown Source)
   - locked <0x00000000a060e838> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(Unknown Source)
   at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

   Locked ownable synchronizers:
   - None

"Reference Handler" daemon prio=10 tid=0x0000000009eb6800 nid=0x3d08 in Object.wait() [0x000000000b25f000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000a060e458> (a java.lang.ref.Reference$Lock)
   at java.lang.Object.wait(Object.java:503)
   at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
   - locked <0x00000000a060e458> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
   - None

"VM Thread" prio=10 tid=0x0000000009eb2800 nid=0x52e0 runnable

"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000002d77800 nid=0x77d8 runnable

"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000002d79000 nid=0x59e8 runnable

"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000002d7b000 nid=0x8d6c runnable

"GC task thread#3 (ParallelGC)" prio=6 tid=0x0000000002d7c800 nid=0x4428 runnable

"VM Periodic Task Thread" prio=10 tid=0x0000000009f21000 nid=0x5e04 waiting on condition

JNI global references: 276


[close]

And here is a snippet of the threads in the thread monitor with the timestamp that I killed the application in case that is also useful:
Spoiler
(https://i.imgur.com/cd0fop0.png)
[close]
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 10, 2021, 08:17:47 PM
This is the main thread, looks like:
"Thread-3" prio=6 tid=0x000000000c3bf800 nid=0x53e4 runnable [0x000000000d0ae000]
   java.lang.Thread.State: RUNNABLE
   at com.fs.starfarer.api.impl.campaign.graid.ShipWeaponsGroundRaidObjectivePluginIm pl.performRaid(ShipWeaponsGroundRaidObjectivePluginImpl.java:300)


If you take a look at line 300 in ShipWeaponsGroundRaidObjectivePluginImpl, you can see that's a while loop that looks like it could potentially keep going forever. Probably not under vanilla conditions, though, so maybe something will jump out at you as far as weapon value etc that might cause the loop to keep going. Just offhand looking at that method for a couple of minutes, it seems like this could happen if some weapons had a base value of zero.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 10, 2021, 08:28:28 PM
This is the main thread, looks like:
"Thread-3" prio=6 tid=0x000000000c3bf800 nid=0x53e4 runnable [0x000000000d0ae000]
   java.lang.Thread.State: RUNNABLE
   at com.fs.starfarer.api.impl.campaign.graid.ShipWeaponsGroundRaidObjectivePluginIm pl.performRaid(ShipWeaponsGroundRaidObjectivePluginImpl.java:300)


If you take a look at line 300 in ShipWeaponsGroundRaidObjectivePluginImpl, you can see that's a while loop that looks like it could potentially keep going forever. Probably not under vanilla conditions, though, so maybe something will jump out at you as far as weapon value etc that might cause the loop to keep going. Just offhand looking at that method for a couple of minutes, it seems like this could happen if some weapons had a base value of zero.

Its an interface for me. I can't actually look at the code. I'll double check the weapons value issue. None should have that except maybe fighter weapons, and those shouldn't be possible to drop. If you want to PM me the method or just the while loop I can look in further detail if want but no worries if you'd rather not.

*EDIT* Nvm my IDE was just scoping me to the interface. There is a ShipWeaponsGroundRaidObjectivePluginImpl available in the API. My bad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 10, 2021, 09:16:06 PM
is there a way to change jump location/alter the star in a systems size cause ive got a jump point no one can get to in my home system on random sector mode

There is a console command RunCode iirc, or something like that.

You could maybe try:

Code
        StarSystemAPI system = Global.getSector().getStarSystem("Name Of Star System");
        JumpPointAPI jumpPoint = (JumpPointAPI) system.getEntityById("jump_point_id");
        jumpPoint.setCircularOrbit(jumpPoint.getOrbitFocus(), jumpPoint.getCircularOrbitAngle(), 5000, jumpPoint.getCircularOrbitPeriod());

 - where you get the jump point ID by putting the game into dev mode and dumping the memory at the related jump point in hyperspace (which you should be able to reach) and looking for "entity.Id = "whatever_the_id_is" in the memory list.

Then you can enter the orbit radius (the number in the second line of code) to change how far out or close it is to the object it orbits.

If you need to change that to something else, then get the ID of the object you want it to orbit (same method as getting the jump point id only in-system this time when interacting with the entity) and replace "jumpPoint.getOrbitFocus()" with "system.getEntityById("entity_id")"

I have no clue if that would actually work in-campaign though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 10, 2021, 10:05:23 PM
Just offhand looking at that method for a couple of minutes, it seems like this could happen if some weapons had a base value of zero.

All of my weapons have a base value greater than zero and even if they didn't I'm pretty sure line 312 would throw an ArithmeticException because it would be a divide by zero error and not be what the thread dump indicated? It could not actually capture that though, idk.

But I *think* I figured it out.

Spoiler
See lines 191 - 194:
Code
		int maxTier = 0;
if (market.getSize() >= 6) {
maxTier = 1;
}

The maxTier is set to 1000 if its a military base or the market has heavy industry. (So a patrol HQ and size under 6 gets a max tier of 1.

But what if the faction doesn't know any weapons below tier 2?

Then that would mean the picker on line 221 wouldn't get anything added to it when iterating over the faction's known weapons:
Code
			if (spec.getTier() > maxTier) continue;

 - and if the picker is empty, then when it tries and adds the weapons to the weaponSubset on lines 240 - 247 based upon the number of marines sent on the raid, the weapon spec is always null again because weaponSubset is empty too:
Code
		for (int i = 0; i < 4 + marinesAssigned; i++) {
WeaponSpecAPI spec = pickerW.pick();
if (spec != null) {
float w = pickerW.getWeight(spec);
weaponSubset.add(spec, w);
pickerW.remove(spec);
}
}

 - and so when a weapon is picked on line 301 and it checks for null on line 302:
Code
			if (weapon != null) {

 - it never passes because there isn't a non-null entry and there is not an "else" route for the loop to take - hence an infinite loop.

Now to see if that is actually the case with the 3 factions. I think it might as they are all high tech with rare high tier stuff. And the one that doesn't have this problem has some low tier stuff mixed in.

Assuming this is the case, an isEmpty() check on the picker and some kind of message that the structure "has nothing of value" or "is too well guarded" would help modders not have to retrace this, but I'll have to confirm that this is what's going on first.

The only other thing I can think of right now (and I'm done working on this tonight) is that lootMult would be passed in as 0, but even that I think would eventually break the while loop from line 318:

Code
weaponValue -= val * num;

 - and val is always non-zero and num is always at least 1.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 11, 2021, 01:58:33 AM
Is there a way to configure supplies/month and DP costs of ships through raws? For example setting 40 DP to 35 DP etc
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2021, 08:11:33 AM
Oh, hmm, so the code you're seeing doesn't have a bunch of "else" clauses there, like so?

Code
if (weapon != null) {
    int min = 1, max = 2;
    ...
    if (num > 0) {
        looted.addWeapons(weapon.getWeaponId(), num);
        weaponValue -= val * num;
        totalValue += val * num;
    } else {
        break;
    }
} else {
    break;
}

If it doesn't, looks like this was fixed in dev, then.

Is there a way to configure supplies/month and DP costs of ships through raws? For example setting 40 DP to 35 DP etc

What do you mean "raws"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 11, 2021, 09:24:32 AM
Is there some way to cut/link the module during the combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2021, 09:26:16 AM
ShipAPI.setStationSlot(null) should let you detach it.  Not sure about re-attaching, that might or might not work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on August 11, 2021, 09:39:49 AM
ShipAPI.setStationSlot(null) should let you detach it.  Not sure about re-attaching, that might or might not work.
Hmmm, so what's the ai of detached module? could it perform like a normal ship? if couldn't, will resetDefaultAI() takes effect?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2021, 09:43:16 AM
Offhand, yes and if not also yes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on August 11, 2021, 10:00:56 AM
How do a make a quest giver (from a bar quest) available as a contact?
I have made a custom bar quest. Everything seems to work properly. But once the quest is finished the quest giver disappear and dosnt appear as a potential contact. I tried aping the settings of the findOrCreateGiver() of other bar quest but to no avail
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2021, 10:02:30 AM
if (barEvent) {
   setGiverIsPotentialContactOnSuccess(1f);
}

1f is the probability, if you want to make it guaranteed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Neb on August 11, 2021, 10:03:19 AM
Hello again!

I try to create a custom mine strike system but i don't know what im doing.
My approach was to just copy all the files related to vanilla mine strike and then modifying them.
It kind of worked but my mines still look the same even tho I changed the particle color in the wpn file and the weapon graphics.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 11, 2021, 11:00:13 AM
Oh, hmm, so the code you're seeing doesn't have a bunch of "else" clauses there, like so?

Code
if (weapon != null) {
    int min = 1, max = 2;
    ...
    if (num > 0) {
        looted.addWeapons(weapon.getWeaponId(), num);
        weaponValue -= val * num;
        totalValue += val * num;
    } else {
        break;
    }
} else {
    break;
}

If it doesn't, looks like this was fixed in dev, then.

No it doesn't have that and I confirmed that was the issue. Glad its fixed in dev!

Just in case, be aware that this is also the case for fighter wings and hullmods though if you fixed one place then the others are probably also fixed. Figured I'd let you know just to be sure. But the issue is fixed on my end just by making sure there are tier 0 things in those categories in the known section of the faction file if not the priority section.

As a side effect, this will also likely make markets of those factions seem more full than before so win-win.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 11, 2021, 04:28:27 PM
Is there a way to configure supplies/month and DP costs of ships through raws? For example setting 40 DP to 35 DP etc

What do you mean "raws"?

I mean through code, since sifting through the hull code only seems to show bounds, attached hull mods, position of defined mounts but no options to change sup/month or DP
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on August 11, 2021, 05:48:21 PM
I mean through code, since sifting through the hull code only seems to show bounds, attached hull mods, position of defined mounts but no options to change sup/month or DP

That's done through ship_data.csv under supplies/rec and supplies/month columns.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pokpaul on August 12, 2021, 04:47:45 PM
I was wondering if it was possible to modify the relationship hit depending on who initiated combat, i.e. if the other fleet pursues you and forces you to fight the relationship penalty would be less than if you did the same.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on August 13, 2021, 06:55:27 AM
if i wanted to update from 0.8a (for my own personal use from a mod that doesnt state it is supposed to be dead forever, im assuming tis ok for me to mess with it just so i can use an old mod i loved) what would that entail?
i really just want the fighters from that mod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 13, 2021, 06:04:46 PM
question
how do i declare/reference vanilla music files as non-music sounds in sounds.json?
specifically so i can use it for beam loop sound
i tried copying vanilla declaration
but it works only if within the music category
and then the sound can't be used by a weapon, it crashes with null
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 13, 2021, 06:17:28 PM
I mean through code, since sifting through the hull code only seems to show bounds, attached hull mods, position of defined mounts but no options to change sup/month or DP

Ah - yeah, looks like the ShipHullSpecAPI interface doesn't have all the methods that it perhaps should...

I was wondering if it was possible to modify the relationship hit depending on who initiated combat, i.e. if the other fleet pursues you and forces you to fight the relationship penalty would be less than if you did the same.

You'd have to provide your own implementation of FleetInteractionDialogPluginImpl, I believe. Not something you generally want to mess with, since that's a tough are for mods not to step on each others' toes in.

if i wanted to update from 0.8a (for my own personal use from a mod that doesnt state it is supposed to be dead forever, im assuming tis ok for me to mess with it just so i can use an old mod i loved) what would that entail?
i really just want the fighters from that mod

For the fighters, you could try just removing everything else from that mod. Depending on the amount of custom scripting involved with the fighters, that might just work.

question
how do i declare/reference vanilla music files as non-music sounds in sounds.json?
specifically so i can use it for beam loop sound
i tried copying vanilla declaration
but it works only if within the music category
and then the sound can't be used by a weapon, it crashes with null

Music is streamed from disk, while sound effects are loaded into memory in uncompressed form. Loading a music file into memory to be played back like an fx loop sound would be... extremely prohibitive, memory-wise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 16, 2021, 02:21:26 PM
is there a way to trigger the same variant update as a player removing/adding a hullmod? this would be considered an attempt to fix the issue where an OP cost reduction hullmod doesn't apply until the variant is updated through some kind of player interaction with the refit dialog, or through switching to and from another fleetmember in the refit dialog. the hullmod itself is added through a dialog as a perma-mod to the variant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 18, 2021, 02:41:16 PM
I'm working with rule.csv and I have two DialogOptionSelected with the same option ID.

What I thought how it worked was that if you have two of the same option ID, the rule.csv will fire at best one of the 50% of the time and the other 50% of the time as well, but I'm having a hard time getting a good 50%... Is there something more involved or am I just falling into the gambler's fallacy?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 18, 2021, 03:04:01 PM
is there a way to trigger the same variant update as a player removing/adding a hullmod? this would be considered an attempt to fix the issue where an OP cost reduction hullmod doesn't apply until the variant is updated through some kind of player interaction with the refit dialog, or through switching to and from another fleetmember in the refit dialog. the hullmod itself is added through a dialog as a perma-mod to the variant.

Sorry for the delayed response! Hmm, I don't think so. In general, negative OP hullmods are basically busted.


I'm working with rule.csv and I have two DialogOptionSelected with the same option ID.

What I thought how it worked was that if you have two of the same option ID, the rule.csv will fire at best one of the 50% of the time and the other 50% of the time as well, but I'm having a hard time getting a good 50%... Is there something more involved or am I just falling into the gambler's fallacy?

It'll fire the rule with more matching conditions, so if one of them has more than just $option == <id>, then that might be it. Otherwise - if both of the rules have the same number of conditions and they all match - it should be 50%.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 18, 2021, 04:19:00 PM
is there a way to trigger the same variant update as a player removing/adding a hullmod? this would be considered an attempt to fix the issue where an OP cost reduction hullmod doesn't apply until the variant is updated through some kind of player interaction with the refit dialog, or through switching to and from another fleetmember in the refit dialog. the hullmod itself is added through a dialog as a perma-mod to the variant.

Sorry for the delayed response! Hmm, I don't think so. In general, negative OP hullmods are basically busted.

this is one that uses the WeaponOPCostListener that was implemented, rather than one that is just a negative value in the .csv (which worked before 0.9.5 even if built in). is there no way to increase the OP that a ship has through some kind of code?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 18, 2021, 05:52:20 PM
this is one that uses the WeaponOPCostListener that was implemented, rather than one that is just a negative value in the .csv (which worked before 0.9.5 even if built in). is there no way to increase the OP that a ship has through some kind of code?

Ah - from the WeaponOPCostModifier javadoc:
Quote
If multiple different ones are added to the same ship stats, they might have a hard time coordinating properly.
Should be used with care, and ideally only through built-in hullmods.

Hullmods reducing OP costs or modifying OP is not going to work well combined with them also being removable. There just aren't UI-level checks to prevent adding them, going over OP, and then removing them. There *might* be some workarounds, but I'm not familiar with them and I'd suspect they have some downsides.

And, right - there's no way to increase ship OP directly, no. You might consider a built-in / permanent hullmod that reduces weapon OP costs, for example, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 11:53:32 AM
And, right - there's no way to increase ship OP directly, no. You might consider a built-in / permanent hullmod that reduces weapon OP costs, for example, though.

the idea is to be able to install the OP cost modifier onto any ship in the game though. it still is installed using addPermaMod, but i'm assuming you mean through the .ship/.skin files, which is very out of scope for the mod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 11:54:20 AM
I think with addPermaMod it would likely be ok? At least, not thinking of any issues right now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 12:32:37 PM
I think with addPermaMod it would likely be ok? At least, not thinking of any issues right now.

that's the method i'm using, and it leads to the current OP not updating until either a change to the ship (like installing a hullmod, but i'm pretty sure installing a weapon doesn't work!) occurs or you pick a different ship, then switch back to the now-upgraded ship through the refit dialog.

essentially some kind of interaction is needed in the refit dialog in order for the OP changes to apply.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 12:46:15 PM
Ah, yeah, if you're doing this in the refit screen, I can see how there'd be problems with it not refreshing. I was thinking of if it was applied with code at some other point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 12:51:39 PM
Ah, yeah, if you're doing this in the refit screen, I can see how there'd be problems with it not refreshing. I was thinking of if it was applied with code at some other point.

It's applied in a dialog, not in the refit screen. The issue is that you need to interact with the refit screen by installing any random hullmod or switching to/from another ship for the changed OP to actually take effect before you can modify the ship to take advantage of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 01:06:55 PM
Hmm - make sure you're doing addListener() inside applyEffectsBeforeShipCreation, and that your hullmod overrides the affectsOPCosts() method and has it return true. (Edit: if neither one is the problem here, I'll be preeeetty confused...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 01:15:08 PM
Hmm - make sure you're doing addListener() inside applyEffectsBeforeShipCreation, and that your hullmod overrides the affectsOPCosts() method and has it return true. (Edit: if neither one is the problem here, I'll be preeeetty confused...)

so the Listener is supposed to be applied to the stats object and not the ship? maybe that would explain it, actually.

edit: sorry, looked at the wrong one. the listener is applied in applyEffectsBeforeShipCreation, and the hullmod returns true in affectsOPCosts
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 01:16:19 PM
Right! Per the javadoc:
Quote
Only applies when added to MutableShipStatsAPI, not to ShipAPI or the combat engine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 01:19:11 PM
Right! Per the javadoc:
Quote
Only applies when added to MutableShipStatsAPI, not to ShipAPI or the combat engine.

sorry, posted before i looked at what the code was doing. the listener is applied to the Stats object in applyEffectsBeforeShipCreation, and the hullmod returns true in affectsOPCosts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 01:34:32 PM
I just tried it and it works for me. That is, I built in a permaMod that affects OP this way with code on a button press, and the OP changes are reflected immediately upon opening the refit screen.

One other key point - and this applies to any other ship variant manipulation with code - is if you're going to change a variant, and its .getSource() != VariantSource.REFIT, you need to clone the variant and set the fleet member's variant to the cloned version of it. You can search FleetEncounterContext for .clone() to see an example of code doing that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 19, 2021, 01:59:13 PM
It'll fire the rule with more matching conditions, so if one of them has more than just $option == <id>, then that might be it. Otherwise - if both of the rules have the same number of conditions and they all match - it should be 50%.

It doesn't discriminate on what type of conditions right? Like if
option1 has $option == <id>,$alwaystrue,$alwaystrue as opposed to
option2 has $option == <id>,$alwaystrue3,$alwaystrue4

would have the same 50%?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 02:13:48 PM
Right.

Just for general information, you can append " score:<number>" (without the quotes) to the end of a condition to set its score; the default score is 1. So in your example they'd both have score 3.

But if you did:
$option == <id> score:2
$alwaystrue
$alwaystrue

Then that would have score 4.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 02:29:59 PM
I just tried it and it works for me. That is, I built in a permaMod that affects OP this way with code on a button press, and the OP changes are reflected immediately upon opening the refit screen.

One other key point - and this applies to any other ship variant manipulation with code - is if you're going to change a variant, and its .getSource() != VariantSource.REFIT, you need to clone the variant and set the fleet member's variant to the cloned version of it. You can search FleetEncounterContext for .clone() to see an example of code doing that.

i'm using a BuffManager to apply the hullmod (which is probably now a less-than-efficient way of doing it)

the code that applies the variant is like so
Code
			if(shipVariant.isStockVariant()) {
shipVariant = shipVariant.clone();
shipVariant.setSource(VariantSource.REFIT);
member.setVariant(shipVariant, false, false);
}
inside of a BuffManager that is applied to a FleetMember in dialog. after this, the BuffManager applies the hullmod, and finally FleetMemberAPI.updateStats is called

i'll add a check for the source to apply the cloned variant if the source isn't refit, but otherwise i think i'm doing the same thing as you. the only thing i could think of is you may be using a dev version where this single oddity is already fixed.

edit:

here's my investigation after adding the check.

this picture shows off the dialog-applied hullmod
https://i.imgur.com/66V6kWu.png

this picture shows off the ship's OP after applying the hullmod, with the ballistic weapons in frame.
https://i.imgur.com/IJlQEOt.png

this picture shows off the fleet refit screen, where it shows the free OP that the ship should have.
https://i.imgur.com/gnc0FdM.png

additionally, and this is a bug i hadn't noticed before, when closing and reopening the refit dialog for that specific ship, the free OP disappears as well, and it appears i was mistaken about the OP appearing if you install something on the ship. it only appears if you switch what ship you are looking at.

looking at the logs, it appears the WeaponOPCostListener is called very often, much more often than applyEffectsBeforeShipCreation is, which is called twice because of the affectsOpCosts method returning true in the hullmod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 19, 2021, 03:06:18 PM
Right.

Just for general information, you can append " score:<number>" (without the quotes) to the end of a condition to set its score; the default score is 1. So in your example they'd both have score 3.

But if you did:
$option == <id> score:2
$alwaystrue
$alwaystrue

Then that would have score 4.
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 03:32:49 PM
@presidentmattdamon: hmm, that's weird. I don't remember changing anything related. This could actually be related to doing this in a BuffManager, so I'd suggest trying it just as code in response to a dialog option being selected or something.

looking at the logs, it appears the WeaponOPCostListener is called very often, much more often than applyEffectsBeforeShipCreation is, which is called twice because of the affectsOpCosts method returning true in the hullmod

It would be, yeah, since it's called for each weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 03:36:29 PM
@presidentmattdamon: hmm, that's weird. I don't remember changing anything related. This could actually be related to doing this in a BuffManager, so I'd suggest trying it just as code in response to a dialog option being selected or something.

looking at the logs, it appears the WeaponOPCostListener is called very often, much more often than applyEffectsBeforeShipCreation is, which is called twice because of the affectsOpCosts method returning true in the hullmod

It would be, yeah, since it's called for each weapon.

i'll set up a way that works withouta buff manager. i've done some more investigation and i have this:
a stats object that doesn't match a single fleet member in my fleet!

Code
681977 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] applyEffectsBeforeShipCreation
681977 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] stats getEntity null getFleetMember null
681977 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] could not find a fleet member for this stats object!

681978 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] applyEffectsBeforeShipCreation
681978 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] stats getEntity eagle_Balanced null [eagle] getFleetMember Balanced,Eagle, owner: 0, name: PLS Blueshift
681978 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] found fleet member Balanced,Eagle, owner: 0, name: PLS Blueshift
681978 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] FleetMember has augment Spooled Ammo Feeders installed
681978 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [SpooledFeeders] applying upgrades before ship creation to stats
681978 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [SpooledFeeders] stats did not have a spooled feeder listener!

i'd like to continue by saying that sometimes this isn't an issue:
Code
681965 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] applyEffectsBeforeShipCreation
681965 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] stats getEntity null getFleetMember null
681965 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] found fleet member Balanced,Eagle, owner: 0, name: PLS Blueshift
681965 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [ExtraSystemsHM] FleetMember has augment Spooled Ammo Feeders installed
so this one must not be attached to any single FleetMember at all, whether by calling fm.getStats, variant.getStatsForOpCosts, stats.getEntity or stats.getFleetMember

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 03:42:38 PM
This seems normal, stats are recomputed from scratch all the time - any time you open the fleet screen, make a change to a fleet member, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 03:50:41 PM
This seems normal, stats are recomputed from scratch all the time - any time you open the fleet screen, make a change to a fleet member, etc.

why wouldn't the stats object be attached to the fleet member in that case though?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2021, 03:54:47 PM
Presumably because the stats got recomputed (and a new stats object created) since the point where you'd saved the reference to the previous stats object?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2021, 04:03:00 PM
Presumably because the stats got recomputed (and a new stats object created) since the point where you'd saved the reference to the previous stats object?

the previous stats objects in this case are the ones stored directly on the fleet members. the one i'm performing the "search" with are passed to applyEffectsBeforeShipCreation.

if a new Stats object is being created and not being set on the fleet members or their variants before the call to applyEffectsBeforeShipCreation, that would cause this issue. if that's supposed to be the case, that's okay.

edit: i've rewritten my code to not use a buff manager, and the issue was resolved. pretty weird, honestly. thanks for the help, i appreciate your patience
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on August 19, 2021, 09:44:50 PM
Hey Alex,

Discovered something strange, and I'm not sure of the source. I've made a weapon that has two beams, and have Converge on Point set to true like the Guardian. However, when the AI fires the beams at missiles in the simulator, they converge just slightly to the left of the missile and never hit. I've attached an image to demonstrate.

Spoiler
(https://i.imgur.com/iP1WNIf.png)
[close]

Is there something I'm doing wrong, or is this a vanilla based bug?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 20, 2021, 08:20:58 AM
edit: i've rewritten my code to not use a buff manager, and the issue was resolved. pretty weird, honestly. thanks for the help, i appreciate your patience

Cool, glad you got it working! Stuff in BuffManager is applied at some point in the "update the stats for this ship" process so it's not *too* surprising that would go wrong sometimes.

Hey Alex,

Discovered something strange, and I'm not sure of the source. I've made a weapon that has two beams, and have Converge on Point set to true like the Guardian. However, when the AI fires the beams at missiles in the simulator, they converge just slightly to the left of the missile and never hit. I've attached an image to demonstrate.

...

Is there something I'm doing wrong, or is this a vanilla based bug?

Ah - looking at the code, convergesOnPoint will aim for the endpoint of the first beam, so it's not going to work with a pair of offset beams like that. The first beam "barrel" defined in the .wpn file pretty much needs to point straight down the middle for this to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 20, 2021, 08:46:49 AM
Hey Alex,

Discovered something strange, and I'm not sure of the source. I've made a weapon that has two beams, and have Converge on Point set to true like the Guardian. However, when the AI fires the beams at missiles in the simulator, they converge just slightly to the left of the missile and never hit. I've attached an image to demonstrate.

...

Is there something I'm doing wrong, or is this a vanilla based bug?

Ah - looking at the code, convergesOnPoint will aim for the endpoint of the first beam, so it's not going to work with a pair of offset beams like that. The first beam "barrel" defined in the .wpn file pretty much needs to point straight down the middle for this to work.

is it possible to have an invisible 0 damage beam as the first beam?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 20, 2021, 09:10:22 AM
AFAIK you can't define damage or color per-beam.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 20, 2021, 05:28:31 PM
Ah - looking at the code, convergesOnPoint will aim for the endpoint of the first beam, so it's not going to work with a pair of offset beams like that. The first beam "barrel" defined in the .wpn file pretty much needs to point straight down the middle for this to work.

That seems like a bug which could be fixed by a simple offset check.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 20, 2021, 05:39:48 PM
(It's definitely not a bug. It could probably be changed reasonably easily, though.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: King Alfonzo on August 20, 2021, 10:09:27 PM
Ah - looking at the code, convergesOnPoint will aim for the endpoint of the first beam, so it's not going to work with a pair of offset beams like that. The first beam "barrel" defined in the .wpn file pretty much needs to point straight down the middle for this to work.

Alright, thanks for that. Should be a simple fix then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 23, 2021, 09:52:11 PM
Is there any way for a "sub-faction" to spawn smodded variants using a Lion's Guard HQ or...? I have a Lion's Guard-like faction that I wish for it to spawn with specific smods that I've already specified inside the variants. I thought the variants saved with its smod variant would be able to work, but that didn't seem to be the case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 24, 2021, 07:17:06 PM
is there any way to get an expandable tooltip for a hullmod, like press F1 for it to expand and show more?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 25, 2021, 03:09:01 AM
Sort of a modded-bug-report thing: Is there a smarter way to handle ShardSpawner's use of setCombatNotOverForAtLeast(time)?
Currently if a player or allied shard spawner ship appears in a battle and doesn't get disabled or retreat, the combat won't end except using devmode/console.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 25, 2021, 08:18:45 AM
Is there any way for a "sub-faction" to spawn smodded variants using a Lion's Guard HQ or...? I have a Lion's Guard-like faction that I wish for it to spawn with specific smods that I've already specified inside the variants. I thought the variants saved with its smod variant would be able to work, but that didn't seem to be the case.

Hmm - a custom fleet inflater is always an option. To be honest, I don't remember how the default one works; a little surprised that it wouldn't keep s-mods specified in a .variant file, though.

is there any way to get an expandable tooltip for a hullmod, like press F1 for it to expand and show more?

I don't believe so, actually - looks like that's a case where there *isn't* an "isTooltipExpandable()" method for it.

Sort of a modded-bug-report thing: Is there a smarter way to handle ShardSpawner's use of setCombatNotOverForAtLeast(time)?
Currently if a player or allied shard spawner ship appears in a battle and doesn't get disabled or retreat, the combat won't end except using devmode/console.

I'm not sure I understand. setCombatNotOverForAtLeast() gets called from that hullmod's advanceInCombat() method, which will not get called if the ship is removed from combat for example via script. Between that, disabling, and retreating, what other state is there for a ship to be in where you *wouldn't* want it to prevent combat from ending?

(Incidentally, I'm surprised it works at all on the player side; wasn't really coded with that in mind at all...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 25, 2021, 01:34:44 PM
Hmm - a custom fleet inflater is always an option. To be honest, I don't remember how the default one works; a little surprised that it wouldn't keep s-mods specified in a .variant file, though.
In a way, it sort of does if you specified the fleet spawn to have an average of >0 smod. However, I would like one that it would ignore hullmod restriction and let me spawn "illegal" variants like a Flux Shunted Caps  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 25, 2021, 05:36:49 PM
I'm not sure I understand. setCombatNotOverForAtLeast() gets called from that hullmod's advanceInCombat() method, which will not get called if the ship is removed from combat for example via script. Between that, disabling, and retreating, what other state is there for a ship to be in where you *wouldn't* want it to prevent combat from ending?

(Incidentally, I'm surprised it works at all on the player side; wasn't really coded with that in mind at all...)
Well the specific issue that came up is that Nex had a way (which was disabled for other reasons) to temporarily get an Aspect in the player fleet, but using that ship results in the battle not ending after the player has won (enemies all retreated or disabled).

EDIT: Hmm, one potential fix would be to suppress the setCombatNotOverForAtLeast call if enemy has no ships deployed, and (no ships in reserve, or is in full retreat). This is what was checked for by the old mod-side fix for the "modular ships retreating prevents battle from ending" bug.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 25, 2021, 07:25:09 PM
Ahh, right, that makes sense. Looking at what setCombatNotOverForAtLeast() does, it's asymmetrical anyway - it cancels out "no-one's left or everyone is retreating" on the enemy side only. So, I think just doing an "if (ship.getOriginalOwner() != 0)" is sufficient here. The battle will end if this is the only kind of ship left on the player side and it gets disabled, but it already would anyway.

(If you decide to use an Aspect in the player fleet, it seems like the simplest solution would be to have a variant with the shard spawner in "suppressedMods". At least, I think that ought to work, though not 100% sure.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on August 25, 2021, 09:44:01 PM
Is there a way to get ships with Fighter hullsize to capture objectives?

The workaround I have been using to command them is setting the ship to frigate hullsize before issuing any order, which works for literally everything else... but capture orders seem to be immediately cancelled as soon as the ships hullsize is set back to fighter. It seems they still 'have' the assignment because if I alternate between the two hullsizes, the ship will attempt to return to carrying out objective-based orders on frigate hullsize, but return to the default 'no orders' behavior when switched to fighter hullsize.

Edit: Is there some way to get text input from the player with the API?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 29, 2021, 03:21:02 AM
Does anyone know how to cause a text choice to randomly pick one of many dialogue options available?

To be specific, I want to mod in more dialogue for the foreign sector comm relay interaction in Beyond The Sector, letting it pick one of many options available.

But I’m no script wizard, and very few interactions anywhere seem to do this, so I’m not sure how to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on August 29, 2021, 05:48:38 AM
Is there a way to get ships with Fighter hullsize to capture objectives?

The workaround I have been using to command them is setting the ship to frigate hullsize before issuing any order, which works for literally everything else... but capture orders seem to be immediately cancelled as soon as the ships hullsize is set back to fighter. It seems they still 'have' the assignment because if I alternate between the two hullsizes, the ship will attempt to return to carrying out objective-based orders on frigate hullsize, but return to the default 'no orders' behavior when switched to fighter hullsize.

Edit: Is there some way to get text input from the player with the API?


neophyte is an understatement concerning my coding abilities, however, isnt there some way to set the size as frigate but for collision purposes set it as fighter?
i can see the workaround in my head but have no idea how to write the code
it would be a long line of code to be sure..... you would have to make some exception rules (i think thats how it works) where in it points to fighter for collision and being able to dock but the actual class is frigate
anyway in my head i see it as that.....have the size as frigate with something that redirects to the code that handles fighters for things that you want to be fighter status like collision and pd weapon damage

.....is that how youve made it work so far anyway?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 29, 2021, 01:47:26 PM
Is there a way to get ships with Fighter hullsize to capture objectives?

The workaround I have been using to command them is setting the ship to frigate hullsize before issuing any order, which works for literally everything else... but capture orders seem to be immediately cancelled as soon as the ships hullsize is set back to fighter. It seems they still 'have' the assignment because if I alternate between the two hullsizes, the ship will attempt to return to carrying out objective-based orders on frigate hullsize, but return to the default 'no orders' behavior when switched to fighter hullsize.

Edit: Is there some way to get text input from the player with the API?

Hmm - having dug around a bit, I don't think it's possible directly. Honestly, I'm not 100% clear on all the details under the hood, it'd require a lot more digging around to be certain one way or another.

Does anyone know how to cause a text choice to randomly pick one of many dialogue options available?

To be specific, I want to mod in more dialogue for the foreign sector comm relay interaction in Beyond The Sector, letting it pick one of many options available.

But I’m no script wizard, and very few interactions anywhere seem to do this, so I’m not sure how to do it.

I'm not sure what you're asking. What do you mean by "letting it pick"? If you could describe the exact interaction flow you want that'd help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 29, 2021, 04:28:46 PM
I mean out of maybe 10 available options, when you press Continue it uses one of them for the interaction, kinda like those random number generators except with text options
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 29, 2021, 04:31:44 PM
When you say "options" it sounds like you're talking about, like, numbered options presented to the player. But I'm starting to think that maybe you just mean "possibilities"? That is, there's just one option - "Continue" - and when the player selects it, one of 10 different things happens.

If so: you can achieve this by just having 10 different rules with the same set of conditions that match this continue option. If the rules all 1) pass their conditions and 2) have the *same number of conditions* (the rule's "score"), then one of them will be picked randomly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 29, 2021, 08:35:28 PM
When you say "options" it sounds like you're talking about, like, numbered options presented to the player. But I'm starting to think that maybe you just mean "possibilities"? That is, there's just one option - "Continue" - and when the player selects it, one of 10 different things happens.

If so: you can achieve this by just having 10 different rules with the same set of conditions that match this continue option. If the rules all 1) pass their conditions and 2) have the *same number of conditions* (the rule's "score"), then one of them will be picked randomly.

Yeah, I was talking about possibilities.

Is it possible to do this via simply copying the existing interaction’s code, then pasting it and re-writing the text displayed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on August 30, 2021, 01:44:28 PM
I'm having a bit of trouble with a deco weapon- I've set it to display hull damage decals, but it's not. It's in a deco slot too, in case that's an issue. The deco weapon goes over the large slot, and under everything else, which I've set using renderOrderMod in the .ship file.

.wpn file:
Spoiler
{
   "id":"apex_deco_caiman_center",
   "specClass":"beam",
   "type":"DECORATIVE",
   "size":"LARGE",
   "showDamageWhenDecorative":true,
   "renderBelowAllWeapons":false,
   "turretSprite":"graphics/ships/decos/apex_caiman_center.png",
   "hardpointSprite":"graphics/ships/decos/apex_caiman_center.png",
   "turretOffsets":[0, 0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[0, 0],
   "hardpointAngleOffsets":[0],   
   "fringeColor":[255,255,255,255],
   "coreColor":[255,255,255,255],
   "glowColor":[255,255,255,255],
   "width":1.0,
   "textureType":ROUGH,
   "textureScrollSpeed":1.0,
   "pixelsPerTexel":1.0,
}
[close]
(https://i.imgur.com/zQRHxwl.png)

Also, is there a way to figure out if a ship is trying to turn to present less-damaged armor? Like the bit where a ship has stripped armor and will try to turn away from that point if its shields are down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 30, 2021, 04:25:25 PM
Yeah, I was talking about possibilities.

Is it possible to do this via simply copying the existing interaction’s code, then pasting it and re-writing the text displayed?

Hmm, probably? You could also do something more elegant where you put the code in a separate rule with a unique trigger and FireBest <that trigger> from all your "different text" rules.

Also, if all you want is just different text, you can do this via the text column, by separating the possible text with an "OR" on a separate line, like so:

<text 1>
OR
<text 2>
OR
<text 3>

etc.

I'm having a bit of trouble with a deco weapon- I've set it to display hull damage decals, but it's not. It's in a deco slot too, in case that's an issue. The deco weapon goes over the large slot, and under everything else, which I've set using renderOrderMod in the .ship file.

.wpn file:
...

Hmm - the only thing that comes to mind is that the damage decals for a decorative weapon are fairly small and anything larger than a standard large-sized weapon is unlikely to be covered by them - at least, if I remember correctly how this works.

If this isn't the problem, then the only thing that I can think of is to start with a case where it *is* working and try to isolate the particular change that makes it not work...

Also, is there a way to figure out if a ship is trying to turn to present less-damaged armor? Like the bit where a ship has stripped armor and will try to turn away from that point if its shields are down.

It doesn't set any flag when it's doing that, so not directly, no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 30, 2021, 04:37:17 PM
Yeah, I was talking about possibilities.

Is it possible to do this via simply copying the existing interaction’s code, then pasting it and re-writing the text displayed?

Hmm, probably? You could also do something more elegant where you put the code in a separate rule with a unique trigger and FireBest <that trigger> from all your "different text" rules.

Also, if all you want is just different text, you can do this via the text column, by separating the possible text with an "OR" on a separate line, like so:

<text 1>
OR
<text 2>
OR
<text 3>

etc.

I tried the copy-paste method and the game crashed for “duplicate keys” so this is probably the ideal method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 30, 2021, 05:51:16 PM
I tried the copy-paste method and the game crashed for “duplicate keys”

That probably means you didn't change the rule id for your new rules. Each rule needs to have a unique rule id.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MeinGott on August 31, 2021, 08:31:23 AM
Hello,
I tried to make Heavy Weapons Integration, so in 1st step I took Heavy Ballistics Integration from source archive, changed the name wherever it was due, added .cvs entry accordingly and changed package name in code's first line to data.hullmods. Didnt change what it does yet, just wanted to see if the game would start.
Then I took
Spoiler
22456 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.mm_hwi]
java.lang.RuntimeException: Error loading [data.hullmods.mm_hwi]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassFormatError: Inconsistent constant value type in class file data/hullmods/mm_hwi
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at org.codehaus.janino.JavaSourceClassLoader.defineBytecode(JavaSourceClassLoader.java:244)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:194)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]
to the knee.
It obviously tells me nothing as I am uneducated schmuck. Is the solution compiling it manually or something completly else?

Thank you from the mountain, as we say in my country.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on August 31, 2021, 09:00:05 AM
Hello,
I tried to make Heavy Weapons Integration, so in 1st step I took Heavy Ballistics Integration from source archive, changed the name wherever it was due, added .cvs entry accordingly and changed package name in code's first line to data.hullmods. Didnt change what it does yet, just wanted to see if the game would start.
Then I took
Spoiler
22456 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.mm_hwi]
java.lang.RuntimeException: Error loading [data.hullmods.mm_hwi]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassFormatError: Inconsistent constant value type in class file data/hullmods/mm_hwi
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at org.codehaus.janino.JavaSourceClassLoader.defineBytecode(JavaSourceClassLoader.java:244)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:194)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]
to the knee.
It obviously tells me nothing as I am uneducated schmuck. Is the solution compiling it manually or something completly else?

Thank you from the mountain, as we say in my country.
I presume this is a loose file, rather than compiled?
The compiler packaged with the game really doesn't like generic object types.

If you just handle things on an individual basis, it's more work but the compiler doesn't argue. For example, here's my Missile-based variant:
Code
	public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.LARGE_MISSILE_MOD).modifyFlat(id, -10);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "10";
return null;
}

@Override
public boolean affectsOPCosts() {
return true;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on August 31, 2021, 09:02:22 AM
I'm having a bit of trouble with a deco weapon- I've set it to display hull damage decals, but it's not. It's in a deco slot too, in case that's an issue. The deco weapon goes over the large slot, and under everything else, which I've set using renderOrderMod in the .ship file.

.wpn file:
Spoiler
{
   "id":"apex_deco_caiman_center",
   "specClass":"beam",
   "type":"DECORATIVE",
   "size":"LARGE",
   "showDamageWhenDecorative":true,
   "renderBelowAllWeapons":false,
   "turretSprite":"graphics/ships/decos/apex_caiman_center.png",
   "hardpointSprite":"graphics/ships/decos/apex_caiman_center.png",
   "turretOffsets":[0, 0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[0, 0],
   "hardpointAngleOffsets":[0],   
   "fringeColor":[255,255,255,255],
   "coreColor":[255,255,255,255],
   "glowColor":[255,255,255,255],
   "width":1.0,
   "textureType":ROUGH,
   "textureScrollSpeed":1.0,
   "pixelsPerTexel":1.0,
}
[close]
(https://i.imgur.com/zQRHxwl.png)

Also, is there a way to figure out if a ship is trying to turn to present less-damaged armor? Like the bit where a ship has stripped armor and will try to turn away from that point if its shields are down.

may not be your paricular issue, but iirc what determines if the decal gets the damage overlay is if the cell of the ship its on takes damage. So if the decal isn't on those exact coordinates where damage is taken, it won't be reflected
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 31, 2021, 09:04:27 AM
Hello,
I tried to make Heavy Weapons Integration, so in 1st step I took Heavy Ballistics Integration from source archive, changed the name wherever it was due, added .cvs entry accordingly and changed package name in code's first line to data.hullmods. Didnt change what it does yet, just wanted to see if the game would start.
Then I took
Spoiler
22456 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.mm_hwi]
java.lang.RuntimeException: Error loading [data.hullmods.mm_hwi]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassFormatError: Inconsistent constant value type in class file data/hullmods/mm_hwi
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at org.codehaus.janino.JavaSourceClassLoader.defineBytecode(JavaSourceClassLoader.java:244)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:194)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]
to the knee.
It obviously tells me nothing as I am uneducated schmuck. Is the solution compiling it manually or something completly else?

Thank you from the mountain, as we say in my country.
I presume this is a loose file, rather than compiled?
The compiler packaged with the game really doesn't like generic object types.

This is very true, yeah. In addition:

public static final float COST_REDUCTION  = 10;

I think it doesn't like a float being assigned an int value. Changing the "10" to a "10f" might also get around that issue.

may not be your paricular issue, but iirc what determines if the decal gets the damage overlay is if the cell of the ship its on takes damage. So if the decal isn't on those exact coordinates where damage is taken, it won't be reflected

(Ahh, good catch!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Omnicast on August 31, 2021, 10:47:38 PM
Just throwing ideas out there. Is it possible for Alex to get fighter/bomber/drone LPCs to spawn multiple wings from one hanger slot? Would it be possible to make it adjustable in game? So each LPC has a min/max and the player can choose a number from min to max using +/- buttons next to the hanger slot. The higher the number the more penalties to rearming/crew required/supplies needed/etc, but you can burst the enemy down with more small crafts.

So if I modified the Talon Interceptor Wing LPC it would spawn 5 wings of 4 fighters each for a grand total of 20 fighters using one hanger slot. Of course it's gonna cost 5x more crew, supplies, and CR to recover fully.

Anyways the point is I want my computer to overload with fighters/bombers/drones swarming everywhere.

Second idea... is it possible for some badass animator to make fighters do flips and ***? Like barrel rolls? Maybe it actually has a function like giving a dodge bonus or temp invulnerability while looking cool.

Idea three. Pilot promotions. After a few space battles there's a chance that some Talon pilot actually survives enough times to be qualified as a experienced pilot. This could tie in with my first idea and a more experienced pilot could act like a squad leader allowing more wings to watch his/her flank. They can level up like officers and pick Pilot skills. Some of which could have cool animations like my second idea.

Stealing ideas from 1C's Star Wolves series they could get active special abilities that they will automatically use when the right situation calls for it. Missiles heading their way? If the pilot has the flares ability then the small craft/assisting wings will fire off personally mounted flares.

Or the pilot has an alpha strike ability that increases fire rate for all weapons on the craft being piloted by 20-40% for 4 seconds with a CD of 30 seconds.

Stealing from Star Fox we could have a tiny window open up where the pilot's sprite is shown and a small dialogue oozing overconfidence! Said overconfident Talon pilot dies right away.  ;D

Feeling ambitious? Animate the pilots portrait!

This will make me take recovery shuttles. Otherwise that mod is god damn useless.  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on September 02, 2021, 04:46:45 PM
For
Global.getSector().getPlayerPerson().getStats().setSkillLevel();
Presuming the Sector,PersonAPI and their stats are not null, what would cause this loc to cause a NPE?
I've been stumped on this one for a bit. I have a skill added to a mod that runs this line in the ModPlugins onGameLoad. It works for me, but it always results in NPE for the person testing when they trying loading up a game.

The only way I can reproduce this is by completely deleting the skills folder and trying to load, but even when I provided them with my data folder, it still crashes. Is there anyway another skill could be somehow overwriting the  one i've added, or something like that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2021, 04:48:42 PM
Just real quick - need to see a stack trace for this sort of thing.

(But, yeah, my initial guess would be a skill id getting passed in that doesn't match any actual skill...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on September 02, 2021, 04:50:26 PM
whoops, here it is.

118067 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
    at com.fs.starfarer.campaign.CharacterStats.refreshCharacterStatsEffects(Unknown Source)
    at com.fs.starfarer.campaign.CharacterStats.setSkillLevel(Unknown Source)
    at data.scripts.MechaModPlugin.onGameLoad(MechaModPlugin.java:127)
    at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
    at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
    at com.fs.starfarer.ui.Oo0O.dismiss(Unknown Source)
    at com.fs.starfarer.ui.impl.o0oO.dismiss(Unknown Source)
    at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
    at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
    at com.fs.starfarer.ui.I.?00000(Unknown Source)
    at com.fs.starfarer.ui.I.processInput(Unknown Source)
    at com.fs.starfarer.ui.newnew.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
    at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
    at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
    at com.fs.starfarer.coreui.oo0o.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
    at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
    at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
    at com.fs.starfarer.E.I.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
    at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
    at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.Oo0O.processInputImpl(Unknown Source)
    at com.fs.starfarer.campaign.save.J.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
    at com.fs.starfarer.ui.v.dispatchEventsToChildren(Unknown Source)
    at com.fs.starfarer.ui.v.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.o00O.processInput(Unknown Source)
    at com.fs.starfarer.title.TitleScreenState.processInput(Unknown Source)
    at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
    at com.fs.state.AppDriver.begin(Unknown Source)
    at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2021, 04:55:50 PM
Thank you! Unfortunately that's a pretty long method so it doesn't narrow things down much.

There has to be some difference between your setup and the setup of the person helping you test (mods enabled, mod versions?, settings tweaks, etc). If it's a possibility, I'd suggest trying to eliminate those differences until you find what's causing the issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 02, 2021, 07:18:25 PM
How do I edit the effects of special items on industries? The special_items.csv only seems to list general things like graphics, price, description etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 02, 2021, 07:38:31 PM
Thank you! Unfortunately that's a pretty long method so it doesn't narrow things down much.

There has to be some difference between your setup and the setup of the person helping you test (mods enabled, mod versions?, settings tweaks, etc). If it's a possibility, I'd suggest trying to eliminate those differences until you find what's causing the issue.
We found the issue to be an outdated version of Quality Captains that abuses the "replace" in the mod_info.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on September 05, 2021, 11:51:53 PM
Is there a way to pass float values into RepActionEnvelope instead of RepActions(Or is there way to create a custom one?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 06, 2021, 10:13:29 AM
Is there a way to pass float values into RepActionEnvelope instead of RepActions(Or is there way to create a custom one?)

There's a CustomRepImpact class you can pass in there; see: PunitiveExpeditionIntel.applyRepPenalty()

How do I edit the effects of special items on industries? The special_items.csv only seems to list general things like graphics, price, description etc.

Sorry I missed this!  See the ItemEffectsRepo class; you'll need to add your own effect to the static ITEM_EFFECTS map - you can do this from another class in your own code. Make sure not to have any data members in your InstallableItemEffect implementation since these persist across saves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on September 06, 2021, 05:54:39 PM
may not be your paricular issue, but iirc what determines if the decal gets the damage overlay is if the cell of the ship its on takes damage. So if the decal isn't on those exact coordinates where damage is taken, it won't be reflected

this is hugely useful, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 06, 2021, 07:34:50 PM
How do I edit the effects of special items on industries? The special_items.csv only seems to list general things like graphics, price, description etc.

Sorry I missed this!  See the ItemEffectsRepo class; you'll need to add your own effect to the static ITEM_EFFECTS map - you can do this from another class in your own code. Make sure not to have any data members in your InstallableItemEffect implementation since these persist across saves.

Wait, but where do I find this? I don’t seem to be able to find it in special_items.csv and no other file seems to contain relevant data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 06, 2021, 07:48:51 PM
How do I edit the effects of special items on industries? The special_items.csv only seems to list general things like graphics, price, description etc.

Sorry I missed this!  See the ItemEffectsRepo class; you'll need to add your own effect to the static ITEM_EFFECTS map - you can do this from another class in your own code. Make sure not to have any data members in your InstallableItemEffect implementation since these persist across saves.

Wait, but where do I find this? I don’t seem to be able to find it in special_items.csv and no other file seems to contain relevant data.
It's in code; com.fs.starfarer.api.impl.campaign.econ.impl.ItemEffectsRepo
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 06, 2021, 09:13:51 PM
True, a while after I wrote that I managed to find it. However, I still do have a question:

How do I tweak an item to only boost production to only a single supplied commodity of an industry? Say, I want the special item to only increase supply of Metals from a Refining, instead of increasing both Metals and Transplutonics production.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 08, 2021, 08:06:19 AM
About DamageListener...seems that if hit by a beam, the damage would be unreasonable....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 08, 2021, 10:23:43 AM
How do I tweak an item to only boost production to only a single supplied commodity of an industry? Say, I want the special item to only increase supply of Metals from a Refining, instead of increasing both Metals and Transplutonics production.

If you look in the ItemEffectsRepo class you should find some examples of similar things.

About DamageListener...seems that if hit by a beam, the damage would be unreasonable....

Hmm? I'm not sure I understand what the question is here, if there is one. AFAIK it would reportDamageApplied() every beam tick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 08, 2021, 06:11:03 PM
Hmm? I'm not sure I understand what the question is here, if there is one. AFAIK it would reportDamageApplied() every beam tick.
So while I get the damage from result, beam damage seems to be much more than other damage...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 08, 2021, 06:18:08 PM
Hmm - this sort of thing in a hullmod:
Code
@Override
public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
ship.addListener(new DamageListener() {
public void reportDamageApplied(Object source, CombatEntityAPI target, ApplyDamageResultAPI result) {
System.out.println(result.getDamageToHull());
System.out.println(result.getTotalDamageToArmor());
}
});
}
Seems to produce as-expected results.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 08, 2021, 06:43:22 PM
Hmm - this sort of thing in a hullmod:
Code
@Override
public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
ship.addListener(new DamageListener() {
public void reportDamageApplied(Object source, CombatEntityAPI target, ApplyDamageResultAPI result) {
System.out.println(result.getDamageToHull());
System.out.println(result.getTotalDamageToArmor());
}
});
}
Seems to produce as-expected results.
Oh...seems that there are some struncture problems in my code which would multiple the damage...Thanks for explanation :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 08, 2021, 06:57:50 PM
No problem, glad you figured it out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on September 08, 2021, 08:19:11 PM
What do the MOVEMENT_DEST and REACHED_WAYPOINT ship AI flags mean? I'm working on a toggleable long-range travel drive system, and need some way to figure out if the ship AI is close to a place it wants to stop.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 08, 2021, 08:32:40 PM
What do the MOVEMENT_DEST and REACHED_WAYPOINT ship AI flags mean? I'm working on a toggleable long-range travel drive system, and need some way to figure out if the ship AI is close to a place it wants to stop.
MOVEMENT_DEST iirc gets set to a Vector2f with the location of whatever task the ship is currently assigned. REACHED_WAYPOINT is... not anything meaningful right now and is generally not set.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on September 09, 2021, 01:55:14 PM
Hi! I'm new to the forum.

Where is GroundRaidObjectivePlugin in the API/scripts? GroundRaidTargetPickerDelegate, losses, and a lot of other scripts refer to it, but I haven't a devil of a clue where it is.

For reference, what I'm trying to implement is a hullmod that adds a 200 ground support per 100 marines instead of merely 1 support 1 marine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 09, 2021, 05:56:49 PM
Hi! I'm new to the forum.

Where is GroundRaidObjectivePlugin in the API/scripts? GroundRaidTargetPickerDelegate, losses, and a lot of other scripts refer to it, but I haven't a devil of a clue where it is.

For reference, what I'm trying to implement is a hullmod that adds a 200 ground support per 100 marines instead of merely 1 support 1 marine.
For the plugins themselves (crossposting from Discord), search for extends BaseGroundRaidObjectivePluginImpl in the API to find the different implementations. The GroundRaidObjectivePlugin interface itself is at com.fs.starfarer.api.impl.campaign.graid.

On the hullmod idea, I'm not actually sure it's possible to inject a ground support bonus that exceeds the marine count, without modifying MarketCMD...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on September 11, 2021, 06:24:00 PM
Is there any way to make a weapon  deco render BENEATH engines?  :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 11, 2021, 11:27:30 PM
When creating a fleet with a DelayedFleetEncounter (or some other hub mission), can I make the fleet scale to approximate a certain fraction of the player fleet's size/strength (e.g. "75% as strong as player")?

EDIT: Hmm, seems I can try estimating the desired size myself and using triggerSetFleetSizeFraction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on September 12, 2021, 08:58:39 AM
is there a way to determine the amount of currently installed vents and capacitors in the refit dialog in applyEffectsBeforeShipCreation? it appears that one of the calls to applyEffectsAfterShipCreation has the correct amount on the ship variant, but every other call to applyEffectsBeforeShipCreation and applyEffectsAfterShipCreation has the amount that is installed on the ship variant before the refit is opened.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 12, 2021, 11:09:46 AM
Is there any way to make a weapon  deco render BENEATH engines?  :'(

Hmm, I don't *think* so (and some brief checking doesn't turn up anything), though not quite 100% sure.

When creating a fleet with a DelayedFleetEncounter (or some other hub mission), can I make the fleet scale to approximate a certain fraction of the player fleet's size/strength (e.g. "75% as strong as player")?

EDIT: Hmm, seems I can try estimating the desired size myself and using triggerSetFleetSizeFraction.

Right, something like that would probably be the easiest way to go. For clarity, that fraction would be a fraction of the "maximum possible" fleet size (in fleet points) for that faction, given the hulls it has access to. You can get this value using faction.getApproximateMaxFPPerFleet().

Though, of course, "strength relative to the player's fleet" also involves officers, ship quality, and s-mods...


is there a way to determine the amount of currently installed vents and capacitors in the refit dialog in applyEffectsBeforeShipCreation? it appears that one of the calls to applyEffectsAfterShipCreation has the correct amount on the ship variant, but every other call to applyEffectsBeforeShipCreation and applyEffectsAfterShipCreation has the amount that is installed on the ship variant before the refit is opened.

I'm not sure what you're seeing, but something like:
Code
if (stats.getVariant() != null) {
stats.getHullBonus().modifyFlat(id, stats.getVariant().getNumFluxVents());
}
In applyEffectsBeforeShipCreation() seems to modify hull integrity by the correct number.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on September 12, 2021, 03:39:46 PM
Is there any way to make a weapon  deco render BENEATH engines?  :'(

Hmm, I don't *think* so (and some brief checking doesn't turn up anything), though not quite 100% sure.

When creating a fleet with a DelayedFleetEncounter (or some other hub mission), can I make the fleet scale to approximate a certain fraction of the player fleet's size/strength (e.g. "75% as strong as player")?

EDIT: Hmm, seems I can try estimating the desired size myself and using triggerSetFleetSizeFraction.

Right, something like that would probably be the easiest way to go. For clarity, that fraction would be a fraction of the "maximum possible" fleet size (in fleet points) for that faction, given the hulls it has access to. You can get this value using faction.getApproximateMaxFPPerFleet().

Though, of course, "strength relative to the player's fleet" also involves officers, ship quality, and s-mods...


is there a way to determine the amount of currently installed vents and capacitors in the refit dialog in applyEffectsBeforeShipCreation? it appears that one of the calls to applyEffectsAfterShipCreation has the correct amount on the ship variant, but every other call to applyEffectsBeforeShipCreation and applyEffectsAfterShipCreation has the amount that is installed on the ship variant before the refit is opened.

I'm not sure what you're seeing, but something like:
Code
if (stats.getVariant() != null) {
stats.getHullBonus().modifyFlat(id, stats.getVariant().getNumFluxVents());
}
In applyEffectsBeforeShipCreation() seems to modify hull integrity by the correct number.

the way i am using it is:

Code
    @Override
    public void applyAugmentToStats(FleetMemberAPI fm, MutableShipStatsAPI stats, float quality, String id) {
        int numCapsStats = stats.getVariant().getNumFluxCapacitors();
        int numVentsStats = stats.getVariant().getNumFluxVents();

        ExtraSystemHM.log.info(String.format("[%s] stats caps %s vents %s", this.getKey(), numCapsStats, numVentsStats));

        int maxCaps = (int) fm.getFleetCommander().getStats().getMaxCapacitorsBonus().computeEffective(MAX_FLUX_EQUIPMENT.get(fm.getHullSpec().getHullSize()));
        int maxVents = (int) fm.getFleetCommander().getStats().getMaxVentsBonus().computeEffective(MAX_FLUX_EQUIPMENT.get(fm.getHullSpec().getHullSize()));

        int crReduction = 0;
        if(numCapsStats > maxCaps / 2) {
            crReduction += numCapsStats - (maxCaps / 2);
        }

        if(numVentsStats > maxVents / 2) {
            crReduction += numVentsStats - (maxVents / 2);
        }

        if(crReduction > 0) {
            stats.getMaxCombatReadiness().modifyFlat(this.getName(), -crReduction / 100f, this.getName());
        }
    }

code is intended to reduce CR by 1 point for every capacitor and vent installed over half of their respective maximums.
upon opening the ship in refit, i see the below logs

Code
681716 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681716 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681717 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681719 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681719 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681720 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681721 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681721 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681722 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681723 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681755 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681757 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681758 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681758 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681761 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681761 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681762 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681763 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681763 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681764 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681766 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681770 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681771 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681772 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681773 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681774 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
681774 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14

when changing the vents to 15, i see the following
Code
750069 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750069 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750069 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750071 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750071 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750072 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750074 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750074 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750075 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750076 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 15
750104 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 15
750107 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750107 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750107 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750109 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750109 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750110 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750111 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750111 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750112 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750113 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 15
750118 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 15
750119 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750119 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750120 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750120 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14
750121 [Thread-3] INFO  extrasystemreloaded.hullmods.ExtraSystemHM  - [PlasmaCatalyst] stats caps 0 vents 14

to me it seems like certain stats objects are used for certain objects inside the refit dialog, so reducing the CR according to the current number of vents and capacitors without switching to/from another ship doesn't work properly for the displayed CR in the refit dialog. once exiting the refit dialog it applies correctly though, so more of a minor issue than an actual bug.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on September 14, 2021, 07:08:52 AM
Got inspired to pull an old hullmod out of mothball. It still doesn't work, feedback appreciated:

Spoiler
Code
	public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
if (stats.getVariant().getSMods().contains("ordstore")) {

stats.getDynamic().getMod(Stats.SMALL_BALLISTIC_MOD).modifyFlat(id, -1f);
stats.getDynamic().getMod(Stats.MEDIUM_BALLISTIC_MOD).modifyFlat(id, -2f);
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -4f);

stats.getCargoMod().modifyMult(id, 0.75f);

} else {

stats.getDynamic().getMod(Stats.SMALL_BALLISTIC_MOD).modifyFlat(id, -0f);
stats.getDynamic().getMod(Stats.MEDIUM_BALLISTIC_MOD).modifyFlat(id, -1f);
stats.getDynamic().getMod(Stats.LARGE_BALLISTIC_MOD).modifyFlat(id, -2f);

stats.getCargoMod().modifyMult(id, 0.5f);
}

}
[close]

Basically, if the mod is not built-in the Cargo and Ballistic mods apply as intended (yay!),
But when it is built in only the CargoMod updates, the ballistic mod doesn't update (nay!).

The IF values for the Ballistic mods do apply if the referenced hullmod is built in before applying this one. e.g. if I referenced turretgyros and had that built in as an SMod prior to applying this then the IF value would be used.
(Or the event of self referencing, the player can install it as an Smod, save, exit and reload to use the correct value)

So really, what I need is some way to force-update/reapply the hullmod after it is has been installed as an SMod.


I'm guessing we're back in "unsupported by game" territory as you outlined previously:

The other thing to get around somehow is the player installing the hullmod, using the extra OP, and then removing it.  Generally speaking the game assumes that hullmods that modify OP costs are non-removable, and breaking that assumption puts it into "unsupported by the game" territory. Not to say it couldn't be made to work somehow, perhaps!

The new plan was to have it modify the weapon OP only when the hullmod was built in (the else values are currently for testing purposes to check it initially applies). I've got a dirty dirty work around on standby if we can't get this working correctly (Make the OP cost for the hullmod more than any potential gains so you won't see the benefits unless you SMod it).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2021, 10:17:37 AM
the way i am using it is:

Ah, alright - it's possible what's in dev is working a bit differently, then.


But when it is built in only the CargoMod updates, the ballistic mod doesn't update (nay!).

Argh! After a bunch of digging, it looks like there's a vanilla bug here; fixed it up.

(Interestingly, I think if you build in reinforced bulkheads, then save and reload, it should apply the bonus, I believe.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on September 14, 2021, 12:40:42 PM
Argh! After a bunch of digging, it looks like there's a vanilla bug here; fixed it up.

(Interestingly, I think if you build in reinforced bulkheads, then save and reload, it should apply the bonus, I believe.)

Ah. Fair enough. Good to know it should be sorted.

Saving and reloading works even without bulkheads.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 14, 2021, 09:01:45 PM
I have engines that are color 255,125,25,255. I want to change them to 170,220,222,255 using ShipEngineControllerAPI.fadeToOtherColor(). What inputs do I need? Is it even possible? All I can get are shades of violet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dcong89 on September 15, 2021, 04:54:44 AM
sorry guys, i've got a problem but dont know how .The weapons everyship when firing it's fire backward and forward for example in attachement.



[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 15, 2021, 08:34:25 PM
I've got an issue with ship sale transactions in the listener.

So the ship says it sells for so much (and this is indeed the amount of credits I get):
(https://i.imgur.com/OSx1dFH.png)

But ShipSaleInfo.getPrice() in the PlayerMarketTransaction lists a much lower price:
694691 [Thread-3] INFO  exerelin.campaign.intel.merc.MercContractIntel  - Sale value: 54963.996
694691 [Thread-3] INFO  exerelin.campaign.intel.merc.MercContractIntel  - Sale value with tariff: 59910.758
694692 [Thread-3] INFO  exerelin.campaign.intel.merc.MercContractIntel  - Tariff: 0.09

Is the sale info doing something annoying like getting the ship price after the submarket cargo has already mothballed it?

sorry guys, i've got a problem but dont know how .The weapons everyship when firing it's fire backward and forward for example in attachement.
Sorry, it's not clear what's going on. Do you have a cleaner screenshot, with fewer things happening?

If the issue is what I think it is, first thing I'd check is whether the gun is actually firing in both directions (has a second fire offset in the weapon file, pointing backwards)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 16, 2021, 04:22:12 AM
I have engines that are color 255,125,25,255. I want to change them to 170,220,222,255 using ShipEngineControllerAPI.fadeToOtherColor(). What inputs do I need? Is it even possible? All I can get are shades of violet.

And today it's working the way I want. ???

Okay.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Primus on September 16, 2021, 05:59:54 AM
Greetings !

I am trying to edit the Drive Field Stabilizer hull mods (to reduce a litle bit its Increase of the sensor profile, and perhaps increase the burn bonus), but I am unable to find where it is located.

I used notepad++ to search the files of the game, but I didn't find anything, does anyone knows where it is?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 16, 2021, 09:51:16 AM
Is the sale info doing something annoying like getting the ship price after the submarket cargo has already mothballed it?

Yeah, that was exactly it! Fixed it up. The price should've just been passed in as a parameter to begin with, not sure how it ended up computing it twice.


Greetings !

I am trying to edit the Drive Field Stabilizer hull mods (to reduce a litle bit its Increase of the sensor profile, and perhaps increase the burn bonus), but I am unable to find where it is located.

I used notepad++ to search the files of the game, but I didn't find anything, does anyone knows where it is?

starfarer.api.zip has a bunch of source and among other things, that file is there. Keep in mind that just editing it in that file won't do anything - the source is just provided for reference. To change it, you'd need to make a mod that provides your own implementation, and a hull_mods.csv entry that points to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on September 16, 2021, 04:39:29 PM
Running into some weird stuff with mine behavior- I'm trying to make an anti-fighter mine, which necessitates having the mine not collide with friendlies. However, despite having the mine collision class and explosion collision class set to MISSILE_NO_FF, the mine will still collide with allies when it's in the windup phase. The explosion doesn't, but the mine will damage friendly ships if they run into it, and allies will try to rotate their shields towards the mine.

Is there some way to fix this, or do I just need to write an AI script that replicates the sound/flash/explosion behavior for a bomb projectile?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on September 16, 2021, 10:37:23 PM
Is there any way to dynamically modify the codex, planet/ship descriptions, or other such things not directly stored by rules.csv?

Specifically I'm interested in having some planetary descriptions modify based on the results of a quest.

edit:

I dropped an idiot box: the special quest ships do exactly that. I'll look at how they're implemented before asking any other questions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Primus on September 18, 2021, 12:53:15 PM

starfarer.api.zip has a bunch of source and among other things, that file is there. Keep in mind that just editing it in that file won't do anything - the source is just provided for reference. To change it, you'd need to make a mod that provides your own implementation, and a hull_mods.csv entry that points to it.

Thanks for your answer!

I tried to copy-paste the file so it goes inside [.]\Starsector\starsector-core\data\hullmods ; and changed the hull_mods.csv so that on the Drive Field Stabilizer line, it is written "hullmods.DriveFieldStabilizer" instead of "com.fs.starfarer.api.impl.hullmods.DriveFieldStabilizer" .
It didn't worked and crash the game at launch.  ???


On another point, I am not sure if it is the correct thread, but I am looking at the code in the saves to move star system :  I was expecting the coordinates of each star sector and the coordinates of its jump point to be somewhere in the  campaign.xml save file, but I have trouble to guess what they could be.

I tried to look for informations who are similar between two star system who are near to each other, but I didn't see anything that could be it ???.
 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 18, 2021, 06:00:52 PM
I tried to copy-paste the file so it goes inside [.]\Starsector\starsector-core\data\hullmods ; and changed the hull_mods.csv so that on the Drive Field Stabilizer line, it is written "hullmods.DriveFieldStabilizer" instead of "com.fs.starfarer.api.impl.hullmods.DriveFieldStabilizer" .
It didn't worked and crash the game at launch.  ???
Should be data.hullmods.DriveFieldStabilizer I think
(EDIT: and the package declaration at the top of the file should also be package data.hullmods;)

If it still fails, change the line
Code: java
public static final float BURN_BONUS = 1;
to
Code: java
public static final float BURN_BONUS = 1f;
If it still fails, check the error message (it'll be at the end of starsector-core/starsector.log when opened immediately following the crash).

(Also it's recommended to make your own mod rather than editing core files directly, to avoid stuff getting overwritten on a reinstall. But let's keep things simple for now.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Primus on September 19, 2021, 01:16:00 AM
If it still fails, change the line
Code: java
public static final float BURN_BONUS = 1;
to
Code: java
public static final float BURN_BONUS = 1f;

It worked !!  ;D

Thanks a lot !
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2021, 12:51:25 PM
Running into some weird stuff with mine behavior- I'm trying to make an anti-fighter mine, which necessitates having the mine not collide with friendlies. However, despite having the mine collision class and explosion collision class set to MISSILE_NO_FF, the mine will still collide with allies when it's in the windup phase. The explosion doesn't, but the mine will damage friendly ships if they run into it, and allies will try to rotate their shields towards the mine.

Is there some way to fix this, or do I just need to write an AI script that replicates the sound/flash/explosion behavior for a bomb projectile?

Hmm - I *think* if you call: missile.setNoFlameoutOnFizzling(true) on the mine when it's spawned then this should get around the issue.

Edit: just tried it and it seems to work. Also changed it to do this automatically for mines with MISSILE_NO_FF explosions since this behavior kind pretty much feels like a bug. Just a side effect of the mine technically "fizzling out" at some point in the process.

And, ah: you probably also want to call "missile.setNoMineFFConcerns(true)", that may or may not be necessary to get friendly ships to stop reacting to it as if it was a danger.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on September 19, 2021, 06:53:21 PM
Hmm - I *think* if you call: missile.setNoFlameoutOnFizzling(true) on the mine when it's spawned then this should get around the issue.

Edit: just tried it and it seems to work. Also changed it to do this automatically for mines with MISSILE_NO_FF explosions since this behavior kind pretty much feels like a bug. Just a side effect of the mine technically "fizzling out" at some point in the process.

And, ah: you probably also want to call "missile.setNoMineFFConcerns(true)", that may or may not be necessary to get friendly ships to stop reacting to it as if it was a danger.

setNoFlameoutOnFizzling doesn't appear to be exposed in the API. Fortunately, it seems that setting the missile's collision class to MISSILE_NO_FF every frame also fixes it. I can also confirm the second part works. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2021, 07:00:00 PM
Ah, I must've added it very recently, then. Glad you got this sorted out, though!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 20, 2021, 12:22:03 PM
Is there a limit on what the Historian can generate a blueprint for? Or some way to restrict a hull from being picked?

I like to dummy out stuff rather than remove it to help preserve saves, so I don't want them (or WIP stuff) getting blueprints created.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2021, 12:41:29 PM
It's based on the histXt tags where X is a 1, 2, or 3; "t" stands for "tier".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 20, 2021, 12:52:00 PM
Ah, so opt-in rather than opt-out? Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 20, 2021, 02:33:29 PM
Yep!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 20, 2021, 03:42:50 PM
How do I edit specific industries to spawn in a market(where do I find the plug-in?)? I’ve checked and there doesn’t seem to be individual plugins for markets and the system api doesn’t seem to contain that kind of information.

Also, would it be advisable to make a mod that adds markets/tweaks existing markets of an already existent Core World? I’ve noticed that no other mod directly adds markets to vanilla core worlds unless it’s Nex, hence I’m presuming it takes some sort of overriding the vanilla code that makes it too much of a hassle to be fun.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 21, 2021, 01:06:25 PM
So I found out scientist contact did nothing.. will there be missions for them in 0.951  ???
Title: Hi
Post by: Kolokol on September 21, 2021, 01:13:00 PM
Hello,

I have this mod idea, about fight simulation as I am not entirely sure how "Order your second in-command" works.

Would it be possible to make combat run REALLY fast? We do have with "SpeedUp" addon, but the idea would be to disable rendering, for faster processing, and run multiple simulations of fight at high speeds and provide a player an option to skip fight if the average of simulations satisfies him.

Maybe someone has done it already?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 21, 2021, 06:31:22 PM
How do I edit specific industries to spawn in a market(where do I find the plug-in?)? I’ve checked and there doesn’t seem to be individual plugins for markets and the system api doesn’t seem to contain that kind of information.

Also, would it be advisable to make a mod that adds markets/tweaks existing markets of an already existent Core World? I’ve noticed that no other mod directly adds markets to vanilla core worlds unless it’s Nex, hence I’m presuming it takes some sort of overriding the vanilla code that makes it too much of a hassle to be fun.
Global.getSector().getEconomy().getMarket(id).addIndustry(industryId);

Mods can add markets to a vanilla star system the same way they add one to a modded star system; Shadowyards has an updated-for-0.95 example. Nex and Industrial.Evolution both add industries to existing core markets. This stuff isn't done too often, which is good since if a lot of people were doing it mods would start conflicting.

Would it be possible to make combat run REALLY fast? We do have with "SpeedUp" addon, but the idea would be to disable rendering, for faster processing, and run multiple simulations of fight at high speeds and provide a player an option to skip fight if the average of simulations satisfies him.

Maybe someone has done it already?
Don't think it's currently possible; e.g. Dark.Revenant doesn't mention it in the Station Balance testing thread (https://fractalsoftworks.com/forum/index.php?topic=15758) (from 2019), where it would have been pretty useful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 21, 2021, 07:02:39 PM
So I found out scientist contact did nothing.. will there be missions for them in 0.951  ???

There could be missions for them now, if you added them :)


Don't think it's currently possible; e.g. Dark.Revenant doesn't mention it in the Station Balance testing thread (https://fractalsoftworks.com/forum/index.php?topic=15758) (from 2019), where it would have been pretty useful.

Right, yeah - and just on the performance side of things, it's completely unviable. At best - for a smaller fight, and if it were possible at all - it'd speed the fight up maybe by 10x.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 22, 2021, 12:22:26 AM
How do I edit specific industries to spawn in a market(where do I find the plug-in?)? I’ve checked and there doesn’t seem to be individual plugins for markets and the system api doesn’t seem to contain that kind of information.

Also, would it be advisable to make a mod that adds markets/tweaks existing markets of an already existent Core World? I’ve noticed that no other mod directly adds markets to vanilla core worlds unless it’s Nex, hence I’m presuming it takes some sort of overriding the vanilla code that makes it too much of a hassle to be fun.
Global.getSector().getEconomy().getMarket(id).addIndustry(industryId);

Mods can add markets to a vanilla star system the same way they add one to a modded star system; Shadowyards has an updated-for-0.95 example. Nex and Industrial.Evolution both add industries to existing core markets. This stuff isn't done too often, which is good since if a lot of people were doing it mods would start conflicting.

I’m also interested in where to find it in the api, since I’ve been looking for it and can’t find it.

Now I also have a different question: After digging through the system code of some mods, it seems they either follow the vanilla style of not adding industries/conditions to their planets in said system code(mostly ORA), while other mods use ArrayLists to state clearly industries/conditions(XLU/VIC/SCY etc). I don’t really get why there are these two coding types here, is it a compatibility issue that got jury rigged to workability or just a stylistic/convenience decision that doesn’t affect much?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 24, 2021, 06:50:08 PM
Asking for the daddy in Discord.

This doesn't work according to him as a plugin. The daddy wants to replace your script.

Code
package sstest;

import org.lazywizard.console.Console;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.GenericPluginManagerAPI;
import com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3;
import com.fs.starfarer.api.impl.campaign.fleets.FleetParamsV3;
import com.fs.starfarer.api.plugins.CreateFleetPlugin;

import sstest.utils.Utils;

public class SSTestCreateFleetPlugin implements CreateFleetPlugin {

    @Override
    public int getHandlingPriority(Object params) {
        return GenericPluginManagerAPI.MOD_GENERAL;
    }

    @Override
    public CampaignFleetAPI createFleet(FleetParamsV3 params) {

        CampaignFleetAPI fleet = FleetFactoryV3.createFleet(params);
        Console.showMessage("Fleet has been created:\nSystem: " + fleet.getContainingLocation().getName() + "\nName: " + fleet.getFullName() + "\nCommander: " + fleet.getCommander().getNameString() + "Faction: " + fleet.getFaction().getDisplayName() + "\n");
        Utils.SetMemKey(Constants.MEMORY_KEY_TEST_DATA, params);
       
        return fleet;
    }

}
Daddy's setting.json
Code
{
    "plugins":{
        "SSTestCreateFleetPlugin":"sstest.SSTestCreateFleetPlugin"
    }
}
Help?  ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 24, 2021, 07:02:11 PM
I’m also interested in where to find it in the api, since I’ve been looking for it and can’t find it.
com.fs.starfarer.api.campaign.econ.MarketAPI

Have you been looking in starfarer_api.zip? If you have an IDE and add it to source, you can jump to any API class/method by Ctrl-clicking it in the IDE (at least that's the shortcut in NetBeans, dunno if other IDEs do it differently). Also you can search for stuff in the extracted folder with Notepad++ or similar.

Quote
Now I also have a different question: After digging through the system code of some mods, it seems they either follow the vanilla style of not adding industries/conditions to their planets in said system code(mostly ORA), while other mods use ArrayLists to state clearly industries/conditions(XLU/VIC/SCY etc). I don’t really get why there are these two coding types here, is it a compatibility issue that got jury rigged to workability or just a stylistic/convenience decision that doesn’t affect much?
Think it's just a 'pick whatever you prefer' thing, although the code approach is needed if you're adding markets after game start. Also I think the config JSONs didn't exist in earlier versions of the game?

Asking for the daddy in Discord.

This doesn't work according to him as a plugin. The daddy wants to replace your script.
Daddy needs to register the plugin in code (not the settings.json). Example from my test mod:
Code
@Override
public void onGameLoad(boolean newGame) {
Global.getSector().getGenericPlugins().addPlugin(new TestCreateFleetPlugin(), true);  // second arg makes it transient
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2021, 07:07:02 PM
Ah - the plugins section in settings.json is not for stuff like that, it's for things where there's one specific implementation the game will use (e.g. the officer level up plugin, or the surveying plugin), not where the game picks one of several possible implementations depending on what it's dealing with.

What you want is SectorAPI.getGenericPlugins().addPlugin().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 24, 2021, 07:13:30 PM
Asking for the daddy in Discord.

This doesn't work according to him as a plugin. The daddy wants to replace your script.
Daddy needs to register the plugin in code (not the settings.json). Example from my test mod:
Code
@Override
public void onGameLoad(boolean newGame) {
Global.getSector().getGenericPlugins().addPlugin(new TestCreateFleetPlugin(), true);  // second arg makes it transient
}
Ah - the plugins section in settings.json is not for stuff like that, it's for things where there's one specific implementation the game will use (e.g. the officer level up plugin, or the surveying plugin), not where the game picks one of several possible implementations depending on what it's dealing with.

What you want is SectorAPI.getGenericPlugins().addPlugin().
Ok thank u.u
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2021, 07:16:36 PM
(Oh, durr, I didn't see Histidine's reply! Half asleep over here, sorry.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 25, 2021, 08:06:59 PM
I’m also interested in where to find it in the api, since I’ve been looking for it and can’t find it.
com.fs.starfarer.api.campaign.econ.MarketAPI

Have you been looking in starfarer_api.zip? If you have an IDE and add it to source, you can jump to any API class/method by Ctrl-clicking it in the IDE (at least that's the shortcut in NetBeans, dunno if other IDEs do it differently). Also you can search for stuff in the extracted folder with Notepad++ or similar.

Quote
Now I also have a different question: After digging through the system code of some mods, it seems they either follow the vanilla style of not adding industries/conditions to their planets in said system code(mostly ORA), while other mods use ArrayLists to state clearly industries/conditions(XLU/VIC/SCY etc). I don’t really get why there are these two coding types here, is it a compatibility issue that got jury rigged to workability or just a stylistic/convenience decision that doesn’t affect much?
Think it's just a 'pick whatever you prefer' thing, although the code approach is needed if you're adding markets after game start. Also I think the config JSONs didn't exist in earlier versions of the game?

Thanks, though I believe I have found success in coding the industries and conditions through arraylists. Another question(sorry for all the questions lo, im pretty new to modding) though, how do I override the default(vanilla) Askonia file to use my own? Currently it seems that the game is using the default Askonia file instead of the one in my mod so changes are not applying.

Edit: After temporarily removing the vanilla Askonia file and adding the new one in, the markets still don’t spawn. I’m guessing something is wrong somewhere in the code itself too.

(The code, for reference)
https://imgur.com/MxfE3Pp (https://imgur.com/MxfE3Pp)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on September 26, 2021, 07:34:15 PM
Is it possible to disable and hide/enable and show weapon mounts with a hullmod by playing with the variant or something?
Kind of like the damaged weapon mounts thing, but without a skin file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on September 27, 2021, 04:43:10 AM
I was wondering if there was a way to show the mining strength of each weapon and ship as you hover over them as an additional stat. I know that Nex has a list that pops up when you click on a planet and ask it to list them so those stats are out there. However that list does not seem to include some weapons and drones from other mods.

It is a feature I've wanted for awhile but never asked until I came across theDragn's WhicMod and realized it was possible to show additional text on each ship and weapon regardless of what mod it comes from. TY
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 27, 2021, 12:18:53 PM
Working with Contacts now... (shaking... developing something with milk)

If I don't want a particular contact mission to show up in the bar at all BUT not restrict it to a person_id. How would I do this? Because the person that hands out these type of contact missions can differ in procgen of my contact printer that prints out contact cards for the player to call.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 27, 2021, 05:37:54 PM
It is a feature I've wanted for awhile but never asked until I came across theDragn's WhicMod and realized it was possible to show additional text on each ship and weapon regardless of what mod it comes from. TY

WhichMod uses a hack - it edits every mod's description files. Useful, mostly harmless, but a hack nonetheless.


Working with Contacts now... (shaking... developing something with milk)

If I don't want a particular contact mission to show up in the bar at all BUT not restrict it to a person_id. How would I do this? Because the person that hands out these type of contact missions can differ in procgen of my contact printer that prints out contact cards for the player to call.

PersonAPIs have memory that you can put a memory key in - then you just look for contacts that have that memory key.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 27, 2021, 07:08:47 PM
PersonAPIs have memory that you can put a memory key in - then you just look for contacts that have that memory key.

You misunderstood. I'm making a custom contact mission right now and it's spawning in bar events even though I don't want it to. >.>

Oh maybe it's something when I copied too much. Let's see... silly me. I copied it into BAR_EVENTS.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 27, 2021, 07:25:00 PM
Oh, lol, didn't see it was you, Techpriest, sorry :P don't mind me stating basic modding stuff at you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 27, 2021, 08:24:09 PM
I wanted to make a mod that the Player Faction does not select the portrait the player has currently by thinking there would be a removePortrait similar to removeKnown[stuff].

I'm saddened to see that the FactionAPI does not contain a removePortrait nor a getPortrait that returns a set (instead of a weightrandompicker). I'd like for the player to be able to choose their set of portraits on a new game start, but then remove those portraits for their player faction portraits.

May I ask for a request for this in the next version?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on September 28, 2021, 12:41:46 AM
It is a feature I've wanted for awhile but never asked until I came across theDragn's WhicMod and realized it was possible to show additional text on each ship and weapon regardless of what mod it comes from. TY

WhichMod uses a hack - it edits every mod's description files. Useful, mostly harmless, but a hack nonetheless.

Thank you for pointing that out SafariJohn. The more I look into it I do not think it would work anyway since there seems to be two different ways mining is handled and it is separate from the weapon and ship files.

I've been digging around various mods to see how they interact with Nexerelin’s mining mini game. I noted that some have two files in the data folder "\data\config\exerelin". The first seems to be for mining weapons (mining_weapons.csv) and the second for mining ships (mining_ships.csv).

On top of the mining_ships.csv and mining_weapons.csv files I have also learned that mining values can also be set in modSettings.json (found in \data\config) under the lines "mining_ship_strengths" and "mining_weapon_strengths". This is how Nexerelin does it in its own folders for vanilla stuff and how some mods like Scy do it.

Essentially it looks like Nexerelin originally used those csv files because I had noticed that in Nexerelin those files just say "#deprecated; use modSettings.json instead,," but 4 of the mods I checked (haven’t checked them all) still used the mining_ships.csv and mining_weapons.csv files.

This is becoming a deeper rabbit hole than I had expected lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 28, 2021, 03:21:49 AM
Is there a way to add "gas giant" condition to a planet(or in this case, station)? Specifically, the one that allows Plasma Dynamo to work properly. I tried "GAS_GIANT" and it doesn't exist.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2021, 10:56:11 AM
Edit: After temporarily removing the vanilla Askonia file and adding the new one in, the markets still don’t spawn. I’m guessing something is wrong somewhere in the code itself too.

If it wasn't mentioned already, make sure that the folder path for your Askonia.java file is correct - same as in vanilla. Other than that, maybe try some minor changes to make sure that it works? Also, maybe goes without saying, but you need to start a new game for changes in that kind of file to apply.

Is it possible to disable and hide/enable and show weapon mounts with a hullmod by playing with the variant or something?
Kind of like the damaged weapon mounts thing, but without a skin file?

I don't think so, not without a .skin file.

I wanted to make a mod that the Player Faction does not select the portrait the player has currently by thinking there would be a removePortrait similar to removeKnown[stuff].

I'm saddened to see that the FactionAPI does not contain a removePortrait nor a getPortrait that returns a set (instead of a weightrandompicker). I'd like for the player to be able to choose their set of portraits on a new game start, but then remove those portraits for their player faction portraits.

May I ask for a request for this in the next version?

(Not the right thread for modding feature requests!) That said, the player's portrait should already be extremely unlikely to be picked for a player-faction NPC. It's still possible but it'd have to get picked like 5 times in a row.

Is there a way to add "gas giant" condition to a planet(or in this case, station)? Specifically, the one that allows Plasma Dynamo to work properly. I tried "GAS_GIANT" and it doesn't exist.

The market conditions are defined in data/campaign/market_conditions.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on September 28, 2021, 01:16:26 PM
I wanted to make a mod that the Player Faction does not select the portrait the player has currently by thinking there would be a removePortrait similar to removeKnown[stuff].

From AO as an example. Afaik this works though I'm not 100% sure I actually tested it thoroughly.

Code
    // Used by the mod plugin to remove faction portraits from the player faction after the player portrait is selected.
    public void removePortraits(String faction) {
        if (faction == null) {
            return;
        }

        WeightedRandomPicker<String> factionMalePortraitIDs = new WeightedRandomPicker<>();
        WeightedRandomPicker<String> factionFemalePortraitIDs = new WeightedRandomPicker<>();

        factionMalePortraitIDs.addAll(Global.getSector().getFaction(faction).getPortraits(FullName.Gender.MALE));
        factionFemalePortraitIDs.addAll(Global.getSector().getFaction(faction).getPortraits(FullName.Gender.FEMALE));

        List<String> maleIDs = factionMalePortraitIDs.getItems();
        Iterator<String> maleIDsIterator = maleIDs.iterator();
        while (maleIDsIterator.hasNext()) {
            Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).remove(maleIDsIterator.next());
        }

        List<String> femaleIDs = factionFemalePortraitIDs.getItems();
        Iterator<String> femaleIDsIterator = femaleIDs.iterator();
        while (femaleIDsIterator.hasNext()) {
            Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).remove(femaleIDsIterator.next());
        }
    }

And I've tested this and I know it worked at the time:

Code

    // Used by the rule command and also available for use in other classes. (See: CheckCommissionForPortraitLocks.java)
    // Passing in "all" as the faction id sets all available portraits depending upon faction rep with some factions.
    public void setPortraits(String faction) {
        if (faction == null) {
            return;
        }

        WeightedRandomPicker<String> factionMalePortraitIDs = new WeightedRandomPicker<>();
        WeightedRandomPicker<String> factionFemalePortraitIDs = new WeightedRandomPicker<>();

        if (!faction.equalsIgnoreCase("all")) {
            factionMalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.MALE);
            factionFemalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.FEMALE);
        } else {
            List<FactionAPI> allFactions = Global.getSector().getAllFactions();
            Iterator<FactionAPI> iterator = allFactions.iterator();
            FactionAPI playerFaction = Global.getSector().getPlayerFaction();
            String nextFaction;

            while (iterator.hasNext()) {
                nextFaction = iterator.next().getId();

                if (checkForBlacklistedFactions(nextFaction)) {
                    factionMalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.MALE));
                    factionFemalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.FEMALE));
                }
            }
            if (playerFaction.isAtWorst(ArcheusFactions.ADAMANTINE, RepLevel.FAVORABLE)) {
                factionMalePortraitIDs.addAll(Global.getSector().getFaction("adamantine_consortium").getPortraits(FullName.Gender.MALE));
                factionFemalePortraitIDs.addAll(Global.getSector().getFaction("adamantine_consortium").getPortraits(FullName.Gender.FEMALE));
            }
            if (playerFaction.isAtWorst(ArcheusFactions.ARCHEUS, RepLevel.FRIENDLY) || Misc.getCommissionFactionId().equalsIgnoreCase("archean_order")) {
                factionMalePortraitIDs.addAll(Global.getSector().getFaction("archean_order").getPortraits(FullName.Gender.MALE));
                factionFemalePortraitIDs.addAll(Global.getSector().getFaction("archean_order").getPortraits(FullName.Gender.FEMALE));
            }
        }

        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).clear();
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).clear();
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).addAll(factionMalePortraitIDs);
        Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).addAll(factionFemalePortraitIDs);
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kolokol on September 28, 2021, 02:59:43 PM
Hello!

I was wondering, maybe someone has done or has attempted to do a mod, that lets you visually change the paint job on a ship?
Like change the sprite of your Paragon to Ludic colours or Hegemony. Add in stripe/fractal/tribal effects to mix it a bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: geminitiger on September 28, 2021, 11:54:15 PM
How would I change the required 20,000 metal requirement for a Hypershunt?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 29, 2021, 12:41:33 AM
Is there a way to add "gas giant" condition to a planet(or in this case, station)? Specifically, the one that allows Plasma Dynamo to work properly. I tried "GAS_GIANT" and it doesn't exist.

The market conditions are defined in data/campaign/market_conditions.csv

I checked, and it seems there’s no defined Gas Giant condition. Which is odd, because Plasma Dynamo in ItemEffectsRepo defined “GAS_GIANT” and “NOT_A_GAS_GIANT” which I don’t know how it defines as a gas giant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 29, 2021, 05:03:11 AM
Whether a planet type is a gas giant or not is defined in planets.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 29, 2021, 05:06:50 AM
Whether a planet type is a gas giant or not is defined in planets.json.

Well, then is it possible to list a market as a gas giant for Plasma Dynamo compatibility?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 29, 2021, 05:22:43 AM
No. It checks the planet, not the market.

You might be able to override Plasma Dynamo's implementation so it looks for a market condition instead, but I'm not 100% sure of that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 29, 2021, 05:43:37 AM
Well for one I know that TASC's stations are considered gas giants, and the market I am talking about is a station so I'm not sure if they count as gas giants too
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on September 30, 2021, 04:36:44 AM
Question related to fixed derelict spawns as I try to fix something:

I went into Galatia.java in data\scripts\world\systems and changed the fixed derelicts that spawn in Tetra orbit in the various addDerelict lines, for example:
addDerelict(system, tetra, "hammerhead_Balanced", ShipCondition.AVERAGE, 450f, true);
changed to
addDerelict(system, tetra, "enforcer_Outdated", ShipCondition.BATTERED, 450f, false);

However, when starting a new game the original derelicts (the guaranteed recovery Hammerhead, the two Kites etc) always spawn instead of the newly specified ones from the modified Galatia.java file - even if the "tutorial" is bypassed with a mod.

I don't know why and would like help, thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on September 30, 2021, 06:21:30 AM
is it possible to create a mod that allows 4x or even 10x on the campaign screen?
preferably with a different button from the 2x



also, how would one make a ship use the broadside ai more frequently?
it doesnt seem like just putting combat weapons in the big rear mounts works
it may be worth mentioning the ship i intend to do this with is a mod ship: the izar from hyperion systems
it has two large mounts, one forward one back- i want it to circle ships and broadside, considering that layout, but it seems to want to just point directly at whatever its target is, even though i put the main battery on the back (it is after all a civ turned combat sort of ship with high campaign speed, so theoretically should be powerful on the retreat)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2021, 09:44:34 AM
I was wondering, maybe someone has done or has attempted to do a mod, that lets you visually change the paint job on a ship?
Like change the sprite of your Paragon to Ludic colours or Hegemony. Add in stripe/fractal/tribal effects to mix it a bit.

I don't think that's really doable; if you want a decent paintjob that pretty much means you've got to have that sprite made. Slapping some patterns onto an existing hull isn't going to look good (or easily work with the engine, but that's another point...)


How would I change the required 20,000 metal requirement for a Hypershunt?

Search rules.csv for:
$metalsReq = 20000 0

And then make your own mod wit a rule with the same id that changes that number to whatever you like.


I checked, and it seems there’s no defined Gas Giant condition. Which is odd, because Plasma Dynamo in ItemEffectsRepo defined “GAS_GIANT” and “NOT_A_GAS_GIANT” which I don’t know how it defines as a gas giant.

Ah, those aren't market conditions, not necessarily/directly.

See: BaseInstallableItemEffect.getUnmetRequirements()

For details on how that all works, if you're curious.


Question related to fixed derelict spawns as I try to fix something:

I went into Galatia.java in data\scripts\world\systems and changed the fixed derelicts that spawn in Tetra orbit in the various addDerelict lines, for example:
addDerelict(system, tetra, "hammerhead_Balanced", ShipCondition.AVERAGE, 450f, true);
changed to
addDerelict(system, tetra, "enforcer_Outdated", ShipCondition.BATTERED, 450f, false);

However, when starting a new game the original derelicts (the guaranteed recovery Hammerhead, the two Kites etc) always spawn instead of the newly specified ones from the modified Galatia.java file - even if the "tutorial" is bypassed with a mod.

I don't know why and would like help, thanks in advance.

Hmm. Did you restart the application before starting a new game? Changes to these files (and in general, except for rules.csv) require the application to be restarted to take effect.

Also: if you've got mods enabled and are editing the base Galatia.java file, it's possible that a mod is overriding it.

And, finally, if you use notepad or some such, sometimes when you save it'll add a .txt extension to the file and especially if you don't have the OS set to show you file extensions that can be easy to miss.

Beyond these possibilities, nothing much comes to mind right now.


is it possible to create a mod that allows 4x or even 10x on the campaign screen?
preferably with a different button from the 2x

There's campaignSpeedupMult in settings.json. Beyond that, I'm not sure.


also, how would one make a ship use the broadside ai more frequently?
it doesnt seem like just putting combat weapons in the big rear mounts works
it may be worth mentioning the ship i intend to do this with is a mod ship: the izar from hyperion systems
it has two large mounts, one forward one back- i want it to circle ships and broadside, considering that layout, but it seems to want to just point directly at whatever its target is, even though i put the main battery on the back (it is after all a civ turned combat sort of ship with high campaign speed, so theoretically should be powerful on the retreat)

I really can't say - I don't think you can, but maybe someone with more modding experience/broadside ships knows some tricks. That's a bit off-topic for this thread, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Negheve on September 30, 2021, 09:56:34 AM
Is there a method for setting the battlesize (that works not just onGameLoad), something like a set version of
Code
Global.getSettings.getBattleSize()
?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on September 30, 2021, 10:07:04 AM
Hmm. Did you restart the application before starting a new game? Changes to these files (and in general, except for rules.csv) require the application to be restarted to take effect.

Also: if you've got mods enabled and are editing the base Galatia.java file, it's possible that a mod is overriding it.

And, finally, if you use notepad or some such, sometimes when you save it'll add a .txt extension to the file and especially if you don't have the OS set to show you file extensions that can be easy to miss.

I only edit files without the application running so no problem there.
The file type wasn't tampered with, it's still proper JAVA.

I tried a different approach of restoring the default vanilla file and instead making a small mod that includes the modified Galatia.java file (with proper arborescence and mod structure) to see if it would override the vanilla one but that didn't work either.

I don't have any other mods with a Galatia.java that would override it, but I am guessing that there are other ways that mods could tamper with the fixed derelicts in that system without it? Any pointers to find how or should I just trial-and-error it?

Thank you for your time and helping my dumb ass with this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2021, 10:15:37 AM
Hmm, that's really weird. I'd suggest - just as a quick test - making some really guaranteed-not-to-compile edits (just, like, jam on your keyboard mid-file) to Galatia.java in vanilla. And then disabling any mods you might have - to rule them out as a possible contributor, regardless of whether they provide the file or not - and trying to run the game. It should get all the way through the progress bar and then crash trying to compile the intentionally-broken Galatia.java.

If that *doesn't* happen it would be an indicator that whatever you're editing is not what the game is using. If it does break, you have a starting point to work from and can add things in one by one to see what doesn't work, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on September 30, 2021, 11:55:16 AM
Found the problem.
The Adjusted Sector mod's source.jar contains .class files for various vanilla systems including Galatia. I never looked into this jar as this mod doesn't override derelicts added by other mods to the same systems and never realized it could be the issue.

Thank you for your time. There's many things I don't like about this game's development (or have grown to dislike over the years) but one thing I can never criticize is the help you provide to modders.
Cheers :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2021, 12:38:21 PM
:) Glad you got it figured out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 30, 2021, 01:34:15 PM
...
Thanks, using your code I was able to build something much simpler.
Code
Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).remove(Global.getSector().getPlayerPerson().getPortraitSprite()); 
Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).remove(Global.getSector().getPlayerPerson().getPortraitSprite());
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on September 30, 2021, 02:01:25 PM
is there an easy way to determine the parent fleet member of a ship module? is it as simple as MutableShipStatsAPI.getFleetMember(), or do i have to get to the parent ship somehow?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Negheve on September 30, 2021, 02:48:17 PM
Is there a method that makes the game reload its settings so I can modify things like maxShipsInFleet on the fly without having to reload the game/save?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 30, 2021, 03:19:30 PM
is there an easy way to determine the parent fleet member of a ship module? is it as simple as MutableShipStatsAPI.getFleetMember(), or do i have to get to the parent ship somehow?

Get the module's parent "station" and then the parent's FleetMember.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 30, 2021, 06:32:18 PM
What are tags in bar_events.csv to be used for... I can't find anything in the source code (as I thought they would let you specify which bar events can spawn in which market faction or even block which bar events but I suppose that's in the plugin itself which I would like to ask if... the tags are related to how the plugin interact with requireMarketFaction, preferMarketFaction... and so on).

I would think modded factions would appreciate the fact if they act as pacifists that their bars not suddenly tell the player to disrupt the heavy industry of someone.

Or heck someone from the League/Diktat telling me to attack each other when they're supposed to stick together?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 01, 2021, 03:11:27 AM
I don't think that's really doable; if you want a decent paintjob that pretty much means you've got to have that sprite made. Slapping some patterns onto an existing hull isn't going to look good (or easily work with the engine, but that's another point...)
It'd definitely be doable from your end (and somewhat easily too?) by introducing a palette that gets remapped (much like the earlier Command & Conquer games did). Although you're right about the lack of guarantee that it'd look good, and then there's the actual implementation of how and when said remap would get changed/apply...

Yeah, I can see why it might not be a high priority for consideration.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 01, 2021, 12:12:34 PM
Am I just imagining things? I thought the Ziggurat had a special condition that instantly revealed the player's fleet presence regardless of transponder.... and thought it was in a simple ship tag... is this a hardcoded concept?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 01, 2021, 05:45:18 PM
Am I just imagining things? I thought the Ziggurat had a special condition that instantly revealed the player's fleet presence regardless of transponder.... and thought it was in a simple ship tag... is this a hardcoded concept?

This was a pain to find. Not hardcoded: Tags.SHIP_UNIQUE_SIGNATURE is applied to the player's Ziggurat in TTBlackSite.java.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on October 02, 2021, 06:13:19 AM
Okay, I Have an issue regarding the usage of onNewGameAfterEconomyLoad() method.

I did some research on methods, and I believe that they are supposed to be used the following way:
Define what the Method does, then:
Calling the method.

I tried this on the onNewGameAfterEconomyLoad() method in the above way.

However, the method does not seem to do what I intend for it to do, which is to add markets to systems after they are generated by the vanilla game.

Am I formatting the method wrongly or is there something else I overlooked?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 02, 2021, 06:10:03 PM
Okay, I Have an issue regarding the usage of onNewGameAfterEconomyLoad() method.

I did some research on methods, and I believe that they are supposed to be used the following way:
Define what the Method does, then:
Calling the method.

I tried this on the onNewGameAfterEconomyLoad() method in the above way.

However, the method does not seem to do what I intend for it to do, which is to add markets to systems after they are generated by the vanilla game.

Am I formatting the method wrongly or is there something else I overlooked?

Post code

otherwise, use the vanilla style of adding market to systems (data\economy\econ\allthesystemname.json files
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on October 02, 2021, 07:51:48 PM
Okay, I Have an issue regarding the usage of onNewGameAfterEconomyLoad() method.

I did some research on methods, and I believe that they are supposed to be used the following way:
Define what the Method does, then:
Calling the method.

I tried this on the onNewGameAfterEconomyLoad() method in the above way.

However, the method does not seem to do what I intend for it to do, which is to add markets to systems after they are generated by the vanilla game.

Am I formatting the method wrongly or is there something else I overlooked?

Post code

otherwise, use the vanilla style of adding market to systems (data\economy\econ\allthesystemname.json files

Spoiler
public class DE_ModPlugin extends BaseModPlugin {
        private static void initMyMod() {
            new Gen().generate(Global.getSector());
        }

        @Override
        public void onNewGameAfterEconomyLoad() {
            Global.getLogger(this.getClass()).info("Hooray My mod plugin in a jar is loaded!");
            initMyMod();

            SectorAPI sector = null;
            assert false;

            StarSystemAPI system = sector.getStarSystem("Askonia");

            // Salus Siphon Platform
            SectorEntityToken diktatsiphonStation = system.addCustomEntity("salus_siphon", "Salus Siphon Platform", "station_side05", "sindrian_diktat");
            diktatsiphonStation.setCustomDescriptionId("station_salus_siphon");
            diktatsiphonStation.setInteractionImage("illustrations", "space_bar");
            diktatsiphonStation.setCircularOrbitWithSpin(system.getEntityById("salus"), 50, 45, 80, 700, 25);
            MarketAPI diktatsiphonStation_market = addMarketplace("sindrian_diktat",
                    diktatsiphonStation,
                    null,
                    "Salus Siphon Platform",
                    4,
                    new ArrayList<>(
                            Arrays.asList(
                                    Conditions.VOLATILES_DIFFUSE,
                                    Conditions.POPULATION_4,
                                    ("gas_giant")
                            )
                    ),
                    new ArrayList<>(
                            Arrays.asList(
                                    Industries.ORBITALSTATION_HIGH,
                                    Industries.GROUNDDEFENSES,
                                    Industries.MINING, Items.PLASMA_DYNAMO,
                                    Industries.POPULATION,
                                    Industries.SPACEPORT
                            )
                    ),
                    new ArrayList<>(
                            Arrays.asList(
                                    Submarkets.SUBMARKET_OPEN,
                                    Submarkets.SUBMARKET_BLACK,
                                    Submarkets.SUBMARKET_STORAGE
                            )
                    ),
                    //tariffs
                    0.3f,
                    //freeport
                    false,
                    //junk and chatter
                    true);


            // Opis Mining Platform
            SectorEntityToken diktatStation = system.addCustomEntity("opis_mining", "Opis Mining Platform", "station_side00", "sindrian_diktat");
            diktatStation.setCustomDescriptionId("station_opis_mining");
            diktatStation.setInteractionImage("illustrations", "space_bar");
            diktatStation.setCircularOrbitWithSpin(system.getEntityById("salus"), 45, 1100, 70, 40, 80);
            MarketAPI diktatStation_market = addMarketplace("sindrian_diktat",
                    diktatStation,
                    null,
                    "Opis Mining Platform",
                    6,
                    new ArrayList<>(
                            Arrays.asList(
                                    Conditions.ORE_RICH,
                                    Conditions.RARE_ORE_RICH,
                                    Conditions.VOLATILES_TRACE,
                                    Conditions.NO_ATMOSPHERE,
                                    Conditions.POPULATION_6
                            )
                    ),
                    new ArrayList<>(
                            Arrays.asList(
                                    Industries.BATTLESTATION,
                                    Industries.HEAVYBATTERIES,
                                    Industries.MINING,
                                    Industries.POPULATION,
                                    Industries.REFINING, Items.CATALYTIC_CORE,
                                    Industries.MILITARYBASE,
                                    Industries.WAYSTATION,
                                    Industries.SPACEPORT
                            )
                    ),
                    new ArrayList<>(
                            Arrays.asList(
                                    Submarkets.SUBMARKET_STORAGE,
                                    Submarkets.SUBMARKET_BLACK,
                                    Submarkets.SUBMARKET_OPEN,
                                    Submarkets.GENERIC_MILITARY
                            )
                    ),

                    //tariffs
                    0.3f,
                    //freeport
                    false,
                    //junk and chatter
                    false);

            PlanetAPI drakon = system.addPlanet("drakon", system.getEntityById("star"), "Drakon", "frozen1", 280, 150, 12000, 800);
            drakon.getSpec().setPitch(180f);
            drakon.getSpec().setTilt(-30f);
            drakon.getSpec().setGlowTexture(Global.getSettings().getSpriteName("hab_glows", "asharu"));
            drakon.applySpecChanges();
            drakon.setInteractionImage("illustrations", "space_bar");
            drakon.setCustomDescriptionId("planet_drakon");
            MarketAPI market = Global.getSector().getEconomy().getMarket("drakon");
            MarketAPI Drakon_market = addMarketplace("sindrian_diktat",
                    drakon,
                    null,
                    "Drakon",
                    4,
                    new ArrayList<>(
                            Arrays.asList(
                                    Conditions.ORGANICS_PLENTIFUL,
                                    Conditions.VOLATILES_DIFFUSE,
                                    Conditions.NO_ATMOSPHERE,
                                    Conditions.VERY_COLD,
                                    Conditions.POPULATION_5,
                                    Conditions.OUTPOST,
                                    Conditions.FRONTIER
                            )
                    ),

                    new ArrayList<>(
                            Arrays.asList(
                                    Industries.GROUNDDEFENSES,
                                    Industries.MINING,
                                    Industries.POPULATION,
                                    Industries.REFINING,
                                    Industries.SPACEPORT
                            )
                    ),
                    new ArrayList<>(
                            Arrays.asList(
                                    Submarkets.SUBMARKET_STORAGE,
                                    Submarkets.SUBMARKET_BLACK,
                                    Submarkets.SUBMARKET_OPEN,
                                    Submarkets.GENERIC_MILITARY
                            )
                    ),

                    //tariffs
                    0.3f,
                    //freeport
                    false,
                    //junk and chatter
                    false);


        }
}
[close]

The mod plugin file, I can send the gen file too if necessary though it is just code for addMarketplace
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 02, 2021, 11:52:28 PM
The mod plugin file, I can send the gen file too if necessary though it is just code for addMarketplace
Just post the whole mod plugin and gen file. I can't tell if you forgot to import them or any miscellaneous things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on October 03, 2021, 03:04:55 AM
The mod plugin file, I can send the gen file too if necessary though it is just code for addMarketplace
Just post the whole mod plugin and gen file. I can't tell if you forgot to import them or any miscellaneous things.

Spoiler
package data.world;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.ids.*;
import static data.world.DEAddMarketplace.addMarketplace;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;

import java.util.ArrayList;
import java.util.Arrays;

public class DE_ModPlugin extends BaseModPlugin {
        private static void initDE() {
            new Gen().generate(Global.getSector());
        }

    @Override
    public void onNewGame() {initDE();}

}

[close]

I deleted the market info because I felt it was conflicting with the other code and hindering generation, though it won't be much of an issue to add it back(also why most of the imports will be unused until I add them back)

Spoiler
package data.world;



import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.econ.EconomyAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.impl.campaign.ids.Items;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import data.world.world.systems.DE_Andor;
import data.world.world.systems.DE_Askonia;


import java.util.ArrayList;
import java.util.Arrays;


public class Gen implements SectorGeneratorPlugin {

    @Override
    public void generate(SectorAPI sector) {

        new DE_Andor().generate(sector);
    }

}


Where DE_Andor is the desired system to generate
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Frezeh on October 03, 2021, 04:28:15 AM
Hey, I'm a fairly new to modding (and programming in general), and in the process of making a PD Integration mod for a few PD focused ships I'm having some trouble.  I keep getting the following error when trying to launch.

Fatal: Error loading [data.hullmods.KiloPD]
Cause: File 'data/hullmods/KiloPD.java', Line 15 Column 34: Unknown variable or type "Stats.SMALL_PD_MOD"


Log file had this to say

Spoiler
Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/KiloPD.java', Line 14, Column 34: Unknown variable or type "Stats.SMALL_PD_MOD"
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/KiloPD.java', Line 14, Column 34: Unknown variable or type "Stats.SMALL_PD_MOD"
   at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5424)
   at org.codehaus.janino.UnitCompiler.access$12300(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$16.visitPackage(UnitCompiler.java:5115)
   at org.codehaus.janino.Java$Package.accept(Java.java:3164)
   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5419)
   at org.codehaus.janino.UnitCompiler.access$15400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$16.visitAmbiguousName(UnitCompiler.java:5149)
   at org.codehaus.janino.Java$AmbiguousName.accept(Java.java:3135)
   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
   at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:7533)
   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7429)
   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7333)
   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5663)
   at org.codehaus.janino.UnitCompiler.access$13800(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$16.visitMethodInvocation(UnitCompiler.java:5132)
   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3971)
   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7333)
   at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3873)
   at org.codehaus.janino.UnitCompiler.access$6900(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:3263)
   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
   at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:3290)
   at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:4368)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2662)
   at org.codehaus.janino.UnitCompiler.access$4400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$7.visitMethodInvocation(UnitCompiler.java:2627)
   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2654)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1643)
   at org.codehaus.janino.UnitCompiler.access$1100(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java:936)
   at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:2097)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
   at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
   at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
   at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
   ... 5 more
[close]

With some testing I found that the variables, "MEDIUM_PD_MOD" and "LARGE_PD_MOD" also got me the same results. The current hullmod code found bellow.
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class KiloPD extends BaseHullMod {

private static final int PD_S_OP = 2;
private static final int PD_M_OP = 4;
private static final int PD_L_OP = 8;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.SMALL_PD_MOD).modifyFlat(id, -PD_S_OP);
stats.getDynamic().getMod(Stats.MEDIUM_PD_MOD).modifyFlat(id, -PD_M_OP);
stats.getDynamic().getMod(Stats.LARGE_PD_MOD).modifyFlat(id, -PD_L_OP);
}

@Override
public boolean affectsOPCosts() {
return true;
}


}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Negheve on October 03, 2021, 10:45:01 AM
Does anyone know what the float that FactionAPI.pickShipAndAddToFLeet() returns is? Is it maybe the amount of FP the method added to the fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 03, 2021, 05:39:44 PM
Hey, I'm a fairly new to modding (and programming in general), and in the process of making a PD Integration mod for a few PD focused ships I'm having some trouble.  I keep getting the following error when trying to launch.

Fatal: Error loading [data.hullmods.KiloPD]
Cause: File 'data/hullmods/KiloPD.java', Line 15 Column 34: Unknown variable or type "Stats.SMALL_PD_MOD"


[...]

The current hullmod code found bellow.
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class KiloPD extends BaseHullMod {

private static final int PD_S_OP = 2;
private static final int PD_M_OP = 4;
private static final int PD_L_OP = 8;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.SMALL_PD_MOD).modifyFlat(id, -PD_S_OP);
stats.getDynamic().getMod(Stats.MEDIUM_PD_MOD).modifyFlat(id, -PD_M_OP);
stats.getDynamic().getMod(Stats.LARGE_PD_MOD).modifyFlat(id, -PD_L_OP);
}

@Override
public boolean affectsOPCosts() {
return true;
}
}
Add an import com.fs.starfarer.api.impl.campaign.ids.Stats; with the other imports near the top of the file.

(Using an IDE will greatly help in spotting such issues)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: lethargie on October 04, 2021, 07:09:46 AM
Im making a simple HubMissionWithBarEvent

I use trigger to create a fleet around a derelict ship when the mission reach the appropriate stage:
Code
            beginStageTrigger(Stage.GOGET);

            triggerCreateFleet(FleetSize.LARGE, FleetQuality.DEFAULT,
                               "vanidad", FleetTypes.PATROL_MEDIUM, entity.getLocation());
            triggerAutoAdjustFleetStrengthModerate();
            triggerSetFleetFaction("vanidad");
            triggerMakeFleetIgnoredByOtherFleets();
            triggerFleetSetName("Exploradors");
            triggerMakeLowRepImpact();
           
           
            triggerPickLocationAroundEntity(entity, 5);
            triggerSpawnFleetAtPickedLocation("$vanidad_loe_f_authority",
                                              "$vanidad_loe_ref");
            triggerOrderFleetPatrol(entity);
            triggerFleetOnlyEngageableWhenVisibleToPlayer();
            triggerFleetSetPatrolLeashRange(200);
            triggerFleetSetPatrolActionText("Orbiting derelict ship");

            endTrigger();

I would like the player to be able to explore the derelict only when they have dealt with the patrolling fleet. Right now I have put a tag on the derelict that is removed once the player talk to the fleet and select an option (going throught rule.cmd). I would like to make sure the derelict is explorable if the fleet is destroyed, either by the player or another fleet. (or even if its engaged with something else). How would I go doing that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2021, 10:42:03 AM
Does anyone know what the float that FactionAPI.pickShipAndAddToFLeet() returns is? Is it maybe the amount of FP the method added to the fleet?

From the javadoc:
Returns a total weight of ships added to the fleet. Generally will return
1 when ships were added, 0 when they weren't, and a number >1 when adding, say,
a medium ship instead of a small one because no small ones are available.




I would like the player to be able to explore the derelict only when they have dealt with the patrolling fleet. Right now I have put a tag on the derelict that is removed once the player talk to the fleet and select an option (going throught rule.cmd). I would like to make sure the derelict is explorable if the fleet is destroyed, either by the player or another fleet. (or even if its engaged with something else). How would I go doing that?

The simplest thing would be to do something like this:
triggerMakeFleetIgnoredByOtherFleets();
triggerMakeFleetIgnoreOtherFleetsExceptPlayer();
triggerFleetAddDefeatTrigger("YourRuleTrigger");

Which would fire YourRuleTrigger when the fleet is defeated, and rule out the case of "destroyed by something else". (See: FleetInteractionDialogPlugin, around line 2002, for some variables you can check when that trigger is fired.)

You could also, instead of a tag, set a memory value on the entity using
triggerSetEntityFlag(flag, Object ... stages)
That will automatically be removed when the mission ends; not necessarily applicable here but might be handy.

And, finally, if you want to catch all cases of the fleet fighting something, you could call:

triggerCustomAction()

And then provide a custom action that addes a FleetEventListener to the TriggerActionContext.fleet when it's called. You could make your mission class implement FleetEventListener just for convenience, and have the doAction() method call "context.fleet.addListener(YourMission.this)". Hope that makes sense!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 05, 2021, 06:14:28 AM
Any thoughts on how one would find out from what mod a given skin of a vanilla ship originates from? It's not connected to any .csv, so getMergedSpreadsheetDataForMod() and "fs_rowSource" isn't an option, nor can you glean information from looking at the base hull, given it's a vanilla ship. I'm wondering if there's anything obvious or convenient that I'm missing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dcong89 on October 05, 2021, 07:04:48 AM
hi guys

this error keep make the game crash (it's said Fatal:4) when i refit and add hull mods to some ships.

184747 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 4
java.lang.ArrayIndexOutOfBoundsException: 4
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus$ShipStatus.applyDamage(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus$ShipStatus.applyHullFractionDamage(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus.applyHullFractionDamage(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.applyDamageToFl eetMember(BattleAutoresolverPluginImpl.java:490)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.computeOutcomeF orFleetMember(BattleAutoresolverPluginImpl.java:690)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.resolveEngageme nt(BattleAutoresolverPluginImpl.java:333)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.resolve(BattleAutoresolverPluginImpl.java:243)
   at com.fs.starfarer.campaign.fleet.Battle.doAutoresolveRound(Unknown Source)
   at com.fs.starfarer.campaign.fleet.Battle.advance(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.advanceEvenIfPaused(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on October 05, 2021, 04:38:44 PM
Any thoughts on how one would find out from what mod a given skin of a vanilla ship originates from? It's not connected to any .csv, so getMergedSpreadsheetDataForMod() and "fs_rowSource" isn't an option, nor can you glean information from looking at the base hull, given it's a vanilla ship. I'm wondering if there's anything obvious or convenient that I'm missing.
A "good enough" method would be trying to load the skin's json data using Global.getSettings().loadJSON("/data/hulls/skins/skin_id.skin", modID) for each mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 06, 2021, 01:56:40 AM
Is there any way to influence restore ship logic? I'd like to add some extra conditions, say require Metals based on the hull size, or specific industry being present on the market used to restore...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on October 06, 2021, 07:52:38 PM
Can I directly use Vertex Array/Buffer Object in OpenGL while modding?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 07, 2021, 11:37:24 AM
Is there any way to influence restore ship logic? I'd like to add some extra conditions, say require Metals based on the hull size, or specific industry being present on the market used to restore...

There isn't, no - that'd require UI changes, too (showing requirements etc) and none of it is set up for that. Could of course be done with an entirely custom dialog option, though, just not through the refit screen.

Can I directly use Vertex Array/Buffer Object in OpenGL while modding?

I don't see why not!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on October 09, 2021, 03:02:22 PM
Is there any way to figure out what weapon or projectile flak AoE damage comes from? It appears to be an instance of DamagingProjectileAPI, but returns null for getWeapon() and getProjectileSpecId(). Asking because I'm trying to do an onhit effect for a flak gun- but flak AoE doesn't trigger onhit scripts, apparently. So I did it with a listener instead, and ran into the previously mentioned problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on October 09, 2021, 10:58:59 PM
Can I directly use Vertex Array/Buffer Object in OpenGL while modding?

I don't see why not!
Welll...I am just considering about if there are someone whose gpu is not compatible with OpenGL 3.0...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 10, 2021, 12:17:39 AM
Can CampaignPlugin.pickAutofitPlugin be marked as @Deprecated? It took me a while to figure out why mine wasn't being called.

(CoreAutofitPlugin is called from the fleet inflater, which is the plugin I actually need to have a picker for)

EDIT: or alternatively, make the inflater actually use the plugin pick
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 11, 2021, 10:25:28 AM
Asking because I'm trying to do an onhit effect for a flak gun- but flak AoE doesn't trigger onhit scripts, apparently.

Hmm, really? It's supposed to apply any on hit effects from the weapon - so the "onHitEffect" would be specified in its normal place, not inside the explosionSpec, for example.

Welll...I am just considering about if there are someone whose gpu is not compatible with OpenGL 3.0...

Ah - I mean, that's up to you to decide if you care about that, not really a question I can answer.

Can CampaignPlugin.pickAutofitPlugin be marked as @Deprecated? It took me a while to figure out why mine wasn't being called.

(CoreAutofitPlugin is called from the fleet inflater, which is the plugin I actually need to have a picker for)

EDIT: or alternatively, make the inflater actually use the plugin pick

Ahh! That method *is* used by the refit screen. What DefaultFleetInflater does is kind of... up to what it wants to do, if that makes sense - it *happens* to use CoreAutofitPluginImpl because it's convenient and that implementation does double-duty as far as being used both for player refit and for NPC fleets, but that's not a required state of affairs.

Added a comment to pickAutofitPlugin() to clarify that it's only used for the refit screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 12, 2021, 06:29:19 PM
If I wanted to apply a certain damage modifier to a damage API, would this be the right way to go about it ? The main thing im unsure about is how to apply mults and percentmod together.
Code
DamageAPI damage;

float damageMod = ( damage.getStats().getDamageToFighters().getPercentMod()/100f ) * damage.getStats().getDamageToFighters().getMult())

damage.setMultiplier( damage.getMultiplier() + damageMod );


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on October 13, 2021, 01:43:48 AM
Hmm, really? It's supposed to apply any on hit effects from the weapon - so the "onHitEffect" would be specified in its normal place, not inside the explosionSpec, for example.

I've double-checked this; the onhit gets called if I remove the proximity explosion, but does not get called when I add it back in. Presumably it has something to do with the projectile exploding without touching anything- the damage applied by the flak AoE returns null if you try to get its projectile ID or source weapon.
.wpn file, in case I'm smoking something (the script is just some extra damage and graphical effects, nothing terribly fancy):
Spoiler
{
   "id":"apex_flak_shot",
   "specClass":"projectile",
   "spawnType":"BALLISTIC",
   "collisionClass":"PROJECTILE_FF",
   "collisionClassByFighter":"PROJECTILE_FIGHTER",
   "onHitEffect":"data.weapons.proj.ApexQGOnHit",
   "length":35.0,
   #"length":0,
   "hitGlowRadius":10,
   "width":6.5,
   "fadeTime":0.2,
   "fringeColor":[255,245,175,200],
   "coreColor":[255,250,225,200],   
   #"fringeColor":[255,50,50,0],
   #"coreColor":[255,255,200,0],   
   "textureScrollSpeed":64.0,
   "pixelsPerTexel":5.0,
   "bulletSprite":"graphics/missiles/shell_large_blue.png",
   #"bulletSprite":"",
   "behaviorSpec":{"behavior":"PROXIMITY_FUSE",
               "range":35,
               #"vsMissileRange":100,
               "explosionSpec":{"duration":0.1f,
                            "radius":50,
                            "coreRadius":35, # full damage within core radius - also equal to proximity fuse range
                            "collisionClass":PROJECTILE_FF,
                            "collisionClassByFighter":PROJECTILE_FIGHTER,
                            "particleSizeMin":3.0,
                            "particleSizeRange":3.0,
                            "particleDuration":1,
                            "particleCount":100,
                            "particleColor":[255,245,175,255],
                            "sound":"explosion_flak"},
               }
               
}
[close]

Also, do CombatEngineAPI's applyDamage(), spawnDamagingExplosion(), and spawnEmpArc() methods automatically do Targeting Analysis's bonus damage vs different ship sizes? Or do I need to add that in myself?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 13, 2021, 04:25:40 AM
I am about to try something new, and add new types of colonies to the game. By new, I mean new implementations of MarketAPI interface. Before I start (interface is large) I wanted to confirm there is no magic involved anywhere else in the (obfuscated) code, and that I can happily replace vanilla MarketAPI objects with my own.

I want to achieve the following (not limited to):
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 13, 2021, 01:24:59 PM
If I wanted to apply a certain damage modifier to a damage API, would this be the right way to go about it ? The main thing im unsure about is how to apply mults and percentmod together.
Code
DamageAPI damage;

float damageMod = ( damage.getStats().getDamageToFighters().getPercentMod()/100f ) * damage.getStats().getDamageToFighters().getMult())

damage.setMultiplier( damage.getMultiplier() + damageMod );

You want to use damage.getModifier() - it returns a MutableStat which you can then modify with a percentage and a multiplier separately.

I've double-checked this; the onhit gets called if I remove the proximity explosion, but does not get called when I add it back in. Presumably it has something to do with the projectile exploding without touching anything- the damage applied by the flak AoE returns null if you try to get its projectile ID or source weapon.

Ah, my bad - the onHitEffect needs to be inside behaviorSpec (but *not* inside explosionSpec).

Also, do CombatEngineAPI's applyDamage(), spawnDamagingExplosion(), and spawnEmpArc() methods automatically do Targeting Analysis's bonus damage vs different ship sizes? Or do I need to add that in myself?

It should apply automatically.

I am about to try something new, and add new types of colonies to the game. By new, I mean new implementations of MarketAPI interface. Before I start (interface is large) I wanted to confirm there is no magic involved anywhere else in the (obfuscated) code, and that I can happily replace vanilla MarketAPI objects with my own.

Ah, that's definitely not going to work. Generally speaking when something is *API it's just an interface to expose core functionality, and when something is *Plugin, it's something that can actually be replaced by an alternative implementation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 13, 2021, 02:00:12 PM
Ah, that's definitely not going to work. Generally speaking when something is *API it's just an interface to expose core functionality, and when something is *Plugin, it's something that can actually be replaced by an alternative implementation.

So if I understand you correctly, *API exposes only part of the actual implementation. Say you have a Colony class that implements MarketAPI. MarketAPI is a small subset of Colony's actual interface (exposed to modders), and in your code you operate on a Colony instead of MarketAPI.

I could now see how me trying to replace a market (via `public class MyColony implements MarketAPI`) would instantly cause `Cannot cast MyColony to Colony` exception on first try.

Still, both EconomyAPI (addMarket) and SectorEntityToken (setMarket) expect MarketAPI. So you must be casting the interface to concrete class, is it truly necessary? (I really want to add custom colonies).

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 13, 2021, 02:12:50 PM
So if I understand you correctly, *API exposes only part of the actual implementation. Say you have a Colony class that implements MarketAPI. MarketAPI is a small subset of Colony's actual interface (exposed to modders), and in your code you operate on a Colony instead of MarketAPI.

I could now see how me trying to replace a market (via `public class MyColony implements MarketAPI`) would instantly cause `Cannot cast MyColony to Colony` exception on first try.

Yep, that's right.

Still, both EconomyAPI (addMarket) and SectorEntityToken (setMarket) expect MarketAPI. So you must be casting the interface to concrete class, is it truly necessary? (I really want to add custom colonies).

(I mean, it kind of has to take a MarketAPI since the implementing "Market" class isn't exposed...)

Yes, it's actually pretty necessary! Of course, it's *possible* to make alternate market implementations work, but it'd be a significant effort. Aside from the fact that there are 150+ references to Market in the core code and it'd be a pain to try to clean up, the game also has a "fake" market class for planet-condition-markets only (that only go into the savefile) and it does some conversion between the two on saving/loading. Plus there are probably other specific behaviors of the Market implementation that are relied on in places, that I'm not thinking about right now. Again, nothing that's *technically* impossible, but also not something I can see taking on, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 13, 2021, 04:42:15 PM
I'd like to ask if "time travel" into the future is possible.

I have a quest scenario where the player is knocked out for a month and although I could just have the player wait out a month, I'd like to have them play it out in a mini-game which after the mini-game passes a month passes.

I have the mini-game done, but although I can change the calendar timing, nothing in-gameplay would change per-say? As fleets seem to stay in the same spot as they did a month ago.

I know the game starts on January 1, 206, and stimulates 2 months into March 1, 206 for the player to start. Would this be feasible to do even after the game has already started then? I don't mind if the game has to save and reload, just asking whether this concept is even possible.

If it's not possible, I'll pursue an alternative endeavor.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 13, 2021, 04:51:02 PM
Hmm, yeah, I don't think this is doable - I don't see the necessary methods in the API.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 13, 2021, 05:40:05 PM
You want to use damage.getModifier() - it returns a MutableStat which you can then modify with a percentage and a multiplier separately.

Thanks Alex!
One last thing. I'm trying to emulate the positioning of the native addFloatingDamageText effect when ships take damage. Is there somewhere I can look to see how the base game does it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 14, 2021, 03:21:03 PM
Maybe it's a lost cause, but

is there a method in Java for variants to be loaded without requiring a modded weapon spec and hull spec?

Like said I wanted to create a variant (modded_variantid) using SWP's weapons (miniblaster) without making SWP a dependency on the mod, could that be possible where the variants wouldn't be loaded in the game until SWP is activated?

I thought about using something like this to add the variants to the faction and default entries for role, but as long as the variants has a modded weapon or rely on a modded hull it can't find, it will pass an exception... is it possible for a variant line to be added to not be loaded on the game load then?
Code
   List<RoleEntryAPI> getEntriesForRole(String factionId, String role);
   void addEntryForRole(String factionId, String role, String variantId, float weight);
   void removeEntryForRole(String factionId, String role, String variantId);

   List<RoleEntryAPI> getDefaultEntriesForRole(String role);
   void addDefaultEntryForRole(String role, String variantId, float weight);


On another sidenote: Missions can't add allied ships (just ships in the player but not able to be controlled by the player) huh?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 15, 2021, 08:47:26 AM
One last thing. I'm trying to emulate the positioning of the native addFloatingDamageText effect when ships take damage. Is there somewhere I can look to see how the base game does it?

Hmm, I don't think so. Also, vanilla has some custom code to merge damage floaties together when more damage is taken near the same point, you wouldn't be able to emulate that either.

Maybe it's a lost cause, but

is there a method in Java for variants to be loaded without requiring a modded weapon spec and hull spec?

Like said I wanted to create a variant (modded_variantid) using SWP's weapons (miniblaster) without making SWP a dependency on the mod, could that be possible where the variants wouldn't be loaded in the game until SWP is activated?

I thought about using something like this to add the variants to the faction and default entries for role, but as long as the variants has a modded weapon or rely on a modded hull it can't find, it will pass an exception... is it possible for a variant line to be added to not be loaded on the game load then?

I don't think it's possible with .variant files since those are only going to be loaded once on application startup and that's not something that can be made conditional. You might be able to create the variants with code, though - I don't see why not, actually.

On another sidenote: Missions can't add allied ships (just ships in the player but not able to be controlled by the player) huh?

You can call .setAlly(true) on the FleetMemberAPI returned by MissionDefinitionAPI.addToFleet().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 15, 2021, 09:46:31 PM
Hmm, I don't think so. Also, vanilla has some custom code to merge damage floaties together when more damage is taken near the same point, you wouldn't be able to emulate that either.

it seems to add numbers together without issue from my testing, and even seperates armor/hull/shield damage values.. I'm doing this via DamageListener's reportDamageApplied, maybe that's why? or maybe its related to the color of the floaty? I guess it doesn't matter too much, it just werkz
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 16, 2021, 12:01:20 PM
... well, if it works, it works!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 16, 2021, 11:02:05 PM
You might be able to create the variants with code, though - I don't see why not, actually.
Aye I did using
Spoiler
Code
public ShipVariantAPI loadVariant(String path) {
        ShipVariantAPI variant = null;
        try {
            JSONObject obj = Global.getSettings().loadJSON(path);
            String displayName = obj.getString("displayName");
            int fluxCapacitors = obj.getInt("fluxCapacitors");
            int fluxVents = obj.getInt("fluxVents");
            boolean goalVariant = false;
            try {
                goalVariant = obj.getBoolean("goalVariant");
            } catch (JSONException ignored) {
            }
            String hullId = obj.getString("hullId");
            JSONArray hullMods = obj.getJSONArray("hullMods");
            JSONArray modules = null;
            try {
                modules = obj.getJSONArray("modules");
            } catch (JSONException ignored) {
            }
            JSONArray permaMods = obj.getJSONArray("permaMods");
            JSONArray sMods = null;
            try {
                sMods = obj.getJSONArray("sMods");
            } catch (JSONException ignored) {
            }
            //float quality = (float) obj.getDouble("quality"); not used/available in API
            String variantId = obj.getString("variantId");
            JSONArray weaponGroups = obj.getJSONArray("weaponGroups");
            JSONArray wings = null;
            try {
                wings = obj.getJSONArray("wings");
            } catch (JSONException ignored) {
            }

            variant = Global.getSettings().createEmptyVariant(variantId, Global.getSettings().getHullSpec(hullId));
            variant.setVariantDisplayName(displayName);
            variant.setNumFluxCapacitors(fluxCapacitors);
            variant.setNumFluxVents(fluxVents);
            variant.setGoalVariant(goalVariant);
            // todo: check if order matters
            for (int i = 0; i < hullMods.length(); i++) {
                String hullModId = hullMods.getString(i);
                variant.addMod(hullModId);
            }
            for (int j = 0; j < permaMods.length(); j++) {
                String permaModId = hullMods.getString(j);
                variant.addPermaMod(permaModId);
            }
            if (sMods != null) {
                for (int k = 0; k < sMods.length(); k++) {
                    String sModId = hullMods.getString(k);
                    variant.addPermaMod(sModId, true);
                }
            }
            if (modules != null) {
                for (int m = 0; m < modules.length(); m++) {
                    JSONObject module = modules.getJSONObject(m);
                    // todo this is a very inefficient way to do it (obj length always == 1)
                    //  but I don't want to deal with Iterators
                    JSONArray slots = module.names();
                    for (int s = 0; s < slots.length(); s++) {
                        String slotId = slots.getString(s);
                        String moduleVariantId = module.getString(slotId);
                        //todo *** Given moduleVariantId instead of path, create ShipVariantAPI using loadVariant() ***
                        variant.setModuleVariant(slotId, Global.getSettings().getVariant(moduleVariantId));
                    }
                }
            }
            // todo maybe you can do something better with variant.getNonBuiltInWeaponSlots()?
            for (int wg = 0; wg < weaponGroups.length(); wg++) {
                WeaponGroupSpec weaponGroupSpec = new WeaponGroupSpec(WeaponGroupType.LINKED);
                JSONObject weaponGroup = weaponGroups.getJSONObject(wg);
                boolean autofire = weaponGroup.getBoolean("autofire");
                String mode = weaponGroup.getString("mode");
                JSONObject weapons = weaponGroup.getJSONObject("weapons");
                JSONArray slots = weapons.names();
                for (int s = 0; s < slots.length(); s++) {
                    String slotId = slots.getString(s);
                    String weaponId = weapons.getString(slotId);
                    variant.addWeapon(slotId, weaponId);
                    weaponGroupSpec.addSlot(slotId);
                }
                weaponGroupSpec.setAutofireOnByDefault(autofire);
                weaponGroupSpec.setType(WeaponGroupType.valueOf(mode));
                variant.addWeaponGroup(weaponGroupSpec);
            }
            if (wings != null) {
                int numBuiltIn = Global.getSettings().getVariant(variant.getHullSpec().getHullId() + "_Hull").getFittedWings().size();
                for (int w = 0; w < wings.length(); w++) {
                    variant.setWingId(numBuiltIn + w, wings.getString(w));
                }
            }
        } catch (IOException | JSONException e) {
            log.error("could not load" + path, e);
        }
        return variant;
    }
[close]
which works somewhat well, but not for something like SettingAPI.addDefaultEntryForRole or SettingAPI.addEntryForRole. However, I ask in advance so that future modders wouldn't need to make some weapon packs a required dependency or bloat the weapon list with almost similar weapon clones of each other below.
...
is there a method in Java for variants to be loaded without requiring a modded weapon spec and hull spec?
...
I thought about using something like this to add the variants to the faction and default entries for role, but as long as the variants has a modded weapon or rely on a modded hull it can't find, it will pass an exception... is it possible for a variant line to be added to not be loaded on the game load then?

I don't think it's possible with .variant files since those are only going to be loaded once on application startup and that's not something that can be made conditional.
How does the game load mission variants into the campaign itself then?

1) Started a new game.
2) Exited game with a save, went into Missions, and made some variants that Player refitted.
3) Load the save from step 1. Find out mission variants can transfer over into the campaign layer.
4) Exited game again, reset Mission variants.
5) Load game, variants disappeared.

It seemed if Missions were able to automatically generate variant files based on a player's refit and make their own ID... then could I ask for the Mission API to allow code to generate a variant file?
(https://i.imgur.com/fPzjymI.png)

This image is extracted from a print statement from
Code
SettingsAPI.getAllVariantIds()
I did some more testing and found out these loaded variant files were UNSANITIZED, but still work nonetheless like any other variants. It will try to load variants with modded weapons and will crash (obviously if the mod dependency isn't activated) which is a good thing since, in the MissionDefinition.java, I can simply just check if the mod dependency is available for me to generate a variant file.

Or if I'm still incoherent, this made me realize to ask whether or not something like this may be possible or something of the sort.

Code
SettingsAPI.writeVariantFileToMission(ShipVariantAPI variant, ?API missionId) 
/*To be used in the MissionDefinition.java where mod authors can generate variant file made into the mission's folder*/

SettingsAPI.deleteVariantFileFromMission(ShipVariantAPI variant, ?API missionId)
/*To remake the variants again if needed or delete them permanently.*/

SettingsAPI.fileExistsInMission
/*Not sure if needed.. since SettingsAPI.doesVariantExist(variantID) exist functionally similar...*/

SettingsAPI.readTextFileFromMission
/*redundant code, SettingsAPI.getVariant(variantId) does this almost functionally the same*/
similar to how SettingsAPI.writeTextFileToCommon work
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 17, 2021, 08:35:28 AM
3) Load the save from step 1. Find out mission variants can transfer over into the campaign layer.

Hmm, what do you mean by that?

(Whatever it is, this sounds like it's probably a bug, btw.)

It seemed if Missions were able to automatically generate variant files based on a player's refit and make their own ID... then could I ask for the Mission API to allow code to generate a variant file?

I roughly get what you're asking, but, this isn't the right thread for more in-depth modding feature requests. It also feels like this request is based on trying to utilize a likely bug, so I'm not sure it's a good idea.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 17, 2021, 08:56:28 AM
Hmm, what do you mean by that?
1) Main Menu > Missions
3) A Fistful of Credit > Refit the Stranger II and/or Milk Run (does not matter)
4) Head back into Main Menu > Make a New Game
5) (https://i.imgur.com/DEYTgPO.png)
6) Save & Exit to Main Menu > Missions > Turning the Tables
7) Load the Game / Continue from Main Menu
8.) (https://i.imgur.com/1wCjNS1.png)
9) (https://i.imgur.com/gxma8ba.png)
10) (https://i.imgur.com/eIZ2OpH.png)
11) Save & Exit to Main Menu > Missions > (Reset) A Fistful of Credit & Turning the Tables
12) Load the Game / Continue from Main Menu
13) (https://i.imgur.com/fmI0wSV.png)
14) The 4 ships still exist, nothing has changed aside from the variants not being able to be listed anymore.

The campaign layer will load and seems to refresh ANY mission variants as part of the listed total variants and it only cares if the mission has been defined, so any deactivated mission with an existing variant file won't be read but it will read.

If that's not possible to implement then oh well. Just interesting to see how a variant file can still be read more than once through the mission list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 17, 2021, 09:31:12 AM
Ah, ok, loading it through the console makes sense - thank you for clarifying. I thought you meant it'd show up in the campaign somehow!

(This is only part of what you'd want for loading stuff with weapons etc from missing mods; it's... more involved than that. Again, this specific approach doesn't seem promising for that.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 18, 2021, 09:25:39 AM
Ah, ok, loading it through the console makes sense - thank you for clarifying. I thought you meant it'd show up in the campaign somehow!

(This is only part of what you'd want for loading stuff with weapons etc from missing mods; it's... more involved than that. Again, this specific approach doesn't seem promising for that.)
Hmmm.. I'll do some testing with that... to see if that's possible at all.

On another note, I notice that in the modding community some sounds are preloaded into the RAM (weapon sfx) while some are loaded when needed (like music). What determines how some audio gets preloaded and some don't? I'm working on voiced interactions (where it only fires from dialog interactions) and wonder if it's possible to have these audio files, not preload. Or am I just getting this all wrong and they're all preloaded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2021, 09:34:03 AM
Music is streamed from disk, and sfx are preloaded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 18, 2021, 09:48:53 AM
Music is streamed from disk, and sfx are preloaded.
Yeah how does sound.json know when to distinguish the difference?

Do they have to be within that "music" category or is of how they're formatted? I see

Code
"music_campaign":[
{"file":"miscallenous_corvus_campaign_music.ogg","source":"sounds/music/music.bin","volume":0.6},
],
vs
Code
 	"disintegrator_fire":[
{"file":"sounds/sfx_wpn_energy/disintegrator_fire_01.ogg","pitch":1,"volume":0.7},
],
So I'm assuming either the way they're formatted determines how one is streamed from the disk or preloaded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2021, 09:52:33 AM
It's that but also the method that's used for playback assumes it's one or the other. E.G. when you call playMusic() it'll stream from disk (and look for the id in the music section), but it also has some other consequences (such as replacing the current music), etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RustyCabbage on October 20, 2021, 06:16:40 AM
Is there a way to define suppressed hullmods in a .variant file? Trying something like

"suppressedMods": ["high_maintenance"],

on a Hyperion doesn't alter the variant, but I can't find any examples of suppressedMods being used anywhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on October 20, 2021, 06:34:28 AM
Is it possible for a colony to be mobile?  I mean fully functioning colony with all the bells and whistles.

I understand you would likely run into issues with trade fleets etc; is this even possible in the game engine though?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 20, 2021, 07:16:00 AM
Yes. I think it can't go into hyperspace, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on October 20, 2021, 07:23:06 AM
What makes you say that?  I have seen static colonies be implemented in hyperspace.  Is it because without a certain level of "know where it is" the trade fleets etc cant find it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 20, 2021, 08:21:34 AM
Because (from what I've seen of Prism Freeport), a colony in hyperspace is a massive source of lag. Probably something to do with patrol fleets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on October 20, 2021, 08:29:02 AM
So it IS theoretically possible to have a mobile colony?

The idea of having a mobile space station intrigues me; being able to leave it wherever you need to and head out with a high burn elite task force just sounds fun to me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on October 20, 2021, 10:16:22 PM
I've got a weird issue: I have a civilianized tanker and freighter and need them to spawn in a faction's markets in appropriate numbers. I've got them in default_ship_roles.json and the faction knows the ships, but the tanker spawns at an absurd rate- all but two or three of the civilian ship market's ships are the tanker, and the freighter won't spawn at all. However, this only applies to the civilian market- they show up in the correct number and proportion for military and black markets. Both ships have the relevant CIVILIAN and TANKER or FREIGHTER hints in ship_data.csv.

the ship ID's in question are apex_spectrum_civcargo, apex_spectrum_civfuel (the variants are apex_spectrum_hauler and apex_spectrum_tanker, respectively).

the relevant bits of default_ship_roles.json:
Spoiler
   "tankerMedium":{
      "apex_spectrum_tanker":5
   },
   "freighterMedium":{
      "apex_spectrum_hauler":5
   },
[close]

Edit: On further inspection, this appears to be an issue with role weighting somehow. Giving the faction access to base_bp produces a more reasonable ship distribution, but still does not spawn the cargo ship in the market. Presumably something to do with how the civilain market plugin is handling ship selection when the faction doesn't have a civilian ship in each role?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 21, 2021, 09:45:58 AM
Is there a way to define suppressed hullmods in a .variant file? Trying something like

"suppressedMods": ["high_maintenance"],

on a Hyperion doesn't alter the variant, but I can't find any examples of suppressedMods being used anywhere.

Hmm - "suppressedMods" should work - but looking into it, apparently that wasn't being loaded properly. Fixed this up!


Spoiler
I've got a weird issue: I have a civilianized tanker and freighter and need them to spawn in a faction's markets in appropriate numbers. I've got them in default_ship_roles.json and the faction knows the ships, but the tanker spawns at an absurd rate- all but two or three of the civilian ship market's ships are the tanker, and the freighter won't spawn at all. However, this only applies to the civilian market- they show up in the correct number and proportion for military and black markets. Both ships have the relevant CIVILIAN and TANKER or FREIGHTER hints in ship_data.csv.

the ship ID's in question are apex_spectrum_civcargo, apex_spectrum_civfuel (the variants are apex_spectrum_hauler and apex_spectrum_tanker, respectively).

the relevant bits of default_ship_roles.json:
Spoiler
   "tankerMedium":{
      "apex_spectrum_tanker":5
   },
   "freighterMedium":{
      "apex_spectrum_hauler":5
   },
[close]

Edit: On further inspection, this appears to be an issue with role weighting somehow. Giving the faction access to base_bp produces a more reasonable ship distribution, but still does not spawn the cargo ship in the market. Presumably something to do with how the civilain market plugin is handling ship selection when the faction doesn't have a civilian ship in each role?
[close]

I'm not sure what the problem might be; I'd suggest stepping through OpenMarketPlugin.updateCargoPrePlayerInteraction() with a debugger to see what's doing on. All the code that generates this stuff should be in mod-land, aside from IIRC the bit that grabs probabilities out of the .faction - but even then, you should be able to see what the problem is based on what that's returning, if that happens to be the culprit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on October 21, 2021, 03:30:43 PM
I'm not sure what the problem might be; I'd suggest stepping through OpenMarketPlugin.updateCargoPrePlayerInteraction() with a debugger to see what's doing on. All the code that generates this stuff should be in mod-land, aside from IIRC the bit that grabs probabilities out of the .faction - but even then, you should be able to see what the problem is based on what that's returning, if that happens to be the culprit.

I think the issue is with how it's adding tankers- adding the tankers last (instead of adding them along with everything else) appears to be replacing other ships, though I'm unsure how, or why it's not happening in vanilla. Regardless, managed to fix it with a custom market plugin that just pretends to be the open market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 23, 2021, 02:14:27 AM
Is it me or is the casualty reduction mult from Ground Operations skill not registering in the player's mutable fleet stats, somehow? Only the effectiveness modifier is applying.

(tested with no non-library, non-utility mods)

Code: java
runcode 
Console.showMessage("Planetary operations power mult is " + Global.getSector().getPlayerFleet().getStats().getDynamic().getMod(Stats.PLANETARY_OPERATIONS_MOD).computeEffective(1));
Console.showMessage("Planetary operations casualties mult is " + Global.getSector().getPlayerFleet().getStats().getDynamic().getMod(Stats.PLANETARY_OPERATIONS_CASUALTIES_MULT).computeEffective(1));
104614 [Thread-3] INFO  org.lazywizard.console.Console  - Planetary operations power mult is 2.0
104615 [Thread-3] INFO  org.lazywizard.console.Console  - Planetary operations casualties mult is 1.0

Marine XP bonuses seem to be having the same problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 23, 2021, 07:41:25 AM
I think it's an issue with your using getMod() instead of getStat(). Stuff ending with _MULT should use getStat() (which assumes a base value of 1, always), stuff ending with _MOD uses getMod(). Main point is that where it uses the value needs to be consistent with how the value is modified, in this case by the skill. The naming convention for the Stats.XXXX names is just to try to help keep it straight.

Probably not something I'd do the same way if I had a second go at it since it's easy to mix up which one a value in question is using and I've done it myself, but, ah well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 24, 2021, 02:58:57 AM
Ah, thanks, that was it exactly.

New question: Is it possible (and desirable) to make a hub mission transition from one stage to another from code? Rather than the seemingly roundabout way of calling  e.g. connectWithGlobalFlag at start and then setting that flag in order to progress.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 24, 2021, 08:18:24 AM
New question: Is it possible (and desirable) to make a hub mission transition from one stage to another from code? Rather than the seemingly roundabout way of calling  e.g. connectWithGlobalFlag at start and then setting that flag in order to progress.

Yes! See BlueprintIntel for an example. I *think* both the "dialog" and "memoryMap" parameters can be null, but that'll also depend on your implementation (if any) of endSuccessImpl/endFailureImpl and possibly I didn't see a case where they're used when looking through it just now.

Code
public void reportAboutToShowLootToPlayer(CargoAPI loot, InteractionDialogAPI dialog) {
for (CargoStackAPI stack : loot.getStacksCopy()) {
if (item.equals(stack.getData())) {
Global.getSector().getListenerManager().removeListener(this);
setCurrentStage(Stage.COMPLETED, dialog, dialog.getPlugin().getMemoryMap());
break;
}
}
}

connectWithGlobalFlag() and similar are mostly there for when the transitions are initiated from rules, though they can be handy in some other cases, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on October 26, 2021, 04:38:01 AM
In my mod I have a functional toggle ability that a user has requested be tied into a hull mod for it to work. I have tried several ways to make this happen but I cannot seem to figure out how to go about it and rather than going over my many failed attempts I just would like to ask:

Is is possible to do and if so how?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 26, 2021, 06:50:51 AM
Intent: Player may expend story point to lower the CR of enemy frigates and destroyers [and even kill] at a cost of theirs.

So everything in this code seems to work, every fleet is given a memory tag if they $can_dogfight based on how many frigates and destroyers they have!

However I'm running into an issue with.. stacked fleets? Like say the player encounter Fleet A and Fleet B together. Fleet A has the $can_dogfight, player encounters that and has the option. However when the Fleet A retreats and player is given another dialog interaction, the option disappears. I'm a little confused why, that's likely either Fleet A and B are merging together and memories don't overlap? Or is it because the dialog interaction is unlucky and accessing Fleet B's memory instead?

Either way, is there a code that can scan nearby fleets of their memory then? Since it seems the dialog interaction combines the fleets together as part of the enemy forces.
Code
        @Override
        public void reportShownInteractionDialog (InteractionDialogAPI dialog) {
            if (dialog.getInteractionTarget().getMemoryWithoutUpdate().getBoolean("$can_dogfight")) {
                dialog.getOptionPanel().addOption("Order your second-in-command to harass their frigates", "optionid_dogfight");
                dialog.getOptionPanel().setEnabled("optionid_dogfight", false);
                dialog.getOptionPanel().setTooltip("optionid_dogfight", "Before the battle begins, you may expend a story point to soften up the enemy's frigates and their destroyers.");
            }
        }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2021, 02:57:06 PM
In my mod I have a functional toggle ability that a user has requested be tied into a hull mod for it to work. I have tried several ways to make this happen but I cannot seem to figure out how to go about it and rather than going over my many failed attempts I just would like to ask:

Is is possible to do and if so how?

You mean an active campaign ability, yes? IIRC there's an "isUsable()" method the ability plugin and you could check for ship-with-hullmod presence there.


Intent: Player may expend story point to lower the CR of enemy frigates and destroyers [and even kill] at a cost of theirs.

So everything in this code seems to work, every fleet is given a memory tag if they $can_dogfight based on how many frigates and destroyers they have!

However I'm running into an issue with.. stacked fleets? Like say the player encounter Fleet A and Fleet B together. Fleet A has the $can_dogfight, player encounters that and has the option. However when the Fleet A retreats and player is given another dialog interaction, the option disappears. I'm a little confused why, that's likely either Fleet A and B are merging together and memories don't overlap? Or is it because the dialog interaction is unlucky and accessing Fleet B's memory instead?

Either way, is there a code that can scan nearby fleets of their memory then? Since it seems the dialog interaction combines the fleets together as part of the enemy forces.
Code
        @Override
        public void reportShownInteractionDialog (InteractionDialogAPI dialog) {
            if (dialog.getInteractionTarget().getMemoryWithoutUpdate().getBoolean("$can_dogfight")) {
                dialog.getOptionPanel().addOption("Order your second-in-command to harass their frigates", "optionid_dogfight");
                dialog.getOptionPanel().setEnabled("optionid_dogfight", false);
                dialog.getOptionPanel().setTooltip("optionid_dogfight", "Before the battle begins, you may expend a story point to soften up the enemy's frigates and their destroyers.");
            }
        }

I think the option disappearing is due to how you're adding the option - reportShownInteractionDialog() is only going to get called *once* at the start of the encounter. While the battle is ongoing, the dialog is still "up", and you return to it once the current engagement is over, so it's not "shown" again at that point. I don't think there's an easy/good way to resolve this, short of providing a replacement for FleetInteractionDialogPluginImpl, which is going to conflict with any mods that also do this (i.e. Nexerelin).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on October 26, 2021, 04:38:29 PM
In my mod I have a functional toggle ability that a user has requested be tied into a hull mod for it to work. I have tried several ways to make this happen but I cannot seem to figure out how to go about it and rather than going over my many failed attempts I just would like to ask:

Is is possible to do and if so how?

You mean an active campaign ability, yes? IIRC there's an "isUsable()" method the ability plugin and you could check for ship-with-hullmod presence there.


I looked over all the abilities in starsector core as well as the few I found in other mods and though I do see some "public boolean isUsable()" lines, none of them address a hullmod being referenced. I thank you for your reply and I will keep researching.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on October 27, 2021, 08:01:00 AM
Follow up to my previous question: Is there an option to require a certain type of ship to be in the players fleet using a public boolean isUsable() line in an ability? I am essentially attempting to make it so that an active campaign ability in my mod will not show up in the available abilities to be added to the players toolbar unless the player has that type of ship in their fleet inventory.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 28, 2021, 08:36:37 PM
So I noticed a weirdness in population growth when planet-condition-only markets are converted to normal markets via mod code (i.e. colonizing a planet via code). Possibly related to this older issue (https://fractalsoftworks.com/forum/index.php?topic=5061.msg319528#msg319528).

How to repro:
Spoiler
- Load a vanilla or lightly modded save from fairly late into the game, like cycle 212 or later (the ones here (https://fractalsoftworks.com/forum/index.php?topic=20035.msg310169#msg310169) will do nicely)
- Run the following code on a 100% hazard, uncolonized planet (in the save provided above, one such market is the one on planet ID "system_185c:planet_1")
Important: AFAICT the colony needs to have a positive growth rate immediately for this to work, which is why the spaceport construction is made instant

Code: java
public static void createColonyStatic(MarketAPI market) 
{
log.info("Colonizing market " + market.getName() + ", " + market.getId());
String factionId = Factions.PLAYER;

market.setSize(3);
market.addCondition("population_3");
market.setFactionId(factionId);
market.setPlanetConditionMarketOnly(false);

if (market.hasCondition(Conditions.DECIVILIZED))
{
market.removeCondition(Conditions.DECIVILIZED);
market.addCondition(Conditions.DECIVILIZED_SUBPOP);
}
market.addIndustry(Industries.POPULATION);

market.addSubmarket(Submarkets.LOCAL_RESOURCES);
market.addSubmarket(Submarkets.SUBMARKET_STORAGE);

market.setSurveyLevel(MarketAPI.SurveyLevel.FULL);
for (MarketConditionAPI cond : market.getConditions())
{
cond.setSurveyed(true);
}

Global.getSector().getEconomy().addMarket(market, true);
market.getPrimaryEntity().setFaction(factionId);

market.setPlayerOwned(true);
market.addIndustry(Industries.SPACEPORT);
SubmarketAPI storage = market.getSubmarket(Submarkets.SUBMARKET_STORAGE);
if (storage != null)
((StoragePlugin)storage.getPlugin()).setPlayerPaidToUnlock(true);
}
- Do not open the colony screen (D hotkey) or interact with the newly colonized planet.

At the next economy tick, the new colony jumps to size 5 or 6 instantly.
- This does not happen if the player opens the colony screen (e.g. to check the actual colony growth progress), this seems to make the game notice "oh something is wrong" and fix it.
- Adding the following code to the end of the method does not suppress the behavior:
Code: java
ImmigrationPlugin plugin = getImmigrationPlugin(market);
float min = plugin.getWeightForMarketSize(market.getSize());
market.getPopulation().setWeight(min);
market.getPopulation().normalize();
[close]
Is this possible to fix modside? I could forcibly pop up the colony screen when creating the colony, but that'd be annoying for the player.

Follow up to my previous question: Is there an option to require a certain type of ship to be in the players fleet using a public boolean isUsable() line in an ability? I am essentially attempting to make it so that an active campaign ability in my mod will not show up in the available abilities to be added to the players toolbar unless the player has that type of ship in their fleet inventory.
There doesn't seem to be a way to make an ability hidden (if the player already has it), only disabled.

For enabling/disabling the ability though, the ability plugin can get the fleet it's on (with getFleet()), which in turn knows what ships are in itself, so it's just a matter of checking those.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 29, 2021, 09:51:47 AM
... the heck! It turns out that CoreImmigrationPluginImpl runs 100 iterations of increasing the population in its advance() method if market.wasIncomingSetBefore() returns false. I'm not sure *why* it's doing this - maybe a holdover from when things worked differently? Or perhaps it's needed to stabilize the population composition of the core worlds - which isn't actually *used* anywhere.

Good news is it should be easy to get around - just call:
market.setIncoming(new PopulationComposition());
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 29, 2021, 06:42:20 PM
Follow up to my previous question: Is there an option to require a certain type of ship to be in the players fleet using a public boolean isUsable() line in an ability? I am essentially attempting to make it so that an active campaign ability in my mod will not show up in the available abilities to be added to the players toolbar unless the player has that type of ship in their fleet inventory.

I did something like that for the Roider Union's Argos conversions ability, but I just made a one and done script for it. If the player ever gets an Argos, then they learn the ability for the rest of time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on October 29, 2021, 08:05:58 PM
Ty SafariJohn but I decided to remove the ability from my mod and make it a separate utility mod for players who would like the convenience of it but not interested in playing my faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on October 30, 2021, 02:26:03 PM
I am trying to replicate lists shown in Codex. Specifically, I want a list of weapons, ship hulls and fighter wings. I start with the list from Global.getSettings().getAllWeaponsSpecs() / getAllShipHullSpecs() / getAllFighterWingSpecs() and filter out... well, what exactly?

Currently, I am pretty close to matching Codex lists, I do:


Almost is not exactly same, so how could I get it right?

Edit: Forgot about modspecs - right now just filtering based on `isHidden`. I want to list all modspecs can possibly show up in a market.

Edit 2: Just noticed Ravelin, Merlon and Gargoyle do list in codex. I'll manually remove them then. After thinking some more, it might be more correct for me to go over factions and build a list of known weapons, ships, hullmods, and fighters from that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 30, 2021, 03:45:08 PM
Honestly, I'd say the Codex is not the best point of reference. As you noted from the Ravelin et al being present it's not entirely correct, and generally it's in need of an overhaul at some point - it hasn't really kept up or been properly updated for a very long time..
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on October 30, 2021, 06:21:34 PM
Deleted, I figured my question out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on November 01, 2021, 01:30:43 AM
The HintPanelAPI should be adjusted I think.
Currently we must put in the index, and it has low compatibility that we can not judge if there are other guys using hint panel.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2021, 09:44:46 AM
The HintPanelAPI should be adjusted I think.
Currently we must put in the index, and it has low compatibility that we can not judge if there are other guys using hint panel.

I see what you mean. But, hmm - I'm having a hard time picturing a situation where multiple mods are using HintPanel simultaneously and something hasn't already gone very wrong. That aside, though, that API is just not intended for multiple simultaneous use by different uncoordinated bits of code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on November 02, 2021, 07:21:41 AM
Does anyone know how to add a jump point to an existing system? I tried using the code used to normally generate jump points but the point has no exit to hyperspace and crashes the game upon being selected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on November 02, 2021, 10:15:46 AM
I see what you mean. But, hmm - I'm having a hard time picturing a situation where multiple mods are using HintPanel simultaneously and something hasn't already gone very wrong. That aside, though, that API is just not intended for multiple simultaneous use by different uncoordinated bits of code.
fine... and I need a bigger cargo picker ui :'( :'( :'(!!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on November 03, 2021, 07:15:41 AM
QuickQ:

Is it possible to adjust min/max crew in a .skin file?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on November 03, 2021, 10:08:06 AM
QuickQ:
Is it possible to adjust min/max crew in a .skin file?
I don't know for sure but, if you look at the XIV skin file, you can see modifications to the OP and cost. Both of those are part of the ships_data.csv along with min/max crew so maybe its the same operations using different fields?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 03, 2021, 11:34:07 AM
Does anyone know how to add a jump point to an existing system? I tried using the code used to normally generate jump points but the point has no exit to hyperspace and crashes the game upon being selected.

Your best bet would probably be to find a mod that does this and look at the code. I believe you'd need to manually add the exit point in hyperspace and link them up using .addDestination().

QuickQ:

Is it possible to adjust min/max crew in a .skin file?

Aside from adding a built-in hullmod, I don't believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 04, 2021, 02:42:20 AM
Could you share implementation of tooltipMakerAPI.shortenString? Specifically, the logic where you decide whether text fits the desired length (or more precisely, how you determine text length). I am trying to implement this, and so far managed to get it (with some hacks) to mostly work, but it will require you to install Insignia (true type) font system-wide (will default to Dialog if not found, results still acceptable but no longer consistent):

Code
    protected float getTextWidth(String text) {
        Font font = new Font("Insignia", Font.PLAIN, 12);
        FontRenderContext frc = new FontRenderContext(font.getTransform(), true, true);
        double longTextAdjustment = 40 + text.length() * 0.5;// it wasn't pixel perfect, probably due to rasterized version having different letter widths
        return (float) (font.getStringBounds(text, frc).getWidth() + longTextAdjustment);
    }

Alternatively, I would like to ask for TooltipMakerAPI.stringWidth() method (that uses currently selected font, something I assume shortenString() takes account for). My main use case is to create a button large enough to hold its label.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 04, 2021, 08:05:37 AM
Sure, let me add some methods! Sharing the implementation would not be particularly useful, I don't think, since it uses an internal text rendering class which uses the data loaded from the various .fnt files the game comes with.

Added SettingsAPI.computeStringWidth(String in, String font)
Added TooltipMakerAPI.computeStringWidth(String in)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 04, 2021, 09:06:26 AM
Thanks! Slapping @Deprecated(since=0.95.1) on my method. You shall not be missed ;)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 04, 2021, 09:32:35 AM
 ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 05, 2021, 08:41:33 AM
Forum kept eating my changes to the post. Seems like finding # inside a JSON values breaks the whole reader (Global.getSettings().load()), for example:

Example JSON:
Code
{
    "STORAGE_BOARD_NO_CONTENT": "You do not have anything in your storage.",
    "STORAGE_BOARD_CONTENT": "You have {0, choice, 0#no items|1#one item|1<{0, number, integer} items} and {1, choice, 0#no ships|1#one ship|1<{1, number, integer} ships} stored.",
    "STORAGE_INTEL_CONTENT": "{0, choice, 0#no items|1#one item|1<{0, number, integer} items} and {1, choice, 0#no ships|1#one ship|1<{1, number, integer} ships}"
}

Edit: seems to hate # - aaah, you treat them as a comment, probably shouldn't inside a "". I can work around it by using a different character instead of # and replacing after loading is done, but that's a bit iffy :(

Edit 2: Posted a bug report: https://fractalsoftworks.com/forum/index.php?topic=22917
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 05, 2021, 01:01:26 PM
... and I need a bigger cargo picker ui :'( :'( :'(!!

(Added a version of showCargoPicker etc that takes width/height as parameters...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 06, 2021, 07:30:41 AM
What's the button color of active tab? Say, intel screen - currently selected tab? Closest I got so far is: Misc.scaleColor(Global.getSettings().getColor("buttonBg"), 0.7f) but it's not THE color :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2021, 09:12:30 AM
That's actually achieved by rendering the button background again on top of it, additively, so I'm not sure what the exact color would be. Let me add highlight()/unhighlight() to ButtonAPI, since that's how the game does it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on November 06, 2021, 09:14:07 PM
Hello world, it's been a while.

My question: how would I make a ship have unlimited peak performance time, without altering its entry under ship_data.csv?

I know that one can simply leave the peak CR sec value under the ship entry blank to achieve this, but I was hoping to instead achieve this by either using a .skin file or even a script attached to a built-in hullmod.

Any good places to start? For example, I can getPeakCRDuration() via MutableShipStatsAPI (the same way the vanilla Hardened Subsystems hullmod does it), but after that I'm pretty much stuck...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on November 07, 2021, 07:42:21 AM
Is it possible to hide a variant in the Codex without hiding the other variants for that class?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2021, 08:32:34 AM
Hello world, it's been a while.

My question: how would I make a ship have unlimited peak performance time, without altering its entry under ship_data.csv?

I know that one can simply leave the peak CR sec value under the ship entry blank to achieve this, but I was hoping to instead achieve this by either using a .skin file or even a script attached to a built-in hullmod.

Any good places to start? For example, I can getPeakCRDuration() via MutableShipStatsAPI (the same way the vanilla Hardened Subsystems hullmod does it), but after that I'm pretty much stuck...

Hi! I'd suggest copying data.hullmods.HardenedSubsystems and then doing:
stats.getPeakCRDuration().modifyFlat(id, 1000000f);

Peak times >100,000 are treated as infinite, so increasing it by a million should cover most cases (i.e. unless something else reduces it by more than a factor of 10).

Is it possible to hide a variant in the Codex without hiding the other variants for that class?

I don't believe so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on November 07, 2021, 12:26:19 PM
Thank you Alex!

Your solution works as intended in the combat battlespace (i.e. no PPT timer ticking down).

However, when outside of combat, the codex entry (or ship card in the Refit/Fleet screens) displays this as a number instead of simply showing the word "Unlimited" (i.e. what it normally does for ships that have a blank value in the CSV).

Might there be another code solution to clean up this aesthetic? Or perhaps should I log this as a request for a future build of Starsector?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2021, 12:37:49 PM
You're welcome!

I think you can get around this by doing:
stats.getCRLossPerSecondPercent().modifyMult(id, 0f);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 09, 2021, 02:26:53 AM
I am trying to recreate `showCargo()` and `showShips()` behaviour, already pretty close to it with my `showPeople()`. Now I am adding a new one - showAny - a generalized and custom way of showing a list. It builds up on beginImageWithText(), addPara(), and addImageWithText(). While I managed to get it work for PersonAPI and FleetMemberAPI (except it's not icon, image is not a square), I struggle to get correct (or any) icon for CargoStackAPI. Could you show how icon is determined in `showCargo()` (and also in `showShips()`) please? Or will I be lacking unobfuscated code to actually implement that (I have a feeling you directly render inside those methods)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 09, 2021, 10:10:13 AM
Yeah, the rendering for all of these is done with some internal (and relatively involved) code, it's not as simple as just drawing a sprite. Consider that blueprints are composited from a base image and what they're a blueprint of, and that ship icons have a faint grid overlaid on top of them, that sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 09, 2021, 02:18:04 PM
Honestly, I'd say the Codex is not the best point of reference. As you noted from the Ravelin et al being present it's not entirely correct, and generally it's in need of an overhaul at some point - it hasn't really kept up or been properly updated for a very long time..

Sadly, I have to redo my list building. Indeed, Codex is a bad reference - even if something is seen there, it does not mean it is known by anyone and thus might not be showing up in any market. With other mods adding semi-hidden stuff, I need a better way to build those lists. Right now I am considering iterating over each (non-hidden) faction and building a known list of ids (for weapons, hullmods, fighter wings, and ships). Is there a better way?


Also, is it possible to tap into "Show on map" button (or recreate its functionality)? I'd like to add a custom button with a different SectorEntityToken to intel's one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on November 11, 2021, 08:59:53 AM
I'm trying to make a command to search for derelict ships. If I had the SectorEntityToken object of a derelict ship, how would I find what type of hull it is?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2021, 09:10:58 AM
Also, is it possible to tap into "Show on map" button (or recreate its functionality)? I'd like to add a custom button with a different SectorEntityToken to intel's one.

It's not currently possible, no. Best you could do is swap out what the getMapLocation() method on the intel returns...

I'm trying to make a command to search for derelict ships. If I had the SectorEntityToken object of a derelict ship, how would I find what type of hull it is?

Something along the lines of:
((DerelictShipEntityPlugin)entity.getPlugin()).getData().ship

And then see the PerShipData class for the specific data members in that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 11, 2021, 10:30:48 AM
Also, is it possible to tap into "Show on map" button (or recreate its functionality)? I'd like to add a custom button with a different SectorEntityToken to intel's one.

It's not currently possible, no. Best you could do is swap out what the getMapLocation() method on the intel returns...

That would be enough if there was a way to trigger the button click without actually clicking it... Oh. Oooooh. Swap token with desired one, use AWT keyboard to send S, swap back. Custom show location buttons here I come!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2021, 10:39:07 AM
Oh, nice idea! *Seems* like it ought to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on November 11, 2021, 10:57:11 AM
Is it possible to hide a variant in the Codex without hiding the other variants for that class?
I don't believe so.
If I made a new .skin file that did nothing except add the HIDE_IN_CODEX hint, would that hide all the variants that use the skin as it was a base hull?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2021, 11:36:49 AM
If I made a new .skin file that did nothing except add the HIDE_IN_CODEX hint, would that hide all the variants that use the skin as it was a base hull?

You could try it and see :) Make sure to put all of the base hull's hints in the skin file, too, since if that's present it will be considered the complete set of hints for that hull, not additions to it. (Likewise for tags etc.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on November 11, 2021, 06:00:12 PM
Is there any way that IntelManagerAPI.getIntel(PersonBountyIntel.class) could be returning classes that aren't PersonBountyIntels? I've run into an interesting cross-mod interaction- Fleet Action History has the following code:
    for (IntelInfoPlugin i : Global.getSector().getIntelManager().getIntel(PersonBountyIntel.class)) {
      String bountyString = ((PersonBountyIntel) i).getName();
      /* ... */
    }

This causes a ClassCastException error when it runs into a (unofficially updated) Vayra's Sector VayraPersonBountyIntel object because that object extends BaseIntelPlugin, not PersonBountyIntel and thus can't be cast to a PersonBountyIntel. But that also means that getIntel(PersonBountyIntel.class) shouldn't be returning it in the first place.

Also worth noting that this is a one-off crash that I haven't been able to replicate, but the player who reported it was able to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 11, 2021, 07:01:52 PM
Addendum to previous: Could the fact that previous versions of Vayra's Sector did have VayraPersonBountyIntel extend PersonBountyIntel be affecting it (in some weird, incomprehensible way)?

(requoted since it's on previous page)
Is there any way that IntelManagerAPI.getIntel(PersonBountyIntel.class) could be returning classes that aren't PersonBountyIntels? I've run into an interesting cross-mod interaction- Fleet Action History has the following code:
    for (IntelInfoPlugin i : Global.getSector().getIntelManager().getIntel(PersonBountyIntel.class)) {
      String bountyString = ((PersonBountyIntel) i).getName();
      /* ... */
    }

This causes a ClassCastException error when it runs into a (unofficially updated) Vayra's Sector VayraPersonBountyIntel object because that object extends BaseIntelPlugin, not PersonBountyIntel and thus can't be cast to a PersonBountyIntel. But that also means that getIntel(PersonBountyIntel.class) shouldn't be returning it in the first place.

Also worth noting that this is a one-off crash that I haven't been able to replicate, but the player who reported it was able to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2021, 07:18:25 PM
About the only way I could see this happening is if there was code that did:

Global.getSector().getIntelManager().getIntel(PersonBountyIntel.class).add(<a VayraPersonBountyIntel object)

Otherwise, that seems impossible. Well, unless there's a very fundamental bug in core utility code that's been exercised a *lot* and not changed for a very long time; odds of this being the case seem exceedingly low, since this (the returned list only containing objects castable to the passed-in class) is an assumption that's relied in everywhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 12, 2021, 07:53:18 AM
How do I use `TooltipMakerAPI`s `setXAlignOffset()`? Specifically, how do I reset it so it's back to (0?) for the next usage?

I move the last added element by 6 to the left, and (naively) reset tooltip back to 0, but every next item that is added starts aligned by -6.

Code
        tooltip.getPrev().getPosition().setXAlignOffset(-6);
        tooltip.getPosition().setXAlignOffset(6);

Edit: Might there be a bug in the logic? I worked around this by:

Code
        tooltip.getPrev().getPosition().setXAlignOffset(-6);
        tooltip.addSpacer(0);
        tooltip.getPrev().getPosition().setXAlignOffset(6);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 12, 2021, 08:37:24 AM
It doesn't look like there's a bug; it looks like your actual solution is correct.

Calling:
tooltip.getPosition().setXAlignOffset(6);
Is going to adjust the position of the tooltip within its parent component, which is not what you want at all.

And since components are added below the left edge of the previous one, what you're doing is exactly right - move component to the right, add a 0-height spacer, and move the spacer to the left so that whatever goes below it is back to the normal alignment. It's part of why addSpacer() is there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 12, 2021, 08:52:21 AM
Oh, now it all makes sense. I assumed there was an internal variable offsetX that I could manipulate. Instead I just manipulate position via adding offset to existing position.

Perhaps a moveByOffsetX would be clearer here. I'll add some documentation to my API version. Thanks for explaining.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on November 12, 2021, 10:46:12 AM
How do I get `buttonPressConfirmed(Object buttonId, IntelUIAPI ui)` to redirect to `Global.getSector().getCampaignUI().showCoreUITab(CoreUITabId.CARGO)` instead of intel tab?
This:

Code
    @Override
    public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
        Global.getSector().getCampaignUI().showCoreUITab(CoreUITabId.CARGO);
    }

Does not work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 12, 2021, 11:26:37 AM
`buttonPressConfirmed` is for button clicks on the intel you are displaying. If you want to "hijack" ui, you could try putting that code in say createSmallIntel.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on November 12, 2021, 02:03:27 PM
About the only way I could see this happening is if there was code that did:

Global.getSector().getIntelManager().getIntel(PersonBountyIntel.class).add(<a VayraPersonBountyIntel object)

Otherwise, that seems impossible. Well, unless there's a very fundamental bug in core utility code that's been exercised a *lot* and not changed for a very long time; odds of this being the case seem exceedingly low, since this (the returned list only containing objects castable to the passed-in class) is an assumption that's relied in everywhere.

That's what I figured, I suppose hoping for a bug in core java was too much to ask. Still haven't been able to replicate it, so I'm gonna pretend it's user error for now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on November 12, 2021, 04:20:30 PM
Is the correct use for renderOrderMod to have a number following it with higher numbers making weapon slots render above any slot with a lower number (or no renderOrderMod set)?
I have renderOrderMod": 1 on a weapon slot (along with the slot having a higher id number) but it and any weapon mounted on it still render under a nearby slot with no renderOrderMod line.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 13, 2021, 05:32:14 AM
Oh, nice idea! *Seems* like it ought to work.

It works: https://cdn.discordapp.com/attachments/824910699415207937/909072511617105920/show-any-market.gif

One caveat though, cannot revert token back to what it was in the same "click" handler, as AWT-sending keystroke is handled in another thread, and by the time it is picked up, the token will be reverted. So instead I let it be whatever was the last one set, and in advance reset it to what it was.

Edit 1:
Question (about efficiency):
Code
    @Override
    public void advance(float amount) {
        setSectorEntityToken(resultSet.getSystemToken());
    }

Or:
Code
    @Override
    public void advance(float amount) {
        if (resultSet.getSystemToken() != getSectorEntityToken()) {
            setSectorEntityToken(resultSet.getSystemToken());
        }
    }

Or perhaps even add script on token swap, let it run while paused, and fix it after X frames have been rendered?

Edit 2:
Ok, self-removing, run while pause advance works like a champ.
Code
    @Override
    public void advance(float amount) {
        advancedAmount += amount;
        if (advancedAmount > 1) {
            setSectorEntityToken(resultSet.getSystemToken());
            SectorUtils.removeScript(this);
            advancedAmount = 0;
        }
    }

Now, if only I could get those new button CutStyles (nothing looks good so far)...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 13, 2021, 12:10:16 PM
How do I get `buttonPressConfirmed(Object buttonId, IntelUIAPI ui)` to redirect to `Global.getSector().getCampaignUI().showCoreUITab(CoreUITabId.CARGO)` instead of intel tab?
This:

Code
    @Override
    public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
        Global.getSector().getCampaignUI().showCoreUITab(CoreUITabId.CARGO);
    }

Does not work.

Hmm - this method just doesn't work if you're interacting with an entity. For example it'll work if you open the intel screen while flying in space, but it doesn't work if you do it while docked at Jangala.


Is the correct use for renderOrderMod to have a number following it with higher numbers making weapon slots render above any slot with a lower number (or no renderOrderMod set)?
I have renderOrderMod": 1 on a weapon slot (along with the slot having a higher id number) but it and any weapon mounted on it still render under a nearby slot with no renderOrderMod line.

It's a modifier to the default render order, which is based on weapon size and slot type. For example, hardpoints render under turrets, and larger weapons render over smaller ones, etc. I'd suggest experimenting with the values to find one that works for what you want; something in the -30 to 30 range should do the job.

Edit 2:
Ok, self-removing, run while pause advance works like a champ.

*thumbs up*, looks good!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on November 14, 2021, 06:40:29 AM
How to generate a gravity well for a gas giant manually without using autogenerateHyperspacePoints? I’m trying to add a gas giant into an existing system and it doesn’t spawn with a gravity well if this is not used, while if it is used it spawns duplicates of existing jump points.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 14, 2021, 06:54:24 AM
You need to spawn a jump point using FactoryAPI.createJumpPoint(), put it in hyperspace orbiting the star's JP, and set it up so it looks like normal gas giant JPs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xaiier on November 14, 2021, 04:28:45 PM
What is the best way to prevent the AI from taking manual control of a weapon? I have a unique weapon which requires custom aiming logic with an AutofireAIPlugin, but when the AI selects the group, it reverts to the default "mouse aim" AI which is unsuitable for the weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 15, 2021, 10:07:20 AM
What is the best way to prevent the AI from taking manual control of a weapon? I have a unique weapon which requires custom aiming logic with an AutofireAIPlugin, but when the AI selects the group, it reverts to the default "mouse aim" AI which is unsuitable for the weapon.

I think if you add the PD hint that might do it, though that'll also have an impact on the AI's understanding of what range the ship should try to maintain vs an enemy. Making its size "small" might also have an effect. If it's a missile, the DO_NOT_CONSERVE and DO_NOT_AIM hints may help, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex_Sans on November 15, 2021, 12:36:29 PM
Is it possible to mod the player faction music (when you land on your colony or interact with your patrol) without changing the Independent and/or Persean League?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 16, 2021, 03:53:01 AM
How do one use LabelAPI.computeTextHeight(string)? Is it what the height would be had the text been vertically rendered? For a 65 tall PositionAPI, the call returned me 998 when I passed same string as I did to original addPara().

Also, I think we are missing the ability to set font on an AreaCheckbox, tried all four and didn't change:

Code
        tooltip.setButtonFontVictor10();// this would be expected one to work, since it returns ButtonAPI
        tooltip.setParaFont(Fonts.VICTOR_10);
        tooltip.setTitleFont(Fonts.VICTOR_10);
        tooltip.setGridFont(Fonts.VICTOR_10);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2021, 07:57:38 AM
Is it possible to mod the player faction music (when you land on your colony or interact with your patrol) without changing the Independent and/or Persean League?

Yeah - you'd specify the music in the player.faction file. See, say, hegemony.faction for an example.


How do one use LabelAPI.computeTextHeight(string)? Is it what the height would be had the text been vertically rendered? For a 65 tall PositionAPI, the call returned me 998 when I passed same string as I did to original addPara().

It returns the number of linebreaks in the string (plus one) times the "line height" of the font.

... except, oops, it was calling computeStringWidth() under the hood! Fixed that up, thank you :)

Also, I think we are missing the ability to set font on an AreaCheckbox, tried all four and didn't change:

Code
        tooltip.setButtonFontVictor10();// this would be expected one to work, since it returns ButtonAPI
        tooltip.setParaFont(Fonts.VICTOR_10);
        tooltip.setTitleFont(Fonts.VICTOR_10);
        tooltip.setGridFont(Fonts.VICTOR_10);

Yeah, that's not currently configurable. Let me add these to TooltipMakerAPI:
void setAreaCheckboxFont(String areaCheckboxFont);
void setAreaCheckboxFontDefault();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on November 16, 2021, 08:59:58 AM
Also, is it possible to tap into "Show on map" button (or recreate its functionality)? I'd like to add a custom button with a different SectorEntityToken to intel's one.

It's not currently possible, no. Best you could do is swap out what the getMapLocation() method on the intel returns...

I'm trying to make a command to search for derelict ships. If I had the SectorEntityToken object of a derelict ship, how would I find what type of hull it is?

Something along the lines of:
((DerelictShipEntityPlugin)entity.getPlugin()).getData().ship

And then see the PerShipData class for the specific data members in that.

This code above for finding derelict ship hull type didn't work. SectoryEntityToken doesn't have a getPlugin method, so I'm assuming you meant ((DerelictShipEntityPlugin)entity.getCustomEntitySpec().getPlugin()).getData().ship . I tried this but getData returns null when I tried this code on a derelict ship entity. Any idea what's wrong
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2021, 01:03:09 PM
Erm, it should be getCustomPlugin() instead of getPlugin() in my original code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 18, 2021, 05:57:10 AM
I am copying an existing commodity supply's modifiers to a custom commodity, which almost works correctly. The problem I have is if the custom commodity has a global excess, it isn't marked as a surplus.

Is this a bug, a consequence of my hack job, or did I just miss something?

Here is exactly what I am doing:

Spoiler
The call:
Code: java
supply(id, market, Industries.POPULATION, PERSEAN_MEDIA, Commodities.CREW, PERSEAN_MEDIA_MOD);

The method:
Code: java
public static void supply(String id, MarketAPI market, String industry,
            String commodity, String sourceCom, int modifier) {
    BaseIndustry ind = (BaseIndustry) market.getIndustry(industry);

    if (ind == null) return;

    MutableStat source = ind.getSupply(sourceCom).getQuantity();
    ind.supply(id, commodity, 0, "");

    MutableStat supply = ind.getSupply(commodity).getQuantity();
    for (MutableStat.StatMod mod : source.getFlatMods().values()) {
        if (mod.desc != null && mod.desc.contains("Base value")) {
            supply.modifyFlat(id + mod.source, mod.value + modifier, mod.desc);
            continue;
        }

        supply.modifyFlat(id + mod.source, mod.value, mod.desc);
    }
    for (MutableStat.StatMod mod : source.getPercentMods().values()) {
        supply.modifyFlat(id + mod.source, mod.value, mod.desc);
    }
    for (MutableStat.StatMod mod : source.getMultMods().values()) {
        supply.modifyFlat(id + mod.source, mod.value, mod.desc);
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 18, 2021, 07:54:16 AM
... and I need a bigger cargo picker ui :'( :'( :'(!!

(Added a version of showCargoPicker etc that takes width/height as parameters...)

What about fleet member pickers? We have `showFleetMemberPickerDialog` that takes in rows and columns (and icon size), and now we have `showCargoPickerDialog` now that takes in width and height instead - could that be standardized? Say `showFleetMemberPickerDialog()` that also takes width and height (and uses same-ish icon size as showCargoPickerDialog grid size).

As it is, for the former to fill "whole screen", I need to get screen size, pick icon size, calculate the number of rows and columns I could fit in the given screen size (float), take the rows and columns again (as floor int now), calculate the new icon size, and finally I know the right sizes to "more or less" fill the whole screen.

So far I've been using 7 rows, 10 columns and 92 icon size to make `showFleetMemberPickerDialog` sameish size as `showCargoPickerDialog`.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 18, 2021, 04:29:51 PM
I am copying an existing commodity supply's modifiers to a custom commodity, which almost works correctly. The problem I have is if the custom commodity has a global excess, it isn't marked as a surplus.

Is this a bug, a consequence of my hack job, or did I just miss something?

Here is exactly what I am doing:

Hmm, it's hard to say. Does this work if you apply it to a standard commodity? If so, that'd indicate the problem is with the commodity, otherwise it's probably something else.

And I'm assuming you've looked at the commodity detail dialog to see what that shows?


What about fleet member pickers? We have `showFleetMemberPickerDialog` that takes in rows and columns (and icon size), and now we have `showCargoPickerDialog` now that takes in width and height instead - could that be standardized? Say `showFleetMemberPickerDialog()` that also takes width and height (and uses same-ish icon size as showCargoPickerDialog grid size).

As it is, for the former to fill "whole screen", I need to get screen size, pick icon size, calculate the number of rows and columns I could fit in the given screen size (float), take the rows and columns again (as floor int now), calculate the new icon size, and finally I know the right sizes to "more or less" fill the whole screen.

So far I've been using 7 rows, 10 columns and 92 icon size to make `showFleetMemberPickerDialog` sameish size as `showCargoPickerDialog`.

Hmm, I don't think I'm going to try standardizing this. I just added the width/height parameters for the cargo picker because it also has a side panel which can have its own size, and it seemed to make more sense, but imo the two dialog types aren't similar enough to want to make this uniform.

(I can see how being able to specify rows/columns for cargo picked would be handy, though. Maybe at some point! For now it's just down to figuring out what the width/height ought to be to get the desired result.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on November 18, 2021, 07:35:17 PM
I am trying to add a built-in hull mod (non S-mod) to player ships via member.getVariant().addPermaMod("name", false), where member is an instance of FleetMemberAPI.

It works most of the time, however on some ships there is some strange behavior: the hull mod shows up in the fleet summary screen (hovering over the question mark on a ship with it installed), but does not show up in the refit screen. And, when saving the game and reloading, the hull mod disappears entirely. Does anyone know why this might be happening?

Also, I'm encountering some strange behavior with settings.json. I've since moved the mod settings to a different file, so it doesn't really matter now, but I wasn't able to get any of the json entries to actually load other than ruleCommandPackages. When I attached a debugger to the game, it showed that the JSONObject variable contained all the entries of a different enabled mod and nothing else. With multiple mods enabled, it contained entries from only one of the mods. With no other mods enabled, it worked as intended. Is there something about settings.json that I'm missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on November 19, 2021, 12:27:19 AM
Anyone know how to stop hyperspace storm clouds from spawning around a system in hyperspace?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 19, 2021, 01:58:18 AM
Hmm, I don't think I'm going to try standardizing this. I just added the width/height parameters for the cargo picker because it also has a side panel which can have its own size, and it seemed to make more sense, but imo the two dialog types aren't similar enough to want to make this uniform.

(I can see how being able to specify rows/columns for cargo picked would be handy, though. Maybe at some point! For now it's just down to figuring out what the width/height ought to be to get the desired result.)

Fair enough. Perhaps unification could happen one day with a new version that uses "whole screen" instead?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 19, 2021, 10:22:23 PM
I am trying to add a built-in hull mod (non S-mod) to player ships via member.getVariant().addPermaMod("name", false), where member is an instance of FleetMemberAPI.

It works most of the time, however on some ships there is some strange behavior: the hull mod shows up in the fleet summary screen (hovering over the question mark on a ship with it installed), but does not show up in the refit screen. And, when saving the game and reloading, the hull mod disappears entirely. Does anyone know why this might be happening?
The variant is probably still marked as a stock variant, so the hullmod gets reverted on save/load, and doesn't appear in refit screen till the player completes a refit.
See if doing this before adding the perma-mod works:
Code: java
member.setVariant(member.getVariant().clone(), false, false);
member.getVariant().setSource(VariantSource.REFIT);
Quote
Also, I'm encountering some strange behavior with settings.json. I've since moved the mod settings to a different file, so it doesn't really matter now, but I wasn't able to get any of the json entries to actually load other than ruleCommandPackages. When I attached a debugger to the game, it showed that the JSONObject variable contained all the entries of a different enabled mod and nothing else. With multiple mods enabled, it contained entries from only one of the mods. With no other mods enabled, it worked as intended. Is there something about settings.json that I'm missing?
Might be worth checking if that other mod has settings.json in its replace array (although that sounds like it'd completely break the game unless the mod duplicated all the vanilla settings values)

Anyone know how to stop hyperspace storm clouds from spawning around a system in hyperspace?
Do you need the stormless deep hyper to still be there? If not, can just clear deep hyper from around the system:
Code: java
	public static void clearDeepHyper(SectorEntityToken entity, float radius) {
HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
NebulaEditor editor = new NebulaEditor(plugin);

float minRadius = plugin.getTileSize() * 2f;
editor.clearArc(entity.getLocation().x, entity.getLocation().y, 0, radius + minRadius * 0.5f, 0, 360f);
editor.clearArc(entity.getLocation().x, entity.getLocation().y, 0, radius + minRadius, 0, 360f, 0.25f);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on November 20, 2021, 02:56:36 PM
The variant is probably still marked as a stock variant, so the hullmod gets reverted on save/load, and doesn't appear in refit screen till the player completes a refit.
See if doing this before adding the perma-mod works:
Code: java
member.setVariant(member.getVariant().clone(), false, false);
member.getVariant().setSource(VariantSource.REFIT);

Thanks, that seems to have fixed it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 20, 2021, 06:08:29 PM
Where is RepTrackerEvent instantiated and added to the sector? No instance of it seems to be created anywhere in the API I have.

(trying to modify how trade-with-enemies rep penalty is handled)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2021, 06:54:38 PM
Where is RepTrackerEvent instantiated and added to the sector? No instance of it seems to be created anywhere in the API I have.

It's in data/config/events.json. That whole file pretty much deprecated but a couple of things are still done through it just because I hadn't got around to moving them out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on November 21, 2021, 04:46:07 AM
Anyone know how to stop hyperspace storm clouds from spawning around a system in hyperspace?
Do you need the stormless deep hyper to still be there? If not, can just clear deep hyper from around the system:
Code: java
	public static void clearDeepHyper(SectorEntityToken entity, float radius) {
HyperspaceTerrainPlugin plugin = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin();
NebulaEditor editor = new NebulaEditor(plugin);

float minRadius = plugin.getTileSize() * 2f;
editor.clearArc(entity.getLocation().x, entity.getLocation().y, 0, radius + minRadius * 0.5f, 0, 360f);
editor.clearArc(entity.getLocation().x, entity.getLocation().y, 0, radius + minRadius, 0, 360f, 0.25f);
}

I applied this to my game, but it causes a NullPointerException when generating a new save. Is there a possible reason why? I believe I added the appropriate imports too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 21, 2021, 11:35:28 AM
I am copying an existing commodity supply's modifiers to a custom commodity, which almost works correctly. The problem I have is if the custom commodity has a global excess, it isn't marked as a surplus.

Is this a bug, a consequence of my hack job, or did I just miss something?

Here is exactly what I am doing:

Hmm, it's hard to say. Does this work if you apply it to a standard commodity? If so, that'd indicate the problem is with the commodity, otherwise it's probably something else.

Think I figured out my problem: global excesses don't produce surpluses normally. ::) Looks like it is correctly marked surplus if I nuke the planets accessibility.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: esm8m on November 21, 2021, 08:38:24 PM
I'm trying to build a mod that will play custom music in the menu for a planet based on the planet's name. Right now I'm just trying to verify that I'm going down the right path by having it print something when I interact with the planet. I'm not getting any print out. What would be the right way to do it?

I'm using the Asteroid Mining code (https://fractalsoftworks.com/forum/index.php?topic=6926.0) as a base.

Code
Code: mod_info.json
{
    "id":"CustomMusic",
    "name":"Custom Music",
    "version":"0.0.1",
    "description":"Custom music",
    "gameVersion":"0.95a-RC15",
    "modPlugin":"scripts.CustomMusic_ModPlugin"
}
Code: CustomMusic_ModPlugin.java
package scripts;
import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

public class CustomMusic_ModPlugin extends BaseModPlugin {
    @Override
    public void onGameLoad(boolean newGame) {
        super.onGameLoad(newGame);
        System.out.println("Registering mod");
        Global.getSector().registerPlugin(new CustomMusicCampaignPlugin());
    }
}
Code: CustomMusicCampaignPlugin.java
package scripts;

import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.BaseCampaignPlugin;
import com.fs.starfarer.api.campaign.OrbitalStationAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

public class CustomMusicCampaignPlugin extends BaseCampaignPlugin {
    @Override
    public String getId() {
        System.out.println("ID");
        return "CustomMusic";
    }

    @Override
    public boolean isTransient() {
        System.out.println("Transient");
        return true;
    }

    @Override
    public PluginPick<com.fs.starfarer.api.campaign.InteractionDialogPlugin> pickInteractionPluginPick(SectorEntityToken interactionTarget) {
        System.out.println("Interaction");
        if ((interactionTarget instanceof OrbitalStationAPI) || (interactionTarget instanceof PlanetAPI)) {
            System.out.println(interactionTarget.getName());
        }

        return null;
    }

    @Override
    public  PluginPick<com.fs.starfarer.api.campaign.InteractionDialogPlugin> pickInteractionDialogPlugin(java.lang.Object param, com.fs.starfarer.api.campaign.SectorEntityToken interactionTarget) {
        System.out.println("Interaction w/ param");
        return null;
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jackundor on November 21, 2021, 11:25:50 PM
this has probably already been asked several dozen times but well... In what state should a mod be for when you want it to be added to the index? In my weapon pack i currently have 4 weapons and 2 fighter wings finished and i'm working on some more weapons... would that be enough?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 22, 2021, 11:27:34 AM
I applied this to my game, but it causes a NullPointerException when generating a new save. Is there a possible reason why? I believe I added the appropriate imports too.

I'd check if your HyperSpaceGeneratorPlugin or the SectorEntityToken you are passing into that method is null, and then you can narrow down which one it is as it has to be one of the two assuming it operates normally if this code block isn't run at all.

See this next section of my post for more helpful information relating to this.

I'm trying to build a mod that will play custom music in the menu for a planet based on the planet's name. Right now I'm just trying to verify that I'm going down the right path by having it print something when I interact with the planet. I'm not getting any print out. What would be the right way to do it?

I'm using the Asteroid Mining code (https://fractalsoftworks.com/forum/index.php?topic=6926.0) as a base.

Code
Code: mod_info.json
{
    "id":"CustomMusic",
    "name":"Custom Music",
    "version":"0.0.1",
    "description":"Custom music",
    "gameVersion":"0.95a-RC15",
    "modPlugin":"scripts.CustomMusic_ModPlugin"
}
Code: CustomMusic_ModPlugin.java
package scripts;
import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

public class CustomMusic_ModPlugin extends BaseModPlugin {
    @Override
    public void onGameLoad(boolean newGame) {
        super.onGameLoad(newGame);
        System.out.println("Registering mod");
        Global.getSector().registerPlugin(new CustomMusicCampaignPlugin());
    }
}
Code: CustomMusicCampaignPlugin.java
package scripts;

import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.campaign.BaseCampaignPlugin;
import com.fs.starfarer.api.campaign.OrbitalStationAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

public class CustomMusicCampaignPlugin extends BaseCampaignPlugin {
    @Override
    public String getId() {
        System.out.println("ID");
        return "CustomMusic";
    }

    @Override
    public boolean isTransient() {
        System.out.println("Transient");
        return true;
    }

    @Override
    public PluginPick<com.fs.starfarer.api.campaign.InteractionDialogPlugin> pickInteractionPluginPick(SectorEntityToken interactionTarget) {
        System.out.println("Interaction");
        if ((interactionTarget instanceof OrbitalStationAPI) || (interactionTarget instanceof PlanetAPI)) {
            System.out.println(interactionTarget.getName());
        }

        return null;
    }

    @Override
    public  PluginPick<com.fs.starfarer.api.campaign.InteractionDialogPlugin> pickInteractionDialogPlugin(java.lang.Object param, com.fs.starfarer.api.campaign.SectorEntityToken interactionTarget) {
        System.out.println("Interaction w/ param");
        return null;
    }
}
[close]

Admittedly I haven't looked at your code snippets so it could simply be that System.out.println is never reached, but assuming that isn't the case it may be better to set up a logger instead:

Code
private static final Logger LOG = Global.getLogger(*YourClassNameHere*.class);

then in place of the println statement you'd call:

Code
LOG.info("Interacted with planet PlanetName");

 - or something like that. Then you can check the Starsector log file (A text file called Starsector in the core directory) and search for your class name to find the relevant logs (starting from the bottom to find the most recent) and see if your code is actually being ran at all. IIRC I don't think Janino can handle this so you'd need an IDE set up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on November 22, 2021, 06:22:03 PM
Is there any way to use HullModEffect.isApplicableToShip outside of combat? The problem is that it takes in a ShipAPI as the argument, but in the campaign layer we seem to only have access to FleetMemberAPI instances. I couldn’t find any way to instantiate a ShipAPI from a FleetMember or ShipVariant outside of combat (the spawnFleetMember and spawnShipOrWing functions take in position vectors so I don’t think they’re usable outside of combat, and getShipFor seems to always return null in the campaign layer).

I could create a map between FleetMemberAPI and ShipAPI that gets filled in by an engagement listener, but the issue with that is that I need the data even if the ship in the player’s fleet has never seen combat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2021, 06:29:25 PM
this has probably already been asked several dozen times but well... In what state should a mod be for when you want it to be added to the index? In my weapon pack i currently have 4 weapons and 2 fighter wings finished and i'm working on some more weapons... would that be enough?

It's more about it getting some use and player feedback, but we don't really have an official set of criteria.


Is there any way to use HullModEffect.isApplicableToShip outside of combat? The problem is that it takes in a ShipAPI as the argument, but in the campaign layer we seem to only have access to FleetMemberAPI instances. I couldn’t find any way to instantiate a ShipAPI from a FleetMember or ShipVariant outside of combat (the spawnFleetMember and spawnShipOrWing functions take in position vectors so I don’t think they’re usable outside of combat, and getShipFor seems to always return null in the campaign layer).

I could create a map between FleetMemberAPI and ShipAPI that gets filled in by an engagement listener, but the issue with that is that I need the data even if the ship in the player’s fleet has never seen combat.

There isn't, no - sorry! And I don't think it'd be a good idea to either try to instantiate ShipAPIs in the campaign or hang on to ones from combat at some prior time; the latter in particular seems like it could result in memory leaks/savefile bloat/and so on, while the former wouldn't perform very well.

It does need a ship, though, rather than a FleetMemberAPI, so basically determining whether a hullmod is applicable to a ship is not possible in the campaign. Consider a case where one hullmod adds a shield to a shieldless ship, and another requires the ship to have shields. Since the first mod acts on a ShipAPI - and is in fact an arbitrary script - there's no way to get this information about what the hullmod does without actually applying it to a ShipAPI and seeing what the result is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on November 22, 2021, 06:47:10 PM
Quote

There isn't, no - sorry! And I don't think it'd be a good idea to either try to instantiate ShipAPIs in the campaign or hang on to ones from combat at some prior time; the latter in particular seems like it could result in memory leaks/savefile bloat/and so on, while the former wouldn't perform very well.

It does need a ship, though, rather than a FleetMemberAPI, so basically determining whether a hullmod is applicable to a ship is not possible in the campaign. Consider a case where one hullmod adds a shield to a shieldless ship, and another requires the ship to have shields. Since the first mod acts on a ShipAPI - and is in fact an arbitrary script - there's no way to get this information about what the hullmod does without actually applying it to a ShipAPI and seeing what the result is.

Ah, I see, thanks! Out of curiosity, how does it work in the refit screen? I am able to select hull mods there and have other hull mods disable/enable themselves on the fly. Is the refit screen actually inside a combat instance?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2021, 06:49:58 PM
Ah, I see, thanks! Out of curiosity, how does it work in the refit screen? I am able to select hull mods there and have other hull mods disable/enable themselves on the fly. Is the refit screen actually inside a combat instance?

Sort of! There's always a combat instance (which gets reset when you enter a battle, say) and the refit screen is using that one while still being in the campaign game state.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: esm8m on November 22, 2021, 07:42:59 PM
Admittedly I haven't looked at your code snippets so it could simply be that System.out.println is never reached, but assuming that isn't the case it may be better to set up a logger instead:

Code
private static final Logger LOG = Global.getLogger(*YourClassNameHere*.class);

then in place of the println statement you'd call:

Code
LOG.info("Interacted with planet PlanetName");

 - or something like that. Then you can check the Starsector log file (A text file called Starsector in the core directory) and search for your class name to find the relevant logs (starting from the bottom to find the most recent) and see if your code is actually being ran at all. IIRC I don't think Janino can handle this so you'd need an IDE set up.

I just tried doing that, and it didn't seem to get called. I had to switch from using scripts to using the jar for it, as you said. I have prints in getting the ID for the CampaignPlugin and in onGameLoad in the ModPlugin - those appear when using the script but not the jar. I wonder if I'm doing something wrong with the jar?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 23, 2021, 03:44:14 PM
I just tried doing that, and it didn't seem to get called. I had to switch from using scripts to using the jar for it, as you said. I have prints in getting the ID for the CampaignPlugin and in onGameLoad in the ModPlugin - those appear when using the script but not the jar. I wonder if I'm doing something wrong with the jar?

Have you declared your jar in your mod_info file?

Example:

   "jars": ["Archean Order TC v0.9.5a.jar"],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on November 23, 2021, 06:41:30 PM
One of the users of my mod Junk Yard Dogs is having a crash with the CHM hull mod in it. I've had the mod up for some time now and this is the first time anyone has had this issue with it. I have exhausted my knowledge trying to help him and thought maybe someone more adept with Java could help.

His error Log:
304193 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at data.scripts.hullmods.CHM_JYD.applyEffectsBeforeShipCreation(CHM_JYD.java:24)
   at com.fs.starfarer.campaign.fleet.FleetMember.updateStats(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMember.init(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMember.<init>(Unknown Source)
   at com.fs.starfarer.title.Object.M.o00000(Unknown Source)
   at com.fs.starfarer.title.Object.M.render(Unknown Source)
   at com.fs.starfarer.coreui.OO0o.super(Unknown Source)
   at com.fs.starfarer.ui.newnew.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.impl.StandardTooltipV2.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.render(Unknown Source)
   at com.fs.starfarer.ui.v.renderImpl(Unknown Source)
   at com.fs.starfarer.ui.o00O.render(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.render(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

CHM_JYD code:

Code
package data.scripts.hullmods;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;

public class CHM_JYD extends BaseHullMod {
    private static final Map jydcom = new HashMap();
public static final float ARMOR_BONUS = 20f;
    public static final float MAINTENANCE_MULT = 0.90f;
    static {
        jydcom.put(HullSize.FRIGATE, 30f);
        jydcom.put(HullSize.DESTROYER, 25f);
        jydcom.put(HullSize.CRUISER, 20f);
        jydcom.put(HullSize.CAPITAL_SHIP, 15f);
        jydcom.put(HullSize.DEFAULT, 15f);
    }

    @Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        float timeMult = 1f / ((100f + (Float) jydcom.get(hullSize)) / 100f);
        stats.getFighterRefitTimeMult().modifyMult(id, timeMult);
        stats.getMinCrewMod().modifyMult(id, MAINTENANCE_MULT);
stats.getArmorBonus().modifyFlat(id, ARMOR_BONUS);
    }


    @Override
    public String getDescriptionParam(int index, HullSize hullSize) {
        if (index == 0) return "" + ((Float) jydcom.get(HullSize.FRIGATE)).intValue()  + "%";
        if (index == 1) return "" + ((Float) jydcom.get(HullSize.DESTROYER)).intValue()  + "%";
        if (index == 2) return "" + ((Float) jydcom.get(HullSize.CRUISER)).intValue()  + "%";
        if (index == 3) return "" + ((Float) jydcom.get(HullSize.CAPITAL_SHIP)).intValue()  + "%";
        if (index == 4) return "" + (int) ((1f - MAINTENANCE_MULT) * 100f) + "%";
if (index == 5) return "" + (int) ARMOR_BONUS;
        return null;
    }


    @Override
    public Color getBorderColor() {
        return new Color(147, 102, 50, 0);
    }

    @Override
    public Color getNameColor() {
        return new Color(220,185,20);
    }
}

Any help would be appreciated, thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 23, 2021, 06:47:35 PM
   at data.scripts.hullmods.CHM_JYD.applyEffectsBeforeShipCreation(CHM_JYD.java:24)

Line 24 looks to be this (bolded the line number in the stack trace, btw, so you know where to look for it):
float timeMult = 1f / ((100f + (Float) jydcom.get(hullSize)) / 100f);

If that's indeed the line, the only way it can throw an NPE is when trying to cast the return of get() to a Float. Which means that the given hullSize is not present in that map. Given what you've got in there, I suspect it's "FIGHTER", but why a ship would be of that hull size and refittable, I'm not sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 23, 2021, 06:56:43 PM
Any help would be appreciated, thank you.
In addition to what Alex said.

https://fractalsoftworks.com/forum/index.php?topic=22981.msg345402#msg345402

I see this case come up with Diable Avionics a lot :V
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on November 23, 2021, 07:58:51 PM
Thank you both for your help. TBH I would never have considered FIGHTER to be a HullSize. If I were to add it to the hash map would it be: jydcom.put(HullSize.FIGHTER, 35f); then add FIGHTER to the index list for getDescriptionParam?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on November 23, 2021, 08:17:19 PM
Sort of! There's always a combat instance (which gets reset when you enter a battle, say) and the refit screen is using that one while still being in the campaign game state.

Is there any way I could use this combat instance to create something similar to the hull mod selection interface on the refit screen? I thought maybe I could hijack any ShipAPI I could find and use setVariantForHullModCheckOnly, but it turns out that function doesn't modify a ship's stats, hull size, or shields, and probably other things as well. So I feel like there must be a way to get a ShipAPI for a ship that I can use, unless the refit screen is using methods that aren't exposed in the API.

I've also thought about it and holding onto ShipAPIs from the last engagement doesn't work either, since it's possible that the fleet member's stats get changed in the meantime. Theoretically there could be a hull mod that requires some ship stat to be a certain number. This means that the hull mod selection interface must be using a "fresh" copy of the ship in question... but how?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: esm8m on November 23, 2021, 08:46:27 PM
Have you declared your jar in your mod_info file?

Example:

   "jars": ["Archean Order TC v0.9.5a.jar"],

Yep:

Code
{
    "id":"CustomMusic",
    "name":"Custom Music",
    "version":"0.0.1",
    "description":"Custom music",
    "gameVersion":"0.95a-RC15",
    "jars": ["jars/CustomMusic.jar"]
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 23, 2021, 08:52:41 PM
Thank you both for your help. TBH I would never have considered FIGHTER to be a HullSize. If I were to add it to the hash map would it be: jydcom.put(HullSize.FIGHTER, 35f); then add FIGHTER to the index list for getDescriptionParam?

Yeah, that sounds about right.


... unless the refit screen is using methods that aren't exposed in the API.

I'm afraid that's what it does, yeah.

And: creating ShipAPI objects in the background might not be a good idea anyway, at least... depending. For example if you were doing it for NPC fleets, too, it would certainly be a bad idea performance-wise. As would, say, doing it a bunch of times per frame, etc etc.

But that's really secondary to there just not being a way to do it that's exposed in the API. And I'm leery of adding one - I'd have to be really careful about it and do a lot of testing (which would likely not happen due to it not being used by vanilla), since this specific thing can (i.e. has in the past) produce some very, very nasty memory leaks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 23, 2021, 09:00:10 PM
Thank you both for your help. TBH I would never have considered FIGHTER to be a HullSize. If I were to add it to the hash map would it be: jydcom.put(HullSize.FIGHTER, 35f); then add FIGHTER to the index list for getDescriptionParam?
For getDescriptionParam? No, not necessary. Whenever something has a FIGHTER for some reason, I just put a 0f or a negating effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 23, 2021, 09:08:03 PM
Thank you both for your help. TBH I would never have considered FIGHTER to be a HullSize. If I were to add it to the hash map would it be: jydcom.put(HullSize.FIGHTER, 35f); then add FIGHTER to the index list for getDescriptionParam?
For getDescriptionParam? No, not necessary. Whenever something has a FIGHTER for some reason, I just put a 0f or a negating effect.

(Oh, you're right! getDescriptionParam() would only need to be updated if the description was changed to include its effect on fighters.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on November 24, 2021, 06:03:01 AM
@esm8m

Hmm, I'm not sure then. I looked at the code you originally posted and nothing pops out as being explicitly wrong. I haven't ever needed to register a plugin like what you are attempting though so my experience is limited.

It is strange that it would somewhat work using Janino to compile your scripts and not work with the jar from an IDE. I suppose its possible that the jar wasn't complied correctly but I wouldn't know where to start as far as troubleshooting goes.

It might be worthwhile to post your updated code in case there is something there that has changed from your original script that would cause it to not run. The only other thing I can think of is that your overloaded methods in the base plugin class aren't being used in the specific instance you are testing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 24, 2021, 07:22:17 AM
Code
AddTextSmall "You received recommendation from $PersonRank $personLastName"
$player.hasHegemonyRecommendation = true
$player.HegemonyRecommendationRank = $PersonRank
$player.HegemonyRecommendationName = $personLastName
AddTextSmall "$player.HegemonyRecommendationRank $player.HegemonyRecommendationName"

So I wanted to make a promotion in the rule.csv... to my sudden surprise $PersonRank and $personLastName isn't defined when I suddenly use devmode to dump memory... but yet AddTextSmall was able to extract the $PersonRank and $personLastName.. seems... interesting but annoyed I had to use rulecmd to extract the person's last name since the $PersonRank can be found as $Rank.

.............


On a side note, is it possible to have a customized graphic for these four below.. asking for a friend who wants to make a foreign blueprint, but doesn't want to make every weapon bp for his new graphics.

Base Ship Blueprint (ship_bp)
Base Weapon Blueprint (weapon_bp)
Base Fighter Blueprint (fighter_bp)
Base Industry Blueprint (industry_bp)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 24, 2021, 08:31:56 AM
On a side note, is it possible to have a customized graphic for these four below.. asking for a friend who wants to make a foreign blueprint, but doesn't want to make every weapon bp for his new graphics.

Base Ship Blueprint (ship_bp)
Base Weapon Blueprint (weapon_bp)
Base Fighter Blueprint (fighter_bp)
Base Industry Blueprint (industry_bp)

Unless I'm misunderstanding the question, the graphic is defined special_items.csv. If you mean having a different base graphic for only some of the blueprints, that'd be a bit more involved - it'd basically be a new item that works the same way. Still seems doable, though if you also wanted it to drop, be a mission reward for existing missions, etc - the way normal blueprints can be - then that would be substantially more work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on November 24, 2021, 09:47:01 AM
Just a quick thank you to Alex and Timid, Dragar reports that the adjustment you recommended fixed his crashing issue. Hugs
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 24, 2021, 05:18:47 PM
Several mods do custom BP items. Roider Union has ship retrofit BPs which can drop as loot like normal BPs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 25, 2021, 02:28:54 AM
Several mods do custom BP items. Roider Union has ship retrofit BPs which can drop as loot like normal BPs.
Thanks!

....

Is there a way to force the CampaignFleetAPI spawnFleet to have a flagship of a smaller flagship?

Right now the certain industry is spawning legions in the fleet when the commander's mainship prefers to sit in an eagle. When I adjust the fleet points appropriately, the commander sits in an eagle but as the fleet point starts scaling upward, the eagle disappears and the commander is sit atop of a legion.

I think the workaround is to force-add the said eagle ship and force the commander on-top of it, but is there a more supported method?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 26, 2021, 05:42:02 AM
I am implementing a Hyperspace Skype(tm). Via intel UI of course.

I would like to tap into rules.csv via `IntelUIAPI.shoDialog(token, ruleId)`. My first surprise was that it doesn't work with rule ids. It takes triggers instead.

Either way, got a bad version of it working (via `market.getPlanetEntity(), "OpenInteractionDialog"`) which does the job, but I want better. I want to OpenCDE (OpenCommLink?) with the person directly. Unfortunately, we don't have sources for that class and I don't know what memory keys are needed. So I seek guidance. Or is there a different way to open dialog with a specific person?

Edit: The reason I went through rules.csv route is that if I create my custom InteractionDialogPlugin and showCommsDirectory with desired people myself, they are no longer clickable / interactable.'

Edit 2: Did some variations of the following with no luck :(
Code
        SectorEntityToken token = market.getPlanetEntity();
        token.setActivePerson(person);
        ui.showDialog(token, "OpenCDE");

Edit 3: Hmm, been comparing memory dumps from when I access contact via CommDirectory and when I access it manually. I do seem to be missing `$entity` keys, and all local keys point to market (`fullName = Hegemony Jangala` instead of contact name). The hunt for right memory keys continues...

Edit 4: MemoryAPI key overwritting not possible (tried to replace $id that had market with personId, gets overwritten anyway, adding new one is fine), should I look into custom rulecmd (extend BaseCommandPlugin and set things up from there)?

Edit 5: I am slowly loosing hope. Might need a new API method: `ui.showDialog(PersonAPI person, String ruleCmd)` or so (since token in rules can either be Person or Market).

Edit 6: I am now suspecting a bug. When I set active person on the token that's passed to the dialog, I'd expect the memory map to reflect that. I see this used in `BeginConversation`. But in my own tiny code this does not seem to work.

Edit 7: A new hope. Found RuleBasedInteractionDialogPluginImpl. Extending that, and updating interaction target manually kinda works (why it didin't when I modified original token used in calling showDialog?). Hunt continues.

Edit 8: SUCCESS! Took only 5h.

Code
public class ContactDialog extends RuleBasedInteractionDialogPluginImpl {

    private final PersonAPI person;

    public ContactDialog(PersonAPI person) {
        super("OpenCDE");
        this.person = person;
    }

    @Override
    public void init(InteractionDialogAPI dialog) {
        dialog.getInteractionTarget().setActivePerson(person);
        super.init(dialog);
    }
}

Two problems:
1. As mentioned, the SectorEntityToken that I to set active person on (prior to calling showDialog) seems to be ignored. Had to set it manually in init again.
2. When cutting the comm link with the person, I am moved to market interaction (first time I am moved twice, to non-existent commdirectory, then to market; second and after straight to market). But I should have this covered - just higher priority rule, based on some extra key I will set, to avoid market interaction and just close the dialog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 26, 2021, 11:03:25 AM
Oh, oops - let me change the name of the parameter from "ruleId" to "trigger". And, yeah, using RuleBasedInteractionDialogPluginImpl is the way to go - it handles all/most of the fiddly hooking up that's required to make it all work.

Re: setActivePerson(), it's meant to be used only within the context of an existing dialog and is reset when an interaction dialog is shown, hence what you're seeing. The init() method is called after the active person was reset.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BaBosa on November 26, 2021, 05:21:25 PM
If I make a weapon with a long charge up time, very fast projectile speed and slow turn rate. Would enemy ships try to get out of the way during the charge time?
Also, if a ship system allowed two phase ships to hit each other. Would the AI work fine with that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on November 27, 2021, 05:53:41 AM
How could I get a list of all possible contact types in a current game? I found 5 vanilla types in Tags (although I haven't seen pather or science contact myself), and mods can add more, yet my quick search through API hasn't yielded any results. Seems like we are missing "SettingsAPI.getAllContactTags()" or similar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 27, 2021, 11:12:27 AM
It's a bit thornier than that, since contact tags defined in contact_tag_data.json are not guaranteed to actually be used anywhere. Your best bet is probably iterating through all the ContactIntel the player has and cross-checking it against what's in contact_tag_data - which you could get to by reading the (merged-with-mod-stuff) file in onApplicationLoad(), given the absence of an API method to get to it. And probably pre-seeding that list with trade/military/underworld in case you need it to be non-empty for whatever UI you've got in mind to "work"...

If I make a weapon with a long charge up time, very fast projectile speed and slow turn rate. Would enemy ships try to get out of the way during the charge time?
Also, if a ship system allowed two phase ships to hit each other. Would the AI work fine with that?

Definitely not, on both counts.

Well, for "getting out of the way", they'll generally speaking have some behaviors that make them harder to hit with a weapon like that - especially frigates - but it's not going to be particularly reliable or aware of this weapon's specifics. I'd suggest just trying it to see what happens; it'd be pretty trivial to tweak the stats on an existing weapon to what you've got in mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on November 27, 2021, 12:09:15 PM
I'm trying to make a ship with a maneuvering jets ship system. How would you implement the visual effect of side engines lighting up when the ability is active on ships such as the falcon?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 27, 2021, 12:31:21 PM
I'm trying to make a ship with a maneuvering jets ship system. How would you implement the visual effect of side engines lighting up when the ability is active on ships such as the falcon?

Set contrailSize for that engine to 128. It's... more than a bit of a hack; that field is not used for anything else so it sort of became a "use for some kind of flag" field instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 27, 2021, 01:29:14 PM
If I make a weapon with a long charge up time, very fast projectile speed and slow turn rate. Would enemy ships try to get out of the way during the charge time?

Go play with the Mimir from Shadowyards. I think its main gun has a long chargeup and fast projectile like the weapon you want to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 27, 2021, 04:47:05 PM
I am using
Code
dialog.showCargoPickerDialog
public void recreateTextPanel(TooltipMakerAPI panel, CargoAPI cargo, CargoStackAPI pickedUp, boolean pickedUpFromSource, CargoAPI combined)

I found that adding buttons here in panel.AddButton makes the button graphically, but I can't do anything with it otherwise. I can't even check if it's enabled, or checked, set a shortcut, or even have buttonpressedsound.

Is it not supported in recreateTextPanel?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 27, 2021, 05:07:43 PM
I *think* if you call:
panel.setForceProcessInput(true)
That should do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 27, 2021, 05:29:52 PM
I *think* if you call:
panel.setForceProcessInput(true)
That should do it.
Oh, that worked, too bad there's no button.setButtonPressed to incur a script or something  :-[

Using addAreaCheckbox I thought would at least let me check if it got checked or not.

Thanks for helping!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 29, 2021, 03:18:22 PM
I wish to encourage people to do the single player missions except I don't know the method in an API to detect the score or even if the player attempted it once. I've scanned thorugh the Global API and asked around looking for something which I thought some super old mod would use, but found nothing. Does a method exist?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2021, 03:22:40 PM
I don't think there is, no. The scores are stored in saves/mission_scores.json but that's no good either, since iirc you wouldn't be able to read stuff from there using SettingsAPI.loadJSON() etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on November 29, 2021, 03:36:08 PM
I know you can get some amount of fancy code running for specific missions - things like the old Ship and Weapon Pack Arcade mission.

While that wouldn't let you get at the player score, it should let you track what's going on during the mission and write your own data to a file, which could then be read during the main campaign.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on November 30, 2021, 05:46:17 AM
If I remove something from a faction file's known hullmods, (how) would that affect an already existing game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 30, 2021, 09:30:44 AM
If I remove something from a faction file's known hullmods, (how) would that affect an already existing game?

It won't - adding things via the .faction file will work on an existing game, but removing them will not. Reason being, it's possible to add, say, a known hull (or hullmod, etc) in some other way - for example, selling a blueprint to pirates, or something else scripted a mod might do. The game doesn't know *why* a faction knows what it does, so it doesn't simply reset to the faction's known set of things on game load - though it does ensure that the faction knows everything in the .faction file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on November 30, 2021, 11:35:56 AM
It won't - adding things via the .faction file will work on an existing game, but removing them will not. Reason being, it's possible to add, say, a known hull (or hullmod, etc) in some other way - for example, selling a blueprint to pirates, or something else scripted a mod might do. The game doesn't know *why* a faction knows what it does, so it doesn't simply reset to the faction's known set of things on game load - though it does ensure that the faction knows everything in the .faction file.
What is the point of the removeKnownFighter, removeKnownHullMod, removeKnownIndustry, removeKnownShip, removeKnownWeapon.. etc then?

Or did I misread.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 30, 2021, 12:06:51 PM
They work on the faction data in the campaign. I was talking about making changes in the .faction file. But, yeah, removing stuff that the faction "knows" via the .faction file through these methods will only work until the save is re-loaded. So if it's desired to suppress ships etc the faction has in the faction file, you'd have to do call these methods in onSaveLoad().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 01, 2021, 06:25:56 AM
Another basic one: If I have a ballistic weapon that uses missile projectiles, which bonuses (from skills and the like) does it benefit from?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 01, 2021, 06:42:06 AM
Another basic one: If I have a ballistic weapon that uses missile projectiles, which bonuses (from skills and the like) does it benefit from?

the projectile will benefit from missile-buffing stuff (like eccm's speed & missile spec's hp buff) but the weapon will benefit from ballistic buffs, I found this out this morning whille messing w/ a kyeltziv technocracy ship
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 01, 2021, 03:37:56 PM
If a modular ship has Phase Cloak, will its modules phase with it automatically?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 01, 2021, 03:41:23 PM
If a modular ship has Phase Cloak, will its modules phase with it automatically?
98% confident that the answer is nope.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Axisoflint on December 01, 2021, 07:48:53 PM
Is it possible to create a scaling hullmod for purposes of increasing marine effectiveness?

For instance if I created a random ship sprite that had an integrated hullmod (so as not to affect balance with other ground support options), that functioned in terms of - 100 marines = x supplies, 1000 marines = x + 900 supplies (or whatever scaling was appropriate, ballparking).

I realise there are many ground support options already, I'm just thinking of trying to create a later game option to consolidate on to a larger, single ship.

Think of it as akin to Smaller freighter > Mid freighter > Atlas or Dram > Phaeton > Prometheus.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 02, 2021, 02:00:41 AM
Another basic one: If I have a ballistic weapon that uses missile projectiles, which bonuses (from skills and the like) does it benefit from?

the projectile will benefit from missile-buffing stuff (like eccm's speed & missile spec's hp buff) but the weapon will benefit from ballistic buffs, I found this out this morning whille messing w/ a kyeltziv technocracy ship
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2021, 10:02:16 AM
Is it possible to create a scaling hullmod for purposes of increasing marine effectiveness?

For instance if I created a random ship sprite that had an integrated hullmod (so as not to affect balance with other ground support options), that functioned in terms of - 100 marines = x supplies, 1000 marines = x + 900 supplies (or whatever scaling was appropriate, ballparking).

I realise there are many ground support options already, I'm just thinking of trying to create a later game option to consolidate on to a larger, single ship.

Think of it as akin to Smaller freighter > Mid freighter > Atlas or Dram > Phaeton > Prometheus.

It should be possible!

(In general, it's easier to give a more useful answer to a question if there's already a demonstrated attempt to do something that's going wrong somehow, since then there are specifics to get into.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 02, 2021, 03:27:25 PM
hello
what would be the proper way to accomplish the following:
Spoiler
starsystem with several stars
all stars orbit a specific empty point in space
there are stations and planets orbiting one of the stars
there are _also_ stations orbiting that empty point in space. and those stations have markets attached to them
[close]
i mean, i can make it, it works.
but there are problems, likely a lot more than i can see
one i found is with the system info window:
Spoiler
(https://i.imgur.com/JPKzEF8.png)
[close]
note the selected station supposedly orbiting tree stars simultaneously. it is actually orbiting that "empty space".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 02, 2021, 03:41:42 PM
The first thing that comes to mind is have an invisible "dummy" star, so anything orbiting it gets it's own listing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 02, 2021, 04:21:53 PM
The first thing that comes to mind is have an invisible "dummy" star, so anything orbiting it gets it's own listing.
i considered that
but i'm yet to figure out how to make star invisible and non-interactible. or simply just non-interactible.
atm i'm using an invisible custom entity. which can be made invisible quite easily. but something doesn't work clearly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2021, 04:35:02 PM
Hmm - vanilla does this with some types of trinary systems, no? The ones where there are multiple stars in the middle of the system, orbiting a common system.getCenter().

Except for the "with stations" part. It's possible that the display showing stations is not working in this case, hmm - though in your shoes I'd make sure it's doing stuff the same way that vanilla is for that case.

The StarSystemGenerator class might be a good place to look - that' where this is done - but it has quite a lot of stuff going on. The addStars() method might make a reasonable starting point for the code-dive.

Edit: another thing to try would be to find a vanilla-generated trinary with all three stars in the middle, then add a station to that system, and see how/if that works out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 02, 2021, 07:01:49 PM
thanks
yes, i looked into system generator before asking here
i haven't tried linking stars directly to the system.getCenter before, i thought for some reason that it's just coordinates and not an entity. doing that does solve the problem with multiplying stations. but they still stick to the system's primary star no matter what i try.

any advice on making invisible stars?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2021, 07:13:16 PM
Hmm - nebula_center and similar stuff in planets.json? That has its own set of baggage, though, if that's the "primary" of a star system; I forget how much of it is configurable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on December 02, 2021, 07:19:59 PM
I'm also curious about this; I have a system I'd like to turn into a nebula, and I haven't had much if any luck with it so far.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 02, 2021, 07:26:34 PM
yes, i tried nebula centers a while ago
but they still show up on the map and can be interacted with by player
looking at the definitions, they're literally just planets/stars with blank texture
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2021, 07:38:22 PM
Are you calling system.setStar() on this "invisible" star? If you do that, there's just not going to be any recourse - the game will assume it's either a star or a nebula center and behave accordingly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 02, 2021, 08:37:08 PM
i tried again with the nebula center
it kinda works, because it's a literal star there
but there's a couple of problems
first there's this weird squggle around where the nebula is located:
Spoiler
(https://i.imgur.com/jktWZEc.png)
[close]
looks like a distorted corona.
then there's this weird object all the way on the fringe of the system:
Spoiler
(https://i.imgur.com/ofUxOVk.png)
[close]
if i physically fly to that object there's actually nothing there, it only shows on the map
i used the following code:
(https://i.imgur.com/8bLVJgc.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 02, 2021, 08:39:16 PM
Here's (https://github.com/Histidine91/Nexerelin/blob/master/jars/sources/ExerelinCore/exerelin/world/ExerelinNewGameSetup.java#L164) the results of the cargo cult/trial-and-error attempt thing I did to create the nebula containing Prism Freeport in Nex, it may help.


(Checking the code, there's a part where it calls system.setStar(star), where star has already been removed from the location following its generation. Looks wack, but I don't feel like seeing what happens if I remove it. Possibly not having it previously made the system CTD due to not having a star.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 04, 2021, 01:18:21 PM
So let's say I add a hullmod to the Diktat, and it changes ship builds enough I want them to use different variants for it.
1) Is there a way to prohibit the hullmod from being auto-fit on NPC ships?
2) Is there a way to make variants faction-exclusive? Or at least, only available to those who know the hullmod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 04, 2021, 01:27:24 PM
So let's say I add a hullmod to the Diktat, and it changes ship builds enough I want them to use different variants for it.
1) Is there a way to prohibit the hullmod from being auto-fit on NPC ships?
2) Is there a way to make variants faction-exclusive? Or at least, only available to those who know the hullmod?

An example from luddic_church.faction:

"combatLarge":{
   "includeDefault":true,
   "dominator_Fighter_Support":50,
},

So you'd basically want to do this sort of thing for your custom variants you want the faction to use. Another part of the solution could be variantOverrides; here's an example from luddic_path.faction:

# variantOverrides restricts hulls to listed variants and adjusts their probability
"variantOverrides":{
   "enforcer_Overdriven":30,
   "hammerhead_Overdriven":30,
   "sunder_Overdriven":30,
},
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 04, 2021, 01:32:54 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on December 04, 2021, 09:14:14 PM
I've been trying to make a .SKIN file that moves a turret to a new location but haven't been successful. Is it impossible to move or am I doing it wrong?
Spoiler
"weaponSlotChanges":{
   "WS0018":{
      #"id": "WS0018",
      #"size": "SMALL",
      #"type": "BALLISTIC",
      #"mount": "TURRET",
      #"arc": 180,
      #"angle": 135,
      "location": [-65.5, 53],
   },
},
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 04, 2021, 09:20:07 PM
Taking a quick look, slot location changes are not supported. If you're also making the original .ship, you could have multiple slots in it and have skins remove the ones they don't want, instead.

But if you're modifying an existing ship, I don't think there's a way to do this via the skin file. You could however do ShipHullSpecAPI.getWeaponSlotAPI(id).getLocation().set(x, y) - that should do the trick. Probably somewhere in ModPlugin.onApplicationLoad().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IonDragonX on December 04, 2021, 10:57:27 PM
Taking a quick look, slot location changes are not supported. If you're also making the original .ship, you could have multiple slots in it and have skins remove the ones they don't want, instead.
Thank you. This trick does work around the issue. I created an extra mount at the destination coordinate on the original .SHIP file but initialized it as decorative. (even in refit, the original can't see a thing) Then I changed that type in the .SKIN file to make it a useable weapon mount again. (and cut the mount I wanted) Now its just a matter of keeping the .VARIANT files from ever referencing a removed or decorative weapon mount.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2021, 10:22:06 AM
Ah, nice! Using the deco mount is a good way to avoid having two skins (and never using the original). And yeah, making sure the slot ids are correct everywhere is going to be important :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 06, 2021, 11:05:02 AM
How to load the custom font?
I found that there is an api called "setParaFont" in TooltipAPI, how to use the parameter if I want to use my own font(Haven't try it yet)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 06, 2021, 11:09:11 AM
IIRC loading an entirely custom font is not supported, aside from the one case of "defaultFont" in settings.json - but that overrides the standard font.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on December 06, 2021, 07:41:34 PM
Greetings again,

Been doing some API reading a bit, and I can see (from several hullmods and SurveyPluginImpl.class) that it is possible to modify the Commodities requirements for surveying via getSurveyCostReductionId():

Code
stats.getDynamic().getMod(Stats.getSurveyCostReductionId(Commodities.CREW)).modifyFlat(id,REDUCTION_GOES_HERE);

(Odd how only SUPPLIES and HEAVY_MACHINERY have a hard minimum of five units...)


Can't seem to find a counterpart for Salvaging though. I'd imagine there is a similar way to modify Commodities requirements for either or both the post-combat salvage dialog and derelict/debris/exploration salvage dialog?

NO SIR I AM DEFINITELY NOT AN AI JUST A SOLO STARFARER CONTEMPLATING ESCHEWING FLESHY CREW FOR AN ARMY OF ROBOTIC DRONES TO AVOID PAYING WAGES AS WELL AS REDUCING LIFE SUPPORT REQUIREMENTS
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 06, 2021, 08:13:47 PM
There is not a dynamic way to modify those via stats, actually - sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 08, 2021, 12:04:13 AM
I'm trying to create random bounty fleets without a market, but for some reason I cannot manage to set their quality in any way. The ships are always pristine regardless of the values for quality, qualityMod, qualityOverride, averageSMods. I tried to force the values to 0, force the fleet to inflate, to deflate, etc to no avail.

Code: java
    private static CampaignFleetAPI generateRandomFleet(String factionId, float qualityOverride, String fleetType, float fleetPoints, float freightersAndTankersFraction ) {
       
        FleetParamsV3 params = new FleetParamsV3(
                null, //Fake market are actually not needed, one will be created by the FleetFactory
                new Vector2f(),
                factionId,
                qualityOverride, //this is supposed to everride the default fleet quality without market of 0.5
                fleetType,
                fleetPoints*(1-freightersAndTankersFraction),
                fleetPoints*(freightersAndTankersFraction/3),
                fleetPoints*(freightersAndTankersFraction/3),
                fleetPoints*(freightersAndTankersFraction/3),
                0f, 0f,
                0 //DO NOT SET A QUALITY MOD, it is added to the market quality
        );
       
        params.ignoreMarketFleetSizeMult = true;
        params.maxNumShips = 50;
        params.modeOverride = FactionAPI.ShipPickMode.PRIORITY_THEN_ALL;
       
        //add S mods?
        if(qualityOverride>1){
            params.averageSMods = Math.round(qualityOverride-1);
        } else {
            params.averageSMods=0;
        }
//        params.quality=0;
//        params.qualityMod=0;
//        params.qualityOverride=null;
       
        CampaignFleetAPI tempFleet = FleetFactoryV3.createFleet(params);
        if (tempFleet==null || tempFleet.isEmpty()) {
            log.warn("Failed to create procedural Support-Fleet");
            return null;
        }
//        tempFleet.inflateIfNeeded();
//        tempFleet.deflate();
//        tempFleet.forceSync();
//        tempFleet.updateFleetView();
       
        return tempFleet;
    }

If it is relevant, I'm generating an empty fleet, then adding to it a specific Flagship, specific escort ships, then filling the rest with randomly generated ships taken from that tempFleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 08, 2021, 08:13:32 AM
Is there a way to have two weapons get disabled/repaired at the same time?

Alternatively, is there a way to have a weapon both be a beam and produce projectiles (that do separate damage)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 08, 2021, 10:39:35 AM
I'm trying to create random bounty fleets without a market, but for some reason I cannot manage to set their quality in any way. The ships are always pristine regardless of the values for quality, qualityMod, qualityOverride, averageSMods. I tried to force the values to 0, force the fleet to inflate, to deflate, etc to no avail.

...

If it is relevant, I'm generating an empty fleet, then adding to it a specific Flagship, specific escort ships, then filling the rest with randomly generated ships taken from that tempFleet.

First thing I'd try is spawning tempFleet to make sure it's getting the quality you want.

Also, make sure that your empty fleet does not have an inflater - unless you want it to have one, of course. But the inflater is responsible for adding d-mods and s-mods. So either you'd inflate() tempFleet and add ships to your empty fleet and make sure the empty fleet has no inflater (which is less efficient because those custom variants would exist always, instead of being inflated from shared stock variants when needed), or you could add uninflated fleet members from tempFleet and set an inflater on your empty fleet with the desired DefaultFleetInflaterParams (which includes ship quality). The simplest way to do this would probably be to just the inflater from tempFleet, which would have its parameters set based on what you passed into FleetFactoryV3.

Is there a way to have two weapons get disabled/repaired at the same time?

Alternatively, is there a way to have a weapon both be a beam and produce projectiles (that do separate damage)?

I can't think of any way to sync it up like that, and there'd be many potential UI issues. I think your best bet might be to have it be a beam weapon, with the projectile spawning happening in its BeamEffectPlugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 08, 2021, 11:13:28 AM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 09, 2021, 01:50:07 AM
Is there any way to get the (turret/hardpoint)GunSprite of a weapon (aka the recoil sprite)?
The API for WeaponSpec has    
getHardpointSpriteName()
and
getHardpointUnderSpriteName()

But I dont see anything for the barrel.../recoil sprite
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on December 09, 2021, 08:41:23 AM
I'm helping Tartiflette a bit with MagicLib to add bounties that are generated based off of just a json object. We wanted to allow a potential translator to have more control over the code that generates text by letting them edit a code file itself (loose script using Janino).

The snag is that the Janino-compiled file references classes in the MagicLib .jar, which causes compilation of the script to fail, as (it seems) Janino compiles before mod jars are loaded.

Is there currently a way to have a loose .java file get compiled *after* mod jars are loaded, so that it can depend on a class from a .jar? If not, is there a possibility of this being added?


-----------
More, non-critical info:
The dependency is bi-directional, meaning that the compiled classes also reference the loose script, but I worked around that by copy/pasting the class into the compiled source (so the class is both in non-compiled and compiled source), then excluding the class from the output .jar (I use gradle for this, not sure how to do it using maven, could also simply do it by hand by deleting the .class files). It's a hacky way of treating the class like a library/runtime dependency.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on December 09, 2021, 08:46:25 AM
@Wisp

I think in this case you want the translator to create his own mod, say `magiclib-chinese` which loads after `magiclib`, and overshadows the class files loaded from your main jar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 09, 2021, 10:13:05 AM
Is there any way to get the (turret/hardpoint)GunSprite of a weapon (aka the recoil sprite)?
The API for WeaponSpec has    
getHardpointSpriteName()
and
getHardpointUnderSpriteName()

But I dont see anything for the barrel.../recoil sprite

Hmm - I don't see it in the API, but I'm pretty sure GraphicsLib needs to have access to this to work, so it's possible I'm missing something.

Is there currently a way to have a loose .java file get compiled *after* mod jars are loaded, so that it can depend on a class from a .jar? If not, is there a possibility of this being added?

Ah, I'm sorry - the answer is "no (that I'm aware of)" and "no".

Janino is... it's not quite deprecated, as far as its place in the Starsector code - that is, there's no danger of me wanting to remove it - but it's about as close as can be to that otherwise. It has various problems, and it's compounded by the time it takes to compile loose scripts easily becoming something that increases the loading time of the game (even though it's done on a separate thread).


I think in this case you want the translator to create his own mod, say `magiclib-chinese` which loads after `magiclib`, and overshadows the class files loaded from your main jar.

Oh, hey, that sounds like a potentially workable idea! Not 100% sure whether the ordering would do it, off the top of my head, but it seems worth a shot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on December 09, 2021, 10:21:45 AM
@Wisp

I think in this case you want the translator to create his own mod, say `magiclib-chinese` which loads after `magiclib`, and overshadows the class files loaded from your main jar.

That's a really good idea. As I mentioned in the Discord, it does make it harder on a translator, but, well, it's not like there are other good options, and if they're going to the code for a translation, maybe compiling a jar wouldn't be so hard for them anyway.
Tartiflette talked with Originem and it sounds like the whole point is moot; what we have now is good enough for translating :)

Thank you Jaghaimo and Alex, now we know what to do if someone does want to get advanced with translations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zeppelin17 on December 10, 2021, 10:57:22 AM
Can someone explain how to make a weapon deal hard flux? Or what makes a weapon do so? Is it fixed to a certain weapon type? I saw that the Pulse Laser does hard flux, but how and how much? Where can that be edited?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 11, 2021, 02:00:16 AM
Can someone explain how to make a weapon deal hard flux? Or what makes a weapon do so? Is it fixed to a certain weapon type? I saw that the Pulse Laser does hard flux, but how and how much? Where can that be edited?
projectile weapons deal hard flux, beam weapons deal soft flux
simple as that
no easy way to change that without writing a rather complex script, there's no single variable tied to that
or, rather, you can't change that at all, but you can circumvent that by applying hard flux manually with script after the damage is dealt
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zeppelin17 on December 11, 2021, 02:58:03 AM
Can someone explain how to make a weapon deal hard flux? Or what makes a weapon do so? Is it fixed to a certain weapon type? I saw that the Pulse Laser does hard flux, but how and how much? Where can that be edited?
projectile weapons deal hard flux, beam weapons deal soft flux
simple as that
no easy way to change that without writing a rather complex script, there's no single variable tied to that
or, rather, you can't change that at all, but you can circumvent that by applying hard flux manually with script after the damage is dealt

 :o  ??? How does the Pulse laser do hard flux then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on December 11, 2021, 06:10:13 AM
:o  ??? How does the Pulse laser do hard flux then?
Pulse Laser is a projectile weapon. It fires bolts that go from A to B and hit whatever they touch/pass through. Other examples would be the Plasma Cannon, Ion Cannon, and every ballistic weapon in the game. Hard flux.

Beams are weapons that stretch from the gun to the target - Tactical Laser, Tachyon Lance, Graviton Beam, etc. They are a special case of dealing only soft flux damage.

(beams are all energy weapons but this does not have any effect on the type of flux it deals: if there were hypothetically a ballistic-slot beam weapon, it would deal soft flux damage - similarly, there is basically no difference between the functioning of a Pulse Laser and a Heavy Autocannon besides their stats - they're both projectiles, despite being different mount types)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on December 12, 2021, 07:49:48 PM
Is there a way to prevent the missile behaviour where they can turn around with their engines off before igniting/re-igniting (ie missile launched opposite direction of target will do a 180° right after launch before ignition) ?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2021, 08:20:28 PM
Is there a way to prevent the missile behaviour where they can turn around with their engines off before igniting/re-igniting (ie missile launched opposite direction of target will do a 180° right after launch before ignition) ?

Yep - a custom missile AI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 12, 2021, 09:09:41 PM
Is there any way to get the (turret/hardpoint)GunSprite of a weapon (aka the recoil sprite)?
The API for WeaponSpec has    
getHardpointSpriteName()
and
getHardpointUnderSpriteName()

But I dont see anything for the barrel.../recoil sprite
The methods you want are in WeaponAPI, not WeaponSpec. Specifically, WeaponAPI.getSprite(), WeaponAPI.getUnderSpriteAPI(), and WeaponAPI.getBarrelSpriteAPI().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: macmillant on December 13, 2021, 12:19:17 AM
Fighter Expansion Rebalanced: hhe_sfl_AegisSystem

Code does a lovely thing of adding PD and PDAlso to specific weapons. Is there a way to replicate this for HEATSEEKER? I have tried to replicate it but don't know if it can be done at my level. (there is code related to PD and PDAlso in the Letter.class files.)

Code
package data.hullmods;


import com.fs.starfarer.api.combat.WeaponAPI;

public interface AddHints extends WeaponAPI {

    void setHEATSEEKER(boolean HEATSEEKER);

}

And...
Whole phrase included so you can see the fun thing I'm trying to do:

Code
	public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
MutableShipStatsAPI stats = fighter.getMutableStats();
List weapons = ship.getAllWeapons();
Iterator iter = weapons.iterator();

while(iter.hasNext()) {
WeaponAPI weapon = (WeaponAPI)iter.next();
boolean sizeMatches = weapon.getSize() == WeaponAPI.WeaponSize.SMALL;
boolean notHEATSEEKER = !weapon.hasAIHint(WeaponAPI.AIHints.HEATSEEKER);
if (sizeMatches && notHEATSEEKER && weapon.getType() != WeaponAPI.WeaponType.MISSILE) {
weapon.setHEATSEEKER(true);
}
}
super.applyEffectsToFighterSpawnedByShip(fighter, ship, id);
}

Anyone know of a way to achieve this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 13, 2021, 02:23:06 AM
What values can ship.getCaptain().getPersonalityAPI().getId() return, and how do they map to the various aggression levels?

Edit: A second question: Is there a way to get weapons to render under the ship, as opposed to above?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 13, 2021, 10:52:26 AM
Fighter Expansion Rebalanced: hhe_sfl_AegisSystem

Code does a lovely thing of adding PD and PDAlso to specific weapons. Is there a way to replicate this for HEATSEEKER? I have tried to replicate it but don't know if it can be done at my level. (there is code related to PD and PDAlso in the Letter.class files.)
Spoiler
Code
package data.hullmods;


import com.fs.starfarer.api.combat.WeaponAPI;

public interface AddHints extends WeaponAPI {

    void setHEATSEEKER(boolean HEATSEEKER);

}

And...
Whole phrase included so you can see the fun thing I'm trying to do:

Code
	public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
MutableShipStatsAPI stats = fighter.getMutableStats();
List weapons = ship.getAllWeapons();
Iterator iter = weapons.iterator();

while(iter.hasNext()) {
WeaponAPI weapon = (WeaponAPI)iter.next();
boolean sizeMatches = weapon.getSize() == WeaponAPI.WeaponSize.SMALL;
boolean notHEATSEEKER = !weapon.hasAIHint(WeaponAPI.AIHints.HEATSEEKER);
if (sizeMatches && notHEATSEEKER && weapon.getType() != WeaponAPI.WeaponType.MISSILE) {
weapon.setHEATSEEKER(true);
}
}
super.applyEffectsToFighterSpawnedByShip(fighter, ship, id);
}

Anyone know of a way to achieve this?
[close]

Unless I'm missing something, the way I think you're trying to go about this fundamentally can't work. It's a bit of an "that's not how any of this works" type of situation :) You can't add methods to an existing interface by having an interface that extends it.

What values can ship.getCaptain().getPersonalityAPI().getId() return, and how do they map to the various aggression levels?

Edit: A second question: Is there a way to get weapons to render under the ship, as opposed to above?

See: Personalities.java

And, don't think so. Best be would be to put decorative "weapons" on top of it and make sure they have showDamageWhenDecorative set to true in the .wpn file. And also renderAboveAllWeapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 13, 2021, 11:04:42 AM
Thanks!

Is there any way to affect how much a storm throws you off-course?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 13, 2021, 11:13:22 AM
Short of a custom hyperspace terrain plugin, I don't think so. (You can fairly easily check this sort of thing, btw - it's all in mod-code, HyperspaceTerrainPlugin etc. If you have the source attached to your IDE then navigating all that should be fairly straightforward.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 13, 2021, 11:53:41 AM
Oh I found the code easy enough, I just couldn't understand it 'XD
Thanks anyway!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 13, 2021, 12:15:48 PM
Oh I found the code easy enough, I just couldn't understand it 'XD
Thanks anyway!

Ahh, fair enough in that case, that's absolutely what this thread is for!

(I just get the feeling sometimes that this thread can become the *first* source when someone has a question, rather than digging around some for the answer. And for reasons of my own sanity, I appreciate it when someone tries to find the answer for themselves first.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: immortalartisan on December 13, 2021, 08:35:07 PM
any method of disabling the minuim markets number for nexerlin random core generations? i had an idea for a cool scenario where you start with a single colony in the entire sector
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 13, 2021, 08:57:27 PM
any method of disabling the minuim markets number for nexerlin random core generations? i had an idea for a cool scenario where you start with a single colony in the entire sector
That question should be asked in the Nexerelin thread, but anyway: you can't, except by modifying the code.

(I've had a 'OG Corvus' single-system scenario on the todo list for some time now, but it was never interesting enough for me to put the needed work in)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LinWasTaken on December 15, 2021, 05:00:56 AM
is there a mod that increases the amount of ships available in shops.
when you have multiple mods that add new ships and you keep seeing the same ships on a lot of different planets it gets frustrating.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 15, 2021, 05:39:59 AM
That means the mod has set those ships' frequencies too high in default_ship_roles.json
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 15, 2021, 06:12:06 AM
It can also be that the faction has them as a favoured ship.
Persean League, for instance, will sell (and deploy?) Conquests to the exclusion of everything else, unless those capitals are also set as preferred.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on December 15, 2021, 07:03:01 AM
So on a scale of haha no to maybe if you go hard at it for 3 months, how feasible is it to create new ship systems from scratch for someone with only basic programming knowledge? Where should I start?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 15, 2021, 08:11:10 AM
Depends how close to an existing ship system it is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on December 15, 2021, 09:02:35 AM
I've two ideas and one is completely different from everything I've seen in vanilla while the other is somewhat different from what I've seen in vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 15, 2021, 12:31:23 PM
Posting for someone...
Quote from: Anonymous
what ... do i have to do to make the extra system line go away
I want the game to treat [ship_system_name] etc. as phase cloak
why ... isn't it doing it, i have it tagged as a phase cloak type system in the system file and the system csv

This is when said ship system name worked finely before pre-damper rightclick rework for almost more than 5 years.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 15, 2021, 12:58:07 PM
Posting for someone...
Quote from: Anonymous
what ... do i have to do to make the extra system line go away
I want the game to treat [ship_system_name] etc. as phase cloak
why ... isn't it doing it, i have it tagged as a phase cloak type system in the system file and the system csv

This is when said ship system name worked finely before pre-damper rightclick rework for almost more than 5 years.

You need to add PHASE to the ship's hints in ship_data.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 15, 2021, 12:59:03 PM
I've two ideas and one is completely different from everything I've seen in vanilla while the other is somewhat different from what I've seen in vanilla.

The biggest issue will be writing your own AI for the system. The system itself is fairly easy to make in the majority of cases. If you can't use a vanilla AI script with it, though, that is some serious effort.

More details will help to determine whether that will the case for you or not. Generally speaking though, if the system is a binary use system (as in meets a certain easy set of criteria to trigger) like, say, a weapon or attack boost? Then you can probably get away with a vanilla AI script. Same thing with a speed boost or teleport kind of system.

The more complex it gets the harder the AI will be to accommodate it reasonably well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 15, 2021, 01:04:51 PM
Posting for someone...
Quote from: Anonymous
what ... do i have to do to make the extra system line go away
I want the game to treat [ship_system_name] etc. as phase cloak
why ... isn't it doing it, i have it tagged as a phase cloak type system in the system file and the system csv

This is when said ship system name worked finely before pre-damper rightclick rework for almost more than 5 years.

You need to add PHASE to the ship's hints in ship_data.csv.
ok thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on December 15, 2021, 07:45:07 PM
I've two ideas and one is completely different from everything I've seen in vanilla while the other is somewhat different from what I've seen in vanilla.

The biggest issue will be writing your own AI for the system. The system itself is fairly easy to make in the majority of cases. If you can't use a vanilla AI script with it, though, that is some serious effort.

More details will help to determine whether that will the case for you or not. Generally speaking though, if the system is a binary use system (as in meets a certain easy set of criteria to trigger) like, say, a weapon or attack boost? Then you can probably get away with a vanilla AI script. Same thing with a speed boost or teleport kind of system.

The more complex it gets the harder the AI will be to accommodate it reasonably well.

Well, they're both functionally simple - one is quite literally a weaponized boost while the other is more or less a weaponized venting mechanism. Though I've still no real clue how to go about scripting said systems... Sure, I could probably start with a vanilla system in the first case for the boost part of it, but then I'm stumped.

Guess I should probably get the csv files over to Sheets and check out existing system files...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 16, 2021, 07:18:02 AM
Is there anyway to know every elements of .proj/.wpn/.ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on December 16, 2021, 07:46:41 AM
Is there anyway to know every elements of .proj/.wpn/.ship?

Since those files live in data, couldn't you re-read them manually with `Global.getSettings().loadJson()`?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 16, 2021, 09:00:51 AM
Guess I should probably get the csv files over to Sheets and check out existing system files...

For a brief overview, the csv determines the systems resources and a couple misc things like tags, the name and icon, etc. So if you want this system to have charges (whether finite or regenerating), cost hard flux or soft flux to activate, generate flux over time, etc, that's the place to define that stuff.

The JSON file determines that AI and stats scripts that the system uses. The stats script is the real meat of what the system does. For example, looking at the Ammo Feeder:

   "id":"targetingfeed",
   "type":"STAT_MOD",
   "aiType":"TARGETING_FEED",
   
   "statsScript":"com.fs.starfarer.api.impl.combat.TargetingFeedStats",

 - so checking out TargetingFeedStats is the place you would want to start to see how a system actually does things. The other stuff is mostly just cosmetic and resource use. The AI script isn't visible to modders, with the exception of an example script from Fast Missile Racks that isn't actually used by vanilla anymore. But, the good news is that it sounds like you can mostly get away with using the available AI scripts - at least for the first one. The second one is a little more dicey, but if needed I can link you some code from one of my AI scripts that specifically handles flux management.



Ok, so this has been somewhat of a thorn in my side for a bit now. I am still getting end user reports of:

63831 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoClassDefFoundError: org/lazywizard/lazylib/combat/AIUtils
java.lang.NoClassDefFoundError: org/lazywizard/lazylib/combat/AIUtils
   at data.scripts.shipsystems.ai.AO_FluxConverterAI.assessNearbyThreats(AO_FluxConverterAI.java:164)
   at data.scripts.shipsystems.ai.AO_FluxConverterAI.advance(AO_FluxConverterAI.java:102)
   at com.fs.starfarer.loading.specs.M$1.super(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.lazywizard.lazylib.combat.AIUtils
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 12 more

 - For my AI script from my Flux Converter system. Specifically, this line:

List<ShipAPI> shipList = AIUtils.getNearbyEnemies(ship, nearbyShipAssessmentRange);

 - which is imported with:

import org.lazywizard.lazylib.combat.AIUtils;

I checked the javadoc and the path to the class is correct and the class contains the necessary method. I don't get this error when I test out the system myself, and the user has stated that the most current version of the mod and lazylib are both running.

I'm not sure if its environment related and for some reason the user's system doesn't like static method calls or what is going on. Can anyone who has used lazylib extensively please help me out or point me in the right direction as to what's going on? I'd like to help the user, but I don't really know what else to do other than try and find the exact encounter (Guardian fight).

Speaking of that, is there a way to pinpoint that encounter's location using devmode? Then I could turn devmode off to have a completely controlled test once I know what system to go to.

*EDIT*

Hmm, come to think of it, I wonder if this is caused by the library class path not matching the user's actual C drive. The project assumes C:\Program Files (x86)\Fractal Softworks\Starsector\mods is the mods directory for the game.

Now, how to fix it? Maybe I should just include the source itself in the project to get around that. That way its one jar and the C drive path won't matter. Then I can just include a script to crash the mod if LazyLib isn't on the mod list.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on December 16, 2021, 01:32:59 PM
For a brief overview, the csv determines the systems resources and a couple misc things like tags, the name and icon, etc. So if you want this system to have charges (whether finite or regenerating), cost hard flux or soft flux to activate, generate flux over time, etc, that's the place to define that stuff.

The JSON file determines that AI and stats scripts that the system uses.
[omitted]

Ooooh, thank you so much! That clarifies a lot of things!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 16, 2021, 01:41:57 PM
Ooooh, thank you so much! That clarifies a lot of things!

Np and happy modding!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 16, 2021, 05:10:59 PM
Dunno about AO since I don't use it, but I run the whole game on a non-C drive and it works fine with all the mods I've used this version.

Here's a console runcode to find all cryosleepers:
Code
runcode 
for (StarSystemAPI system : Global.getSector().getStarSystems())
{
for (SectorEntityToken token : system.getAllEntities()) {
if ("derelict_cryosleeper".equals(token.getCustomEntityType())) {
Console.showMessage(system.getBaseName());
}
}
}
Do you use LazyLib at any point before the Flux Converter system? I'm not sure I trust users to actually have LazyLib enabled.

Also you should already be using the mod dependency function in mod_info.json that was added in 0.95a.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 16, 2021, 08:08:13 PM
Since those files live in data, couldn't you re-read them manually with `Global.getSettings().loadJson()`?
Well, I mean, I don't know if there are elements which doesn't show in common .wpn/.proj, like, i don't now I could set
Code
"noCollisionWhileFading":true,
"useHitGlowWhenDestroyed":true,
in .proj if others didn't tell me
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 16, 2021, 09:13:18 PM
Dunno about AO since I don't use it, but I run the whole game on a non-C drive and it works fine with all the mods I've used this version.

It's really just the thing that stood out in the IDE when looking at the project structure. That, and technically having lazylib enabled wasn't even required. It just had to be in the mods directory. That made it seem like it was using the exact path for the class rather than using the game's compiled scripts - which would require the mod to be enabled at compile time afaik. This would mean that only windows users would subsequently have the correct path to the class if they had lazylib in their mods directory. That's my thought process at least. I still can't reproduce it even after finding the exact encounter on the downloaded mod version (instead of the dev version).

Quote
Here's a console runcode to find all cryosleepers:

I appreciate the shortcut. I didn't actually think to use the runcode method at the time and was hoping for a devmode solution but that was essentially the same thing.

Quote
Do you use LazyLib at any point before the Flux Converter system? I'm not sure I trust users to actually have LazyLib enabled.

See above. It actually didn't have to be enabled. It just had to be present in the mods directory. But, that said, I only use the method in this AI and in the Commissioned Crews hullmod for the Adamantine Consortium which was a WIP until recently, so this is a fairly new issue yes. It comes up very intermittently and there was a case in the past where lazylib changed the directories and I had to make some changes - though I think that was a while ago.

I haven't seen the error myself in a while. 

Quote
Also you should already be using the mod dependency function in mod_info.json that was added in 0.95a.

Thanks for pointing this out to me. I either missed this or looked at it and then forgot. I'll check the prior patch notes for syntax or look at other mods for an example. Either way, I made my code generate a RuntimeException if the lazylib library mod isn't enabled.

*EDIT*

Oh, almost forgot, I also hopefully solved the issue by including the lazylib jar in the mod directory and adding that jar to the mod_info file. This made it so that lazylib didn't even need to be in the mods directory -  which leads me to believe that the necessary class definition is compiled correctly at runtime instead of relying on an exact path to the mods directory as it would seem to be the case with adding the library to the IntelliJ project. Granted, the IntelliJ version is old so newer versions could not have this problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 17, 2021, 12:55:43 PM
Separate issue I discovered while testing the script issue:

The Guardian seems to spawn without its modules in the Cryosleeper interaction. I can't find the code that handles this, however. It doesn't seem to be in rules and I looked in MiscThemeGenerator and DerelictThemeGenerator and I don't see any reference to the Guardian.

And, finally, how would I go about replacing MiscThemeGenerator?

I figure I should do it on a new game, of course, but what would I add it to and do I need to replace more than just that script? Just getting pointed in the general direction would help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 18, 2021, 06:08:57 AM
How do I make an admin skill that can take effect and appear in the skill list of persons I specifically give it to, but won't be picked in createAdmin?

I guess I could tag it as being both player_only and npc_only...

EDIT: Also, out of morbid curiosity, is the special deployment ability from that deprecated 0.95.1a skill in a working state?
Spoiler
Force Concentration
[close]

And, finally, how would I go about replacing MiscThemeGenerator?
SectorThemeGenerator.generators is a public static list, so you can take generators out of it and add your own. Though there's stuff elsewhere in the codebase that calls static methods in the theme generators, so I don't know how much will end up actually being changed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 18, 2021, 07:11:50 AM
@Histidine

Thanks and all I'm trying to do is change the hardcoded ids of the derelict salvageable ships to the TC ids. So hopefully that one portion is only called at the game start.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on December 19, 2021, 10:41:27 PM
Is there any way to get a gun's recoil sprite to still return to the original position if the gun doesn't have any ammo? I've got a gun that generates ammo slightly slower than it uses it (rather than reloading in clips, it just drops to a slower rate of fire when the ammo runs out) and the recoil sprite just stays fixed backwards once it runs out of ammo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 20, 2021, 02:13:42 AM
Where exactly are defend orders placed during a station fight (so I know how wide I can make a station)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 20, 2021, 09:37:12 AM
Is there any way to get a gun's recoil sprite to still return to the original position if the gun doesn't have any ammo? I've got a gun that generates ammo slightly slower than it uses it (rather than reloading in clips, it just drops to a slower rate of fire when the ammo runs out) and the recoil sprite just stays fixed backwards once it runs out of ammo.

Hmm, I don't believe there is.


Where exactly are defend orders placed during a station fight (so I know how wide I can make a station)?

2500 units away; the actual angles depend on where the bulk of the enemy fleet is and the location is updated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 20, 2021, 09:54:17 AM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 20, 2021, 01:26:49 PM
So I was able to enable d-mods on my spawned fleets, (https://fractalsoftworks.com/forum/index.php?topic=5061.msg347085#msg347085) but now I have a different issue: not only ships do get D-mods and S-mods, but they also get autofitted too. The problem being that those fleets are most of the times built around having a very specific flagship with a custom loadout.

I would like to know if there is a way to exclude specific ships from the fleet inflater? Or if there could be a way in the future like a tag on the variant maybe?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 20, 2021, 01:29:59 PM
You can add a no_autofit tag to the ship's variant with code. Important: don't do it via the .variant file, you can't specify tags there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tartiflette on December 20, 2021, 02:47:59 PM
Thanks, that's exactly what I needed!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on December 20, 2021, 08:09:36 PM
I'm trying to make a console command that duplicates ships, and what I currently have is correctly copying everything except Smods. I've already tried simply cloning the variant and setting the boolean field of addPermaMod to false (which seemed to make it behave the exact same as it did as when it was set to true). Any idea what is wrong?
Code
    private void copySmods(ShipVariantAPI original, ShipVariantAPI copy)
    {
        // tested on shrike w. unstable injector smod, writes "smod2: unstable_injector"
        for(String smod : original.getSMods())
        {
            Console.showMessage("smod:" + smod);
            copy.addPermaMod(smod, true);
        }
       
        // tested on shrike w. unstable injector, writes "smod2: unstable_injector"
        for(String smod : copy.getSMods())
        {
            Console.showMessage("smod2:" + smod);
        }
    }

    // code from lazy wizard
    private boolean cloneShip(FleetMemberAPI cloneCandidate, int amount)
    {
        String variantId = cloneCandidate.getVariant().getHullSpec().getHullId();
        String variant = null;
        for (String id : Global.getSettings().getAllVariantIds())
        {
            if (variantId.equalsIgnoreCase(id))
            {
                variant = id;
                break;
            }
        }

        // Test for empty hulls
        if (variant == null)
        {
            final String withHull = variantId + "_Hull";
            for (String id : Global.getSettings().getAllVariantIds())
            {
                if (withHull.equalsIgnoreCase(id))
                {
                    variant = id;
                    break;
                }
            }
        }

        if(variantId == null)
        {
            return false;
        }

        // We have finally verified the variant id, now create the actual ship
        FleetMemberAPI ship;
        try
        {
            ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variant);
        }
        catch (Exception ex)
        {
            Console.showException("Failed to create variant '" + variant + "'!", ex);
            return false;
        }

        final FleetDataAPI fleet = Global.getSector().getPlayerFleet().getFleetData();
        for (int i = 0; i < amount; i++)
        {
            ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variant);

            ShipVariantAPI variantCopy = cloneCandidate.getVariant().clone();
            copySmods(cloneCandidate.getVariant(), variantCopy);

            // tested on shrike w. unstable injector, writes "smod2: unstable_injector"
            for(String smod : variantCopy.getSMods())
            {
                Console.showMessage("smod3:" + smod);
            }
           
            ship.setVariant(variantCopy, true, true);
            FleetEncounterContext.prepareShipForRecovery(ship,
                    true, true, true,1f, 1f, MathUtils.getRandom());
            fleet.addFleetMember(ship);
        }
        return true;
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 21, 2021, 02:55:51 AM
Two questions:

- I assume this code is redundant and I only need one sync?
Code: java
fleet.getFleetData().setSyncNeeded();
fleet.getFleetData().syncIfNeeded();
fleet.forceSync();
- Is there a way to suppress (at least temporarily) the "player character must always be assigned to a ship" behavior?
I'm doing a thing where I temporarily setPlayerFleet(otherFleet) for the purposes of assigning its officers and refitting ships, but the PC gets force-assigned to one of its ships which is undesirable. If there isn't a solution, I'll just implement my own GUI for officer assignment.


@itBeABruhMoment: First thing I'd try is calling variant.setSource(VariantSource.REFIT) on the cloned variant before or after assigning it to the ship.
If that fails, could take a look at how Industrial.Evolution's Hull Forge does it (the industry can make ships with S-mods already present, if the forge template had them).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2021, 11:03:47 AM
Two questions:

- I assume this code is redundant and I only need one sync?
Code: java
fleet.getFleetData().setSyncNeeded();
fleet.getFleetData().syncIfNeeded();
fleet.forceSync();

If it's there, it possibly needed multiple syncs for effects that work with the effects of other effects. But I'm not seeing where this would be in vanilla code, and forceSync() basically does the above two lines twice.

- Is there a way to suppress (at least temporarily) the "player character must always be assigned to a ship" behavior?
I'm doing a thing where I temporarily setPlayerFleet(otherFleet) for the purposes of assigning its officers and refitting ships, but the PC gets force-assigned to one of its ships which is undesirable. If there isn't a solution, I'll just implement my own GUI for officer assignment.

Offhand, I don't think so. But you might be able to remove the player from the flagship after that happens and it might not happen. It all depends on the exact code path, and it *will* happen again I think when you either join a battle or open the fleet screen or possibly other things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on December 21, 2021, 02:35:37 PM
Two questions:

- I assume this code is redundant and I only need one sync?
Code: java
fleet.getFleetData().setSyncNeeded();
fleet.getFleetData().syncIfNeeded();
fleet.forceSync();
- Is there a way to suppress (at least temporarily) the "player character must always be assigned to a ship" behavior?
I'm doing a thing where I temporarily setPlayerFleet(otherFleet) for the purposes of assigning its officers and refitting ships, but the PC gets force-assigned to one of its ships which is undesirable. If there isn't a solution, I'll just implement my own GUI for officer assignment.


@itBeABruhMoment: First thing I'd try is calling variant.setSource(VariantSource.REFIT) on the cloned variant before or after assigning it to the ship.
If that fails, could take a look at how Industrial.Evolution's Hull Forge does it (the industry can make ships with S-mods already present, if the forge template had them).

Welp, I've tried your proposed solutions and they didn't seem to work. In terms of the industrial evo solution, I tested making a new ship and adding a smod to it through the process seen in industrial evo source code, which also didn't work. Could you tell me how to activate the mechanic that produces smodded ships in industrial evo, I want to ensure that the mechanic works in 0.95.1a. addPermaMod not correctly adding smods even though the hullmod that was "added" appears in the collection returned by getSMods feels like a bug.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on December 21, 2021, 04:25:17 PM
I'm trying to make a console command that duplicates ships, and what I currently have is correctly copying everything except Smods. I've already tried simply cloning the variant and setting the boolean field of addPermaMod to false (which seemed to make it behave the exact same as it did as when it was set to true). Any idea what is wrong?

-snipped code-

There's an overload of createFleetMember that takes a ShipVariantAPI instead of a variantID string, and I'm wondering what's wrong with just using that? For example, this two liner worked to clone a ship for me, S-mods and all:

Code
FleetMemberAPI dup = Global.getFactory().createFleetMember(FleetMemberType.SHIP, fleetMember.getVariant().clone());
Global.getSector().getPlayerFleet().getFleetData().addFleetMember(dup);
Iirc some ships have temporary variant ids (notably the ships you start with), so it's a bit tricker to spawn ships using variant id strings, since you have to walk through the hull id to variant list map and actually find one that corresponds to the variant's hull id, but I've not encountered a situation where the actual ship's getVariant is temporary or otherwise unusable.

Edit: good call on the cloning, added that in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2021, 04:28:17 PM
Offhand, you might want to throw in a fleetMember.getVariant().clone() - otherwise it seems like you might end up with them sharing the variant and changes in one might be reflected in the other, depending.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on December 21, 2021, 05:08:24 PM
I'm trying to make a console command that duplicates ships, and what I currently have is correctly copying everything except Smods. I've already tried simply cloning the variant and setting the boolean field of addPermaMod to false (which seemed to make it behave the exact same as it did as when it was set to true). Any idea what is wrong?

-snipped code-

There's an overload of createFleetMember that takes a ShipVariantAPI instead of a variantID string, and I'm wondering what's wrong with just using that? For example, this two liner worked to clone a ship for me, S-mods and all:

Code
FleetMemberAPI dup = Global.getFactory().createFleetMember(FleetMemberType.SHIP, fleetMember.getVariant().clone());
Global.getSector().getPlayerFleet().getFleetData().addFleetMember(dup);
Iirc some ships have temporary variant ids (notably the ships you start with), so it's a bit tricker to spawn ships using variant id strings, since you have to walk through the hull id to variant list map and actually find one that corresponds to the variant's hull id, but I've not encountered a situation where the actual ship's getVariant is temporary or otherwise unusable.

Edit: good call on the cloning, added that in.

Thanks, I've figured it out. Why I couldn't get this to work for fleet members created by createFleetMember(FleetMemberType.SHIP, hull_id) is beyond me. Here is the code for anyone's future reference
Code
final FleetDataAPI fleet = Global.getSector().getPlayerFleet().getFleetData();
clonedShip = Global.getFactory().createFleetMember(FleetMemberType.SHIP, cloneCandidate.getVariant().clone());
FleetEncounterContext.prepareShipForRecovery(clonedShip, true, true, true,1f, 1f, MathUtils.getRandom());
for(String smod : cloneCandidate.getVariant().getSMods())
{
    clonedShip.getVariant().addPermaMod(smod, true);
}
clonedShip.updateStats(); //seems to work fine without this function, but I saw this used in some code to add smods
fleet.addFleetMember(clonedShip);
note that this uses functions from LazyLib
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 21, 2021, 06:24:19 PM
How to transfer S-mods from one FleetMemberAPI to another, as used in Roider_BaseRetrofitManager.java:
Code: java
    public void transferSMods(FleetMemberAPI source, FleetMemberAPI target) {
        LinkedHashSet<String> sMods = source.getVariant().getSMods();

        for (String mod : sMods) {
            target.getVariant().addPermaMod(mod, true);
        }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 21, 2021, 07:45:17 PM
I am creating tokens and adding them to systems for fleets to travel to. Am I using them right? Do they automatically get cleaned up? Is this a memory leak?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 21, 2021, 07:56:22 PM
question
how can i iterate through all existing people in the sector
i mean custom people, like andrada and such
i mean without knowing their ID beforehand
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2021, 08:13:38 PM
I am creating tokens and adding them to systems for fleets to travel to. Am I using them right? Do they automatically get cleaned up? Is this a memory leak?

The createToken() comment:
// Not actually added to the location, and doesn't need to be. Can be added via addEntity if it needs to have an orbit.

So if you're actually adding them to the system, you do need to also remove them, otherwise it would be (a quite minor) savefile/memory leak. But if you just want the fleet to go to a specific coordinate, you can create the token, NOT add it to the system, and just pass it in to the fleet's assignment - and when that's finished, all references to the token will be gone and it will get cleaned up.


question
how can i iterate through all existing people in the sector
i mean custom people, like andrada and such
i mean without knowing their ID beforehand

There's:
Global.getSector().getImportantPeople()

And also you could iterate over:
Global.getSector().getEconomy().getMarketsCopy() (or something similar)
And do .getPeople() on each market.

It depends on exactly what you're looking to do.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 21, 2021, 08:30:10 PM
I am creating tokens and adding them to systems for fleets to travel to. Am I using them right? Do they automatically get cleaned up? Is this a memory leak?

The createToken() comment:
// Not actually added to the location, and doesn't need to be. Can be added via addEntity if it needs to have an orbit.

So if you're actually adding them to the system, you do need to also remove them, otherwise it would be (a quite minor) savefile/memory leak. But if you just want the fleet to go to a specific coordinate, you can create the token, NOT add it to the system, and just pass it in to the fleet's assignment - and when that's finished, all references to the token will be gone and it will get cleaned up.

Ah, right. I do need orbits, so I will have to handle cleanup. Didn't think about it because all my other usages are in system gen classes where there is no risk of memory leaks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on December 21, 2021, 09:36:31 PM
I'm trying to make a console command that duplicates ships, and what I currently have is correctly copying everything except Smods. I've already tried simply cloning the variant and setting the boolean field of addPermaMod to false (which seemed to make it behave the exact same as it did as when it was set to true). Any idea what is wrong?

-snipped code-

There's an overload of createFleetMember that takes a ShipVariantAPI instead of a variantID string, and I'm wondering what's wrong with just using that? For example, this two liner worked to clone a ship for me, S-mods and all:

Code
FleetMemberAPI dup = Global.getFactory().createFleetMember(FleetMemberType.SHIP, fleetMember.getVariant().clone());
Global.getSector().getPlayerFleet().getFleetData().addFleetMember(dup);
Iirc some ships have temporary variant ids (notably the ships you start with), so it's a bit tricker to spawn ships using variant id strings, since you have to walk through the hull id to variant list map and actually find one that corresponds to the variant's hull id, but I've not encountered a situation where the actual ship's getVariant is temporary or otherwise unusable.

Edit: good call on the cloning, added that in.

Thanks, I've figured it out. Why I couldn't get this to work for fleet members created by createFleetMember(FleetMemberType.SHIP, hull_id) is beyond me. Here is the code for anyone's future reference
Code
final FleetDataAPI fleet = Global.getSector().getPlayerFleet().getFleetData();
clonedShip = Global.getFactory().createFleetMember(FleetMemberType.SHIP, cloneCandidate.getVariant().clone());
FleetEncounterContext.prepareShipForRecovery(clonedShip, true, true, true,1f, 1f, MathUtils.getRandom());
for(String smod : cloneCandidate.getVariant().getSMods())
{
    clonedShip.getVariant().addPermaMod(smod, true);
}
clonedShip.updateStats(); //seems to work fine without this function, but I saw this used in some code to add smods
fleet.addFleetMember(clonedShip);
note that this uses functions from LazyLib
>finished code
>decides to update to rc-6 because code was done
>use command when trying the new falcon
>copies nothing correctly but the smods
code bricks in rc-6, back to the drawing board
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on December 21, 2021, 09:44:32 PM
>finished code
>decides to update to rc-6 because code was done
>use command when trying the new falcon
>copies nothing correctly but the smods
code bricks in rc-6, back to the drawing board

I tested those two lines on RC6 and they work fine. BTW, cloneCandidate.getVariant() already stores information about its own S-mods, so there isn't any need to transfer them onto clonedShip's variant. It's different if you use variant ids from the global list map, since I think those are just the stock variants that don't have any custom hull mods on them at all. Do you have a stack trace?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on December 21, 2021, 09:47:42 PM
My bad I got my jars mixed up. NVM
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SikeSky on December 22, 2021, 03:46:28 AM
Hi, I'm trying to get some custom shields working. I'll try to be as clear as possible, but be warned that I am fairly wet-behind-the-ears when it comes to Java.

My goal is to have multiple small shields rotating around the ship with stats and behavior separate from the default shield. They will power up whenever the main shield is activated and power down when it's turned off. I want a lot on every ship I'm adding, so I'd prefer not to use modules to jury rig it.

Since ShieldAPI is an abstract class it's impossible to instantiate any new ShieldAPIs, so instead I started to implement it as a new class. Somebody quickly pointed out that since I had no idea how ShieldAPI was implemented in vanilla I would likely not be able to create a new, working implementation. Unfortunately neither of us could find where ShieldAPI was implemented in the game files - they searched through the obf.jar file which I was unfamiliar with but turned up nothing.

So I guess my question(s) are first, where can I find that implementation for reference, and second, is there anything else I should know/consider when it comes to creating custom shields?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on December 22, 2021, 03:03:47 PM
Hi, I'm trying to get some custom shields working. I'll try to be as clear as possible, but be warned that I am fairly wet-behind-the-ears when it comes to Java.

My goal is to have multiple small shields rotating around the ship with stats and behavior separate from the default shield. They will power up whenever the main shield is activated and power down when it's turned off. I want a lot on every ship I'm adding, so I'd prefer not to use modules to jury rig it.

Since ShieldAPI is an abstract class it's impossible to instantiate any new ShieldAPIs, so instead I started to implement it as a new class. Somebody quickly pointed out that since I had no idea how ShieldAPI was implemented in vanilla I would likely not be able to create a new, working implementation. Unfortunately neither of us could find where ShieldAPI was implemented in the game files - they searched through the obf.jar file which I was unfamiliar with but turned up nothing.

So I guess my question(s) are first, where can I find that implementation for reference, and second, is there anything else I should know/consider when it comes to creating custom shields?

Keep in mind that even if you were able to create your own implementation of ShieldAPI, there isn't really any way to attach it to your ship. See ShipAPI for example -- the setShield method doesn't allow you to pass in an arbitrary ShieldAPI; it instead tells you to pass in the shield type, upkeep, efficiency, and arc, and it's very likely that the game is generating its own implementation behind the scenes.

Off the top of my head I can think of two examples that sort of do the functionality you're asking for. The first is the Exemplar-class from Vayra's ship pack (I think), which has a ship system that spawns six drones, each with its own shield, and the drones rotate around the ship. The second is to use modules with their own shield to simulate the ship having multiple shields, but I'm not sure how you'd get them to rotate around the ship. never mind, you've already thought of this
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 22, 2021, 04:55:54 PM
Yeah, a custom implementation of ShieldAPI is extremely unlikely to work - under the hood, the game is likely to be assuming it's the actual vanilla implementing class in any number of places. Generally in Starsector code, if something ends in "API", it means its exposing some functionality from core code, but not something that can be replaced, while if something ends in "Plugin", then that *is* meant to be replaceable by an alternate implementation.

I think extra modules is the only real viable way I see here for what you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SikeSky on December 22, 2021, 05:29:06 PM
Yeah, a custom implementation of ShieldAPI is extremely unlikely to work - under the hood, the game is likely to be assuming it's the actual vanilla implementing class in any number of places. Generally in Starsector code, if something ends in "API", it means its exposing some functionality from core code, but not something that can be replaced, while if something ends in "Plugin", then that *is* meant to be replaceable by an alternate implementation.

I think extra modules is the only real viable way I see here for what you want.

I see, thank you. I'm not sure how hard it would be to open that up to custom implementation, but I think being able to create custom shields and shield geometry etc. would open up all kinds of interesting possibilities for modders. It sounds like it's a little more in-depth than a simple API addition, but would the API request thread be an appropriate place to make the suggestion, if at all?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 22, 2021, 05:42:47 PM
The API requests thread is mainly for "this is present in core code but there's no way to get to it", with a little leeway.

What you're talking about here is a major re-engineering effort :) So perhaps that wouldn't be the place for it, but, I mean, consider the suggestion made! Odds of it actually being implemented are extremely not good, though, due to the sheer amount of work (and time) it would require. Never mind that something this complicated without a vanilla use case would also be near-impossible to adequately test and not break going forward.

Sorry to shoot the idea down! It's just, well, not very practical on the backend.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 23, 2021, 06:37:48 AM
So while troubleshooting this thread (https://fractalsoftworks.com/forum/index.php?topic=23212.0) to ensure I am not also doing something to cause this crash (since my mod was present on the list of a few of these reports) I get to this line in BattleAutoresolverPluginImpl.java:

Code
490			member.getStatus().applyHullFractionDamage(damage, i);

This relies upon dealing damage to individual fighters in a wing according to the comments? Even though its looking for modules in this case? So, if I am understanding this correctly (though I doubt I am considering how obscure the code is in this particular section is and I suspect its been reused from its original use case) something is going on with:

Code
463				String slotId = member.getVariant().getModuleSlots().get(i - 1);
464 variant = variant.getModuleVariant(slotId);

 - which is causing an array out of bounds when trying to apply the calculate damage based upon the index being passed in. The weird thing is that "i" isn't supposed to be able exceed the number of "statuses" though what this actually means is unclear to me considering the notes seem to indicate it can be the number of wing members in a fighter wing or the number of modules on a ship depending upon a context that isn't really defined:
Code
458		float num = member.getStatus().getNumStatuses();
459 boolean someActiveRemaining = false;
460 for (int i = 0; i < num; i++) {

But! Based upon this line:

Code
455		if (member.isFighterWing()) return;

 - my guess is the context is whether the FleetMemberAPI is a fighter wing or a ship. And in this case its looking for ships only to check for modules.

Histidine thinks this may be due to improperly defined modules in the mod, but I was wondering if there was any additional insight from the backend side of things. Cross referencing vanilla code seems to indicate everything is defined properly - unless I am missing something but it isn't obvious to me anyway.

Thanks for any additional help in advance! Hopefully I can track this thing down as I think it has happened in other mods too and just having the information out there would likely prove useful to modders in general if they are making stations or moduled ships.

I've cross reference over half of my station files and nothing seems out of the ordinary compared to the vanilla implementation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2021, 08:29:45 AM
Yeah, this isn't used for fighters anymore, that's from way back when they were full-fledged fleet members and not installed on carriers. (Unless a mod somewhere out there still does this? It might work.)

So, it's used for ships with modules and stations. The status with index 0 is the main body; the rest are the modules, in the order they're defined in the variant, iirc. The absolute key thing - and I think possibly where the problem might come from? Is that the number of modules (and perhaps type, not 100% on that offhand) *can not* change from when the fleet member is originally created, since the status array is created then, too. If, for example, you dynamically add an extra module with code, stuff will crash in this way because the new module will push the number of modules higher than the size of the status array.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 23, 2021, 09:13:50 AM
Yeah, this isn't used for fighters anymore, that's from way back when they were full-fledged fleet members and not installed on carriers. (Unless a mod somewhere out there still does this? It might work.)

So, it's used for ships with modules and stations. The status with index 0 is the main body; the rest are the modules, in the order they're defined in the variant, iirc. The absolute key thing - and I think possibly where the problem might come from? Is that the number of modules (and perhaps type, not 100% on that offhand) *can not* change from when the fleet member is originally created, since the status array is created then, too. If, for example, you dynamically add an extra module with code, stuff will crash in this way because the new module will push the number of modules higher than the size of the status array.

I really appreciate the insight. Nothing I do does this afaik. At least assuming "dynamically" means in the combat layer.

Other than that? I cannot say.

*EDIT* In other words, I don't add any modules dynamically. At least, if I add any additional ones it is through variant files which reference different ship files with updated module slots and so that should be irrelevant, etc. The only thing that might be different in this case is the hullmods which also add fighter bays. I doubt that this is the cause of the error though considering that the use case has changed completely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2021, 09:17:48 AM
By dynamically I mean in the campaign layer. Like, the "bad" sequence of steps would be something like:

1) Add a ship-with-modules/station fleet member to a fleet
2) Use member.getVariant().setModuleVariant() to add a module to it, into a module slot that the original fleet member's variant had empty
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 23, 2021, 09:30:49 AM
By dynamically I mean in the campaign layer. Like, the "bad" sequence of steps would be something like:

1) Add a ship-with-modules/station fleet member to a fleet
2) Use member.getVariant().setModuleVariant() to add a module to it, into a module slot that the original fleet member's variant had empty

Ah ok thanks for clarifying! I don't do this specifically, but it's good to know that it's not a good idea either way. Well, then I can only assume its nothing related to my implementation from what I can gather.

If anyone has additional input let me know, but I am considering this bug "solved" until then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2021, 09:41:03 AM
Now that I think about it, one time this came up recently, iirc, was when someone had a problem with one of the .variant files... trying to remember what it was (or who it was, so I can look it up) but having a hard time remembering. But it was something like one of the variants having a different number of modules than the rest, though I'm not sure what the additional factor was that made this into a crash instead of being fine.

It could for example be something like: the ship is in a player-faction fleet, and has "goal" variants for autofit. In which case there's a chance that it'll try to fit with that variant as the "target" instead of the original variant of the fleet member. And if there's a mismatch in the number of modules, then that would cause a crash, without any dynamic modification of the variant - but simply because a stock variant, and a player-made goal variant (based on another stock variant) had a different number of modules, if that makes sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 23, 2021, 10:11:09 AM
Now that I think about it, one time this came up recently, iirc, was when someone had a problem with one of the .variant files... trying to remember what it was (or who it was, so I can look it up) but having a hard time remembering. But it was something like one of the variants having a different number of modules than the rest, though I'm not sure what the additional factor was that made this into a crash instead of being fine.

It could for example be something like: the ship is in a player-faction fleet, and has "goal" variants for autofit. In which case there's a chance that it'll try to fit with that variant as the "target" instead of the original variant of the fleet member. And if there's a mismatch in the number of modules, then that would cause a crash, without any dynamic modification of the variant - but simply because a stock variant, and a player-made goal variant (based on another stock variant) had a different number of modules, if that makes sense.

Ok, hmmm, this is just offhand (and I will continue checking variant files for mismatches either way), then this could only occur with the Mothership and Guardian encounters based upon an initial assessment since the Guardian is technically acquire-able through a mod-setting-only which defaults to false. The .ship with modules couldn't be in the player fleet otherwise unless in an "Allied Battle" - assuming no mod alteration influences at least - and therefore wouldn't be part of any autofit considerations - though technically a base setting removes autofit from being a possibility through the default presence of the "no_autofit" tag in most ship definitions. However, this is also customizable in settings so it is relatively unreliable in a report since this is the case... so sigh.

I'll try and see what additional info I can produce, if any,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on December 23, 2021, 11:19:06 AM
It could for example be something like: the ship is in a player-faction fleet, and has "goal" variants for autofit. In which case there's a chance that it'll try to fit with that variant as the "target" instead of the original variant of the fleet member. And if there's a mismatch in the number of modules, then that would cause a crash, without any dynamic modification of the variant - but simply because a stock variant, and a player-made goal variant (based on another stock variant) had a different number of modules, if that makes sense.

I think I get what you mean here, but just in case this would otherwise be an issue, I disabled   "goalVariant": true, -to:   "goalVariant": false, - in all of my mod's station modules. Since the mod overrides variants that reference separate ship files, I would therefore think that wouldn't be an issue, but this is a safeguard in case multiple things are coming together from a user customization standpoint to cause this error.

I haven't tested this yet to see what this impacts in the TC, but I will see if I can reproduce anything later on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2021, 11:54:57 AM
I think I get what you mean here, but just in case this would otherwise be an issue, I disabled   "goalVariant": true, -to:   "goalVariant": false, - in all of my mod's station modules. Since the mod overrides variants that reference separate ship files, I would therefore think that wouldn't be an issue, but this is a safeguard in case multiple things are coming together from a user customization standpoint to cause this error.

That wouldn't necessarily matter here - a custom variant could become a "goal" variant if the player saves their current variant as such, using the autofit dialog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 23, 2021, 04:20:29 PM
Is there some way to get the color of a small area of pixels from a sprite (say, the area around a ship where a deco was) then shift the hue of the deco to better match the color of the ship? AFAIK, turret covers do this somewhat, but i'm not sure how i'd be able to reproduce it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on December 24, 2021, 01:06:57 AM
Interesting its possible to edit UI? For example I want add some skill as new one, without overwriting, but then skills kinda don't fit the screen:(https://media.discordapp.net/attachments/908476833736060969/923857357715427348/screenshot002.png?width=945&height=591)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 24, 2021, 03:14:55 AM
Making them new aptitudes, such that they have their own line, is the only option.



How do I make hyperspace storms deal no damage? I have a hullmod that should set the damage to 0 (multiplies it by 0), but when struck, ships are losing armour still (no hull damage though).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inhilicon on December 24, 2021, 03:22:18 AM
Hello, altruistic helper folks whom I wish merry christmas to. I'm having a problem with my custom ship. It seems to ignore variants and keeps placing a Hammer barrage on the sole large ballistic slot of the ship. Any guess as to why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 24, 2021, 03:40:40 AM
What Faction does it belong to? Chances are they don't know the blueprint for the weapon you want there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inhilicon on December 24, 2021, 04:10:12 AM
What Faction does it belong to? Chances are they don't know the blueprint for the weapon you want there.

EDIT: Nevermind all that, it apparently had a built-in weapon that was invisible in the editor. Thanks for the help anyway, Yunru. And merry christmas!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on December 24, 2021, 04:58:01 AM
Speaking of UI, adding new altitudes is easy apparently, but its now have only one skill in it:
(https://media.discordapp.net/attachments/908476833736060969/923920759657746483/screenshot005.png?width=945&height=591)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 24, 2021, 06:03:39 AM
Speaking of custom skill aptitudes, I don't suppose it's possible to give a skill custom requirements (say, it requires no skill points but the player must have another skill X, and spend N story points)?
Well, could just create a separate GUI to learn such skills, with the character screen only for displaying its effects. Shame to waste the established skill GUI though...

How do I make hyperspace storms deal no damage? I have a hullmod that should set the damage to 0 (multiplies it by 0), but when struck, ships are losing armour still (no hull damage though).
Dunno if it fits your needs, but UNGP's Storm Rider rule gives the whole fleet immunity to storm damage by setting a memory key on loop:
Code: java
fleet.getMemoryWithoutUpdate().set("$stormStrikeTimeout", true, 0.1f);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2021, 12:48:51 PM
Is there some way to get the color of a small area of pixels from a sprite (say, the area around a ship where a deco was) then shift the hue of the deco to better match the color of the ship? AFAIK, turret covers do this somewhat, but i'm not sure how i'd be able to reproduce it.

Not of a subsection of a sprite, but there's SpriteAPI.getAverageColor(). And SpriteAPI.setColor().

Speaking of custom skill aptitudes, I don't suppose it's possible to give a skill custom requirements (say, it requires no skill points but the player must have another skill X, and spend N story points)?

Ah, sorry - that'd be fairly involved and also runs into the usual "not used in vanilla so would probably be broken in some way or at some point in time" issues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 25, 2021, 12:56:28 AM
Well, figured as much.

New questions:
- Once a fleet has despawned, is it possible to respawn it? Adding it to a containing location doesn't seem to make it appear.
- Can LocationAPI.createToken tokens be renamed? They still seem to be named "unknown location" after my setName call.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: styrud on December 25, 2021, 04:12:43 AM
I need some help. I'm trying to import parts of the neutrino mods that a mod I've made for myself is dependent on. I've fiddled around a bit but I can't find where the error is hiding. It seems to be the NeutTractorbeamEffect script or something related to it.
I posted the last part of the log where the error seems to be.

Spoiler
299256 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.scripts.weapons.NeutTractorbeamEffect]
java.lang.RuntimeException: Error loading [data.scripts.weapons.NeutTractorbeamEffect]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.scripts.weapons.NeutTractorbeamEffect
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]

Any help would be appreciated. Merry Christmas and a happy new year.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 25, 2021, 08:46:58 AM
New questions:
- Once a fleet has despawned, is it possible to respawn it? Adding it to a containing location doesn't seem to make it appear.

Checked; doesn't look like it. Some stuff is set when a fleet despawns to make it fade out etc and there's no way to reset that.

- Can LocationAPI.createToken tokens be renamed? They still seem to be named "unknown location" after my setName call.

It can't - a large number, the vast majority, really, of the methods for these kinds of tokens are just empty no-op implementations.


Caused by: java.lang.ClassNotFoundException: data.scripts.weapons.NeutTractorbeamEffect
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more[/spoiler]

Any help would be appreciated.

Hmm - that almost sounds like the class defined in that file is not named NeutTractorbeamEffect? It'd help to see the full source of the file it's complaining about.

Merry Christmas and a happy new year.

You too!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: styrud on December 25, 2021, 10:21:30 AM
Hmm - that almost sounds like the class defined in that file is not named NeutTractorbeamEffect? It'd help to see the full source of the file it's complaining about.

Here's the code from the java file.
Spoiler
//by Deathfly
package data.scripts.weapons;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import static data.scripts.util.AdvForce.applyMomentum;
import java.awt.Color;
import org.lwjgl.util.vector.Vector2f;

public class NeutTractorbeamEffect implements BeamEffectPlugin {

    private float coreAlpha = 0;
    private Color coreColor;

    public NeutTractorbeamEffect() {

    }

    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {
        if (engine.isPaused()) {
            return;
        }
        CombatEntityAPI target = beam.getDamageTarget();
        if (target != null && beam.didDamageThisFrame()) {
            target.setMass(target.getMass() + 1000);
            applyMomentum(target, beam.getTo(), Vector2f.sub(beam.getTo(), beam.getFrom(), null), -100, false);
            target.setMass(target.getMass() - 1000);
            coreAlpha = coreAlpha < 1 ? coreAlpha + 0.1f : 1f;
           
        } else {
            coreAlpha = coreAlpha > 0 ? coreAlpha - 0.1f : 0f;
        }
        coreAlpha = coreAlpha < 0 ? 0:coreAlpha;
        coreAlpha = coreAlpha > 1 ? 1:coreAlpha;
        coreColor = new Color((int) (255 * coreAlpha), (int) (255 * coreAlpha), (int) (255 * coreAlpha));
        beam.setCoreColor(coreColor);
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 25, 2021, 10:32:52 AM
Is it in the data/scripts/weapons folder?

Also, I'd try changing:
private float coreAlpha = 0;
To:
private float coreAlpha = 0f;

Janino (the 3rd party java compiler used to compile loose scripts like this) can be really picky about this sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 25, 2021, 10:34:12 AM
Is there a way to retrieve an instance of a constellation's label entity without being provided a SectorMapAPI? The only way to get constellation labels seems to be via SectorMapAPI.getConstellationLabelEntity(), but that doesn't seem to be possible in any context when you'd want to use the new VisualPanelAPI.showMapMarker.

Also, stop working and get back to Christmas, Alex!  :P

It seems to be the NeutTractorbeamEffect script or something related to it.
The error is saying it can't find that script at all. My guess would be you referenced it incorrectly in another file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 25, 2021, 10:45:41 AM
Is there a way to retrieve an instance of a constellation's label entity without being provided a SectorMapAPI? The only way to get constellation labels seems to be via SectorMapAPI.getConstellationLabelEntity(), but that doesn't seem to be possible in any context when you'd want to use the new VisualPanelAPI.showMapMarker.

After a quick check: those are created when the map is created, so they're not permanent entities - so, no.

Also, stop working and get back to Christmas, Alex!  :P

Aye aye :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: styrud on December 25, 2021, 10:50:59 AM
Is it in the data/scripts/weapons folder?

Also, I'd try changing:
private float coreAlpha = 0;
To:
private float coreAlpha = 0f;
Yeah, the file is in src/data/scripts/weapons.
Changing the value to 0f didn't do anything and the error looks identical to the previous one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 25, 2021, 11:11:22 AM
Janino (the 3rd party java compiler used to compile loose scripts like this) can be really picky about this sort of thing.
Oh Janino, I once had it crash because it was trying (and failing) to convert a float... into a float.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on December 25, 2021, 11:17:59 AM
Is there a way to retrieve an instance of a constellation's label entity without being provided a SectorMapAPI? The only way to get constellation labels seems to be via SectorMapAPI.getConstellationLabelEntity(), but that doesn't seem to be possible in any context when you'd want to use the new VisualPanelAPI.showMapMarker.

After a quick check: those are created when the map is created, so they're not permanent entities - so, no.
Ah, gotcha. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 25, 2021, 05:47:32 PM
Is it in the data/scripts/weapons folder?

Also, I'd try changing:
private float coreAlpha = 0;
To:
private float coreAlpha = 0f;
Yeah, the file is in src/data/scripts/weapons.
Changing the value to 0f didn't do anything and the error looks identical to the previous one.
Delete the contents of starsector.log, start the game and run it till it crashes, then post the log.

IIRC if the game fails to load the class (then crashes later because it can't find the said class), it'll write an error earlier in the log.


Hmm, but before that check if the mod has the data.scripts.util.AdvForce class, since the tractor beam class is importing a method from it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: styrud on December 25, 2021, 07:59:49 PM
I've cleared the log and got myself a fresh crash. The new log is linked here since it was too big to post or attach. https://mega.nz/file/Xk4QhZYA#y_gC8Yo7cmHrql7zm3XgrM5jVojUivDU3IF3jsIP3IY
I have a java file called AdvForce in the src/data/scrpts/util folder. I post the contents below.
Spoiler
package data.scripts.util;

import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import org.lazywizard.lazylib.VectorUtils;
import org.lwjgl.util.vector.Vector2f;

public class AdvForce {

    /**
     * Apply momentum to an object.
     *
     * Momentum is multiplied by 100 to avoid requiring ridiculous momentum
     * amounts.
     *
     * @param entity The {@link CombatEntityAPI} to apply the momentum to.
     * @param direction The directional vector of the momentum (this will
     * automatically be normalized).
     * @param pointOfImpact Where the momentum should apply to.
     * @param momentum How much momentum to apply. Unit is how much it takes to
     * modify a 100 weight object's velocity by 1 su/sec.
     */
    public static void applyMomentum(CombatEntityAPI entity, Vector2f pointOfImpact, Vector2f direction, float momentum, boolean elasticCollision) {
        if(entity==null){
            return;
        }
        // Filter out forces without a direction
        if (direction.lengthSquared() == 0) {
            return;
        }
        // Avoid divide-by-zero errors...
        float mass = Math.max(1f, entity.getMass());
        // We should not move stations, right?
        if (entity instanceof ShipAPI) {
            ShipAPI ship = (ShipAPI) entity;
            if (ship.isStation() || (ship.isStationModule() && ship.getParentStation().isStation())) {
                return;
            }
            if (ship.isStationModule() && ship.isShipWithModules()) {
                entity = ship.getParentStation();
                mass = Math.max(1f, ship.getMassWithModules());
            }
        }
        // Momentum is far too weak otherwise
        momentum *= 100f;
        // Doing some vector calculate
        Vector2f BPtoMC = Vector2f.sub(entity.getLocation(), pointOfImpact, null);
        Vector2f forceV = new Vector2f();
        direction.normalise(forceV);
        forceV.scale(momentum);
        // get force vector
        BPtoMC.normalise(BPtoMC);
        // calculate acceleration
        BPtoMC.scale(Vector2f.dot(forceV, BPtoMC) / mass);
        if (elasticCollision) {
            // Apply velocity change
            Vector2f.add(BPtoMC, entity.getVelocity(), entity.getVelocity());
        } else {
            // Apply velocity change
            direction = new Vector2f(forceV);
            direction.scale(1 / mass);
            Vector2f.add(direction, entity.getVelocity(), entity.getVelocity());
        }
        // calculate moment change
        float angularAcc = VectorUtils.getCrossProduct(forceV, BPtoMC) / (0.5f * mass * entity.getCollisionRadius() * entity.getCollisionRadius());
        angularAcc = (float) Math.toDegrees(angularAcc);
        // Apply angular velocity change
        if (elasticCollision) {
            entity.setAngularVelocity(entity.getAngularVelocity() + angularAcc);
        } else {
            entity.setAngularVelocity(entity.getAngularVelocity() - angularAcc);
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 25, 2021, 08:38:18 PM
Hmmm, log indicates the script is loading fine, only for it to not be found later...

At this point it's probably easier to upload the whole mod and I can see what's going wrong when I can. (I have a couple of suspicions, but need to look at the folder to be sure)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: styrud on December 25, 2021, 08:54:17 PM
Here's the mod. Hope you can figure something out.
https://mega.nz/file/7lwATZiL#VJR54FgBIU6a7KsNuMTZZmoxORPhZnZbgjblAM18Jj4
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 26, 2021, 03:04:52 AM
Is it autofitting a ship with modules that can produce crashes, or autofitting a ship's modules?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on December 26, 2021, 03:06:23 AM
Is there a way to just prevent hullmod from being applied on modules without having the module require a built-in hullmod to block this out?

Like ship.getParentStation() would work, but this seems to be null regardless of module status in the refit screen...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 26, 2021, 05:10:49 PM
Here's the mod. Hope you can figure something out.
https://mega.nz/file/7lwATZiL#VJR54FgBIU6a7KsNuMTZZmoxORPhZnZbgjblAM18Jj4
So I looked at it and the issue was what I suspected:

Janino (the game's runtime compiler for Java scripts) only works on scripts in data/scripts and a couple of other directories. Files in src/ need to be compiled using an IDE (which is also recommended for other reasons if you're going to be doing any extensive scripting); you can see how to do that here (https://starsector.fandom.com/wiki/Getting_started_with_mod_programming#Getting_Set_Up_.28IDEs.29).

Anyway I fixed the mod by moving the files in src/data/scripts to data/scripts. After doing this I moved one of the copied-over files from data/shipsystem to data/shipsystems. It loads correctly, at least to the point of getting into the campaign and adding a Styrud ship to the player fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: styrud on December 26, 2021, 11:37:28 PM
Thanks! That's seems to have fixed it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 27, 2021, 12:40:33 PM
How do I make ships fly "above" others, like fighters do?
Is it just hullSize: "Fighter"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on December 27, 2021, 01:25:32 PM
How do I make ships fly "above" others, like fighters do?
Is it just hullSize: "Fighter"?

The short answer would be to set the ship's CollisionClass to be that of a fighter's: ship.setCollisionClass(CollisionClass.FIGHTER);.

The author of Arma Armatura, shoi, made a post back in November on how to make playable fighters (https://fractalsoftworks.com/forum/index.php?topic=22983.msg345376#msg345376).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 27, 2021, 05:00:30 PM
adding onto that, do not give any ship fighter hullsize unless you have workarounds in place to deal with it. Since it wasn't meant to be playable some things wont work otherwise, the biggest of these is causing the game to crash when the ship tries to retreat


Not of a subsection of a sprite, but there's SpriteAPI.getAverageColor(). And SpriteAPI.setColor().


Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Embolism on December 28, 2021, 03:17:49 AM
Minor question.

I've been trying to "fix" Derinkuyu Mining Station by giving it an ore deposit condition in scripts/world/Galatia.java (presumably Galatia's market is defined here instead of campaign/econ due to its market/alignment shifts)... but no matter what I add it just doesn't show up. Adding industries to Derinkuyu works fine, adding industries and conditions to Ancyra (in the same system) works fine, but conditions just won't stick to Derinkuyu.

Any idea why?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 28, 2021, 03:49:04 AM
Try setting that specific condition to surveyed.

Code: java
String token = market.addCondition(Conditions.ORE_MODERATE);
market.getSpecificCondition(token).setSurveyed(true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 28, 2021, 11:06:48 PM
Is there a way to keep the illegal arm dealer event from having certain BPs show up? Would no_sell be enough?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on December 29, 2021, 08:23:52 AM
There's a 'no_dealer' tag just for that. 'Restricted' also blocks it, although that's a much more strict tag in general and will block something from most forms of availability by itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 30, 2021, 09:45:07 PM
Is there a way to force a module to be rendered above the main ship sprite? (and if possible, any weapons on the ship would also be underneath)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on December 31, 2021, 03:13:48 AM
Is there a way to force a module to be rendered above the main ship sprite? (and if possible, any weapons on the ship would also be underneath)
The smaller the hullsize, the higher the render, although to have weapons under too, you'll want the Hull to be a decorative weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 31, 2021, 03:56:43 AM
The smaller the hullsize, the higher the render, although to have weapons under too, you'll want the Hull to be a decorative weapon.
Oh! So that's how it works! Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on December 31, 2021, 05:21:54 AM
Is there a significance to some skills not having the combat officer, admiral or admin flags in skill_data.csv, e.g. Automated Ships and Derelict Contingent?
AFAIK this doesn't affect those skills' availability to NPCs anyway.

(This came up when I added a mechanism for the player to give admiral skills to a specific NPC fleet commander; filtering for isAdmiralSkill() excludes some that would be relevant)


In hub missions, is there a way to enforce spawning entities at a specific Vector2f? e.g. I tried to make this objective spawn 10k units from the star, but sometimes it'll just place itself in some terrain feature like a ring near the star, or a point some distance from the star but clearly not 10k units away:
Code: java
		LocData loc = new LocData(EntityLocationType.HIDDEN_NOT_NEAR_STAR, null, Global.getSector().getCurrentLocation());
loc.loc = new BaseThemeGenerator.EntityLocation();
loc.loc.type = BaseThemeGenerator.LocationType.OUTER_SYSTEM;
loc.loc.location = MathUtils.getPointOnCircumference(system.getCenter().getLocation(),
10000, genRandom.nextFloat() * 360f);

spawnMissionNode(loc);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceDrake on December 31, 2021, 05:23:33 AM
So I asked about this in the discord, but what part of the code actually dictates what derelict ships actually spawn and how?

What I'd like to do is add a bit more variety to the galaxy's derelicts, specifically getting some mod faction ones to appear more regularly (any faction that adds options to pirates or indeps gets theirs to show up, but finding, say, Scalartech or Diable or Imperium derelicts is pretty rare) but I can't seem to find the part of the code that determines discoverable derelict spawning (since that's all done at sector creation and you can cheat and search the save file for what's where right at the start. Does anyone have insight on precisely how it all works, and what file(s) govern that behavior?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 01, 2022, 06:43:32 AM
Is it possible to make a faction know a ship only if they know another?

For instance, say I were to make a Legion (P), is it possible to only have the Pirates know it if they know the Legion (say by being sold a blueprint)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2022, 09:51:37 AM
Is there a significance to some skills not having the combat officer, admiral or admin flags in skill_data.csv, e.g. Automated Ships and Derelict Contingent?
AFAIK this doesn't affect those skills' availability to NPCs anyway.

(This came up when I added a mechanism for the player to give admiral skills to a specific NPC fleet commander; filtering for isAdmiralSkill() excludes some that would be relevant)

Admiral: no.

Admin, combat officer: yes, it's used for spawning officers/admins, among other things.

In hub missions, is there a way to enforce spawning entities at a specific Vector2f? e.g. I tried to make this objective spawn 10k units from the star, but sometimes it'll just place itself in some terrain feature like a ring near the star, or a point some distance from the star but clearly not 10k units away:
Code: java
		LocData loc = new LocData(EntityLocationType.HIDDEN_NOT_NEAR_STAR, null, Global.getSector().getCurrentLocation());
loc.loc = new BaseThemeGenerator.EntityLocation();
loc.loc.type = BaseThemeGenerator.LocationType.OUTER_SYSTEM;
loc.loc.location = MathUtils.getPointOnCircumference(system.getCenter().getLocation(),
10000, genRandom.nextFloat() * 360f);

spawnMissionNode(loc);

Hmm - I'd suggest finding a fixed seed that makes it go wrong and then stepping through with a debugger. Just looking at the code, I'm not sure why it'd do that. One other quick-ish thing you might try is setting loc.loc.orbit = null.


So I asked about this in the discord, but what part of the code actually dictates what derelict ships actually spawn and how?

What I'd like to do is add a bit more variety to the galaxy's derelicts, specifically getting some mod faction ones to appear more regularly (any faction that adds options to pirates or indeps gets theirs to show up, but finding, say, Scalartech or Diable or Imperium derelicts is pretty rare) but I can't seem to find the part of the code that determines discoverable derelict spawning (since that's all done at sector creation and you can cheat and search the save file for what's where right at the start. Does anyone have insight on precisely how it all works, and what file(s) govern that behavior?

See: the getNearbyFactions() methods in SalvageSpecialAssigner, and where they are called from. Unfortunately, this isn't exactly easy to influence; best bet for a mod to do this would I think be a final pass over the derelicts, replacing some of them, or just adding a bunch of new ones - something like that.


Is it possible to make a faction know a ship only if they know another?

For instance, say I were to make a Legion (P), is it possible to only have the Pirates know it if they know the Legion (say by being sold a blueprint)?

Yeah - you'd have to have some kind of script that checks this and makes the other hull available/unavailable as needed. Preferably not doing the check every frame but in some kind of callback (say, on player market interaction, or just on a timer, or some such).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sphr on January 02, 2022, 04:48:51 AM
re: Broken hull mods


I was working on some hullmods which were working.
Then I did some refactoring of the code and suddenly in game, these mods can be seen as available (inthe add mod list) but when I click on them, nothing happened.  They are still shown on the list as able to be installed, but they are not installed.

I was wondering what I might have accidentally changed that broke this and hope that somebody may be able to give me some hints.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 02, 2022, 03:41:18 PM
How do I initialise a ShipAPI? My IED says that this doesn't do it, so I am at a loss.
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class YunruShieldModule extends BaseHullMod {
   
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        ShipAPI ship;
        float yunruAdultFluxBase = ship.getParentStation().getMutableStats().getFluxCapacity().getBaseValue();
        float yunruAdultFluxEnd = ship.getParentStation().getMutableStats().getFluxCapacity().getModifiedValue();
        float yunruAdultFluxMult = yunruAdultFluxEnd/yunruAdultFluxBase;
        stats.getFluxCapacity().modifyMult(id,yunruAdultFluxMult);
    }

}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 02, 2022, 05:02:22 PM
Gonna have to figure out the use of a debugger for that mission objective bug.
(I should mention that it can be reproduced easily, by having a static method in the mission class that creates the location in the player's current system, and calling that using console)

New question: Is there a way to make an NPC fleet always have its transponder on, other than setting it every frame?
I noticed that FleetAIFlags.WANTS_TRANSPONDER_ON isn't used anywhere (it's read but never used in the Go Dark AI, and doesn't occur at all in the transponder AI)
Hmm, I could tag the fleet as a patrol or trader, hopefully that has no funny effects...

How do I initialise a ShipAPI? My IED says that this doesn't do it, so I am at a loss.
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class YunruShieldModule extends BaseHullMod {
   
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        ShipAPI ship;
        float yunruAdultFluxBase = ship.getParentStation().getMutableStats().getFluxCapacity().getBaseValue();
        float yunruAdultFluxEnd = ship.getParentStation().getMutableStats().getFluxCapacity().getModifiedValue();
        float yunruAdultFluxMult = yunruAdultFluxEnd/yunruAdultFluxBase;
        stats.getFluxCapacity().modifyMult(id,yunruAdultFluxMult);
    }

}
Yeah, the code is basically neither creating a ShipAPI nor getting an existing one, that's not gonna work...

(Look at the method name for why you're never going to get a ShipAPI from inside there. The method you want is applyEffectsAfterShipCreation(ShipAPI ship, String id) which passes the needed ShipAPI in the args)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2022, 05:25:48 PM
re: Broken hull mods


I was working on some hullmods which were working.
Then I did some refactoring of the code and suddenly in game, these mods can be seen as available (inthe add mod list) but when I click on them, nothing happened.  They are still shown on the list as able to be installed, but they are not installed.

I was wondering what I might have accidentally changed that broke this and hope that somebody may be able to give me some hints.

Sorry, that's a bit too vague, it's hard to say. Maybe something to do with whether the hullmod is applicable to the ship? If e.g. isApplicableToShip() starts returning false when the mod is added, that might cause it to be insta-removed, for example.


Gonna have to figure out the use of a debugger for that mission objective bug.
(I should mention that it can be reproduced easily, by having a static method in the mission class that creates the location in the player's current system, and calling that using console)

If you can paste me some code that reliably (or at least relatively reliably) does this, I should hopefully be able to take a look!

New question: Is there a way to make an NPC fleet always have its transponder on, other than setting it every frame?
I noticed that FleetAIFlags.WANTS_TRANSPONDER_ON isn't used anywhere (it's read but never used in the Go Dark AI, and doesn't occur at all in the transponder AI)
Hmm, I could tag the fleet as a patrol or trader, hopefully that has no funny effects...

Cleanest way is probably via a custom ability AI by returning it for that fleet only, using CampaignPlugin.pickAbilityAI().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 02, 2022, 06:03:39 PM
Gonna have to figure out the use of a debugger for that mission objective bug.
(I should mention that it can be reproduced easily, by having a static method in the mission class that creates the location in the player's current system, and calling that using console)
If you can paste me some code that reliably (or at least relatively reliably) does this, I should hopefully be able to take a look!
Accept a contact mission, then while still in the convo with the contact, run the following code one or more times (replacing the mission ref memory key with the appropriate one for the accepted mission):

Code: java
	/* runcode exerelin.TestScript.debugMission(); */
public static void debugMission() {
HubMissionWithTriggers mission = (HubMissionWithTriggers)Global.getSector().getCampaignUI().
getCurrentInteractionDialog().getInteractionTarget().getActivePerson().getMemoryWithoutUpdate().get("$my_mission_ref");
debugMission(mission);
}

public static void debugMission(HubMissionWithTriggers mission) {
BaseHubMission.LocData loc = new BaseHubMission.LocData(BaseHubMission.EntityLocationType.HIDDEN_NOT_NEAR_STAR, null, Global.getSector().getCurrentLocation());
loc.loc = new BaseThemeGenerator.EntityLocation();
loc.loc.type = BaseThemeGenerator.LocationType.OUTER_SYSTEM;
loc.loc.location = new Vector2f(10000, 10000);
loc.loc.orbit = null;

Misc.makeImportant(mission.spawnMissionNode(loc), "test");
}
(did my test with an extraction mission from Rayan Arroyo)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sphr on January 02, 2022, 08:05:18 PM
Sorry, that's a bit too vague, it's hard to say. Maybe something to do with whether the hullmod is applicable to the ship? If e.g. isApplicableToShip() starts returning false when the mod is added, that might cause it to be insta-removed, for example.

Thanks! That actually gave me enough hints.  I was under the impression that isApplicableToShip is only called before the mod is applied.  I was trying to make mods that excludes each other (known as a set), so isApplicableToShip will return false if any one of them is installed.  But apparently, due to the unknown behavior, the ship will be applicable before applying a mod from the set, but once installed, its own presence will cause isApplicableToShip to fail immediately (thus removing itself).

I've actually created another thread on this problem.  Will document the behavior and findings there, in case anybody tries to search for this again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sphr on January 02, 2022, 09:21:39 PM
Sorry to add another post.  different issue.

I've tried to search for this but didn't find any relevant hits.

re: Mandatory/Required fields in json data files

Is there a guide to the json data file (such as wpn) on which fields are mandatory vs which fields are optional?

What I am trying to do is to create the following 2 types of "weapons"

1. purely decorative, no function, 2 possible subversions being can/cannot be damaged/destroyed
2. invisible, runs an effects script, cannot be damaged/destroyed

While finding tutorials/examples that are similar that works isn't that difficult, one thing is usually omitted: whether a property is mandatory or optional or when it must be defined if using for certain purposes (possibly including interpretation by modlibs), I am looking for the minimal set properties needed, including mandatory ones, that can be used for the above-mentioned purposes (instead of simply voodoo-copying from another weapon that works, but in a way propagate that inappropriate voodoo "knowledge")

Any links to the info/guide will be greatly appreciated
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 02, 2022, 11:15:16 PM
Is there a way to disable a weapon or simply stop it from being fireable via code outside of setting its cooldown to a number every frame?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 03, 2022, 04:09:54 AM
The code that actually reads the jsons is hidden and Alex doesn't maintain documentation on the jsons for us to use. You can suss out the required fields through trial and error, but knowing all the optional fields requires voodoo.

Edit: The only json I have seen perfectly documented is .skin, because Alex shared the IO code and I made a doc from it. At that time there were only 2 required fields and 29 optional fields for ship skins.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 03, 2022, 05:10:58 AM
Speaking of ship skins... is there a way to add them to the known ships for factions...?

Code
    @Override
    public void onGameLoad(boolean newGame) {
Global.getSector().getFaction("hegemony").getKnownShips().add("legion_xiv");
Global.getSector().getFaction("hegemony").clearShipRoleCache();
    }
@Override
    public void onApplicationLoad() throws JSONException, IOException {
            if (Global.getSettings().getHullSpec("legion_xiv") != null) {Global.getSettings().getHullSpec("legion_xiv").addTag("XIV_bp");}
Global.getSector().getFaction("hegemony").clearShipRoleCache();
}

I tried to use this to test something on game load that it would use the blueprint but it doesn't seem to use it at all.

Never mind, I was adding the legion_xiv to the xiv_bp's spec via code and assumed first then it would be applied the same to the known faction xD. never mind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 03, 2022, 09:41:49 AM
A problem I ran into recently, is that the missile Autoforge will crash if you have over 100 mounts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 04, 2022, 06:59:05 PM
(https://i.imgur.com/9SWy7zq.png)
(https://i.imgur.com/oB1rcNg.png)

So we're trying out fighter modules and weapons don't seem to want to render over the fighter modules here.. is there a specific way to make weapons of the main ship render over module?

We tried some things like large RenderOrderMod, negative RenderOrderMod, really small decimals and tried changing types or are we out of luck here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 04, 2022, 08:14:58 PM
Is there a way to disable a weapon or simply stop it from being fireable via code outside of setting its cooldown to a number every frame?

Offhand, I don't think so, but maybe I'm forgetting something.


A problem I ran into recently, is that the missile Autoforge will crash if you have over 100 mounts.

Hmm, really? Offhand I'm not seeing how it would. Which one is it - one of the ship systems, or the hullmod?

So we're trying out fighter modules and weapons don't seem to want to render over the fighter modules here.. is there a specific way to make weapons of the main ship render over module?

We tried some things like large RenderOrderMod, negative RenderOrderMod, really small decimals and tried changing types or are we out of luck here?

Pretty much - all the things you've tried affect render order within a ship. But modules are separate ship and their order is based on 1) hull size and 2) if that's tied, the order they were added to the engine. Using a fighter-sized module - I'm guessing you have a reason for it? But one of the primary effects would in fact be it rendering above the other stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 05, 2022, 02:50:56 AM
Hmm, really? Offhand I'm not seeing how it would. Which one is it - one of the ship systems, or the hullmod?
It was a ship system. Lowering the amount of mounts fixed the issue, although I can probably recreate it if interested.

Edit: Specifically, it was Missile Autoforge on F, and Burn Drive on Right Click.
Burn Drive doesn't seem to play nice with any right click system (tested with Temporal Shell and Missile Autoforge (ironically enough another Burn Drive is fine)), whether it's on right click or not.

Here's a similar error (although with a different system in place of Missile Autoforge):
Code
68384 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: temporalshell]
java.lang.RuntimeException: temporalshell]
    at com.fs.starfarer.loading.specs.oO0O.createSystemAI(Unknown Source)
    at com.fs.starfarer.combat.ai.BasicShipAI.<init>(Unknown Source)
    at com.fs.starfarer.combat.ai.BasicShipAI.<init>(Unknown Source)
    at com.fs.starfarer.launcher.ModManager.pickShipAIPlugin(Unknown Source)
    at com.fs.starfarer.combat.CombatState.setAutopilot(Unknown Source)
    at com.fs.starfarer.combat.tasks.CombatTaskManager.giveDirectOrder(Unknown Source)
    at com.fs.starfarer.combat.OoOO.A.rightClickReleased(Unknown Source)
    at com.fs.starfarer.combat.OoOO.o0ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
    at com.fs.starfarer.ui.V.o00000(Unknown Source)
    at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
    at com.fs.state.AppDriver.begin(Unknown Source)
    at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
    at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: com.fs.starfarer.combat.systems.O00O cannot be cast to com.fs.starfarer.combat.systems.do
    at com.fs.starfarer.combat.ai.system.A.<init>(Unknown Source)
    ... 15 more
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 05, 2022, 03:42:43 AM
In hub missions, is there a way to enforce spawning entities at a specific Vector2f? e.g. I tried to make this objective spawn 10k units from the star, but sometimes it'll just place itself in some terrain feature like a ring near the star, or a point some distance from the star but clearly not 10k units away:
Code: java
		LocData loc = new LocData(EntityLocationType.HIDDEN_NOT_NEAR_STAR, null, Global.getSector().getCurrentLocation());
loc.loc = new BaseThemeGenerator.EntityLocation();
loc.loc.type = BaseThemeGenerator.LocationType.OUTER_SYSTEM;
loc.loc.location = MathUtils.getPointOnCircumference(system.getCenter().getLocation(),
10000, genRandom.nextFloat() * 360f);

spawnMissionNode(loc);

Hmm - I'd suggest finding a fixed seed that makes it go wrong and then stepping through with a debugger. Just looking at the code, I'm not sure why it'd do that. One other quick-ish thing you might try is setting loc.loc.orbit = null.
Update: Went through it with a debugger. What I'm fairly sure is happening is that when the LocData has an EntityLocationType specified, using it in a BaseMissionHub.spawnEntity call causes the LocData to recompute its own position (due to LocData.updateLocIfNeeded being called).

I'm now creating my own EntityLocation and passing it in the LocData constructor (and setting the subsequent mission node's orbit manually).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BeyondTheHorizon on January 05, 2022, 05:27:33 AM
I found .didDamage(), getDamagedAlready() and getDamagedTarget() for missile in <MissileAPI> always return false or null even when a missile directly hit a ship with no shield. Is this a bug? Or they will only be true or register damaged targets on a specific occasion?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CoreWolff on January 05, 2022, 05:52:48 AM
Hi,

So I've got a question on modifying your fleets maintenance supply upkeep cost.

It looks like the skill that applies this - MakeshiftEquipment - uses MutableStat "getSuppliesPerMonth()" and then uses modifyMult to change that.

Then from searching around it looks like people have had success doing the same with a hullmod, either as one you can install yourself, or a built-in hidden mod and applying to ship hulls.

Would there be a way to apply that to every ship in your fleet, say as a temporary modifier when you load a game? I was attempting to make a simple mod with a settings file to allow to configure a bonus supply or fuel usage reduction.


Some values e.g. the amount of salvage you get can be adjusted fleet-wide by applying:
stat.getDynamic().getStat(Stats.FUEL_SALVAGE_VALUE_MULT_FLEET).modifyFlat(id, float);

There is a stat "SUPPLY_BONUS_MOD" but unsure what that does?
The same for fuel, there's a stat "FUEL_SUPPLY_BONUS_MOD"?

For getSuppliesPerMonth() that seems to be per ship, and the skill modifies the value for each ship in the fleet individually. But trying to do the same outside of a skill doesn't seem to work? e.g.

  for (FleetMemberAPI ship : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
        String id = "supply_reduction";
        MutableShipStatsAPI stats = ship.getStats();
        float useMult = 0.5f;
        stats.getSuppliesPerMonth().modifyMult(id, useMult);
  }
 
Am I missing something or is it only possible via hullmods or skills to amend this?

Any help is appreciated!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 05, 2022, 11:46:46 AM
Burn Drive doesn't seem to play nice with any right click system (tested with Temporal Shell and Missile Autoforge (ironically enough another Burn Drive is fine)), whether it's on right click or not.

That makes sense, most vanilla system AIs will not handle the system being on right-click. I might end up updating them at some point. The reason it works with another burn drive is that the right-click AI picks up the "regular system" burn drive, so it wouldn't really work either. For example, I think it would not try to use it while the other burn drive was on cooldown, etc.

Update: Went through it with a debugger. What I'm fairly sure is happening is that when the LocData has an EntityLocationType specified, using it in a BaseMissionHub.spawnEntity call causes the LocData to recompute its own position (due to LocData.updateLocIfNeeded being called).

I'm now creating my own EntityLocation and passing it in the LocData constructor (and setting the subsequent mission node's orbit manually).

Ahh, that tracks. Thank you for the update!


I found .didDamage(), getDamagedAlready() and getDamagedTarget() for missile in <MissileAPI> always return false or null even when a missile directly hit a ship with no shield. Is this a bug? Or they will only be true or register damaged targets on a specific occasion?

Hmm, I'm reasonably (like, 99%) certain that this isn't actually true. It's hard to see how this could happen, and besides, stuff in vanilla code depends on these methods working properly.


Some values e.g. the amount of salvage you get can be adjusted fleet-wide by applying:
stat.getDynamic().getStat(Stats.FUEL_SALVAGE_VALUE_MULT_FLEET).modifyFlat(id, float);

There is a stat "SUPPLY_BONUS_MOD" but unsure what that does?
The same for fuel, there's a stat "FUEL_SUPPLY_BONUS_MOD"?

These are unrelated - you can check where they're used to see what they do. (They're for colony production.)

For getSuppliesPerMonth() that seems to be per ship, and the skill modifies the value for each ship in the fleet individually. But trying to do the same outside of a skill doesn't seem to work? e.g.
... 
Am I missing something or is it only possible via hullmods or skills to amend this?

Any help is appreciated!

Right; a fleet member's stats are recreated from scratch quite often, with all the modifiers applied anew. You can apply remporary modifiers using FleetMemberAPI.getBuffManager(). See the CRRecoveryBuff class for an example of a temporary buff that modifies a fleet member's stat. "Buff" is a misnomer, it's really any kind of modifier, btw.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CoreWolff on January 05, 2022, 12:25:44 PM

Some values e.g. the amount of salvage you get can be adjusted fleet-wide by applying:
stat.getDynamic().getStat(Stats.FUEL_SALVAGE_VALUE_MULT_FLEET).modifyFlat(id, float);

There is a stat "SUPPLY_BONUS_MOD" but unsure what that does?
The same for fuel, there's a stat "FUEL_SUPPLY_BONUS_MOD"?

These are unrelated - you can check where they're used to see what they do. (They're for colony production.)

For getSuppliesPerMonth() that seems to be per ship, and the skill modifies the value for each ship in the fleet individually. But trying to do the same outside of a skill doesn't seem to work? e.g.
... 
Am I missing something or is it only possible via hullmods or skills to amend this?

Any help is appreciated!

Right; a fleet member's stats are recreated from scratch quite often, with all the modifiers applied anew. You can apply remporary modifiers using FleetMemberAPI.getBuffManager(). See the CRRecoveryBuff class for an example of a temporary buff that modifies a fleet member's stat. "Buff" is a misnomer, it's really any kind of modifier, btw.

Okay, awesome, I'll take a look at that thank you. I did suspect they're recreated often due to fleet composition changes and refitting etc, but wasn't sure where to look next.

On a side note love the changes in the latest update, will have to buy another copy of the game when it releases on v1.0 one day :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 05, 2022, 01:11:09 PM
On a side note love the changes in the latest update, will have to buy another copy of the game when it releases on v1.0 one day :)

Thank you! And, I super appreciate the thought/intent :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 06, 2022, 10:35:32 AM
Is the a way, via running a script, to change a ship's weighting default_ship_roles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sphr on January 06, 2022, 09:40:18 PM
Was experimenting into "animated" ships and have several questions.
Only did a quick search to see if there were relevant topics but could not seem to find any, so pls pardon me (and link me to the relevant resource) if they have already been answered.


1. Is it possible to change slot positions during combat?  Due to animation, there are states where slots will appear strange in their original positions.  It would be best if the slots can be updated.  If this is possible, are other slot stats (those defined in ship data) changeable dynamically as well? (i.e. not changing the variant in before ship creation, but rather on a ship that has already been created and is active in combat)

2. If previous is not possible, is it possible to change ship weapons during combat?  One trick I thought of to implement the above is to simply have 2 sets of fixed weapon slots, then simply "move" the weapon between the slots where necessary.

3. Must the "origin" of weapons fixed at the center of the sprite?  I was wondering if I can reduce the image size of some weapons where it is very unbalanced in the actual area being used vs the areas with nothing.

4. Is it possible to make a weapon slot that "scales" the sprite of the weapon being fitted?  use case is some weapon sprites being too big default-size (relative to the particular ship).

5. Is there a comprehensive guide to the exact render order of weapons wrt other decorative/built-in parts.  I have been getting along with voodoo on the renderModOrder and types/sizes of weapons but I still do not know how it works exactly and rely on time-inefficient experimentation to find out how things looks.  This is especially hard if there are many parts on the ship.

EDIT:
added:

6. Is it possible to move/turn off engine effects (the exhaust/trail etc) dynamically (java) during combat?

tia.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IGdood on January 07, 2022, 10:41:35 AM
How do I edit the frequency of a mod's ships showing up in a fleet or market? 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on January 07, 2022, 01:12:57 PM
Interesting, its possible to tell ship AI to use missile weapon for targeting? I did broadside ship with builtin Hammer Barrages on sides, but I found AI issue with it, when weapon type is MISSILE ship never turns their weapon towards the enemy, targeting AI just excludes Large Missiles from consideration, I found hacky way to make ship aim and fire its missiles, I made another builtin variant of Hammer Barrage with DO_NOT_CONSERVE flag and Ballistic weapon type, its makes ship actually attack the enemy but have own drawback, now weapon benefit from Ballistic Weapon skill\hullmod bonuses, not Missile ones, so its not good option too, another one, make invisible ballistic\energy weapon with zero damage just to make ship AI turn, but still, I didn't tried yet, but I see several issues with it too.

Interesting, its possible to teach AI to aim with Missile weapons without dirty hacks? This AI issue actually affect vanilla ships too, like Apogee side mound or Guardian Large Missiles which placed on sides, and ship itself is wide, since AI never aim these weapons, these ships almost never use non-homing missile weapons on wide or side mounts, they are properly used by AI only if mounts are looks forward.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 07, 2022, 03:34:51 PM
Is there some way to distinguish assigments or give them a unique id?

I am giving ship assignment to move to a waypoint I created. To prevent these waypoints from cloggin up the command UI, I do this:
Quote
               if(ctm.getAssignmentFor(ship) != null && ctm.getAssignmentFor(ship).getType() == CombatAssignmentType.RALLY_TASK_FORCE)
                  ctm.removeAssignment(ctm.getAssignmentFor(ship));
For some reason this also remove engage/defend/ and other orders, but does not affect ships who have been put on Search & Destroy. Any idea why that is? I would think it wouldn't since those assignments have their own enums...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 07, 2022, 09:36:36 PM
How do I edit the frequency of a mod's ships showing up in a fleet or market?
hullFrequency table in the .faction file (look at hegemony.faction for an example)

To affect all factions at once, you can edit the variant frequencies in data/world/factions/default_ship_roles.json.

Also note that if a ship is in a faction's priorityShips table, it'll use that ship to the near-exclusion of all other ships in the same role

This suggestion thread (https://fractalsoftworks.com/forum/index.php?topic=15540.0) has some info
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SOLDIER First on January 08, 2022, 01:56:55 PM
Is there a way to modify getImproveStoryPoints() from BaseIndustry that would play nice with other mods? I'd like to change the way the story point cost is calculated, but talk on the Discord suggests that there's no way to do this without manually replacing the classes for every single industry, and that's not exactly a compatible method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 08, 2022, 06:20:39 PM
When I wanted to add officer skills in the campaign missions...
Spoiler
package data.missions.eis_queens;

import java.util.List;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.impl.campaign.ids.Skills;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.characters.FullName;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.fleet.FleetGoal;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.mission.FleetSide;
import com.fs.starfarer.api.mission.MissionDefinitionAPI;
import com.fs.starfarer.api.mission.MissionDefinitionPlugin;

//You wouldn't just edit the file to make this mission easier wouldn't you?

public class MissionDefinition implements MissionDefinitionPlugin {
   
   protected boolean campaignMode;

   public void defineMission(MissionDefinitionAPI api) {

      // Set up the fleets
      api.initFleet(FleetSide.PLAYER, "HSS", FleetGoal.ATTACK, false, 1);
      api.initFleet(FleetSide.ENEMY, "TTS", FleetGoal.ATTACK, true, 10);

      // Set a blurb for each fleet
      api.setFleetTagline(FleetSide.PLAYER, "The HSS Bond accompanied by patrol ships");
      api.setFleetTagline(FleetSide.ENEMY, "Tri-Tachyon mercenary detachment");
      
      // These show up as items in the bulleted list under
      // "Tactical Objectives" on the mission detail screen
      api.addBriefingItem("Ava has the following skills: Combat Endurance (Elite), Helmsmanship, Iron Heritage, and Support");
      api.addBriefingItem("Doctrine. The HSS Bond has Zandatsu which gains a buff when reflecting a missile.");
      api.addBriefingItem("Defeat all enemy forces. HSS Bond must survive.");
      api.addBriefingItem("Completing this mission grants you the Valorous Bond in the Nexerelin's agent start.");
      
      if (!campaignMode) {
         // Set up the player's fleet
         FleetMemberAPI member = api.addToFleet(FleetSide.PLAYER, "eis_valorous_bond", FleetMemberType.SHIP, "HSS Bond", true);
         PersonAPI coffeemom = Global.getSector().getFaction("ironshell").createRandomPerson(FullName.Gender.FEMALE);
         coffeemom.setId("eisava_mission1");
         coffeemom.getName().setFirst("Ava");
         coffeemom.getName().setLast("Nitia");
         coffeemom.getName().setGender(FullName.Gender.FEMALE);
         coffeemom.setPersonality("aggressive");
         coffeemom.setPortraitSprite("graphics/portraits/eis_ava.png");
         coffeemom.setFaction("hegemony");
         coffeemom.getStats().setSkillLevel(Skills.HELMSMANSHIP, 1);
         coffeemom.getStats().setSkillLevel(Skills.COMBAT_ENDURANCE, 3);
         coffeemom.getStats().setSkillLevel(Skills.SUPPORT_DOCTRINE, 1);
         coffeemom.getStats().setSkillLevel("eis_xiv", 1);
         coffeemom.getMemoryWithoutUpdate().set("$chatterChar", "eis_ava");
         coffeemom.getStats().setLevel(3);
         member.setCaptain(coffeemom);
            float maxCR = member.getRepairTracker().getMaxCR();
            member.getRepairTracker().setCR(maxCR);
         
         FleetMemberAPI member2 = api.addToFleet(FleetSide.PLAYER, "eis_courageous_elite", FleetMemberType.SHIP, false);
         member2.getRepairTracker().setCR(member2.getRepairTracker().getMaxCR());
         //member2.setAlly(true);
         FleetMemberAPI member3 = api.addToFleet(FleetSide.PLAYER, "eis_courageous_elite", FleetMemberType.SHIP, false);
         member3.getRepairTracker().setCR(member3.getRepairTracker().getMaxCR());
         //member3.setAlly(true);
         FleetMemberAPI member4 = api.addToFleet(FleetSide.PLAYER, "eis_courageous_elite", FleetMemberType.SHIP, false);
         member4.getRepairTracker().setCR(member4.getRepairTracker().getMaxCR());
         //member4.setAlly(true);
         FleetMemberAPI member5 = api.addToFleet(FleetSide.PLAYER, "eis_courageous_elite", FleetMemberType.SHIP, false);
         member5.getRepairTracker().setCR(member5.getRepairTracker().getMaxCR());
         //member5.setAlly(true);
         
         // Mark player flagship as essential
         api.defeatOnShipLoss("HSS Bond");
         
         // Set up the enemy fleet.
         api.addToFleet(FleetSide.ENEMY, "odyssey_Balanced", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "medusa_Attack", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "medusa_PD", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "sunder_CS", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "sunder_Assault", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "wolf_CS", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "wolf_Assault", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "tempest_Attack", FleetMemberType.SHIP, false);
         //api.addToFleet(FleetSide.ENEMY, "tempest_Attack", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "tempest_Attack", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "lasher_CS", FleetMemberType.SHIP, false);
         api.addToFleet(FleetSide.ENEMY, "lasher_Assault", FleetMemberType.SHIP, false);
      }
      // Set up the map.
      float width = 24000f;
      float height = 18000f;
      api.initMap((float)-width/2f, (float)width/2f, (float)-height/2f, (float)height/2f);
      
      float minX = -width/2;
      float minY = -height/2;
      
      for (int i = 0; i < 15; i++) {
         float x = (float) Math.random() * width - width/2;
         float y = (float) Math.random() * height - height/2;
         float radius = 100f + (float) Math.random() * 900f;
         api.addNebula(x, y, radius);
      }
      
      api.addNebula(minX + width * 0.8f - 1000, minY + height * 0.4f, 2000);
      api.addNebula(minX + width * 0.8f - 1000, minY + height * 0.5f, 2000);
      api.addNebula(minX + width * 0.8f - 1000, minY + height * 0.6f, 2000);
      
      api.addObjective(minX + width * 0.8f - 1000, minY + height * 0.4f, "sensor_array");
      api.addObjective(minX + width * 0.7f - 1000, minY + height * 0.6f, "nav_buoy");
      api.addObjective(minX + width * 0.4f + 1000, minY + height * 0.3f, "sensor_array");
      api.addObjective(minX + width * 0.5f, minY + height * 0.5f, "nav_buoy");
      //api.addObjective(minX + width * 0.2f + 1000, minY + height * 0.5f, "sensor_array");
      
      api.addAsteroidField(minX, minY + height / 2, 0, 8000f,
                      20f, 70f, 100);
   }

    public void setCampaignMode(boolean mode) {
        campaignMode = mode;
    }
   
}
[close]

Code
float maxCR = member.getRepairTracker().getMaxCR();
            member.getRepairTracker().setCR(maxCR);

I used this code to make it give the proper CR to everyone with Combat Endurance in missions. However, despite this, every officer and commander seems to get every skill effect except Support Doctrine never mind just had to find out I needed the commander to have it which then made it work very well. just fine so far. Did something change in the Combat Endurance or missions that every ship always get 70% CR?

I remember in previous versions this used to work...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on January 09, 2022, 08:43:43 AM
im having an odd error that i cant track down
ctd at start of loading screen with error message:
           Fatal: No enum constant
           com.fs.starfarer.api.combat.WeaponAPI.AIHints.RESET_BARREL_INDEX_ON_BURST

it says to check the log but there is no error message there
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IGdood on January 09, 2022, 10:48:47 AM
How do I edit the frequency of a mod's ships showing up in a fleet or market?
hullFrequency table in the .faction file (look at hegemony.faction for an example)

To affect all factions at once, you can edit the variant frequencies in data/world/factions/default_ship_roles.json.

Also note that if a ship is in a faction's priorityShips table, it'll use that ship to the near-exclusion of all other ships in the same role

This suggestion thread (https://fractalsoftworks.com/forum/index.php?topic=15540.0) has some info

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on January 09, 2022, 01:24:59 PM
im having an odd error that i cant track down
ctd at start of loading screen with error message:
           Fatal: No enum constant
           com.fs.starfarer.api.combat.WeaponAPI.AIHints.RESET_BARREL_INDEX_ON_BURST

it says to check the log but there is no error message there

Update Starsector, ideally to RC6. This was added in RC4.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sphr on January 09, 2022, 07:30:18 PM
Can anybody help to confirm on how SpriteAPI works?
wrt Center, Height/Width and Angle

I am guessing the following:
- Height/width originally same as the image file used as texture
- Center started out as half of height/width
- angle started out 0
- visible texture for sprite is scaled(change actual height/width wrt image), then translated( changed center), before applying rotation around center (angle)?


EDIT:
another issue:
Effect object is probably only associated with one ShipAPI, but what about things like hullmods which are objects that exists before ships.  Do all ships share the same hull mod instance or is there a unique hullmod instance (of a class) for each applicable ship/fleet member variant.

Basically, trying to figure out whether it is "safe" to store properties specific to a ship in such classes/objects (as opposed to the same object possibly used for all applicable ship)


tia


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 10, 2022, 06:44:23 AM
Is there a way to make a ship never go backwards (stopping, and stationary turning, is fine, just no reverse)?

Edit: Also is there some sort of way to prevent a weapon from firing (/do weapons fire) if they lack enough ammo for a full burst?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AdmiralRem on January 10, 2022, 06:51:25 AM
Are there standard sprite sizes and or canvas sizes for weapons in the hard point and turret categories? I noticed in mods they have 2 of each weapon and they are consistently offset and I’m wondering if there are specifics to this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sphr on January 10, 2022, 07:19:39 AM
RE: How to tell if a weapon (WeaponAPI) is point defense?

There seens to be methods to set the value (setPD()), but there isn't one that reads the current value? (e.g. isPD())?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 10, 2022, 12:17:02 PM
1. Is it possible to change slot positions during combat?  Due to animation, there are states where slots will appear strange in their original positions.  It would be best if the slots can be updated.  If this is possible, are other slot stats (those defined in ship data) changeable dynamically as well? (i.e. not changing the variant in before ship creation, but rather on a ship that has already been created and is active in combat)

2. If previous is not possible, is it possible to change ship weapons during combat?  One trick I thought of to implement the above is to simply have 2 sets of fixed weapon slots, then simply "move" the weapon between the slots where necessary.

I don't believe so.

3. Must the "origin" of weapons fixed at the center of the sprite?  I was wondering if I can reduce the image size of some weapons where it is very unbalanced in the actual area being used vs the areas with nothing.

It's the center for turrets, and the center of the lower half for hardpoints.

4. Is it possible to make a weapon slot that "scales" the sprite of the weapon being fitted?  use case is some weapon sprites being too big default-size (relative to the particular ship).

It's not.

5. Is there a comprehensive guide to the exact render order of weapons wrt other decorative/built-in parts.  I have been getting along with voodoo on the renderModOrder and types/sizes of weapons but I still do not know how it works exactly and rely on time-inefficient experimentation to find out how things looks.  This is especially hard if there are many parts on the ship.

I don't think so. But basically: larger stuff gets rendered later. Hardpoints get rendered before turrets. Missiles get rendered before other weapon types of the same size and mount type. And the render order modifier per slot can override all of that if it's large enough.

6. Is it possible to move/turn off engine effects (the exhaust/trail etc) dynamically (java) during combat?

I don't believe so.


Interesting, its possible to tell ship AI to use missile weapon for targeting? I did broadside ship with builtin Hammer Barrages on sides, but I found AI issue with it, when weapon type is MISSILE ship never turns their weapon towards the enemy, targeting AI just excludes Large Missiles from consideration, I found hacky way to make ship aim and fire its missiles, I made another builtin variant of Hammer Barrage with DO_NOT_CONSERVE flag and Ballistic weapon type, its makes ship actually attack the enemy but have own drawback, now weapon benefit from Ballistic Weapon skill\hullmod bonuses, not Missile ones, so its not good option too, another one, make invisible ballistic\energy weapon with zero damage just to make ship AI turn, but still, I didn't tried yet, but I see several issues with it too.

Interesting, its possible to teach AI to aim with Missile weapons without dirty hacks? This AI issue actually affect vanilla ships too, like Apogee side mound or Guardian Large Missiles which placed on sides, and ship itself is wide, since AI never aim these weapons, these ships almost never use non-homing missile weapons on wide or side mounts, they are properly used by AI only if mounts are looks forward.

Hmm, I don't think it's possible. I might be able to have a look at some point; offhand I'd think weapons like Annihilator Pods for example would work as broadside weapons, but based on what you're saying it sounds like this isn't the case?

I don't think the Apogee is affected, btw, since it only has one large off-angle mount and so would not consider itself a broadside ship regardless. The Guardian, well, it's not available to the player and its fits have guided missiles in those slots for a reason :) It indeed doesn't handle Hammers in those slots well - but that seems like a different concern, in that case it's more about just those slots being too far off-center so the aim is never good (and it's not aware that e.g. the hammers have enough spread to where it's fine anyway).

Actually, this would be a good thing to make sure of: your "broadside" ship, does it actually have more firepower in its broadsides than facing front? Because e.g. if you've got less firepower on the sides, it's just never going to do an "occasionaly face sideway to fire it" thing. The actual broadside firepower needs to be higher than what it can bring to bear on the front.


Is there some way to distinguish assigments or give them a unique id?

I am giving ship assignment to move to a waypoint I created. To prevent these waypoints from cloggin up the command UI, I do this:
Quote
               if(ctm.getAssignmentFor(ship) != null && ctm.getAssignmentFor(ship).getType() == CombatAssignmentType.RALLY_TASK_FORCE)
                  ctm.removeAssignment(ctm.getAssignmentFor(ship));
For some reason this also remove engage/defend/ and other orders, but does not affect ships who have been put on Search & Destroy. Any idea why that is? I would think it wouldn't since those assignments have their own enums...

It shouldn't do that and it's hard to see how that could happen. I suspect something else is probably going on, in addition to what you think is going on.


Is there a way to modify getImproveStoryPoints() from BaseIndustry that would play nice with other mods? I'd like to change the way the story point cost is calculated, but talk on the Discord suggests that there's no way to do this without manually replacing the classes for every single industry, and that's not exactly a compatible method.

There isn't - it sounds like you have an accurate grasp of how it's set up.


When I wanted to add officer skills in the campaign missions...

...

I used this code to make it give the proper CR to everyone with Combat Endurance in missions. However, despite this, every officer and commander seems to get every skill effect except Support Doctrine never mind just had to find out I needed the commander to have it which then made it work very well. just fine so far. Did something change in the Combat Endurance or missions that every ship always get 70% CR?

I remember in previous versions this used to work...

Hopnestly, I don't know off the top of my head. If it used to work and now it doesn't, then I suppose something must've changed, but mission ships having higher CR seems like it might be tricky in particular, since it's an out-of-combat fleetwide effect and a fleet doesn't exist there.



Can anybody help to confirm on how SpriteAPI works?
wrt Center, Height/Width and Angle

I am guessing the following:
- Height/width originally same as the image file used as texture
- Center started out as half of height/width
- angle started out 0
- visible texture for sprite is scaled(change actual height/width wrt image), then translated( changed center), before applying rotation around center (angle)?

That sounds about right.

another issue:
Effect object is probably only associated with one ShipAPI, but what about things like hullmods which are objects that exists before ships.  Do all ships share the same hull mod instance or is there a unique hullmod instance (of a class) for each applicable ship/fleet member variant.

Basically, trying to figure out whether it is "safe" to store properties specific to a ship in such classes/objects (as opposed to the same object possibly used for all applicable ship)

For hullmods there's only one instance per hullmod effect, yeah - you definitely don't want to store stuff in member variables there.


Is there a way to make a ship never go backwards (stopping, and stationary turning, is fine, just no reverse)?

ship.blockCommandForOneFrame(ShipCommand.ACCELERATE_BACKWARDS) should to it, if called every frame.

Edit: Also is there some sort of way to prevent a weapon from firing (/do weapons fire) if they lack enough ammo for a full burst?

I don't believe so, though just the other day I added WeaponAPI.forceNoFireOneFrame().


Are there standard sprite sizes and or canvas sizes for weapons in the hard point and turret categories? I noticed in mods they have 2 of each weapon and they are consistently offset and I’m wondering if there are specifics to this?

There aren't - the just need to "look good" on their respective slot types and sizes. The center is always going to be in the middle of the turret sprite and in the middle of the lower half of the hardpoint sprite.


RE: How to tell if a weapon (WeaponAPI) is point defense?

There seens to be methods to set the value (setPD()), but there isn't one that reads the current value? (e.g. isPD())?

WeaponAPI.hasAIHint(AIHints.PD)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 10, 2022, 01:29:46 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SOLDIER First on January 10, 2022, 04:26:29 PM
There isn't - it sounds like you have an accurate grasp of how it's set up.

That's unfortunate. Thanks for taking the time to respond.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sphr on January 10, 2022, 07:04:24 PM
@Alex
thanks for the prev answers!

@all
new questions that need help

re: hull mods

1. Is the order in which hullmod applies their effects (e.g. before/after creating ship) arbitrary (and not controllable at all)?

2. If the answer to prev is yes, then is there some place which is definitely called once before/after all hullmod applies their effects? (EDIT: clarify, e.g. when using before ship creation to modify the variant, is there some object/method that is called before/after all hullmods applies their effects, to do necessary initialization/finalization)

3. Is there some place to handle when hullmods are added or removed? Currently, it seems like there is no way to handle it at all, and just depends on the hull mod to apply whatever they need to in the various overriden methods, and the only way to check if a hullmod is removed, is to actually remember that it was installed and check it using another hullmod (theoretically possible, but could be messy to implement...)


re: sprite

4. I tried to use the setAngle() method of SpriteAPI, expected it to "rotate" the sprite, but I could not see any effects at all.  What exactly is the parameter, and how does it actually behave?


re: ship variant

5. Is it possible to change the weapon slot type before ship creation (i.e. the method in hull mod with mutablestats as argument)?  e.g. usual types to/from decorative/built-in

re:shipsystem statsscript

6. Is it possible to cancel/deactivate the ship system application from within the stats script itself. e.g. when it is found that the activation is inapplicable.

tia.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on January 12, 2022, 05:39:19 PM
Is there any way to discern what role a fleet has from its CampaignFleetAPI. (Eg. station, patrol, trade convoy, bounty hunter, expedition, if its related to some mission)

Edit: In addition to what Alex posted you can use fleet.getMemoryWithoutUpdate().getString(MemFlags.MEMORY_KEY_FLEET_TYPE) (with fleet being a CampaignFleetAPI)
Fleet types found in com.fs.starfarer.api.impl.campaign.ids.FleetTypes
This can also be used to identify nex fleets
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on January 13, 2022, 02:38:08 AM
I'm trying to work out how black market suspicion works. Been reading CoreCampaignPluginImpl, and found this odd:

Code
	public static final float (MarketAPI market) {
        /* snip */
float extra = market.getMemoryWithoutUpdate().getFloat(MemFlags.MARKET_EXTRA_SUSPICION);
suspicionLevel += extra;
suspicionLevel *= Math.min(1f, suspicionLevel);/* <- multiplication? */

return suspicionLevel;

Should the last operation be a multiplication instead of assignment? It seems more likely this was meant to cap suspicionLevel at 1 instead...

Either way, I am looking hard and cannot see where the transponder being on/off affects the increase of suspicion level. UNLESS, `updateMarketFacts` is only called when transponder if on...

Edit: Or is it just hidden behind calculations using PlayerTradeData? Seems to be the `transponderOffMarketAwarenessMult` setting.



What is the difference between negative and positive tags in the abilities? Say Active Sensor Probe has "burn-" which will disable Sustained Burn on activation (which has "burn+"). But it will also disable Neutrino Detector despite both having "sensors+". Is that a bug?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 14, 2022, 11:06:17 AM
Is it required for a module to have a sprite path attached? Or does setting the module to hidden remove it from the variant when controlled by the enemy fleet?

I have a weird issue where hidden modules spawning derelicts will spawn them under AI control on the player side and not on the enemy AI side. I'm assuming its tied to one of those two things so figured I'd ask.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 14, 2022, 12:15:13 PM
re: hull mods

1. Is the order in which hullmod applies their effects (e.g. before/after creating ship) arbitrary (and not controllable at all)?

It's in the order they're added to the ship, IIRC. So you can pretty well rely on built-into-the-hull hullmods applying before other ones, for example.

2. If the answer to prev is yes, then is there some place which is definitely called once before/after all hullmod applies their effects? (EDIT: clarify, e.g. when using before ship creation to modify the variant, is there some object/method that is called before/after all hullmods applies their effects, to do necessary initialization/finalization)

There isn't. You'd need to track/do this sort of thing in a script, or e.g. add an AdvanceableListener to a Ship and do stuff (and remove it) once combat starts, etc.

3. Is there some place to handle when hullmods are added or removed? Currently, it seems like there is no way to handle it at all, and just depends on the hull mod to apply whatever they need to in the various overriden methods, and the only way to check if a hullmod is removed, is to actually remember that it was installed and check it using another hullmod (theoretically possible, but could be messy to implement...)

There isn't, no.


4. I tried to use the setAngle() method of SpriteAPI, expected it to "rotate" the sprite, but I could not see any effects at all.  What exactly is the parameter, and how does it actually behave?

That should work, so: need more details. The parameter is an angle in degrees.


re: ship variant

5. Is it possible to change the weapon slot type before ship creation (i.e. the method in hull mod with mutablestats as argument)?  e.g. usual types to/from decorative/built-in

I don't believe so.

re:shipsystem statsscript

6. Is it possible to cancel/deactivate the ship system application from within the stats script itself. e.g. when it is found that the activation is inapplicable.

Hmm, you'd need to be more precise - right now the only answer that comes to mind is "yes of course since the code that applies the system's effects is fully your code so it will do whatever you code it to do", so I'm guessing you might have meant something more specific.



Is there any way to discern what role a fleet has from its CampaignFleetAPI. (Eg. station, patrol, trade convoy, bounty hunter, expedition, if its related to some mission)

There's some flags - look for MemFlags.MEMORY_KEY_PATROL_FLEET and what's around it in that file. But nothing that's fully specific like what you're asking.


Should the last operation be a multiplication instead of assignment? It seems more likely this was meant to cap suspicionLevel at 1 instead...

Thank you, fixed! Should indeed have just been an assignment.

Either way, I am looking hard and cannot see where the transponder being on/off affects the increase of suspicion level. UNLESS, `updateMarketFacts` is only called when transponder if on...

Edit: Or is it just hidden behind calculations using PlayerTradeData? Seems to be the `transponderOffMarketAwarenessMult` setting.

Yeah, this is handled in PlayerTradeDataForSubmarket.

What is the difference between negative and positive tags in the abilities? Say Active Sensor Probe has "burn-" which will disable Sustained Burn on activation (which has "burn+"). But it will also disable Neutrino Detector despite both having "sensors+". Is that a bug?

See: BaseAbilityPlugin.isCompatible()

IIRC: abilities that have "opposite" tags are incompatible - i.e. burn+ and burn-. And also, if two abilities have the same + tag, they're incompatible too.

For: burn+ and burn-, incompatible. burn+ and burn+, also incompatible. burn- and burn-: compatible.



Is it required for a module to have a sprite path attached? Or does setting the module to hidden remove it from the variant when controlled by the enemy fleet?

I have a weird issue where hidden modules spawning derelicts will spawn them under AI control on the player side and not on the enemy AI side. I'm assuming its tied to one of those two things so figured I'd ask.

I don't know what you mean by "sprite path attached". And the answer to your question is going to most likely depend on exactly how you're spawning the derelicts, so I'd suggest looking at that? Or providing some detail about it. As is, I really can't say.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on January 14, 2022, 01:25:50 PM
I am wondering if there was a way to have a modded planet flagged with free port or hazard pay in their econ json file? I've looked over several mods planets and cannot seem to find the correct entry to do either. Essentially I want a planet with light industry to start producing recreational drugs and the only way I know to do that is with free port on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 14, 2022, 01:53:30 PM
I am wondering if there was a way to have a modded planet flagged with free port or hazard pay in their econ json file? I've looked over several mods planets and cannot seem to find the correct entry to do either. Essentially I want a planet with light industry to start producing recreational drugs and the only way I know to do that is with free port on.
Why don't you look in how the vanilla planet json do it....

There's 12 hits in 10 files in how they do it....

for hazard pay you just do

Code
MarketAPI.setImmigrationIncentivesOn(boolean)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on January 14, 2022, 02:32:07 PM
OK took me a bit but I did find "freePort":true, in the file for Thule. I am a noob I know, but where would I put that code "MarketAPI.setImmigrationIncentivesOn(boolean)" to effect 1 planet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 14, 2022, 07:25:55 PM
You need to do that in java code. Something like this in your ModPlugin class.

Code: java
    public static final String MARKET_ENTITY_1 = "YOUR_PLANET_OR_STATION_ID_HERE";
    @Override
    public void onNewGameAfterEconomyLoad() {
        for (MarketAPI market : Global.getSector().getEconomy().getMarketsCopy()) {
            if (market.getPrimaryEntity().getId().equals(MARKET_ENTITY_1)) {
                market.setImmigrationIncentivesOn(true);
                break;
            }
        }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 14, 2022, 11:41:07 PM
Quote
613518 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Can't create nested lists using GLListManager
java.lang.RuntimeException: Can't create nested lists using GLListManager

Hey, sometimes people get this error. But often, we never know why and where. Will be possible to add a another log on the CombatMain or say how resolve it on a thread ? Thank you very much :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2022, 10:14:28 AM
Quote
613518 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Can't create nested lists using GLListManager
java.lang.RuntimeException: Can't create nested lists using GLListManager

Hey, sometimes people get this error. But often, we never know why and where. Will be possible to add a another log on the CombatMain or say how resolve it on a thread ? Thank you very much :)

Definitely need to see more of the stack trace for this; this doesn't tell me very much beyond the issue being related to how GL lists are being used. It would also help to know what the person was doing when this crash occurred.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 15, 2022, 12:10:15 PM
I don't know what you mean by "sprite path attached". And the answer to your question is going to most likely depend on exactly how you're spawning the derelicts, so I'd suggest looking at that? Or providing some detail about it. As is, I really can't say.

I mean in the .ship json I have:

  "spriteName": "",

They are spawned using an implementation of the vanilla drone system. The reason I thought it had to either be because the modules themselves are hidden or because of the sprite name is because the mothership also uses the same system on different modules that aren't hidden and it works under enemy AI control in the simulator. That said, I tried changing those two things and it didn't make a difference so it has to be something else.

Example System Implementation:

Spoiler
{
   "id":"archean_drone_mothership_defender_PD",
   "type":"DRONE_LAUNCHER",
   "aiType":"DRONE_LAUNCHER_PD",
   
   "droneVariant":"defender_PD",
   
   
   "allowFreeRoam":true,
   
   "launchSpeed":100,
   "launchDelay":8,
   "maxDrones":3,
   "droneBehavior":[
      {"droneIndex":[0],
       "defaultFacing":"MATCH_DRONE_HEADING",   # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
       "faceEnemy":true,
       "holdRoamRange":1200,
       "freeRoamRange":2500,
       "targetPriority":[SHIP, FIGHTER, MISSILE], # also SHIP_TARGET to prefer targeting the mothership's target
       "initialOrbitAngle":90,
       "orbitRadius":500,             # plus ship radius
       "orbitDir":1,                # -1 or 1
       "orbitSpeed":0,             # pixels/second
      },
      {"droneIndex":[1],
       "defaultFacing":"MATCH_DRONE_HEADING",   # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
       "faceEnemy":true,
       "holdRoamRange":1200,
       "freeRoamRange":2500,
       "targetPriority":[SHIP, FIGHTER, MISSILE], # also SHIP_TARGET to prefer targeting the mothership's target
       "initialOrbitAngle":-90,
       "orbitRadius":500,             # plus ship radius
       "orbitDir":1,                # -1 or 1
       "orbitSpeed":0,             # pixels/second
      },
      {"droneIndex":[2],
       "defaultFacing":"MATCH_DRONE_HEADING",   # MATCH_DRONE_HEADING, MATCH_SHIP_HEADING, MATCH_SHIP_FACING, AWAY_FROM_SHIP
       "faceEnemy":true,
       "holdRoamRange":1200,
       "freeRoamRange":2500,
       "targetPriority":[SHIP, FIGHTER, MISSILE], # also SHIP_TARGET to prefer targeting the mothership's target
       "initialOrbitAngle":180,
       "orbitRadius":650,             # plus ship radius
       "orbitDir":1,                # -1 or 1
       "orbitSpeed":0,             # pixels/second
      },
   ],
   
   "useSound":"drone_launch",
   "outOfUsesSound":"gun_out_of_ammo",
   
   "aiHints":{
   }
}
[close]

Module Example:

Spoiler
{
  "bounds": [
    1,
    1,
    -1,
    1,
    -1,
    -1,
    1,
    -1
  ],
  "builtInMods": [
    "reduced_explosion",
    "never_detaches"
  ],
  "builtInWings": [],
  "center": [
    0,
    0
  ],
  "collisionRadius": 27.5,
  "engineSlots": [],
  "height": 0,
  "hullId": "archean_module_guardian_dronebay_sentry_left",
  "hullName": "Module",
  "hullSize": "FRIGATE",
  "shieldCenter": [
    0,
    0
  ],
  "shieldRadius": 26.5,
  "spriteName": "",
  "style": "LOW_TECH",
  "viewOffset": 0,
  "weaponSlots": [
    {
      "angle": 90,
      "arc": 0,
      "id": "WS0001",
      "locations": [
        0,
        -0
      ],
      "mount": "HIDDEN",
      "size": "SMALL",
      "type": "SYSTEM"
    }
  ],
  "width": 0
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 15, 2022, 02:39:25 PM
Any idea why this is happening on generating starting ships?

Spoiler
14554 [Thread-3] WARN  com.fs.starfarer.campaign.rules.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - Problem with command of class com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddShip: null
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity.addFleetMemberGai nText(AddRemoveCommodity.java:238)
   at com.fs.starfarer.api.impl.campaign.rulecmd.NGCAddShip.execute(NGCAddShip.java:39)
   at com.fs.starfarer.campaign.rules.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.execute(Unknown Source)
   at com.fs.starfarer.campaign.rules.Object.runScript(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.applyRule(FireBest.java:106)
   at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.execute(FireBest.java:51)
   at com.fs.starfarer.api.impl.campaign.rulecmd.FireBest.fire(FireBest.java:57)
   at com.fs.starfarer.api.impl.campaign.NewGameDialogPluginImpl.fireBest(NewGameDialogPluginImpl.java:154)
   at com.fs.starfarer.api.impl.campaign.NewGameDialogPluginImpl.optionSelected(NewGameDialogPluginImpl.java:115)
[close]

NCG options look like this:
NGCAddShip omsk-cv-indie_variant
NGCAddShip rostov-indie_variant
NGCAddShip rostov-e-indie_variant


These are copy/pasted IDs for variants. All of them, however, are based on skins.

Skins and variants work in game, including campaign. Just not being generated as starting options.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 15, 2022, 03:18:38 PM
Any idea why this is happening on generating starting ships?

Either the variant is coming up as null or the variant isn't returning a hullspec.

Since the second seems unlikely, I think it might be from:

Code
		ShipVariantAPI variant = Global.getSettings().getVariant(vid);

 - returning null. This could possibly be because the variant hasn't been added to default_ship_roles.json but there isn't a way for me to know for sure. The interface method doesn't explain where it is getting the variant info from.

As for the hullspec returning null, I'd think that would almost be impossible if the variant works correctly in the other scenarios.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2022, 03:20:52 PM
They are spawned using an implementation of the vanilla drone system. The reason I thought it had to either be because the modules themselves are hidden or because of the sprite name is because the mothership also uses the same system on different modules that aren't hidden and it works under enemy AI control in the simulator. That said, I tried changing those two things and it didn't make a difference so it has to be something else.

Does the module have the proper owner/originalOwner set when you spawn it in?

If that isn't the problem: vanilla drone systems work, right, so I'd suggest starting with something that works and making changes incrementally until you find out what the problem is. It's a tried-and-true debugging technique!

Any idea why this is happening on generating starting ships?

NCG options look like this:
NGCAddShip omsk-cv-indie_variant
NGCAddShip rostov-indie_variant
NGCAddShip rostov-e-indie_variant


These are copy/pasted IDs for variants. All of them, however, are based on skins.

Skins and variants work in game, including campaign. Just not being generated as starting options.

I don't think it'd matter here whether it's based on a skin or not; under the hood those become separate hulls. The crash is because it can't find those variants.

It's possible that it doesn't like "-" in the variant names, so that might be the first thing to try. Also make sure the variant ids are spelled right; they're case sensitive.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 15, 2022, 03:28:00 PM
Figured the issue. Had to write it ""variant id"" not just plaing variant id.

NGCAddShip ""omsk-cv-indie_variant"" instead of NGCAddShip omsk-cv-indie_variant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 15, 2022, 10:10:03 PM
Does the module have the proper owner/originalOwner set when you spawn it in?
Afaik it should. I don't do anything fancy at least. Assuming that the simulator assigns child modules' owner the same way it would the original parent ship, then definitely yes.

Quote
If that isn't the problem: vanilla drone systems work, right, so I'd suggest starting with something that works and making changes incrementally until you find out what the problem is. It's a tried-and-true debugging technique!
Well, the reason I asked was because I'm not 100% sure of that. The vanilla drone systems work under vanilla conditions absolutely, but the hidden nature of the modules on a ship that is also spawned under special circumstances - especially considering module code came way later than drone system code? Not so much there right? I have far less in the way of a test control under those circumstances. The issue of the basics working was never in question. This very much seems like a special case unless I'm missing something obvious (and I very well could be!) considering the following:

For instance, the mothership rotates like a station when tested in the simulator on the enemy or ally side. That was kind of my test bed of "ok this works" for the autofactory systems in the first place and they still work with similar implementations other than the hidden modules. The mothership doesn't rotate like a station in the actual campaign encounter, however, so I'm assuming something happens under the hood to change that behavior. I wasn't sure if that would be a factor for the guardian too. That said, I've reproduced the problem in both places (simulator and actual encounter for the guardian) and so I thought it had to be something related to the module itself related specifically to the non-flagship spawn logic (since as a flagship it works and as an ally or enemy spawned ship it doesn't as far as simulation tests go). I know the system works. I know all the things outside the modules themselves work - ship/variant/etc - and I know it works when under player control and autopiloted but for some reason it doesn't work when spawned as an ally or enemy in the simulator and it doesn't work in the actual campaign encounter.

I've at least started the process of narrowing it down but my point here is that it for the moment isn't making much sense from the perspective of the code I have available. Or, at least, I haven't found the difference yet other than what I've already mentioned.

I'll keep looking but for now this is really stumping me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Snrasha on January 15, 2022, 11:18:56 PM
Quote
613518 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Can't create nested lists using GLListManager
java.lang.RuntimeException: Can't create nested lists using GLListManager

Hey, sometimes people get this error. But often, we never know why and where. Will be possible to add a another log on the CombatMain or say how resolve it on a thread ? Thank you very much :)

Definitely need to see more of the stack trace for this; this doesn't tell me very much beyond the issue being related to how GL lists are being used. It would also help to know what the person was doing when this crash occurred.

From the user:
Quote
I went to mission, there was a mission where I could select basicaly any ship (benchmark, one before the last). I chose the Lodium, put the hardened shield mod, went to a simulation, all went fine.
When I exited the simulation and pressed esc, the game crashed again:
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 16, 2022, 04:56:50 AM
Is there any way to make fighter blueprints look much bigger on that blueprint chip?
My fighters are too small when automatically placed on these.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 18, 2022, 09:24:24 AM
Well, the reason I asked was because I'm not 100% sure of that. The vanilla drone systems work under vanilla conditions absolutely, but the hidden nature of the modules on a ship that is also spawned under special circumstances - especially considering module code came way later than drone system code? Not so much there right? I have far less in the way of a test control under those circumstances. The issue of the basics working was never in question. This very much seems like a special case unless I'm missing something obvious (and I very well could be!) considering the following:

For instance, the mothership rotates like a station when tested in the simulator on the enemy or ally side. That was kind of my test bed of "ok this works" for the autofactory systems in the first place and they still work with similar implementations other than the hidden modules. The mothership doesn't rotate like a station in the actual campaign encounter, however, so I'm assuming something happens under the hood to change that behavior. I wasn't sure if that would be a factor for the guardian too. That said, I've reproduced the problem in both places (simulator and actual encounter for the guardian) and so I thought it had to be something related to the module itself related specifically to the non-flagship spawn logic (since as a flagship it works and as an ally or enemy spawned ship it doesn't as far as simulation tests go). I know the system works. I know all the things outside the modules themselves work - ship/variant/etc - and I know it works when under player control and autopiloted but for some reason it doesn't work when spawned as an ally or enemy in the simulator and it doesn't work in the actual campaign encounter.

I've at least started the process of narrowing it down but my point here is that it for the moment isn't making much sense from the perspective of the code I have available. Or, at least, I haven't found the difference yet other than what I've already mentioned.

I'll keep looking but for now this is really stumping me.

The things you've listed seem like good things to go through one by one and eliminate as suspects. For example, you might try a not-hidden module, etc etc. The important thing is to be methodical so you can be sure about what changed and what didn't.


From the user:
Quote
I went to mission, there was a mission where I could select basicaly any ship (benchmark, one before the last). I chose the Lodium, put the hardened shield mod, went to a simulation, all went fine.
When I exited the simulation and pressed esc, the game crashed again:

Thank you for that added info. Still really need the full stack trace, though, to have any idea of what this might have been.



Is there any way to make fighter blueprints look much bigger on that blueprint chip?
My fighters are too small when automatically placed on these.

Are your fighter sprites significantly bigger than the actual fighters, with blank space around them in the sprites? If so, that might be causing the problem.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 01:04:44 PM
Hey all, COMPLETELY new to modding here. I've kitbashed together a ship and have it all up and running with the ship and weapon editor, but I cant seem to spawn it in game? No errors or crashes, and I have a unique ship ID for it, not sure where the problem lies. Any help would be appreciated, and I can upload files if need be!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 18, 2022, 01:16:26 PM
Do you have a .variant file for the ship?

How are you trying to spawn it in-game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 01:24:36 PM
I do not have a .variant file, I was following the intro to modding on the wiki and I don't think it mentions needing one at the step I'm at. I'm trying to spawn it through the console commands mod with the addship command.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 18, 2022, 01:29:15 PM
Right - that's the problem, then. A "variant" is basically telling the game what weapons etc that ship has on it. The game also creates a default one named <ship id>_Hull that doesn't have anything equipped, so if you do AddShip <ship id>_Hull that should work, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 01:39:52 PM
I'll get on adding a variant file then, but popping in game and trying that command still doesn't spawn anything, and I've combed through the hulls, so I must have messed up something along the way, oop.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 18, 2022, 01:59:03 PM
Hmm, yeah. If you could list all the things you *did* do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceDrake on January 18, 2022, 02:03:33 PM
addShip [your_hull] isn't giving you anything? What happens when you try to addShip with just the base hull, burger?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 02:19:58 PM
I have the ship's image saved as a png in starsector/mods/project/graphics/ships, and I have both a .ship file and .cvs file in starsector/mods/project/data/hulls. Made the .ship file with the ships and weapon editor mod, and I pulled the .cvs file from the game's .cvs file of the onslaught and edited it to fit the ship a bit more.. I'm using Ron's editor for the spreadsheet. The ship ID is the same in both files, so I'm just not sure what I'm missing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 18, 2022, 02:21:16 PM
Shot in the dark: Is the mod enabled?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 18, 2022, 02:22:52 PM
Another question: is the file named ship_data.csv, or ".cvs", as you've typed three separate times in your post? :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 02:25:28 PM
The mod is indeed enabled, and it is ship_data.csv, oop. I was typing cvs for some dumb reason haha
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 02:40:37 PM
addShip [your_hull] isn't giving you anything? What happens when you try to addShip with just the base hull, burger?

I've tried to add it in with the base hull too, and I still get nothing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceDrake on January 18, 2022, 03:01:15 PM
addShip [your_hull] isn't giving you anything? What happens when you try to addShip with just the base hull, burger?

I've tried to add it in with the base hull too, and I still get nothing.

What does the console output when you try to add your ship to your fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 03:04:00 PM
addShip [your_hull] isn't giving you anything? What happens when you try to addShip with just the base hull, burger?

I've tried to add it in with the base hull too, and I still get nothing.

What does the console output when you try to add your ship to your fleet?

It simply says no ship can be found with the ID
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 18, 2022, 03:31:49 PM
Oh my god I figured it out.

The .csv spreadsheet had copied over improperly and had the label for each column in the wrong spot altogether

I feel so dumb
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on January 18, 2022, 04:05:28 PM
Is there anyway to convert Global.getSettings().getControlStringForEnumName's output into a format that's compatible with Keyboard.getKeyIndex?

For example, Global.getSettings().getControlStringForEnumName("SHIP_STRAFE_KEY") returns "Shift". However, Keyboard.getKeyIndex("Shift") returns 0, because "Shift" isn't actually recognized as a key. Instead, Keyboard.getKeyIndex("LSHIFT") returns 42, which incidentally is also the event index for the InputEventAPI corresponding to the shift key.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on January 19, 2022, 01:15:50 AM
My swapping of `open_market` with `regulated_open_market` has an unexpected consequence of removing markets from F1 tooltip.

Is the id hardcoded in there (like right aligned submarket position for `storage` is hardcoded), or am I missing some "update" post swap?

Edit: Seems like it is hardcoded. I will have to override vanilla specs, and come up with an "uninstaller" instead. Or perhaps I could use same package as vanilla implementation and have a "silent" swap during deserialization... Need to try.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 19, 2022, 01:40:21 PM
Is there a way to disable zero-flux bonus?
I've been using this to do it:
Code
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, -2f);
    }
But it falls flat on it's face when the ship is manned with an officer with (elite?) Helmsmanship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 19, 2022, 02:05:45 PM
Can't you just modFlat it by -3 instead of -2?

Helmsmanship only modFlats it by +1. SO does it by +2.

EDIT: Can't read - Helmsmanship modifies getAllowZeroFluxAtAnyLevel(). Which ... I'm not sure why or how that is a MutableStat. ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 19, 2022, 03:31:51 PM
Doesn't work, nvm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 19, 2022, 03:35:38 PM
Quick question, is it possible to make a ballistic projectile spin?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 19, 2022, 03:40:54 PM
Is there anyway to convert Global.getSettings().getControlStringForEnumName's output into a format that's compatible with Keyboard.getKeyIndex?

For example, Global.getSettings().getControlStringForEnumName("SHIP_STRAFE_KEY") returns "Shift". However, Keyboard.getKeyIndex("Shift") returns 0, because "Shift" isn't actually recognized as a key. Instead, Keyboard.getKeyIndex("LSHIFT") returns 42, which incidentally is also the event index for the InputEventAPI corresponding to the shift key.

Not easily, no. What you're looking for are the names of the various constants in Keyboard.KEY_<name>, but you'd have a hard time getting at them dynamically since reflection is disabled. You could however list them out, but mapping this to getControlStringForEnumName() is going to be a manual process since that method just fundamentally returns a user-facing string.

Is there a way to disable zero-flux bonus?
...
But it falls flat on it's face when the ship is manned with an officer with (elite?) Helmsmanship.

You could getAllowZeroFluxAtAnyLevel().modifyMult(id, 0f) to counteract that.

Quick question, is it possible to make a ballistic projectile spin?

I'd imagine so, with a custom script?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 19, 2022, 03:45:56 PM
I mostly just meant in general, if it's possible. Making a custom script will be a whole 'nother ordeal, haha. I've been snooping around a bit to see if some mod has implemented something like it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 19, 2022, 04:06:47 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 19, 2022, 04:35:07 PM
I mostly just meant in general, if it's possible. Making a custom script will be a whole 'nother ordeal, haha. I've been snooping around a bit to see if some mod has implemented something like it.

You have to script it. It shouldn't be too complicated once you are over the hurdle of getting into scripting.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Pogre on January 19, 2022, 05:09:14 PM
I mostly just meant in general, if it's possible. Making a custom script will be a whole 'nother ordeal, haha. I've been snooping around a bit to see if some mod has implemented something like it.

You have to script it. It shouldn't be too complicated once you are over the hurdle of getting into scripting.

Looks like a fully fleshed out garbage cannon is gonna take awhile, rip.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 20, 2022, 01:56:29 AM
What does this mean? Happens on new game creation after i've added a rather simple system with a few planets and markets.

Spoiler
42608 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving to ..\\saves/save_RileyBray_8944815207128770081...
42705 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving stage 2
42705 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving stage 3
43699 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Error saving game
43699 [Thread-3] ERROR com.fs.starfarer.campaign.save.CampaignGameManager  - Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : java.lang.RuntimeException
cause-message       : org.json.JSONException: JSON does not allow non-finite numbers.
method              : com.fs.starfarer.campaign.CustomCampaignEntity.writeReplace()
-------------------------------
com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : java.lang.RuntimeException
cause-message       : org.json.JSONException: JSON does not allow non-finite numbers.
method              : com.fs.starfarer.campaign.CustomCampaignEntity.writeReplace()
-------------------------------
   at com.thoughtworks.xstream.core.util.SerializationMembers.callWriteReplace(SerializationMembers.java:110)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:78)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.wri teItem(AbstractCollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.wri teItem(AbstractCollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.wri teItem(AbstractCollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.wri teItem(AbstractCollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.wri teItem(AbstractCollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.wri teItem(AbstractCollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.wri teItem(AbstractCollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
   at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
   at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
   at com.thoughtworks.xstream.XStream.marshal(XStream.java:1319)
   at com.thoughtworks.xstream.XStream.marshal(XStream.java:1308)
   at com.thoughtworks.xstream.XStream.toXML(XStream.java:1296)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.N.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.OoO0.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.oooO.?00000(Unknown Source)
   at com.fs.starfarer.ui.oooO.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: org.json.JSONException: JSON does not allow non-finite numbers.
   at com.fs.starfarer.loading.String.o00000(Unknown Source)
   at com.fs.starfarer.campaign.BaseCampaignEntity.writeReplace(Unknown Source)
   at com.fs.starfarer.campaign.CustomCampaignEntity.writeReplace(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at com.thoughtworks.xstream.core.util.SerializationMembers.callWriteReplace(SerializationMembers.java:101)
   ... 299 more
Caused by: org.json.JSONException: JSON does not allow non-finite numbers.
   at org.json.JSONObject.testValidity(JSONObject.java:1241)
   at org.json.JSONObject.put(JSONObject.java:1039)
   ... 307 more
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 20, 2022, 02:06:10 AM
You've got a non-finite number somewhere. Either a non-numerical character slipped in, or you missed a comma or such.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 20, 2022, 02:33:08 AM
Strange. I have no values set.
Could it be some orbit radius set too large?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Okim on January 20, 2022, 02:38:24 AM
Figured it.
Turns out i've managed to somehow set orbit to 0...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 20, 2022, 09:02:08 AM
How are we supposed to do multi-line short descriptions for ships? In 0.9.1a I was able to use text2, but that doesn't work anymore.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 20, 2022, 09:20:32 AM
I don't understand exactly what you mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 20, 2022, 09:27:06 AM
Sorry, multiple paragraphs.

For ship short descriptions, the game uses the first paragraph of text1 in descriptions.csv, right? In older versions I could force-set the short description with multiple paragraphs using text2. Now text2 and text3 have been repurposed for the Ziggurat and there doesn't seem to be a way to force-set a short description.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine 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?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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
(https://i.imgur.com/9qK6fWq.png)
(https://i.imgur.com/js8AWYx.png)
(https://i.imgur.com/H8pKVJK.png)
[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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn 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.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 23, 2022, 08:35:34 AM
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.

I'm not quite 100% sure what you mean, but if you mean that the tooltip wouldn't show the change or would otherwise be misleading, then just for clarity I cross-referenced the stats of the exact same variant without the officer and the relevant stats are identical.

And just to be absolutely sure, I checked the speed in the simulator and it is unaffected. If Rugged Construction is working, then something must be going on with how the skills are applied.

To be fair, I'm also getting reports of other kinds of weird things that *shouldn't* be happening so there might be something bigger than just this that is off somehow. For example (and I haven't confirmed this yet), apparently factions aren't actually using the ship quality set in the faction file and generally ignore any nearby nanoforges. The thing is, to my knowledge I don't do anything to that part of the campaign rig and I don't override d-mods iirc so the only thing I could think of is that this is somehow from the no_autofit tag?

Here is the screenshot I got and the report:

And the D-mods is referred to this post https://fractalsoftworks.com/forum/index.php?topic=13183.msg338815#msg338815
Only some of the mod modified ship has D-mods when spawning in an NPC fleet. Majorly, they are all pristine even pirate Atlas.

(https://i.ibb.co/g31t8RM/456.jpg) (https://ibb.co/VtyMGqW)

So while the ships have some d-mods, it isn't nearly enough of them when reading what the quality stat states should roughly be there. I would say that maybe its Nex making changes, but:

Quote
This issue is exclusive to your mod. I never encounter it in vanilla or in other combinations of mods. It might be that it doesn't pull the quality value properly or there's no D-mods version of the ship to choose from? or they don't know the new modified D-mods? Also adding or removing nano forge (by stealing) doesn't affect the D-mods. Most of the factions have quality over 100% so they will be fine even with this bug initially but if the player stole the nano forge the quality issue will not be reflected correctly as well.

I haven't tested this on .1a yet. I will try to test it today.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 26, 2022, 04:57:07 AM
Is there a way to add tags and hints via hullmods?

For example, I would like to be able to add ALWAYS_PANIC alongside an Autoforge, and need to add special_allows_system_use, system_allows_special_use
for switching a shield to a damper system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2022, 06:30:36 PM
Is there a way to add tags and hints via hullmods?

For example, I would like to be able to add ALWAYS_PANIC alongside an Autoforge, and need to add special_allows_system_use, system_allows_special_use
for switching a shield to a damper system.

There isn't, no - hints are tracked per hull spec, and there's only one instance of it shared between all the ships with that hull, so changing it for one ship would change it for all of them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 27, 2022, 02:10:54 AM
Bugger, thanks anyway!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kris_xK on January 27, 2022, 10:44:09 AM
Is it possible to use Enum WeaponAPI.WeaponType in a hullmod to get a turret count? I'm just curious if my ongoing failure is a result of my complete lack of coding skills or if my method is just a nonstarter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on January 27, 2022, 01:11:48 PM
How do I find the location of a specific fighter bay?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 27, 2022, 01:32:17 PM
                           for(WeaponSlotAPI possbay:lastResort.getHullSpec().getAllWeaponSlotsCopy())
                           {
                                                                                //check for id here
                              if(possbay.getWeaponType() == WeaponAPI.WeaponType.LAUNCH_BAY)
                              {
                                 location = possbay.getLocation();

                              }
                              
                           }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 28, 2022, 03:42:12 AM
Is it possible to change a ship's shield to Damper Field with a hullmod? Only needs to work for one ship class, not in general.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on January 28, 2022, 06:52:36 AM
Is it possible to change a ship's shield to Damper Field with a hullmod? Only needs to work for one ship class, not in general.
Possibly. Try out a ship with a regular shield, but the special system hints and see if it crashes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 28, 2022, 07:32:08 AM
Is it possible to use Enum WeaponAPI.WeaponType in a hullmod to get a turret count? I'm just curious if my ongoing failure is a result of my complete lack of coding skills or if my method is just a nonstarter.

You're probably looking for WeaponSlotAPI.isTurret(), but it's hard to say without knowing more about what you're doing.


Is it possible to change a ship's shield to Damper Field with a hullmod? Only needs to work for one ship class, not in general.

I think there are some modded hullmods that let you switch paintjobs? Depending on how those are implemented - i.e. if they end up switching the hull to a different skin, under the hood - then you might be able to use the same kind of approach. Not sure, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vandermeer on January 28, 2022, 10:20:00 AM
If I were to add a line ->
Code
item_:{tags:[my_awesome_bp]}
to one or more blueprint drop groups with some arbitrary frequency, would these blueprints continue to drop, or does the blueprint giveaway stop once you have a category or single ship unlocked?

I could find out by playing, but I refuse to get new post 0.9 ingame experience spoiled before everything is finely modded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 28, 2022, 06:33:35 PM
Is it possible to change a ship's shield to Damper Field with a hullmod? Only needs to work for one ship class, not in general.

I think there are some modded hullmods that let you switch paintjobs? Depending on how those are implemented - i.e. if they end up switching the hull to a different skin, under the hood - then you might be able to use the same kind of approach. Not sure, though.

Tried hackery, but found no solace. I think when the time comes I will just make it have Damper by default and no shield option. Or make it separate hulls and route the player through my conversion mechanics to switch between them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on January 29, 2022, 07:01:19 PM
How do I get the target ship API of a fighter wing when the owner carrier doesn't have a target?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 30, 2022, 04:11:10 AM
If you have the FighterWingAPI you can just getWingMembers() to get a list of ShipAPIs. If you have the carrier's ShipAPI you can use getAllWings() to get the list of its FighterWingAPIs first.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on January 30, 2022, 10:15:09 AM
Offhand question I haven't had time to investigate: What are the circumstances for the AI to use Reserve Deployment now? I'm pretty sure there were changes in the most recent update iirc.

The AI seems to refuse to use it even when the replacement rate is at 30% in my mod.

*EDIT* Ah ok so its related to the AI setting the wings to engage. It seems to use it upon first setting it to engage but not everytime so maybe its looking for a full wing count. It doesn't typically use it during regroup even with a low replacement rate.

So the AI now treats it as an attack boost from the extra wing members rather than a replenishment system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Oni on January 31, 2022, 01:55:54 PM
Quick question, do bounty contracts take distance from the core into account as well as fleet strength when calculating the job's pay?

It's kinda weird asking my contact for an "easy" bounty, and seeing it on the far edge of the outer systems with only a 30,000 payout. I'd spend more on fuel and ship maintenance than I'd get doing it, so no point unless I happened to be doing something else in the area.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on February 01, 2022, 02:47:00 AM
Is there a way to use colored text in hullmods.csv? I've noticed that if I use one of the faction names as "design type", it will automatically write it in that faction's color, but any other generic entry will be default UI color. How do I define custom design types that have their own colors associated with them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 01, 2022, 03:16:59 AM
Code
"designTypeColors":{
"Roider Union":[242,208,141,255],
},

in settings.json
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on February 01, 2022, 03:26:47 AM
Thank you, this was probably the last place I expected it to be.  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on February 01, 2022, 08:09:29 AM
Is there a complete list of elements for .skin files anywhere?

I've found a few of the hidden ones e.g. "fighterBays": and "addHints":, I'm sure there must be more...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2022, 08:42:40 AM
Is there a complete list of elements for .skin files anywhere?

I've found a few of the hidden ones e.g. "fighterBays": and "addHints":, I'm sure there must be more...

Not to my knowledge - maybe on the wiki? Otherwise, your best bet would be looking through existing .skin files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on February 01, 2022, 08:56:12 AM
Not to my knowledge - maybe on the wiki? Otherwise, your best bet would be looking through existing .skin files.

No luck, wiki is incomplete. Same with vanilla .skins. There might be a complete example across mods but it's impractical to dig through every mod for an example.

Trial and error it is  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 01, 2022, 07:32:00 PM
I got an example skin I made put up on the wiki https://starsector.fandom.com/wiki/.skin_File_Overview#Skin_file_example

Take a look, Great Wound.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on February 01, 2022, 07:42:22 PM
I got an example skin I made put up on the wiki https://starsector.fandom.com/wiki/.skin_File_Overview#Skin_file_example

Take a look, Great Wound.

Thanks. here's a couple more you're missing:
   "suppliesToRecover":40,
   "suppliesPerMonth":40,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 01, 2022, 07:47:08 PM
Thanks, those and probably others have been added since I made that.


BTW, Alex, do you remember where the heck you posted the IO source code I made that from? I can't find it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 02, 2022, 08:36:57 AM
BTW, Alex, do you remember where the heck you posted the IO source code I made that from? I can't find it.

I don't even remember posting it, so, no :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Juan-Dela_Cruz on February 02, 2022, 06:11:23 PM
I am trying to replace a ship's bounds and I've tried using "core_clearArray", but it doesn't seem to work. Am I going about this wrong? 

 "bounds": [
    core_clearArray,
    58, 45,
    75, 33,
    75, 21,
    85, 8,
    85, -8,
    75, -21,
    75, -33,
    58, -45,
    -20, -45,
    -20, -45,
    -38, -28,
    -58, -28,
    -58, 28,
    -38, 28,
    -20, 45
  ]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 02, 2022, 06:45:07 PM
Hmm - offhand, that looks right to me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 02, 2022, 07:24:11 PM
Doesn't work as in does nothing, or straight-up crashes? (I recall getting the latter issue trying to use clearArray in a settings.json array in a previous version, maybe because I was entering it as a string literal)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Juan-Dela_Cruz on February 03, 2022, 04:35:43 AM
It just crashes, says that it is not a number. I've even tried using quotation marks. didn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 03, 2022, 12:28:34 PM
got a FleetAssignmentAI, activating an ability via fleet.getAbility().activate() only causes it to toggle for one or two frames, then deactivate it again.

It's irritating cause I want the fleet to use sustained burn to follow the player (Via FleetAssignment.ORBIT_PASSIVE, but any other results in the same...), and it just doesn't want to do it!

Any help is appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 03, 2022, 12:49:43 PM
got a FleetAssignmentAI, activating an ability via fleet.getAbility().activate() only causes it to toggle for one or two frames, then deactivate it again.

It's irritating cause I want the fleet to use sustained burn to follow the player (Via FleetAssignment.ORBIT_PASSIVE, but any other results in the same...), and it just doesn't want to do it!

Any help is appreciated.

Hmm, if I had to make an offhand guess, I'd say there is probably a memory key that needs to be added to the FleetAPI that ensures that the ability stays active. There is probably a periodic check every couple of seconds and the engine is looking at the memory keys on the fleet for that FleetAssignment and going "oh sustained burn should be on for that fleet!" as a failsafe.

ORBIT_PASSIVE likely assumes that the fleet isn't going at the sustained burn speed and so will actively turn it off because the assumption is the fleet is orbiting a market or other SectorEntity, etc.

Assuming that's true, then the problem you might run into is that the keys related to sustained burn don't fall into a proper use case. I doubt it though because there is an AI state for fleet AI that has the fleet essentially do what you're describing - maintain contact with the player fleet without engaging with it or really doing anything else. However, come to think of it that might also cause the fleet to use the interdiction ability against the player fleet under certain circumstances since that state is technically a hostile one, so you might have to build something to prevent that.

I'd take a look, if possible, at the FleetAssignment for hostile fleets maintaining contact as a starting place for what you want to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 03, 2022, 12:53:01 PM
...
Assignment does not have influence on this behaviour, it always aborts it regardless of assignment!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 03, 2022, 04:35:51 PM
Sounds like the Sustained Burn AI is turning it off.

A campaign plugin can assign a specific ability AI to a fleet, letting you override this behavior. Example from Nex:
Code: java
	@Override
public PluginPick<AbilityAIPlugin> pickAbilityAI(AbilityPlugin ability, ModularFleetAIAPI ai) {
if (ability == null) return null;
String id = ability.getId();
if (id == null) return null;
CampaignFleetAPI fleet = ai.getFleet();
if (fleet == null) return null;

if (id.equals(Abilities.TRANSPONDER) && fleet.getMemoryWithoutUpdate().getBoolean(AlwaysOnTransponderAI.MEMORY_KEY_ALWAYS_ON)) {
Global.getLogger(this.getClass()).info("Adding custom transponder AI to fleet " + fleet.getName());
AlwaysOnTransponderAI aai = new AlwaysOnTransponderAI();
aai.init(ability);
return new PluginPick<AbilityAIPlugin>(aai, PickPriority.MOD_SET);
}
return null;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on February 03, 2022, 10:30:01 PM
I've double-checked this; the onhit gets called if I remove the proximity explosion, but does not get called when I add it back in. Presumably it has something to do with the projectile exploding without touching anything- the damage applied by the flak AoE returns null if you try to get its projectile ID or source weapon.

Ah, my bad - the onHitEffect needs to be inside behaviorSpec (but *not* inside explosionSpec).

This is a super delayed reply but I've just now noticed that doing this causes the onhit to get called at least a half-dozen times against any target caught in the AoE. I'm guessing there are a bunch of invisible projectiles that are checking collision or something? Is there any way to only get that script to be called once per target per explosion?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 04, 2022, 04:53:28 AM
Is there a skill or something tied to Marine XP? Wondering if there's a way I can modify it (Like having the minimum XP  for marines always at Veteran, with a custom skill..or something)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: default on February 04, 2022, 08:03:38 AM
I am very new to modding and wanted to get into the coding part of it, but I have come across an issue. When following the guide found here: https://starsector.fandom.com/wiki/IntelliJ_IDEA_Setup (https://starsector.fandom.com/wiki/IntelliJ_IDEA_Setup), I got to the debugging section, modified the bat file, and then tried to run it. It looks like it tried to run, but encountered errors. Did I do something wrong? I don't really know a whole lot of coding, just slowly learning it, so I'm not familiar with too many errors. I apologize if I'm just being a newbie... Help would be appreciated.

Putting errors here to not make the post needlessly long.
Error 1:
Feb 04, 2022 10:53:57 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

Error 2:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.Sys
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 04, 2022, 08:16:04 AM
This is a super delayed reply but I've just now noticed that doing this causes the onhit to get called at least a half-dozen times against any target caught in the AoE. I'm guessing there are a bunch of invisible projectiles that are checking collision or something? Is there any way to only get that script to be called once per target per explosion?

It's getting called every frame of the explosion's existence. Generally speaking you'd want to keep track of what the on-hit effect applied to already and bail out for repeats. IIRC you have have data members in the OnHitEffect class - it's instantiated per projectile/explosion/etc.


Is there a skill or something tied to Marine XP? Wondering if there's a way I can modify it (Like having the minimum XP  for marines always at Veteran, with a custom skill..or something)

This is handled in PlayerFleetPersonnelTracker, but modding that is going to be fairly involved; the specific levers you want are not exposed (and don't really exist in the first place), so you'd have to replace it with your own version.

I am very new to modding and wanted to get into the coding part of it, but I have come across an issue. When following the guide found here:
...
Did I do something wrong? I don't really know a whole lot of coding, just slowly learning it, so I'm not familiar with too many errors. I apologize if I'm just being a newbie... Help would be appreciated.

Hi! I actually have no idea about this, sorry - I don't use IDEA, and this error message doesn't ring any bells for me. This isn't very helpful, but, didn't want you to think I was responding to others and just ignoring you :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: default on February 04, 2022, 09:08:13 AM
I am very new to modding and wanted to get into the coding part of it, but I have come across an issue. When following the guide found here:
...
Did I do something wrong? I don't really know a whole lot of coding, just slowly learning it, so I'm not familiar with too many errors. I apologize if I'm just being a newbie... Help would be appreciated.

Hi! I actually have no idea about this, sorry - I don't use IDEA, and this error message doesn't ring any bells for me. This isn't very helpful, but, didn't want you to think I was responding to others and just ignoring you :)
It's all good. I'll just try to mess around with it and hopefully figure something out. Or maybe somebody has a solution. Either way, thanks for the reply!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on February 04, 2022, 09:32:07 AM
It's all good. I'll just try to mess around with it and hopefully figure something out. Or maybe somebody has a solution. Either way, thanks for the reply!

The error code in your original post is an “access denied” error, meaning you don’t have sufficient permissions. When this mind of error pops up on a Windows machine, I can think of two possible causes/solutions:

- Try running the bat file as an administrator (right click, run as administrator or ctrl+shift+enter in the start menu bar).

- Where is your Starsector installation located? If it’s in Program Files or Program Files (x86), try moving it out to, say, Documents. Windows really doesn’t like its users modifying the program files for some reason.

Edit: upon further inspection, this seems like a java issue and not a Starsector issue, so the second suggestion is unlikely to work. If running as administrator fails you may need to go into regedit and create the java preferences key yourself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: default on February 04, 2022, 09:50:19 AM
It's all good. I'll just try to mess around with it and hopefully figure something out. Or maybe somebody has a solution. Either way, thanks for the reply!

The error code in your original post is an “access denied” error, meaning you don’t have sufficient permissions. When this mind of error pops up on a Windows machine, I can think of two possible causes/solutions:

- Try running the bat file as an administrator (right click, run as administrator or ctrl+shift+enter in the start menu bar).

- Where is your Starsector installation located? If it’s in Program Files or Program Files (x86), try moving it out to, say, Documents. Windows really doesn’t like its users modifying the program files for some reason.

Edit: upon further inspection, this seems like a java issue and not a Starsector issue, so the second suggestion is unlikely to work. If running as administrator fails you may need to go into regedit and create java preferences key yourself.
When I just run the bat file as admin, it just brings up the command prompt like bat files do, and it closes out after anything is pressed. I ran IDEA as admin and went to debug it again, and it did clear up the first error, which is awesome. However, the second error still shows up.

Edit: I realize it would likely be more helpful to post the entire output I got when running the debugger on IDEA as it does say Error in there even though it was not highlighted in red...
Spoiler
cmd.exe /c "C:/Program Files (x86)/Fractal Softworks/Starsector/starsector-core/debug-starsector.bat"

C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core>..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Xms1536m -Xmx1536m -Xss2048k -Dcom.fs.starfarer.settings.paths.logs=. -Dcom.fs.starfarer.settings.paths.saves=../saves -Dcom.fs.starfarer.settings.paths.screenshots=../screenshots -Dcom.fs.starfarer.settings.paths.mods=../mods -classpath janino.jar;commons-compiler.jar;commons-compiler-jdk.jar;starfarer.res.jar;starfarer.api.jar;starfarer_obf.jar;jogg-0.0.7.jar;jorbis-0.0.15.jar;json.jar;lwjgl.jar;lwjgl_util_applet.jar;jinput.jar;lwjgl_test.jar;log4j-1.2.9.jar;lwjgl_util.jar;fs.sound_obf.jar;fs.common_obf.jar;xstream-1.4.10.jar com.fs.starfarer.StarfarerLauncher
Listening for transport dt_socket at address: 5005
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Starting Starsector 0.95.1a-RC6 launcher
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Running in C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - OS: Windows 8.1 6.3
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Java version: 1.7.0_79 (64-bit)
12   [main] INFO  com.fs.starfarer.launcher.ModManager  - Found mod:  [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Magellan Protectorate(modified)]
13   [main] INFO  com.fs.starfarer.settings.StarfarerSettings  - Loading settings
13   [main] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/config/settings.json)]
53   [main] ERROR com.fs.starfarer.StarfarerLauncher  - java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
   at java.lang.ClassLoader.loadLibrary(Unknown Source)
   at java.lang.Runtime.loadLibrary0(Unknown Source)
   at java.lang.System.loadLibrary(Unknown Source)
   at org.lwjgl.Sys$1.run(Sys.java:72)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
   at org.lwjgl.Sys.loadLibrary(Sys.java:87)
   at org.lwjgl.Sys.<clinit>(Sys.java:117)
   at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
   at com.fs.graphics.DisplayManager.Ò00000(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.detectResolutions(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.<init>(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.createUI(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.Sys
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
Press any key to continue . . .
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on February 04, 2022, 10:18:56 AM
When I just run the bat file as admin, it just brings up the command prompt like bat files do, and it closes out after anything is pressed. I ran IDEA as admin and went to debug it again, and it did clear up the first error, which is awesome. However, the second error still shows up.

Edit: I realize it would likely be more helpful to post the entire output I got when running the debugger on IDEA as it does say Error in there even though it was not highlighted in red...
Spoiler
cmd.exe /c "C:/Program Files (x86)/Fractal Softworks/Starsector/starsector-core/debug-starsector.bat"

C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core>..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Xms1536m -Xmx1536m -Xss2048k -Dcom.fs.starfarer.settings.paths.logs=. -Dcom.fs.starfarer.settings.paths.saves=../saves -Dcom.fs.starfarer.settings.paths.screenshots=../screenshots -Dcom.fs.starfarer.settings.paths.mods=../mods -classpath janino.jar;commons-compiler.jar;commons-compiler-jdk.jar;starfarer.res.jar;starfarer.api.jar;starfarer_obf.jar;jogg-0.0.7.jar;jorbis-0.0.15.jar;json.jar;lwjgl.jar;lwjgl_util_applet.jar;jinput.jar;lwjgl_test.jar;log4j-1.2.9.jar;lwjgl_util.jar;fs.sound_obf.jar;fs.common_obf.jar;xstream-1.4.10.jar com.fs.starfarer.StarfarerLauncher
Listening for transport dt_socket at address: 5005
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Starting Starsector 0.95.1a-RC6 launcher
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Running in C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - OS: Windows 8.1 6.3
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Java version: 1.7.0_79 (64-bit)
12   [main] INFO  com.fs.starfarer.launcher.ModManager  - Found mod:  [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Magellan Protectorate(modified)]
13   [main] INFO  com.fs.starfarer.settings.StarfarerSettings  - Loading settings
13   [main] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/config/settings.json)]
53   [main] ERROR com.fs.starfarer.StarfarerLauncher  - java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
   at java.lang.ClassLoader.loadLibrary(Unknown Source)
   at java.lang.Runtime.loadLibrary0(Unknown Source)
   at java.lang.System.loadLibrary(Unknown Source)
   at org.lwjgl.Sys$1.run(Sys.java:72)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
   at org.lwjgl.Sys.loadLibrary(Sys.java:87)
   at org.lwjgl.Sys.<clinit>(Sys.java:117)
   at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
   at com.fs.graphics.DisplayManager.Ò00000(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.detectResolutions(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.<init>(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.createUI(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.Sys
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
Press any key to continue . . .
[close]

Sorry, I was only looking at the first error. The second error does seem like it could be caused by putting Starsector in your program files. Try moving Starsector out of program files and/or running IntelliJ as an admin. If that fails, could you post screenshots of your run configuration?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: default on February 04, 2022, 10:58:23 AM
When I just run the bat file as admin, it just brings up the command prompt like bat files do, and it closes out after anything is pressed. I ran IDEA as admin and went to debug it again, and it did clear up the first error, which is awesome. However, the second error still shows up.

Edit: I realize it would likely be more helpful to post the entire output I got when running the debugger on IDEA as it does say Error in there even though it was not highlighted in red...
Spoiler
cmd.exe /c "C:/Program Files (x86)/Fractal Softworks/Starsector/starsector-core/debug-starsector.bat"

C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core>..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Xms1536m -Xmx1536m -Xss2048k -Dcom.fs.starfarer.settings.paths.logs=. -Dcom.fs.starfarer.settings.paths.saves=../saves -Dcom.fs.starfarer.settings.paths.screenshots=../screenshots -Dcom.fs.starfarer.settings.paths.mods=../mods -classpath janino.jar;commons-compiler.jar;commons-compiler-jdk.jar;starfarer.res.jar;starfarer.api.jar;starfarer_obf.jar;jogg-0.0.7.jar;jorbis-0.0.15.jar;json.jar;lwjgl.jar;lwjgl_util_applet.jar;jinput.jar;lwjgl_test.jar;log4j-1.2.9.jar;lwjgl_util.jar;fs.sound_obf.jar;fs.common_obf.jar;xstream-1.4.10.jar com.fs.starfarer.StarfarerLauncher
Listening for transport dt_socket at address: 5005
0    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Starting Starsector 0.95.1a-RC6 launcher
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Running in C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - OS: Windows 8.1 6.3
1    [main] INFO  com.fs.starfarer.StarfarerLauncher  - Java version: 1.7.0_79 (64-bit)
12   [main] INFO  com.fs.starfarer.launcher.ModManager  - Found mod:  [C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\Magellan Protectorate(modified)]
13   [main] INFO  com.fs.starfarer.settings.StarfarerSettings  - Loading settings
13   [main] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [ABSOLUTE_AND_CWD: null (data/config/settings.json)]
53   [main] ERROR com.fs.starfarer.StarfarerLauncher  - java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
   at java.lang.ClassLoader.loadLibrary(Unknown Source)
   at java.lang.Runtime.loadLibrary0(Unknown Source)
   at java.lang.System.loadLibrary(Unknown Source)
   at org.lwjgl.Sys$1.run(Sys.java:72)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
   at org.lwjgl.Sys.loadLibrary(Sys.java:87)
   at org.lwjgl.Sys.<clinit>(Sys.java:117)
   at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
   at com.fs.graphics.DisplayManager.Ò00000(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.detectResolutions(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.<init>(Unknown Source)
   at com.fs.starfarer.launcher.opengl.GLLauncher.createUI(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.Sys
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.<init>(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.main(Unknown Source)
Press any key to continue . . .
[close]

Sorry, I was only looking at the first error. The second error does seem like it could be caused by putting Starsector in your program files. Try moving Starsector out of program files and/or running IntelliJ as an admin. If that fails, could you post screenshots of your run configuration?
I tried moving Starsector to my desktop and running the debug, then again as admin, to no avail. Though the error log did look slightly different. Also by run configuration I assume you mean the config I have on IDEA for running the bat file? I'm still very new to all this. Regardless, I will post a screenshot of that. If anything else is needed, let me know. It helps to be specific.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on February 04, 2022, 11:34:58 AM
I tried moving Starsector to my desktop and running the debug, then again as admin, to no avail. Though the error log did look slightly different. Also by run configuration I assume you mean the config I have on IDEA for running the bat file? I'm still very new to all this. Regardless, I will post a screenshot of that. If anything else is needed, let me know. It helps to be specific.

Your debug-starsector.bat is not specifying java.library.path. It should look like this (since you are on Windows, you can just copy/paste the entire thing):

Code
start ..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Djava.library.path=native\windows -Xms1536m -Xmx1536m -Xss2048k -Dcom.fs.starfarer.settings.paths.logs=. -Dcom.fs.starfarer.settings.paths.saves=../saves -Dcom.fs.starfarer.settings.paths.screenshots=../screenshots -Dcom.fs.starfarer.settings.paths.mods=../mods -classpath janino.jar;commons-compiler.jar;commons-compiler-jdk.jar;starfarer.res.jar;starfarer.api.jar;starfarer_obf.jar;jogg-0.0.7.jar;jorbis-0.0.15.jar;json.jar;lwjgl.jar;lwjgl_util_applet.jar;jinput.jar;lwjgl_test.jar;log4j-1.2.9.jar;lwjgl_util.jar;fs.sound_obf.jar;fs.common_obf.jar;xstream-1.4.10.jar com.fs.starfarer.StarfarerLauncher

The following option is of particular relevance:
Code
-Djava.library.path=native\windows

You should also set up a run configuration for attaching a debugger to Starsector. To do this, click + on the top-left of "Run/Debug Configurations" and select "Remote JVM Debug". Use the following settings:

Debugger mode: Attach to remote JVM
Transport: Socket
Host: localhost
Port: 5005
Command line arguments for remote JVM: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Use module classpath: <your mod>
Before launch: Run another configuration -> run the debug-starsector batch script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: default on February 04, 2022, 12:16:49 PM
I tried moving Starsector to my desktop and running the debug, then again as admin, to no avail. Though the error log did look slightly different. Also by run configuration I assume you mean the config I have on IDEA for running the bat file? I'm still very new to all this. Regardless, I will post a screenshot of that. If anything else is needed, let me know. It helps to be specific.

Your debug-starsector.bat is not specifying java.library.path. It should look like this (since you are on Windows, you can just copy/paste the entire thing):

Code
start ..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Djava.library.path=native\windows -Xms1536m -Xmx1536m -Xss2048k -Dcom.fs.starfarer.settings.paths.logs=. -Dcom.fs.starfarer.settings.paths.saves=../saves -Dcom.fs.starfarer.settings.paths.screenshots=../screenshots -Dcom.fs.starfarer.settings.paths.mods=../mods -classpath janino.jar;commons-compiler.jar;commons-compiler-jdk.jar;starfarer.res.jar;starfarer.api.jar;starfarer_obf.jar;jogg-0.0.7.jar;jorbis-0.0.15.jar;json.jar;lwjgl.jar;lwjgl_util_applet.jar;jinput.jar;lwjgl_test.jar;log4j-1.2.9.jar;lwjgl_util.jar;fs.sound_obf.jar;fs.common_obf.jar;xstream-1.4.10.jar com.fs.starfarer.StarfarerLauncher

The following option is of particular relevance:
Code
-Djava.library.path=native\windows

You should also set up a run configuration for attaching a debugger to Starsector. To do this, click + on the top-left of "Run/Debug Configurations" and select "Remote JVM Debug". Use the following settings:

Debugger mode: Attach to remote JVM
Transport: Socket
Host: localhost
Port: 5005
Command line arguments for remote JVM: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Use module classpath: <your mod>
Before launch: Run another configuration -> run the debug-starsector batch script.

Oooohh, okay. This worked. I was getting confused on the wording in the tutorial. It says "Replace the beginning of the one line in the file as follows:" Key word is replace. I replaced this: "-Djava.library.path=native\windows" with this: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" because I thought something needed to be replaced. Due to the wording of it, but now it makes sense.

Thanks for being patient with my lack of experience with any bat files at all, and also the tip for attaching a debugger.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on February 04, 2022, 06:09:25 PM
Feb 04, 2022 10:53:57 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

This can be safely ignored, but if you want to get rid of the warning there are steps here (https://stackoverflow.com/questions/23720446/java-could-not-open-create-prefs-error)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 05, 2022, 04:26:24 AM
This is handled in PlayerFleetPersonnelTracker, but modding that is going to be fairly involved; the specific levers you want are not exposed (and don't really exist in the first place), so you'd have to replace it with your own version.

augh, okay. Thanks :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 05, 2022, 03:44:34 PM
I'm looking to create two hullmods:
#1:

Keeps the replenishment for fighters at 100% during combat, and sets the refit time for any fighter it has to 1 second.

#2:

Gives a range boost to a specific classname or classnames of weapons.   If that is not possible, then boost one type of weapon, energy, for example.

Are these doable?   My java knowledge is poor at best.

Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on February 06, 2022, 05:30:18 AM
I want to make certain hullmods, ships, weapons, fighters player only. Is there a way to make this? If this is pretty big deal for this thread, I can make a seperate thread about it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 06, 2022, 07:24:53 AM
I'm looking to create two hullmods:
#1:Keeps the replenishment for fighters at 100% during combat, and sets the refit time for any fighter it has to 1 second.
#2:Gives a range boost to a specific classname or classnames of weapons.   If that is not possible, then boost one type of weapon, energy, for example.
Are these doable?   My java knowledge is poor at best.

Thanks in advance.
Both of these are feasible.

I want to make certain hullmods, ships, weapons, fighters player only. Is there a way to make this? If this is pretty big deal for this thread, I can make a seperate thread about it.
If you do not add a ship or weapon to the faction files of other factions, they will not show up with them. It's a simple thing. Best examples to be found in mods like Tahlan.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on February 06, 2022, 07:25:41 AM
I also got a question - I want to make a fleet perma-visible to the player, both on the campaign layer as well as the Map.
Any way to get this done?

Thanks in advance,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 06, 2022, 08:14:11 AM
Seems that member.getStats().getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD) doesn't work while used in BuffManagerAPI...
In campaign layer, the deployment points seem to be reduced, but while in combat layer, the deployment points revert to normal
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2022, 08:40:23 AM
I also got a question - I want to make a fleet perma-visible to the player, both on the campaign layer as well as the Map.
Any way to get this done?

Thanks in advance,

Hmm, I don't think so. Depending on what you want, though, it might be worth looking at how the OrbitalStation industry handles this sort of thing - with a custom entity with a fleet somehow attached to it, iirc. Not 100% sure whether there's anything "special" there that makes it only work for that narrow use case, though.


Seems that member.getStats().getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD) doesn't work while used in BuffManagerAPI...
In campaign layer, the deployment points seem to be reduced, but while in combat layer, the deployment points revert to normal

Oh, wow, that's a bit of a mess - it was applying, but only sometimes. Fixed this up, thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 06, 2022, 08:43:23 AM
Oh, wow, that's a bit of a mess - it was applying, but only sometimes. Fixed this up, thank you.
FINE... I will try to directly apply it in the combat layer, looks like the CoordinatedManeuversScript is related to the dp change.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on February 06, 2022, 02:28:47 PM
[ Re-enabling auto pause on F9 ]

Greetings,

Is there some sort of API method -- or better yet, a hidden boolean that can be set within settings.json -- that can force the game to always start a reloaded game in a paused state?

I understand that this is already the default behavior with vanilla 0.95.1a StarSector, but I suspect one of my (125+) installed mods is overriding this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 07, 2022, 04:00:45 AM
I've been making a personal little mod to change ship paintjobs through a hullmod and i've run up against a few problems (one small and one big, though both are kinda minor)

First off the small one - can we get something like isShowDamageWhenDecorative() for weaponSpecAPI, it'd be a nice shorthand for seeing if something is a deco that actually needs to be replaced (and is kinda wierd that isRenderAboveAllWeapons() is a thing but this isn't, I guess no one's asked for it beore?)

And the big one - clearing decorative slots and replacing the weapon in them seems to completely break / ignore render order.

deco weapon replacement code
Code
        for (WeaponAPI weapon : ship.getAllWeapons()) {

            String weapslot = weapon.getSlot().getId();
            String weapid = weapon.getId();
            ShipVariantAPI variant = ship.getMutableStats().getVariant();

            boolean hasSwapped = weapid.contains(prefix); //prefix for weapon graphics & names

            boolean isBlinker = weapid.contains("blinker"); //checks for "not armour deco" stuff start
            boolean isGlow = weapid.contains("glow") || weapid.contains("light");
            boolean isEmpCore = weapid.contains("empcore");
            boolean isShadow = weapid.contains("shadow");//checks end

            if (weapon.getSlot().isDecorative() && !hasSwapped && !isBlinker && !isEmpCore && !isGlow && !isShadow) {
                variant.clearSlot(weapslot);
                variant.addWeapon(weapslot, prefix + weapid);
            }
        }
[close]

This swaps all non-painted deco weaps that have replacements to their painted equivalents, but somewhere along the way it also seems to completely break the render order of the replaced weaps, despite not touching it at all.
It's also got the wierd side effect of keeping the broken render order between removing the hullmod and fully stripping the ship, though I'm assuming that's because I never readd the unpainted decos (?)

no hullmod, shadow & covers are over guns
(https://cdn.discordapp.com/attachments/824910699415207937/940048032026746930/screenshot258.png)
[close]
with paintjob, shadows are over gun but covers are below
(https://cdn.discordapp.com/attachments/824910699415207937/940048032337104896/screenshot256.png)
[close]
after removing paintjob, before stripping the ship, same as image 2
(https://cdn.discordapp.com/attachments/824910699415207937/940048031741542440/screenshot257.png)
[close]

Safarijohn suggested saving the variant then stripping it & putting it all back in code, but that seems too complicated for me (and this feels like a bug so I thought I'd ask here as well), honestly I'm hoping I just overlooked something obvious 

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sutopia on February 07, 2022, 06:54:03 AM
Is there a way to manually spawn custom objectives during a battle?
I want to make a station battle with gimmick of taking over objectives to make station weaker.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2022, 01:10:04 PM
[ Re-enabling auto pause on F9 ]

Greetings,

Is there some sort of API method -- or better yet, a hidden boolean that can be set within settings.json -- that can force the game to always start a reloaded game in a paused state?

I understand that this is already the default behavior with vanilla 0.95.1a StarSector, but I suspect one of my (125+) installed mods is overriding this.

I don't think there's any specific config value for this, at least not that I recall. You could do this with a script, though.


First off the small one - can we get something like isShowDamageWhenDecorative() for weaponSpecAPI, it'd be a nice shorthand for seeing if something is a deco that actually needs to be replaced (and is kinda wierd that isRenderAboveAllWeapons() is a thing but this isn't, I guess no one's asked for it beore?)

Just an oversight; added that in.

And the big one - clearing decorative slots and replacing the weapon in them seems to completely break / ignore render order.

deco weapon replacement code
Code
        for (WeaponAPI weapon : ship.getAllWeapons()) {

            String weapslot = weapon.getSlot().getId();
            String weapid = weapon.getId();
            ShipVariantAPI variant = ship.getMutableStats().getVariant();

            boolean hasSwapped = weapid.contains(prefix); //prefix for weapon graphics & names

            boolean isBlinker = weapid.contains("blinker"); //checks for "not armour deco" stuff start
            boolean isGlow = weapid.contains("glow") || weapid.contains("light");
            boolean isEmpCore = weapid.contains("empcore");
            boolean isShadow = weapid.contains("shadow");//checks end

            if (weapon.getSlot().isDecorative() && !hasSwapped && !isBlinker && !isEmpCore && !isGlow && !isShadow) {
                variant.clearSlot(weapslot);
                variant.addWeapon(weapslot, prefix + weapid);
            }
        }
[close]

This swaps all non-painted deco weaps that have replacements to their painted equivalents, but somewhere along the way it also seems to completely break the render order of the replaced weaps, despite not touching it at all.
It's also got the wierd side effect of keeping the broken render order between removing the hullmod and fully stripping the ship, though I'm assuming that's because I never readd the unpainted decos (?)

no hullmod, shadow & covers are over guns
(https://cdn.discordapp.com/attachments/824910699415207937/940048032026746930/screenshot258.png)
[close]
with paintjob, shadows are over gun but covers are below
(https://cdn.discordapp.com/attachments/824910699415207937/940048032337104896/screenshot256.png)
[close]
after removing paintjob, before stripping the ship, same as image 2
(https://cdn.discordapp.com/attachments/824910699415207937/940048031741542440/screenshot257.png)
[close]

Safarijohn suggested saving the variant then stripping it & putting it all back in code, but that seems too complicated for me (and this feels like a bug so I thought I'd ask here as well), honestly I'm hoping I just overlooked something obvious

Hmm - mainly I'm amazed that this works at all, not that it breaks somewhat. Once a ship exists, changes to the variant are not going to be reflected in the ship - all of the weapons etc for the ship have been created, so changing the variant should have at best no effect. Or, at worst, it might break things if some ship code expects the variant to still match what the ship was created from.


Is there a way to manually spawn custom objectives during a battle?
I want to make a station battle with gimmick of taking over objectives to make station weaker.

Hmm, I don't think you can do this *during* a battle. But you could provide your own version of BattleCreationPluginImpl for a specific battle that would add the objectives you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on February 09, 2022, 02:40:37 PM
I'm trying to use the SettingsAPI loadJSON method. To test it, I tried loading my mod's "mod_info.json" with the console command "runcode org.json.JSONObject data = Global.getSettings().loadJSON("mod_info.json", "better_variants");", "better_variants" being the id of my mod. The problem is that this line of code throws a nullpointer exception. Any clue what I what I might be doing wrong?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2022, 02:47:36 PM
Seeing the actual stack trace would help here - I forget, does console commands print it? I'd kind of expect that it would...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 11, 2022, 08:17:23 AM


<my post>


Hmm - mainly I'm amazed that this works at all, not that it breaks somewhat. Once a ship exists, changes to the variant are not going to be reflected in the ship - all of the weapons etc for the ship have been created, so changing the variant should have at best no effect. Or, at worst, it might break things if some ship code expects the variant to still match what the ship was created from.

You were right to be amazed that it worked, it straight up didn't lmao
I've got the base sprite being replaced and I completely forgot to make sure the weapons were actually getting replaced, after checking for that I found out that the slots would get cleared but not refilled by addweapon().
It seems odd that addweapon() works for the thing that inspired this venture (apex design collective's variable warheads (https://github.com/theDragn/ApexDesignCollective/blob/main/jars/src/data/hullmods/ApexVariableWarheads.java)) and not this, the "only" differences I can see are a normal weap vs a deco weap being replaced & the slot initially being empty in the .ship file (this is where I think its going wrong - I did a test w/ replacing all weaps and it would clear the builtin but not add it back)

at the same time as all this I moved all the swapping into applyEffectsBeforeShipCreation() (due to probably misunderstanding your comment) and it seems to work the same, right down to not working in the same way :')

before creation deco swapper
Code
        ShipVariantAPI variant = stats.getVariant();
        ShipVariantAPI variantClone = variant.clone();

        for (WeaponSlotAPI slot : variantClone.getHullSpec().getAllWeaponSlotsCopy()) {

            String slotid = slot.getId();
            String replacementWeapId = variantClone.getWeaponId(slotid);

            if (replacementWeapId == null) {
                continue;
            }

            boolean hasSwapped = !replacementWeapId.contains(prefix);

            boolean isBlinker = !replacementWeapId.contains("blinker"); //checks for "not armour deco" stuff start
            boolean isGlow = !(replacementWeapId.contains("glow") || replacementWeapId.contains("light"));
            boolean isEmpCore = !replacementWeapId.contains("empcore");
            boolean isShadow = !replacementWeapId.contains("shadow");

            if (slot.isDecorative() && hasSwapped && isBlinker && isGlow && isEmpCore && isShadow) {
                variant.clearSlot(slotid);
                variant.addWeapon(slotid, prefix + replacementWeapId);
            }
        }
[close]
hopefully this makes sense, I've been bashing my head against this for a bit and I'm not sure if I'm getting anywhere
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 12, 2022, 04:40:57 PM
I have a hullmod that boosts the range of energy weapons.   I want to also give a chance of causing a flameout on each engine when firing any large energy weapon when flux is above 50%.   How is the best way to implement this?  Can it be done as part of the hullmod or does it need to be linked to something else that captures when a large energy weapon is fired by a ship that has this hullmod?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on February 13, 2022, 09:04:44 AM
Currently I'm using the code below to add a hull of a specific variant to AI fleets. "variantId" always correspond to some variant specified in a .variant file somewhere. Is cloning the variantAPI necessary here? Also, ships added using this method have missing cr, is there any way to ensure they have an appropriate amount of cr after they get added?

Code
private static void createAndAddVariant(CampaignFleetAPI fleetAPI, String variantId)
{
    System.out.println(variantId);
    FleetMemberAPI ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, Global.getSettings().getVariant(variantId).clone());
    fleetAPI.getFleetData().addFleetMember(ship);
}

Edit: If you're using a script run by reportFleetSpawned from BaseCampaignEventListener you can do fleet.setInflated(true) to prevent autofit. This method appears to be called before the inflater is applied. Something like this
Code
@Override
    public void reportFleetSpawned(CampaignFleetAPI fleet) {
       fleet.setInflated(true);
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 13, 2022, 10:24:04 AM
You were right to be amazed that it worked, it straight up didn't lmao
I've got the base sprite being replaced and I completely forgot to make sure the weapons were actually getting replaced, after checking for that I found out that the slots would get cleared but not refilled by addweapon().
It seems odd that addweapon() works for the thing that inspired this venture (apex design collective's variable warheads (https://github.com/theDragn/ApexDesignCollective/blob/main/jars/src/data/hullmods/ApexVariableWarheads.java)) and not this, the "only" differences I can see are a normal weap vs a deco weap being replaced & the slot initially being empty in the .ship file (this is where I think its going wrong - I did a test w/ replacing all weaps and it would clear the builtin but not add it back)

at the same time as all this I moved all the swapping into applyEffectsBeforeShipCreation() (due to probably misunderstanding your comment) and it seems to work the same, right down to not working in the same way :')
...
hopefully this makes sense, I've been bashing my head against this for a bit and I'm not sure if I'm getting anywhere[/s]

Hmm. It's actually kind of hard to say - there could be some internal reasons why this can't work, but they're not coming to mind right now.

I'd suggest doing something *super* simple - like hardcoding the mod to replace one deco weapon in a specific slot with another - to see if that works at all and if the culprit is somewhere in the replacement logic, or something more fundamental.


I have a hullmod that boosts the range of energy weapons.   I want to also give a chance of causing a flameout on each engine when firing any large energy weapon when flux is above 50%.   How is the best way to implement this?  Can it be done as part of the hullmod or does it need to be linked to something else that captures when a large energy weapon is fired by a ship that has this hullmod?

You probably want to modify the engine flameout chance in your implementation of the HullModEffect.advanceInCombat() method, based on whether any large weapons are firing/flux state/etc. Something along those lines, anyway!


Currently I'm using the code below to add a hull of a specific variant to AI fleets. "variantId" always correspond to some variant specified in a .variant file somewhere. Is cloning the variantAPI necessary here? Also, ships added using this method have missing cr, is there any way to ensure they have an appropriate amount of cr after they get added?

Code
private static void createAndAddVariant(CampaignFleetAPI fleetAPI, String variantId)
{
    System.out.println(variantId);
    FleetMemberAPI ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, Global.getSettings().getVariant(variantId).clone());
    fleetAPI.getFleetData().addFleetMember(ship);
}

Why not use the alternate version of FactoryAPI.createFleetMember() that takes a variantId as the second parameter?

For CR: you'd need to set it using FleetMemberAPI.getRepairTracker().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: hqz on February 16, 2022, 04:14:50 AM
Is there a way to mod the list of starting ships options when starting a new game?

And is there a way to disable (or mod away) the slipstreams? I found a reference to com.fs.starfarer.api.impl.campaign.velfield.SlipstreamTerrainPlugin2 in data/campaing/terrain.json but I'm not sure how this works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 17, 2022, 11:30:43 AM
Is there a way to mod the list of starting ships options when starting a new game?

Look at data/campaign/rules.csv under the "new game options" portion and also be sure to reference the scripts it calls. I know its either in rules itself or in one of the scripts that rules calls. I'm 80% sure its in rules itself though.

You can add a rule by the same name with a higher score to override the vanilla rule and then set what ships you want. Keep in mind that this won't work when running Nex.

I highly recommend SafariJohn's Rule Tool (https://fractalsoftworks.com/forum/index.php?topic=13976.0) if you are going to mess with rules in any capacity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: hqz on February 17, 2022, 04:20:25 PM
Look at data/campaign/rules.csv under the "new game options" portion and also be sure to reference the scripts it calls. I know its either in rules itself or in one of the scripts that rules calls. I'm 80% sure its in rules itself though.

You can add a rule by the same name with a higher score to override the vanilla rule and then set what ships you want. Keep in mind that this won't work when running Nex.

I highly recommend SafariJohn's Rule Tool (https://fractalsoftworks.com/forum/index.php?topic=13976.0) if you are going to mess with rules in any capacity.

Thanks. This is super helpful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on February 17, 2022, 06:06:34 PM
I'm trying to disable autofit for ai fleets. First of all, is there a simple way of doing this (ie calling some method)? If not, when do ships in ai fleets get autofit applied to them? I'm using this method to build fleets and they still end up with autofit.

Code

private static void createAndAddVariant(CampaignFleetAPI fleetAPI, String variantId)
{
      FleetMemberAPI ship = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variantId);
      fleetAPI.getFleetData().addFleetMember(ship);
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 18, 2022, 09:30:48 AM
And is there a way to disable (or mod away) the slipstreams? I found a reference to com.fs.starfarer.api.impl.campaign.velfield.SlipstreamTerrainPlugin2 in data/campaing/terrain.json but I'm not sure how this works.

IIRC you'd want to remove the SlipstreamManager via something like Global.getSector().removeScriptsOfClass(SlipstreamManager.class)

(Probably not exactly, just typing this from memory.)

You'd need to do it onGameLoad().


I'm trying to disable autofit for ai fleets. First of all, is there a simple way of doing this (ie calling some method)? If not, when do ships in ai fleets get autofit applied to them? I'm using this method to build fleets and they still end up with autofit.

I think it should be as simple as:
fleet.setInflater(null);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: default on February 18, 2022, 11:08:20 AM
I was looking through mod files to see how different mods are organized and function so I can get an idea of how I want mine to be set up, and I have a few questions.
First, why do some mods have a "shaders" folder with a material, normal, and surface folder which have different looking images? The "normal" ones look very odd. Is there a function reason for this, or is it preference?
Second, How would I go about making my own engine style? I know other mods have their own engine flare colors/styles, but I can't seem to find where any of them are in mod files so I would be able to infer what to do or what to name the image. Then after the new engine style is created, what would I have to do in the ship editor to actually apply it to my ships?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 20, 2022, 12:36:12 AM
Say there's a battle where you deploy a ship several times over multiple engagements. Is there a way to determine how many times you did so?
Is reportPlayerEngagement basically this as far as returning individual engagements during a battle?
yep thats it, hurray for experimentation
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 20, 2022, 05:33:21 AM
I was looking through mod files to see how different mods are organized and function so I can get an idea of how I want mine to be set up, and I have a few questions.
First, why do some mods have a "shaders" folder with a material, normal, and surface folder which have different looking images? The "normal" ones look very odd. Is there a function reason for this, or is it preference?
Second, How would I go about making my own engine style? I know other mods have their own engine flare colors/styles, but I can't seem to find where any of them are in mod files so I would be able to infer what to do or what to name the image. Then after the new engine style is created, what would I have to do in the ship editor to actually apply it to my ships?

Material, normal, and surface maps are used by the GraphicsLib mod's shader engine. Normal maps let a flat surface pretend to be 3D when calculating lighting.

Engine styles are defined in data/config/engine_styles.json. I have always found it easier to manually set custom engine styles, but I think you can load them into the ship editor using Load Custom (M)od Data and then set each engine to your style by editing its de(T)ails.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: default on February 20, 2022, 08:57:46 AM
Material, normal, and surface maps are used by the GraphicsLib mod's shader engine. Normal maps let a flat surface pretend to be 3D when calculating lighting.

So it's not something that has to be done, it's just if you want things to look better?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 20, 2022, 09:21:05 AM
Correct. I usually use ModLab to quickly generate my normal maps. https://store.steampowered.com/app/768970/ModLab/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on February 21, 2022, 11:43:07 AM
Is there any way to set an unofficered ship's personality before battle? The ai of unofficered ships get set "in combat" so any changes made using setPersonality on unofficered ships before battle seems to get overridden. If not, would a every frame combat script that run setPersonality on the PersonAPI's of relevant ships work? CombatFleetManagerAPI setDefaultCommander also seems promising.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on February 21, 2022, 01:08:30 PM
If not, would a every frame combat script that run setPersonality on the PersonAPI's of relevant ships work?

It should, yes. I do this with a couple of my ship system AIs and those are EveryFrameCombatScripts iirc. They at least work very similarly in function.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cptdash on February 21, 2022, 08:23:38 PM
Hello,
I have been investigating mod options for adding additional quests to the bar. As a basic start, I wanted to play around with the mission frequency of the CheapCommidityMission. I attempted the following changes:

bar_events.csv - changing 'freq' to 9999 and 99999999999 for cheapCom entry -- no change in quest frequency
bar_events.csv - adding 'priority' tag to cheapCom entry -- no change in frequency
bar_events.csv - duplicating cheapCom entry to add cheapCom2-cheapCom30 entries -- no change in frequency
person_missions.csv - adding cheapCom2-cheapCom30 entries duplicated off original cheapCom -- no change in frequency
rules.csv - duplicating table entries for cheapCom, changing 'id' column names to cheapCom2-30 -- no change in frequency

All changes were tested by starting a new game and visiting at least 15 stations. Usually I only found 1 quest of the cheapCom variety.
Am I missing something, or is the logic for quest frequency expanded somewhere else?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 22, 2022, 01:40:58 AM
Is there anything similar to ShipAPI.isDefenseDisabled() but for Ship Systems?

I notice there is something for ShipAPI.setShipSystemDisabled(boolean), and I'm just curious if the AI script I'm coding should be running if for some reason the ship has its ship systems disabled.

Also, is there a getControlStringForEnumName for something like Hold Fire.. I can't seem to find any mentions of this enum anywhere...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 23, 2022, 04:48:48 PM
Is there something i'm missing to get the maximum number of elite skills the players officers can have?

      MutableCharacterStatsAPI playerStats = Global.getSector().getPlayerFleet().getFleetData().getCommander().getStats();
      int maxElite = (int)Global.getSettings().getInt("officerMaxEliteSkills") + (int)playerStats.getDynamic().getValue(Stats.OFFICER_MAX_ELITE_SKILLS_MOD);

Doing this returns two, but the character has Cybernetic Augmentation + Officer Training, so it should be 4..
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 23, 2022, 05:35:40 PM
ello,
I have been investigating mod options for adding additional quests to the bar. As a basic start, I wanted to play around with the mission frequency of the CheapCommidityMission. I attempted the following changes:

bar_events.csv - changing 'freq' to 9999 and 99999999999 for cheapCom entry -- no change in quest frequency
bar_events.csv - adding 'priority' tag to cheapCom entry -- no change in frequency
bar_events.csv - duplicating cheapCom entry to add cheapCom2-cheapCom30 entries -- no change in frequency
person_missions.csv - adding cheapCom2-cheapCom30 entries duplicated off original cheapCom -- no change in frequency
rules.csv - duplicating table entries for cheapCom, changing 'id' column names to cheapCom2-30 -- no change in frequency

All changes were tested by starting a new game and visiting at least 15 stations. Usually I only found 1 quest of the cheapCom variety.
Am I missing something, or is the logic for quest frequency expanded somewhere else?

Offhand, that seems like it should work, but it's possible that there simply isn't a "cheap commodity" mission available at that particular colony - iirc it requires a local surplus of a legal commodity. I'd try changing the frequency on some of the other missions to see if it works for those.

Is there anything similar to ShipAPI.isDefenseDisabled() but for Ship Systems?

I notice there is something for ShipAPI.setShipSystemDisabled(boolean), and I'm just curious if the AI script I'm coding should be running if for some reason the ship has its ship systems disabled.

No and no. The system would be disabled if the ship's CR is 0%, btw, but then it wouldn't work at all regardless of if the AI tried to use it.

Also, is there a getControlStringForEnumName for something like Hold Fire.. I can't seem to find any mentions of this enum anywhere...

Should be SHIP_HOLD_FIRE I believe.

Is there something i'm missing to get the maximum number of elite skills the players officers can have?

      MutableCharacterStatsAPI playerStats = Global.getSector().getPlayerFleet().getFleetData().getCommander().getStats();
      int maxElite = (int)Global.getSettings().getInt("officerMaxEliteSkills") + (int)playerStats.getDynamic().getValue(Stats.OFFICER_MAX_ELITE_SKILLS_MOD);

Doing this returns two, but the character has Cybernetic Augmentation + Officer Training, so it should be 4..

You want:
(int) stats.getDynamic().getMod(Stats.OFFICER_MAX_ELITE_SKILLS_MOD).computeEffective(0);
To get the bonus from skills, instead of getValue().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on February 24, 2022, 10:22:14 AM
Where do missiles get associated with their AI scripts? Can't see anything in weapon_data, weapon definitions or projectile definitions. Am I blind?  :o I'm trying to make custom missiles that have vanilla locust AI and are spawned in using CombatEngineAPI instead of a weapon. (it would seem I still need to define fake weapons?) I know there's a way to change missile AI script, but how do I get the name of the vanilla class locust uses?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 24, 2022, 10:24:31 AM
See: ModPlugin.pickMissileAI() for how you might specify a custom AI.

But, the locust uses the standard missile AI that's used for all of the "missileType":"MISSILE", missiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on February 24, 2022, 10:37:00 AM
But, the locust uses the standard missile AI that's used for all of the "missileType":"MISSILE", missiles.

Does that mean that just defining a missile projectile with turn speed etc specified will make it behave like locust/harpoon/swarmer/etc? If yes, than the question becomes "how do I change a missile's target from outside its AI script". What I want is basically spawn in a missile with the default guided AI, give it a specific target to chase, and have it revert to default behaviour (choosing new target) if my target is unavailable. I know there's getUnwrappedMissileAI, but then I need to know the name of the vanilla class and whatever its "setTarget" method is called, if it exists?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 24, 2022, 10:41:46 AM
There's a GuidedMissileAI interface. You could do something like:
if (missile.getAI() instanceof GuidedMissileAI) {
    ((GuidedMissileAI)missile.getAI()).setTarget(...)
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on February 24, 2022, 10:46:52 AM
There's a GuidedMissileAI interface. You could do something like:
if (missile.getAI() instanceof GuidedMissileAI) {
    ((GuidedMissileAI)missile.getAI()).setTarget(...)
}

Sounds exactly like what I wanted, thank you.  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on February 24, 2022, 10:59:35 PM
Is there a way to change the hiring cost of crew, or otherwise make them unpurchasable at markets (only by capture or looting)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 25, 2022, 07:22:37 PM
You want:
(int) stats.getDynamic().getMod(Stats.OFFICER_MAX_ELITE_SKILLS_MOD).computeEffective(0);
To get the bonus from skills, instead of getValue().
Aha, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2022, 08:35:01 PM
Is there a way to change the hiring cost of crew, or otherwise make them unpurchasable at markets (only by capture or looting)?

There's a "price" column in commodities.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on February 26, 2022, 09:31:54 AM
Is there a way to make sure autofit doesn't fit a given weapon (but the player and variants still can)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 26, 2022, 09:52:00 AM
Nothing that immediately comes to mind, short of a custom fleet inflater.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 26, 2022, 10:09:17 AM
What influences derelict drop rates?

I can have 1 mod with 20 ships and 1 mod with 5 ships.

And the 1 mod with 5 ships will spawn derelict more in sectorgen.. what am I missing? The value? The default_ship_roles.json? I'm kinda confused what directly affects it so much.

Alternatively is there a way for me to exclude certain ships from derelict drops for SectorGen then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cptdash on February 26, 2022, 08:45:54 PM
I am trying to remove the original DeliveryBarEventCreator instance (as I have created several of my own). In my BaseModPlugin, I am attempting to view/remove the instance of DeliveryBarEventCreator.class from the BarEventManager:


Quote
if (barEventManager.hasEventCreator(DeliveryBarEventCreator.class))
            {
                log("present:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));     //this shows true, meaning it found it
                int i = barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class);     
                log("index:"+barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class)); //this returns -1, meaning it isn't present
                boolean successRemove = barEventManager.getCreators().remove(DeliveryBarEventCreator.class); //this returns false, meaning it wasn't removed
                barEventManager.getCreators().remove(i); //this crashes the game since it tries to remove an item at index -1
                log("present2:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));
            }

Any thoughts on how to go about this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2022, 10:46:38 AM
What influences derelict drop rates?

I can have 1 mod with 20 ships and 1 mod with 5 ships.

And the 1 mod with 5 ships will spawn derelict more in sectorgen.. what am I missing? The value? The default_ship_roles.json? I'm kinda confused what directly affects it so much.

Alternatively is there a way for me to exclude certain ships from derelict drops for SectorGen then?

See: BaseThemeGenerator.addDerelictShip()

Basically derelicts will be picked from the ships of the factions that have a presence nearby, and from a set of default factions otherwise.

Re: excluding certain ships, I don't think so, offhand.

I am trying to remove the original DeliveryBarEventCreator instance (as I have created several of my own). In my BaseModPlugin, I am attempting to view/remove the instance of DeliveryBarEventCreator.class from the BarEventManager:


Quote
if (barEventManager.hasEventCreator(DeliveryBarEventCreator.class))
            {
                log("present:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));     //this shows true, meaning it found it
                int i = barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class);     
                log("index:"+barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class)); //this returns -1, meaning it isn't present
                boolean successRemove = barEventManager.getCreators().remove(DeliveryBarEventCreator.class); //this returns false, meaning it wasn't removed
                barEventManager.getCreators().remove(i); //this crashes the game since it tries to remove an item at index -1
                log("present2:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));
            }

Any thoughts on how to go about this?

The list returned by getCreators() doesn't contain objects of type Class. Rather, it contains instances of the various bar event creators. So you want to iterate over that list and check whether each element is "instanceof DeliveryBarEventCreator" to find the one you're looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: KPMkiller on February 27, 2022, 02:11:30 PM
Is there any way to change the values that gamma/beta/alpha AI cores give to the industries they are attached to? I am no modder, but I have poked my head with Notepad++ everywhere but java files to no avail; the closest I seen them change/be different was as part of a Colonies related mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 27, 2022, 06:46:35 PM
The script for each industry specifies the effects of AI cores on it. So, yes, you have to get into java coding to modify that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on February 28, 2022, 03:44:37 AM
(Also note that such modification would be mutually exclusive with the likes of Industrial Evolution unless you get really complicated to make it compatible.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: spaceman256 on February 28, 2022, 05:55:42 AM
Hello, I am relatively new to modding. I want to add the special colony items to a supply cache, but it doesn't work.
My code:

SectorEntityToken special_sc1 = system.addCustomEntity("specialcache1",
          "Special Supply Cache",
          "supply_cache",
          null);
   special_sc1.setCircularOrbitPointingDown(gaia9planet, 280, 300, 365);
CargoAPI specialsc1salvage = Global.getFactory().createCargo(true);
   specialsc1salvage.addCommodity(Commodities.GAMMA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.BETA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.ALPHA_CORE, 2);
   BaseSalvageSpecial.addExtraSalvage(specialsc1salvage, special_sc1.getMemoryWithoutUpdate(), -1);

The supply cache and ai cores will spawn as intended, however trying to add special colony items will always crash the game. What do I need to import and what should the code be?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: cptdash on February 28, 2022, 10:17:37 AM

I am trying to remove the original DeliveryBarEventCreator instance (as I have created several of my own). In my BaseModPlugin, I am attempting to view/remove the instance of DeliveryBarEventCreator.class from the BarEventManager:


Quote
if (barEventManager.hasEventCreator(DeliveryBarEventCreator.class))
            {
                log("present:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));     //this shows true, meaning it found it
                int i = barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class);     
                log("index:"+barEventManager.getCreators().indexOf(DeliveryBarEventCreator.class)); //this returns -1, meaning it isn't present
                boolean successRemove = barEventManager.getCreators().remove(DeliveryBarEventCreator.class); //this returns false, meaning it wasn't removed
                barEventManager.getCreators().remove(i); //this crashes the game since it tries to remove an item at index -1
                log("present2:"+barEventManager.hasEventCreator(DeliveryBarEventCreator.class));
            }

The list returned by getCreators() doesn't contain objects of type Class. Rather, it contains instances of the various bar event creators. So you want to iterate over that list and check whether each element is "instanceof DeliveryBarEventCreator" to find the one you're looking for.

I appreciate the quick responses! I tried your recommendation, which doesn't give any errors but still doesn't seem to remove the mission type. I am doing this inside the onGameLoad() method of BaseModPlugin, maybe that is occurring before all the bar events are initialized?
Code
            BarEventManager barEventManager = BarEventManager.getInstance();
            Iterator<BarEventManager.GenericBarEventCreator> baritr = barEventManager.getCreators().iterator();
            while (baritr.hasNext())
            {
                BarEventManager.GenericBarEventCreator barevent = baritr.next();
                if (barevent instanceof DeliveryBarEventCreator)
                {
                    baritr.remove();
                }
            }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 02, 2022, 05:02:38 AM
Can a ship (specifically a module on a larger ship) be made non-restorable in refit screen?

Hello, I am relatively new to modding. I want to add the special colony items to a supply cache, but it doesn't work.
My code:

SectorEntityToken special_sc1 = system.addCustomEntity("specialcache1",
          "Special Supply Cache",
          "supply_cache",
          null);
   special_sc1.setCircularOrbitPointingDown(gaia9planet, 280, 300, 365);
CargoAPI specialsc1salvage = Global.getFactory().createCargo(true);
   specialsc1salvage.addCommodity(Commodities.GAMMA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.BETA_CORE, 4);
   specialsc1salvage.addCommodity(Commodities.ALPHA_CORE, 2);
   BaseSalvageSpecial.addExtraSalvage(specialsc1salvage, special_sc1.getMemoryWithoutUpdate(), -1);

The supply cache and ai cores will spawn as intended, however trying to add special colony items will always crash the game. What do I need to import and what should the code be?
Code: java
specialsc1salvage.addSpecial(new SpecialItemData("id_in_special_items.csv", "parameter"), 1);
For e.g. a synchrotron, it'd be addSpecial(new SpecialItemData("synchrotron", null), 1); I think
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 02, 2022, 05:53:19 AM
Is there a way to get where a ship's armour grid was just hit from a damageListener? (or any way, for that matter, doesn't have to be in the listener)

I've been trying to make a limited-area armour heal that triggers in response to a high damage hit, but it just doesn't seem possible (with a damageListener) given that the source param is the ship that dealt the damage, not the projectile.

Code
Code
    public static class SDSY_TraumaResponse implements DamageListener {
/*
/ added to a ship by a builtin hullmod's advance()
*/
        @Override
        public void reportDamageApplied(Object source, CombatEntityAPI target, ApplyDamageResultAPI result) {
            log.debug("hit registered");
            if (!(source instanceof DamagingProjectileAPI)) {
                log.debug("what the hell hit me");
                log.debug(source.getClass().getName());
                return;
            }
            log.debug("projectile hit registered");

            ShipAPI ship = (ShipAPI) target;
            ArmorGridAPI grid = ship.getArmorGrid();
            DamagingProjectileAPI sourceProj = (DamagingProjectileAPI) source;

/*
/no idea if below this works, turns out it was never getting used
*/

            if (result.getDamageToPrimaryArmorCell() >= 750f) {
                Vector2f centerCellLoc = sourceProj.getLocation();
                int[] centerCellOngrid = grid.getCellAtLocation(centerCellLoc);
                int cellX = centerCellOngrid[0];
                int cellY = centerCellOngrid[1];
                int amountToHeal = (int) Math.round(result.getDamageToPrimaryArmorCell() * 0.6);
                int[][] cellToHeal = {{cellX, cellY},{amountToHeal}};
                String traumaKey = "trauma_" + ship.getId();
                ship.getCustomData().put(traumaKey, cellToHeal);
            }
        }
    }
[close]

Is there currently any way around this or is it a "not possible at all" kinda thing?
And to turn this into an api request (if it's not doable already) - something like getImpactLoc or getPrimaryArmourCellLoc to return where the damage was applied in engine coords would be v useful in applyDamageResultAPI (or something similar). 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: spaceman256 on March 02, 2022, 07:32:53 AM

Code: java
specialsc1salvage.addSpecial(new SpecialItemData("id_in_special_items.csv", "parameter"), 1);
For e.g. a synchrotron, it'd be addSpecial(new SpecialItemData("synchrotron", null), 1); I think

Thank you! Everything works perfectly now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on March 03, 2022, 02:17:46 PM
I'm looking to change a portrait between four variants based on the in-game month, how would I go about doing so, if possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 03, 2022, 03:18:50 PM
Can a ship (specifically a module on a larger ship) be made non-restorable in refit screen?

Aside from "it not having d-mods", I don't believe so. Let me add an "unrestorable" tag to hulls and variants.


Is there a way to get where a ship's armour grid was just hit from a damageListener? (or any way, for that matter, doesn't have to be in the listener)

Hmm, I don't think so, no.

Is there currently any way around this or is it a "not possible at all" kinda thing?
And to turn this into an api request (if it's not doable already) - something like getImpactLoc or getPrimaryArmourCellLoc to return where the damage was applied in engine coords would be v useful in applyDamageResultAPI (or something similar).

You might be able to add a DamageTakenModifier or a HullDamageAboutToBeTakenListener to the target (or to the combat engine); that gets you a point parameter. Which you might save to refer to in the subsequent call to the damage listener.


I'm looking to change a portrait between four variants based on the in-game month, how would I go about doing so, if possible?

Apologies if I'm misunderstanding something, but: an every frame script and PersonAPI.setPortraitSprite()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on March 03, 2022, 03:33:02 PM
I'm looking to change a portrait between four variants based on the in-game month, how would I go about doing so, if possible?

Apologies if I'm misunderstanding something, but: an every frame script and PersonAPI.setPortraitSprite()?
I was thinking something less intensive, like how production only occurs once a month, but thanks!
(Also I don't know how to check the in-game month.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 03, 2022, 03:39:02 PM
SectorAPI.   getClock().getMonth()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on March 03, 2022, 03:40:38 PM
SectorAPI.   getClock().getMonth()
Many thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 03, 2022, 04:25:15 PM
I was thinking something less intensive, like how production only occurs once a month, but thanks!
(Also I don't know how to check the in-game month.)

Ah! You could also try implementing an EconomyTickListener, though if you're not doing anything silly in your every frame script, it should be fine. E.G. if you just check the current month to see if it changed, that wouldn't be a performance problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on March 03, 2022, 08:10:32 PM
Is there a way to create a weapon that fires a lightning arc?

Spoiler
Something like the Ziggy's attractor ability visually, but as an energy weapon.

I found this code:

float emp = 0;
float dam = 0;
EmpArcEntityAPI arc = (EmpArcEntityAPI)engine.spawnEmpArc(ship, slotLoc, ship, target,
                        DamageType.ENERGY,
                        dam,
                        emp, // emp
                        100000f, // max range
                        "mote_attractor_targeted_ship",
                        40f, // thickness
                        //new Color(100,165,255,255),
                        MoteControlScript.getEMPColor(ship),
                        new Color(255,255,255,255)
                        );

Can this be modified and used as the script for an energy weapon?  If the source is a weapon mount, will said Arc hit the firing ship and or ships' shields?

[close]


Is there an AI hint for ships to tell them to never retreat?
Is there an AI hint to tell a ship that most of it's weapons are on its sides?  I saw some discussions of a BROADSIDER hint but no idea if if was ever implemented.
Is there a master list of all the AI hints?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 04, 2022, 01:33:26 AM
Is there a way to create a weapon that fires a lightning arc?

look at the vanilla shock repeater, high tech expansion's arc emitters or SWP's lighting gun, they all do this (though the lightning gun has ome funky code to stop it from hitting modules through shields)

Is there an AI hint for ships to tell them to never retreat?
Is there an AI hint to tell a ship that most of it's weapons are on its sides?  I saw some discussions of a BROADSIDER hint but no idea if if was ever implemented.
Is there a master list of all the AI hints?

there's a list of all hints here (https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipHullSpecAPI.ShipTypeHints.html#enum_constant_summary), though the DO_NOT_BACK_OFF hidden hullmod sounds like what you want

You might be able to add a DamageTakenModifier or a HullDamageAboutToBeTakenListener to the target (or to the combat engine); that gets you a point parameter. Which you might save to refer to in the subsequent call to the damage listener.

also a quick edit - thanks for pointing this out to me! I somehow never thought to look at other listeners & I'll probably be able to hack something together out of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on March 04, 2022, 03:58:50 AM
Edit: Holy moly, it just worked! Leaving for future generations.


Sanity check before I am off to coding. I want to make all recoveries (post battle for both player lost ships and enemy salvageable ships) require a story point. Also derelict ships, but that's for another time. The way I want to achieve it is, according to the code:


And then all that is needed is to remove all vanilla implementations (should be one, right?). But how,`GenericPluginManagerAPI` doesn't look like the right candidate. So I also need to replace `CoreCampaignPluginImpl` with my custom one (it would just override `pickInteractionDialogPlugin(SectorEntityToken interactionTarget)` to load my custom `FleetInteractionDialogPluginImpl`, otherwise call `super.pickInteractionDialogPlugin(SectorEntityToken interactionTarget)`? In which case I just `unregisterPlugin("coreCampaignPluginImpl")` and `registerPlugin` with my custom `CoreCampaignPluginImpl` (doesn't matter if called on `SectorAPI` or `GenericPluginManagerAPI`, right?).

I was looking at PickPriority enum, and I THINK I could do the same without replacing vanilla `CoreCampaignPluginImpl`, just by adding a new `BaseCampaignPlugin` implementation that only  overrides `pickInteractionDialogPlugin(SectorEntityToken interactionTarget)` and returns my custom `FleetInteractionDialogPluginImpl` with higher `PickPriority` than vanilla, and null otherwise...

Edit: Well, it took me LONGER to write this post that it took me to write the code. Might as well show what I intend:

Code
public class StarpocalypseFleetEncounterContext extends FleetEncounterContext {

    private List<FleetMemberAPI> recoverableShips = new LinkedList<>();
    private List<FleetMemberAPI> storyRecoverableShips = new LinkedList<>();

    @Override
    public List<FleetMemberAPI> getRecoverableShips(
        BattleAPI battle,
        CampaignFleetAPI winningFleet,
        CampaignFleetAPI otherFleet
    ) {
        recoverableShips.clear();
        recoverableShips.addAll(super.getRecoverableShips(battle, winningFleet, otherFleet));
        storyRecoverableShips.clear();
        storyRecoverableShips.addAll(super.getStoryRecoverableShips());
        return Collections.emptyList();
    }

    @Override
    public List<FleetMemberAPI> getStoryRecoverableShips() {
        List<FleetMemberAPI> allShips = new LinkedList<>();
        allShips.addAll(recoverableShips);
        allShips.addAll(storyRecoverableShips);
        int cutOff = Math.min(23, allShips.size());
        return allShips.subList(0, cutOff);
    }
}
Code
public class StarpocalypseFleetInteractionDialogPlugin extends FleetInteractionDialogPluginImpl {

    public StarpocalypseFleetInteractionDialogPlugin() {
        this(null);
    }

    public StarpocalypseFleetInteractionDialogPlugin(FIDConfig params) {
        super(params);
        context = new StarpocalypseFleetEncounterContext();
    }
}
Code
public class StarpocalypseCampaignPlugin extends BaseCampaignPlugin {

    @Override
    public String getId() {
        return "starpocalypseCampaignPlugin";
    }

    @Override
    public PluginPick<InteractionDialogPlugin> pickInteractionDialogPlugin(SectorEntityToken interactionTarget) {
        if (interactionTarget instanceof CampaignFleetAPI) {
            return new PluginPick<InteractionDialogPlugin>(
                new StarpocalypseFleetInteractionDialogPlugin(),
                PickPriority.MOD_GENERAL
            );
        }
        return super.pickInteractionDialogPlugin(interactionTarget);
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amoebka on March 04, 2022, 07:53:37 AM
Is there a way to permanently recolor engines? I know there's ShipEngineControllerAPI.fadeToOtherColor(...), but it's not instant, has to be called every frame, and doesn't allow to adjust glow size.

I've tried:
Code
for (ShipEngineControllerAPI.ShipEngineAPI engine : missile.getEngineController().getShipEngines()) {
                    engine.getEngineSlot().setColor(color_engine);
                    engine.getEngineSlot().setContrailColor(color_trail);
                    engine.getEngineSlot().setGlowAlternateColor(color_engine);
                    engine.getEngineSlot().setGlowSizeMult(1f + missile.getDamage().getDamage() / 1500f);
            }
..but it doesn't do anything at all. What are those methods even for then?  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 04, 2022, 02:32:26 PM
dose anyone know were the available crew, supplies, and heavy machinery for surveying is calculated? I want to make code that edits said values, but am finding it very difficult to find.
i have already looked at the SurveyPlugin but it looks like that only deals with the cost of a survey, not what is available.
i would also like the ability to run code when the 'preform survey' button is clicked successfully, but also have no idea how such code might be implemented.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 05, 2022, 12:19:09 PM
does  ShipAPI CustomData persist between engagements?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 05, 2022, 12:31:52 PM
Is there an AI hint to tell a ship that most of it's weapons are on its sides?

No; the ships make that determination based on the weapons that are mounted on them.

Is there a way to permanently recolor engines? I know there's ShipEngineControllerAPI.fadeToOtherColor(...), but it's not instant, has to be called every frame, and doesn't allow to adjust glow size.

Aside from that, no.  You *can* also adjust the glow size; see the implementation of SafetyOverrides for details.

dose anyone know were the available crew, supplies, and heavy machinery for surveying is calculated? I want to make code that edits said values, but am finding it very difficult to find.
i have already looked at the SurveyPlugin but it looks like that only deals with the cost of a survey, not what is available.
i would also like the ability to run code when the 'preform survey' button is clicked successfully, but also have no idea how such code might be implemented.

See: SurveyPluginImpl (and also, "surveyPlugin" in settings.json).

Edit: ah - this is called from core code, so if you're trying to modify *that*, you can't. But you could e.g. reduce the costs by providing a different implementation of the plugin that provides lowered requirements.

does  ShipAPI CustomData persist between engagements?

No. ShipAPI objects also do not persist between engagements.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 05, 2022, 03:04:38 PM
Quote
See: SurveyPluginImpl (and also, "surveyPlugin" in settings.json).

Edit: ah - this is called from core code, so if you're trying to modify *that*, you can't. But you could e.g. reduce the costs by providing a different implementation of the plugin that provides lowered requirements.
well its nice to know for sure that I can call off my search. was kind of hoping to find that I could find the other parts of survey plugin so i could do some things to it, but ill make do.
thank you regardless.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 05, 2022, 04:33:03 PM
Hmm, I'm beginning to get the impression that it's impossible to change Termination Sequence without writing a custom AI?

It relies upon DroneStrikeStatsAIInfoProvider and I get a nullpointer whenever I put the ship under AI control. It works fine when manually firing the system.

All I'm doing is extending DroneStrikeStats to override the weapon id in order to change speed and damage values in the weapon spreadsheet:

Code
package data.scripts.shipsystems;

import com.fs.starfarer.api.impl.combat.DroneStrikeStats;
import com.fs.starfarer.api.impl.combat.DroneStrikeStatsAIInfoProvider;

public class ArcheanDroneStrikeStats extends DroneStrikeStats implements DroneStrikeStatsAIInfoProvider {
@Override
protected String getWeaponId() {
return "archean_terminator_missile";
}
}

Checking out the implementation it doesn't look like anything is specifically hardcoded that would cause a nullpointer with this change. The attached drone wing of the ship is a different id, but it seems like the system itself just gets the attached wings in launch bays. If it works in vanilla, then it stands to reason that it should work here unless something is going on in the AI script that the extension isn't providing. That could only be two things.

Since system AIs aren't exposed afaik, are there hardcoded ids in the AI script that would cause a nullpointer if a different wing or weapon id is attached to DroneStrikeStats when the AI is engaged?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on March 05, 2022, 06:41:48 PM
Hmm, I'm beginning to get the impression that it's impossible to change Termination Sequence without writing a custom AI?

It relies upon DroneStrikeStatsAIInfoProvider and I get a nullpointer whenever I put the ship under AI control. It works fine when manually firing the system.

All I'm doing is extending DroneStrikeStats to override the weapon id in order to change speed and damage values in the weapon spreadsheet:

Code
package data.scripts.shipsystems;

import com.fs.starfarer.api.impl.combat.DroneStrikeStats;
import com.fs.starfarer.api.impl.combat.DroneStrikeStatsAIInfoProvider;

public class ArcheanDroneStrikeStats extends DroneStrikeStats implements DroneStrikeStatsAIInfoProvider {
@Override
protected String getWeaponId() {
return "archean_terminator_missile";
}
}

Checking out the implementation it doesn't look like anything is specifically hardcoded that would cause a nullpointer with this change. The attached drone wing of the ship is a different id, but it seems like the system itself just gets the attached wings in launch bays. If it works in vanilla, then it stands to reason that it should work here unless something is going on in the AI script that the extension isn't providing. That could only be two things.

Since system AIs aren't exposed afaik, are there hardcoded ids in the AI script that would cause a nullpointer if a different wing or weapon id is attached to DroneStrikeStats when the AI is engaged?

It shouldn't be. Iron Shell's Courageous uses the exact same code as Terminator and has a copied version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 05, 2022, 07:40:41 PM
*EDIT2 - SOLVED*

It looks like its from the "attack_at_an_angle" tag in the wing_data spreadsheet being added to the drones that the system uses. For whatever reason that caused the nullpointer when activating the Termination Sequence system without a target selected.

It works now both under AI control with the vanilla AI script and when manually fired.

Original Issue:

It shouldn't be. Iron Shell's Courageous uses the exact same code as Terminator and has a copied version.

Ok thanks it must be something else then. I originally tried replacing everything but the AI script and I was still getting nullpointers, so I reduced the override to just the duplicated weapon id to see if that would fix it. I'll double check the new weapon itself to make sure I didn't inadvertently forget something and go from there.

It's possible that the error is coming from the system itself as well, but I thought I was very thorough with that part of it and that seems unlikely since manually using the system works. Hmm. Well, the only thing to do is continue to test and isolate the changes to see where its coming from.

*EDIT*

Well, I get this when I manually activate the system without a target selected:

Code
232117 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.ai.movement.maneuvers.AttackRunManeuver.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.int$o.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.int.super(Unknown Source)
at com.fs.starfarer.combat.ai.FighterAI.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

If I have a target selected, it works as intended. Any idea what this could be from Alex? I can provide the drone implementation if that helps. I'll keep testing in the meantime.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on March 10, 2022, 01:35:22 AM
 how does

OfficerManagerEvent.pickSkill(PersonAPI person, java.util.List<java.lang.String> skills, OfficerManagerEvent.SkillPickPreference pref, int numSpec, java.util.Random random)

 work? does it actually give the officer you pass in as an argument a skill? It returns a string so I assumed it just gives you an id, but I have been running into an issue if I increase the skill level using the returned id with MutableCharacterStats.IncreaseSkill(), the skill is always elite level, instead of the basic skill.

Also, what does numSpec argument do?


Code Snippet:
Code
					List<String> validSkills = new ArrayList<String>();
validSkills.add(Skills.COMBAT_ENDURANCE);
validSkills.add(Skills.HELMSMANSHIP);
validSkills.add(Skills.ENERGY_WEAPON_MASTERY);
validSkills.add(Skills.BALLISTIC_MASTERY);
validSkills.add(Skills.FIELD_MODULATION);
validSkills.add(Skills.TARGET_ANALYSIS);
validSkills.add(Skills.IMPACT_MITIGATION);
validSkills.add(Skills.DAMAGE_CONTROL);
///we get the skill id..?
String newSkill = OfficerManagerEvent.pickSkill(pilot,validSkills,OfficerManagerEvent.SkillPickPreference.YES_ENERGY_YES_BALLISTIC_YES_MISSILE_YES_DEFENSE,0, new Random());

// ... i cut out some logic here. basically it checks if personAPI already has the skill to prevent them going over the elite skill cap, but the below else always seems to fire instead, so might as well leave it out
else
{
Global.getSector().getCampaignUI().addMessage("Pilot, callsign \""+ callsign + "\" learned " + skillName +"!",Misc.getHighlightColor());
stats.increaseSkill(newSkill);
stats.setLevel(stats.getLevel()+1);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2022, 09:26:20 AM
Hmm - unless I'm missing some aspect of the question, you can actually see what this method does - the OfficerManagerEvent class implementation is in the starfarer.api.zip file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on March 10, 2022, 10:18:42 AM
So, I'm looking at implementing a planetary condition (extends BaseMarketConditionPlugin) that has variable effects depending on stuff the player can mess about with.

The mechanical implementation of this is fine.

Where I'm having issues is the tooltip - the game seems to create it once, cache the result, and not update it until the player has left the planet and returned.

Is there a way to say "Hey, invalidate your existing tooltip please?" or am I going to have to resort to shenanigans?

(Shenanigans: a reasonable description of an implementation that splits the condition into an invisible one that does all the work, and a visible one that gets removed and replaced every time anything changes. I also tried hanging onto the most-recently-passed-in TooltipMakerAPI object, but that particular method doesn't quite work right for reasons I do not currently understand.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2022, 11:09:38 AM
You're overriding the MarketConditionPlugin.createTooltip() method, right? That should get called every frame the tooltip is up, so there shouldn't be any problem with it being out of date somehow. I'm not even sure how what you're describing would be possible, actually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on March 10, 2022, 11:20:04 AM
Huh. Nope, I was overriding createTooltipAfterDescription. I'll change that, see if that fixes it.

Edit: And after much fuss about adding debug logging, suddenly it works. And then I removed the debug logging... and it still works. I am now very confused, and will post back here again later if I manage to break it again. Bizarre.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on March 10, 2022, 01:42:57 PM
is there any way to check if a ship system is affected by the "MutableShipStatsAPI.getSystemUsesBonus" stat inside of a hullmod's applyEffectsBeforeShipCreation without a hacky workaround like this?

Code
private boolean doesSystemHaveUses(ShipSystemSpecAPI spec, MutableShipStatsAPI stats) {
        boolean hasUses = false;
       
        stats.getSystemUsesBonus().modifyFlat("systemUses", 1);
       
        if(spec.getMaxUses(stats) > 1) {
            hasUses = true;
        }
       
        stats.getSystemUsesBonus().unmodify("systemUses");
       
        return hasUses;
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 11, 2022, 07:57:47 AM
You could do something like:
spec.getMaxUses(null) < 10000
Or some suitably high number. But what you're doing is pretty fine too; there are some cases in core code where it uses a similar approach to infer some things. I'd make sure the ID for the stat change you're making is a little more unique - maybe prefix it with a <mod id>_ or some such? It seems not impossible that there could be a collision otherwise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 12, 2022, 02:43:40 PM
To bring this back up after some more testing:

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.

Are you absolutely sure about this? I removed all mods on version 0.95.1a-RC6 and manually added Rugged Construction to the dominator_d_Assault variant and checked the tooltip in dev mode under "edit variants". It does not appear to lessen the armor malus from Compromised Armor in the tooltip. I know it says it doesn't effect all reductions so is this one of the exceptions?

Also the tooltip just appears inaccurate to begin with. The base armor for the Dominator is 1500. 10% less armor should be 1350 and its saying its 1200 without any modifiers - which is a 20% decrease. Removing Rugged Construction does nothing to alter the value either way though.

Reproducing it should be as easy as adding the hullmod to the variant and then checking the tooltip in your dev mode. Unless there is something I'm not understanding about how it is supposed to be functioning here or it has already been fixed but not released?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 12, 2022, 02:52:59 PM
Perhaps this is an ordering issue? "rugged" needs to be added before any of the d-mods, i.e. if you're specifying:

"builtInMods":["comp_armor","rugged"],

It won't work. But the other way around it will.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 12, 2022, 04:33:05 PM
*SOLVED* Ok... it does work when testing that way. Let me see if it works in the mod now... yes it does work there too... sigh I must have messed up the test the first time and took the skill before looking at the original number and then tied it to the captain because I was used to it working that way. I only assume that because I just did the same thing when testing the isolated mod and then it dawned on me when rechecking the actual code for the skill file that taking the skill immediately applies the effect to all ships... Either that, or I fixed it at some point in between and didn't test in the campaign because I was working on Rugged Construction tests. Arrgh at least its fixed now!  :P

*EDIT3* I created a small mod to isolate the change: Test Mod (https://drive.google.com/drive/folders/1W--xnewwcXEMs_0jeHUITwXzhJNaXffR?usp=sharing)

Other effects use the same implementation for all ships in the fleet and they work as intended. Is it maybe because I am not extending something else, such as FleetTotalSource? I was under the impression that was just to implement an OP threshold and didn't have anything to do with the skill effect except to calculate the value based upon the OP returned. Is that not accurate?

*EDIT2* SOLVED: Confirmed that the ordering is the factor by adding the hullmod to the .skin file. Therefore the likely cause of the original issue is ordering unless I hear otherwise from Alex. You cannot edit the D-mod effectiveness dynamic stat through skills. (It might be a good idea to add this note to the documentation.)

Hmm, forgot about the second part of the below post saying skills are added before... I suppose I'll have to look at whether or not I'm inadvertently changing the order? Or it's something else.

Perhaps this is an ordering issue? "rugged" needs to be added before any of the d-mods, i.e. if you're specifying:

"builtInMods":["comp_armor","rugged"],

It won't work. But the other way around it will.

I will check yes it definitely could be! Are skill effects ordered after ship effects? That would explain why adding the effect to a skill wouldn't work in practice.

*EDIT*

Details of implementation just for ordering reference:

Code
	public static class Level5 implements ShipSkillEffect {
public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
            stats.getDynamic().getStat(Stats.DMOD_EFFECT_MULT).modifyMult(id, DMOD_EFFECT_MULT);
}

 - so is the overridden "apply" method of ShipSkillEffect applied before or after the ShipAPI is created and the dmods effects are applied when updating the tooltip or creating the entity in the battle? If it's after (and it seems like it would likely have to be), then editing that dynamic stat in a skill is impossible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on March 13, 2022, 12:06:18 PM
Is there a way to alter rate of fire on a weapon-by-weapon basis?
I'm trying to increase the rate of fire for ammo-reloading weapons, but the closest I can find is setRefireDelay, but there's no matching get, and even if there were, I think I would need to unapply it afterwards (this is for a ship system)? If so, I've no idea how I'd do that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Morrokain on March 13, 2022, 12:25:10 PM
Is there a way to alter rate of fire on a weapon-by-weapon basis?
I'm trying to increase the rate of fire for ammo-reloading weapons, but the closest I can find is setRefireDelay, but there's no matching get, and even if there were, I think I would need to unapply it afterwards (this is for a ship system)? If so, I've no idea how I'd do that.

Does float getCooldown(); from WeaponAPI work? That's the only thing I see that could be it anyway. To unapply it I would store the original value in a map before you set the increased rate and reset the original value in the unapply portion using the weapon id as a key or something like that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2022, 12:31:45 PM
Is there a way to alter rate of fire on a weapon-by-weapon basis?
I'm trying to increase the rate of fire for ammo-reloading weapons, but the closest I can find is setRefireDelay, but there's no matching get, and even if there were, I think I would need to unapply it afterwards (this is for a ship system)? If so, I've no idea how I'd do that.

Let me add WeaponAPI.getRefireDelay().

To unapply this sort of thing - the ship system script has an unapply() method, right? So I'd imagine you'd want to do it there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 14, 2022, 03:37:11 AM
Is there a way to modify just the launch speed of missiles?

been poking around in the API and (as far as I can see) there's lots of adjacent stats but not launch speed itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on March 14, 2022, 04:28:38 AM
Is there a way to check how long a colony has had freeport status/how free the port is?

I want to make Commerce add a black market, but only when freeport reaches the -3 stability level.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 14, 2022, 06:40:10 AM
Does interacting with some sector entity (specifically a derelict ship in space) for the first time after loading a save, cause music player to forcibly play a new track or something? Because something's overriding my custom music playing:

220711 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 39 - last

<dock with quest-specific derelict ship>

221550 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.rulecmd.Sunrider_PlayInteractionMusic  - Playing track SunriderDark  // uses a SoundPlayerAPI.playCustomMusic call
221551 [Thread-3] INFO  sound.public  - Creating streaming player for music with id [SunriderDark.ogg]
222960 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [scavenge_music_v1.ogg]  // huh, why is this playing?
222962 [Thread-9] INFO  sound.OooO  - Playing music with id [scavenge_music_v1.ogg]

<undock>

226716 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SunriderSalvageDefenderInter action$1  - Resetting music // also playCustomMusic, but with a null track
226729 [Thread-7] INFO  sound.public  - Cleaning up music with id [scavenge_music_v1.ogg]
226966 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [scavenge_music_v1.ogg]
226968 [Thread-9] INFO  sound.OooO  - Playing music with id [scavenge_music_v1.ogg]

<redock with same entity>

227497 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.rulecmd.Sunrider_PlayInteractionMusic  - Playing track SunriderDark
227498 [Thread-3] INFO  sound.public  - Creating streaming player for music with id [SunriderDark.ogg]  // now it works fine, nobody tries to play the scavenge music over it


Is there a way to check how long a colony has had freeport status/how free the port is?

I want to make Commerce add a black market, but only when freeport reaches the -3 stability level.
The FreeMarket market condition plugin has a getDaysActive() method.
For the current stability value, could check the market's stability modifiers using (I think) market.getCondition("bla").getIdForPluginModifications() as the key.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 14, 2022, 09:52:47 AM
Is there a way to modify just the launch speed of missiles?

been poking around in the API and (as far as I can see) there's lots of adjacent stats but not launch speed itself.

Not aside from the column in weapon_data.csv, no.

Does interacting with some sector entity (specifically a derelict ship in space) for the first time after loading a save, cause music player to forcibly play a new track or something? Because something's overriding my custom music playing:

What does the code for what you're doing look like? I don't remember how this works at all from the mod-end of things - do you call some kind of method to suspend "normal" music playback? I vaguely remember that being a thing but can't find it right now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 15, 2022, 11:12:50 AM
Is there any way to get projectiles to not spawn debris when shot down? I've got some energy projectiles and it looks out-of-place if they make shrapnel when destroyed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2022, 11:35:12 AM
You mean missiles, right? There isn't, though I've added the ability to specify debris color (and iirc number of particles) in the dev version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on March 15, 2022, 01:02:24 PM
You mean missiles, right? There isn't, though I've added the ability to specify debris color (and iirc number of particles) in the dev version.
Yeah, missiles, sorry. And that's great, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2022, 01:51:09 PM
More specifically, hmm - there's a "noDebrisWhenDestroyed" for the missile, and you can specify

"debrisSmall":7,
"debrisMedium":0,
"debrisLarge":0,

For the MIRV "split", but not for the regular mission explosion; I was misremembering that bit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 15, 2022, 08:01:14 PM
What does the code for what you're doing look like? I don't remember how this works at all from the mod-end of things - do you call some kind of method to suspend "normal" music playback? I vaguely remember that being a thing but can't find it right now.
Currently it just does this:

Rule command
Code: java
	@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
if (params.isEmpty()) {
playMusic(null);
return true;
}

String track = params.get(0).getString(memoryMap);
playMusic(track);
return true;
}

public void playMusic(String track) {
/*log.info("Playing track " + track);*/
Global.getSoundPlayer().playCustomMusic(1, 1, track, track != null);
}

Script column of rules.csv row, with OpenInteractionDialog trigger:
Code
ShowImageVisual SunriderNM
Sunrider_PlayInteractionMusic SunriderDark
(also further testing indicates that simply undocking and redocking doesn't prevent it from playing the "wrong" music, I have to undock/redock fast enough)

I worked around it by only playing the new track in the next the dialog screen (after the player clicks the continue option in the current one), so the music playing call is made after the regular interaction music has started. Timid also proposed using MusicPlayerPluginImpl.KEEP_PLAYING_LOCATION_MUSIC_DURING_ENCOUNTER_MEM_KEY to suppress the music autoplay.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 16, 2022, 09:31:20 AM
Thank you for clarifying!

Do you feel like you have a usable workaround, then? In all honesty, this is not something I really want to poke at unless it's absolutely necessary - the code is pretty fiddly and prone to breaking in non-obvious and hard-to-spot-immediately ways.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 16, 2022, 05:56:45 PM
Yeah, it sounds like it's better to leave things as they are and use the workarounds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 16, 2022, 09:41:45 PM
i'm sure it's been asked before
but i can't seem to find a specific answer here
so, question
is it possible at all to enable installation of dock-requiring hullmods in space, on condition of having a specific ship or item?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 17, 2022, 03:47:11 AM
FleetLogisticsAPI can get the total repair and recovery cost for a fleet, but is there a way to get it for a single fleet member (or an arbitrary collection of fleet members)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 17, 2022, 07:35:56 AM
is it possible at all to enable installation of dock-requiring hullmods in space, on condition of having a specific ship or item?

If HullmodSpecAPI.getTags() returns the real set of tags, then yes. If it only returns a copy, then probably not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 17, 2022, 08:53:15 AM
FleetLogisticsAPI can get the total repair and recovery cost for a fleet, but is there a way to get it for a single fleet member (or an arbitrary collection of fleet members)?

Hmm, I don't think so - you might be able to calculate it directly, though, based on cr/hull levels etc.

is it possible at all to enable installation of dock-requiring hullmods in space, on condition of having a specific ship or item?

If HullmodSpecAPI.getTags() returns the real set of tags, then yes. If it only returns a copy, then probably not.

It returns the set of tags, yeah, not a copy. You'd have to be really careful about modifying it, though, since changes here will even stick around across different saves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 17, 2022, 09:45:42 AM
Where are post-battle derelicts spawned?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 17, 2022, 12:52:31 PM
CoreScript.generateOrAddToDebrisFieldFromBattle()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on March 18, 2022, 05:19:21 PM
1. Can the ship AI evaluate its circumstances based on weapon ranges that differ from their base values?

I am writing a total conversion mod that, among other things, gives ballistic projectiles unlimited range but includes an onHitEffect that lets ships jink them by moving 'up' or 'down' depending on their size, max sideways acceleration, projectile speed, projectile distance traveled, and ship shield radius.  Every weapon would therefore have a different effective range against every ship, the AI of which would have to evaluate the range of its weapons and those of its allies and enemies every frame when evaluating its circumstances.

Consequently, even an Onslaught could jink the ballistic weapons on a Hound from far away, but the Hound could approach the Onslaught and hit it while still being far enough to jink the ballistic weapons on the Onslaught.  Whereas with fixed-range weapons in 2D, the Onslaught could swivel its turrets sideways faster than the Hound could fly sideways, and the stream of rounds from the Onslaught would catch the Hound.


2. Can the ship AI evaluate, or be forced to evaluate, its circumstances based on non-fixed information?

Another onHitEffect I want to write for my TC mod is for laser weapons, which I have given unlimited speed and range, bonus damage to subsystems, and 0 charge-up time, but which I want to balance with 3-to-1 flux inefficiency, weakness against armor, and inverse-square damage falloff over range.  The AI would have to anticipate the damage of its beam weapons and those of other ships rather than read them off weapon_data.csv or else waste its fire at long range.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Guy on March 18, 2022, 07:17:02 PM
I've been tearing my hair out about this for hours now,
here is an example mod that i've just cooked up along with it's file structure. I have a script in data.scripts.rulecmd that I want to fire from my custom rule.csv that i've created in data.campaign
so I create the script and extend BaseCommandPlugin and implement the execute method. I then refer to this package in a custom settings.json file in data.config. Only problem is that StarSector is having a real hard time finding the script i've refered to in my rules.csv and screams at me every time I try and load the game up.
I even refer to the mods jar file in the mod_info.json file but it's still not finding it.
What am I doing wrong here?

file structure and error
Spoiler
(https://i.imgur.com/mmpcRIp.png)
[close]
rules.csv
Spoiler
(https://i.imgur.com/AWyV5qI.png)
[close]
settings.json
Spoiler
(https://i.imgur.com/4bU2zVx.png)
[close]
mod_info.json
Spoiler
(https://i.imgur.com/cGNbGPe.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 19, 2022, 03:38:01 AM
@Big Guy: Only guess I've got is to open the .jar in a zip program and make sure data/scripts/rulecmd/ExampleDialogManager.class is indeed there (i.e. it was compiled properly).
Otherwise, you could upload the mod and I could see if there's something obviously wrong with it.


Two questions:

1) On the pictured weapon stats card, the refire delay shows an incorrect value because the chargeup time is added to the burst delay. It should only use the burst delay without modification.
(The weapon has 9999 burst, fires continuously while trigger is held down after fully charged. Derived DPS value is correct)
Is there a way to fix the false value or replace it with my own?
Spoiler
(https://i.imgur.com/TS1DRJF.png)
[close]

2) After calling CombatEngineAPI.setCustomExit and using the exit button it provides, FleetInteractionDialogPluginImpl.backFromEngagement is not called, so the game ends up in a weird state.
Is there a way to detect when this has happened (e.g. from within a derived class of FIDPI), so I can move the dialog along appropriately?

Spoiler
(https://i.imgur.com/BvEEKGB.png)
[close]

EDIT: Third question – is it me or does FleetMemberAPI.getStatus().getArmorDamageTaken() return 0 after the ship has taken armor damage from an asteroid impact? Even though the repair bar in fleet screen shows the damage fine.
(Was trying to figure out how to compute repair costs from the CR, hull and armor the ship has lost)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Guy on March 19, 2022, 11:42:35 AM
@Big Guy: Only guess I've got is to open the .jar in a zip program and make sure data/scripts/rulecmd/ExampleDialogManager.class is indeed there (i.e. it was compiled properly).
Otherwise, you could upload the mod and I could see if there's something obviously wrong with it.

Yup, cracked the jar open with 7zip and lo and behold, ExampleDialogManager is in there, right where it should be.
ExampleDialogManager location along with settings.json entry
Spoiler
(https://i.imgur.com/J0SEF76.png)
[close]

Here's the download link for the mod (https://www.mediafire.com/file/vvatryyvghymhjv/ExampleMod.zip/file), let me know if you can find anything because i feel like getting the rules.csv to work is pretty important for any mod looking to add interactivity. There isn't much in there, legitimately all that's in there is the barebones in getting a rule to fire. In the ExampleDialogManager class, all it does is log the rule that fired to the output terminal.
Thank you for the help btw
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 19, 2022, 12:02:55 PM
1) On the pictured weapon stats card, the refire delay shows an incorrect value because the chargeup time is added to the burst delay. It should only use the burst delay without modification.
(The weapon has 9999 burst, fires continuously while trigger is held down after fully charged. Derived DPS value is correct)
Is there a way to fix the false value or replace it with my own?
Spoiler
(https://i.imgur.com/TS1DRJF.png)
[close]

There isn't a way to override it, no. This is a tricky one because technically the value shown is "correct" - it's how long it takes between the last shot in a burst, and the first shot of a new burst, right? But yeah it's also totally not what you want here. ... let me just change it to only use the refire delay for interruptibleBurst weapons; that seems - at least, offhand - like a safe change to make.

2) After calling CombatEngineAPI.setCustomExit and using the exit button it provides, FleetInteractionDialogPluginImpl.backFromEngagement is not called, so the game ends up in a weird state.
Is there a way to detect when this has happened (e.g. from within a derived class of FIDPI), so I can move the dialog along appropriately?

Spoiler
(https://i.imgur.com/BvEEKGB.png)
[close]

Ah, hmm. Changed it so that it does, and that it pretends the player won the battle, when the custom exit happens - same code path as for a dev-mode "auto win" when you exit. Presumably, you'd be handling it in a custom way regardless.

EDIT: Third question – is it me or does FleetMemberAPI.getStatus().getArmorDamageTaken() return 0 after the ship has taken armor damage from an asteroid impact? Even though the repair bar in fleet screen shows the damage fine.
(Was trying to figure out how to compute repair costs from the CR, hull and armor the ship has lost)

That method is only going to work after combat - it's a way to measure the change in armor from before to after. One-off campaign events don't factor into this, just not how this is set up. I'm not sure what that would even mean in a pure-campaign context.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 19, 2022, 07:33:10 PM
Thanks Alex!

@Big Guy: Only guess I've got is to open the .jar in a zip program and make sure data/scripts/rulecmd/ExampleDialogManager.class is indeed there (i.e. it was compiled properly).
Otherwise, you could upload the mod and I could see if there's something obviously wrong with it.

Yup, cracked the jar open with 7zip and lo and behold, ExampleDialogManager is in there, right where it should be.
ExampleDialogManager location along with settings.json entry
Spoiler
(https://i.imgur.com/J0SEF76.png)
[close]

Here's the download link for the mod (https://www.mediafire.com/file/vvatryyvghymhjv/ExampleMod.zip/file), let me know if you can find anything because i feel like getting the rules.csv to work is pretty important for any mod looking to add interactivity. There isn't much in there, legitimately all that's in there is the barebones in getting a rule to fire. In the ExampleDialogManager class, all it does is log the rule that fired to the output terminal.
Thank you for the help btw
Well that was funny. I noticed the .jar was ridiculously bloated (it includes the entire rest of the mod in itself) so I deleted everything that wasn't a .class file, and now it works fine; I can get ingame, and the dialog rule fires correctly once I give it a sufficiently high score (!$fakeVar score:90000 in conditions column).

Is there a maximum size to the .jars the game can load? Anyway, check how your IDE packages stuff (I dunno how to configure it in any IDE other than NetBeans, but you should be able to google something for yours).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Guy on March 19, 2022, 08:28:12 PM
Well that was funny. I noticed the .jar was ridiculously bloated (it includes the entire rest of the mod in itself) so I deleted everything that wasn't a .class file, and now it works fine; I can get ingame, and the dialog rule fires correctly once I give it a sufficiently high score (!$fakeVar score:90000 in conditions column).
Oh wow, thanks a bunch man!
Yeah I had a look at the build settings for Intellij and it was compiling all the starsectore-core jars with it. Once i told it to cut that out it's all working as intended! You've got no idea how much this has been giving me grief, now I can continue with the rest of my mod. much appreciated man  8)
now I just gotta figure out what conditions i can check for and how it related to the scripts
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on March 21, 2022, 01:30:45 AM
Is there a way to load an image over the portrait frame, or to alter it in general?

I tried searching through the UI elements, but couldn't find anything.

(In my case I want to drop a static png over it to make all the portraits look like pin badges.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2022, 09:08:07 AM
I don't think so, no. You could set the person's portrait via PersonAPI, though. And probably set it back later, provided you keep track of the changes and there's some way for your code to be notified when that interaction is over.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 22, 2022, 06:26:34 AM
What does the ship system AI of type WEAPON_BOOST look like?

I'm trying to debug a case where a fighter won't use its High Energy Focus-like ability while having a SUPPORT role (although FIGHTER role + a carrier engage order seems to work). So I'd like to see what the AI script is doing that makes it not work. If I can't work around the rules, I'd like to make my own AI script for the system, which would also be helped by having the code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 22, 2022, 07:43:36 AM
It's actually a pretty simple one, so it's easy enough to paste the code. The meat of it is:

Code
float fluxLevel = ship.getFluxLevel();

if (fluxLevel > 0.9f) return;


boolean isUseful = false;
boolean isFiring = false;
float numUseful = 0;
float numFiring = 0;
if (system.getSpec().getWeaponTypes() == null) {
isUseful = true;
} else {
for (WeaponAPI w : ship.getAllWeapons()) {
if (system.getSpec().getWeaponTypes().contains(w.getType()) && w.getCooldownRemaining() <= 1f) {
isUseful = true;
float weight = 1f;
if (w.getSize() == WeaponSize.LARGE) weight = 4f;
else if (w.getSize() == WeaponSize.MEDIUM) weight = 2f;
numUseful += weight;
if (w.isFiring()) {
isFiring = true;
numFiring += weight;
}
}
}
}
if (!isUseful) return;

float rangeToTarget = Utils.getDistance(ship.getLocation(), target.getLocation());
float radSum = (ship.getCollisionRadius() + target.getCollisionRadius()) * 0.75f;

float closingSpeed = AIUtils.getClosingSpeed(ship, target);
boolean closingIn = closingSpeed > 5f;

boolean inRange = attackAI.getOptimalNonMissileRange() >= rangeToTarget - radSum;
boolean veryClose = attackAI.getOptimalNonMissileRange() * 0.5f >= rangeToTarget - radSum;

if ((inRange && closingIn) || veryClose || (numFiring > 0 && numFiring >= numUseful * 0.5f)) {
ship.giveCommand(new Ship.Command(CommandType.USE_SYSTEM, null));
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 22, 2022, 11:58:04 AM
four questions:
is it possible to modify what commodities all industries on an single world supply/demand?
example: on an world with a certain market condition, I might want to say, change all crew supply with organics supply for all industries

is it possible to change captions portraits and names based on there 'home' system/world, or barring that, there faction?
example: said fleet has an 'home' world with a certain market condition, change there name and portrait accordingly

is it possible to add hull mods to all ships in fleets with a certain 'home' system/world, or barring that, there faction?
example: said fleet has an 'home' world with a certain market condition, add on any hull mods that you want to add on to all ships in said fleet.

also dose anyone know were the growth speed of an market is calculated? I cant seem to find it for some reason.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on March 22, 2022, 01:25:22 PM
Working fixing weird niches for MagicLib as a slave
What's the "cleanest" way to detect if a ship does not have a shield nor phase for its defense system.. or even what are the conditions for a right-click system to show up in the UI? I could use what the Vanguard has but given the Invictus... and eventual later systems.

On another hand what triggers the MissileAPI to be IsGuided()?
Does it check the enginespec of the missileapi to see if it can turn or not? I'm kinda lost here.


How do I detect if a ship system is on the right-click or a current system for an ai script? I guess I could use ship.getSystem() and ship.getPhaseCloak() to check... I wonder if there are any workarounds that someone might try to do but I think those two should be the only way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on March 22, 2022, 01:42:47 PM
double post somehow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 22, 2022, 06:16:31 PM
Thanks for the code Alex! I can see why it's not working in my particular case, but doing the implementation I need will be pretty easy.

is it possible to change captions portraits and names based on there 'home' system/world, or barring that, there faction?
example: said fleet has an 'home' world with a certain market condition, change there name and portrait accordingly

is it possible to add hull mods to all ships in fleets with a certain 'home' system/world, or barring that, there faction?
example: said fleet has an 'home' world with a certain market condition, add on any hull mods that you want to add on to all ships in said fleet.
I'm guessing this is for generic fleets like patrols, rather than a specific fleet which you spawn and can do anything with?

Here's what I think I'd do:

- Create a fleet spawn listener (use reportFleetSpawned in a class that extends BaseCampaignEventListener). To add the listener to the sector, you can call the constructor with a (true) arg, or add it manually with Global.getSector().addListener(myListener) or Global.getSector().addTransientListener(myListener).
- When a fleet spawns, look for MemFlags.MEMORY_KEY_SOURCE_MARKET in its memory. If the market is the correct one, do anything you like with the captain portraits/names.

- To add the special hullmod, we want to implement a BaseCampaignPlugin (added with Global.getSector().registerPlugin(myPlugin)) and use its pickFleetInflater method (look at vanilla's CoreCampaignPluginImpl for an example). Make it return a custom fleet inflater that extends DefaultFleetInflater.
- Our custom inflater would have something like this:
Code: java
public void inflate(CampaignFleetAPI fleet) {
    super.inflate(fleet);
    // look for the source market memory key again, if it's there, add the hullmod to all the fleet members in this fleet
}
Extra note:
Listeners and campaign plugins should generally be added transiently (unless you're storing persistent data in them) so that they don't take up space in the save. Campaign plugin transience is controlled by the isTransient() method in the plugin. If something is transient add it in your mod plugin's onGameLoad method, else it goes in onNewGame or similar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 23, 2022, 04:50:19 PM
Thanks for the responses on my second and third question Histdine. took me a bit to understand what you said, but I have almost finished all my objectives that required said questions be answered first. thanks so mush =)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 23, 2022, 05:19:38 PM
Working fixing weird niches for MagicLib as a slave
What's the "cleanest" way to detect if a ship does not have a shield nor phase for its defense system.. or even what are the conditions for a right-click system to show up in the UI? I could use what the Vanguard has but given the Invictus... and eventual later systems.

It has a special right-click system with a UI if:
ship != null && ship.getPhaseCloak() != null && !ship.isPhaseShip();


On another hand what triggers the MissileAPI to be IsGuided()?
Does it check the enginespec of the missileapi to see if it can turn or not? I'm kinda lost here.

public boolean isGuided() {
   return getAI() instanceof GuidedMissileAI;
}

How do I detect if a ship system is on the right-click or a current system for an ai script? I guess I could use ship.getSystem() and ship.getPhaseCloak() to check...

Yes, that's how you'd do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Frederoo on March 25, 2022, 02:02:28 AM
Is there a way to filter out or block fighter wings from being installed via a hullmod or listener? I want to achieve an affect exactly like Automated ships (only allow drones), without the ship actually being automated. I've seen a similar effect with the Roider Union mod "Fighter Clamps" (blocks bombers specifically), but was redirected here instead. :) Right now I'm quite crudely removing those wings if they get selected based on Tags.AUTOMATED_FIGHTER in applyEffectsBeforeShipCreation
https://github.com/AlfredBroda/AlkemiaArmory/blob/0.8.1/data/hullmods/AlkemiaDroneConversion.java#L62

I disallowed bombers, not drones. Automated ships are limited to drone wings, but I can't find how they do it. Try asking on the Misc Modding Questions thread.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on March 25, 2022, 09:00:34 AM
Under what conditions would FleetMemberAPI.getRepairTracker().computeRepairednessFraction() return infinity or NaN?

Got a crash report with
Code
java.lang.NumberFormatException: For input string: "?"
My code that breaks is trying to apply a numeric format to the repairedness fraction, the "?" is apparently a Unicode replacement character for either +infinity or NaN.

Haven't been able to replicate the crash at all, any possible leads would be appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 25, 2022, 09:29:07 AM
Is there a way to filter out or block fighter wings from being installed via a hullmod or listener? I want to achieve an affect exactly like Automated ships (only allow drones), without the ship actually being automated. I've seen a similar effect with the Roider Union mod "Fighter Clamps" (blocks bombers specifically), but was redirected here instead. :) Right now I'm quite crudely removing those wings if they get selected based on Tags.AUTOMATED_FIGHTER in applyEffectsBeforeShipCreation
https://github.com/AlfredBroda/AlkemiaArmory/blob/0.8.1/data/hullmods/AlkemiaDroneConversion.java#L62

I disallowed bombers, not drones. Automated ships are limited to drone wings, but I can't find how they do it. Try asking on the Misc Modding Questions thread.

For automated ships iirc it's just hardcoded and looks for the "automated" hullmod and the "auto" tag on the wing.

You could add a FighterOPCostModifier listener to the ship, though, and increase the OP cost of non-auto wings to... I think going over 1000 makes the UI treat that fighter as "not installable" and puts it at the end of the list, instead of listing the cost.

Under what conditions would FleetMemberAPI.getRepairTracker().computeRepairednessFraction() return infinity or NaN?

Got a crash report with
Code
java.lang.NumberFormatException: For input string: "?"
My code that breaks is trying to apply a numeric format to the repairedness fraction, the "?" is apparently a Unicode replacement character for either +infinity or NaN.

Haven't been able to replicate the crash at all, any possible leads would be appreciated.

It'd have to be bad data that got into the FleetMemberStatus somehow. If somehow the maximum hitpoints of a ship got reduced to 0, perhaps?

However, infinity or NaN convert to "Infinity" and "NaN" when printed out as strings; I haven't ever seen it come out as "?".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Frederoo on March 25, 2022, 04:34:24 PM
For automated ships iirc it's just hardcoded and looks for the "automated" hullmod and the "auto" tag on the wing.

You could add a FighterOPCostModifier listener to the ship, though, and increase the OP cost of non-auto wings to... I think going over 1000 makes the UI treat that fighter as "not installable" and puts it at the end of the list, instead of listing the cost.
Thank you! That's exactly the effect I saw in SafariJohn's Roider Union mod - that's enough for me. ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 26, 2022, 12:01:32 AM
Trying to document sensor ghosts on the wiki. Leviathan looks like it should generate a slipstream behind it, but I don't think I've ever seen it do this in actual gameplay, and it doesn't when I manually spawn one in code. Am I missing something?

(Also my code can't seem to spawn minnows which is odd)

EDIT: Okay, I don't think ghosts in general work if I just sit wherever and spawn them with console (e.g. Remnant, ship and Zig ghosts just stay where they're spawned and don't move or reveal themselves). I've seen ghosts spawn slipstreams but I dunno which type they are.
For the wiki, I'll just write down what I already knew to be true.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 26, 2022, 03:19:58 AM
question
what is the current official hard cap on weapon fire delay?
the minimum amount of time between firing a shot, chargeup, chargedown and burst delay combined
i mean exact number it gets cut off at, not balance or sanity considerations
i know there was no hard cap once but now there is and i don't recall reading anywhere what it is, just that thereis one
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on March 26, 2022, 05:10:38 AM
Under what conditions would FleetMemberAPI.getRepairTracker().computeRepairednessFraction() return infinity or NaN?

Got a crash report with
Code
java.lang.NumberFormatException: For input string: "?"
My code that breaks is trying to apply a numeric format to the repairedness fraction, the "?" is apparently a Unicode replacement character for either +infinity or NaN.

Haven't been able to replicate the crash at all, any possible leads would be appreciated.

It'd have to be bad data that got into the FleetMemberStatus somehow. If somehow the maximum hitpoints of a ship got reduced to 0, perhaps?

However, infinity or NaN convert to "Infinity" and "NaN" when printed out as strings; I haven't ever seen it come out as "?".

Got it, this is a "should never happen" situation right?

My mistake btw, the "?" was from a DecimalFormat I was using to round the repairedness to 2 decimal places (found the exact issue on stackoverflow (https://stackoverflow.com/questions/5584020/java-decimalformat-returns-a)), the crash occurred when trying to parse the output as a float. Not my problem strictly speaking, but it'd be nice to find the exact cause
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 26, 2022, 07:51:28 AM
Trying to document sensor ghosts on the wiki. Leviathan looks like it should generate a slipstream behind it, but I don't think I've ever seen it do this in actual gameplay, and it doesn't when I manually spawn one in code. Am I missing something?

(Also my code can't seem to spawn minnows which is odd)

EDIT: Okay, I don't think ghosts in general work if I just sit wherever and spawn them with console (e.g. Remnant, ship and Zig ghosts just stay where they're spawned and don't move or reveal themselves). I've seen ghosts spawn slipstreams but I dunno which type they are.
For the wiki, I'll just write down what I already knew to be true.

You've looked at SensorGhostManager, right? spawnGhost() in particular; the SensorGhost needs to be added to the "ghosts" list in order to function. ... which, that list is protected right now, let me add a getter for it - otherwise, I don't think you can spawn fully functional ghosts. And yeah, the leviathan leaves a slipstream behind.

Hmm - I suppose you could work around this with a custom derived SensorGhostManager; feels like you'd probably be doing this sort of thing already for a number of things.

question
what is the current official hard cap on weapon fire delay?
the minimum amount of time between firing a shot, chargeup, chargedown and burst delay combined
i mean exact number it gets cut off at, not balance or sanity considerations
i know there was no hard cap once but now there is and i don't recall reading anywhere what it is, just that thereis one

It's 20 shots per second.

Got it, this is a "should never happen" situation right?

My mistake btw, the "?" was from a DecimalFormat I was using to round the repairedness to 2 decimal places (found the exact issue on stackoverflow (https://stackoverflow.com/questions/5584020/java-decimalformat-returns-a)), the crash occurred when trying to parse the output as a float. Not my problem strictly speaking, but it'd be nice to find the exact cause

Right! It's a hard one to track down because once there's a NaN or Infinity in the data somewhere, it can propagate almost anywhere - any calculation that uses these results in a NaN (or Infinity), too, and there's no way to trace where it came from.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 26, 2022, 01:29:27 PM
I'm trying to specify an OnRightClick action, as well as some sprite rendering for a commodity. There is a "Plugin" field in commodities.csv, but it doesn't appear to do anything (specifying a SpecialItemPlugin there doesn't allow setting OnRightClick actions, tooltip modifications or rendering). Any way to manually specify an lItemPlugin for a commodity and get access to these methods while not losing the economy integration?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 26, 2022, 02:51:38 PM
The plugin field in commodities.csv is not used; I'm not actually sure why it's even there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stelarwand030 on March 27, 2022, 05:10:23 PM
I am trying to edit a hullmod mod I bought but the game keeps crashing. i would ask the creator but he lives in Kyiv... so...

Here is the Mod: https://files.gamebanana.com/bitpit/rofhullmod_378fa.rar its a super cheaty mod that increases damage and rate of fire for all weapons. I want to drop the damage modifier but the game keeps crashing. Can someone tell me how to do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 27, 2022, 05:13:09 PM
dose anyone know how to accesses and or remove an markets population growth modifiers? I want to replace all of them with my own if certain conditions are meet.
i tried using the Immigration Modifiers to clear the population growth, but nothing happened. i think they are used for something completely different, but I had to try something
(i put this into the applyGrowthChanges() of an market condition that extends BaseMarketConditionPlugin implements MarketImmigrationModifier )
Code
LinkedHashSet<MarketImmigrationModifier> i = market.getImmigrationModifiers();
for(MarketImmigrationModifier a : i){
   market.removeImmigrationModifier(a);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 27, 2022, 06:20:52 PM
I am trying to edit a hullmod mod I bought but the game keeps crashing. i would ask the creator but he lives in Kyiv... so...

Here is the Mod: https://files.gamebanana.com/bitpit/rofhullmod_378fa.rar its a super cheaty mod that increases damage and rate of fire for all weapons. I want to drop the damage modifier but the game keeps crashing. Can someone tell me how to do that?
Works for me, you might just have edited it wrong (post the modified code and error message if you continue having trouble)

Here's the missile hullmod with halved damage bonus (replace the contents of existing file):
Spoiler
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import data.scripts.util.MagicIncompatibleHullmods;

public class MissileRoFHullmod extends BaseHullMod {

    public static final float ROF_BONUS = 1f;

    public static final float DAMAGE_BONUS_PERCENT = 25f;

    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        if (stats.getVariant().getHullMods().contains("rof_hullmod_all"))
            MagicIncompatibleHullmods.removeHullmodWithWarning(stats.getVariant(), "rof_hullmod_all", "rof_hullmod_missile");

        stats.getMissileRoFMult().modifyMult(id, 1f + (ROF_BONUS));
        stats.getMissileWeaponDamageMult().modifyPercent(id, DAMAGE_BONUS_PERCENT);
    }

    public boolean isApplicableToShip(ShipAPI ship) {
        return (!ship.getVariant().getHullMods().contains("rof_hullmod_all"));
    }

    public String getUnapplicableReason(ShipAPI ship) {
        if (ship.getVariant().getHullMods().contains("rof_hullmod_all"))
            return "Incompatible with Weapon RoF Improvement";
        return null;
    }

    public String getDescriptionParam(int index, HullSize hullSize) {
        float mult = 1f + ROF_BONUS;
        float bonusPercent = (int) ((mult - 1f) * 100f);
        if (index == 0) return "" + (int) bonusPercent + "%";
        if (index == 1) return "" + (int) DAMAGE_BONUS_PERCENT + "%";
        return null;
    }
}
[close]
All-boost mod with double ROF, 50% flux reduction and 200% bonus beam damage:
Spoiler
Code: java
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import data.scripts.util.MagicIncompatibleHullmods;

public class AllRoFHullmod extends BaseHullMod {

    public static final float ROF_BONUS = 2f;
    public static final float FLUX_REDUCTION = 50f;

    public static final float DAMAGE_BONUS_PERCENT = 200f;

    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        if (stats.getVariant().getHullMods().contains("rof_hullmod_ballistic"))
            MagicIncompatibleHullmods.removeHullmodWithWarning(stats.getVariant(), "rof_hullmod_ballistic", "rof_hullmod_all");
        if (stats.getVariant().getHullMods().contains("rof_hullmod_energy"))
            MagicIncompatibleHullmods.removeHullmodWithWarning(stats.getVariant(), "rof_hullmod_energy", "rof_hullmod_all");

        stats.getBallisticRoFMult().modifyMult(id, 1f + (ROF_BONUS));
        stats.getBallisticWeaponFluxCostMod().modifyMult(id, 1f - (FLUX_REDUCTION * 0.01f));
        stats.getEnergyRoFMult().modifyMult(id, 1f + (ROF_BONUS));
        stats.getEnergyWeaponFluxCostMod().modifyMult(id, 1f - (FLUX_REDUCTION * 0.01f));

        stats.getMissileRoFMult().modifyMult(id, 1f + (ROF_BONUS));
        stats.getMissileWeaponFluxCostMod().modifyMult(id, 1f - (FLUX_REDUCTION * 0.01f));
        stats.getBeamWeaponDamageMult().modifyPercent(id, DAMAGE_BONUS_PERCENT);
    }

    public boolean isApplicableToShip(ShipAPI ship) {
        return (!ship.getVariant().getHullMods().contains("rof_hullmod_ballistic") &&
                !ship.getVariant().getHullMods().contains("rof_hullmod_energy"));
    }

    public String getUnapplicableReason(ShipAPI ship) {
        if (ship.getVariant().getHullMods().contains("rof_hullmod_ballistic"))
            return "Incompatible with Improved Ammo Feeders";
        if (ship.getVariant().getHullMods().contains("rof_hullmod_energy"))
            return "Incompatible with Fast Recharging Capacitors";
        return null;
    }

    public String getDescriptionParam(int index, HullSize hullSize) {
        float mult = 1f + ROF_BONUS;
        float bonusPercent = (int) ((mult - 1f) * 100f);
        if (index == 0) return "" + (int) bonusPercent + "%";
        if (index == 1) return "" + (int) DAMAGE_BONUS_PERCENT + "%";
        if (index == 2) return "" + (int) FLUX_REDUCTION + "%";
        return null;
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stelarwand030 on March 27, 2022, 07:12:58 PM
I am trying to edit a hullmod mod I bought but the game keeps crashing. i would ask the creator but he lives in Kyiv... so...

Here is the Mod: https://files.gamebanana.com/bitpit/rofhullmod_378fa.rar its a super cheaty mod that increases damage and rate of fire for all weapons. I want to drop the damage modifier but the game keeps crashing. Can someone tell me how to do that?
Works for me, you might just have edited it wrong (post the modified code and error message if you continue having trouble)

Here's the missile hullmod with halved damage bonus (replace the contents of existing file):
Spoiler
Code
code
[close]
code
[/code][/spoiler]

I am using rons editor. what i want to change is the damage bonus for the all rof hullmod from 1000 to 100. yet every time i do this I get: fatal: Error loading [data.hullmods.allrofhullmod] Cause parsing compilation unit 'data.hullmods. allrofhullmod'

here is the original code
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import data.scripts.util.MagicIncompatibleHullmods;

public class AllRoFHullmod extends BaseHullMod {

    public static final float ROF_BONUS = 10f;
    public static final float FLUX_REDUCTION = 500f;

    public static final float DAMAGE_BONUS_PERCENT = 1000f;
    public static final float AMMO_BONUS_PERCENT = 1000f;
    public static final float RANGE_BONUS_PERCENT = 1000f;
    public static final float HEALTH_BONUS_PERCENT = 1000f;
    public static final float ACCELERATION_BONUS_PERCENT = 1000f;
    public static final float SPEED_BONUS_PERCENT = 1000f;

    public void applyEffectsBeforeShipCreation(HullSize hullSize
        if (stats.getVariant().getHullMods().contains("rof_hullmod_ballistic"))
            MagicIncompatibleHullmods.removeHullmodWithWarning(stats.getVariant()

I want to drop the DAMAGE_BONUS_PERCENT = 1000f to 100f but whenever I do the game crashes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 28, 2022, 05:49:33 PM
Don't use Ron's Editor to open .java files, it's for .csv. Notepad++ will do, although for more serious work an IDE is recommended.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stelarwand030 on March 28, 2022, 06:19:40 PM
Don't use Ron's Editor to open .java files, it's for .csv. Notepad++ will do, although for more serious work an IDE is recommended.

Ide?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Frederoo on March 29, 2022, 05:16:59 AM
Integrated Development Environment, like Visual Studio Code, IntelliJ Idea, Atom. There are a couple tutorials on how to use them with Starsector, here is one: https://fractalsoftworks.com/forum/index.php?topic=19532.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceDrake on March 29, 2022, 10:08:27 PM
Don't use Ron's Editor to open .java files, it's for .csv. Notepad++ will do, although for more serious work an IDE is recommended.

Ide?

If you're getting down and dirty with actual .java files, you're entering the territory where it'll be time to start learning general programming terminology, methods and best practices, for what it's worth.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on March 29, 2022, 10:10:04 PM
I have a mod that replaces "data/world/factions/default_ship_roles.json" and this seems to break the merging with other mods with this file that normally occurs.  Replacing this file breaks the spawning of modded ships in fleets and markets. Is there any way to get this file merged properly?

edit: figured it out, just don't replace the file override the default values
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on March 31, 2022, 09:25:49 AM
I want to make certain hullmods, ships, weapons, fighters player only. Is there a way to make this? If this is pretty big deal for this thread, I can make a seperate thread about it.
If you do not add a ship or weapon to the faction files of other factions, they will not show up with them. It's a simple thing. Best examples to be found in mods like Tahlan.
What about hullmods? Sorry for very late reply and nitcpicking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 31, 2022, 02:41:20 PM
Good Evening,

I'm trying to increase the OP of a ship via built in hullmod.
In 0.9.1a, I was able to do that by assigning a negative value to hullmod OP cost, then adding that.

This does not appear to work anymore.
Is there a way that does work?

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on March 31, 2022, 03:11:09 PM
Good Evening,

I'm trying to increase the OP of a ship via built in hullmod.
In 0.9.1a, I was able to do that by assigning a negative value to hullmod OP cost, then adding that.

This does not appear to work anymore.
Is there a way that does work?

Thanks!

there's no vanilla way to do this. Concord can though
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on March 31, 2022, 03:28:05 PM
I'd have to add that as dependency, right?

If that is the case, I'll probably go the OP reduction to weapons ect route. Intermod dependencies are not something I really want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stelarwand030 on March 31, 2022, 05:18:24 PM
I dont know why but i cannot see the entire skill tree. Is there a mod that fixes this? I have a bunch of mods but i don't know if any of them mess with the skill tree.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 31, 2022, 07:53:51 PM
I want to make certain hullmods, ships, weapons, fighters player only. Is there a way to make this? If this is pretty big deal for this thread, I can make a seperate thread about it.
If you do not add a ship or weapon to the faction files of other factions, they will not show up with them. It's a simple thing. Best examples to be found in mods like Tahlan.
What about hullmods? Sorry for very late reply and nitcpicking.
Hullmods work the same way, a faction only knows whatever the .faction file specifies that it should know. So you can make only player.faction have those hullmods.

(I think NPC ships in general don't use hullmods unless the variant specifies it, but knowing a hullmod presumably affects availability for sale on markets)

I dont know why but i cannot see the entire skill tree. Is there a mod that fixes this? I have a bunch of mods but i don't know if any of them mess with the skill tree.
There's no horizontal scroll bar, so any mod that adds new skills to an aptitude can cause problems, including old versions of Quality Captains if you're using that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on April 01, 2022, 08:54:51 AM
Thanks Histidine  :)

Why some files are in starfarer.api/impl? For example phase ancor hullmod file is in starfarer.api/impl/hullmod but most of other hullmod files are in data/hullmods folder. What's the difference? Can I just modify them and replace the old files, will my changes be applied? If not can I create duplicate version of them and put them in mod folder?  I'm confused.

By the way where is .faction files you mentioned?

I tried to create duplicate version of gladius and thunder fighters, changed their name, added their  corresponding data to ships_data.csv ad wing_data.csv. But I get fatal:null error in the end. I'm sure it's those files causing the problem since when I remove the modded ship folder the game works fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 02, 2022, 08:00:32 PM
.faction files are in data/world/factions

AFAIK there isn't really a reason some hullmod scripts are compiled in the .jar while others are loose.
Modifying loose .java files directly will work, but if you want make the changes from a separate mod, or to override compiled hullmod scripts, you'll need to do the following:
- Add a hull_mods.csv file to your mod, containing the rows for the hullmods you want to change
- Set each hullmod's script value to your modified script, e.g. my.script.package.MyHullmod

If your mod is crashing on load check starsector.log and look for the error, including what it was trying to load in the same thread just before the crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on April 03, 2022, 08:56:25 AM
- Set each hullmod's script value to your modified script, e.g. my.script.package.MyHullmod

If your mod is crashing on load check starsector.log and look for the error, including what it was trying to load in the same thread just before the crash.
Thank you for help. But I don't know how to create this "my.script.package" thing. I tried imitating starfarer.api.zip file with exact same destination (com\fs\starfarer\api\impl\hullmods) and put the modified .java hullmod files in there but it didn't work.

Should I make seperate thread because it seems like I'm very amateur and I can use more extensive help  ???
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on April 04, 2022, 04:02:33 PM
Sorry for double posting but I want to make quantum disruptor systems further reaching and active for longer time. I've tried modding direclty the main file in the .zip package but the changes are no visible. I've tried putting the modded file to data/shipsytems/myscripts but that didn't work either  :o Any help please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on April 04, 2022, 04:54:40 PM
Is it possible to restrict a fighter LPC to a ship that has a certain hullmod?  Maybe make it's OP cost 10x if the hullmod does not exist?   Otherwise I think the only way is make the fighter a built in wing, but I'd like to have the flexibility if possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on April 05, 2022, 10:23:59 AM
Really minor question; how is the TooltipMakerAPI rendering the em dashes for ship and weapon quotes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 05, 2022, 10:27:07 AM
Is it possible to restrict a fighter LPC to a ship that has a certain hullmod?  Maybe make it's OP cost 10x if the hullmod does not exist?   Otherwise I think the only way is make the fighter a built in wing, but I'd like to have the flexibility if possible.

If the hullmod is built-in, you can do it by having the hullmod add a FighterOPCostModifier to the ship. A cost above 1000 will make it show as "not installable".

Really minor question; how is the TooltipMakerAPI rendering the em dashes for ship and weapon quotes?

I... don't know? There's no special code for em-dashes. My guess is they're just regular dashes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on April 05, 2022, 10:34:11 AM
Weird! I could have sworn they were em dashes. But you're right - they're ordinary dashes and my brain was filling in.

POST FACTO EDIT: in case anyone actually needs this utterly useless piece of information, you can type '\u2014' for an em dash or '\u2013' for an en dash, and Starsector will dutifully render one in text.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Protonus on April 07, 2022, 10:16:18 PM
I'm trying to figure out how to allow separated modules to fly on their own once detached from the parent ship. Apparently, even with the Top Speed is already given and Flameout is logically turned off at that point, the module still thinks it's still attached and top speed is non-existent.

I'm assuming there is still a script telling the module to stay as it is even after separation.

The specific code:
Quote
        @Override
        public void advanceInCombat(ShipAPI ship, float amount) {
            super.advanceInCombat(ship, amount);
            if (!ship.isAlive()) return;
       
            if (ship.getHitpoints() > (ship.getMaxHitpoints() * 0.9f)) {
                ship.getEngineController().forceFlameout();
            }
           
            if (ship.getHitpoints() < (ship.getMaxHitpoints() * 0.9f)) {
                ship.setParentStation(null);
            }
        }

Spoiler
(https://i.imgur.com/KL16K3d.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 08, 2022, 08:55:23 AM
Hmm - try setStationSlot(null) on the module. I don't remember offhand if it'd be possible to do what you're trying to do, but if it was, you would definitely have to do that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Guy on April 08, 2022, 09:42:34 AM
Need some help in regards to interaction dialog.
I have 2 files, a Dialog manager that receives events from rules.csv and runs the appropriate dialog interaction based on the triggered event in rules.csv
and the other file which is the Dialog interaction which handles all the dialog interaction content. My Dialog Manager points to the appropriate Dialog Interaction based on the event fired in Rules.csv

My Dialog manager looks somethings like
Code
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap){
        String interactionTargetID = dialog.getInteractionTarget().getId();
        Global.getLogger(this.getClass()).info("Fired Event " + ruleId.toLowerCase(Locale.ROOT) + " " + interactionTargetID);

        // When the player first interacts with a specific interaction target
        if (interactionTargetID.equals("target")){
            new InteractionDialogHandler().init(dialog);
        }
        return true;
    }
And for my interaction dialog handler, see spoiler below
Spoiler
package data.scripts.rulecmd.dialog;

import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.combat.EngagementResultAPI;

import java.util.Map;

public class InteractionDialogHandler implements InteractionDialogPlugin {
    protected InteractionDialogAPI dialog;
    protected TextPanelAPI text;
    protected OptionPanelAPI options;

    enum OptionId{
        INIT,
        CONTINUE,
        LEAVE
    }

    @Override
    public void init(InteractionDialogAPI dialog) {
        this.dialog = dialog;
        this.text = dialog.getTextPanel();
        this.options = dialog.getOptionPanel();
        this.optionSelected(null, OptionId.INIT);
    }

    @Override
    public void optionSelected(String optionText, Object optionData) {
        if(optionData instanceof OptionId){
            dialog.getOptionPanel().clearOptions();

            switch ((OptionId) optionData){
                case INIT:
                    text.addPara("Text 1");
                    options.addOption("Continue.", OptionId.CONTINUE);

                    break;
                case CONTINUE:
                    text.addPara("Text 2");
                    options.addOption("Leave.", OptionId.LEAVE);
                    break;
                case LEAVE:
                    dialog.dismiss();
                    break;
            }
        }
    }

    @Override
    public void optionMousedOver(String optionText, Object optionData) {

    }

    @Override
    public void advance(float amount) {

    }

    @Override
    public void backFromEngagement(EngagementResultAPI battleResult) {

    }

    @Override
    public Object getContext() {
        return null;
    }

    @Override
    public Map<String, MemoryAPI> getMemoryMap() {
        return null;
    }
}
[close]
This works fine, it works great.
However, the problem stems from when I try and select an option.
Upon interacting with a target it shows the dialog fine along with its options. However, when selecting an option the interaction doesn't advance or continue. So I'll be shown "Text 1" and the button "Continue" but I can't advance to "Text 2" even if I click the button to continue.
The game knows I've selected an option because the options I've selected flashes and plays the appropriate audio que but the interaction remains on the content created for the INIT section. I have to hit the ESC key to back out of the interaction. I'm assuming that I need to tie my Dialog Interaction file to an event otherwise it'll just fire once and won't check for events fired by selecting an option but I wouldn't know, nor would I know how to tie a file to an event, that's just me speculating.
Anyone know what I'm doing wrong here?
Many thanks~
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dampfnudel on April 09, 2022, 12:32:25 AM
Any mod suggestion that adds some nice weapons with proximity charge and aoe weapons?

I do love the looks of the proximity charge launcher or the flak cannon in action!

All my ships are are armed with these :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirFfuzzyLogik on April 09, 2022, 03:25:26 PM
Does anyone know of a mod that buffs fragmentation damage?

It's really all I'm looking for, a simple, perhaps adjustable, buff to the damage type as a whole.

Perhaps a savvy coder or someone knowledgeable could tell me how/where to make that change?

Thank you in advance :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 09, 2022, 03:51:27 PM
This thread is for questions on how to modify the game, not a place to ask for mod suggestions.

Perhaps a savvy coder or someone knowledgeable could tell me how/where to make that change?

You would have to make a script that modified the MutableShipStatsAPI.getFragmentationDamageTakenMult() MutableStat of every deployed ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on April 09, 2022, 11:39:56 PM
I am trying to add a hullmod that reduces damage taken by type:  Explosive / Frag / Kinetic.   Also the reduction gets a little better the bigger the ship.  Maneuverability suffers.   

The damage reduction appears to work... but too well?     A frigate with 10%  kinetic dmg redux makes the vanilla rail gun (base 100 dmg per hit) do 6.5 dmg  on the armor  (2x hits do 13)

Is my math totally off?   The description for the hullmod works as intended


Spoiler

package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class battlefleets_ork_orkish_spaced_armor_alt extends BaseHullMod
{
   
   private static Map dmgexp = new HashMap();
   static {
      dmgexp.put(HullSize.FRIGATE, 0.8f);
      dmgexp.put(HullSize.DESTROYER, 0.75f);
      dmgexp.put(HullSize.CRUISER, 0.72f);
      dmgexp.put(HullSize.CAPITAL_SHIP, 0.70f);
   }
   
   private static Map dmgfrg = new HashMap();
   static {
      dmgfrg.put(HullSize.FRIGATE, 0.70f);
      dmgfrg.put(HullSize.DESTROYER, 0.67f);
      dmgfrg.put(HullSize.CRUISER, 0.65f);
      dmgfrg.put(HullSize.CAPITAL_SHIP, 0.60f);
   }
   
   private static Map dmgkin = new HashMap();
   static {
      dmgkin.put(HullSize.FRIGATE, 0.9f);
      dmgkin.put(HullSize.DESTROYER, 0.88f);
      dmgkin.put(HullSize.CRUISER, 0.77f);
      dmgkin.put(HullSize.CAPITAL_SHIP, 0.85f);
   }
   
   public static final float MANEUVER_PENALTY = 15f;

   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
   {
      stats.getHighExplosiveDamageTakenMult().modifyMult(id, (Float) dmgexp.get(hullSize) );
      stats.getFragmentationDamageTakenMult().modifyMult(id, (Float) dmgfrg.get(hullSize) );
      stats.getKineticArmorDamageTakenMult().modifyMult(id, (Float) dmgkin.get(hullSize) );
      
      
      stats.getAcceleration().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      stats.getDeceleration().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      stats.getTurnAcceleration().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      stats.getMaxTurnRate().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      
   }

   public String getDescriptionParam(int index, HullSize hullSize)
   {
      if (index == 0) return "" + (int) Math.round((1f - ((Float) dmgexp.get(hullSize))) * 100f) + "%";
      if (index == 1) return "" + (int) Math.round((1f - ((Float) dmgfrg.get(hullSize))) * 100f) + "%";
      if (index == 2) return "" + (int) Math.round((1f - ((Float) dmgkin.get(hullSize))) * 100f) + "%";
      if (index == 3) return "" + (int) Math.round(MANEUVER_PENALTY) + "%";
      return null;
   }

}

[close]

I also tried a fixed amount for all hulls with no hashmaps used and the same result:

Spoiler

package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class battlefleets_ork_orkish_spaced_armor extends BaseHullMod
{

   public static final float MANEUVER_PENALTY = 15f;

   public static final float HIGH_EXPLOSIVE_DAMAGE_REDUCTION = 0.7f;
   public static final float FRAGMENTATION_DAMAGE_REDUCTION = 0.8f;
   public static final float KINETIC_DAMAGE_REDUCTION = 0.9f;

   public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
   {
      stats.getHighExplosiveDamageTakenMult().modifyMult(id, HIGH_EXPLOSIVE_DAMAGE_REDUCTION);
      stats.getFragmentationDamageTakenMult().modifyMult(id, FRAGMENTATION_DAMAGE_REDUCTION);
      stats.getKineticArmorDamageTakenMult().modifyMult(id, KINETIC_DAMAGE_REDUCTION);      
      
      stats.getAcceleration().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      stats.getDeceleration().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      stats.getTurnAcceleration().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      stats.getMaxTurnRate().modifyMult(id, 1f - MANEUVER_PENALTY * 0.01f);
      
   }

   public String getDescriptionParam(int index, HullSize hullSize)
   {
      if (index == 0) return "" + (int) Math.round((1f - HIGH_EXPLOSIVE_DAMAGE_REDUCTION) * 100f) + "%";
      if (index == 1) return "" + (int) Math.round((1f - FRAGMENTATION_DAMAGE_REDUCTION) * 100f) + "%";
      if (index == 2) return "" + (int) Math.round((1f - KINETIC_DAMAGE_REDUCTION) * 100f) + "%";
      if (index == 3) return "" + (int) Math.round(MANEUVER_PENALTY) + "%";
      return null;
   }

}


[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 10, 2022, 10:39:10 AM
You seem to be forgetting that armor already reduces damage. Check what the railgun's first shot damage on that ship is without your hullmod. It should be like 7 damage per shot (+10%).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on April 11, 2022, 04:46:18 PM
You seem to be forgetting that armor already reduces damage. Check what the railgun's first shot damage on that ship is without your hullmod. It should be like 7 damage per shot (+10%).

*facepalm*  Totally missed that ummm.. minor detail   :o

Thanks for clearing up my tunnel vision.   Sometimes you need another pair of eyeballs to look at things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 11, 2022, 08:22:38 PM
recently I have been building an system to effectively replace the growth system on an world with the right market condition. however I have been having an slight trouble : in order to remove the market growth of an population successfully i had to put my 'remove market growth' code into the showIcon() function of my market condition. but i don't think the game is suppose to work that way, because every time i click on 'freeport', 'hazard pay', or i upgrade, downgrade, remove, or build anything, the market growth goes funny
before pressing buttons
(https://preview.redd.it/vo8s16ngi0t81.png?width=1323&format=png&auto=webp&s=41f87f97b58a22227802795b43730291321d9632)
[close]
after pressing buttons
(https://preview.redd.it/kektr8ngi0t81.png?width=1306&format=png&auto=webp&s=fa67c3420295f3a79da3eaeaf8b54e71e6a193a7)
[close]
as you can see, in before pressing buttons my growth speed is 6.67%. both the description and the big number under growth is the same.
in the after pressing buttons picture, my description stays the same, but the big number under growth changes, to what the number would normally be if i didn't remove all the growth bonuses

as far as i can tell, the game dose not like me interacting with it in the way that I am, that is with my growth code running in the showIcon() function of my market condition. however, I feel like I know why my code is not working anywhere else: in order to remove all growth modifiers, I need to run my code last (after all other growth modifiers have been applied, so they can them be removed without avoiding my code). and i guess the showIcon() function is running last or close enough to it for it to work. however i also guess that it after the big number growth bonus is calculated. hence the trouble displayed in the pictures.

anyhow, my question is: is there anywhere else I could put my code so it run after all other market growth modifiers are added together, but before the big growth number is calculated? or barring that any other way to fix the strange number trouble that I showed in my pictures?
(sorry if I'm a bit wordy. kind of tired today.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on April 12, 2022, 04:55:16 AM
how would one edit an officer?  is this done in the save file?
i have edited wing commander armaa pilots and everything was there
i found the names of all of my officers but i dont know what the references numbers mean or how to go about changing any of the values
i mainly want to change the portrait of one of them, but am curious how one might edit other things
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 12, 2022, 05:57:44 AM
how would one edit an officer?  is this done in the save file?
i have edited wing commander armaa pilots and everything was there
i found the names of all of my officers but i dont know what the references numbers mean or how to go about changing any of the values
i mainly want to change the portrait of one of them, but am curious how one might edit other things

yeah, search for their first or last name, for some reason their full names are stored in a different place than the rest of their data
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2022, 11:01:09 AM
... i had to put my 'remove market growth' code into the showIcon() function of my market condition

Hmm, what? This isn't, as far as I can tell, a thing.

Regardless, though: see the MarketImmigrationModifier interface, and MarketAPI.addImmigrationModifier().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 12, 2022, 01:44:03 PM
Hmm, what? This isn't, as far as I can tell, a thing.

Regardless, though: see the MarketImmigrationModifier interface, and MarketAPI.addImmigrationModifier().
tell me if I'm missing something obvious please, but i have tried putting it into an MarketImmigrationModifier with my market condition, but it seemed to remove growth bonuses at random. if you are suggesting that I instead use MarketAPI.addImmigrationModifier() to add an negative modifier equal to all the growth I want to remove, that would still require that the growth exist in PopulationComposition incoming when this code is ran, and im about 95% sure that will have the same troubles as this. also it would be kind of confusing for the user. then again if that works... ill give it a try and see if i can get that working, but i have no hope for it to work.

as for it not being a thing, i kinda sorta made it one.
this is my code that i use to remove market growth from an world, currently in the showIcon() function of my market condition
activeGrowth is the growth modifiers I want to keep on the world
PopulationComposition incoming = marketAPI.getIncoming()
Code
   private void modifyGrowth(PopulationComposition incoming){
        String[] activeGrowth = {
            "population_AIRetrofit_0",
            "population_AIRetrofit_1",
            "population_AIRetrofit_2",
            "AIRetrofits_BasicDroneFactory_0",
            "AIRetrofits_AdvancedDroneFactory_0",
        };
        int a = 0;
        while(incoming.getWeight().getFlatMods().keySet().size() != 0 && a < incoming.getWeight().getFlatMods().keySet().size()){
            boolean out = true;
            String m = incoming.getWeight().getFlatMods().keySet().toArray()[a].toString();
            for (String s : activeGrowth) {
                if (m.equals(s)) {
                    a++;
                    out = false;
                    break;
                }
            }
            if(out) {
                incoming.getWeight().unmodify(incoming.getWeight().getFlatMods().keySet().toArray()[a].toString());
            }
        }
    }
edit:
I tried moveing this code into the MarketImmigrationModifier of my code, as well as changing it to an negative modifier.
the negative modifier,  had the same issues as simply removing modifiers.
moveing the code into MarketImmigrationModifier had mush better resalts. the issue of the big number not matching the description and effects fixed itself, however my code could not remove/read:
-the 'starport' growth bounus.
-the freeport growth bonus. (it did on one world that didn't have a spaceport, no idea why)
i tried to fix this by changing the 'order' that the market condition had in the market_conditions.csv (i tried 1, 10000, 999, and 10, with new games, and with old games) but that didn't seem to do anything.

so if anyone knows were, i would like to know somewhere that i could put this code so it runs after freeport and starport do, (and any other growth modifiers) so it can remove them / counter them on worlds were I want them to do so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on April 12, 2022, 02:09:00 PM
How do I make engine trails only appear when the ship system is being used?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Guy on April 12, 2022, 03:20:19 PM
How do I script interaction dialog without rules.csv?
I can get dialog to show, but i can't show different dialog after the first initial text is shown
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 12, 2022, 05:04:21 PM
How do I make engine trails only appear when the ship system is being used?

Set contrail size on the desired engines to 128.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on April 13, 2022, 03:44:03 AM
How do I make engine trails only appear when the ship system is being used?

Set contrail size on the desired engines to 128.
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 15, 2022, 08:11:50 AM
How do I script interaction dialog without rules.csv?
I can get dialog to show, but i can't show different dialog after the first initial text is shown
Where/how are you implementing the dialog? If you're doing an InteractionDialogPlugin, the optionSelected implementation needs to look at the option the user clicked on and act accordingly. Vanilla has some examples; TutorialWelcomeDialogPluginImpl is one of the simpler ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Guy on April 15, 2022, 06:37:00 PM
How do I script interaction dialog without rules.csv?
I can get dialog to show, but i can't show different dialog after the first initial text is shown
Where/how are you implementing the dialog? If you're doing an InteractionDialogPlugin, the optionSelected implementation needs to look at the option the user clicked on and act accordingly. Vanilla has some examples; TutorialWelcomeDialogPluginImpl is one of the simpler ones.

If you take a look at my previous post (https://fractalsoftworks.com/forum/index.php?topic=5061.8640) halfway down the last page which is more indepth
I've implemented InteractionDialogPlugin and it is similar to the example you've stated in regards to option handling but it still doesn't register the selected option.
And I have instantiated this class which executes init() in another file which gets fired from rules.csv. I know I asked how to go about this without rules.csv but I only use it in this case as an entry point.
My file handling the interaction dialog contents for reference
Spoiler
package data.scripts.rulecmd.dialog;

import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.combat.EngagementResultAPI;

import java.util.Map;

public class InteractionDialogHandler implements InteractionDialogPlugin {
    protected InteractionDialogAPI dialog;
    protected TextPanelAPI text;
    protected OptionPanelAPI options;

    enum OptionId{
        INIT,
        CONTINUE,
        LEAVE
    }

    @Override
    public void init(InteractionDialogAPI dialog) {
        this.dialog = dialog;
        this.text = dialog.getTextPanel();
        this.options = dialog.getOptionPanel();
        this.optionSelected(null, OptionId.INIT);
    }

    @Override
    public void optionSelected(String optionText, Object optionData) {
        if(optionData instanceof OptionId){
            dialog.getOptionPanel().clearOptions();

            switch ((OptionId) optionData){
                case INIT:
                    text.addPara("Text 1");
                    options.addOption("Continue.", OptionId.CONTINUE);

                    break;
                case CONTINUE:
                    text.addPara("Text 2");
                    options.addOption("Leave.", OptionId.LEAVE);
                    break;
                case LEAVE:
                    dialog.dismiss();
                    break;
            }
        }
    }

    @Override
    public void optionMousedOver(String optionText, Object optionData) {

    }

    @Override
    public void advance(float amount) {

    }

    @Override
    public void backFromEngagement(EngagementResultAPI battleResult) {

    }

    @Override
    public Object getContext() {
        return null;
    }

    @Override
    public Map<String, MemoryAPI> getMemoryMap() {
        return null;
    }
}
[close]
Something which I think is cluing me in is the fact that on all these interaction dialogs have public static enum OptionId however when I insert that into my interaction dialog handler, my ide is telling me that the static keyword is redundant.
I'm fairly sure I'm doing something stupid or the answer is obvious but I just can't put my finger on it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 15, 2022, 07:23:22 PM
What's the best way to determine if Player has established a faction?  (Such that getFaction().getDisplayName() will return an inputted faction name, as opposed to the default 'Player' name)

Would simply checking the number of markets owned by player faction be sufficient?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 15, 2022, 09:00:04 PM
Hmm, I generated the dialog from code while in the campaign screen (using the code from previous page, no modifications except different name/package and adding a static debugger method) and it works fine (https://imgur.com/rYgI4fp).
How are you creating the dialog plugin? Opening a dialog from another dialog requires some special handling; I don't have a good grasp on how it works, but looking at MarketCMD.engage() (specifically the part where it sets and initializes a new plugin for the current dialog screen) might help.

What's the best way to determine if Player has established a faction?  (Such that getFaction().getDisplayName() will return an inputted faction name, as opposed to the default 'Player' name)

Would simply checking the number of markets owned by player faction be sufficient?
If you just need to check whether the player has seen the faction setup screen, use Misc.isPlayerFactionSetUp()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on April 17, 2022, 07:25:48 PM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on April 18, 2022, 01:01:26 PM
I am trying to delete planets. That much is easy. However, I am having trouble finding the nascent gravity well matching the planet so that can be deleted. Alex remarked on twitter that running .getLocationInHyperspace() just returns the location of the system, not the nascent well.

https://pastebin.com/3n1Dp4W9 code I've tried. the printloc returns the hyperspace location of the system itself

Right now I unable to A. find the hyperspace location of the nascent well and B. unable to find it that well corresponds to a particular planet. Any advice would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Guy on April 18, 2022, 02:31:22 PM
Hmm, I generated the dialog from code while in the campaign screen (using the code from previous page, no modifications except different name/package and adding a static debugger method) and it works fine (https://imgur.com/rYgI4fp).
How are you creating the dialog plugin? Opening a dialog from another dialog requires some special handling; I don't have a good grasp on how it works, but looking at MarketCMD.engage() (specifically the part where it sets and initializes a new plugin for the current dialog screen) might help.

First of all, thank you so much for referring me to look at MarketCMD.engage() while it wasn't obvious and it took me around 2 hours of trial and error, all I had to do was to insert the following into my Dialog Manager
Code
if (interactionTargetID.equals("target")){
            dialog.setPlugin(new InteractionDialogHandler());
            dialog.getPlugin().Init(dialog);
}
as opposed to
Code
if (interactionTargetID.equals("target")){
            new InteractionDialogHandler().init(dialog);
}
But it wasn't working at first,
all the old options were still present even though the options panel was called to clear itself.
Turns out to fix this you have to add options for the panel to clear itself and it'll work like a dream. So you can't have an empty options panel.
So again, thank you for the help, this has taken me days to get around.  8)
Wonder if I can update the starsector modding wiki's tutorial on creating interaction dialog since it remains incomplete.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 18, 2022, 06:26:40 PM
I am trying to delete planets. That much is easy. However, I am having trouble finding the nascent gravity well matching the planet so that can be deleted. Alex remarked on twitter that running .getLocationInHyperspace() just returns the location of the system, not the nascent well.

https://pastebin.com/3n1Dp4W9 code I've tried. the printloc returns the hyperspace location of the system itself

Right now I unable to A. find the hyperspace location of the nascent well and B. unable to find it that well corresponds to a particular planet. Any advice would be greatly appreciated.

In brief, you want to check if the entity is an instanceof NascentGravityWellAPI, and then use the .getTarget() method in that interface to check if that well points to the planet you're removing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Omnicast on April 18, 2022, 11:21:01 PM
Question: How does one change the player faction music. I want to swap the default song to Starlight Cabal's theme... thanks!

Mod Idea: Can someone make a mod that adds faction theme songs in cassette format? Gotta collect them all. Wait are we using cassettes in this timeline or holodiscs?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2022, 11:53:16 AM
Question: How does one change the player faction music. I want to swap the default song to Starlight Cabal's theme... thanks!

You can add a "music" section to the data/world/factions/player.faction file. See e.g. the hegemony.faction file for how that should look; the music itself is defined in data/config/sounds.json.

Or, I suppose, in your specfiic case you'd want to just copy the music section from the Starlight Cabal's .faction file. Just be aware that if you do this in the core game file - instead of making the change into a "proper" mod - then chances are the game would crash if you ever disabled that mod, since it'd still be looking for music that was no longer there. At the very least, I'd suggest backing up the player.faction file before editing it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on April 19, 2022, 04:49:22 PM
Is it possible to create a custom crew type and have a ship only count said custom crew as crew for that ship?
 
If that is possible , I imagine some kind of custom script to handle crew casualties would need to be made as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 19, 2022, 05:55:20 PM
For practical purposes, this isn't possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Omnicast on April 19, 2022, 10:46:25 PM
Alright got it! Thanks for the help Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 20, 2022, 07:53:42 AM
I am trying to accelerate a ship past its top speed a little, but the quick-slowdown acceleration is cancelling out my effect. What is its value or how is it calculated for a ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 20, 2022, 08:03:11 AM
IIRC it's based on the ship's current speed, so it would be difficult to get anything precise. Personally I'd recommend temporarily increasing the ship's max speed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 20, 2022, 08:10:15 AM
Ah, yeah, that would be a lot safer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on April 21, 2022, 12:10:52 AM
Will weapons, fighters, industries, and hulls covered by blueprint packs (e.g. base_bp, hightech_bp, rare_bp) drop as single item blueprints? I am trying to spice the exploration up by removing blueprint packs from drop lists (since otherwise you can learn almost all bps within the first few exploration journeys; they are way too common, but that's a topic for another time) which I achieve by adding Tags.NO_DROP to special item spec.

I've been told (by the modding community) that I need to remove all blueprint pack tags from them, but that will remove the knowledge of those from other factions too. How could I make sure the things that used to drop as part of blueprint packs will now drop as single blueprints?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 21, 2022, 04:58:45 AM
Look for stuff that has the no_drop tag - that is what blocks stuff from dropping as singleton BPs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 21, 2022, 08:38:23 AM
If the special items for the blueprint packs can't drop, then I'm not seeing - at least, offhand - what harm leaving the hightech_bp etc tags on the ships/weapons/etc would do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DialecticDetective on April 21, 2022, 01:10:18 PM
Hello everyone.

I've been messing around with a lot of mods recently, and sometimes you just want a quick start.
How difficult would it be to add another starting option to the game with a selection of ships, officers, fuel, and credits specified by me?


I had a google and a look through the 'Core' files, but God damn it Jim, I'm a technical writer, not a modder!

Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on April 22, 2022, 04:36:26 AM
Is it possible to have multiple EMP arcs from an OnHit effect?

I have the following code, but beyond the initial arc, there's no visual or damage indication that other arcs have generated. (The logging also flat out doesn't work, nothing is added to the log file - could that be due to testing in the Sim?)

Code: java
public class yunruArcing_Tesla implements OnHitEffectPlugin {

    private static final Logger log = Global.getLogger(yunruArcing_Tesla.class);

public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target,
  Vector2f point, boolean shieldHit, ApplyDamageResultAPI damageResult, CombatEngineAPI engine) {
if (target instanceof ShipAPI) {
float emp = 0f;
float dam = 0f;

engine.spawnEmpArc(projectile.getSource(), projectile.getSpawnLocation(), projectile.getSource(),
target,
DamageType.ENERGY,
dam,
emp, // emp
100000f, // max range
"shock_repeater_emp_impact",
60f, // thickness
new Color(25,100,155,255),
new Color(255,255,255,255)
);
log.info("Arc 1");
if (!shieldHit) {

emp = projectile.getEmpAmount();
dam = projectile.getDamageAmount();

for (int i = 0; i < 4; i++ ){
engine.spawnEmpArc(projectile.getSource(), point, target, target,
DamageType.ENERGY,
dam,
emp, // emp
100000f, // max range
"shock_repeater_emp_impact",
60f, // thickness
new Color(25,100,155,255),
new Color(255,255,255,255));
log.info("Arc " + (i+2));
}

}
}
}
}

EDIT: A separate question: Is there an explanation for what the various fields in condition_gen_data.csv do anywhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaros426 on April 22, 2022, 07:26:59 AM
Hi everyone,

I'm searching for a way of removing the deployment cost reductions from d-mods

Does anyone know where to find that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2022, 01:15:26 PM
Is it possible to have multiple EMP arcs from an OnHit effect?

I have the following code, but beyond the initial arc, there's no visual or damage indication that other arcs have generated. (The logging also flat out doesn't work, nothing is added to the log file - could that be due to testing in the Sim?)

I don't see why it wouldn't work. That the logging code doesn't run seems to indicate the problem is likely elsewhere?

EDIT: A separate question: Is there an explanation for what the various fields in condition_gen_data.csv do anywhere?

Nothing official, I don't think - possibly the wiki? I don't know, though.


Hi everyone,

I'm searching for a way of removing the deployment cost reductions from d-mods

Does anyone know where to find that?

Hi - the value is defined in CompromisedStructure.DEPLOYMENT_COST_MULT, but that data member is set to "final" so you can't change it. (It really shouldn't be; I just removed that.)

You could still do it, but you'd have to provide an alternate implementation for all of the d-mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on April 22, 2022, 01:37:44 PM
Is it possible to have multiple EMP arcs from an OnHit effect?

I have the following code, but beyond the initial arc, there's no visual or damage indication that other arcs have generated. (The logging also flat out doesn't work, nothing is added to the log file - could that be due to testing in the Sim?)

I don't see why it wouldn't work. That the logging code doesn't run seems to indicate the problem is likely elsewhere?
It's certainly a puzzle. I would of thought the script simply be not running, but for the fact all the visual elements of the weapon comes from said script. For it to only partially work...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 22, 2022, 01:52:03 PM
My initial guess would be some part of your build process not working and older code still running, but not being update with your changes - something along those lines.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zaros426 on April 22, 2022, 03:15:14 PM
Thank you for the quick answer Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on April 23, 2022, 01:52:48 AM
I hate myself.
I checked the weapon file, because I'd run out of anything else it could be. It was still using the Shock Repeater's projectile rather than it's own.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 23, 2022, 08:47:41 AM
Ouch! At least you finally found it :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AsianGamer on April 23, 2022, 09:36:54 PM
Hey, I'm looking to create a mod where you complete some missions that cause a new faction to be created (Nova Maxios becoming the Maxios Charter again). Where should I start? Can I have the group of missions trigger after the main storyline? Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sincronic on April 23, 2022, 09:55:46 PM
I need mini help with making a hullmod

Trying to make mass of ship lower by % of its base mass, but i'm not sure how to do it.
What i have tried is this:

Code
    @Override
    public void applyEffectsAfterShipCreation(HullSize hullSize, ShipAPI ship, String id) {
            ship.setMass(ship.getMass() - (ship.getMass() * (Float) MASS_REDUCTION.get(hullSize) / 100f));
}

But this didn't work, i've read somewhere stat changes should go into "before" function but since there is no stats.mass thing, i tried adding ShipAPI ship there and slapping line there, didn't work either. Is there some simple way to do this or do i have to it in advanceInCombat function?

Spoiler
I never coded in java before, and i'm using notepad to do this, so i can't debug at all, sorry  ::) I did manage to make like 10 hullmods so far though so, as long as it works lol
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on April 24, 2022, 12:33:31 AM
is there a way to use VisualPanelAPI.showCustomPanel and VisualPanelAPI.showFleetMemberInfo to show both a custom panel and a fleet member info? i'm trying to show an image like so:

(https://media.discordapp.net/attachments/310517733458706442/967641566686621776/unknown.png?width=853&height=468)

except with the weapons on the ship still. the way it currently works is by grabbing the fleet member's hullspec's sprite. i also get the nice background too if i was able to use showFleetMemberInfo.

the only other alternative is using Global.getFactory().createCustomPanel(), but i'm not sure if there's a way to remove custom panels at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 24, 2022, 01:23:03 AM
so I got a FleetAssignmentAI that is supposed to make a fleet go to a planet, orbit it, run a script, then return to the player.

However, the fleet appears to get stuck in the system it is in after orbiting the planet, and does not leave.
There is no real reason that I can see.

Am I missing something?
Thanks!

Code: java
    @Override
    protected void pickNext() {
        if (fleet.getAI() == null) return;
        IndEvo_modPlugin.log("Transport Detachment AI setting up");

        if(!cargoTransferScript.finished){
            checkOrCorrectMarket();
            MarketAPI market = Global.getSector().getEconomy().getMarket(targetMarketId);

            fleet.addFloatingText("Heading to " + market.getName(), fleet.getFaction().getBaseUIColor(), 1f);

            fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, market.getPrimaryEntity(), ASSIGNMENT_DURATION_FOREVER, "Delivering cargo to " + market.getName());
            fleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, market.getPrimaryEntity(), ASSIGNMENT_DURATION_3_DAY, "Unloading Cargo", cargoTransferScript);
        }

        fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, Global.getSector().getPlayerFleet(), ASSIGNMENT_DURATION_FOREVER, "Returning to main force", new Script() {
            @Override
            public void run() {
                FleetUtils.mergeFleetWithPlayerFleet(fleet);
            }
        });
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on April 24, 2022, 05:31:53 PM
Where does the code for the venting graphics hide? Or is it obfuscated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 24, 2022, 05:57:10 PM
Obfuscated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 25, 2022, 11:03:42 AM
Hey, I'm looking to create a mod where you complete some missions that cause a new faction to be created (Nova Maxios becoming the Maxios Charter again). Where should I start? Can I have the group of missions trigger after the main storyline? Thanks in advance.

Hmm, this is too big a question to really handle here, I think? I'd suggest looking at some existing missions (see: the com.fs.starfarer.api.impl.campaign.missions package) and then asking more specific questions; that might be the best way to go.

is there a way to use VisualPanelAPI.showCustomPanel and VisualPanelAPI.showFleetMemberInfo to show both a custom panel and a fleet member info? i'm trying to show an image like so:

Hmm - I don't believe so, no. Your best bet would probably be to try to show the fleet member info in the custom panel on your own, without using showFleetMemberInfo().

so I got a FleetAssignmentAI that is supposed to make a fleet go to a planet, orbit it, run a script, then return to the player.

However, the fleet appears to get stuck in the system it is in after orbiting the planet, and does not leave.
There is no real reason that I can see.

Am I missing something?

Nothing jumps out as being wrong. I'd suggest maybe trying to debug the state the fleet is in - adding a script that prints out its current assignment and its data (time remaining etc), that kind of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on April 25, 2022, 11:30:25 AM
is there a way to use VisualPanelAPI.showCustomPanel and VisualPanelAPI.showFleetMemberInfo to show both a custom panel and a fleet member info? i'm trying to show an image like so:

Hmm - I don't believe so, no. Your best bet would probably be to try to show the fleet member info in the custom panel on your own, without using showFleetMemberInfo().

unfortunately there's no way to get stuff like the weapons or the background that showFleetMemberInfo provides. the easiest way would be a way to hide/remove a panel that has been created, but if there's no way then i'll just stick with displaying the ship's sprite.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on April 27, 2022, 04:21:19 AM
Is there a way to alter how much damage the AI thinks a weapon would do?
I know the AI can't see scripted damage, but is there a way to say "this does X more damage than it's listed damage"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 27, 2022, 10:55:30 AM
so, I tried the
so I got a FleetAssignmentAI that is supposed to make a fleet go to a planet, orbit it, run a script, then return to the player.

However, the fleet appears to get stuck in the system it is in after orbiting the planet, and does not leave.
There is no real reason that I can see.

Am I missing something?
Thanks!

Code: java
   code

so, I tried that exact same thing with a purely vanilla assignment AI, and I suspect it might actually be a vanilla problem.

I made a test mod for you to replicate this.
Only thing required is that you are in a different system than Askonia, and load into the game with the mod enabled.

it'll spawn a fleet that goes to cruor, orbits it for a day, and should then return - but actually gets stuck in-system for no discernible reason.

Hoping to get this resolved, if not now, at least in the next version :)

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on April 27, 2022, 03:08:32 PM
Is there a way to alter how much damage the AI thinks a weapon would do?
I know the AI can't see scripted damage, but is there a way to say "this does X more damage than it's listed damage"?

Yes, but it's a bit complicated- Use an onFireEffect to increase the projectile's damage so that it properly represents the scripted damage it deals, then reduce it back down to the original value when it actually deals damage using a listener.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 28, 2022, 07:34:50 AM
Is there a way to get where the AI (or player) wants a ship's omni shields to be, even if the ship has no shields at all (or an alternate system that replaces shields)?

I've seen getShieldTarget() in ShipAPI & I'm hoping that that's what I want, though I've not yet had the time to check if it actually is.

EDIT : I've managed to check (with the below code in a hullmod) and it seems to return null no matter what, any ideas?

Code
    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {
        CombatEngineAPI engine = Global.getCombatEngine();
        float totalArc = ship.getShield().getActiveArc();
        if (ship.getShield().isOn() && ship.getShieldTarget() != null) {
            engine.addNebulaParticle(ship.getShieldTarget(), ship.getVelocity(), 1f, 1f, 1f,1f, amount, Misc.getPositiveHighlightColor());
        }
        if (ship.getOriginalOwner() != -1) {
            log.debug("the ship's shield target is " + ship.getShieldTarget());
            /*
            tried getShieldTarget.toString() as well and it always crashed
            */
        }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 29, 2022, 01:14:06 PM
Is there a way to alter how much damage the AI thinks a weapon would do?
I know the AI can't see scripted damage, but is there a way to say "this does X more damage than it's listed damage"?

I don't believe so, at least nothing comes to mind offhand.

Is there a way to alter how much damage the AI thinks a weapon would do?
I know the AI can't see scripted damage, but is there a way to say "this does X more damage than it's listed damage"?

Yes, but it's a bit complicated- Use an onFireEffect to increase the projectile's damage so that it properly represents the scripted damage it deals, then reduce it back down to the original value when it actually deals damage using a listener.

(Ah!)


so, I tried that exact same thing with a purely vanilla assignment AI, and I suspect it might actually be a vanilla problem.

I made a test mod for you to replicate this.
Only thing required is that you are in a different system than Askonia, and load into the game with the mod enabled.

it'll spawn a fleet that goes to cruor, orbits it for a day, and should then return - but actually gets stuck in-system for no discernible reason.

Hoping to get this resolved, if not now, at least in the next version :)

Thank you for the test mod! Basically the fleet doesn't know what location the player fleet is in - it hasn't seen it jump, so it just has no idea where to go, unless the player fleet is in the same system (in which case the GO_TO_LOCATION assignment knows where to go, but e.g. a fleet looking for the player normally still wouldn't).

This is e.g. so that a pursuing fleet doesn't magically know you've entered hyperspace if you jump out from outside their sensor range. I've changed it so that player-faction fleets can follow your fleets movements regardless. In the meantime, your best bet would be to create a SectorEntityToken, use a script to keep it where the player fleet is, and target the return assignment to that token.

Is there a way to get where the AI (or player) wants a ship's omni shields to be, even if the ship has no shields at all (or an alternate system that replaces shields)?

I've seen getShieldTarget() in ShipAPI & I'm hoping that that's what I want, though I've not yet had the time to check if it actually is.

EDIT : I've managed to check (with the below code in a hullmod) and it seems to return null no matter what, any ideas?

getShieldTarget() is actually going the other way - it lets you override where the shield will point. I don't *think* there's anything that would do what you're looking for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: IGdood on April 30, 2022, 12:58:54 PM
Since a lot of popular Chinese mods (Polaris, Approlight, ICE etc) got updated recently is there a way to have the game be able to display both English and Chinese?

Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 30, 2022, 02:50:52 PM
Since a lot of popular Chinese mods (Polaris, Approlight, ICE etc) got updated recently is there a way to have the game be able to display both English and Chinese?

Thanks

There really, really isn't - afaik the Chinese translation depends on replacing core font files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on April 30, 2022, 05:04:14 PM
is there a way to get the list of recoverable ships shown in the post-battle salvage dialog? i'm trying to show info about the recoverable ships to the player before they pick what ships to recover.

i was going to use FleetEncounterContext.getRecoverableShips, but it appears to reroll the recoverable ships list every time it is called. the list of recoverable ships is also private in both FleetInteractionDialogPluginImpl and FleetEncounterContext, which means that i can't simply extend the class and expose them without reimplementing (i.e. copying) the entire method from either class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 01, 2022, 01:01:31 PM
If you wanted to go that far, you might be able to copy-paste the getRecoverableShips() method and re-implement that whole interaction. Let me make those fields protected in the meantime; no reason for them to be private...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on May 01, 2022, 02:13:28 PM
If you wanted to go that far, you might be able to copy-paste the getRecoverableShips() method and re-implement that whole interaction. Let me make those fields protected in the meantime; no reason for them to be private...

i was specifically trying to avoid this because other mods (namely nexerelin, which many many many many players use) implement their own dialog and context for other reasons. plus, if you update it then i have to go through and update the method all over again.

but thanks for making it protected, means i can ask histidine to put a getter in. i was trying to put a dialog option after combat where it shows recoverable ships. nexerelin has a trigger that fires every time the encounter dialog changes state, which i've duplicated in my mod for if it isn't enabled.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 01, 2022, 02:31:50 PM
Aaah, ok - I was wondering how this would get along with Nex.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 01, 2022, 05:47:31 PM
You can get lost ships by putting a defeat trigger (Misc.addDefeatTrigger()) on the fleet you are interested in and running a rule command like below.

Code: java
@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {

    SectorEntityToken entity = dialog.getInteractionTarget();

    if (entity instanceof CampaignFleetAPI) {
        CampaignFleetAPI fleet = (CampaignFleetAPI) entity;

        MemoryAPI mem = memoryMap.get("local");
        BattleAPI battle = (BattleAPI) mem.get("$battle");

        if (battle != null) {
            // Should be able to get the FleetEncounterContext here somehow, but I do not know offhand
            // Otherwise you can reimplement getRecoverableShips()
            FleetEncounterContext context = todo();
            List<FleetMemberAPI> recoverable = context.getRecoverableShips(BattleAPI battle, CampaignFleetAPI winningFleet, CampaignFleetAPI otherFleet)

        }
    }

    return true;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on May 01, 2022, 08:43:48 PM
You can get lost ships by putting a defeat trigger (Misc.addDefeatTrigger()) on the fleet you are interested in and running a rule command like below.

Code: java
@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {

    SectorEntityToken entity = dialog.getInteractionTarget();

    if (entity instanceof CampaignFleetAPI) {
        CampaignFleetAPI fleet = (CampaignFleetAPI) entity;

        MemoryAPI mem = memoryMap.get("local");
        BattleAPI battle = (BattleAPI) mem.get("$battle");

        if (battle != null) {
            // Should be able to get the FleetEncounterContext here somehow, but I do not know offhand
            // Otherwise you can reimplement getRecoverableShips()
            FleetEncounterContext context = todo();
            List<FleetMemberAPI> recoverable = context.getRecoverableShips(BattleAPI battle, CampaignFleetAPI winningFleet, CampaignFleetAPI otherFleet)

        }
    }

    return true;
}

running getRecoverableShips will re-roll the ships that can be recovered
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 01, 2022, 08:57:41 PM
Then the method is bugged, because it is clearly supposed to be determinate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on May 01, 2022, 09:01:14 PM
Then the method is bugged, because it is clearly supposed to be determinate.

my reasoning is that it has the Misc.getRandom method which rolls using a seed 11 times
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on May 01, 2022, 11:31:53 PM
I am trying to delete planets. That much is easy. However, I am having trouble finding the nascent gravity well matching the planet so that can be deleted. Alex remarked on twitter that running .getLocationInHyperspace() just returns the location of the system, not the nascent well.

https://pastebin.com/3n1Dp4W9 code I've tried. the printloc returns the hyperspace location of the system itself

Right now I unable to A. find the hyperspace location of the nascent well and B. unable to find it that well corresponds to a particular planet. Any advice would be greatly appreciated.

In brief, you want to check if the entity is an instanceof NascentGravityWellAPI, and then use the .getTarget() method in that interface to check if that well points to the planet you're removing.

Very sorry to bother again, but I'm having a somewhat odd casting error while trying to call the getTarget method on the entity. I can't call the getTarget method on the generic SectorEntityToken, and when I try the cast, I get...this. Which is odd, because I don't know how on earth I'm getting a Location Token.

(https://i.imgur.com/vDBUUKi.png)

        List<SectorEntityToken>allEntities=Global.getSector().getHyperspace().getAllEntities();
        for (SectorEntityToken entity:allEntities)
        {
            if (entity instanceof NascentGravityWellAPI)
                log.info("Looking for nascent gravity wells to purge.");
                //note: isInCurrentLocation doesn't work because the well is in hyper, not realspace
                NascentGravityWellAPI nascwell= (NascentGravityWellAPI) entity; //note: yeah the cast is not legit
                if(nascwell.getTarget() == planet);
                {
                    //note: it's nothing in this code block that's causing the cast problem, I tried commenting it out
                    log.info("Purging nascent gravity well.");
                    LocationAPI location = entity.getContainingLocation();
                    log.info("nascent grav well's location is" + location.getLocation());
                    location.removeEntity(entity);
                    break;
                }
        }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 02, 2022, 10:05:51 AM
Then the method is bugged, because it is clearly supposed to be determinate.

my reasoning is that it has the Misc.getRandom method which rolls using a seed 11 times

It should probably be named "generateRecoverableShips" instead of "get"; it's not bugged (at least not in that way) but it's not supposed to be called multiple times as it makes changes to the underlying data.

Very sorry to bother again, but I'm having a somewhat odd casting error while trying to call the getTarget method on the entity. I can't call the getTarget method on the generic SectorEntityToken, and when I try the cast, I get...this. Which is odd, because I don't know how on earth I'm getting a Location Token.

(https://i.imgur.com/vDBUUKi.png)

   if (entity instanceof NascentGravityWellAPI)

                if(nascwell.getTarget() == planet);
                 

The first if doesn't have a block after it in curly braces, so only the one line after it will be inside the if. The second if has a semicolon after it meaning the block after it is just... a block that will always run. The if itself only gates the empty ; after it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Droll on May 02, 2022, 02:40:04 PM
A quick search yielded me no immediate result so I wanted to ask a question regarding autofit and modded weapons. Specifically, what is required to be in the mod in order for autofit to actually consider the new weapons.

I ask in the context of this mod (https://fractalsoftworks.com/forum/index.php?topic=24311.msg361408#msg361408) that I'm trying to patch up for myself. The ships that it adds work fine but when I try to use the autofit loadout feature the weapons added by that specific mod are seemingly ignored (other modded weapons are fine but I couldn't single out what was different). Additionally, my factions own patrols, though they use the hulls just fine, are not using the relevant weapons and fighter LPCs even though they are set to priority on the doctrine screen.

What files/structures does starsector expect to be able to autofit with mod weapons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 02, 2022, 07:27:16 PM
Make sure the weapons and fighter wings have autofit tags defined (see vanilla's weapon_data and wing_data csvs). If that fails, also check to make sure they're known by the faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Droll on May 02, 2022, 09:06:21 PM
Make sure the weapons and fighter wings have autofit tags defined (see vanilla's weapon_data and wing_data csvs). If that fails, also check to make sure they're known by the faction.

Thank you that has fixed the initial part of my issues, the weapons are now being added in the autofit and they are also showing up on my patrols.

However, the tags that the game uses are things like "kinetic15", "rocket3", "strike14" as well as "LR" or "SR". The latter two I imagine are just so the autofit knows the general range that the weapon is effective under but is there documentation for the former 3? They are not unique as some weapons (and wings) seem to have the same/similar tags. I'm also assuming that the "merc" tag just means that independent fleets of scavengers etc can equip those weapons.

That brings me to the current problem I have. Whenever I click my saved loadout to autofit, for some reason on slots that have the modded weapons don't stay the same as whats on the loadout. What confuses me is that as I said before, some of the vanilla weapons actually have some of the same tags in common. How do I make sure that the game always autofits consistently like it usually does (like how a vulcan cannon will always be autofitted with an available vulcan cannon)?

Thanks for your time
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on May 03, 2022, 05:52:00 AM
what is the proper way to remove/unequip a weapon from the specific slot of a specific fleetMember in campaign ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 03, 2022, 10:23:55 AM
How do I make sure that the game always autofits consistently like it usually does (like how a vulcan cannon will always be autofitted with an available vulcan cannon)?

One thing to check would be to make sure that the "upgrade" option is turned off in the autofit dialog.

Quote
"kinetic15", "rocket3", "strike14"

Pretty much what you'd think, I think - the number is "how good is it at that role". So kinetic15 is better at anti-shield than kinetic14. The SR/LR stuff is that for example a long-range kinetic doesn't get replaced by a quality but short-ranged one because it had a higher number. "rocket" is a dumbfire missile with lots of ammo. Strike is torpedoes and similar.

Tags without a number at the end - except for SR and LR - are not going to  be autofit-related. Your guess as to what "merc" does is spot-on; the way that's handled is by referring to that tag in the mercenary.faction file.

what is the proper way to remove/unequip a weapon from the specific slot of a specific fleetMember in campaign ?

You have to make sure that the VariantSource on its variant is REFIT; if not you'd set it to a clone of the shared variant, like so:
Code
if (member.getVariant().getSource() != VariantSource.REFIT) {
    member.setVariant(member.getVariant().clone(), false, false);
    member.getVariant().setSource(VariantSource.REFIT);
}

Otherwise, you might be modifying a shared STOCK variant, which would affect everywhere that uses it.

And after that you could modify the variant as needed. Depending on what you're doing, you might also want to add/remove the weapon to/from the player fleet's cargo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Droll on May 03, 2022, 10:33:38 AM
Make sure the weapons and fighter wings have autofit tags defined (see vanilla's weapon_data and wing_data csvs). If that fails, also check to make sure they're known by the faction.

Thank you that has fixed the initial part of my issues, the weapons are now being added in the autofit and they are also showing up on my patrols.

However, the tags that the game uses are things like "kinetic15", "rocket3", "strike14" as well as "LR" or "SR". The latter two I imagine are just so the autofit knows the general range that the weapon is effective under but is there documentation for the former 3? They are not unique as some weapons (and wings) seem to have the same/similar tags. I'm also assuming that the "merc" tag just means that independent fleets of scavengers etc can equip those weapons.

That brings me to the current problem I have. Whenever I click my saved loadout to autofit, for some reason on slots that have the modded weapons don't stay the same as whats on the loadout. What confuses me is that as I said before, some of the vanilla weapons actually have some of the same tags in common. How do I make sure that the game always autofits consistently like it usually does (like how a vulcan cannon will always be autofitted with an available vulcan cannon)?

Thanks for your time

Completely disregard my quoted post as I am an unmitigated fool who missed that "randomize weapons" was checked on the autofit screen.

Following Histidines suggestion has completely fixed the problem for me. Thanks

Edit: Also thanks for your response Alex, now it makes sense. Especially since I'm not randomizing weapons anymore and complaining about it lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 03, 2022, 10:48:15 AM
:D It happens!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on May 03, 2022, 06:33:51 PM
what is the proper way to remove/unequip a weapon from the specific slot of a specific fleetMember in campaign ?

You have to make sure that the VariantSource on its variant is REFIT; if not you'd set it to a clone of the shared variant, like so:
Code
if (member.getVariant().getSource() != VariantSource.REFIT) {
    member.setVariant(member.getVariant().clone(), false, false);
    member.getVariant().setSource(VariantSource.REFIT);
}

Otherwise, you might be modifying a shared STOCK variant, which would affect everywhere that uses it.

And after that you could modify the variant as needed. Depending on what you're doing, you might also want to add/remove the weapon to/from the player fleet's cargo.
thank you, this is helpful
however i haven't even gotten to the point of encountering any underwater rocks
i still can't figure out how to remove/unequip a weapon, nothing i tried had any effect so far(beyond null pointer crash, that is) and i can't find a working example, that's why i'm asking
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 03, 2022, 08:08:31 PM
Hmm - ShipVariantAPI has a clearSlot(String slotId) method, have you tried that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on May 04, 2022, 12:07:52 AM
Some odd behavior while trying to get and then delete campaign-level terrain. When I try to print all nearby terrain, I only ever get [TERRAIN] or [TERRAIN, DEBRIS] if there's debris. The worrisome part for me is that I delete magfields but not rings, asteroid fields, or solar shades somehow. RingBandAPI is a subclass of SecEnt.

 final float searchRange =60000f;//arbitrary number, in the future have a check to avoid removing the terrain from unrelated planets
        List<SectorEntityToken> terrainList=CampaignUtils.getNearbyEntitiesWithTag(planet, searchRange, "terrain");
        terrainList.addAll(CampaignUtils.getNearbyEntitiesWithTag(planet, searchRange, "ACCRETION_DISK"));
        terrainList.addAll(CampaignUtils.getNearbyEntitiesWithTag(planet, searchRange, "STELLAR_MIRROR"));
        //note: no idea why terrain covers magfields but not rings. they're both under terrain tags
        terrainList.addAll(CampaignUtils.getNearbyEntitiesWithTag(planet, searchRange, "RING"));
        terrainList.addAll(CampaignUtils.getNearbyEntitiesWithTag(planet, searchRange, "ASTEROID_BELT"));
       //note: adding things to terrainList seems to do precisely nothing in terms of increasing or decreasing the number of entities found

            //note: holy *** it works
            //note: wait ***, it wipes magfields but not rings that are in search range
        for (SectorEntityToken terrain:terrainList)
        {
            log.info((terrain.getTags()));
            system.removeEntity(terrain);
        }

The function I'm calling with getNearbyEntitiesWithTag is a LazyLib function, which seems to have a completely sane implementation based on using locationAPI and distance^2 to check the distance to all relevant SectorEntities in system. The LazyLib function seems to function completely fine in itself in testing. Implementation below in case it matter.

public static <T extends SectorEntityToken> List<T> getNearbyEntitiesWithTag(
            SectorEntityToken token, float range, String entityTag)
    {
        List<T> entities = new ArrayList<>();

        // Find all tokens of the given type within range
        for (SectorEntityToken tmp : token.getContainingLocation().getEntitiesWithTag(entityTag))
        {
            T entity = (T) tmp;

            // Exclude passed in token
            if (entity == token)
            {
                continue;
            }

            // Add any token within range
            if (MathUtils.isWithinRange(token, entity, range))
            {
                entities.add(entity);
            }
        }

        return entities;
    }

 @Nullable
    public static <T extends SectorEntityToken> T getNearestEntityFromFaction(
            SectorEntityToken token, String entityTag, FactionAPI faction)
    {
        T closest = null;
        float distanceSquared, closestDistanceSquared = Float.MAX_VALUE;

        for (SectorEntityToken tmp : token.getContainingLocation().getEntitiesWithTag(entityTag))
        {
            T entity = (T) tmp;

            if (entity == token || faction != entity.getFaction())
            {
                continue;
            }

            distanceSquared = MathUtils.getDistanceSquared(token.getLocation(),
                    entity.getLocation());
            if (distanceSquared < closestDistanceSquared)
            {
                closest = entity;
                closestDistanceSquared = distanceSquared;
            }
        }

        return closest;
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 05, 2022, 08:54:01 AM
Just want to know, how to hide a skill entirely if it is added to the player?
I just add only_npc to the tag, and everything seems okay, the skill is hidden, but I don't actually know if it is okay.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 05, 2022, 10:04:45 AM
I think it's npc_only and yeah that should be ok, that's why the tag is there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 06, 2022, 07:08:20 AM
I think it's npc_only and yeah that should be ok, that's why the tag is there.
oh, yes, I know, thx
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haze on May 06, 2022, 07:22:53 AM
I've tried asking this question in the unofficial discord, but I've not gotten much help.

I've taken two java files from the starfarer.api zip file and I've edited them both. PhaseCloakStats.java to remove the flux slowdown, and MineStrikeStats.java to give it back its old range and minimum spawn range. I've attempted to use this (https://github.com/davidwhitman/starsector-mod-template) to try to make it into a usable mod, with no success.

What do I do? How can I make this work? Keeping the modplugin section in mod_info crashes my game on launch, but deleting it causes the mod to have no effect on the game.

If anyone can help me out, I'll be very very grateful. I've been spending all afternoon toiling over this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haze on May 06, 2022, 07:29:34 AM
I've tried asking this question in the unofficial discord, but I've not gotten much help.

I've taken two java files from the starfarer.api zip file and I've edited them both. PhaseCloakStats.java to remove the flux slowdown, and MineStrikeStats.java to give it back its old range and minimum spawn range. I've attempted to use this (https://github.com/davidwhitman/starsector-mod-template) to try to make it into a usable mod, with no success.

What do I do? How can I make this work? Keeping the modplugin section in mod_info crashes my game on launch, but deleting it causes the mod to have no effect on the game.

If anyone can help me out, I'll be very very grateful. I've been spending all afternoon toiling over this.

And in case someone's willing to make the mod for me, here's the java files I've edited. All I had to do was change up a few values, but still.
https://pastebin.com/bS4EvxQn
https://pastebin.com/XpsJAk4h
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on May 06, 2022, 03:04:46 PM
I've tried asking this question in the unofficial discord, but I've not gotten much help.

I've taken two java files from the starfarer.api zip file and I've edited them both. PhaseCloakStats.java to remove the flux slowdown, and MineStrikeStats.java to give it back its old range and minimum spawn range. I've attempted to use this (https://github.com/davidwhitman/starsector-mod-template) to try to make it into a usable mod, with no success.

What do I do? How can I make this work? Keeping the modplugin section in mod_info crashes my game on launch, but deleting it causes the mod to have no effect on the game.

If anyone can help me out, I'll be very very grateful. I've been spending all afternoon toiling over this.

Post the mod_info, that might help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Haze on May 06, 2022, 03:40:24 PM
Code
{
    "id": "Phase",
    "name": "Phase",
    "author": "Haze",
    "utility": "false",
    "version": { "major":"1", "minor": "0", "patch": "0" },
    "description": "Mod description.",
    "gameVersion": "0.95.1a-RC6",
    "jars":["jars/Phase.jar"],
    "dependencies": [
        {
            "id": "lw_lazylib",
            "name": "LazyLib",
            # "version": "2.6" # If a specific version or higher is required, include this line
        }
    ]
}

Thanks for reaching out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 06, 2022, 05:19:52 PM
displayArcRadius":

What does this do in weapon files?

Also I want a certain weapon to have armor damage like the speaciality of breach missile. How do I do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2022, 04:53:51 PM
displayArcRadius":

What does this do in weapon files?

Nothing. It used to affect the weapon arc overlay at some point in the distant past.

Also I want a certain weapon to have armor damage like the speaciality of breach missile. How do I do that?

I'd suggest taking a look at breach_srm.proj!


I've tried asking this question in the unofficial discord, but I've not gotten much help.

I've taken two java files from the starfarer.api zip file and I've edited them both. PhaseCloakStats.java to remove the flux slowdown, and MineStrikeStats.java to give it back its old range and minimum spawn range. I've attempted to use this (https://github.com/davidwhitman/starsector-mod-template) to try to make it into a usable mod, with no success.

What do I do? How can I make this work? Keeping the modplugin section in mod_info crashes my game on launch, but deleting it causes the mod to have no effect on the game.

If anyone can help me out, I'll be very very grateful. I've been spending all afternoon toiling over this.

And in case someone's willing to make the mod for me, here's the java files I've edited. All I had to do was change up a few values, but still.
https://pastebin.com/bS4EvxQn
https://pastebin.com/XpsJAk4h

In brief, you'd want to set up an IDE and compile your code, then have your mod provide a ship_systems.csv that points at your modified classes instead of the vanilla ones.

The project template you're looking at - I mean, I'm sure it's good! - but it also looks like it might be too much unless you're already pretty familiar with Java. Not that setting up an IDE (dev environment) is going to be the easiest thing, but there are some step-by-step guides for that... somewhere around here - possibly on the wiki? Hopefully someone would be able to point you towards that, either here or on the Discord.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on May 07, 2022, 08:09:50 PM
Is there some way to check to see if weapon arcs are toggled on through code? I have some opengl-rendered indicators that I want to turn off if arcs are off, and Global.getCombatEngine().isUIShowingHUD() only appears to be for the whole hud, not just arcs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2022, 08:15:12 PM
I don't believe so, no. Let me add CombatUIAPI.areWeaponArcsOn().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on May 07, 2022, 08:23:06 PM
I don't believe so, no. Let me add CombatUIAPI.areWeaponArcsOn().

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 08, 2022, 03:06:07 AM
Is there anyway to make AI know "there will be an explosion" and toggle on their shield or phase?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2022, 12:19:19 PM
Hmm - you could try placing an invisible mine with a time-until-explosion set to whatever value you want. That seems like it might work, though it could be tricky if it gets collided with - if it's CollisionClass.NONE, then it might not cause a reaction, but if it's not, then something might hit it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on May 08, 2022, 10:17:02 PM
Hmm - you could try placing an invisible mine with a time-until-explosion set to whatever value you want. That seems like it might work, though it could be tricky if it gets collided with - if it's CollisionClass.NONE, then it might not cause a reaction, but if it's not, then something might hit it.
I have thought about this and wondering if CollisionClass.NONE would be ignored...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: CrashToDesktop on May 09, 2022, 12:42:26 AM
I've got a bit of a brain teaser whose answer I'm not entirely sure of. Beam armor penetration is dependent on their DPS, and that technically changes if the ship undergoes time acceleration, though I'm not sure if the game actually takes that into account. Do beams gain more armor penetration when fired *from* a ship under time acceleration? Is their armor penetration reduced when firing *at* a ship under time acceleration? What if two ships under time acceleration fire beams at eachother?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 10, 2022, 01:06:39 PM
There's no specific interaction there, aside from the beam doing more damage since the damage it deals is based on the timescale of the firing ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on May 12, 2022, 11:11:31 AM
I am trying to make a hullmod that reduces a specific fighter OP cost by a big percentage.  Normally the OP cost is absurdly large at 100 OP.
Also any fighter that doesn't have a specific prefix (used by all fighters in this faction)  will have its OP cost increased by 10.

Currently for some reason not only is the specific fighter OP cost not decreased, all fighters are increased by 10 (so its sorta working.... :o  )

What dumb did I do?


Spoiler
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponSize;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
import com.fs.starfarer.api.combat.listeners.FighterOPCostModifier;
import com.fs.starfarer.api.combat.listeners.WeaponOPCostModifier;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.loading.FighterWingSpecAPI;
import com.fs.starfarer.api.loading.WeaponSpecAPI;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class battlefleets_ork_massive_hangar extends BaseHullMod
{
   
   public static float COST_MODIFIER = 0.2f;

   @Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
   {
      @Override
      stats.addListener(new FighterOPCostModifier()
      {
         public int getFighterOPCost(MutableShipStatsAPI stats, FighterWingSpecAPI fighter, int currCost)
         {
            if (fighter.getId().contains("battlefleets_ork_megabommer"))
            {
               return (int) (currCost * COST_MODIFIER);
            }
            
            if (!fighter.getId().contains("battlefleets_ork_"))
            {   
               return (currCost + (int) 10);
            }
            return currCost;
         }
      });
    }
   
   @Override
   public boolean affectsOPCosts() {
      return true;
   }
   
   public String getDescriptionParam(int index, HullSize hullSize)
   {
      //if (index == 0) return "" + (int) COST_MODIFIER + "%";
      if (index == 0) return "" + (int) Math.round( (1f - COST_MODIFIER) * 100f) + "%";
      if (index == 1) return "" + (int) 10;
      return null;
   }

}

[close]



Edit: Turns out my dumb was in the naming of the fighter wings

Is there a limitation with janino and if statements?

'cause:

if (!fighter.getId().contains("battlefleets_ork_"))
{   
    return (currCost + (int) 10);
}

works  but:

if ( (!fighter.getId().contains("battlefleets_ork_1")) || (!fighter.getId().contains("battlefleets_ork_2")) )
{   
    return (currCost + (int) 10);
}

Causes a crash?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2022, 11:17:55 AM
Hmm, the code looks right to me at first glance? I'd double-check that all the ids you've got in there are actually correct.

Edit: also, getId() is going to return the wing id, not the hull id, in case that's the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceDrake on May 12, 2022, 11:48:47 AM
So out of curiosity, what are all the files that define how faction relations are at the start?

I'm trying to adjust a mod's starting relations to be a bit more "interesting", but it's proving to be a bit of a struggle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 12, 2022, 12:13:36 PM
In vanilla, that's SectorGen.java, but since this can be done arbitrarily by code from just about anywhere, it's not possible to provide a comprehensive list.

Your best bet might be to have a custom script that runs and sets the relations to what you want once the game has started.

Edit: if there's an accepted standard among mods for where to do this, then hopefully someone else could point you to that? I don't know if there is one or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on May 12, 2022, 12:32:36 PM
In the sector gen file you could do something like:


Code

public void generate(SectorAPI sector)
{
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("Your_Snazzy_Faction");                     

FactionAPI Your_Snazzy_Faction = sector.getFaction("Your_Snazzy_Faction");
FactionAPI player = sector.getFaction(Factions.PLAYER);
FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
FactionAPI pirates = sector.getFaction(Factions.PIRATES);
FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);   
FactionAPI diktat = sector.getFaction(Factions.DIKTAT);
FactionAPI kol = sector.getFaction(Factions.KOL);
FactionAPI persean = sector.getFaction(Factions.PERSEAN);
FactionAPI guard = sector.getFaction(Factions.LIONS_GUARD);
FactionAPI remnant = sector.getFaction(Factions.REMNANTS);
FactionAPI derelict = sector.getFaction(Factions.DERELICT);

//vanilla factions
Your_Snazzy_Faction.setRelationship(player.getId(), RepLevel.NEUTRAL);   
Your_Snazzy_Faction.setRelationship(independent.getId(), RepLevel.NEUTRAL);

Your_Snazzy_Faction.setRelationship(guard.getId(), RepLevel.SUSPICIOUS);   
Your_Snazzy_Faction.setRelationship(diktat.getId(), RepLevel.SUSPICIOUS);
Your_Snazzy_Faction.setRelationship(tritachyon.getId(), RepLevel.SUSPICIOUS);     

Your_Snazzy_Faction.setRelationship(persean.getId(), RepLevel.INHOSPITABLE);
Your_Snazzy_Faction.setRelationship(kol.getId(), RepLevel.INHOSPITABLE);

Your_Snazzy_Faction.setRelationship(pirates.getId(), RepLevel.HOSTILE);
Your_Snazzy_Faction.setRelationship(hegemony.getId(), RepLevel.HOSTILE);
Your_Snazzy_Faction.setRelationship(path.getId(), RepLevel.HOSTILE);   

Your_Snazzy_Faction.setRelationship(church.getId(), RepLevel.VENGEFUL);   

//environment
Your_Snazzy_Faction.setRelationship(remnant.getId(), RepLevel.HOSTILE);
Your_Snazzy_Faction.setRelationship(derelict.getId(), RepLevel.FRIENDLY);     
}

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on May 13, 2022, 11:01:50 AM
What causes the Ziggurat to make the player fleet always ID'able? I could have sworn it was a tag in ship_data.csv but it's only got HIDE_IN_CODEX.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2022, 11:28:43 AM
The variant is given the "ship_unique_signature" when it's recovered.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on May 13, 2022, 11:38:16 AM
So out of curiosity, what are all the files that define how faction relations are at the start?

I'm trying to adjust a mod's starting relations to be a bit more "interesting", but it's proving to be a bit of a struggle.

The method I use only requires two files (the example I'm using comes from KoC (https://fractalsoftworks.com/forum/index.php?topic=23393.0))

data/world/generators.csv this file points towards the file that sets the relationships:
Spoiler
Code
className
data.world.KoClove
[close]

data/world/KoClove.java this file contains the rules that set the starting relationships:

Spoiler
Code
package data.world;

import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.Global;

public class KoClove implements SectorGeneratorPlugin {
@Override
    public void generate(SectorAPI sector) {
initFactionRelationships(sector);
    }

public static void initFactionRelationships(SectorAPI sector) {
        FactionAPI hegemony = sector.getFaction(Factions.HEGEMONY);
FactionAPI tritachyon = sector.getFaction(Factions.TRITACHYON);
FactionAPI pirates = sector.getFaction(Factions.PIRATES);
FactionAPI independent = sector.getFaction(Factions.INDEPENDENT);
FactionAPI church = sector.getFaction(Factions.LUDDIC_CHURCH);
FactionAPI path = sector.getFaction(Factions.LUDDIC_PATH);
FactionAPI player = sector.getFaction(Factions.PLAYER);
FactionAPI diktat = sector.getFaction(Factions.DIKTAT);
        FactionAPI league = sector.getFaction(Factions.PERSEAN);
        FactionAPI KoC = sector.getFaction("KoC");

/// REP LEVELS: VENGEFUL/HOSTILE/INHOSPITABLE/SUSPICIOUS/NEUTRAL/FAVORABLE/WELCOMING/FRIENDLY/COOPERATIVE

KoC.setRelationship(Factions.HEGEMONY, RepLevel.COOPERATIVE);
KoC.setRelationship(Factions.PERSEAN, RepLevel.FRIENDLY);
KoC.setRelationship(Factions.INDEPENDENT, RepLevel.FRIENDLY);
KoC.setRelationship(Factions.TRITACHYON, RepLevel.HOSTILE);
KoC.setRelationship(Factions.LUDDIC_PATH, RepLevel.HOSTILE);
KoC.setRelationship(Factions.PIRATES, RepLevel.HOSTILE);
KoC.setRelationship(Factions.PLAYER, RepLevel.FAVORABLE);
    }

}
[close]

There are other methods but the way I do I create a new .java for each faction and specify it in the .csv that way each faction is separate and easier to keep track of.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on May 13, 2022, 11:45:17 AM
Here's a quick one, is there a way to specify sovereignty in the mod_info.json?

I've got Plight and KoC and after moving assets between them I'm wondering if there's a way to ensure they're used exclusive of each other.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on May 13, 2022, 12:19:19 PM
Here's a quick one, is there a way to specify sovereignty in the mod_info.json?

I've got Plight and KoC and after moving assets between them I'm wondering if there's a way to ensure they're used exclusive of each other.
First one that loads up is usually the first one that stays there.

Or it's the last one that loads last that stays there.

The game is ironically picky on this for some reason regarding specific files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 13, 2022, 04:36:12 PM
I don't like the capture the flag points introduced after .95 version. I'm okay with them providing small buffs as they used to be but I want to decrease their effects and prevent them providing deployment points. I just want the battles maps how they used to be, how can I do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 14, 2022, 09:12:04 AM
I don't like the capture the flag points introduced after .95 version. I'm okay with them providing small buffs as they used to be but I want to decrease their effects and prevent them providing deployment points. I just want the battles maps how they used to be, how can I do that?

The easiest thing to do would be to basically turn objectives off by changing:
"maxNoObjectiveBattleSize":100
In settings.json to some high value (like 10000).

To change the actual effects, you would need to provide a custom implementations of the scripts pointed to from data/config/battle_objectives.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 14, 2022, 05:31:26 PM
I don't like the capture the flag points introduced after .95 version. I'm okay with them providing small buffs as they used to be but I want to decrease their effects and prevent them providing deployment points. I just want the battles maps how they used to be, how can I do that?

The easiest thing to do would be to basically turn objectives off by changing:
"maxNoObjectiveBattleSize":100
In settings.json to some high value (like 10000).

To change the actual effects, you would need to provide a custom implementations of the scripts pointed to from data/config/battle_objectives.json.
Would deleting       "battleSizeFractionBonus":0.1, remove the deployment point bonus? That's the only one introduced after 0.95 right? Thanks for the answer :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 14, 2022, 06:30:50 PM
Oh yeah, forgot that was there! Not sure about deleting it, but setting it to 0 should do the trick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 15, 2022, 03:46:06 PM
Oh yeah, forgot that was there! Not sure about deleting it, but setting it to 0 should do the trick.
Would Best of the Best skill still affect it, AI can have that skill right?

 Also is there a way to increase ECM cap to %20 just like Nav rating?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Bee on May 16, 2022, 08:31:24 AM
Hey, how feasible is it to just make a texture pack? In a completely different artstyle, even?

I know I might be able to replace the ship image files, but how hard would it be to make it into a mod so that the player wouldn't have to manually replace the files?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 16, 2022, 11:53:31 AM
Would Best of the Best skill still affect it, AI can have that skill right?

Yes and I'm not sure offhand.

Also is there a way to increase ECM cap to %20 just like Nav rating?

Yes but you'd, IIRC, have to edit the script and recompile it/provide your own version etc.

Hey, how feasible is it to just make a texture pack? In a completely different artstyle, even?

I know I might be able to replace the ship image files, but how hard would it be to make it into a mod so that the player wouldn't have to manually replace the files?

That should be doable - if you just provide a mod with images in the same folder and with the same names as the vanilla ones, the game should load those instead of the vanilla ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Bee on May 16, 2022, 12:02:18 PM
That should be doable - if you just provide a mod with images in the same folder and with the same names as the vanilla ones, the game should load those instead of the vanilla ones.

Whoah nice! That's extremely convenient!

I love how easily modifiable stuff is in this game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 16, 2022, 12:15:28 PM
:D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on May 17, 2022, 03:29:26 AM
How do I force a bar event to spawn under certain conditions (or even just get the creation code to be called very frequently)? I've tried AddBarEvent, but that doesn't call any of the event's creation code, and I have no clue what I need to do in order to get it to do that. It's basically a slightly modified surplus ship bar event - I've got it working fine under normal conditions, but I'd like it to not be random.

I've also tried adding the priority tag to the entry in bar_events.csv and making the freq/prob entries large numbers, with no effect.

Edit- I think this (https://fractalsoftworks.com/forum/index.php?topic=5061.7830) might answer this question but I need to sleep so I can't test it at the moment. (it was not)

I'm basically trying to create a bar event from bar_events.csv through my own code, rather than the existing RNG, and I have no clue how.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2022, 01:31:01 PM
Would the BeginMission <mission id> command do the trick for you?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on May 17, 2022, 02:32:19 PM
If I use BeginMission and use the bar event ID, I get an error; if I make a person_missions.csv entry and use that ID (and point it to my bar event script) it doesn't error out, but none of the data set on event creation seems to get stored in the "right" memory - all the $heOrShe and similar stuff in the dialog isn't replaced, showing the ship/NPC doesn't work, and adding the ship to the player inventory at the end produces an NPE. Using dev mode to dump the memory doesn't show any of the stuff that would normally get set with the bar event, but logging shows that the create() method is getting called successfully.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 17, 2022, 03:48:00 PM
You'd need to still Call <eventRef> updateData and all that other kinds of stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on May 19, 2022, 01:10:57 PM
Is it possible to generate commodities within a hullmod?

Examples would be generating 100 food per day

Was thinking of using advanceInCampaign() but not sure how to go about implementing it yet and if its performant if possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on May 19, 2022, 09:56:14 PM
How do I force a bar event to spawn under certain conditions (or even just get the creation code to be called very frequently)? I've tried AddBarEvent, but that doesn't call any of the event's creation code, and I have no clue what I need to do in order to get it to do that. It's basically a slightly modified surplus ship bar event - I've got it working fine under normal conditions, but I'd like it to not be random.

I've also tried adding the priority tag to the entry in bar_events.csv and making the freq/prob entries large numbers, with no effect.

Edit- I think this (https://fractalsoftworks.com/forum/index.php?topic=5061.7830) might answer this question but I need to sleep so I can't test it at the moment. (it was not)

I'm basically trying to create a bar event from bar_events.csv through my own code, rather than the existing RNG, and I have no clue how.
Techpriest helped me figure this one out. The thing to know is: ((ArrayList) Global.getSector().getEconomy().getMarket("market id here").getMemoryWithoutUpdate().get("$BarCMD_shownEvents")).add("bar_event_id_here");

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on May 20, 2022, 09:09:48 AM
Is it possible to generate commodities within a hullmod?

Figured out how to do it, I just check if a day has passed then adding the commodity to inventory. Works well enough, not sure about performance but its only the player who would be using the hullmod anyways.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 20, 2022, 02:15:50 PM
Is there a way to decrease AI officer spam  :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2022, 06:08:51 PM
Is there a way to decrease AI officer spam  :o

Hmm - there's "officerAIMaxMercsMult" in settings.json, but since I wouldn't call what that affects anything close to "spam", I'm not quite sure if that's what you mean. The other settings in that general section should let you control pretty much what you want, though, unless it's for specific fleets the game spawns with settings that override that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 21, 2022, 06:58:16 AM
Is there a way to tell which submarket the player is currently looking at (within either fleet or cargo screens)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2022, 08:02:46 AM
I think you should be able to keep track of it by using SubmarketInteractionListener.reportPlayerOpenedSubmarket(). I don't believe there's any method to actually query that state.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Üstad on May 21, 2022, 12:51:04 PM
Is there a way to decrease AI officer spam  :o

Hmm - there's "officerAIMaxMercsMult" in settings.json, but since I wouldn't call what that affects anything close to "spam", I'm not quite sure if that's what you mean. The other settings in that general section should let you control pretty much what you want, though, unless it's for specific fleets the game spawns with settings that override that.
I just want to lower AI officer numbers, the current number is 1. Does making it 0.5 make them %50 less officers or it affects only the over the limit ones? Like the limit is 10 and having half mercenary officer only affects after 10?

What about remnant ships, how do I lower AI core officers? What does "baseFPPerOfficer" do?

Thanks for the answer Alex  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stelarwand030 on May 21, 2022, 03:18:17 PM
For what ever reason i cannot see all the skill choices. Is there a mod or something that adds a scroll bar? or a way to view the entire skill list?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 21, 2022, 03:30:52 PM
For what ever reason i cannot see all the skill choices. Is there a mod or something that adds a scroll bar? or a way to view the entire skill list?

sounds like you're using an old version (for 0.95) of quality captains, turn it off and download the new one
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 22, 2022, 10:36:36 AM
I just want to lower AI officer numbers, the current number is 1. Does making it 0.5 make them %50 less officers or it affects only the over the limit ones? Like the limit is 10 and having half mercenary officer only affects after 10?

If affects the over-the-limit ones, yeah.

You can increase baseCombatShipsPerOfficer - it does pretty much what it says, the average number of ships per ship with an officer.


What about remnant ships, how do I lower AI core officers? What does "baseFPPerOfficer" do?

For AI cores, it's slightly different - baseFPPerAICore - which determines the quantity of AI cores based on the "fleet points" value of the ship, which is not a player-visible stats. It's kind of like the deployment cost, but lower than that for larger ships. Raising that number will reduce the number of AI cores in Remnant fleets.

baseFPPerOfficer is commented out and won't do anything.

Keep in mind that some fleets are scripted to have a large number of officers or AI cores - for example, the high-level Remnant bounties from contacts - and they will not be affected by these kinds of settings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on May 23, 2022, 03:56:44 PM
Is there an easy way (or just a way, period) to reproduce the spatter of debris that's created when a ship takes damage or a missile gets destroyed? Not quite sure how to pull the individual sprites/glow from the debris spritesheet. I'm assuming the code that does it is obfuscated but I'm just kinda hoping there's an API method somewhere that I'm missing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 23, 2022, 04:16:19 PM
Not that I can think of, no. IIRC in the next version you'll be able to specify how much debris missiles spawn when destroyed, but the ship-impact debris still wouldn't be configurable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 24, 2022, 03:48:04 AM
I think you should be able to keep track of it by using SubmarketInteractionListener.reportPlayerOpenedSubmarket(). I don't believe there's any method to actually query that state.
Thanks, this was exactly what I needed!

Though now I have a weird issue:
I set settings.json "shipWeaponBuyPriceMult" to zero, which makes the tooltip claim weapons and fighter LPCs are now free to buy on markets...
(https://i.imgur.com/E5th6PO.png)

But when I actually pick them up, the transaction has a price, which indeed gets charged when I confirm:
(https://i.imgur.com/NNyjqyq.png)

(selling with shipWeaponSellPriceMult = 0 works correctly)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 24, 2022, 10:21:12 AM
... oh wow, it looks like that wasn't working *at all, ever* - not even the base 1.2x multiplier - and has managed to go unnoticed until now. Thank you for catching it, fixed it up :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NEmergix on May 24, 2022, 04:59:57 PM
Hey, new here.

I am looking for a mod that adds new ship variants with their textures, eg an onslaught with a pirate paintjob ( and even modified stats ) but i can't find something despite searching all over the web.

Any help ? Seems like an obvious mod.

i did find stuff like that : Hegemony Expeditionary Auxiliaries (HEA) - v.0.95 but not for pirates , or lp ...

Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on May 25, 2022, 04:17:58 PM
Hey, new here.

I am looking for a mod that adds new ship variants with their textures, eg an onslaught with a pirate paintjob ( and even modified stats ) but i can't find something despite searching all over the web.

Any help ? Seems like an obvious mod.

i did find stuff like that : Hegemony Expeditionary Auxiliaries (HEA) - v.0.95 but not for pirates , or lp ...

Thanks in advance.
This is a thread about mod making
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 26, 2022, 05:28:04 AM
Is there a way to only make specific ships immune to damage from hyperspace storms/corona effects or asteroid impacts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on May 26, 2022, 05:57:40 AM
Speaking of editing skills, interesting, its possible to level up skill more than just to Elite version or this code is in obfuscated part of code and can't be edited? Or say differently, it is possible to port skill system from pre-095 version of the game? 091 one with three levels of each skill or 060 one with 10 levels of skill.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 26, 2022, 06:19:49 AM
Speaking of editing skills, interesting, its possible to level up skill more than just to Elite version or this code is in obfuscated part of code and can't be edited? Or say differently, it is possible to port skill system from pre-095 version of the game? 091 one with three levels of each skill or 060 one with 10 levels of skill.

the underlying systems haven't changed (elite skills are literally just level 2 skills (iirc, been a lil bit since i looked at them)), but the UI no longer allows for them to be levelled ast level 2 so they can't be accessed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on May 26, 2022, 07:10:51 AM
Thats bad, I hope new versions of SS will allow to edit UI stuff too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 26, 2022, 09:55:39 AM
Is there a way to only make specific ships immune to damage from hyperspace storms/corona effects or asteroid impacts?

I think you might be able to do it by modifying:
stats.getDynamic().getStat(Stats.CORONA_EFFECT_MULT)

To a large-ish negative value (like, -10), but I'm not 100% sure and it *might* have some repercussions if some of the code that checks it doesn't check for negative CR loss. (It appears to, but I didn't dig in enough to have actual certainty.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on May 26, 2022, 04:17:17 PM
How does one modify the text messages that appear on the center top of the screen on the campaign view ("Game paused"/"Game resumed" and so on) ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on May 27, 2022, 07:31:56 AM
Is there a way to only make specific ships immune to damage from hyperspace storms/corona effects or asteroid impacts?

The answer to such questions is usually a visible (or invisible) hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on May 27, 2022, 12:55:18 PM
How can I programmatically modify the base range of specific projectile specs once Starsector has loaded?  The WeaponSpecAPI method setMaxRange affects only the length of the weapon arcs, leaving the projectiles with the same range.  The WeaponSpecAPI method getProjectileSpec returns an object of a class I have determined to be the obfuscated ProjectileSpec behind the ProjectileSpecAPI, but the reflection tools I have borrowed from lyravega's Experimental Hullmods cannot reach the setMaxRange method  that my IDE indicates it inherits.  lyravega has suggested I ask Alex about this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 27, 2022, 06:01:09 PM
How does one modify the text messages that appear on the center top of the screen on the campaign view ("Game paused"/"Game resumed" and so on) ?

Global.getSector().getCampaignUI().getMessageDisplay();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on May 27, 2022, 10:37:52 PM
Hmmm, working on adding a second faction to my mod.   I got it to generate the system for them, the first faction system is still working.

However when I get <2 light years from the second faction's system, the game crashes with:

Spoiler
425701 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficer sV2(FleetFactoryV3.java:995)
   at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficer s(FleetFactoryV3.java:857)
   at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.createFleet(FleetFactoryV3.java:414)
   at com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager.createTradeR outeFleet(EconomyFleetRouteManager.java:627)
   at com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager.spawnFleet(EconomyFleetRouteManager.java:487)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:619)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
   at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:140)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]


I'm assuming it is trying to generate ships and there is something that it not config'd correctly for the second faction?   Any ideas on where the root cause is?

EDIT:  Hmmm turns out it was my attempt to list a custom names list in the faction file:

"names":
{
    "orks":1,    
},

I have a data/characters/person_names.csv and it looks like this:

name   gender   usage   category
         
Atulg           m,f           f           orks
Azlak   m,f           f           orks
Azuk           m,f           f           orks



Do I need to associate the person_names.csv somehow?



EDIT 2:  Hrrmmmm... everything started working after the 5th attempt  o.0   Not sure about root cause on this one ..........
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 28, 2022, 07:59:53 AM
how do weaponOPCostModifier (and their fighter variant) listeners work?

Code
    public static class SDSY_WandererOPCostListener implements WeaponOPCostModifier {

        @Override
        public int getWeaponOPCost(MutableShipStatsAPI stats, WeaponSpecAPI weapon, int currCost) {

            int discount = 0;

            for (String tag : weapon.getTags()) {
                if (tag.startsWith("wanderer_discount_")) {
                    discount = Integer.parseInt(tag.substring(18));
                }
            }
            return discount;
        }
    }

I've got this listener being added in afterShipCreation and it doesn't seem like it's doing anything, what do I need to have it return (does it need to be the modified value or just the difference?) and is there anything else I need to do?

EDIT - cleaned up code, ty to tomatopaste!

EDIT 2 - being more specific about the way I'm testing it- I'm using SCVE's (https://fractalsoftworks.com/forum/index.php?topic=21591.0) mod tester main menu mission, that might be interfering? (it also prevents me from doing it beforeCreation, if that's the problem) ignore this, read edit 4

EDIT 3 - and a second question - how do you get the status of a ship's right-click system if it isn't shields or phase? is it just getPhaseCloak?

EDIT 4 - Figured it all out, I reread the API documentation and actually noticed that it's gotta be added to the MutableStats, not the ship (also made the hullmod affectOPCosts, but idk if that helped), that I can do just fine in beforeCreation
also for anyone trying to figure this out later- it needs to return the modified value, not just the difference
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on May 28, 2022, 12:47:19 PM
What determines whether an industry is player-buildable or not? My weak java-fu can't find anything and I don't see anything in industries.csv that would affect that either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 28, 2022, 12:57:53 PM
It is in the industry's script: Industry.isAvailableToBuild() and Industry.showWhenUnavailable()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on May 28, 2022, 01:30:21 PM
It is in the industry's script: Industry.isAvailableToBuild() and Industry.showWhenUnavailable()

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on May 28, 2022, 05:34:46 PM
Is there a way to detect when a ship has retreated from combat?

ShipAPI.isRetreating() seems to return true once the retreat order is given, but I can't find anything for when it actually leaves the battlefield
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Visha on May 28, 2022, 08:51:55 PM
So, using UAF and Big Bean's ships and I was getting a crash on the Adventurer and the Pirate Venture when using the auto fit and then hitting weapon groups. This then causes a crash. Then did a test where we removed the auto fit, and added guns one at a time. No crash. Cleared the standard autofits, made one with just UAF guns and fighter. No crash. Seems that something in the Big Bean ship pack autofits is causing the crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 29, 2022, 12:38:46 PM
How can I programmatically modify the base range of specific projectile specs once Starsector has loaded?  The WeaponSpecAPI method setMaxRange affects only the length of the weapon arcs, leaving the projectiles with the same range.  The WeaponSpecAPI method getProjectileSpec returns an object of a class I have determined to be the obfuscated ProjectileSpec behind the ProjectileSpecAPI, but the reflection tools I have borrowed from lyravega's Experimental Hullmods cannot reach the setMaxRange method  that my IDE indicates it inherits.  lyravega has suggested I ask Alex about this.

Hmm, I'm not sure that you can, actually, aside from what you're trying to do. As to why that might not be working, I can't say.

EDIT 3 - and a second question - how do you get the status of a ship's right-click system if it isn't shields or phase? is it just getPhaseCloak?

Yep!

EDIT 4 - Figured it all out, I reread the API documentation and actually noticed that it's gotta be added to the MutableStats, not the ship (also made the hullmod affectOPCosts, but idk if that helped), that I can do just fine in beforeCreation
also for anyone trying to figure this out later- it needs to return the modified value, not just the difference

Glad you got it figured out!


Is there a way to detect when a ship has retreated from combat?

ShipAPI.isRetreating() seems to return true once the retreat order is given, but I can't find anything for when it actually leaves the battlefield

I don't believe there's any actual notification for this. You might look at CombatFleetManagerAPI.getRetreatedCopy() to see when the relevant fleet member shows up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 01, 2022, 07:25:41 PM
Hmm, I'm not sure that you can, actually, aside from what you're trying to do. As to why that might not be working, I can't say.

I've figured it out!

Code
ProjectileSpecAPI projectileSpecAPI = (ProjectileSpecAPI) weaponSpecAPI.getProjectileSpec();
projectileSpecAPI.setMaxRange(maxRange);

Also, do I have your blessing to distribute the following obfuscated code magic? 

I have created a proxy class for that obfuscated ooOOOOOOOO... class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for beam weapons, with a method handle for each obfuscated method of a non-obfuscated type (alongside identical code for the methods of obfuscated types commented-out in-place).  I created it because I needed to call the obfuscated setBeamSpeed method of this obfuscated class to programmatically change the speed of beams.  I also want to complete my existing proxy for that obfuscated class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for projectile weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 02, 2022, 03:00:08 AM
Found a weird mod interaction issue.

Normally, calling Global.getSector() in ModPlugin.onApplicationLoad() returns null. However, you can force a sector to exist by calling SettingsAPI.doesVariantExist:

Code: java
	@Override
public void onApplicationLoad() throws Exception {
Global.getLogger(this.getClass()).info("Sector is " + Global.getSector());
Global.getSettings().doesVariantExist("foobar");
Global.getLogger(this.getClass()).info("Sector is " + Global.getSector());
}
21653 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Sector is null
21728 [Thread-3] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/particlealpha32sq.png (using cast)
21754 [Thread-3] INFO  org.histidine.testmod.plugins.TestModPlugin  - Sector is com.fs.starfarer.campaign.CampaignEngine@7bdde97d

The reason it came up: Apparently someone else's mod was crashing on app load if Nexerelin wasn't enabled, because getSector returned null
(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Schaf-Unschaf on June 02, 2022, 06:30:56 AM
The reason it came up: Apparently someone else's mod was crashing on app load if Nexerelin wasn't enabled, because getSector returned null
(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)

Yep, that's exactly the reason why i called it onApplicationLoad() (correcting imported faction strings). Now i'm doing it onGameLoad() instead.
Never noticed that.. who even is playing modded without Nex? xD
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on June 02, 2022, 07:09:12 AM
> Never noticed that.. who even is playing modded without Nex? xD

I do.

When I removeIntel() from intel manager, will the implementation also removeScript(this) internally, or should I remove both intel and script myself? What if the intel was added as transient script?

Can I change currently selected intel programmatically, without showing Intel UI? Ideally, I'd like to reset it to unselected state.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2022, 11:51:25 AM
Also, do I have your blessing to distribute the following obfuscated code magic? 

I have created a proxy class for that obfuscated ooOOOOOOOO... class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for beam weapons, with a method handle for each obfuscated method of a non-obfuscated type (alongside identical code for the methods of obfuscated types commented-out in-place).  I created it because I needed to call the obfuscated setBeamSpeed method of this obfuscated class to programmatically change the speed of beams.  I also want to complete my existing proxy for that obfuscated class which extends the obfuscated BaseWeaponSpec class to create a custom obfuscated WeaponSpec for projectile weapons.

I would *much* rather get a request for API improvements - that's a more sustainable way going forward, and it won't break when a new version is out.

(Just added WeaponSpecAPI.setBeamSpeed(), btw.)

(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)

Interesting. Definitely not a "valid" usage - at least in terms of "usage that's expected to work", though; calling getSector() outside the campaign may return null. Or an old campaign. Or whatever else. The getAllFactions() method can't work outside the campaign, though, since factions have a bunch of data that is persistent (such as additional known hulls etc). There is a (not exposed with the API) FactionSpec class under the hood, though, and *that* could be made visible with a FactionSpecAPI interface... hmm.

When I removeIntel() from intel manager, will the implementation also removeScript(this) internally, or should I remove both intel and script myself? What if the intel was added as transient script?

You need to removeScript() yourself - it has no idea where you might've added it as a script. (The sector, a location, some kind of entity...)

For a transient script you'd want to remove it anyway - it'll go away on save load, but it seems like you would not want it to keep being advance()'ed after removal.

Can I change currently selected intel programmatically, without showing Intel UI? Ideally, I'd like to reset it to unselected state.

I don't think so, let me make a note!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 02, 2022, 12:49:17 PM
I would *much* rather get a request for API improvements - that's a more sustainable way going forward, and it won't break when a new version is out.

(Just added WeaponSpecAPI.setBeamSpeed(), btw.)

Eek!  Will do!  :-[ 

Thanks so much for the API extension, Alex! :D  The fewer proxies, the better, and a richer API enables deeper modding!

And speaking of the API, my mod entails the following proxy methods, which I would be grateful to see added to the API sometime.

Code
public class ProjectileWeaponSpecProxy {
    public static void setEnergyPerShot(float energyPerShot) {}
    public static void setRefireDelay(float refireDelay) {}
    public static void setBurstDelay(float burstDelay) {}
    public static void setBurstSize(float burstSize) {}
    public static void setMaxAmmo(int maxAmmo) {}
    public static void setAmmoPerSecond(float ammoPerSecond) {}
    public static void setReloadSize(float reloadSize) {}
}

Until then, at least throwables from my proxies (and the tools that create them) are handled safely and logged clearly.

My mod combines these proxies to give ballistic weapons the following real-life attributes:
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 02, 2022, 06:23:30 PM
(One valid reason to be asking for a sector at application load is to list all existing factions with getAllFactions(). Maybe SettingsAPI should have its own version of that method?)

Interesting. Definitely not a "valid" usage - at least in terms of "usage that's expected to work", though; calling getSector() outside the campaign may return null. Or an old campaign. Or whatever else. The getAllFactions() method can't work outside the campaign, though, since factions have a bunch of data that is persistent (such as additional known hulls etc). There is a (not exposed with the API) FactionSpec class under the hood, though, and *that* could be made visible with a FactionSpecAPI interface... hmm.
Well I was thinking a SettingsAPI method could return a list of faction IDs, and the mod calls SettingsAPI.createBaseFaction if it needs data from a particular faction (according to createBaseFaction's javadoc, this is indeed what it's for).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2022, 06:25:04 PM
Well I was thinking a SettingsAPI method could return a list of faction IDs, and the mod calls SettingsAPI.createBaseFaction if it needs data from a particular faction (according to createBaseFaction's javadoc, this is indeed what it's for).

Ah! I forgot that was a thing, yeah, that makes sense :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on June 02, 2022, 07:34:33 PM
I just wanted to say that I've read this thread from page 1 to now.   A decade of people getting help with questions by others and the dev himself.   Bravo to such a level of support everyone!

Anywho, my question:


What does the impact column in the weapon_data.csv do?   

I'm trying to have a weapon hit impart a large force on the ship,  As in give it a nice push based on the mass of the ship.   Is there a separate function to enable this?

Also, how do I setup my custom faction ships (more likely, variants) to be able to select them in the simulator?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Phaseus on June 02, 2022, 09:25:51 PM
I've got one. Haven't been able to find anyone that's run into this exact issue.

Contains minor [REDACTED] spoilers.

I've got custom portraits specifically for [REDACTED] characters and officers so they don't all look like faces in the tech-aether. For contacts with [REDACTED] it works perfectly fine; but as soon as you start combat with any of them, or install any core into a [REDACTED] ship the system defaults to the old red/green/blue portraits. Trying to manually change the portrait in campaign.xml after recruitment just results in a blank officer profile, as if you'd used a transparent image and a black background.

The custom [REDACTED] images are 128x128 PNG and are actually smaller in data size than my regular custom portraits, so I'm not sure what's wrong. I can save-modify regular officers just fine.

Attaching images of the campaign.xml file modifications. Spoilers for people that haven't played the game for longer than an hour or three.

Here is one of the officers.
Spoiler
(https://i.imgur.com/uX9Ahlu.png)
[close]
Note that I've changed the spr= variable, and the g= variable.
spr is modified because that's the character sprite. g is modified because the sprite is currently only assigned to 'female' [REDACTED]. Default was ANY, but it made no difference.

Here is my player character by comparison.
Spoiler
(https://i.imgur.com/WIBhduo.png)
[close]
Note that the only differences here are the specific sprite, some general information, and the 'a' value = true (Not sure what it does, but I assume player-specific, no other characters have 'a' = true. Also with some testing it didn't do anything).

I suspect there's something somewhere that specifically targets [REDACTED] officers outside of the player.faction and [REDACTED].faction files.

EDIT: This may not actually count as  a 'minor' question. There's plenty of threads about modifying saves for regular officer portraits, just not [REDACTED] ones.
Also, I've tried using the VIC mod's officer appearance change in-game. It doesn't count [REDACTED] as officers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 03, 2022, 02:35:48 AM
I just wanted to say that I've read this thread from page 1 to now.   A decade of people getting help with questions by others and the dev himself.   Bravo to such a level of support everyone!

Anywho, my question:


What does the impact column in the weapon_data.csv do?   

I'm trying to have a weapon hit impart a large force on the ship,  As in give it a nice push based on the mass of the ship.   Is there a separate function to enable this?

Also, how do I setup my custom faction ships (more likely, variants) to be able to select them in the simulator?

impact rotates the target iirc, the grav beam uses it
to actually push them back, you'll need some code- lazylib has a useful applyForce function for that!

and you need to add them to sim_opponents.csv to get them to show up in the simulator

I've got one. Haven't been able to find anyone that's run into this exact issue.

Contains minor [REDACTED] spoilers.

I've got custom portraits specifically for [REDACTED] characters and officers so they don't all look like faces in the tech-aether. For contacts with [REDACTED] it works perfectly fine; but as soon as you start combat with any of them, or install any core into a [REDACTED] ship the system defaults to the old red/green/blue portraits. Trying to manually change the portrait in campaign.xml after recruitment just results in a blank officer profile, as if you'd used a transparent image and a black background.

<the rest of your question>

are your custom portraits located in your mod's grapics/portraits folder, with the same names as the vanilla ones?
this'll more or less replace the vanilla graphics, it's a slightly brute force solution but it'll work- I suspect they're getting reset because AI cores aren't "real" officers and they get regenerated every time you go into battle (or something like that, haven't looked at it under the hood), replacing your edited graphic with the default one every time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Phaseus on June 03, 2022, 08:22:39 AM
are your custom portraits located in your mod's grapics/portraits folder, with the same names as the vanilla ones?
this'll more or less replace the vanilla graphics, it's a slightly brute force solution but it'll work- I suspect they're getting reset because AI cores aren't "real" officers and they get regenerated every time you go into battle (or something like that, haven't looked at it under the hood), replacing your edited graphic with the default one every time.

I don't have it installed as a separate mod. I just have the portraits in the basegame folder and referenced in all the relevant .faction files. Works for regular officers, just not [REDACTED].

I don't think they're getting regenerated at all. In campaign.xml they were referencing one of the base AI .png and it never changes. Before modding one of them was always blue and the other was green.

I'll try your suggestion of renaming them after the original AI images and see if that works, though I'd like to avoid it because I have 'MALE' and 'FEMALE' specific portraits for [REDACTED] avatars. I didn't make replacer images, just added new ones.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: punchslinger on June 03, 2022, 09:11:07 AM
Hello,

How do I make my ships spawn as a wreck/derelict when generating world?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 03, 2022, 09:43:28 AM
Hello,

How do I make my ships spawn as a wreck/derelict when generating world?

https://jaghaimo.github.io/starsector-api/classcom_1_1fs_1_1starfarer_1_1api_1_1impl_1_1campaign_1_1missions_1_1hub_1_1HubMissionWithTriggers_1_1SpawnDerelictAction.html
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Phaseus on June 03, 2022, 09:48:27 AM
I don't have it installed as a separate mod. I just have the portraits in the basegame folder and referenced in all the relevant .faction files. Works for regular officers, just not [REDACTED].

I don't think they're getting regenerated at all. In campaign.xml they were referencing one of the base AI .png and it never changes. Before modding one of them was always blue and the other was green.

I'll try your suggestion of renaming them after the original AI images and see if that works, though I'd like to avoid it because I have 'MALE' and 'FEMALE' specific portraits for [REDACTED] avatars. I didn't make replacer images, just added new ones.

Deleting the base game portraits and renaming the custom portraits seems to work fine. I would rather not have had to do that, though. I still feel like there has to be a reference somewhere that checks for two different file names, and if they don't match it has an error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 03, 2022, 12:05:26 PM
Eek!  Will do!  :-[ 

Thanks so much for the API extension, Alex! :D  The fewer proxies, the better, and a richer API enables deeper modding!

And speaking of the API, my mod entails the following proxy methods, which I would be grateful to see added to the API sometime.

Code
public class ProjectileWeaponSpecProxy {
    public static void setEnergyPerShot(float energyPerShot) {}
    public static void setRefireDelay(float refireDelay) {}
    public static void setBurstDelay(float burstDelay) {}
    public static void setBurstSize(float burstSize) {}
    public static void setMaxAmmo(int maxAmmo) {}
    public static void setAmmoPerSecond(float ammoPerSecond) {}
    public static void setReloadSize(float reloadSize) {}
}

Until then, at least throwables from my proxies (and the tools that create them) are handled safely and logged clearly.

Thank you very much, I appreciate you taking the time! I've added these methods (and a bunch more); some to WeaponSpecAPI (where they were shared across all weapon spec types, i.e. ammo) and also to a new ProjectileWeaponSpecAPI interface, which you can case a WeaponSpecAPI to if it's the right kind of weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 03, 2022, 01:25:46 PM
Thank you very much, I appreciate you taking the time! I've added these methods (and a bunch more); some to WeaponSpecAPI (where they were shared across all weapon spec types, i.e. ammo) and also to a new ProjectileWeaponSpecAPI interface, which you can case a WeaponSpecAPI to if it's the right kind of weapon.

(https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fi2.kym-cdn.com%2Fentries%2Ficons%2Foriginal%2F000%2F016%2F911%2Fmcmahongif.PNG&f=1&nofb=1)

I will let the rest of the modding community know about the big news!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 03, 2022, 02:37:51 PM
Thank you very much, I appreciate you taking the time! I've added these methods (and a bunch more); some to WeaponSpecAPI (where they were shared across all weapon spec types, i.e. ammo) and also to a new ProjectileWeaponSpecAPI interface, which you can case a WeaponSpecAPI to if it's the right kind of weapon.

Until the next Starsector release, may I release my mod with those proxy methods which it needs, and which you have added to the API?  It's save-safe total combat conversion, and I'm so proud! :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 03, 2022, 02:40:05 PM
Go for it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 03, 2022, 02:56:15 PM
Go for it!


;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: punchslinger on June 04, 2022, 07:13:22 AM
Hello,

How do I make my ships spawn as a wreck/derelict when generating world?

https://jaghaimo.github.io/starsector-api/classcom_1_1fs_1_1starfarer_1_1api_1_1impl_1_1campaign_1_1missions_1_1hub_1_1HubMissionWithTriggers_1_1SpawnDerelictAction.html

Hello,

Sorry to trouble but I do not know what to do with the information given. Could maybe guide me a little? Again sorry, and thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 04, 2022, 12:37:38 PM
Hello,

Sorry to trouble but I do not know what to do with the information given. Could maybe guide me a little? Again sorry, and thanks.

If you know how to code, then call that method in your mod code.  If not, then come to the Unofficial Starsector Discord to learn how!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 07, 2022, 12:19:02 PM
Is there a way to see what weapon slot a weapon is in in a weaponOpCostModifier listener (and if not, can we get one?)

rn I've got a theoretical workaround of "get variant from mutableStats, check if valid weapon is in the correct slot, change cost accordingly", though I doubt it'll work.

the main reason why I've been thinking about this is to encourage more build variety (or limit it in interesting ways), doing stuff like limiting beams on high tech-adjacent ships, buffing weapons that go in certain mounts or excluding them from going in others, that kinda thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: .Wav on June 08, 2022, 10:46:36 AM
What file dictates the response for fleets when you open a comms request with them?

Additionally I currently have an issue with my faction military name not displaying only 'military' when in the marketplace, is that also in a file location?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 08, 2022, 06:20:48 PM
Is there a way to see what weapon slot a weapon is in in a weaponOpCostModifier listener (and if not, can we get one?)

rn I've got a theoretical workaround of "get variant from mutableStats, check if valid weapon is in the correct slot, change cost accordingly", though I doubt it'll work.

the main reason why I've been thinking about this is to encourage more build variety (or limit it in interesting ways), doing stuff like limiting beams on high tech-adjacent ships, buffing weapons that go in certain mounts or excluding them from going in others, that kinda thing.

That makes sense, yeah, but I don't think there's a straightforward way to do that. Would be kind of a pain to change to core code to make it possible, too, unfortunately, but I'll keep it in mind!

What file dictates the response for fleets when you open a comms request with them?

data/campaign/rules.csv :)

Additionally I currently have an issue with my faction military name not displaying only 'military' when in the marketplace, is that also in a file location?

I'm not sure what you mean!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: .Wav on June 09, 2022, 08:28:12 AM
I'm not sure what you mean!



Whoops, I should clarify. Here's an example, https://imgur.com/a/tDsSJb2 , not sure why the faction name is missing from header, but shows in the description when you mouse over it.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 09, 2022, 12:33:38 PM
Whoops, I should clarify. Here's an example, https://imgur.com/a/tDsSJb2 , not sure why the faction name is missing from header, but shows in the description when you mouse over it.

Ah, thank you! Your faction needs a "personNamePrefix":"<whatever>", to make that work. Make sure you're not missing other stuff from that section of the .faction file that other factions have, too...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: .Wav on June 09, 2022, 01:55:54 PM
Whoops, I should clarify. Here's an example, https://imgur.com/a/tDsSJb2 , not sure why the faction name is missing from header, but shows in the description when you mouse over it.

Ah, thank you! Your faction needs a "personNamePrefix":"<whatever>", to make that work. Make sure you're not missing other stuff from that section of the .faction file that other factions have, too...

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on June 09, 2022, 11:35:36 PM
Short version: I'm trying to use a custom subclass of BaseBarEvent with the "new" HubMission quest framework. Is this practically possible?


Long version: I do not want to use rules.csv to drive bar and interaction dialogs and feel strongly about this. The pre-0.9.5 system allowed these to be implemented as code by subclassing BaseBarEvent and using addPromptAndOption, onOptionSelected, etc.

The newer system adds HubMissionBarEventWrapper, which seems to be hardcoded to be the only subclass of BaseBarEvent used for HubMissions.
Well.
I could not use bar_events.csv and instead use the old system to add my BarEventCreator manually, copying the relevant code from HubMissionBarEventWrapper to create a HubMission into my custom subclass of BaseBarEvent. If my thinking is right, that'll bypass the tight coupling to rules.csv for driving the dialogs while still allowing use of HubMission without rules.csv. The downside is simply that interacting with BarEventManager manually is not as simple as utilizing vanilla code to do the same.


So, is skipping bar_events.csv and manually adding the custom bar event with ripped logic from HubMissionBarEventWrapper to PortsideBarData going to be my best bet, or is there something simpler that I'm missing?


(and, a peek at what I'm working on to give it some air of credibility or something, maybe the opposite)
Spoiler
https://github.com/davidwhitman/stories/blob/dev/data/strings/telos.hjson
and that json fully works in-game using a framework based on the pre-0.95 quest system.

This is the adapter between the json and the framework, ie the part that changes per-quest: https://github.com/davidwhitman/stories/blob/dev/src/main/kotlin/wisp/perseanchronicles/telos/pt1_deliveryToEarth/Telos_Stage1_BarEvent.kt#L16
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 10, 2022, 09:41:45 AM
I could not use bar_events.csv and instead use the old system to add my BarEventCreator manually, copying the relevant code from HubMissionBarEventWrapper to create a HubMission into my custom subclass of BaseBarEvent. If my thinking is right, that'll bypass the tight coupling to rules.csv for driving the dialogs while still allowing use of HubMission without rules.csv. The downside is simply that interacting with BarEventManager manually is not as simple as utilizing vanilla code to do the same.

So, is skipping bar_events.csv and manually adding the custom bar event with ripped logic from HubMissionBarEventWrapper to PortsideBarData going to be my best bet, or is there something simpler that I'm missing?

That sounds like it should work, just based on the fact that old-style bar events still work.

Another option might be to have some stubs in rules.csv that just call some code that does the "which mission is it and which methods should get called" routing for you. So for example some kind of CustomMissionCommand rule-class that you'd call from the rule-stubs when the mission is shown, accepted, etc. And your class that creates missions could put the mission object somewhere where the command class could retrieve it and call the righr method on it. Whether that sort of thing is more or less complicated than what you're already doing, I couldn't say!


(and, a peek at what I'm working on to give it some air of credibility or something, maybe the opposite)
Spoiler
https://github.com/davidwhitman/stories/blob/dev/data/strings/telos.hjson
and that json fully works in-game using a framework based on the pre-0.95 quest system.

This is the adapter between the json and the framework, ie the part that changes per-quest: https://github.com/davidwhitman/stories/blob/dev/src/main/kotlin/wisp/perseanchronicles/telos/pt1_deliveryToEarth/Telos_Stage1_BarEvent.kt#L16
[close]

(Very cool!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 10, 2022, 11:58:42 AM
Is there a way to see what weapon slot a weapon is in in a weaponOpCostModifier listener (and if not, can we get one?)

rn I've got a theoretical workaround of "get variant from mutableStats, check if valid weapon is in the correct slot, change cost accordingly", though I doubt it'll work.

the main reason why I've been thinking about this is to encourage more build variety (or limit it in interesting ways), doing stuff like limiting beams on high tech-adjacent ships, buffing weapons that go in certain mounts or excluding them from going in others, that kinda thing.

That makes sense, yeah, but I don't think there's a straightforward way to do that. Would be kind of a pain to change to core code to make it possible, too, unfortunately, but I'll keep it in mind!

awww, that's a shame but perfectly understandable, thanks for the reply!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on June 11, 2022, 11:34:19 AM
...
So, is skipping bar_events.csv and manually adding the custom bar event with ripped logic from HubMissionBarEventWrapper to PortsideBarData going to be my best bet, or is there something simpler that I'm missing?

That sounds like it should work, just based on the fact that old-style bar events still work.

Another option might be to have some stubs in rules.csv that just call some code that does the "which mission is it and which methods should get called" routing for you. So for example some kind of CustomMissionCommand rule-class that you'd call from the rule-stubs when the mission is shown, accepted, etc. And your class that creates missions could put the mission object somewhere where the command class could retrieve it and call the righr method on it. Whether that sort of thing is more or less complicated than what you're already doing, I couldn't say!

Thank you - I ended up going back to the old way and managed to wrangle my code into working.
I successfully have:
- bar event text, options, and navigation defined in json
- bar event class triggered/managed using code only
- quest and intel use HubMission

Rule stubs were tempting, but I think they'd be tied to the mission id, so the "user" (me) of my framework would need to add stubs for each new quest; not terrible, but I'm trying to avoid needing the "user" needing to know any magic strings.
Code
FireBest.fire(null, dialog, memoryMap, mission.getTriggerPrefix() + "_blurbBar true");
FireBest.fire(null, dialog, memoryMap, mission.getTriggerPrefix() + "_optionBar true");)
Now to clean up my messy code, fix the memory leaks, fix some wiring not working, and find and fix all the other bugs...and then maybe implement some more actual content :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2022, 11:35:55 AM
Nice! And, yeah, think you're right about the stubs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 12, 2022, 04:07:36 PM
what do the intensity and range params in the ShipAPI.setJitter()s do?
at a guess, intensity would be the speed that the jitter moves at & range is the max distance that they can be from the ship, but that doesn't quite seem to be the case from some short testing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on June 12, 2022, 11:37:54 PM

Thank you very much, I appreciate you taking the time! I've added these methods (and a bunch more); some to WeaponSpecAPI (where they were shared across all weapon spec types, i.e. ammo) and also to a new ProjectileWeaponSpecAPI interface, which you can case a WeaponSpecAPI to if it's the right kind of weapon.
Probably obvious and already done, but I'd love if we could manipulate them like other mutable stats (modifyMult, modifyPercent, modifyMult), as they're much simpler than doing it from base get and sets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2022, 10:14:46 AM
what do the intensity and range params in the ShipAPI.setJitter()s do?
at a guess, intensity would be the speed that the jitter moves at & range is the max distance that they can be from the ship, but that doesn't quite seem to be the case from some short testing.

The intensity is just the brightness of the jitter.

Thank you very much, I appreciate you taking the time! I've added these methods (and a bunch more); some to WeaponSpecAPI (where they were shared across all weapon spec types, i.e. ammo) and also to a new ProjectileWeaponSpecAPI interface, which you can case a WeaponSpecAPI to if it's the right kind of weapon.
Probably obvious and already done, but I'd love if we could manipulate them like other mutable stats (modifyMult, modifyPercent, modifyMult), as they're much simpler than doing it from base get and sets.

Ah - that's not how that's set up at all. The MutableStat type things are meant for game objects where multiple sources of modifications need to try to coexist. While I recognize that this might be the case for specs too when multiple mods try to make changes, it's less likely and they're just fundamentally a raw data-holder class with getters and setters.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 14, 2022, 09:43:25 PM
Is there a way to get/set the scroll position in a TooltipMakerAPI? I want to work around the behavior where it goes back to the top after calling IntelUIAPI.updateUIForItem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 15, 2022, 09:20:26 AM
There isn't, no - let me make a note about that!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Bob69Joe on June 15, 2022, 10:13:51 AM
How can I disable the default portraits and add new ones, and can I do that mid-game?

I just want more of Company of Heroes 2 portraits. by priestacity
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: briansd9 on June 16, 2022, 02:53:12 AM
There isn't, no - let me make a note about that!

Hmm, while on the topic, would it be possible to make IntelUIAPI.updateUIForItem() navigate to a different IntelInfoPlugin if passed an argument other than this (the current intel item being displayed)?

Current behavior is it just goes to starmap.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 16, 2022, 12:17:26 PM
I actually added IntelUIAPI.selectItem() just a week or so ago!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 16, 2022, 07:58:58 PM
How can I disable the default portraits and add new ones, and can I do that mid-game?

I just want more of Company of Heroes 2 portraits. by priestacity
The easy way (and the one that works midgame) is to just replace the vanilla portraits by having other images with the same folder and filename in your mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on June 17, 2022, 02:07:28 PM
Greets all. I have a question regarding the aggression settings in Hiver Swarm. I have tweaked it based on all the documentation I could find and added a second system to sort of force them to travel across the map but I still get complaints that they are not aggressive enough. At this point I am unsure if it is a matter of my ignorance, maybe I have them too distant or that I have reached the limit of aggression allowed in the game. Attached below are the json and the faction files (had to save them as a txt to get it attached) for the mod that I believe are the only files that effect aggression.

Any help would be appreciated, thank you.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 18, 2022, 02:55:55 AM
Is the vanilla fleet navigation module available for modding?

I have some features where a fleet is supposed to follow player fleet around (or rather, follow a token set to the same location as player fleet), but I've heard issues being reported with it. Like the fleet is following player, sees player enter system using a jump point, then uses a completely different jump point to enter the system. So I was wondering if I could make a fleet just take the shortest route to player location even if it loses sight.

Greets all. I have a question regarding the aggression settings in Hiver Swarm. I have tweaked it based on all the documentation I could find and added a second system to sort of force them to travel across the map but I still get complaints that they are not aggressive enough. At this point I am unsure if it is a matter of my ignorance, maybe I have them too distant or that I have reached the limit of aggression allowed in the game. Attached below are the json and the faction files (had to save them as a txt to get it attached) for the mod that I believe are the only files that effect aggression.

Any help would be appreciated, thank you.
Aggression in combat or Nex's strategic layer? The first is a matter of ship AI; your current settings should have all the officers be reckless, but ship AI is a bit hard to understand so it may still have issues; it may be afraid to close due to being badly outranged, for instance.
If it's about Nex, specify in what way it's not being aggressive enough (not launching enough invasions?) and I might take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on June 18, 2022, 03:22:08 AM
Aggression in combat or Nex's strategic layer? The first is a matter of ship AI; your current settings should have all the officers be reckless, but ship AI is a bit hard to understand so it may still have issues; it may be afraid to close due to being badly outranged, for instance.
If it's about Nex, specify in what way it's not being aggressive enough (not launching enough invasions?) and I might take a look.

I apologize, I should have been more specific. The mod is meant to be is a non player enemy AI faction designed to be aggressive invaders as well as colonize systems. I have Nex as a required mod since it relies on your wonderful mod to make it work as intended. I have received some complaints that although they do invade eventually, it is slower than they would like. I believe I have them at maximum aggression but I am a still new to modding and am probably missing something, idk. Also, although I have them set to a high probability to colonize (I think) they rarely, if ever, do so.

Thank you for taking the time, I appreciate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 18, 2022, 08:29:21 AM
Is the vanilla fleet navigation module available for modding?

I have some features where a fleet is supposed to follow player fleet around (or rather, follow a token set to the same location as player fleet), but I've heard issues being reported with it. Like the fleet is following player, sees player enter system using a jump point, then uses a completely different jump point to enter the system. So I was wondering if I could make a fleet just take the shortest route to player location even if it loses sight.

IIRC fleet AI just uses the closest-to-it jump-point that leads to the right LocationAPI. I *think* the easiest thing to do might be to make it follow the jump-point you want it to take and only switch to following the player-token once it's on top of it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lord Admiral Spire on June 19, 2022, 12:14:16 AM
Is it possible to have a weapon/hullmod/other component specifically do crew or CR damage?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 19, 2022, 05:59:17 PM
Is it possible to have a weapon/hullmod/other component specifically do crew or CR damage?

Technically correct but probably not very useful answer: yes.

(If you're doing something specific, it might help to know exactly which bit of it you're running into trouble with.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lord Admiral Spire on June 20, 2022, 12:46:56 PM
Is it possible to have a weapon/hullmod/other component specifically do crew or CR damage?

Technically correct but probably not very useful answer: yes.

(If you're doing something specific, it might help to know exactly which bit of it you're running into trouble with.)

Currently looking to simulate boarding and morale mechanics and morale mechanics to imitate various weapons, abilities, and systems from the source material I have. Applying CR drain and/or crew damage to systems/weapons/hullmods seems the most direct route, but I've as of yet gleaned no way to accomplish this without seriously brushing up on my Java.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on June 21, 2022, 01:56:07 AM
Where can I find the Java code for marines commodity in the src of Starsector?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on June 21, 2022, 02:18:08 AM
There isn't, no - let me make a note about that!

Could you please confirm API request thread asks? For example, I did ask for this back in November: https://fractalsoftworks.com/forum/index.php?topic=4900.msg345871#msg345871

The suggestion thread does feel neglected - we haven't heard you there since late November :(

I actually added IntelUIAPI.selectItem() just a week or so ago!

Thank you! Does it accept allow to just deselect whatever is selected (passing `null` I guess) just like `showCoreUITab(CoreUITabId.INTEL, null)` does?

Edit: For people needing this now, there is an ugly workaround (flickers IntelUI screen momentarily): https://fractalsoftworks.com/forum/index.php?topic=24681.msg366999#msg366999
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 21, 2022, 10:01:17 AM
Currently looking to simulate boarding and morale mechanics and morale mechanics to imitate various weapons, abilities, and systems from the source material I have. Applying CR drain and/or crew damage to systems/weapons/hullmods seems the most direct route, but I've as of yet gleaned no way to accomplish this without seriously brushing up on my Java.

Ah - well, you will need code to do that. ShipAPI has a setCurrentCR() method, that sort of thing.

Where can I find the Java code for marines commodity in the src of Starsector?

You mean the code that manages their XP etc, right? com.fs.starfarer.api.impl.PlayerFleetPersonnelTracker.

Could you please confirm API request thread asks? For example, I did ask for this back in November: https://fractalsoftworks.com/forum/index.php?topic=4900.msg345871#msg345871

The suggestion thread does feel neglected - we haven't heard you there since late November :(

Ah - I generally only look through that thread close to release time and pick what I can reasonably do, so it doesn't see much discussion overall. But whatever is there, I will definitely look through; it's always on my radar as a "thing to do at some point before a release"!

Thank you! Does it accept allow to just deselect whatever is selected (passing `null` I guess) just like `showCoreUITab(CoreUITabId.INTEL, null)` does?

It didn't, but, easy enough to do, so: did that!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lord Admiral Spire on June 21, 2022, 09:22:35 PM
A shame. My java's just not good enough to make new API hooks at present. Have to hold off until I know more.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on June 22, 2022, 07:15:54 AM
is there a way to get a fleet member object directly from a fleet member ID without searching through every location and fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 22, 2022, 08:32:04 AM
is there a way to get a fleet member object directly from a fleet member ID without searching through every location and fleet?

There isn't, and that might not necessarily do it - e.g. if it's a player ship, they might have put it in storage, or scuttled it.

You can take a look at com.fs.starfarer.api.impl.campaign.plog.SModRecord for a safe way (using WeakReference) to hang on to FleetMemberAPI references directly, that don't leak those fleet members if they go away.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on June 23, 2022, 09:18:20 AM
is there a way to get a fleet member object directly from a fleet member ID without searching through every location and fleet?

There isn't, and that might not necessarily do it - e.g. if it's a player ship, they might have put it in storage, or scuttled it.

You can take a look at com.fs.starfarer.api.impl.campaign.plog.SModRecord for a safe way (using WeakReference) to hang on to FleetMemberAPI references directly, that don't leak those fleet members if they go away.

will take a look there then. my current way retrieves market storages as well, but there are times where i need the fleet members and needing to iterate through everything doesn't seem like the best way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on June 23, 2022, 09:31:32 AM
Is there a line or code that makes a script wait for a certain amount of time(say 2 cycles) before firing? And if so what units does Starsector use to measure time and how much would it that be for 2 cycles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on June 23, 2022, 10:19:10 AM
Alex is it possible to make an AI Core admin that has permanent different than normal name, image and skills? One you can reassign around, that is. (ie: a player owned version of the tritach guy that has the SUSPECTED_AI tag.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 23, 2022, 10:47:53 AM
Is there a line or code that makes a script wait for a certain amount of time(say 2 cycles) before firing? And if so what units does Starsector use to measure time and how much would it that be for 2 cycles?

To do that, you would just track the amount of time elapsed in the script and then fire whatever code you need and after that happens, have the script's isDone() return true.

The advance(float amount) method gets the amount of seconds elapsed (so, typically, 1/60 or so); you can convert that to in-universe days by using Global.getSector().getClock().convertToDays() or something very similar.

Alex is it possible to make an AI Core admin that has permanent different than normal name, image and skills? One you can reassign around, that is. (ie: a player owned version of the tritach guy that has the SUSPECTED_AI tag.)

Hmm, probably? I think you'd want to start with a regular person and fake it up a bit. I'm not sure exactly how it would work out as far as "not counting against the number of admins" etc, though; that would need a bunch of digging around.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on June 23, 2022, 10:54:38 AM
I tried imitating the tritach guy code but when you assign the admin to a planet, you start to see duplicates.

If you have two of such admins, assigning them both to a planet, make one of them show "unassigned" on the menu, meanwhile on planet list they are assigned properly.

It seems the handling of admins that are AI is very, VERY hardcoded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on June 23, 2022, 08:56:48 PM
What is the best way to play a sound from a ship when a shipsystem is activated?

I tried inside of the BaseShipSystemScript class but can't seem to find the right hooks.

For example, I tried:

public float getInfoText(ShipSystemAPI system, ShipAPI ship)
{
   Global.getSoundPlayer().playSound("waaagh", 1f, .8f, ship.getLocation(), new Vector2f());
   return 0f;
}


I tried something that would use the shipapi, therefore I could use ship.location.     Had no success so far.    Is there a simpler command inside of the BaseShipSystemScript class?


Current shipsystem code with commented out part:
Spoiler

package data.shipsystems.scripts;


import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.Global;

//import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.impl.combat.BaseShipSystemScript;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;

import org.lwjgl.util.vector.Vector2f;

public class WaaaghStats extends BaseShipSystemScript {
   
   public static final float ROF_BONUS = 1f;
   public static final float FLUX_REDUCTION = 50f;
   
   /*
   public float getInfoText(ShipSystemAPI system, ShipAPI ship)
   {
      Global.getSoundPlayer().playSound("waaagh", 1f, .8f, ship.getLocation(), new Vector2f());
      return 0f;
   }
   */

   public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel)
   {
      if (state == ShipSystemStatsScript.State.OUT) {
         stats.getMaxSpeed().unmodify(id); // to slow down ship to its regular top speed while powering drive down
      } else {
         stats.getMaxSpeed().modifyFlat(id, 200f * effectLevel);
         stats.getAcceleration().modifyFlat(id, 200f * effectLevel);
         //stats.getAcceleration().modifyPercent(id, 200f * effectLevel);
      }
      
      
      float mult = 1f + ROF_BONUS * effectLevel;
      stats.getBallisticRoFMult().modifyMult(id, mult);
      stats.getBallisticWeaponFluxCostMod().modifyMult(id, 1f - (FLUX_REDUCTION * 0.01f));
      
   }   
   
   public void unapply(MutableShipStatsAPI stats, String id)
   {
      stats.getMaxSpeed().unmodify(id);
      stats.getMaxTurnRate().unmodify(id);
      stats.getTurnAcceleration().unmodify(id);
      stats.getAcceleration().unmodify(id);
      stats.getDeceleration().unmodify(id);
      
      stats.getBallisticRoFMult().unmodify(id);
      stats.getBallisticWeaponFluxCostMod().unmodify(id);

   }
   
   public StatusData getStatusData(int index, State state, float effectLevel) {
      
      float mult = 1f + ROF_BONUS * effectLevel;
      float bonusPercent = (int) ((mult - 1f) * 100f);
      if (index == 0)
      {
         return new StatusData("ballistic rate of fire +" + (int) bonusPercent + "%", false);
         //return new StatusData("increased engine power", false);
      }
      if (index == 1)
      {
         return new StatusData("ballistic flux use -" + (int) FLUX_REDUCTION + "%", false);
      }
      return null;
   }
}
[close]

Also, what is the correct way to return more then one StatusData at the same time?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2022, 09:46:33 AM
The easiest would be to specify it via
"useSound":"<whatever>",

In the .system file.

For status, you can check out AmmoFeedStats or anything else in vanilla that has multiple status items.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on June 24, 2022, 05:29:43 PM
*facepalm*  Missed the usesound line in the system file, that worked nicely, thanks!    ;D


All vanilla systems I checked only return a single status data item per index number.

How does one return 2 StatusData items for the same index number?


Example ammofeed:

if (index == 0) {
   return new StatusData("ballistic rate of fire +" + (int) bonusPercent + "%", false);
   }
   if (index == 1) {
   return new StatusData("ballistic flux use -" + (int) FLUX_REDUCTION + "%", false);
   }
   return null;
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 24, 2022, 08:05:33 PM
Why would you want to/how would that even work? I feel like there may be some misconception about what the index numbers do - they're just a means to enable the script to return a bunch of different statuses. (I don't remember why I did it this way instead of it just returning a List or some such.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on June 25, 2022, 09:18:04 AM
How I add an abandoned station with stuff in storage but that you must fight to get the stuff?

Also, I tried adding defenders to a planet ruins with setDefenderOverride and it works, but prints some "null" errors on the text, how I fix that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 25, 2022, 06:56:21 PM
Maybe get the actual null errors from starsector.log and work from there.

For defenders of an abandoned station, I'd probably do a custom path for the interaction dialog in rules.csv, started by a rule with an OpenInteractionDialog trigger that checks if the interaction is with the particular station we want. I think once a $defenderFleet is defined, you could use a SalvageDefenderInteraction call to set up the battle.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on June 26, 2022, 06:46:22 AM
Why would you want to/how would that even work? I feel like there may be some misconception about what the index numbers do - they're just a means to enable the script to return a bunch of different statuses. (I don't remember why I did it this way instead of it just returning a List or some such.)

I'm not so much worried about the index number, more interested if there is a way to return two StatusData items.


Basically I squished the ammofeed and burndrive together, because rushing in with guns blazing is lore correct for the faction I'm working on.   However, the mix of the two shipsystems led me to this in the StatusData  function:

Spoiler

public StatusData getStatusData(int index, State state, float effectLevel) {
      
      float mult = 1f + ROF_BONUS * effectLevel;
      float bonusPercent = (int) ((mult - 1f) * 100f);
      if (index == 0)
      {
         return new StatusData("ballistic rate of fire +" + (int) bonusPercent + "%", false);
         //return new StatusData("increased engine power", false);    <---- had to comment this out
      }
      if (index == 1)
      {
         return new StatusData("ballistic flux use -" + (int) FLUX_REDUCTION + "%", false);
      }
      return null;
   }


[close]

So doing two return commands at once is a no-no, but is there a way to combine the two statusdata commands into one return command?    No worries if this is a no-go.

Hope this makes things less muddy   :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 26, 2022, 06:59:05 AM
I'm not so much worried about the index number, more interested if there is a way to return two StatusData items.

Yes, add another index number.

Code: java

      if (index == 0)
      {
         return new StatusData("ballistic rate of fire +" + (int) bonusPercent + "%", false);
      }
      if (index == 1)
      {
         return new StatusData("ballistic flux use -" + (int) FLUX_REDUCTION + "%", false);
      }
      if (index == 2)
      {
         return new StatusData("increased engine power", false);
      }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on June 26, 2022, 10:55:46 PM
Does anyone know why these two don't seem to spawn in the allocated market's comms board?

Spoiler
        PersonAPI TTambassador = Global.getFactory().createPerson();
        TTambassador.setId("TTambassador");
        TTambassador.setGender(FullName.Gender.MALE);
        TTambassador.getName().setFirst("Tim");
        TTambassador.getName().setLast("test");
        TTambassador.setPostId("TTambassadorpost");
        TTambassador.setRankId("TTambassadorrank");
        TTambassador.setImportance(PersonImportance.HIGH);
        TTambassador.setVoice(Voices.OFFICIAL);
        TTambassador.addTag(Tags.CONTACT_UNDERWORLD);
        TTambassador.addTag(Tags.CONTACT_TRADE);
        ip.addPerson(TTambassador);

        PersonAPI PLambassador = Global.getFactory().createPerson();
        PLambassador.setId("PLambassador");
        PLambassador.setGender(FullName.Gender.MALE);
        PLambassador.getName().setFirst("Bill");
        PLambassador.getName().setLast("Silvergale");
        PLambassador.setPostId("PLambassadorpost");
        PLambassador.setRankId("PLambassadorrank");
        PLambassador.setImportance(PersonImportance.HIGH);
        PLambassador.setVoice(Voices.OFFICIAL);
        PLambassador.addTag(Tags.CONTACT_MILITARY);
        PLambassador.addTag(Tags.CONTACT_TRADE);
        ip.addPerson(PLambassador);

        MarketAPI market = Global.getSector().getEconomy().getMarket("ryzan_supercomplex");
        if (market != null && "sindrian_diktat".equals(market.getFactionId())) {
            market.getCommDirectory().addPerson(TTambassador, 1);
            market.addPerson(TTambassador);
            market.getCommDirectory().addPerson(PLambassador, 2);
            market.addPerson(PLambassador);
        }
[close]

I checked with other NPC code and there doesn't seem to be anything wrong so I have no idea what's up at this point.

Also for reference I don't believe it's the unique IDs that are causing it since I already defined them in the mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on June 27, 2022, 06:37:59 AM
I'm not so much worried about the index number, more interested if there is a way to return two StatusData items.

Yes, add another index number.

Code: java

      if (index == 0)
      {
         return new StatusData("ballistic rate of fire +" + (int) bonusPercent + "%", false);
      }
      if (index == 1)
      {
         return new StatusData("ballistic flux use -" + (int) FLUX_REDUCTION + "%", false);
      }
      if (index == 2)
      {
         return new StatusData("increased engine power", false);
      }


This worked splendidly.   Appreciate the solution!   
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 27, 2022, 09:38:30 AM
Does anyone know why these two don't seem to spawn in the allocated market's comms board?

Spoiler
        PersonAPI TTambassador = Global.getFactory().createPerson();
        TTambassador.setId("TTambassador");
        TTambassador.setGender(FullName.Gender.MALE);
        TTambassador.getName().setFirst("Tim");
        TTambassador.getName().setLast("test");
        TTambassador.setPostId("TTambassadorpost");
        TTambassador.setRankId("TTambassadorrank");
        TTambassador.setImportance(PersonImportance.HIGH);
        TTambassador.setVoice(Voices.OFFICIAL);
        TTambassador.addTag(Tags.CONTACT_UNDERWORLD);
        TTambassador.addTag(Tags.CONTACT_TRADE);
        ip.addPerson(TTambassador);

        PersonAPI PLambassador = Global.getFactory().createPerson();
        PLambassador.setId("PLambassador");
        PLambassador.setGender(FullName.Gender.MALE);
        PLambassador.getName().setFirst("Bill");
        PLambassador.getName().setLast("Silvergale");
        PLambassador.setPostId("PLambassadorpost");
        PLambassador.setRankId("PLambassadorrank");
        PLambassador.setImportance(PersonImportance.HIGH);
        PLambassador.setVoice(Voices.OFFICIAL);
        PLambassador.addTag(Tags.CONTACT_MILITARY);
        PLambassador.addTag(Tags.CONTACT_TRADE);
        ip.addPerson(PLambassador);

        MarketAPI market = Global.getSector().getEconomy().getMarket("ryzan_supercomplex");
        if (market != null && "sindrian_diktat".equals(market.getFactionId())) {
            market.getCommDirectory().addPerson(TTambassador, 1);
            market.addPerson(TTambassador);
            market.getCommDirectory().addPerson(PLambassador, 2);
            market.addPerson(PLambassador);
        }
[close]

I checked with other NPC code and there doesn't seem to be anything wrong so I have no idea what's up at this point.

Also for reference I don't believe it's the unique IDs that are causing it since I already defined them in the mod.

Hmm - possibly if the entry is hidden via CommDirectoryEntryAPI.setHidden(true)?

You might try running some code - after adding the entries - to list out the entries and confirm that the one you want is actually present, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on June 27, 2022, 08:17:17 PM
Do we have a way to italicize only part of a paragraph in a TextPanelAPI/TooltipMakerAPI/LabelAPI?

I found the ways to change text color within a para, and to italicize a whole para, but haven't managed to find a way for just a few words.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: esciron on June 28, 2022, 06:53:22 AM
Hi, I want to make a little personal mod. I have no Idea on what's the best way to do this (if there's a way) My goal is to make ships tougher/more durable and capital ships less relevant.

1- I want to add  additional armor, hull, ordinance points and reduce the speed of all ships (including  ships from mods), all of this fixed by a percentage of the ships values. The only way I can think of doing
this is by making a hullmod, but I don't know if there's a way to add that hullmod to every single ship that spawn in the game (including bounties etc).

2- Make capital ships way scarcer and make it so only one capital ship can be deployed at the same time in a battle (1 for each "team" involved) I really don't know how could I do this.

My modding skills are very limited i've only made a couple of hullmods and ships.
I would appreciate any help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on June 28, 2022, 10:49:59 AM
I have two questions:

1. How I make the name of a system be visible on the map, or not? (I want it  to start the game hidden, and later reveal it after a quest)
2. I saw lots of code floating around about how to delete hyper-nebula on top of your system, but what if I want to ADD hyper nebula on top of  system? (I want it to be actually hard to see)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 28, 2022, 03:18:04 PM
Do we have a way to italicize only part of a paragraph in a TextPanelAPI/TooltipMakerAPI/LabelAPI?

I found the ways to change text color within a para, and to italicize a whole para, but haven't managed to find a way for just a few words.

There's no way to do that, no. (Obivously technically doable! But enough of a pain that it's not something I'd want to get into barring a compelling need for it in vanilla.)


Hi, I want to make a little personal mod. I have no Idea on what's the best way to do this (if there's a way) My goal is to make ships tougher/more durable and capital ships less relevant.

1- I want to add  additional armor, hull, ordinance points and reduce the speed of all ships (including  ships from mods), all of this fixed by a percentage of the ships values. The only way I can think of doing
this is by making a hullmod, but I don't know if there's a way to add that hullmod to every single ship that spawn in the game (including bounties etc).

Hi! You might achieve this by creating a "hidden" hullmod and then adding it to all ShipHullSpecAPIs (Global.getSettings().getAllShipHullSpecs) in your ModPlugin.onApplicationLoad() method.

2- Make capital ships way scarcer and make it so only one capital ship can be deployed at the same time in a battle (1 for each "team" involved) I really don't know how could I do this.

Hmm, not sure how you'd do this - there's no code to limit deployment by ship type, just by deployment points.


1. How I make the name of a system be visible on the map, or not? (I want it  to start the game hidden, and later reveal it after a quest)

Offhand, I don't know; nothing comes to mind. Hiding star systems isn't really a thing in vanilla. The Lights Out mod does something along these lines, though, but it doesn't hide just the name; you might want to look at how it does things.

2. I saw lots of code floating around about how to delete hyper-nebula on top of your system, but what if I want to ADD hyper nebula on top of  system? (I want it to be actually hard to see)

Take a look at the NebulaEditor class - that, and where/how it's used, should hopefully point you in the right direction. IIRC tile values from 0 to 15 inclusive are the different tiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Brainwright on June 28, 2022, 08:59:09 PM
I'm using quite a lot of mods, and some of them have custom mods with special conditions as for what ship types and mods they can work with.

Thing is, they don't show up on the mod screen.  I can add them manually by modifying the campaign file, and they work fantastically.  Ships spawn with the mods, too.

I just can't add them from the refit screen because they don't show.  Is there some procedure I can use to make sure they show up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 28, 2022, 09:26:44 PM
You probably need to select their filter tag. Like LoA's hullmods will be under ARS or Reparations Society.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Brainwright on June 28, 2022, 09:30:23 PM
You probably need to select their filter tag. Like LoA's hullmods will be under ARS or Reparations Society.

Yep, that did it.  Just started mods a couple of months ago, never noticed that.  :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: esciron on June 29, 2022, 09:13:39 AM
Hi, I want to make a little personal mod. I have no Idea on what's the best way to do this (if there's a way) My goal is to make ships tougher/more durable and capital ships less relevant.

1- I want to add  additional armor, hull, ordinance points and reduce the speed of all ships (including  ships from mods), all of this fixed by a percentage of the ships values. The only way I can think of doing
this is by making a hullmod, but I don't know if there's a way to add that hullmod to every single ship that spawn in the game (including bounties etc).

Hi! You might achieve this by creating a "hidden" hullmod and then adding it to all ShipHullSpecAPIs (Global.getSettings().getAllShipHullSpecs) in your ModPlugin.onApplicationLoad() method.

2- Make capital ships way scarcer and make it so only one capital ship can be deployed at the same time in a battle (1 for each "team" involved) I really don't know how could I do this.

Hmm, not sure how you'd do this - there's no code to limit deployment by ship type, just by deployment points.

Thank you!
I was able to do the first point, hullmod for the armor and hull but I can't find a way to modify the ordnance points as the only related thing I can find it's in "MutableCharacterStatsAPI".

For the second point a good solution could be multiplying the capital ships deployment points so you wouldn't be able to deploy many capitals but i'm unable to find a way to do it, i've tried to do getSuppliesPerMonth() and getSuppliesToRecover() with a.modifyPercent() in the hullmod but it doesn't change the ships deployment points. Any ideas?

EDIT: I've found a way with getSuppliesToRecover and setSuppliesToRecover in the hullmod plugin (ShipHullSpecAPI). But now I need a way to limit this to capital ships only, is this possible?
EDIT 2: Finally figure it out, it was way simpler than what I was thinking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ez on June 29, 2022, 10:37:05 AM
Hi folks,

This Q is maybe too meta for this thread, so apologies. I made a small mod for myself that I'd like to share but not sure if I should post it in this area (Modding (https://fractalsoftworks.com/forum/index.php?board=3.0)) or if it needs to go in the top-level Mods (https://fractalsoftworks.com/forum/index.php?board=8.0) section? Side Q: I can't start a new thread in the Mods section, wondering how I'd go about posting there if that's where it should go. I noticed some mods in Modding get moved elsewhere, so figured it's worth asking before I do anything.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 29, 2022, 12:23:37 PM
Hi folks,

This Q is maybe too meta for this thread, so apologies. I made a small mod for myself that I'd like to share but not sure if I should post it in this area (Modding (https://fractalsoftworks.com/forum/index.php?board=3.0)) or if it needs to go in the top-level Mods (https://fractalsoftworks.com/forum/index.php?board=8.0) section? Side Q: I can't start a new thread in the Mods section, wondering how I'd go about posting there if that's where it should go. I noticed some mods in Modding get moved elsewhere, so figured it's worth asking before I do anything.

Thanks!

you need to make a thread in modding and ask a forum moderator to move it to mods
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 29, 2022, 02:55:50 PM
I was able to do the first point, hullmod for the armor and hull but I can't find a way to modify the ordnance points as the only related thing I can find it's in "MutableCharacterStatsAPI".

Hmm - the only way that comes to mind would be using hidden hullmods with a negative deployment point cost, but you'd need a bunch of them (for the different number of points you want to add) so it'd be pretty clumsy. Maybe there's a cleaner way, though; just not coming up with one right now.

For the second point a good solution could be multiplying the capital ships deployment points so you wouldn't be able to deploy many capitals but i'm unable to find a way to do it, i've tried to do getSuppliesPerMonth() and getSuppliesToRecover() with a.modifyPercent() in the hullmod but it doesn't change the ships deployment points. Any ideas?

EDIT: I've found a way with getSuppliesToRecover and setSuppliesToRecover in the hullmod plugin (ShipHullSpecAPI). But now I need a way to limit this to capital ships only, is this possible?
EDIT 2: Finally figure it out, it was way simpler than what I was thinking.

I think what you want is stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD)


you need to make a thread in modding and ask a forum moderator to move it to mods

Right! With the intermediate step of the mod getting some player use, a bit of feedback, etc, so that when/if it ends up in the Mods forum (and possibly in the mod list), it's a little more mature.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ez on June 30, 2022, 10:23:29 AM
Thanks guys  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on June 30, 2022, 11:02:18 PM
I created a custom star system, and added the hyperspace objects manually.

Now the star system name NEVER show on hyperspace, including you can't select it as gate destination when gate travelling.

How I fix that?

And no, the thing that lights out mod does is not what I want...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 03, 2022, 07:18:53 AM
A custom allied fleet is having the captain removed from its flagship when I join its battle.
Breakpointing FleetMemberAPI.setCaptain led me to FleetData.ensureHasFlagship in the obsf code.

Am I reading this method right, does the code here mean that a fleet must have its flagship be the first ship in the fleet, else that status is given to the said first ship?
It would be nice if it didn't do this if the fleet already has a valid flagship, or at least if it didn't kick off the old flagship's captain when revoking its flagship status. Or if FleetDataAPI.sort put the existing flagship at the front of the fleet to circumvent this issue.

(The fleet's flagship is a cruiser while there is also a capital in the fleet, which I don't want to be the flagship for reasons)

Can I force the flagship to be at the front of the fleet data somehow?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 03, 2022, 07:51:53 AM
A custom allied fleet is having the captain removed from its flagship when I join its battle.
Breakpointing FleetMemberAPI.setCaptain led me to FleetData.ensureHasFlagship in the obsf code.

Am I reading this method right, does the code here mean that a fleet must have its flagship be the first ship in the fleet, else that status is given to the said first ship?
It would be nice if it didn't do this if the fleet already has a valid flagship, or at least if it didn't kick off the old flagship's captain when revoking its flagship status. Or if FleetDataAPI.sort put the existing flagship at the front of the fleet to circumvent this issue.

(The fleet's flagship is a cruiser while there is also a capital in the fleet, which I don't want to be the flagship for reasons)

Can I force the flagship to be at the front of the fleet data somehow?

Hmm, that's odd - the first ship does not have to be the flagship, no. I think you can see plenty of fleets in vanilla where this isn't the case. The ensureHasFlagship() method should be a no-op if the fleet has exactly one flagship. Is this a manually created fleet? I suspect it may be an issue with the fleet having a commander set, and the commander being assigned to captain a ship, but there not being a fleet.getFleetData().setFlagship(member) call somewhere in there.

(I don't recall why there's a distinction between "flagship" and "fleet member with the fleet commander assigned as captain", but it exists. Possibly to do with some plans that never materialized?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 03, 2022, 10:02:30 AM
So far as I can tell, the flagship has been set correctly in fleet data; only one fleet member returns true for isFlagship(), and it is the same one as returned by fleet.getFlagship(). It's a manually created fleet, yeah.
I'll see later if I can generate a small sample fleet that repros the issue.

I created a custom star system, and added the hyperspace objects manually.

Now the star system name NEVER show on hyperspace, including you can't select it as gate destination when gate travelling.

How I fix that?

And no, the thing that lights out mod does is not what I want...
At a guess, the system needs to have its hyperspace anchor set to appear on the map (which would explain why Ziggurat blacksite doesn't have it).
The javadocs are contradictory and out of date, but: Try calling system.generateAnchorIfNeeded to make the system appear.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 03, 2022, 10:46:14 AM
Ahh, I think I see the issue - it happens when you actually get into the combat, not just when you join the battle in the campaign screen. Checking it out!

Edit: fixed this up! It would only affect allied fleets, and I *think* it would kick out the fleet commander regardless of what ship they were in, so, a pretty significant bug at that. Thank you for the report!

I don't *think* there's a particularly clean workaround, other than, say, undoing this in some combat plugin's init() method or something similar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on July 03, 2022, 05:13:08 PM
So far as I can tell, the flagship has been set correctly in fleet data; only one fleet member returns true for isFlagship(), and it is the same one as returned by fleet.getFlagship(). It's a manually created fleet, yeah.
I'll see later if I can generate a small sample fleet that repros the issue.

I created a custom star system, and added the hyperspace objects manually.

Now the star system name NEVER show on hyperspace, including you can't select it as gate destination when gate travelling.

How I fix that?

And no, the thing that lights out mod does is not what I want...
At a guess, the system needs to have its hyperspace anchor set to appear on the map (which would explain why Ziggurat blacksite doesn't have it).
The javadocs are contradictory and out of date, but: Try calling system.generateAnchorIfNeeded to make the system appear.

I had to go poke in the source to find it.

Basically the map shows as valid systems and gate destinations, only jump points (not gravity wells), and they must end on a star. (or nebula, I assume).

A system anchor is NOT enough. A gravity well is NOT enough either, it must be a jump point, and its target must be a star, not another jump point, not a planet, etc... must be specifically, a star.

What the code does when rendering  the map is is call a function on the jump point itself (thus gravity wells don't have it), and the jump point function grabs its destination, then calls "isStar()".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 03, 2022, 08:24:16 PM
There doesn't have to be a star jump point. See: nebula centers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on July 04, 2022, 06:02:46 AM
I think nebula centers count as star.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 04, 2022, 07:37:27 AM
Yes, but there is no jump point for it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 04, 2022, 09:51:24 AM
I want to programmatically hide the friendly info boxes during combat because they overlap and clutter the battlefield under the extreme zoom-out my mod involves, and I want to replace them with flux and hull diamonds, for which I already have working code, but cannot find an API call to hide the info boxes. I found a hack by simulating an F11 keypress via Robot, to which the OS responds by asking if Starsector should be allowed to control the computer, but I don't want to make users think that my mod hijacks their machine.  Does or will any workaround exist?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: intrinsic_parity on July 04, 2022, 04:38:07 PM
Is anyone aware of a mod that disables the ability to create stable points using an alpha core + story point at a star, or any reason why it wouldn't be possible? I don't seem to be able to do that in my current campaign.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on July 04, 2022, 04:56:02 PM
Is it possible to create recoiling barrels on a weapon that overlap?     Example:  3 spaced barrels on "bottom" row, two slightly shorter spaced barrels on the "top" row.   They all recoil.     

Is there a limit to the amount of barrels for a weapon?

What is the mutable stat used for the upcoming ablative armor hullmod?   I'd like to make something similar on a smaller scale.   Haven't spotted it yet.  Perhaps a usage of getArmorBonus or getArmorDamageTakenMult?

This is assuming there isn't some other function used in a future update.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on July 04, 2022, 06:34:33 PM
Is it possible to create recoiling barrels on a weapon that overlap?     Example:  3 spaced barrels on "bottom" row, two slightly shorter spaced barrels on the "top" row.   They all recoil.
Don't believe so, but I think it's a good idea; being able to spec a "turretGunSprite2" and "hardpointGunSprite2" would be cool for making, say, quad cannons. It does run into the problem of adjudicating which sprite should recoil based on which offsets; unfortunately only our gracious host can really answer the question of whether this is worth his time to consider.

Is there a limit to the amount of barrels for a weapon?
I've made (test) weapons with as many as forty barrel offsets (note, this is a major pain to keep track of and I don't recommend it), but as far as I know there's no set limit.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SpaceDrake on July 04, 2022, 10:07:57 PM
Is anyone aware of a mod that disables the ability to create stable points using an alpha core + story point at a star, or any reason why it wouldn't be possible? I don't seem to be able to do that in my current campaign.

Are you certain you don't already have two occupied points in the system in question?

Somewhat counter-intuitively, gates take up what would be a point slot, IIRC.

I've made (test) weapons with as many as forty barrel offsets (note, this is a major pain to keep track of and I don't recommend it), but as far as I know there's no set limit.

... I'm a little terrified to ask how big that turret was, and I'm someone who's a fan of the Infernus's mega-turret.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 05, 2022, 02:00:48 PM
I want to programmatically hide the friendly info boxes during combat because they overlap and clutter the battlefield under the extreme zoom-out my mod involves, and I want to replace them with flux and hull diamonds, for which I already have working code, but cannot find an API call to hide the info boxes. I found a hack by simulating an F11 keypress via Robot, to which the OS responds by asking if Starsector should be allowed to control the computer, but I don't want to make users think that my mod hijacks their machine.  Does or will any workaround exist?

Hmm, I don't believe so, no - and F11 hides all of the UI, not just the friendly ship overlays, so that doesn't seem ideal either. Let me make a note to take a look at adding this at some point!

What is the mutable stat used for the upcoming ablative armor hullmod?   I'd like to make something similar on a smaller scale.   Haven't spotted it yet.  Perhaps a usage of getArmorBonus or getArmorDamageTakenMult?

This is assuming there isn't some other function used in a future update.

It's just:
stats.getEffectiveArmorBonus().modifyMult(id, 0.1f);

And then having a ton of base armor on the ship.

Is anyone aware of a mod that disables the ability to create stable points using an alpha core + story point at a star, or any reason why it wouldn't be possible? I don't seem to be able to do that in my current campaign.

Are you certain you don't already have two occupied points in the system in question?

Somewhat counter-intuitively, gates take up what would be a point slot, IIRC.

Fairly sure that the bit about the gates is not right, unless there's some kind of bug!

And, no, not aware of any such mod myself. But if a mod overrode the default star interaction, that could very well happen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Princess_of_Evil on July 06, 2022, 03:28:46 AM
How difficult would it be to entirely remove a modded weapon from a save? I accidentally ran my main save with a debug mod and now i have a blueprint and an item of a test gun on it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on July 06, 2022, 05:43:02 AM
Does anyone know how to code a faction's hull(or in this case) fighter doctrine to run different fighter IDs based on the mods being enabled?

For example: mod A adds fighters 1 and 2. If mod A is running the Sindrian Diktat(for example) would be running fighter 1. But if mod B is enabled alongside mod A the Sindrian Diktat would be running exclusively fighter 2 instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 06, 2022, 03:19:15 PM
How difficult would it be to entirely remove a modded weapon from a save? I accidentally ran my main save with a debug mod and now i have a blueprint and an item of a test gun on it.

If it's not used by anything, then you might be able to just edit it out of the savefile. Or drop it off in some cargo pods and let them be lost forever - after the pods with the item despawn, unless you've learned the blueprint, I believe the save should load without that test mod enabled.

Does anyone know how to code a faction's hull(or in this case) fighter doctrine to run different fighter IDs based on the mods being enabled?

For example: mod A adds fighters 1 and 2. If mod A is running the Sindrian Diktat(for example) would be running fighter 1. But if mod B is enabled alongside mod A the Sindrian Diktat would be running exclusively fighter 2 instead.

You'd probably need to detect this in ModPlugin.onNewGame() and then modify the faction's known fighters there.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on July 06, 2022, 07:42:17 PM
How difficult would it be to entirely remove a modded weapon from a save? I accidentally ran my main save with a debug mod and now i have a blueprint and an item of a test gun on it.

If it's not used by anything, then you might be able to just edit it out of the savefile. Or drop it off in some cargo pods and let them be lost forever - after the pods with the item despawn, unless you've learned the blueprint, I believe the save should load without that test mod enabled.

Does anyone know how to code a faction's hull(or in this case) fighter doctrine to run different fighter IDs based on the mods being enabled?

For example: mod A adds fighters 1 and 2. If mod A is running the Sindrian Diktat(for example) would be running fighter 1. But if mod B is enabled alongside mod A the Sindrian Diktat would be running exclusively fighter 2 instead.

You'd probably need to detect this in ModPlugin.onNewGame() and then modify the faction's known fighters there.

I believe that should work, thanks!

Though, I have another question; how do you make a planetary condition that appears on a specific planet after it's been decivilized and changes if it is recolonized? I understand that there is Decivilized/Deciv Subpop and a ColonyDecivListener but checking the Deciv/Deciv Subpop java files doesn't seem to yield anything special and I don't really know how to use the listener.

And a little bonus to the above: How do you make it not spawn if the colony is colonized by a specific faction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 07, 2022, 03:33:21 AM
Is there a "proper" way to get a system to render a glow (specifically, like a phase coil / weapon glow)?

As far as I can tell my best option is to use magiclib's singleframe render function and basically do it myself, but that seems like an unwieldy solution- has anyone come up with a better one?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 07, 2022, 08:55:59 AM
Hmm, I wonder if you could control a deco weapon's jitter glow? That would help with some of my ship systems, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 07, 2022, 12:02:08 PM
I was thinking of doing that first (and swore that there was a setGlowLevel() method in weaponAPI), but as far as I can tell there's no way to interact with anything that determines a weapon's glow level.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 07, 2022, 03:25:28 PM
All I see is setRemainingCooldownTo() and getGlowSpriteAPI(). I don't know if fiddling with cooldown changes a weapon's glow. The latter sounds promising, but I am not sure how much you can actually do with it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 07, 2022, 04:28:21 PM
Though, I have another question; how do you make a planetary condition that appears on a specific planet after it's been decivilized and changes if it is recolonized? I understand that there is Decivilized/Deciv Subpop and a ColonyDecivListener but checking the Deciv/Deciv Subpop java files doesn't seem to yield anything special and I don't really know how to use the listener.

Hmm - for how listeners work, you generally want to do something like:
Global.getSector().getListenerManager().addListener()

And then your object will get the listener interface methods called when appropriate. You also want to .removeListener() when your object no longer needs to exist; having listeners stick around if they're not removed can be an easy way to have a memory leak.

And a little bonus to the above: How do you make it not spawn if the colony is colonized by a specific faction?

That'd just be up to whatever code you write to have that logic in it!


Is there a "proper" way to get a system to render a glow (specifically, like a phase coil / weapon glow)?

As far as I can tell my best option is to use magiclib's singleframe render function and basically do it myself, but that seems like an unwieldy solution- has anyone come up with a better one?

Phase coils are iirc hardcoded to only work with phase-cloak type ship systems?

For weapon glows, though, there's:
ShipAPI.setWeaponGlow()
WeaponAPI.setGlowAmount() (not 100% sure this one is in the release, but the other one is.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Princess_of_Evil on July 07, 2022, 10:54:51 PM
Is it possible to add something to already existing UIs?
Specifically, i wanted to add some info to the ship's infobox without just adding more to the description.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on July 08, 2022, 06:36:21 AM
Is there a way to control the application of economy.json contents with a settings.json defined Boolean?

For example Boolean “DENotSpawnNonDiktatStuff” defined in settings.json, is it possible to use this Boolean to make it so economy.json stuff doesn’t apply when it is true for example?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 08, 2022, 08:40:11 AM
Is it possible to add something to already existing UIs?
Specifically, i wanted to add some info to the ship's infobox without just adding more to the description.

Not to that one, no - at least not easily. I know some people have made UI additions by basically rendering custom overlays, but that's more complicated and situational.


Is there a way to control the application of economy.json contents with a settings.json defined Boolean?

For example Boolean “DENotSpawnNonDiktatStuff” defined in settings.json, is it possible to use this Boolean to make it so economy.json stuff doesn’t apply when it is true for example?

Hmm, possibly? You'd have to basically apply it yourself, though, based on whatever config you want to do; it'd be a bunch of code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Princess_of_Evil on July 08, 2022, 08:48:54 AM
Not to that one, no - at least not easily. I know some people have made UI additions by basically rendering custom overlays, but that's more complicated and situational.
Is there anything i could read about it? I'm not afraid of doing code, there just literally isn't anything i've seen that's similar.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 08, 2022, 08:50:46 AM
I want to say one of Sundog's mods does this for the fleet deployment dialog? Not 100% sure.

Thinking about it some more, though, I don't think this would be a workable approach for ship tooltips because they can show up in such a variety of UI screens and in different locations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: speeder on July 08, 2022, 04:17:03 PM
How I change a faction color programatically? Specially the player, so a menu can be made for those that prefer it orange or something instead of blue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 08, 2022, 06:27:52 PM
Hey Alex, I've noticed the ShipHullSpecAPI lacks a method to tell you if a ship is a station, module, or ship.  I've had to create janky workarounds like seeking ShipTypeHints.STATION, looking at the top speed, acceleration, and deceleration, and checking for a module anchor.  There's gotta be a better way, right?

Code
    private static boolean isModule(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getModuleAnchor() != null
                      || (shipHullSpec.getEngineSpec().getMaxSpeed() == 0
                          && shipHullSpec.getEngineSpec().getAcceleration() == 0
                          && shipHullSpec.getEngineSpec().getDeceleration() == 0);
        } catch (Throwable t) { return false; }
    }

    private static boolean isStation(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getHints().contains(ShipHullSpecAPI.ShipTypeHints.STATION); }
        catch (Throwable t) { return false; }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 09, 2022, 06:14:36 AM
I've got 2 questions about bad ideas modular frigates -

1 - is there a way to make a module completely untargetable in battle? for now I'm using the "module_hull_bar_only" tag, but that still looks iffy when the player zooms in / gets their mouse too close to the ship.

2 - is there a good, consistent way to prevent explosions from missiles / projectiles "leaking" past a module's shields & hitting the main hull?
I've got a frigate with a secondary shield as a system, and if a missile w/ a big enough explosion (it's pretty close to the main hull so an atropos can do it in my case) hits the outer shield, it'll deal damage to both the outer shield & main ship in 2 separate instances (one for the missile on the module, one for the explosion on the main ship) with nothing really connecting the two for me to throw into a damageTakenModifier listener.
I could store a buncha data about each instance and compare that to check if it's close enough, but that feels like jankery of the highest order & i'd like to avoid it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 09, 2022, 10:17:29 AM
How I change a faction color programatically? Specially the player, so a menu can be made for those that prefer it orange or something instead of blue.

I don't think you can; it's not set up to keep that data in a campaign-instance-specific copy of the faction data.

Hey Alex, I've noticed the ShipHullSpecAPI lacks a method to tell you if a ship is a station, module, or ship.  I've had to create janky workarounds like seeking ShipTypeHints.STATION, looking at the top speed, acceleration, and deceleration, and checking for a module anchor.  There's gotta be a better way, right?

Code
    private static boolean isModule(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getModuleAnchor() != null
                      || (shipHullSpec.getEngineSpec().getMaxSpeed() == 0
                          && shipHullSpec.getEngineSpec().getAcceleration() == 0
                          && shipHullSpec.getEngineSpec().getDeceleration() == 0);
        } catch (Throwable t) { return false; }
    }

    private static boolean isStation(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getHints().contains(ShipHullSpecAPI.ShipTypeHints.STATION); }
        catch (Throwable t) { return false; }
    }

That's quite literally what ShipTypeHints.STATION is for! Not sure why you have it in a try/catch, though, that should not be necessary.



I've got 2 questions about bad ideas modular frigates -

1 - is there a way to make a module completely untargetable in battle? for now I'm using the "module_hull_bar_only" tag, but that still looks iffy when the player zooms in / gets their mouse too close to the ship.

You could make it take no hull damage (by setting the hull damage taken multiplier to 0) but I don't think that's what you want. Aside from that, no - if something can get damaged, it can have a hull bar and can be targeted; that seems fairly fundamental.

2 - is there a good, consistent way to prevent explosions from missiles / projectiles "leaking" past a module's shields & hitting the main hull?
I've got a frigate with a secondary shield as a system, and if a missile w/ a big enough explosion (it's pretty close to the main hull so an atropos can do it in my case) hits the outer shield, it'll deal damage to both the outer shield & main ship in 2 separate instances (one for the missile on the module, one for the explosion on the main ship) with nothing really connecting the two for me to throw into a damageTakenModifier listener.

Hmm - that sounds like a bug. Are you positive this is what's happening? Looking at the code, it seems like when a missile hits something and explodes, the explosion treats... ahh, crap, I see. What it was doing is making sure the explosion could not hit 1) any of the target's child modules, and 2) any of its parents' child modules. But it was not including the parent - which, in vanilla, didn't matter because the parent hull is always undamageable so it never came up. Fixed!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 09, 2022, 02:22:14 PM
Hmm - that sounds like a bug. Are you positive this is what's happening? Looking at the code, it seems like when a missile hits something and explodes, the explosion treats... ahh, crap, I see. What it was doing is making sure the explosion could not hit 1) any of the target's child modules, and 2) any of its parents' child modules. But it was not including the parent - which, in vanilla, didn't matter because the parent hull is always undamageable so it never came up. Fixed!

Glad to see that fixed. I had noticed it still happening with Roider armor but never got around to proving and reporting it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inhilicon on July 09, 2022, 06:23:10 PM
Hi! I was wondering if making a weapon that spits out a lot of projectiles causes some form of strain for modern computers. I would think no, but I was thinking that if I have three of this same weapon I'm making, would it cause problems when there are multiple users of such a weapon? This is a three to five-barreled weapon that fires 10 or 6 times in a quick barrage.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 09, 2022, 06:27:13 PM
Hi! I was wondering if making a weapon that spits out a lot of projectiles causes some form of strain for modern computers. I would think no, but I was thinking that if I have three of this same weapon I'm making, would it cause problems when there are multiple users of such a weapon? This is a three to five-barreled weapon that fires 10 or 6 times in a quick barrage.
consider 4-5 wings of piranha releasing their load

that is similar to what you're describing. If you think that doesn't strain a modern computer, you're fine.

It's not like the projectiles are scripted to do something else right? haha...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inhilicon on July 09, 2022, 06:39:15 PM
Hi! I was wondering if making a weapon that spits out a lot of projectiles causes some form of strain for modern computers. I would think no, but I was thinking that if I have three of this same weapon I'm making, would it cause problems when there are multiple users of such a weapon? This is a three to five-barreled weapon that fires 10 or 6 times in a quick barrage.
consider 4-5 wings of piranha releasing their load

that is similar to what you're describing. If you think that doesn't strain a modern computer, you're fine.

It's not like the projectiles are scripted to do something else right? haha...

That's right! They are just standard hurty projectiles with nothing else to them. Thanks for the lightning fast reply, friend.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 09, 2022, 08:11:00 PM
That's quite literally what ShipTypeHints.STATION is for! Not sure why you have it in a try/catch, though, that should not be necessary.

Does that go for modded stations, too, and how about telling if it's a module?  Regardless, I'm relieved to know I might not need that try/catch block.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on July 10, 2022, 08:04:16 AM
Is there a way to change the text/descriptor of a mission based on a mod being enabled?

Example: Mission has text A and ships B by default, but have text C and ships D when mod 1 is enabled.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 10, 2022, 09:06:36 AM
Also, I've noticed a duplication in the API: FighterWingSpec and FighterWingSpecAPI.  Will either of these be deprecated?  I want to use the former in my mod because it has the setRange(float range) method.

Edit: I think FighterWingSpec might be obfuscated.

Edit 2: Yes, it is obfuscated.  May I proxy this method?

Edit 3: And the getRange() method?

Edit 4: Proxy ready!  Awaiting permission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 10, 2022, 09:32:56 AM
you could make it take no hull damage (by setting the hull damage taken multiplier to 0) but I don't think that's what you want. Aside from that, no - if something can get damaged, it can have a hull bar and can be targeted; that seems fairly fundamental.

yeah, that's fair- I was gonna use or well, try to opengl to put a second health bar in a "proper" place, but instead i'll just make it invincible & have it kill itself when the main ship dies (it's not really meant to die before the main ship anyway)

and thanks for fixing up that bug! honestly, I'm surprised it's not come up / been fixed earlier, people on discord were pretty happy to see it fixed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 10, 2022, 12:05:54 PM
Does that go for modded stations, too, and how about telling if it's a module?  Regardless, I'm relieved to know I might not need that try/catch block.

It should go for modded stations too, yeah - if a station doesn't have that hint, that's a bug.

For telling it's a module, you're right, there isn't anything specific, but the way you're checking for it looks good to me.

Is there a way to change the text/descriptor of a mission based on a mod being enabled?

Example: Mission has text A and ships B by default, but have text C and ships D when mod 1 is enabled.

I don't think so, sorry!

Also, I've noticed a duplication in the API: FighterWingSpec and FighterWingSpecAPI.  Will either of these be deprecated?  I want to use the former in my mod because it has the setRange(float range) method.

Edit: I think FighterWingSpec might be obfuscated.

Edit 2: Yes, it is obfuscated.  May I proxy this method?

Edit 3: And the getRange() method?

Edit 4: Proxy ready!  Awaiting permission.

Yeah, go for it! And, thank you for letting me know; added get/setRange() to FighterWingSpecAPI.

and thanks for fixing up that bug! honestly, I'm surprised it's not come up / been fixed earlier, people on discord were pretty happy to see it fixed.

*thumbs up* Yeah, a bit surprised myself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 10, 2022, 01:18:21 PM
It should go for modded stations too, yeah - if a station doesn't have that hint, that's a bug.

Woo, thanks!

Quote
For telling it's a module, you're right, there isn't anything specific, but the way you're checking for it looks good to me.

Thank you again!

Quote
Yeah, go for it! And, thank you for letting me know; added get/setRange() to FighterWingSpecAPI.

Yaaaaay!  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 10, 2022, 02:06:09 PM
Is there a way to change the text/descriptor of a mission based on a mod being enabled?

Example: Mission has text A and ships B by default, but have text C and ships D when mod 1 is enabled.

You can switch which ships are added in the mission's script and I think the second mod could replace the mission's description file. That would only work for 1 submod, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 13, 2022, 09:20:44 AM
Hey Alex,

I have a problem with lead.  The lead calculation of the vanilla autofire AI uses the projectile speeds from weapon_data.csv rather than those of the relevant ProjectileSpecAPIs.  I know that the AI is using the .csv values because both the vanilla AutofireAIPlugin and Leading Pip (https://fractalsoftworks.com/forum/index.php?topic=7921.0) by DarkRevenant estimate the same excessive lead at the thousands of SU of range and projectile speed and hundreds of SU per second of ship speed in Realistic Combat: debugging DarkRevenant's code, I found that it uses the method WeaponAPI.getProjectileSpeed(), which returns the value from weapon_data.csv although Realistic Combat has modified the projectile speed ProjectileSpecAPI of the WeaponSpecAPI of the relevant WeaponAPI.  Replacing that method call with with the following statement corrected the lead:

Code
((ProjectileSpecAPI) weapon.getSpec().getProjectileSpec()).getMoveSpeed(weapon.getShip().getMutableStats(), weapon)

I need the AI to use the value that this statement returns.  I suspect I would have to inject some AutofireAIPlugin, but then I would be at best duplicating your years of effort to write a good one.

If you want to see more code, here it is:

Deriving the relevant stats of the WeaponGroupAPI for which lead is to be calculated
Spoiler
Code
    private static class WeaponGroupDerivedStats {

        private final float averageWeaponSpeed;
        private final Vector2f center;

        private static boolean isActiveNonBeamWeapon(WeaponAPI weapon) {
            return (!weapon.isDisabled()
                    && !weapon.isBeam()
                    && !weapon.isBurstBeam()
                    && weapon.getProjectileSpeed() >= 50f);
        }

        private static boolean firesMissiles(WeaponAPI weapon) {
            return weapon.getSpec().getProjectileSpec() instanceof MissileSpecAPI;
        }

        private static float getMissileSpeed(WeaponAPI weapon) {
            return ((MissileSpecAPI) weapon.getSpec().getProjectileSpec()
            ).getHullSpec().getEngineSpec().getMaxSpeed();
        }

        /**
         * {@code WeaponAPI.getProjectileSpeed()} returns the speed
         * in weapon_data.csv rather than after RealisticCombat has
         * modified the weapon and projectile specs.
         *
         * @param weapon {@link WeaponAPI}
         *
         * @return {@code float} true speed of the projectile of
         *         a {@link WeaponAPI}
         */
        private static float getProjectileSpeed(WeaponAPI weapon) {
            return ((ProjectileSpecAPI) weapon.getSpec().getProjectileSpec()).getMoveSpeed(
                    weapon.getShip().getMutableStats(), weapon);
        }

        private static float getWeaponSpeed(WeaponAPI weapon) {
            return firesMissiles(weapon) ? getMissileSpeed(weapon) : getProjectileSpeed(weapon);
        }

        private WeaponGroupDerivedStats(WeaponGroupAPI weaponGroup) {
            float totalWeaponSpeed = 0.01f, activeNonBeamWeapons = 0;
            Vector2f center = new Vector2f(0, 0);
            for (WeaponAPI weapon : weaponGroup.getWeaponsCopy())
                if (isActiveNonBeamWeapon(weapon)) {
                    totalWeaponSpeed += getWeaponSpeed(weapon);
                    Vector2f.add(center, weapon.getLocation(), center);
                    activeNonBeamWeapons += 1f;
                }
            averageWeaponSpeed = totalWeaponSpeed / activeNonBeamWeapons;
            center.x /= activeNonBeamWeapons; center.y /= activeNonBeamWeapons;
            this.center = center;
        }

        private float getAverageWeaponSpeed() { return averageWeaponSpeed; }

        private Vector2f getWeaponsCenter() { return center; }
    }
[close]

Math and driver code that update the center of the leading indicator.  Note that intercept may return null to indicate that no lead is available.
Spoiler
Code
    /**
     * @param a {@code float} coefficient of x^2
     * @param b {@code float} coefficient of x
     * @param c {@code float} constant
     *
     * @return {@link Vector2f} solutions of a quadratic equation
     *          ax^2 + bx + c = 0
     */
    private static float[] quad(float a, float b, float c) {
        if (Float.compare(Math.abs(a), 0) == 0) {
            if (Float.compare(Math.abs(b), 0) == 0)
                return (Float.compare(Math.abs(c), 0) == 0) ? new float[] {0, 0} : null;
            return new float[] {-c / b, -c / b};
        } else {
            float d = b * b - 4 * a * c;
            if (d >= 0) {
                d = (float) Math.sqrt(d);
                float e = 2 * a;
                return new float[]{(-b - d) / e, (-b + d) / e};
            }
        } return null;
    }

    /**
     * @param point {@link Vector2f} average {@link WeaponAPI} location of a
     *                               {@link WeaponGroupAPI}
     * @param speed {@code float} average {@link DamagingProjectileAPI} speed
     *                            of the {@link WeaponAPI}s of a
     *                            {@link WeaponGroupAPI}
     * @param targetLoc {@link Vector2f} target location
     * @param targetVel {@link Vector2f} target velocity
     *
     * @return {@link Vector2f} at which a {@link DamagingProjectileAPI}
     *         fired from the average {@link Vector2f} location of the
     *         {@link WeaponAPI}s of the selected {@link WeaponGroupAPI} with
     *         the {@code float} average {@link DamagingProjectileAPI} speed of
     *         the same would intercept a target of known {@link Vector2f}
     *         location and anticipated constant {@link Vector2f} velocity
     */
    private static Vector2f intercept(Vector2f point,
                                      float speed,
                                      Vector2f targetLoc,
                                      Vector2f targetVel)
    {
        Vector2f difference = new Vector2f(targetLoc.x - point.x, targetLoc.y - point.y);
        float a = targetVel.x * targetVel.x + targetVel.y * targetVel.y - speed * speed;
        float b = 2 * (targetVel.x * difference.x + targetVel.y * difference.y);
        float c = difference.x * difference.x + difference.y * difference.y;
        float[] solutions = quad(a, b, c);

        if (solutions == null) return null;
        float bestFit = Math.min(solutions[0], solutions[1]);
        if (bestFit < 0) bestFit = Math.max(solutions[0], solutions[1]);
        if (bestFit > 0) return new Vector2f(targetLoc.x + targetVel.x * bestFit,
                                             targetLoc.y + targetVel.y * bestFit);
        return null;
    }

    /**
     * Set the {@link Vector2f} center of the indicator for its targeted
     * {@link ShipAPI}.
     */
    private void updateCenter() {
        ShipAPI playerShip = Global.getCombatEngine().getPlayerShip();
        WeaponGroupAPI weaponGroup = playerShip.getSelectedGroupAPI();
        WeaponGroupDerivedStats stats = new WeaponGroupDerivedStats(weaponGroup);
        Vector2f relativeVelocity = Vector2f.sub(target.getVelocity(), playerShip.getVelocity(),
                null);
        center = intercept(stats.getWeaponsCenter(), stats.getAverageWeaponSpeed(),
                target.getLocation(), relativeVelocity);
    }
Spoiler
[close]
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 13, 2022, 11:05:56 AM
Let me add setProjectileSpeed() to WeaponSpecAPI.

I don't remember why the speed is kept in two places - it probably should not be - but there are many places in the game that assume the two values will always be the same; just changing that AI calculation wouldn't be the half of it. I'd suggest making sure to change both - is there a reason this isn't a good solution for you?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 13, 2022, 11:27:43 AM
Let me add setProjectileSpeed() to WeaponSpecAPI.

Oh, thanks!  I wasn't even expecting you to.  :)  So, would WeaponSpecAPI.setProjectileSpeed(float projectileSpeed) be syntactic sugar WeaponSpecAPI.getProjectileSpec().setMoveSpeed(float moveSpeed)?

Quote
I don't remember why the speed is kept in two places - it probably should not be - but there are many places in the game that assume the two values will always be the same; just changing that AI calculation wouldn't be the half of it.

Oh my.

Quote
I'd suggest making sure to change both - is there a reason this isn't a good solution for you?

Changing weapon_data.csv was my original plan but entailed creating and maintaining a compatibility pack for any mod with which mine were to run, so I added code automatically rescaling all WeaponSpecAPIs.  Could I work further upstream to change what the game thinks is weapon_data.csv and then let it build the specs from these modified values?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 13, 2022, 11:51:09 AM
So, would WeaponSpecAPI.setProjectileSpeed(float projectileSpeed) be syntactic sugar WeaponSpecAPI.getProjectileSpec().setMoveSpeed(float moveSpeed)?

It's absolutely not! WeaponSpecAPI is what initially gets the data from weapon_data.csv (which is only read by the game once, barring devMode F8 (iirc) reload shenanigans). And ProjectileSpecAPI gets a copy of that value at some point - might even be at the same time as the data is being initially loaded. So what's happening is you're probably modifying ProjectileSpecAPI only, but not WeaponSpecAPI, so the values are out of sync.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 13, 2022, 12:45:35 PM
It's absolutely not! WeaponSpecAPI is what initially gets the data from weapon_data.csv (which is only read by the game once, barring devMode F8 (iirc) reload shenanigans). And ProjectileSpecAPI gets a copy of that value at some point - might even be at the same time as the data is being initially loaded. So what's happening is you're probably modifying ProjectileSpecAPI only, but not WeaponSpecAPI, so the values are out of sync.

You're right!  I did modify ProjectileSpecAPI without modifying ProjectileWeaponSpecProxy.  If I modify the former, then the projectile flies as fast as I intend, but the autofire is off; the latter, the autofire is where I would like if the projectile flew so fast, but it does not; both, the projectile flies fast and autofire is perfect.  Thank you, Alex!

Here's what I'm doing now, thanks to your advice: it's duplicative but necessary.  Note the last four lines.  :)

Code
    private static void modifyBallisticAutocannonSpec(WeaponSpecAPI weaponSpec) {
        WeaponCategory category = BALLISTIC_AUTOCANNON;
        float maxRange = getMaxRange(category, weaponSpec);
        WeaponAPI.WeaponSize weaponSize = weaponSpec.getSize();
        weaponSpec.setMaxRange(maxRange);
        weaponSpec.setMinSpread(getMinimumSpread());
        weaponSpec.setMaxSpread(getMaximumSpread());
        projectileWeaponSpecProxy.setWeaponSpec(weaponSpec);
        projectileWeaponSpecProxy.setRefireDelay(getRefireDelay(category, weaponSize)
                                                  / weaponSpec.getHardpointFireOffsets().size());
        projectileWeaponSpecProxy.setBurstDelay(0f);
        projectileWeaponSpecProxy.setBurstSize(1);
        projectileWeaponSpecProxy.setEnergyPerShot(0f);
        projectileWeaponSpecProxy.setMaxAmmo(getMaxAmmo(category, weaponSpec));
        projectileWeaponSpecProxy.setAmmoPerSecond(getAmmoPerSecond(category,
                weaponSize));
        projectileWeaponSpecProxy.setReloadSize(getReloadSize(category, weaponSize));
        projectileWeaponSpecProxy.setProjectileSpeed(maxRange);
        ProjectileSpecAPI projectileSpecAPI = (ProjectileSpecAPI) weaponSpec.getProjectileSpec();
        projectileSpecAPI.setMaxRange(maxRange);
        projectileSpecAPI.setMoveSpeed(maxRange);
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 13, 2022, 12:46:42 PM
That makes sense, yeah - glad you got it sorted out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 13, 2022, 12:59:25 PM
That makes sense, yeah - glad you got it sorted out!

One other question: is there anything that responds to each tick of a BeamAPI hitting something?  My code applies it but only to the first one, causing big damage up front but little to no damage thereafter.  I can think of potential solutions (make all beams one-frame pulse beams, message passing, track all beams, add beam-specific listeners everywhere, etc.) but they all seem janky at best.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 13, 2022, 01:01:41 PM
Hmm, it seems like DamageListener should get called for every beam tick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 13, 2022, 01:02:30 PM
Hmm, it seems like DamageListener should get called for every beam tick.

Ahhhh, there it is!  Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 14, 2022, 01:50:20 AM
is it still impossible to have a non-circular(oval) orbit for planets? and a non-circular ringBand?
i mean, ringBand can be spiral...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 14, 2022, 07:34:59 AM
You could do it - either by providing a custom implementation of OrbitAPI (which *might* run into some problems, potentially, if some vanilla code makes some assumptions that are broken by this) or by just having a script move the entity around however you choose. You could even have a rectangular orbit if you like :)

Whether that works well will depend on the specifics of your use case - with non-circular orbits you'd generally have a harder time making sure that the object doesn't occasionally overlap some of its neighbors in a visually awkward way.

(The spiral ringband doesn't have anything to do with orbits, iirc; it's just a visual for filling in the inside of a circular band, more or less.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 14, 2022, 08:08:02 AM
You could do it - either by providing a custom implementation of OrbitAPI (which *might* run into some problems, potentially, if some vanilla code makes some assumptions that are broken by this) or by just having a script move the entity around however you choose. You could even have a rectangular orbit if you like :)

Waaaaaait a minute.  You mean that planet orbits are circular, but that orbits could be elliptical instead?  You could even give them tilt by shrinking and growing the planet sprite over the orbit, right?  In principle, you could even simulate real orbits!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 14, 2022, 12:55:53 PM
how does using spawnShipOrWing() work for wings specifically?
say that I wanted a fighter to spawn a copy of itself (and for those copies to be able to spawn copies, with a limit), would spawning the extras as individual ships & adding them to the first ship's wing work (and go over the 6 fighter-per-wing limit), or would I have to do something else?

I've tried looking at the shardSpawner code but it's franky incomprehensible to me, I can't really tell where the aspects actually get spawned / get anything assigned to them
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 14, 2022, 07:40:35 PM
I'm not looking hard enough or something but...

I would like a hullmod to be droppable from raiding faction, but not droppable in research stations or random derelicts scattered across the sector. Is there any tag?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2022, 01:04:35 PM
how does using spawnShipOrWing() work for wings specifically?
say that I wanted a fighter to spawn a copy of itself (and for those copies to be able to spawn copies, with a limit), would spawning the extras as individual ships & adding them to the first ship's wing work (and go over the 6 fighter-per-wing limit), or would I have to do something else?

I've tried looking at the shardSpawner code but it's franky incomprehensible to me, I can't really tell where the aspects actually get spawned / get anything assigned to them

It spawns a full wing. I think your best bet might be to spawn those fighters as "ships", but I'm not sure if it's actually possible to add them to an existing wing - wing.getWingMembers().add() wouldn't work because getWingMembers() returns a copy of the list. Someone with more experience modding this stuff might have a better idea, though.


I'm not looking hard enough or something but...

I would like a hullmod to be droppable from raiding faction, but not droppable in research stations or random derelicts scattered across the sector. Is there any tag?

The "no_drop_salvage" tag should do it.

Edit: at least, assuming a mod hasn't changed or added drop groups that don't respect that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 15, 2022, 01:14:39 PM
You could do it - either by providing a custom implementation of OrbitAPI (which *might* run into some problems, potentially, if some vanilla code makes some assumptions that are broken by this) or by just having a script move the entity around however you choose. You could even have a rectangular orbit if you like :)

Whether that works well will depend on the specifics of your use case - with non-circular orbits you'd generally have a harder time making sure that the object doesn't occasionally overlap some of its neighbors in a visually awkward way.

(The spiral ringband doesn't have anything to do with orbits, iirc; it's just a visual for filling in the inside of a circular band, more or less.)

I have now written a patched-conic OrbitAPI implementation that accepts the initial conditions of the semi-major and semi-minor axes, period, and time at pericenter of a 2-body system, alongside the current time, and dynamically updates the position of the orbiting body by applying a Newton-Raphson approximation of Kepler's laws.  I would gladly see this implementation, or a similar one, added to the collection of factories in the settings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 15, 2022, 03:11:39 PM
It spawns a full wing. I think your best bet might be to spawn those fighters as "ships", but I'm not sure if it's actually possible to add them to an existing wing - wing.getWingMembers().add() wouldn't work because getWingMembers() returns a copy of the list. Someone with more experience modding this stuff might have a better idea, though.

hmm, I could work with spawning the ships - I wanted to spawn the wings & give them to the initial carrier so that the targeting / general grouping stuff would be done automatically, though I guess I could replicate some of it by spawning the individual ships & setting their target to the mothership / initial fighter's (whichever one has the correct target) every frame.

thanks for the clarification anyway!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on July 15, 2022, 05:06:33 PM
how does using spawnShipOrWing() work for wings specifically?
say that I wanted a fighter to spawn a copy of itself (and for those copies to be able to spawn copies, with a limit), would spawning the extras as individual ships & adding them to the first ship's wing work (and go over the 6 fighter-per-wing limit), or would I have to do something else?

I've tried looking at the shardSpawner code but it's franky incomprehensible to me, I can't really tell where the aspects actually get spawned / get anything assigned to them

Piggybacking off this spawnShipOrWing() question, is there any way to keep ships spawned like this from appear in the deployment screen (when pressing G during combat)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on July 16, 2022, 03:41:25 AM
I have a 4 barreled ballistic cannon that each shot is replaced with one of 3 random shell types using an EveryFrameWeaponEffectPlugin.

So far I've gotten the shells to replace correctly, but they all spawn from the same Y location (Y center of the sprite).  I need to capture the location of each muzzle.  Is there a way to detect the muzzle offset of the firing weapon so it can be applied to the new projectile?   I use a calculateMuzzle as seen below, it does most of the job but it looks a little odd with all of the projectiles spawning from the same place.


Spoiler
package data.scripts.weapons;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lwjgl.util.vector.Vector2f;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.lang.String;

public class BarrageKannon_EveryFrameEffect implements EveryFrameWeaponEffectPlugin
{
    public static final float SPREAD = 8f;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
   {

      // Removes dummy shot
      for (DamagingProjectileAPI p : engine.getProjectiles())
      {
         if(p == null || p.getProjectileSpecId() == null || !p.getProjectileSpecId().equalsIgnoreCase("battlefleets_ork_barrage_kannon_shell"))
            continue; // Skip projectiles we don't care about
         
         if(p == null || !p.getWeapon().equals(weapon))
            continue; // Skip projectiles that were not fired by this weapon

         engine.removeEntity(p);
         
         // Random number 0-5
         int RndShotType = (int)Math.round(Math.random() * 5);
         if (RndShotType == 0 || RndShotType == 1 || RndShotType == 2)    // HE shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
            float angle = weapon.getCurrAngle() + offset;
            String weaponId = "battlefleets_ork_barrage_kannon_he";
            Vector2f muzzleLocation = calculateMuzzle(weapon);
            DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
            float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
            proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 3 || RndShotType == 4)    // Kinetic shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
            float angle = weapon.getCurrAngle() + offset;
            String weaponId = "battlefleets_ork_barrage_kannon_kinetic";
            Vector2f muzzleLocation = calculateMuzzle(weapon);
            DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
            float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
            proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 5)    // Frag shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
            float angle = weapon.getCurrAngle() + offset;
            String weaponId = "battlefleets_ork_barrage_kannon_frag";
            Vector2f muzzleLocation = calculateMuzzle(weapon);
            DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
            float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
            proj.getVelocity().scale(randomSpeed);   
         }
      }

   }
   
   private Vector2f calculateMuzzle(WeaponAPI weapon)
   {
        float muzzle = 50;
        double angle = Math.toRadians(weapon.getCurrAngle());
        Vector2f dir = new Vector2f((float)Math.cos(angle),(float)Math.sin(angle));
        if (dir.lengthSquared() > 0f) dir.normalise();
        dir.scale(muzzle);
        Vector2f loc = new Vector2f(weapon.getLocation());
        return Vector2f.add(loc,dir,new Vector2f());

    }
}

[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 16, 2022, 03:57:42 AM
I have a 4 barreled ballistic cannon that each shot is replaced with one of 3 random shell types using an EveryFrameWeaponEffectPlugin.

can't you use an onFireEffectPlugin for this? I'm not sure how the actual code would work but it'd probably be pretty similar - it gives you the projectile that was just fired, you could delete that and spawn your own one at the position of the now-gone projectile (with the rest probably being about the same).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on July 16, 2022, 05:44:18 AM
I have a 4 barreled ballistic cannon that each shot is replaced with one of 3 random shell types using an EveryFrameWeaponEffectPlugin.

can't you use an onFireEffectPlugin for this? I'm not sure how the actual code would work but it'd probably be pretty similar - it gives you the projectile that was just fired, you could delete that and spawn your own one at the position of the now-gone projectile (with the rest probably being about the same).


Indeed I tried the similar:

Spoiler
package data.scripts.weapons;

import java.awt.Color;
import java.util.Iterator;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.util.Misc;
import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.util.IntervalUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BarrageKannonOnFireEffect implements OnFireEffectPlugin
{

    public static final float SPREAD = 8f;   
   
   public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
   {

       // Removes dummy shot
      for (DamagingProjectileAPI p : engine.getProjectiles())
      {
         if (p.getWeapon() == weapon && p.getProjectileSpecId().equalsIgnoreCase("battlefleets_ork_barrage_kannon_shell"))
            engine.removeEntity(p);
      }
      
         // Random number 0-5
         int RndShotType = (int)Math.round(Math.random() * 5);
         if (RndShotType == 0 )    // HE shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
                float angle = weapon.getCurrAngle() + offset;
                String weaponId = "battlefleets_ork_barrage_kannon_he";
                Vector2f muzzleLocation = calculateMuzzle(weapon);
                DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
                float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
                proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 1 )    // HE shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
                float angle = weapon.getCurrAngle() + offset;
                String weaponId = "battlefleets_ork_barrage_kannon_he";
                Vector2f muzzleLocation = calculateMuzzle(weapon);
                DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
                float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
                proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 2 )    // HE shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
                float angle = weapon.getCurrAngle() + offset;
                String weaponId = "battlefleets_ork_barrage_kannon_he";
                Vector2f muzzleLocation = calculateMuzzle(weapon);
                DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
                float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
                proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 3)    // Kinetic shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
                float angle = weapon.getCurrAngle() + offset;
                String weaponId = "battlefleets_ork_barrage_kannon_kinetic";
                Vector2f muzzleLocation = calculateMuzzle(weapon);
                DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
                float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
                proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 4)    // Kinetic shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
                float angle = weapon.getCurrAngle() + offset;
                String weaponId = "battlefleets_ork_barrage_kannon_kinetic";
                Vector2f muzzleLocation = calculateMuzzle(weapon);
                DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
                float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
                proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 5)    // Frag shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
                float angle = weapon.getCurrAngle() + offset;
                String weaponId = "battlefleets_ork_barrage_kannon_frag";
                Vector2f muzzleLocation = calculateMuzzle(weapon);
                DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,muzzleLocation,angle,weapon.getShip().getVelocity());
                float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
                proj.getVelocity().scale(randomSpeed);   
         }

   }
   
   private Vector2f calculateMuzzle(WeaponAPI weapon)
   {
        float muzzle = 30;
        double angle = Math.toRadians(weapon.getCurrAngle());
        Vector2f dir = new Vector2f((float)Math.cos(angle),(float)Math.sin(angle));
        if (dir.lengthSquared() > 0f) dir.normalise();
        dir.scale(muzzle);
        Vector2f loc = new Vector2f(weapon.getLocation());
        return Vector2f.add(loc,dir,new Vector2f());

    }
}



[close]


But couldn't get it to delete the original shell.   Still unsure how to capture the proper muzzle offset with either function.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 16, 2022, 06:40:59 AM
note : I've not tested this in game so idk if it actually works, but I'd do something like this.

 code
Code
    @Override
    public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) {

        Vector2f spawnLoc = projectile.getSpawnLocation();
        float facing = projectile.getFacing();
        float randomSpeed = (float) (Math.random() * 0.4f + 0.8f);

        WeightedRandomPicker<String> weapPicker = new WeightedRandomPicker<>();

        weapPicker.add("battlefleets_ork_barrage_kannon_he", 3f);
        weapPicker.add("battlefleets_ork_barrage_kannon_ke", 2f);
        weapPicker.add("battlefleets_ork_barrage_kannon_frag",1f);

        DamagingProjectileAPI newProj = (DamagingProjectileAPI) engine.spawnProjectile(
                weapon.getShip(),
                weapon,
                weapPicker.pick(),
                spawnLoc,
                facing,
                weapon.getShip().getVelocity()
        );
       
        newProj.getVelocity().scale(randomSpeed);

        engine.removeEntity(projectile);
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on July 16, 2022, 05:18:05 PM
note : I've not tested this in game so idk if it actually works, but I'd do something like this.

 code
Code
    @Override
    public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) {

        Vector2f spawnLoc = projectile.getSpawnLocation();
        float facing = projectile.getFacing();
        float randomSpeed = (float) (Math.random() * 0.4f + 0.8f);

        WeightedRandomPicker<String> weapPicker = new WeightedRandomPicker<>();

        weapPicker.add("battlefleets_ork_barrage_kannon_he", 3f);
        weapPicker.add("battlefleets_ork_barrage_kannon_ke", 2f);
        weapPicker.add("battlefleets_ork_barrage_kannon_frag",1f);

        DamagingProjectileAPI newProj = (DamagingProjectileAPI) engine.spawnProjectile(
                weapon.getShip(),
                weapon,
                weapPicker.pick(),
                spawnLoc,
                facing,
                weapon.getShip().getVelocity()
        );
       
        newProj.getVelocity().scale(randomSpeed);

        engine.removeEntity(projectile);
    }
[close]


Ok, tried as is and it hung up on the randomSpeed  declaration, so I tweaked it and it got past that to get hung up on WeightedRandomPicker declaration.

Spoiler
public class BarrageKannonOnFireEffect2 implements OnFireEffectPlugin
{

   public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
   {

      Vector2f spawnLoc = projectile.getSpawnLocation();
      float facing = projectile.getFacing();
      //float randomSpeed = (float) (Math.random() * 0.4f + 0.8f);
      float randomSpeed = (float)Math.random() * 0.4f + 0.8f;

      WeightedRandomPicker<String> weapPicker = new WeightedRandomPicker<>();

      weapPicker.add("battlefleets_ork_barrage_kannon_he", 3f);
      weapPicker.add("battlefleets_ork_barrage_kannon_ke", 2f);
      weapPicker.add("battlefleets_ork_barrage_kannon_frag",1f);

      DamagingProjectileAPI newProj = (DamagingProjectileAPI) engine.spawnProjectile(
            weapon.getShip(),
            weapon,
            weapPicker.pick(),
            spawnLoc,
            facing,
            weapon.getShip().getVelocity()
      );

      newProj.getVelocity().scale(randomSpeed);

      engine.removeEntity(projectile);
    }
}
[close]


However, I did insert the spawnLoc and Facing statements and put them in my EveryFrameWeaponEffectPlugin and it works like a charm!   Your solution seems to be much cleaner though.    I'm not sure how to make the WeightedRandomPicker line play nice.  Does it want something in between the <>    ???



Spoiler
public class BarrageKannon_EveryFrameEffect2 implements EveryFrameWeaponEffectPlugin
{
    public static final float SPREAD = 8f;
    private int RndShotType = 0;

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon)
   {

      // Removes dummy shot
      for (DamagingProjectileAPI p : engine.getProjectiles())
      {
         if(p == null || p.getProjectileSpecId() == null || !p.getProjectileSpecId().equalsIgnoreCase("battlefleets_ork_barrage_kannon_shell"))
            continue; // Skip projectiles we don't care about
         
         if(p == null || !p.getWeapon().equals(weapon))
            continue; // Skip projectiles that were not fired by this weapon
         
         Vector2f spawnLoc = p.getSpawnLocation();
         float facing = p.getFacing();

         engine.removeEntity(p);
         
         // Random number 0-5
         RndShotType = (int)Math.round(Math.random() * 5);
         if (RndShotType == 0 || RndShotType == 1 || RndShotType == 2)    // HE shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
            String weaponId = "battlefleets_ork_barrage_kannon_he";
            DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,spawnLoc,facing,weapon.getShip().getVelocity());
            float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
            proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 3 || RndShotType == 4)    // Kinetic shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
            String weaponId = "battlefleets_ork_barrage_kannon_kinetic";
            DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,spawnLoc,facing,weapon.getShip().getVelocity());
            float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
            proj.getVelocity().scale(randomSpeed);   
         }
         
         if (RndShotType == 5)    // Frag shot
         {
            float offset = ((float)Math.random() * SPREAD) - (SPREAD * 0.5f);
            String weaponId = "battlefleets_ork_barrage_kannon_frag";
            DamagingProjectileAPI proj = (DamagingProjectileAPI)engine.spawnProjectile(weapon.getShip(),weapon,weaponId,spawnLoc,facing,weapon.getShip().getVelocity());
            float randomSpeed = (float)Math.random() * 0.4f + 0.8f;
            proj.getVelocity().scale(randomSpeed);   
         }
      }

   }

}
[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 16, 2022, 05:30:54 PM
Piggybacking off this spawnShipOrWing() question, is there any way to keep ships spawned like this from appear in the deployment screen (when pressing G during combat)

An easy way I think would be .setAlly(true). Others with more modding experience might have a better idea, though.

So far I've gotten the shells to replace correctly, but they all spawn from the same Y location (Y center of the sprite).  I need to capture the location of each muzzle.  Is there a way to detect the muzzle offset of the firing weapon so it can be applied to the new projectile?

Dumb question: wouldn't the muzzle location be the same as the location of the projectile you're replacing?

Alternatively, if you're looking for the location of *all* the muzzles, you could get the offsets via WeaponSpecAPI.getTurretFireOffsets() and getHardpointFireOffsets(). There are methods to get barrel angle offsets, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on July 16, 2022, 07:48:10 PM
Piggybacking off this spawnShipOrWing() question, is there any way to keep ships spawned like this from appear in the deployment screen (when pressing G during combat)

An easy way I think would be .setAlly(true). Others with more modding experience might have a better idea, though.

So far I've gotten the shells to replace correctly, but they all spawn from the same Y location (Y center of the sprite).  I need to capture the location of each muzzle.  Is there a way to detect the muzzle offset of the firing weapon so it can be applied to the new projectile?

Dumb question: wouldn't the muzzle location be the same as the location of the projectile you're replacing?

Alternatively, if you're looking for the location of *all* the muzzles, you could get the offsets via WeaponSpecAPI.getTurretFireOffsets() and getHardpointFireOffsets(). There are methods to get barrel angle offsets, too.


Not dumb at all.  More like my dumb as java is something I'm slowly figuring out and learning the functions here for mod purposes.

getSpawnLocation()   and getFacing() of the projectile seems to do the job nicely.     Get the data from the projectile, delete projectile, use data for new projectile.       I'll take a look at those other functions you mentioned as well,  thanks as always Alex!  :-)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 16, 2022, 07:54:34 PM
Nice, glad that did the job!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NEmergix on July 18, 2022, 05:17:50 PM

Modding newb here, trying to modify the historian bar event so it appears more frequently and whatnot.

I think i might have found what i need; its in a file named "starsector.api.zip" but it seems the .jar with the same name is just a duplicate.

The path goes : com > fs > starfarer > api > impl> campaign > intel > bar > events > historian.

Couple questions :

- Although i might figure it out on my own, what file is the most interesting for my needs ?

- More importantly : how do i compile the code so it applies in game ? I don't think the "starsector.api.zip" will do anything to my game. So where is the proper file i need to tamper in order to change in game stuff ?

Thanks !
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 20, 2022, 07:46:51 AM
Evenin',

I'm looking for a way to get the local nebula colour in a star system.
Doesn't appear to be as straightforward as I thought, since getRenderColor() on the nebula terrain plugin only returns white and there isn't a readily apparent way to see where the nebula gets its colour at all (in that class).

any pointers?
thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 20, 2022, 07:59:44 AM
Evenin',

I'm looking for a way to get the local nebula colour in a star system.
Doesn't appear to be as straightforward as I thought, since getRenderColor() on the nebula terrain plugin only returns white and there isn't a readily apparent way to see where the nebula gets its colour at all (in that class).

any pointers?
thanks!

The actual *color* isn't anywhere in-game other than the nebula sprites that have the color baked into them.

You might do:
String nebulaType = StarSystemGenerator.nebulaTypes.get(system.getAge());

To get a string that represents the type of nebula it is. The strings are defined in StarSystemGenerator.java:
public static final String NEBULA_DEFAULT = "nebula"; // (this is the purple one)
public static final String NEBULA_AMBER = "nebula_amber";
public static final String NEBULA_BLUE = "nebula_blue";
public static final String NEBULA_NONE = "no_nebula";

- Although i might figure it out on my own, what file is the most interesting for my needs ?

That would heavily depend on what you want to do. But you're in the right area!

- More importantly : how do i compile the code so it applies in game ? I don't think the "starsector.api.zip" will do anything to my game. So where is the proper file i need to tamper in order to change in game stuff ?

There ought to be a guide on setting up an IDE on the forum somewhere, but I can't find it right now, hmm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 20, 2022, 08:22:43 AM
Much appreciated, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on July 20, 2022, 11:48:29 AM
- More importantly : how do i compile the code so it applies in game ? I don't think the "starsector.api.zip" will do anything to my game. So where is the proper file i need to tamper in order to change in game stuff ?

There are a few IDE setup guides.

This is the one I think is simplest, although it doesn't have a nice wiki page yet and isn't completely noob-proof. Still, the readme should hit all the major steps needed to complete setup.
https://github.com/davidwhitman/Starsector-IntelliJ-Template
It's also quite new and the wiki doesn't link to it yet.

This is an overview of mod programming, with a few IDEs compared and guides linked. It contains stuff about what the different files are, too (.java, .class, .jar) and why you shouldn't use Janino.
https://starsector.fandom.com/wiki/Getting_started_with_mod_programming

And finally, this is another IntelliJ setup guide: https://starsector.fandom.com/wiki/IntelliJ_IDEA_Setup.
This one has you compile Magellan, as opposed to just a barebones template like the first link.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 20, 2022, 05:24:25 PM
How can I detect each tick of a beam that has hit a CombatEntityAPI, or at least a ShipAPI and its shield?  DamageDealtModifier and DamageTakenModifier detect only the first tick of damage.

Edit: Sweet Ludd.  I had to resort to redundant iteration and spaghetti code to find the beam ticks.  I really hope it's my fault because this is just ugly.  If it's not... please make them detect subsequent ticks?  :'(

Code
    private static void diffractBeam(BeamAPI beam) {
        if (!(beam.getDamageTarget() instanceof ShipAPI)) beam.getDamage().setDamage(
                Penetration.getPenetration(beam));
        else if (beam.getDamageTarget().getShield() == null
                 || !beam.getDamageTarget().getShield().isWithinArc(beam.getTo()))
        {
            final ShipAPI target = (ShipAPI) beam.getDamageTarget();
            final HashMap<String, Float> damage = Damage.getCompartmentAndHullDamage(target, beam);
            final float time = Global.getCombatEngine().getElapsedInLastFrame();
            if (damage.get("compartment") > 0)
                DamageTakenModifier.applyDamage(
                        target,
                        beam.getRayEndPrevFrame(),
                        time * damage.get("hull"),
                        time * damage.get("compartment"),
                        beam.getSource()
                );
            beam.getDamage().setDamage(0);
        }
    }

    private static void diffractAllBeams(ShipAPI ship) {
        for (WeaponAPI weapon : ship.getUsableWeapons())
            if (weapon.isBeam() && weapon.isFiring())
                for (BeamAPI beam : weapon.getBeams())
                    if (beam.getDamageTarget() != null && beam.getBrightness() >= 1)
                        try { diffractBeam(beam); } catch (Throwable ignored) {}
    }

Also, EnergyWeaponRangeBonus seems to affect Beam weapons too.  Can I affect energy projectile but not energy beam range?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PasDeBras on July 21, 2022, 01:29:22 AM
Hello! I'm looking for a way to make a hullmod give a set number of OP (the simpler the better) like a mod i found years ago but lost, in exchange of malfunctions, but modding HM seems way harder that just adding a ship to the game, any pointers?
Thank you precious people..

Edit : Message is unclear, but i want to know what to call for malfunctions...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on July 21, 2022, 11:33:28 PM
Is there a way to make a missile not disappear when hitting shields/fighters? Also optionally how to make a missile bypass shields entirely?

For example, the missile moves to fighter 1 and hits it, but it’s still alive and can move on to target fighter 2.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 22, 2022, 12:28:17 PM
How can I detect each tick of a beam that has hit a CombatEntityAPI, or at least a ShipAPI and its shield?  DamageDealtModifier and DamageTakenModifier detect only the first tick of damage.

Some quick testing shows that modifyDamageDealt() is called for every damage tick. Which is not the same as every frame btw.

Code
try { diffractBeam(beam); } catch (Throwable ignored) {}

(I really wouldn't do this sort of stuff if I were you - in the long run, you're likely hiding some major bugs from *yourself*.


Also, EnergyWeaponRangeBonus seems to affect Beam weapons too.  Can I affect energy projectile but not energy beam range?

You can modify beam range by the inverse.


Hello! I'm looking for a way to make a hullmod give a set number of OP (the simpler the better) like a mod i found years ago but lost, in exchange of malfunctions, but modding HM seems way harder that just adding a ship to the game, any pointers?
Thank you precious people..

Edit : Message is unclear, but i want to know what to call for malfunctions...

IIRC the way to give OP is to give the hullmod a negative cost. For malfunctions, take a look at data.hullmods.IllAdvised.


Is there a way to make a missile not disappear when hitting shields/fighters? Also optionally how to make a missile bypass shields entirely?

For example, the missile moves to fighter 1 and hits it, but it’s still alive and can move on to target fighter 2.

Offhand, I don't think so. You might be able to do something fancier like replacing the missile with a copy and making it non-collideable until it leaves the bounds of the targets, or some such. You might also possibly experiment with setting it to be not "armed" (so that it bounces off on impact) and scripting the damage it does instead. Not 100% sure how well any of that would pan out; too many variables.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 22, 2022, 02:09:14 PM
Some quick testing shows that modifyDamageDealt() is called for every damage tick. Which is not the same as every frame btw.

Wow, you tested it for me?  Gee, Alex... you didn't have to!  Thank you so much!  :)  Why mine doesn't work like yours I have no idea.  I'll try to test it myself some more and see.

Quote from: Alex
Code
try { diffractBeam(beam); } catch (Throwable ignored) {}

(I really wouldn't do this sort of stuff if I were you - in the long run, you're likely hiding some major bugs from *yourself*.

Oh... what should I do instead?  :o I've wrapped the inner workings of the many public, and even a few private, methods of my mod inside one if not several such try-catch blocks because I had thought that guaranteeing that no bug will ever crash the code or generate a nasty error report to be good software engineering practice--and had felt rather proud of myself until just now.  *gulp*  :-[

My best guess is to keep the try-catch blocks but put breakpoints and error dumps inside the catch sections.

Quote from: Alex
You can modify beam range by the inverse.

Thank you!  What a relief.  I can fix a longstanding bug now.  I hope that there will be a method to do so directly someday!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 22, 2022, 06:39:02 PM
Oh... what should I do instead?  :o I've wrapped the inner workings of the many public, and even a few private, methods of my mod inside one if not several such try-catch blocks because I had thought that guaranteeing that no bug will ever crash the code or generate a nasty error report to be good software engineering practice--and had felt rather proud of myself until just now.  *gulp*  :-[

My best guess is to keep the try-catch blocks but put breakpoints and error dumps inside the catch sections.

Buy the book "Code Complete" by Steve McConnell and read it. Page 198-203 of my 2nd edition specifically talks about exceptions.

What you are doing is covering up exceptions you don't know what to do with, which means your code is either raising an exception for no reason, or as Alex said you are hiding problems from yourself.

What you should do is let the null pointers and other exceptions blow out, find where they are coming from, and either avoid or fix those problems.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 22, 2022, 07:48:04 PM
Kicking the player to desktop is unpleasant, so in cases where the error will be visible without such extreme methods and/or is non-fatal (in my case, this is UI elements in an intel display), I've used a catch-all-exceptions block.
But log the error at least so if it's noticed you know what's going on.

Actually now what I'd like is a standardised API for error reporting dialogs (and do this automatically for uncaught exceptions), like the one AI War 2 uses:

Spoiler
(https://i.imgur.com/Pm9SdPP.png)
[close]
- Big annoying popup is big, annoying and full of scary code, but it also immediately lets them know something has gone wrong without the abrupt transition of a CTD, or losing their progress
- When player shows a screenshot of this to someone, the stacktrace is immediately visible without having to tell them where/how to look for starsector.log
- If the error isn't fatal they can resume playing, at least they can make a save copy and try to continue, and even if things are in an invalid state now they can sometimes be left alone till the relevant battle/campaign event ends, or fixed with a console runcode
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 23, 2022, 02:16:07 AM
Buy the book "Code Complete" by Steve McConnell and read it. Page 198-203 of my 2nd edition specifically talks about exceptions.

What you are doing is covering up exceptions you don't know what to do with, which means your code is either raising an exception for no reason, or as Alex said you are hiding problems from yourself.

What you should do is let the null pointers and other exceptions blow out, find where they are coming from, and either avoid or fix those problems.

Thanks for replying!  Why should I let the null pointers and other exceptions blow out if, instead, I could have a breakpoint and error-logger inside every try-catch block?  When I would run the code with a debugger attached, any use of the try-catch block would 'crash' the game to the debugger, saving the trouble of reloading while exposing what went wrong.  When the user would run the code, the try-catch block would execute silently, letting them enjoy the game without worrying about crashes, which I worry about because my mod interacts with every other mod in the game and the entire combat system without many of the guarantees of the API; e.g., I have to cover not only projectiles, missiles, and beams but also asteroids, ships, debris, and anything else that any modder has decided to toss in.  If my mod crashed to the desktop or even displayed an error dialogue for every exception, users could never rest easy and would probably uninstall it.  :(

(see below as well)

Kicking the player to desktop is unpleasant, so in cases where the error will be visible without such extreme methods and/or is non-fatal (in my case, this is UI elements in an intel display), I've used a catch-all-exceptions block.
But log the error at least so if it's noticed you know what's going on.

What do you mean by non-fatal?  I expect nullPointerExceptions, weird numerical errors, etc. especially once huge lists of other mods and their interactions become involved because my mod works with dark DIY API magic, implements a whole new damage model, and has many EveryFrameCombatScripts, some of which do things I know to be unstable but haven't seen an alternative to.  I'm afraid that I am attempting to do stuff so inherently unstable and repetitive that if Realistic Combat so much as threw pop-ups, the user might know no peace.  For example, I received a bug report that the entire combat UI was smeared around the screen, implying that Realistic Combat had 'shrugged and chugged' despite a glaring problem with a perhaps gnarly or obscure cause--just as I had hoped because I haven't received another such report before or since.

Writing all this, I have a bad feeling, but I don't know why.  I think I need another try-catch block.  ???

Quote
Actually now what I'd like is a standardised API for error reporting dialogs (and do this automatically for uncaught exceptions), like the one AI War 2 uses:

Spoiler
(https://i.imgur.com/Pm9SdPP.png)
[close]
- Big annoying popup is big, annoying and full of scary code, but it also immediately lets them know something has gone wrong without the abrupt transition of a CTD, or losing their progress
- When player shows a screenshot of this to someone, the stacktrace is immediately visible without having to tell them where/how to look for starsector.log
- If the error isn't fatal they can resume playing, at least they can make a save copy and try to continue, and even if things are in an invalid state now they can sometimes be left alone till the relevant battle/campaign event ends, or fixed with a console runcode

That's easier than it might seem.  I believe you can use LazyLib to directly draw a big, scary blue block on the screen and print white text on it: "ERROR: [report] PRESS SPACE TO CONTINUE"

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on July 23, 2022, 03:48:42 PM
For example, I received a bug report that the entire combat UI was smeared around the screen, implying that Realistic Combat had 'shrugged and chugged' despite a glaring problem with a perhaps gnarly or obscure cause--just as I had hoped because I haven't received another such report before or since.

you have an issue in one of your UI draw events that caused this, which happened after pushing onto the openGL stack and before popping it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 24, 2022, 08:43:41 PM
What do you mean by non-fatal?  I expect nullPointerExceptions, weird numerical errors, etc. especially once huge lists of other mods and their interactions become involved because my mod works with dark DIY API magic, implements a whole new damage model, and has many EveryFrameCombatScripts, some of which do things I know to be unstable but haven't seen an alternative to.  I'm afraid that I am attempting to do stuff so inherently unstable and repetitive that if Realistic Combat so much as threw pop-ups, the user might know no peace.  For example, I received a bug report that the entire combat UI was smeared around the screen, implying that Realistic Combat had 'shrugged and chugged' despite a glaring problem with a perhaps gnarly or obscure cause--just as I had hoped because I haven't received another such report before or since.

Writing all this, I have a bad feeling, but I don't know why.  I think I need another try-catch block.  ???
By non-fatal I mean anything that won't permanently (within or beyond the current play session).

Regarding the rest:
If your mod is generating errors that need covering up, this often ("know no peace") you need to fix them, not merely sweep them under the rug.
You don't have to make it interfere with the player's UX, maybe write something in the post-combat dialog or campaign message field "X errors in Realistic Combat encountered in last battle, please send me your starsector.log". But the key point remains: If the mod suppresses a hundred distinct bug notifications, that's a hundred bugs in the mod, and hiding them doesn't make them stop being bugs. If the user is experiencing so many hidden errors, they're not receiving the intended experience — but neither you nor they know they're not getting the intended experience!
Relying on your own debugger runs isn't adequate; many errors aren't picked up by the mod dev, but by a player.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 25, 2022, 02:59:36 AM
By non-fatal I mean anything that won't permanently (within or beyond the current play session).
  • If the entire Combat Chatter mod were to stop working in the middle of a battle: annoying but whatever, finish the battle, save and restart the game, assuming you even noticed it stopped working.
  • AI breaks and all the NPC ships stop moving: this is serious, but I think the player should be the one to decide whether they want to close the game now, or just use console (if available) to end it and then save.
  • TBH to justify a CTD you'd probably need a bug that outright corrupts campaign data in an irrecoverable way

Ok, so anything short of the equivalent to SEGMENTATION FAULT: CORE DUMPED is non-fatal.

Quote
Regarding the rest:
If your mod is generating errors that need covering up, this often ("know no peace") you need to fix them, not merely sweep them under the rug.

I have no idea how often my mod generates errors because I have built try-catch blocks into it from the beginning--and it has no logs to record the errors--but I have nothing against fixing them in principle.  In practice I suspect from what I have seen of the errors that have leaked through the try-catch blocks that ones not caused by my own typos or forgetfulness are obscure, gnarly, and peculiar to whatever long content mod list each reporting player pushes through my ship and weapon stat modifications or damage model.  For example, one user has recently complained about a music file not loading even though Realistic Combat never even touches music files.  :o  I have no idea how to fix any of these errors, either.

Maybe this is all so much whining.  :-\

Quote
You don't have to make it interfere with the player's UX, maybe write something in the post-combat dialog or campaign message field "X errors in Realistic Combat encountered in last battle, please send me your starsector.log". But the key point remains: If the mod suppresses a hundred distinct bug notifications, that's a hundred bugs in the mod, and hiding them doesn't make them stop being bugs. If the user is experiencing so many hidden errors, they're not receiving the intended experience —

Ooooh, OK, that could work.  Please tell me more about this because I have no idea how to make it happen.

Quote
but neither you nor they know they're not getting the intended experience!

All according to plan!  ;D

Quote
Relying on your own debugger runs isn't adequate; many errors aren't picked up by the mod dev, but by a player.

Aww...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 25, 2022, 01:00:28 PM
would it be possible to force a ship's fighters to always land at one bay and launch from another?

i.e, if I had a ship with a bay going "through" the hull and always wanted the fighters to land on one end then launch from the other, that kinda thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 25, 2022, 06:32:57 PM
Actually now what I'd like is a standardised API for error reporting dialogs (and do this automatically for uncaught exceptions), like the one AI War 2 uses:

Spoiler
(https://i.imgur.com/Pm9SdPP.png)
[close]
- Big annoying popup is big, annoying and full of scary code, but it also immediately lets them know something has gone wrong without the abrupt transition of a CTD, or losing their progress
- When player shows a screenshot of this to someone, the stacktrace is immediately visible without having to tell them where/how to look for starsector.log
- If the error isn't fatal they can resume playing, at least they can make a save copy and try to continue, and even if things are in an invalid state now they can sometimes be left alone till the relevant battle/campaign event ends, or fixed with a console runcode

Hmm, interesting! The bad case here seems like it'd be the error popping up, putting some mission chain in a "permanently broken" state because something critical to it failed, and then the mission becomes incompletable a few play sessions later. And *then* the player reports a bug with that mission being in a broken state - without mentioning that, oh yeah, there was this error like a week ago. I don't know - I get the appeal, but I feel like this also destroys something very foundational about being able to look at a bug report and know certain things about what led to it. If you can no longer assume that X is true because it would've crashed earlier otherwise, that's real, real bad.

(I suppose one could store these errors in the savefile, but, that really gets to be a rabbit hole...)


would it be possible to force a ship's fighters to always land at one bay and launch from another?

i.e, if I had a ship with a bay going "through" the hull and always wanted the fighters to land on one end then launch from the other, that kinda thing.

I don't *think* so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 25, 2022, 06:59:04 PM
would it be possible to force a ship's fighters to always land at one bay and launch from another?

i.e, if I had a ship with a bay going "through" the hull and always wanted the fighters to land on one end then launch from the other, that kinda thing.

I don't *think* so.

A script for the ship that messes with the fighters? Put all the deck points at the landing end and then teleport any launching fighters to the launch end, maybe.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amazigh on July 25, 2022, 07:45:52 PM
Is there any way to have a fighter with a limited ammo weapon that will return to the carrier to reload, without it being classed as a bomber.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 26, 2022, 02:07:41 PM
was just poking around the api and saw stuff in CollisionGridAPI - what would you consider a "large area" for the purposes of using getCheckIterator() instead of just iterating over every ship or w/e?

also, is there a way to override the ECM rating status? I've had an idea for messing w/ it to make a system cooler so it's not entirely necessary if it's hard / annoying, but I'd like to know if it's possible.

and another quick edit - what's the warpingSpriteRendererUtil class used for / how should it be used? from the name it sounds like it could be cool for vfx, but I unfortunately can't make heads or tails of actually doing anything with it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 26, 2022, 04:13:28 PM
Dear Alex,

Would you please add an explicit method to return the weapon_data.csv move speed of a ProjectileSpecAPI?

I ask because I wanted to know the weapon_data.csv move speed of a ProjectileSpecAPI but have struggled to do so.  A stacktrace of an error from my ProjectileWeaponSpecProxy referred to what I discovered to be the obfuscated class behind ProjectileSpecAPI; reviewing the obfuscated code of the method there, I guessed that an obfuscated variable was the weapon_data.csv move speed and that passing null to the first argument of ProjectileSpecAPI.getMoveSpeed(MutableShipStatsAPI stats, WeaponAPI weapon) would make it return the weapon_data.csv move speed.

I think an explicit method to return the weapon_data.csv move speed or mention of this feature in the ProjectileSpecAPI Javadoc would save future modders the effort I had to make.

Sincerely,
Liral
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 26, 2022, 05:48:11 PM
I think an explicit method to return the weapon_data.csv move speed or mention of this feature in the ProjectileSpecAPI Javadoc would save future modders the effort I had to make.
what would've been even more useful
is to have a proper method for getting contents of any .csv field, even if only string
right now there are a lot of values that cannot be accessed directly, and only produce some derivative, at best, when called, especially for weapons, especially when calling from weaponSpec, when no specific weaponAPI actually exists.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on July 27, 2022, 08:50:32 AM
I don't really know what is wrong with this code:

(It's supposed to delete an entity and replace it with a similar entity in the same location with a unique marketplace data)

Spoiler
        // Replacing Drakon with Ravaryea analogue
        LocationAPI hyper = Global.getSector().getHyperspace();
        String amazing = "mamamia"; // 11000, -7500(Naraka), -4400,-4500(Askonia) +- 200
        for (SectorEntityToken e : hyper.getAllEntities()) {
            if (e.getLocation().x > -4200 && e.getLocation().x < -4600 && e.getLocation().y > -4300 && e.getLocation().y < -4700) {
                amazing = e.getId();
            }
        }
        Global.getSector().getHyperspace().removeEntity(Global.getSector().getEntityById(amazing));
        system.removeEntity(Global.getSector().getEntityById("drakon"));
        PlanetAPI drakon = system.addPlanet("drakon_fortress", system.getStar(), "Drakon", "terran-eccentric", 280, 150, 12000, 1000); //formerly 450 and 650
        if (!isPAGSM) {
            drakon.setCustomDescriptionId("planet_drakon_fortress");
        } else {
            drakon.setCustomDescriptionId("planet_drakon_fortress_PAGSM");
        }
        MarketAPI drakon_fortress_market = addMarketplace(
                "sindrian_diktat",
                drakon,
                null,
                "Drakon",
                5,

                new ArrayList<>(
                        Arrays.asList(
                                Conditions.POPULATION_5,
                                Conditions.HABITABLE,
                                Conditions.VERY_COLD,
                                Conditions.DARK,
                                Conditions.FARMLAND_ADEQUATE,
                                Conditions.ORGANICS_PLENTIFUL,
                                Conditions.VOLATILES_DIFFUSE,
                                Conditions.OUTPOST
                        )
                ),

                new ArrayList<>(
                        Arrays.asList(
                                Submarkets.SUBMARKET_OPEN,
                                Submarkets.SUBMARKET_STORAGE,
                                Submarkets.SUBMARKET_BLACK
                        )
                ),
                new ArrayList<>(
                        Arrays.asList(
                                Industries.POPULATION,
                                Industries.SPACEPORT,
                                Industries.PATROLHQ,
                                Industries.MINING,
                                Industries.FARMING,
                                "commerce",
                                Industries.ORBITALSTATION,
                                Industries.GROUNDDEFENSES
                        )
                ),
                //tariffs
                0.18f,
                //freeport
                false,
                //junk and chatter
                true);
        drakon.setMarket(drakon_fortress_market);
        drakon.getMarket().getIndustry(Industries.POPULATION).setSpecialItem(new SpecialItemData(Items.ORBITAL_FUSION_LAMP, null));
        Misc.setAllPlanetsKnown(system);
[close]

The market seems to spawn deformed; it fails to spawn conditions properly(no effect on hazard, or fail to show up on market screen) and has no admins or people on its comms boards. Does anyone know what's up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 27, 2022, 09:02:50 AM
Let me just add a few methods to SettingsAPI:
   JSONArray getMergedSpreadsheetData(String idColumn, String path)
   JSONObject getMergedJSON(String path)


The market seems to spawn deformed; it fails to spawn conditions properly(no effect on hazard, or fail to show up on market screen) and has no admins or people on its comms boards. Does anyone know what's up?

At a guess, the conditions are not marked as being surveyed, and so are not visible? I didn't dig into the code very much, though. But basically you'd want to iterate over the market's conditions and for each one do setSurveyed(true).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on July 27, 2022, 09:09:49 AM
Let me just add a few methods to SettingsAPI:
   JSONArray getMergedSpreadsheetData(String idColumn, String path)
   JSONObject getMergedJSON(String path)

Ayyyyy, let's gooooo! :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 27, 2022, 09:26:00 AM
Hmm, interesting! The bad case here seems like it'd be the error popping up, putting some mission chain in a "permanently broken" state because something critical to it failed, and then the mission becomes incompletable a few play sessions later. And *then* the player reports a bug with that mission being in a broken state - without mentioning that, oh yeah, there was this error like a week ago. I don't know - I get the appeal, but I feel like this also destroys something very foundational about being able to look at a bug report and know certain things about what led to it. If you can no longer assume that X is true because it would've crashed earlier otherwise, that's real, real bad.

(I suppose one could store these errors in the savefile, but, that really gets to be a rabbit hole...)
Hm, could be useful if, on crash, the game threw you back to the main menu with a dialogue box like that. Best of both worlds for the player?

Alternatively, throwing up a console window with the stack trace and some info for the player to copy when the game crashes might be a good (and easier to implement?) thing.

For my own purposes, info I'd like to know in that crash short report would be:
- Game version
- Installed Mod IDs + version
- Stack trace

While keeping log output in the .log files as it is now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on July 27, 2022, 05:56:37 PM
The market seems to spawn deformed; it fails to spawn conditions properly(no effect on hazard, or fail to show up on market screen) and has no admins or people on its comms boards. Does anyone know what's up?
If the market replacement happens after economy load, you'll need to survey the conditions (as per Alex's post above) and add comm directory people yourself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Somtaaw on July 27, 2022, 06:30:09 PM
So I guess I have too many mods for the game to be comfortable with as its starting to say its running out of the RAM allocated to it but I can edit vmparams(?) file to change that.

I think it defaults to 2GB? at least as far as I can tell from my task manager. What's a safe amount that the game can handle? 8? or should I try 4 first?

Actually I just opened it in Notepad++ and its just a long string and no obvious way to tell the game to allocate more RAM. Thoughts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on July 27, 2022, 09:47:23 PM
There's nothing wrong with storing permanent variables in $market for rules.csv right? I noticed that the rest of the $market.yadda always have an expiration... in dev mode.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 28, 2022, 11:19:02 AM
There's nothing wrong with storing permanent variables in $market for rules.csv right? I noticed that the rest of the $market.yadda always have an expiration... in dev mode.

The variables created by CoreCampaignPluginImpl.updateXXXXXFacts() always have an expiration set because they're recomputed prior to every interaction and they don't need to be stored in memory long term. But yeah, if you're actually using a variable to keep track of something over time, then you can store one there without an expiration. IIRC this happens at times for vanilla missions etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on July 31, 2022, 09:53:12 PM
Is there a way to arbitrarily set the min/max campaign zoom at runtime?

I've gotten as far as `game.settings.setFloat("maxCampaignZoom", zoomMult)` but it doesn't stick and it doesn't look like I have access to any code needed to make it stick, but maybe I'm wrong?

My goal is to be able to allow the player to zoom out to see most of a system for some set period, then change the limit back to their normal one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 01, 2022, 08:10:55 AM
Yeah, that's not going to work - those values are just used to initialize the zoom tracker. Let me add some stuff to CampaignUIAPI:

float getMinZoomFactor();
float getMaxZoomFactor();
void setMinZoomFactor(float min);
void setMaxZoomFactor(float max);

My goal is to be able to allow the player to zoom out to see most of a system for some set period, then change the limit back to their normal one.

Just as a heads up, that seems likely to cause an FPS dive in some star systems, especially if there is a lot of nebula. (Also, stuff isn't designed to look good at that level, but, I mean, that's kind of whatever.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 01, 2022, 08:28:42 AM
Yeah, that's not going to work - those values are just used to initialize the zoom tracker. Let me add some stuff to CampaignUIAPI:

float getMinZoomFactor();
float getMaxZoomFactor();
void setMinZoomFactor(float min);
void setMaxZoomFactor(float max);

Ooh, while we're talking zoom, I would love for my mod to zoom out further in the Command UI but can't find any handle for it in the API.  Have I gotten lost, or is it really not there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on August 01, 2022, 08:50:42 AM
Yeah, that's not going to work - those values are just used to initialize the zoom tracker. Let me add some stuff to CampaignUIAPI:

float getMinZoomFactor();
float getMaxZoomFactor();
void setMinZoomFactor(float min);
void setMaxZoomFactor(float max);

My goal is to be able to allow the player to zoom out to see most of a system for some set period, then change the limit back to their normal one.

Just as a heads up, that seems likely to cause an FPS dive in some star systems, especially if there is a lot of nebula. (Also, stuff isn't designed to look good at that level, but, I mean, that's kind of whatever.)

Epic, thank you!

I might have already handled the performance/visual problem through other means (mod story spoiler stuff), but I'll make sure to check when possible.


Actually - another thing I wanted to change was the `easySensorBonus`, which is "hardcoded" at runtime.
I did successfully change it at runtime, but, uh, in such a way that will probably break next patch (by calling `settings.setFloat("easySensorBonus", bonus)` and then calling a method in `StarfarerSettings` to make it stick, which is bad).

Any chance of getting that one moddable as well? Not a biggie to me if not, having that zoom adjustment will be far more impactful what what I'm doing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gabs on August 05, 2022, 01:11:57 PM
Hello, any tips on how to draw a modded commodity in the same way as the crew and marines? I mean the 'more quantity' = 'draw bowling pin formation' in the cargo holds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 06, 2022, 12:06:35 PM
Re: further zoom stuff etc - I'll keep it in mind!

Also, added SettingsAPI.setEasySensorBonus(float easySensorBonus);

Hello, any tips on how to draw a modded commodity in the same way as the crew and marines? I mean the 'more quantity' = 'draw bowling pin formation' in the cargo holds.

Ah - that's actually totally hardcoded to only work for crew and marines, sorry :)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 06, 2022, 12:45:04 PM
Re: further zoom stuff etc - I'll keep it in mind!

Yay!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Antichrist Hater on August 08, 2022, 08:48:43 PM
Also is there a way to increase ECM cap to %20 just like Nav rating?

Yes but you'd, IIRC, have to edit the script and recompile it/provide your own version etc.


How do I do this? 10% is insignificant. The cap should be higher by default
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 09, 2022, 05:26:58 AM
NickXR and I encountered a problem when trying to make my mod pass messages to his Detailed Combat Results mod during combat: the only available bus was Global.getCombatEngine().getCustomData(), entries in which accumulate and might persist in saves.  Therefore, NickXR had to add to the manager of these entries a method to delete them, and my own mod must include a duplicate of that manager to call this method every frame should Realistic Combat be installed without Detailed Combat Results.  It occurs to me that a similar API method called HashMap<String, Object> Global.getCombatEngine().getFrameCustomData() providing a data bus flushed after every frame would let all modders that want to pass messages between mods every frame avoid this issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lemuria on August 09, 2022, 11:38:08 AM
How can I alter the description of a planet/station?

Anything - file editing or ConsoleCommands will work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 09, 2022, 11:49:53 AM
NickXR and I encountered a problem when trying to make my mod pass messages to his Detailed Combat Results mod during combat: the only available bus was Global.getCombatEngine().getCustomData(), entries in which accumulate and might persist in saves.  Therefore, NickXR had to add to the manager of these entries a method to delete them, and my own mod must include a duplicate of that manager to call this method every frame should Realistic Combat be installed without Detailed Combat Results.  It occurs to me that a similar API method called HashMap<String, Object> Global.getCombatEngine().getFrameCustomData() providing a data bus flushed after every frame would let all modders that want to pass messages between mods every frame avoid this issue.

shouldn't he just add methods that you and other modders can call rather than a whole entry manager?

edit: i think i understand, it's so you don't need to add it as a compile dependency. my only comment on that is you should just not add entries if the mod isn't enabled, unless your mod also has a use for those entries.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 09, 2022, 01:33:59 PM
shouldn't he just add methods that you and other modders can call rather than a whole entry manager?

edit: i think i understand, it's so you don't need to add it as a compile dependency. my only comment on that is you should just not add entries if the mod isn't enabled, unless your mod also has a use for those entries.

I suggested this, but Nick rightly pointed out that it would create a hard dependency on DCR.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 09, 2022, 06:24:37 PM
NickXR and I encountered a problem when trying to make my mod pass messages to his Detailed Combat Results mod during combat: the only available bus was Global.getCombatEngine().getCustomData(), entries in which accumulate and might persist in saves.  Therefore, NickXR had to add to the manager of these entries a method to delete them, and my own mod must include a duplicate of that manager to call this method every frame should Realistic Combat be installed without Detailed Combat Results.  It occurs to me that a similar API method called HashMap<String, Object> Global.getCombatEngine().getFrameCustomData() providing a data bus flushed after every frame would let all modders that want to pass messages between mods every frame avoid this issue.

Stuff in combat engine should not persist in saves unless a mod does something really ill-advised such as saving a reference to Global.getCombatEngine() in a member variable of a script that *does* go into a savefile, or some such. The combat engine, and more specifically the custom data, will get reset every time there's a new battle, or a new simulator run, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 09, 2022, 07:01:54 PM
Stuff in combat engine should not persist in saves unless a mod does something really ill-advised such as saving a reference to Global.getCombatEngine() in a member variable of a script that *does* go into a savefile, or some such. The combat engine, and more specifically the custom data, will get reset every time there's a new battle, or a new simulator run, etc.

That's a relief to know, though I take you to mean Global.getCombatEngine().getCustomData() persists between frames.  A version that resets every frame would be very helpful for message passing.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 09, 2022, 07:10:01 PM
Stuff in combat engine should not persist in saves unless a mod does something really ill-advised such as saving a reference to Global.getCombatEngine() in a member variable of a script that *does* go into a savefile, or some such. The combat engine, and more specifically the custom data, will get reset every time there's a new battle, or a new simulator run, etc.

That's a relief to know, though I take you to mean Global.getCombatEngine().getCustomData() persists between frames.  A version that resets every frame would be very helpful for message passing.  :)

why do you need his listener though? why can't you use Global.getSettings().getModManager() (i forget what the actual method is) to check if the Detailed Combat Results mod is enabled before putting messages into the custom data?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 10, 2022, 06:52:42 AM
why do you need his listener though? why can't you use Global.getSettings().getModManager() (i forget what the actual method is) to check if the Detailed Combat Results mod is enabled before putting messages into the custom data?

Because adding a check for Detailed Combat Results to Realistic Combat would introduce a hard dependency.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lemuria on August 10, 2022, 07:29:54 AM
How can I alter the description of a planet/station?

Anything - file editing or ConsoleCommands will work.

P.S. I have decided to answer my own question.

I wrote a tutorial on altering planet and station descriptions here:
https://github.com/a-random-lemurian/lem-starsector-stuff/blob/main/description_change.md
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 10, 2022, 07:34:34 AM
P.S. I have decided to answer my own question.

I wrote a tutorial on altering planet and station descriptions here:
https://github.com/a-random-lemurian/lem-starsector-stuff/blob/main/description_change.md

Congrats!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 10, 2022, 07:35:53 AM
why do you need his listener though? why can't you use Global.getSettings().getModManager() (i forget what the actual method is) to check if the Detailed Combat Results mod is enabled before putting messages into the custom data?

Because adding a check for Detailed Combat Results to Realistic Combat would introduce a hard dependency.

Many mods check if other mods are enabled. For example, my Roider Union mod checks for Nexerelin. There does not need to be any dependency at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on August 10, 2022, 07:41:51 AM
why do you need his listener though? why can't you use Global.getSettings().getModManager() (i forget what the actual method is) to check if the Detailed Combat Results mod is enabled before putting messages into the custom data?

Because adding a check for Detailed Combat Results to Realistic Combat would introduce a hard dependency.

As SafariJohn said, calling methods in or simply checking for the existence of another mod does not create a dependency on the mod, except for you when compiling.

I made some of this code up to illustrate the idea:
Code
if (Global.getSettings().getModManager().isModEnabled("nexerelin") { // Checks if Nex is enabled, no dependency on Nex, doesn't run the below code if Nex not enabled.
  if (Nexerelin.isCorvusEnabled()) { // If this line of code is run and Nex is not enabled, this will crash. However, because of the above line, this line won't run if it isn't enabled.
    // do something
  }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 10, 2022, 02:18:02 PM
Many mods check if other mods are enabled. For example, my Roider Union mod checks for Nexerelin. There does not need to be any dependency at all.

As SafariJohn said, calling methods in or simply checking for the existence of another mod does not create a dependency on the mod, except for you when compiling.

I made some of this code up to illustrate the idea:
Code
if (Global.getSettings().getModManager().isModEnabled("nexerelin") { // Checks if Nex is enabled, no dependency on Nex, doesn't run the below code if Nex not enabled.
  if (Nexerelin.isCorvusEnabled()) { // If this line of code is run and Nex is not enabled, this will crash. However, because of the above line, this line won't run if it isn't enabled.
    // do something
  }
}

You're right, I should not have called it a dependency.  What I meant was that, should any other mod ever want to know what damage weapons dealt in Realistic Combat, which uses a custom damage listener that bypasses the vanilla damage system, its creator would have to guess that Realistic Combat did so, look deep into the source code to know that it nevertheless reported the relevant information--but only if DCR were installed--and then ask me, and then I would have to add it. 

While I am very lucky that NickXR is smart, helpful, available, and organized enough to write the fancy data bus-flusher that keeps my mod from flooding memory with reports, enabling the cooperation of DCR and RC without the API feature I have requested, other future creators of mods that pass messages frame-by-frame should not expect (or be expected to give) as much help as I got from him in this regard.  Moreover, every such modder would have to re-invent the bus-flushing wheel--something certainly beyond me--whereas adding Global.getCombatEngine().getFrameCustomData() to the API would build-in a self flushing bus.

Hence my proposal: just think of the potential if every mod could pass messages frame-by-frame!  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Klaive on August 10, 2022, 04:34:19 PM
Hello, i have an issue in a heavy modded game.

For some reason when i pursuit the battlemap deploys buoys and if there's a special enemy the game tells me with the alarm; but when i engage in normal combat the battlemap doesn't get anything. Maybe is for some mod? Playing 0.9.5 rc6 with some legal bootlegs

The list:
Spoiler
Code
  "pantera_ANewLevel40",
  "Adjusted Sector",
  "sd_advancedHullMods",
  "A_S-F",
  "AttunedDriveField",
  "blackrock_driveyards",
  "CaptainsLog",
  "chatter",
  "timid_commissioned_hull_mods",
  "lw_console",
  "diyplanets",
  "istl_dassaultmikoyan",
  "hm_flagpack",
  "diableavionics",
  "dynamictariffs",
  "exoticatechnologies",
  "sun_fuel_siphoning",
  "GrandColonies",
  "HMI",
  "nbj_ice",
  "immersionFriendlyPortraitPack",
  "IndEvo",
  "interestingportraitspack",
  "kadur_remnant",
  "lw_lazylib",
  "lockedAndLoaded",
  "MagicLib",
  "Mayasuran Navy",
  "Neutrino",
  "nexerelin",
  "officerExtension",
  "JYDR",
  "planet_search",
  "PulseIndustry",
  "pt_qolpack",
  "QualityCaptains",
  "repdec",
  "roider",
  "tahlan_scalartech",
  "sclskl_scalingskilllimits",
  "SCY",
  "simpleplayerflags",
  "sun_starship_legends",
  "StopGapMeasures3",
  "Sylphon_RnD",
  "tahlan",
  "Terraforming & Station Construction",
  "TORCHSHIPS",
  "URW",
  "vic",
  "vayrasector",
  "vayrashippack",
  "lw_version_checker",
  "weftinships",
  "shaderLib"

[close]
Thanks for your time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 10, 2022, 05:38:43 PM
Also is there a way to increase ECM cap to %20 just like Nav rating?
Yes but you'd, IIRC, have to edit the script and recompile it/provide your own version etc.
How do I do this? 10% is insignificant. The cap should be higher by default
BASE_MAXIMUM in com.fs.starfarer.api.impl.campaign.skills.ElectronicWarfareScript

It's a static and non-final variable, so a mod can modify it from outside like Adjustable Skill Thresholds does for some other skills (maybe AST could have that feature if it doesn't already).

How can I alter the description of a planet/station?

Anything - file editing or ConsoleCommands will work.
Planet and station descriptions are stored in data/strings/descriptions.csv (found in vanilla and most mods)

A mod can change descriptions at runtime (WhatMod does this), haven't checked if adding new ones dynamically is possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 10, 2022, 05:57:50 PM
Moreover, every such modder would have to re-invent the bus-flushing wheel--something certainly beyond me--whereas adding Global.getCombatEngine().getFrameCustomData() to the API would build-in a self flushing bus.

Hence my proposal: just think of the potential if every mod could pass messages frame-by-frame!  :D

the inherent issues of this system are that getFrameCustomData would be based entirely on order of advance methods. say mod A depends on a message from mod B but mod A's advance method runs before mod B's; they would never get the message.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 10, 2022, 06:23:06 PM
the inherent issues of this system are that getFrameCustomData would be based entirely on order of advance methods. say mod A depends on a message from mod B but mod A's advance method runs before mod B's; they would never get the message.

Reading your message has led me to recognize that the broadest understanding of this request entails designing and implementing an asynchronous protocol to pass messages among arbitrarily-many pieces of almost-arbitrary code.  I cannot immediately think of a solution, but I can think of a simpler problem: request the messages passed last frame rather than this one.  A one-frame difference would be unnoticeable to the player but let all advance() methods run, guaranteeing that every mod would see the messages it needs while also prohibiting modders from coding their mods to see or send messages 'too early' and therefore unsafely.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 11, 2022, 08:11:22 AM
How do I make a rule/condition that displays the amount of times it’s been chosen? For example a value that adds 1 to itself every time you complete an interaction and can be shown again in a text box(like how many times you've done it).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2022, 09:11:17 AM
$global.yourCounterVariable++ in the rule somewhere (or not global, whatever) and then you can use that in the text or options to display the value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 11, 2022, 04:23:19 PM
could we get the FleetInteractionDialogPluginImpl to run rules if the option selected isn't recognized?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2022, 04:27:34 PM
You'd have to provide your own version of it, of course, but it ought to be doable, if you take a look at how it handles conversations. And - if it's firing options that are not recognized - then you're already providing a custom version of it, correct?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 11, 2022, 04:33:31 PM
You'd have to provide your own version of it, of course, but it ought to be doable, if you take a look at how it handles conversations. And - if it's firing options that are not recognized - then you're already providing a custom version of it, correct?

i was really wondering if vanilla could provide that, actually. i have my own override of it (which, apparently i'm not using for anything any more), but it defers to Nexerelin's implementation if it is installed. neither overrides the optionSelected method.
my end goal was adding an additional option to the pre- and post-battle dialogs to look at info related to what enemy ships there are, or in the case of post-battle, what enemy ships remain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on August 11, 2022, 06:59:05 PM
Is is possible to have a ship spawn other ships when it is deployed into battle?   I'm looking to make a ship that spawns a few special ships (small frigates that are then basically frigates) and also have carrier wings.   

As an alternate can a ship spawn ships when deployed and also have them treated as its fighters if it has other fighter wings already?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mr_Castinfon on August 12, 2022, 08:21:10 AM
I asked reddit, I made thread on the forum and no one answered my questions please just help me I wanna learn
Here's the copy paste of my questions:


I have an idea for a cool mod that I wanna try making and I wanna see if certain things are even possible to do. So here they are.

Can I remove the original factions?
The mod is set outside the Perseus sector and, logically, the hegemony, luddics, sindria and the other guys aren't gonna exist there, so how can I remove them for my custom factions?

How do I remove the core worlds?
My sector won't be centralized, i.e., there is no core worlds and it's just a big cluster of stars. Is there a way to alter the generation to get that kind of effect? I was told on reddit to look at how Nexerelin handles random core worlds, so if anyone can explain the details?

How do I add my own derelicts
Different sector, different lore. So, how can I add something like the gates or probes In vanilla and have my own ways of how to interact with them.

How do I change something for the base game?
There are a few things in vanilla that I wanna keep, but slightly altered. Like, for example, if I think the Kite shuttle looks *** and I wanna change its look, how can I do that while keeping it's stats.

Please, if anyone can answer anything I'll be so grateful
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 12, 2022, 07:36:46 PM
I asked reddit, I made thread on the forum and no one answered my questions please just help me I wanna learn
Here's the copy paste of my questions:


I have an idea for a cool mod that I wanna try making and I wanna see if certain things are even possible to do. So here they are.

Can I remove the original factions?
The mod is set outside the Perseus sector and, logically, the hegemony, luddics, sindria and the other guys aren't gonna exist there, so how can I remove them for my custom factions?

How do I remove the core worlds?
My sector won't be centralized, i.e., there is no core worlds and it's just a big cluster of stars. Is there a way to alter the generation to get that kind of effect? I was told on reddit to look at how Nexerelin handles random core worlds, so if anyone can explain the details?

How do I add my own derelicts
Different sector, different lore. So, how can I add something like the gates or probes In vanilla and have my own ways of how to interact with them.

How do I change something for the base game?
There are a few things in vanilla that I wanna keep, but slightly altered. Like, for example, if I think the Kite shuttle looks *** and I wanna change its look, how can I do that while keeping it's stats.

Please, if anyone can answer anything I'll be so grateful
Okay, my actual first advice is to start small. Make a mod that changes one of the things you want (say adds a new derelict type or generates a star system), then implement another change in it, and so on.
If you haven't already seen it, the Intro to Modding (https://starsector.fandom.com/wiki/Intro_to_Modding) page on wiki is a helpful resource.

Short answers to the specific questions:
Spoiler
Removing vanilla factions
The most direct way is to have your mod be a total conversion and override the faction list, but this kills compatibility with other mods, so it's not desirable. That said, you can make a faction basically not be there if it has no colonies and is hidden from the intel screen. We'll cover not spawning a faction in the next point.
(I'm not sure how best to make vanilla blueprints not appear in salvage, figure that out later)

Don't spawn vanilla sector
Nexerelin's settings.json contains this table:
Code: json
	"plugins":{
"coreLifecyclePlugin":"exerelin.plugins.NexCoreLifecyclePlugin",
"newGameCreationEntryPoint":"exerelin.world.ExerelinNewGameSetup",

"nex_restoreCommanderPlugin":"exerelin.combat.RestoreCommanderPlugin",
},
The relevant plugin is the newGameCreationEntryPoint one.
The important code of that plugin starts here (https://github.com/Histidine91/Nexerelin/blob/ae86e5a575fcb8185f4de89f0542ccf4c7273ff1/jars/sources/ExerelinCore/exerelin/world/ExerelinNewGameSetup.java#L276), but the key point is you generate your own stars instead of the vanilla ones (how to generate stars is a separate exercise).

Discoverable stuff
Look in the game's API* (you can find the source in starsector-core/starfarer.api.zip) for com.fs.starfarer.api.impl.campaign.procgen.themes.SectorThemeGenerator.

Code: java
	public static List<ThemeGenerator> generators = new ArrayList<ThemeGenerator>();

static {
generators.add(new DerelictThemeGenerator());
generators.add(new RemnantThemeGenerator());
generators.add(new RuinsThemeGenerator());
generators.add(new MiscellaneousThemeGenerator());
}
You can add/remove generators to the list from an external mod script. Look at each of the generators to see how they work.

Changing vanilla stuff
Your mod can modify non-code vanilla files, e.g. you could replace the Kite sprite, or change its stats in the .ship file or ship_data.csv row.

JSON-type definition files (like .ship and .weapon) have merging between vanilla and all running mods, so your mod file only needs to include the values that have changed.
For CSVs, you'll need to replace the whole row.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 12, 2022, 07:40:17 PM
Is is possible to have a ship spawn other ships when it is deployed into battle?   I'm looking to make a ship that spawns a few special ships (small frigates that are then basically frigates) and also have carrier wings.   

As an alternate can a ship spawn ships when deployed and also have them treated as its fighters if it has other fighter wings already?
I think you could put the frigates on the mothership as modules, and make them detach when the ship is deployed.

To manually spawn ships directly, here's an example from SWP's Arcade mission.
Code: java
            FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variant);
            member.getRepairTracker().setCR(0.7f);
            member.getRepairTracker().setMothballed(false);
            member.getRepairTracker().setCrashMothballed(false);
            member.getCrewComposition().setCrew(member.getMinCrew());
            ship = engine.getFleetManager(side).spawnFleetMember(member, tempLoc, -90, 0);
            ship.getLocation().set(tempLoc);
            ship.setOriginalOwner(side.ordinal());
            ship.setOwner(side.ordinal());
            variantId = variant.getHullVariantId();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on August 13, 2022, 05:53:02 AM
Is is possible to have a ship spawn other ships when it is deployed into battle?   I'm looking to make a ship that spawns a few special ships (small frigates that are then basically frigates) and also have carrier wings.   

As an alternate can a ship spawn ships when deployed and also have them treated as its fighters if it has other fighter wings already?

CombatFleetManagerAPI has SpawnShipOrWing  (https://jaghaimo.github.io/starsector-api/interfacecom_1_1fs_1_1starfarer_1_1api_1_1combat_1_1CombatFleetManagerAPI.html#a1de991ed55372227474cdb28e932cff0)(and lazylib has SpawnShipOrWingDirectly in it's combatUtils), you can use either of those to spawn ships whenever you want

here's an example piece of code from something I've used it for in a system
Code

if (!doneOnce) {

            FleetSide cloneSide = FleetSide.ENEMY; //probably a better way of doing this but this works
            if (ship.getOriginalOwner() == 0) {
                cloneSide = FleetSide.PLAYER;
            }

            fleetManager.setSuppressDeploymentMessages(true); //hides the "incoming ship" message
            ShipAPI otherShip = spawnShipOrWingDirectly(
                    varID,
                    FleetMemberType.SHIP,
                    cloneSide,
                    ship.getCurrentCR(),
                    safeLoc,
                    ship.getFacing() + Misc.getAngleInDegrees(safeLoc, loc)
            );
            fleetManager.setSuppressDeploymentMessages(false); //turns it back on
            doneOnce = true; //can only spawn one ship per system activation

            ship.setCustomData(PairKey, otherShip.getId()); //tells the parent ship what it's child ship is, you'll want a different method (probs hashmap?) to keep track of what spawned what if you're doing multiple child ships
        }

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 16, 2022, 07:14:08 AM
is there a vanilla method that checks whether a faction is heavy-industry less that they have to rely on shipimporting or would I make one to iterate thru all markets that have a non-disrupted heavy industry?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 16, 2022, 07:27:17 AM
Hmm. Something like:

ShipQuality.getInstance().getQualityData(market).quality.getFlatBonuses().containsKey("no_prod_penalty")

Might do it, but it requires a market rather than a faction and is a bit dodgy so all in all I'd suggest just iterating over the markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on August 16, 2022, 05:42:55 PM
hey all, random silly question:
is there a way to run code directly after an market calculates all its data? I was using an market condition to run code like this, but it only ran after most of the other code, and was causing issues with not being able to change certain data because it didn't exist yet (mostly things that ran in other market conditions). and that was frustrating to put it simply.
i guess what I'm asking is: can i run code after everything in an market has been calculated? or if that's not possible, is there a way to run my market condition last?
thank you for the help all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 17, 2022, 08:14:17 AM
Hmm - depending on what you need, you might look at EconomyUpdateListener or EconomyTickListener. It wouldn't be exactly what you're asking, but using one of these, you could make sure that your code 1) runs periodically and 2) runs before the player interacts with the colony screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 17, 2022, 08:53:10 AM
something about showing interaction dialog using Global.getSector().getCampaignUI().showInteractionDialog clears the player fleet's (or maybe it's any SectorEntityToken) active person (set using Global.getSector().getPlayerFleet().setActivePerson(PersonAPI)). i got around it with a subclass of the rule based interaction dialog plugin that just sets the active person on init, but i was wondering if this was intended
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 17, 2022, 09:39:20 AM
Yes, it's intended - the active person is not meant to be a persistent value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 17, 2022, 05:06:12 PM
A user report concluded that this type of nullcheck can't be used for any of the Spec getters mainly because...
Code
if (Global.getSettings().getHullSpec("swp_alastor_xiv") != null) {}
even if swp_alastor_xiv didn't or did exist, it would never return null.

Would it be possible for it to return null if it didn't exist? I don't know how else I could be able to do a nullcheck for modded hull and weapons with this current version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 17, 2022, 05:13:36 PM
You could use try-catch if you really needed to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 18, 2022, 11:00:12 PM
is there a way to get access to the skill level descriptions (LevelBasedEffect i think) used by skill tooltips so that i can create them in a custom panel?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2022, 07:30:24 AM
Aside from running the code directly, I don't think so. I mean, the descriptions are in code, and put together with code, so I'm not really sure what you're asking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2022, 10:15:07 AM
Aside from running the code directly, I don't think so. I mean, the descriptions are in code, and put together with code, so I'm not really sure what you're asking.

i'm listing skills from officers. i was asking if there's a way to get a list of the LevelBasedEffect that each SkillSpecAPI level has, which are defined by the effectGroups in the JSON files, instead of needing to write a map into my mod with all vanilla and modded skills. as far as i can tell there's no way to get them without hardcoding it. maybe i could read the skill JSON files myself? not sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 19, 2022, 10:43:38 AM
Ahh, I see - yeah, reading the json files might be your best bet.

Alternatively, you might use TooltipMakerAPI.addSkillPanel() - the skills should have full tooltips there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2022, 11:03:26 AM
Alternatively, you might use TooltipMakerAPI.addSkillPanel() - the skills should have full tooltips there.

i will have to read JSON then, as the addSkillPanel methods i have access to all have name labels which i don't think i can remove. thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 19, 2022, 11:05:59 AM
(https://i.imgur.com/Rs09GrR.png)
for reference, the panel currently. tooltips are just skill names, no description or anything. manually placed the elite icons over the skills that are elite, too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Gabs on August 19, 2022, 03:01:59 PM
Hello, I've been trying to dynamically render cargo sprites based on different settings, right now i've been trying to change the sprites based on the stack size, but the stack.getSize() does not update properly when splitting the item, or moving it around in the cargo screen.
Any ideas on how to properly get this value, even when changing/moving the stack?

[attachment deleted by admin]
Title: Scaling weapons sprites is behaving strange
Post by: KayelGee on August 21, 2022, 02:47:43 PM
Hello, I got a little annoyed that ships look blurry when zoomed in so I wrote a batch script that upscaled all images 2x with ffmpeg nearest neighbor filter.
That works great for ships because they are automatically scaled down to a fixed size ingame.

Weapons don't work out of the box so I tried writing a mod that scales them down.
I've used the following code to scale the weapons down:
Code
public class UpscaleCombatPlugin extends BaseEveryFrameCombatPlugin {
    private CombatEngineAPI engine;
    private List<WeaponAPI> adjustedWeapons;

    @Override
    public void init(CombatEngineAPI engine){
        this.engine = engine;
        for(ShipAPI ship: engine.getShips()){
            System.out.println(ship.getName());
        }
        adjustedWeapons = new ArrayList<WeaponAPI>();
    }

    @Override
    public void advance(float amount, List<InputEventAPI> events) {
        if (engine == null || engine.getCombatUI() == null) return;

        if (engine.getCombatUI().isShowingCommandUI()) return;

        for(ShipAPI ship: engine.getShips()){
            adjustShip(ship);
        }
    }

    private void adjustShip(ShipAPI ship){
        List<WeaponAPI> weapons = ship.getAllWeapons();
        for (WeaponAPI weapon: weapons) {
            if (adjustedWeapons.contains(weapon)) continue;

            adjustSprite(weapon.getSprite(), 2.0f);
            adjustSprite(weapon.getUnderSpriteAPI(), 2.0f);
            adjustSprite(weapon.getBarrelSpriteAPI(), 2.0f);
            adjustSprite(weapon.getGlowSpriteAPI(), 2.0f);
            adjustedWeapons.add(weapon);
        }
    }

    private void adjustSprite(SpriteAPI sprite, float factor) {
        if (sprite == null) return;

        float width = sprite.getWidth() / factor;
        float height = sprite.getHeight() / factor;
        sprite.setSize(width, height);
        sprite.setCenter(sprite.getCenterX()/ factor, sprite.getCenterY() / factor);
    }

}
It works kinda.
The weapon bases work without issue.
The barrels work for hardpoints as far as I can tell.

Turret barrels don't seem to use the CenterY value after the sprite size was changed(no matter to what value I change CenterY for a turret barrel it won't move vertically).
Is there a way to work around that that I'm not aware?

Also animated weapons(chaingun for example) don't work(I could run the resize every frame by saving the sprites to a list or something along those lines).
Is there a way to get all sprites of an animation beforehand?

Also this doesn't work in the refit screen and I can't seem to find a way to do it via the api.
Is there a way to access a ship in the refit screen somehow?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2022, 03:16:52 PM
Any ideas on how to properly get this value, even when changing/moving the stack?

Hmm, I don't think you actually can.

Hello, I got a little annoyed that ships look blurry when zoomed in so I wrote a batch script that upscaled all images 2x with ffmpeg nearest neighbor filter.

(Just so you're aware, that'd be increasing the game's VRAM use, potentially fairly significantly. Though if it it's just vanilla ships, it probably doesn't matter very much.)

Turret barrels don't seem to use the CenterY value after the sprite size was changed(no matter to what value I change CenterY for a turret barrel it won't move vertically).
Is there a way to work around that that I'm not aware?

If it works for the base sprite but doesn't for e.g. barrels, then the answer is probably "no" - I suspect it's probably getting set again after you've changed it. (Checking quickly: yep, looks like it.) Your best bet would be to change the .wpn files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 21, 2022, 03:39:29 PM
What are the ForceCarrier— methods in ShipAPI? Do they control carriers or fighters? Which am I supposed to use them on? Can I pass a null target?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2022, 03:44:25 PM
The setForceCarrierTargetTime() and setForceCarrierTarget() methods force the carrier to target a specific ship with its fighters and allow you to specify a duration for this.

The setForceCarrierPullBackTime() allows you to force the carrier to pull back its fighters for X seconds.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 21, 2022, 04:13:22 PM
It seems like setForceCarrierTarget(null) has no effect even if a targetTime is set. Could it instead cause the "free roam" behavior as when a player carrier has its fighters set to engage with nothing targeted?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 21, 2022, 05:23:17 PM
Oh, sorry, I didn't notice that part of the question. "null" means "do not set a forced target", so it will use its normal targeting behavior.

You might be able to achieve free-roam behavior by calling ship.setPullBackFighters(false) and unsetting the AIFlags.CARRIER_FIGHTER_TARGET flag every frame. That flag's custom data is the actual target.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 21, 2022, 06:12:23 PM
Looks like not. Would be nice to have a way to force free-roam.

Spoiler
Would be better to have fighters lock in their target in vanilla when going from regroup to engage instead of being constantly slaved to the carrier's target. Then I wouldn't have to try modding it in. ;)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 24, 2022, 04:40:00 PM
I wish we had a separate field (and corresponding board column) to put the Starsector version number compatible with each mod rather than typing it into the title of its forum post and that the forum had a dark mode.

Other than that, thanks for all your help so far, Alex!  I couldn't have done all this without you.  You're such a kind game-maker.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on August 24, 2022, 04:56:14 PM
is there a way to easily copy all (or some) of the mutableStats of one ship over to another?

I've got 2 things I wanna use for this - one is to have a shield module copy the stats of it's parent & the other is to have a "rangefinder" beam on an invisible drone for a weapon's visual effect, I *could* currently do it by manually checking everyMutableStat but that would probably melt my brain so I'm hoping for a better way  :P

also, might've asked this before but is there a way to set a carrier as the parent ship of a wing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 25, 2022, 05:15:17 AM
Is $global.gaRH_completed or $global.gaRH_failed getting unset somewhere when Hamatsu mission is completed/failed?

Quote
   public void connectWithGlobalFlag(Object from, Object to, String flag) {
      connections.add(new StageConnection(from, to, new GlobalBooleanChecker(flag)));
      // so it gets auto-unset if it's ever set
      changes.add(new VariableSet(getGlobalMemory(), flag, true));
   }
I guess this is what it does...  ::)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 25, 2022, 10:26:48 AM
I wish we had a separate field (and corresponding board column) to put the Starsector version number compatible with each mod rather than typing it into the title of its forum post and that the forum had a dark mode.

Other than that, thanks for all your help so far, Alex!  I couldn't have done all this without you.  You're such a kind game-maker.

<3

(Yeah, modifying the forum in this type of way is a no-go, sorry!)


is there a way to easily copy all (or some) of the mutableStats of one ship over to another?

I've got 2 things I wanna use for this - one is to have a shield module copy the stats of it's parent & the other is to have a "rangefinder" beam on an invisible drone for a weapon's visual effect, I *could* currently do it by manually checking everyMutableStat but that would probably melt my brain so I'm hoping for a better way  :P

I'm not sure, is there a MutableStat.createCopy() in the currently-out version? Or applyMods(MutableStat other)?

If the methods are there, something like:
Code
public void applyMods(MutableStat other) {
getFlatMods().putAll(other.getFlatMods());
getPercentMods().putAll(other.getPercentMods());
getMultMods().putAll(other.getMultMods());
needsRecompute = true;
}


also, might've asked this before but is there a way to set a carrier as the parent ship of a wing?

I don't think so.


Is $global.gaRH_completed or $global.gaRH_failed getting unset somewhere when Hamatsu mission is completed/failed?

Quote
   public void connectWithGlobalFlag(Object from, Object to, String flag) {
      connections.add(new StageConnection(from, to, new GlobalBooleanChecker(flag)));
      // so it gets auto-unset if it's ever set
      changes.add(new VariableSet(getGlobalMemory(), flag, true));
   }
I guess this is what it does...  ::)

Yeah, these types of flags don't stick around after a mission is over. A mission has to explicitly add code to set them, for example GAFindingCoureuse does this:

Code
beginStageTrigger(Stage.COMPLETED);
triggerSetGlobalMemoryValue("$gaFC_missionCompleted", true);
endTrigger();

A variable could also be set in a relevant rule. I don't think anything is set for gaRH, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on August 25, 2022, 11:59:20 AM
I'm not sure, is there a MutableStat.createCopy() in the currently-out version? Or applyMods(MutableStat other)?

yes there are, thanks for pointing them out!

though now I've run into a second problem - is there a way to prevent a weapon from reaching 100% charge level & if not, can we get one? (say, something like WeaponAPI.setChargeLevel() to go with getChargeLevel()?)
There seem to be a few ways to technically do it (through setAmmo & setRemainingCooldownTo), but they're kinda janky & won't really work for the thing that I want to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on August 25, 2022, 12:30:12 PM
Yeah, these types of flags don't stick around after a mission is over. A mission has to explicitly add code to set them, for example GAFindingCoureuse does this:

Code
beginStageTrigger(Stage.COMPLETED);
triggerSetGlobalMemoryValue("$gaFC_missionCompleted", true);
endTrigger();

A variable could also be set in a relevant rule. I don't think anything is set for gaRH, though.
Hmmm, guess I'll have to override that rule id, thought returning/keeping the Hamatsu was somewhat significant to be remembered since there's a lingering $global.foundHamatsu permanently forever unexpired.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on August 26, 2022, 01:12:43 AM
and that the forum had a dark mode.
It does. It's under one of the preference settings in... Profile, I think?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 26, 2022, 03:35:34 AM
and that the forum had a dark mode.
It does. It's under one of the preference settings in... Profile, I think?

Ahhhhh... thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inari on August 28, 2022, 01:10:36 AM
I ran into this weird bug where the dust rings and asteroid rings/belts in the Tia/Ta'xet system have gone missing. I have no idea what caused it and only noticed it today when I returned back to the system.

Looking at the save file, it is still there and has not been omitted:

Spoiler
<plugin cl="AsteroidBeltTerrainPlugin" z="1404" tid="asteroid_belt" n="Lagua's Torus" nTCA="false">
<entity cl="CampaignTerrain" ref="1396"></entity>
<params cl="AsteroidBeltParams" defined-in="BaseRingTerrain" z="1405" bWIE="170.0" mR="3600.0" n="Lagua's Torus" nA="150" minO="200.0" maxO="250.0" minS="4.0" maxS="16.0"></params>
<params ref="1405"></params>
[close]

Is there a way I can restore it by using the console commands mod or a particular line of code?

I tried some of the codes floating around on the forums but they created asteroid rings/belts on the planets themselves instead. Such an example of a code is shown here:

Spoiler
RunCode Global.getSector().getStarSystem("Tia").addAsteroidBelt((PlanetAPI)Global.getSector().getStarSystem("Tia").getPlanets().get(2), 50, 700f, 240f, 400f, 600f, Terrain.ASTEROID_BELT, "Izanagi's Halo");
Global.getSector().getStarSystem("Tia").addRingBand((PlanetAPI)Global.getSector().getStarSystem("Tia").getPlanets().get(2), "misc", "rings_asteroids0", 256, 3, Color.RED, 240f, 700f, 500f)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on August 28, 2022, 06:29:44 AM
Is it possible to change or lower peak performance time remaining during combat? like increasing it or decreasing it for reasons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Shashakul on August 28, 2022, 06:55:36 AM
How do I install only a part from a mod? For example I really like Amazigh's Ship Foundry mod weapons and fighter wings, but I don't want the ships. Is it possible to get just the weapons? How?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 28, 2022, 07:01:23 AM
Hmmm, guess I'll have to override that rule id, thought returning/keeping the Hamatsu was somewhat significant to be remembered since there's a lingering $global.foundHamatsu permanently forever unexpired.

Yeah, that sounds like your best bet for the moment.

I ran into this weird bug where the dust rings and asteroid rings/belts in the Tia/Ta'xet system have gone missing. I have no idea what caused it and only noticed it today when I returned back to the system.

...

(Sorry, no clue! It *is* weird that they're in the savefile but not showing up, though, but it's just hard to say without really digging into the specifics of what's going on in your save.)

Is it possible to change or lower peak performance time remaining during combat? like increasing it or decreasing it for reasons?

I think you'd want to use ShipAPI.setTimeDeployed() for this.

How do I install only a part from a mod? For example I really like Amazigh's Ship Foundry mod weapons and fighter wings, but I don't want the ships. Is it possible to get just the weapons? How?

In theory, it should be possible depending on the details of how the weapons are implemented (in a "normal" case, it should be, if the weapons are doing something very fancy, it *might* not be) but basically it would involve making your own version of the mod, cutting out the stuff you don't want. At a basic level, it'd mean going through the files in the mod, understanding what's ship-related and what's needed for the weapons, and removing the former. In particular, you'd want to remove default_ship_roles.json (which specifies how/where the ships are to be used), and anything similar, not just the ships themselves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on August 28, 2022, 07:43:48 AM
Is there a way to give a ship a hullmod that changes the damage types of the weapons on it? Also if there is a way to change the hullmod dynamically without making it a modular

(eg. a hullmod on a ship that changes weapon types on it from energy to HE; and can be switched to kinetic or frag, or back to energy)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 28, 2022, 06:22:27 PM
I've read of a multiplayer mod that could has all networking, interpolation, etc. written and working and could launch already if only all random numbers vanilla generates during combat were from the same seed: replacing every in-combat vanilla call to a method of java.util.Random with a call to a corresponding static method of one, global, static random number generator instance with an exposed method public static void seed(int seed) would guarantee they were.  If you implemented this request, all modders would likely follow suit, and we could all play Starsector with and against each other!  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 28, 2022, 07:04:51 PM
If you implemented this request, all modders would likely follow suit,

Doubt. Best you could hope for is some modders making an effort and labeling their mods as compatible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 28, 2022, 07:17:13 PM
Doubt. Best you could hope for is some modders making an effort and labeling their mods as compatible.

I hope most mods don't use RNG in combat to begin with, and that if they do, the calls are few and far-between enough to be easily replaced by the modder and, if not, found and noted by users and the community.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on August 28, 2022, 09:24:04 PM
Ty for answering my question as for another one

anyway to manipulate ordance point cost dynamically through code?

Example: if I install this hullmod/weapon that cost 10 op add an additional 5 op due to reasons?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on August 29, 2022, 05:49:35 PM
I have a few more questions caused by my latest bout of insanity.
first: is there an market condition that is always present on a market?
second: in the advance(float amount) function of an class that extends BaseMarketConditionPlugin, what is amount? and how many would form an week, month or year? or is there an better way of getting that from an market condition?
third: is it possible to edit/change an industries text or image with out making your own class for it, or is something like that not possible?
thank you for your help all. I truly appreciate it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 29, 2022, 11:24:42 PM
is there a limit to amount of abilities that a player can have? my mod attempts to add abilities but certain players don't see it in their ability menu.

i use onGameLoad to add ability if player doesn't have it.
Code
        if (!Global.getSector().getPlayerFleet().hasAbility("viewprisoners")) {
            Global.getSector().getPlayerFleet().addAbility("viewprisoners");
        }

a player used runcode $print(Global.getSector().getPlayerFleet().hasAbility("viewprisoners"))  which printed false
a player has tried to use runcode  Global.getSector().getPlayerFleet().addAbility("viewprisoners"); but it still did not appear, and the command above returned false as well afterwards
the same person has tried to print the spec (  runcode $print(Global.getSettings().getAbilitySpec("viewprisoners"))  ) which printed out a non-null answer (com.fs.starfarer.loading.specs.super@2381ebfc)

so the spec exists, the onGameLoad should add it, we tried to add it on demand, but no matter what some players still don't get it.
the only notable thing is the player has 21 abilities available to select, which is obviously a lot more than vanilla. the same player removed all of their mods except mine, and the ability added fine without any other mods that add abilities.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on August 30, 2022, 03:40:25 AM
2 questions, one potential bug report!

1 - when does an onExplosion effect get run (i.e, if a mine reaches the end of it's lifetime, if a mine hits an enemy, if removeEntity() is called on it)? I've got some mines doing fancy things & I'm not sure if their onExplosion effects will all get properly run.

2 - are advanceableListeners supposed to not get advanced while attached to the engine? I'm using one to manage some of the fancy mine effects (mostly because I've got an irrational dislike of interacting with customdata :p) & whenever I attach the listener to the engine it gets added but advance() is never called. In the meantime I've attached the listeners to the ships the weaps are on & it's working fine, but this still seems unintended.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on August 30, 2022, 10:57:26 AM
How do you get the markets of any space station colonies that may be in a StarSystemAPI? I'm trying to write a function that checks which factions have heavy industry and space stations do not appear under StarSystemAPI.getPlanets().

edit: solved, you can do something like this
Code
         for(FactionAPI faction : Global.getSector().getAllFactions()) {
            String factionId = faction.getId();
            for(MarketAPI market : Misc.getFactionMarkets(factionId)) {
                boolean hasHeavyIndustry = false;
                try {
                    hasHeavyIndustry = market.hasIndustry("heavyindustry") || market.hasIndustry("orbitalworks");
                } catch(Exception e) {
                    hasHeavyIndustry = false;
                }

                if(hasHeavyIndustry) {
                    HAS_HEAVY_INDUSTRY.add(factionId);
                }
            }
        }
with HAS_HEAVY_INDUSTRY being a hash set
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on August 30, 2022, 12:13:24 PM
How do you get the markets of any space station colonies that may be in a StarSystemAPI? I'm trying to write a function that checks which factions have heavy industry and space stations do not appear under StarSystemAPI.getPlanets().

there is Misc.getMarketsInLocation(LocationAPI location) or Global.getSector().getEconomy().getMarkets(location)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 30, 2022, 12:43:42 PM
I could really use WeaponAPI.getCustomData() because I want to render a projectile indicator over every so many shots from a weapon, but I cannot attach a shot-count to it directly but must instead create (and check at every step) a global hashmap of weapons and their shot counts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 30, 2022, 01:55:32 PM
Is there a way to give a ship a hullmod that changes the damage types of the weapons on it? Also if there is a way to change the hullmod dynamically without making it a modular

(eg. a hullmod on a ship that changes weapon types on it from energy to HE; and can be switched to kinetic or frag, or back to energy)

You could add a DamageDealtModifier to the ship and damage.setType() as appropriate whenever it deals damage.


Ty for answering my question as for another one

anyway to manipulate ordance point cost dynamically through code?

Example: if I install this hullmod/weapon that cost 10 op add an additional 5 op due to reasons?

Hmm, I mean, you could add a WeaponOPCostModifier to a ship's stats. But this runs into problems with order of operations - insall a mod/weapon, get bonus, install cheaper weapon, uninstall mod, end with ship potentially over the OP limit, type of thing.


first: is there an market condition that is always present on a market?

No.

second: in the advance(float amount) function of an class that extends BaseMarketConditionPlugin, what is amount? and how many would form an week, month or year? or is there an better way of getting that from an market condition?

"amount" is the number of real-time seconds. You can use Global.getSector().getClock().convertToDays(amount) to get the number of in-world days this corresponds to. By default, 10 real-world seconds is equal to 1 in-game day.

third: is it possible to edit/change an industries text or image with out making your own class for it, or is something like that not possible?

The basic icon is specificed in industries.csv, and so is iirc at least some of the text.


is there a limit to amount of abilities that a player can have? my mod attempts to add abilities but certain players don't see it in their ability menu.

i use onGameLoad to add ability if player doesn't have it.
Code
        if (!Global.getSector().getPlayerFleet().hasAbility("viewprisoners")) {
            Global.getSector().getPlayerFleet().addAbility("viewprisoners");
        }

a player used runcode $print(Global.getSector().getPlayerFleet().hasAbility("viewprisoners"))  which printed false
a player has tried to use runcode  Global.getSector().getPlayerFleet().addAbility("viewprisoners"); but it still did not appear, and the command above returned false as well afterwards
the same person has tried to print the spec (  runcode $print(Global.getSettings().getAbilitySpec("viewprisoners"))  ) which printed out a non-null answer (com.fs.starfarer.loading.specs.super@2381ebfc)

so the spec exists, the onGameLoad should add it, we tried to add it on demand, but no matter what some players still don't get it.
the only notable thing is the player has 21 abilities available to select, which is obviously a lot more than vanilla. the same player removed all of their mods except mine, and the ability added fine without any other mods that add abilities.

Hmm, that's strange. I'm not aware of any limit, and looking at the code, it's hard to see how the sequence of events you're describing could happen - namely, hasAbility() returning false after addAbility() was called. The CampaignFleetAPI.addAbility() method is pretty simple:

Code
public void addAbility(String id) {
if (abilities != null && abilities.containsKey(id)) return;
if (abilities == null) abilities = new LinkedHashMap<String, AbilityPlugin>();

AbilitySpec spec = SpecStore.getSpec(AbilitySpec.class, id);
AbilityPlugin ability = spec.getNewPluginInstance(this);
abilities.put(id, ability);
if (ability instanceof EveryFrameScript) {
addScript((EveryFrameScript) ability);
}
}

I'm not seeing how it could behave the way you're descibing. Which, not to say that I'm not missing something, but it's not clear what that might be.


1 - when does an onExplosion effect get run (i.e, if a mine reaches the end of it's lifetime, if a mine hits an enemy, if removeEntity() is called on it)? I've got some mines doing fancy things & I'm not sure if their onExplosion effects will all get properly run.

This is, perhaps, going to be extremely unhelpful, but the onExplosion() method gets called - or should get called, at any rate - if and only if the mine explodes. Which would include hitting the enemy, I believe, but not removeEntity(). The easiest way to test this sort of thing would be with some debug print statements.

However, I would try to avoid relying on state management through that method, it's probably safer to, say, detect that a mine is no longer around and then do something... depends on your specific case, of course.

2 - are advanceableListeners supposed to not get advanced while attached to the engine? I'm using one to manage some of the fancy mine effects (mostly because I've got an irrational dislike of interacting with customdata :p) & whenever I attach the listener to the engine it gets added but advance() is never called. In the meantime I've attached the listeners to the ships the weaps are on & it's working fine, but this still seems unintended.

Ah, yeah, they're only going to advance() when attached to a ship, not the engine. Not a bug, exactly - I can see why you'd expect that to work but currently only the ship case is supported. I'd have to think about exactly where to splice that in, not something I can just do super quick.


How do you get the markets of any space station colonies that may be in a StarSystemAPI? I'm trying to write a function that checks which factions have heavy industry and space stations do not appear under StarSystemAPI.getPlanets().

edit: solved, you can do something like this
Code
         for(FactionAPI faction : Global.getSector().getAllFactions()) {
            String factionId = faction.getId();
            for(MarketAPI market : Misc.getFactionMarkets(factionId)) {
                boolean hasHeavyIndustry = false;
                try {
                    hasHeavyIndustry = market.hasIndustry("heavyindustry") || market.hasIndustry("orbitalworks");
                } catch(Exception e) {
                    hasHeavyIndustry = false;
                }

                if(hasHeavyIndustry) {
                    HAS_HEAVY_INDUSTRY.add(factionId);
                }
            }
        }
with HAS_HEAVY_INDUSTRY being a hash set

Hmm. You're not actually checking for it being in the some specific star system? Also, I really really hope that HAS_HEAVY_INDUSTRY is not a static variable, otherwise you're probably looking at a major memory leak.


I could really use WeaponAPI.getCustomData() because I want to render a projectile indicator over every so many shots from a weapon, but I cannot attach a shot-count to it directly but must instead create (and check at every step) a global hashmap of weapons and their shot counts.

I'm not sure this is the right thread for requests, but the way you're doing it seems fine. Well, as long as it's not actually global and is stored in the engine's getCustomData()...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on August 30, 2022, 03:20:31 PM
This is, perhaps, going to be extremely unhelpful, but the onExplosion() method gets called - or should get called, at any rate - if and only if the mine explodes. Which would include hitting the enemy, I believe, but not removeEntity(). The easiest way to test this sort of thing would be with some debug print statements.

However, I would try to avoid relying on state management through that method, it's probably safer to, say, detect that a mine is no longer around and then do something... depends on your specific case, of course.

oh yeah that makes sense, I was mainly wondering what "exploded" counted as, ty!

Ah, yeah, they're only going to advance() when attached to a ship, not the engine. Not a bug, exactly - I can see why you'd expect that to work but currently only the ship case is supported. I'd have to think about exactly where to splice that in, not something I can just do super quick.

yeah, makes sense as well! no real need to actually change the behaviour here imo, a "this type of listener only runs when attached to a ship" comment in the api would probably suffice



Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 30, 2022, 06:00:50 PM
I'm not sure this is the right thread for requests,

 :-[ Sorry!

Quote
but the way you're doing it seems fine. Well, as long as it's not actually global and is stored in the engine's getCustomData()...

I stored it as

Code
class ProjectileIndication extends EveryFrameCombatPlugin
    ...
    private static final HashMap<WeaponAPI, HashMap<DamagingProjectileAPI, Integer>> weaponToProjectileToShotNumberHashMap = new HashMap<>();
    private static final HashMap<WeaponAPI, Integer> weaponToShotCountHashMap = new HashMap<>();
    ...

and the code worked as intended but soon crashed to desktop because of a cryptic error that I have read may have related to garbage collection.  I removed the static, and the code has not crashed since.  Should I put these HashMaps in Global.getCombatEngine().getCustomData()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on August 31, 2022, 01:51:34 PM
Is it possible to make an accretion disk without a star? I've tried but it seems that making an accretion disk requires a star/blackhole.

Code
39548 [Thread-3] INFO  org.lazywizard.console.Console  - > goto systemd
39551 [Thread-3] INFO  org.lazywizard.console.Console  - Jumped to systemD Star System.
40212 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.RingBand.render(Unknown Source)
at com.fs.starfarer.campaign.BaseCampaignEntity.render(Unknown Source)
at com.fs.graphics.LayeredRenderer.render(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.render(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.render(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.render(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheProtagonists on September 01, 2022, 12:29:22 AM
Is the 1 million order limit of the illegal arms dealer event hard coded in game? If not is there any way to increase it?
Similarly, is there any way to increase the limit of nanoforge production sellers? (which seems to max out at around 100k or so)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inari on September 01, 2022, 07:07:02 AM

(Sorry, no clue! It *is* weird that they're in the savefile but not showing up, though, but it's just hard to say without really digging into the specifics of what's going on in your save.)

I could share the save file if you would like to take a look but it's quite heavily tweaked and modded, so I'm unsure if it'll complicate things on your end :P
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 01, 2022, 08:51:24 AM
and the code worked as intended but soon crashed to desktop because of a cryptic error that I have read may have related to garbage collection.  I removed the static, and the code has not crashed since.  Should I put these HashMaps in Global.getCombatEngine().getCustomData()?

Keeping it in member variables is ok in this case, but would not be ok if for example they were in a hullmod, since those only have a single instance per application.

Just in general I'd avoid using static data members to hold any kind of dynamic data. It's a recipe for exactly the kind of crash that you've experienced.

Is it possible to make an accretion disk without a star? I've tried but it seems that making an accretion disk requires a star/blackhole.

Yes, it should be fine. You might need to LocationAPI.createToken() to have the disk center on - it still needs to be around *something*.


I could share the save file if you would like to take a look but it's quite heavily tweaked and modded, so I'm unsure if it'll complicate things on your end :P

Ah, yeah - I appreciate the offer, but a modded savefile is quite a bit to dig into :)

Is the 1 million order limit of the illegal arms dealer event hard coded in game? If not is there any way to increase it?
Similarly, is there any way to increase the limit of nanoforge production sellers? (which seems to max out at around 100k or so)

It's controlled by the various static variables in CustomProductionContract. You could have your mod modify them, say in ModPlugin.onApplicationLoad(), like so:

CustomProductionContract.DEALER_MIN_CAPACITY = <whatever>;

And so on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on September 01, 2022, 09:45:11 AM
How do you get the market listed in the "Returning from" field you can see in the interaction dialogues of trade fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 02, 2022, 06:35:20 AM
Hey,

I got a custom orbital station that I wish to change the text of on the campaign map.
However, it seems that using a station fleet/entity system for a combat-capable orbital causes the customDescriptionId to be overridden with ...something? I didn't find out what was happening.

The question is thus:

How do I change this text.
(https://i.imgur.com/vkdVjxq.png)

The code I am using is a copy of the OrbitalStation Industry station spawning code (OrbitalStation.spawnStation())
Specifying a custom map tooltip in the custom entity plugin does not work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 02, 2022, 07:20:00 AM
Is there any way to track if a specific fleet, or in my case, fleets in a radius around a planet/market, have entered combat? Say, a listener? Ideally, also checking for if the player entered combat. I'm trying to make a system that automatically injects a bunch of ships into fights that happen around planets with a specific condition.

See https://fractalsoftworks.com/forum/index.php?topic=25244.0 for more if you're curious.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2022, 07:58:02 AM
How do you get the market listed in the "Returning from" field you can see in the interaction dialogues of trade fleets?

See EconomyFleetAssignmentAI.getTravelActionText() and where that AI is set etc. You could also more simply set it using CampaignFleetAIAPI.setActionTextOverride(). Or you could set the action text when adding an assignment to the fleet.


Hey,

I got a custom orbital station that I wish to change the text of on the campaign map.
However, it seems that using a station fleet/entity system for a combat-capable orbital causes the customDescriptionId to be overridden with ...something? I didn't find out what was happening.

The question is thus:

How do I change this text.
(https://i.imgur.com/vkdVjxq.png)

The code I am using is a copy of the OrbitalStation Industry station spawning code (OrbitalStation.spawnStation())
Specifying a custom map tooltip in the custom entity plugin does not work.

This shows a market tooltip, so it normally shows the planet type, but when hovering over the attached station, it just shows "orbital station" which is hardcoded. Sorry!


Is there any way to track if a specific fleet, or in my case, fleets in a radius around a planet/market, have entered combat? Say, a listener? Ideally, also checking for if the player entered combat. I'm trying to make a system that automatically injects a bunch of ships into fights that happen around planets with a specific condition.

I don't believe there's a "combat started" listener. Your best bet might be a script that checks whether a fleet's getBattle() starts returning non-null. If the script only runs when the location is "current" (i.e. the player is there) that seems like it shouldn't be a problem performance-wise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 02, 2022, 10:00:27 AM

Is there any way to track if a specific fleet, or in my case, fleets in a radius around a planet/market, have entered combat? Say, a listener? Ideally, also checking for if the player entered combat. I'm trying to make a system that automatically injects a bunch of ships into fights that happen around planets with a specific condition.

I don't believe there's a "combat started" listener. Your best bet might be a script that checks whether a fleet's getBattle() starts returning non-null. If the script only runs when the location is "current" (i.e. the player is there) that seems like it shouldn't be a problem performance-wise.

This works for AI fleets, however, this doesn't work for player battles, to my understanding, due to the transition to combat layer. If I do this, I'll probably have to add some sort of new rule or some such that will maybe load a custom battlefield generation? I don't know, really.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 02, 2022, 11:33:32 AM
Keeping it in member variables is ok in this case, but would not be ok if for example they were in a hullmod, since those only have a single instance per application.

Just in general I'd avoid using static data members to hold any kind of dynamic data. It's a recipe for exactly the kind of crash that you've experienced.

Thank you!  I will keep that in mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 02, 2022, 07:13:23 PM
what does getFixedLocation/setFixedLocation do in ShipAPI ?
there's no info in javadoc, and literally one mention of it on the forum, used in entirely different context with no explanation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 03, 2022, 01:57:32 PM
Does anyone have any insight for how the hell TacticalModule hasEnoughStuffAround works? I have an issue where fleets arent joining combat with fleets that are spawned and placed directly on top of the player during dialog, despite me having the fleet dialog plugin set to allow it. I managed to breakpoint it enough to determine that hasEnoughStuffAround must be returning a bad value somewhere, so I really want to know how it works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 03, 2022, 04:21:11 PM
Also, how do you force a fleet to join a given battle? Is it just battle.join(fleet)
Because if it is, im doing something very wrong.
Because my fleets just randomly get their battle set to null and for some reason are also invisible despite having their containing location to the star system as well as location coordinates being valid.

EDIT: Found the issue, I wasn't adding the fleet to the containing location.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 03, 2022, 06:13:21 PM
I want to edit the code of vanilla skills and hullmods but worry about vanilla or mod code modifying skill or hullmod class constants, all of which are public and almost none of which is final.  Would making skill and hullmod class constants private static final be safe, and if so, why are they not already?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Droll on September 04, 2022, 09:01:59 AM
How to you make weapons access their sounds? I notice that in mods like UAF, they reference a file in their .wpn file but I cannot find a file under the same name in sounds. In vanilla I notice that the vulcan cannon is also similar and in fact has multiple sound files?

Referencing directly by file name gives me muted weapons so I'm assuming I'm doing something wrong.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 04, 2022, 09:18:46 AM
You are looking for data/config/sounds.json
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Droll on September 04, 2022, 01:14:03 PM
You are looking for data/config/sounds.json

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 04, 2022, 01:38:55 PM
This works for AI fleets, however, this doesn't work for player battles, to my understanding, due to the transition to combat layer. If I do this, I'll probably have to add some sort of new rule or some such that will maybe load a custom battlefield generation? I don't know, really.

Yes, hmm - that sounds reasonable. Maybe even an always-there combat script, depending on what's easier.



what does getFixedLocation/setFixedLocation do in ShipAPI ?
there's no info in javadoc, and literally one mention of it on the forum, used in entirely different context with no explanation.

It turns off a bunch of movement-related AI and makes the ship do its best to stay at those coordinates. Only useful for stations; iirc the ship won't even try to face any enemies while doing that.


I want to edit the code of vanilla skills and hullmods but worry about vanilla or mod code modifying skill or hullmod class constants, all of which are public and almost none of which is final.  Would making skill and hullmod class constants private static final be safe, and if so, why are they not already?

They're not private or final literally so that mods can change them. If another mod changes them and yours does too, that's just a mod incompatibility.

On the other hand, if you're "editing the code" of vanilla skills, that functionally means providing a different implementation, which could use whatever constants you like, so I'm not sure what the issue is in that case?

... I think maybe I get it, you're asking about making the ones in your skill implementations private and final? I don't really understand the concern, though - another mod is not going to change those by accident since they would have to compile against your mod and specifically change those constants. Vanilla isn't going to do it either, for the same reasons - it doesn't know about your stuff. So, scratch that, I still don't get it :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on September 04, 2022, 02:35:02 PM
How do you get the market listed in the "Returning from" field you can see in the interaction dialogues of trade fleets?

See EconomyFleetAssignmentAI.getTravelActionText() and where that AI is set etc. You could also more simply set it using CampaignFleetAIAPI.setActionTextOverride(). Or you could set the action text when adding an assignment to the fleet.
I need to know information on the fleet's route in the reportFleetSpawned method of a transient BaseCampaignEventListener. After doing some testing, trade fleets don't seem to have the EconomyFleetAssignmentAI script added to them until some time after listeners are run. Is there any way around this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 05, 2022, 07:17:01 AM
They're not private or final literally so that mods can change them. If another mod changes them and yours does too, that's just a mod incompatibility.

Oohhh, I see.  I saw them and thought, "Huh, I thought Java was all about encapsulation, getters, setters, Big Decimal, exception types, Big Decimal, Netbeans, Big Decimal, serious business, Big Decimal...",

https://www.youtube.com/watch?v=kdMG40wUCm4

but now I see you do it deliberately.  ;)

Quote
On the other hand, if you're "editing the code" of vanilla skills, that functionally means providing a different implementation, which could use whatever constants you like, so I'm not sure what the issue is in that case?

... I think maybe I get it, you're asking about making the ones in your skill implementations private and final? I don't really understand the concern, though - another mod is not going to change those by accident since they would have to compile against your mod and specifically change those constants. Vanilla isn't going to do it either, for the same reasons - it doesn't know about your stuff. So, scratch that, I still don't get it :)

Thanks for answering--I hope I can explain better this time!

First, the background is that my mod makes some or all the features of 13 vanilla skills (and 5 vanilla hullmods) irrelevant by circumventing the damage model, drastically changing the range and projectile speed of weapon and projectile specs, and dynamically adjusting weapon ranges, so I have to write my own implementations of these skills and hullmods.  I want to avoid incompatibility (especially hard incompatibility) between my mod and other mods, so I wanted to know what the implications of changing access modifier, finality, and even adding or removing the now-irrelevant class attributes would be for compatibility.

I worry about modifiers I type as many of the modifiers private, static, final as I can before the variables and methods in my code and adjust them with getters and setters because some Java guides on the Internet said so, but I am ultimately a cargo-cult coder who knows nothing of the surprisingly-enterprisey undertaking of writing stable, compatible, configurable, extensible mods while following the best practices of object-oriented programming in Java.  (I mean, have you seen the documentation some authors write?  Some have their own websites to host their Javadocs!  :o)

Anyway, I'm just trying to minimize the chaos and frustration that RC induces and would like your advice because I don't know what I'm doing.  Halp.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 05, 2022, 08:29:47 AM
Basically, if you provide your own versions of skills, and another mod adjusts some constants in the vanilla skill code (which would still be present, but unused), then what that mod does will not matter, because the vanilla skill code would not be used at that point.

I don't think any of the stuff you're worrying about - at least, based on your post - is actually a concern, there's nothing that's going to break or be bad. On the other hand, if you go overboard trying to make your code "good" (definitely in quotes) you can end up with something that's just a huge pain to work with. The "final" keyword is a good example; the only time it shows up in the Starsector code is because some code generation tool stuck it in there and I didn't manually remove it. 99.9% of the time, it's just something that just makes someone's life more difficult at some point in the future when they want to change the value and can't.

"private" is kind of similar - there are reasonable arguments to be made for it, sometimes, probably. But I think "protected" is almost always just better. (Private means that if someone wants to extend your class, they won't have access to those methods/variables, and it's just limiting for no great reason.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 05, 2022, 10:07:07 AM
Basically, if you provide your own versions of skills, and another mod adjusts some constants in the vanilla skill code (which would still be present, but unused), then what that mod does will not matter, because the vanilla skill code would not be used at that point.

Ooooh, OK, well that's a relief.  I'm glad that the vanilla code would still be there to 'catch' the modifications.

Quote
I don't think any of the stuff you're worrying about - at least, based on your post - is actually a concern, there's nothing that's going to break or be bad.

Once again, what a relief!

Quote
On the other hand, if you go overboard trying to make your code "good" (definitely in quotes) you can end up with something that's just a huge pain to work with. The "final" keyword is a good example; the only time it shows up in the Starsector code is because some code generation tool stuck it in there and I didn't manually remove it. 99.9% of the time, it's just something that just makes someone's life more difficult at some point in the future when they want to change the value and can't.

I have put the final keyword before just about every function argument, variable, and class member--even having gone over my codebase and code donated by other mods a few times to ensure none was left out--and reformatted everything accordingly.   :-[  Should I go back and change it?

That said, I have noticed that final keys and values are required for one-step pre-filled HashMap creation:

Code
final T k1 = new T(), k2 = new T();
final V v1 = new V(), v2 = new V();
HashMap<T,V> hashMap = new HashMap<T,V>(){{ put(k1, v1); put(k2,v2);}};

versus

Code
T k1 = new T(), k2 = new T();
V v1 = new V(), v2 = new V();
HashMap<T,V> hashMap = new HashMap<>();
hashMap.put(k1, v1);
hashMap.put(k2,v2);

Quote
"private" is kind of similar - there are reasonable arguments to be made for it, sometimes, probably. But I think "protected" is almost always just better. (Private means that if someone wants to extend your class, they won't have access to those methods/variables, and it's just limiting for no great reason.)

Uh-oh, I did for private what I did for final, and I have a bad feeling now that I should not have.  :-[  I've also noticed that the code written by 'good' modders and you, Alex, lacks the private attribute and at most uses protected.  Should I change all this back, too?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 05, 2022, 10:19:01 AM
I wouldn't obsess about it too much; if it works it works and the use case of another mod modding your mod is probably not a super relevant one. But yeah you definitely don't want final everywhere, all it does is make life slightly more difficult and clutter up the code. Same for private, but it's also very whatever. It matters more for vanilla code because mods really need it to be more flexible/workable-with.

So in your case I'd say it's a question of whether the amount of annoyance it causes you justifies the work of re-formatting it all yet again. Functionally, it doesn't matter.

That said, I have noticed that final keys and values are required for one-step pre-filled HashMap creation:

Code
final T k1 = new T(), k2 = new T();
final V v1 = new V(), v2 = new V();
HashMap<T,V> hashMap = new HashMap<T,V>(){{ put(k1, v1); put(k2,v2);}};

Yes, that's required because the part of the code that has the put() calls in it is actually code in a different, anonymous class that gets defined as a result of this special syntax. If that doesn't make sense, I wouldn't worry about it too much. Basically the compiler needs to know k1/k2 won't change so it can... do stuff.

For that specific code I'd personally just write:
hashMap.put(k1, v1);
hashMap.put(k2, v2);

That doesn't need finals and just looks a little cleaner to me - especially if you end up needing to add more things to the map - but, again, that doesn't really matter. Most things like this don't actually matter, except for when they do :) The bigger point is not to spend too much time worrying about code that works but could be "better", as long as there aren't any functional problems.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 05, 2022, 11:23:18 AM
I wouldn't obsess about it too much; if it works it works and the use case of another mod modding your mod is probably not a super relevant one.

What a relief!  Thanks again for replying so far.  Perhaps some background would help you understand my reasons for using private static final: I want to allow myself to change, re-arrange, or even delete my code without having to remember, foresee, and consider potentially-ensuing side effects, and I want to call some parts of my code as many as a hundred times a frame.  Therefore, I use a 'makeshift-API' approach: splitting my mod into packages of classes, each of which does one thing, which it is called to do by the one public method of that class and which it does through several or even many small private methods, each of which usually calls another such small private method or two in that class, in a chain that can stretch many methods long.  I have encapsulated almost all my code in these private implementation methods, which may also call public methods of other classes to do their work.  Some of the member variables of my classes being pre-calculated constants, which I made private static final to prevent them from being changed.  Despite not yet having profiled my code, I hesitate to make anything public, non-static, or non-final because I worry that the compiler could not optimize enough to avoid baking my poor little potato.

Quote
But yeah you definitely don't want final everywhere, all it does is make life slightly more difficult and clutter up the code. Same for private, but it's also very whatever. It matters more for vanilla code because mods really need it to be more flexible/workable-with.

So in your case I'd say it's a question of whether the amount of annoyance it causes you justifies the work of re-formatting it all yet again. Functionally, it doesn't matter.

I would love to get rid of all those finals...  :D  Would my code still be fast and safe?

Quote
Yes, that's required because the part of the code that has the put() calls in it is actually code in a different, anonymous class that gets defined as a result of this special syntax. If that doesn't make sense, I wouldn't worry about it too much. Basically the compiler needs to know k1/k2 won't change so it can... do stuff.

For that specific code I'd personally just write:
hashMap.put(k1, v1);
hashMap.put(k2, v2);

That doesn't need finals and just looks a little cleaner to me - especially if you end up needing to add more things to the map - but, again, that doesn't really matter.

I'm glad I finally understand now because I had thought Java was just being mean because it could.

Quote
Most things like this don't actually matter, except for when they do :) The bigger point is not to spend too much time worrying about code that works but could be "better", as long as there aren't any functional problems.

That's a really good point.  I worry about how I write my code because I am still learning, so I am trying to learn how to write code the 'right' way the first time!  I also feel kinda lame compared to the really good coding modders, who have all that documentation, formatting, etc., so I try to imitate them at least somewhat.  Is that a good idea?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Droll on September 05, 2022, 02:23:41 PM
Is there a way to make a patch that excludes specific portraits from showing up in the player faction? I don't want to mess with any existing portrait mods/the vanilla portraits directly so I can disable such a change easily.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 05, 2022, 04:16:50 PM
Is there a way to make a patch that excludes specific portraits from showing up in the player faction? I don't want to mess with any existing portrait mods/the vanilla portraits directly so I can disable such a change easily.
Yes. Take a look at how Iron Shell does it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Droll on September 05, 2022, 05:05:29 PM
Is there a way to make a patch that excludes specific portraits from showing up in the player faction? I don't want to mess with any existing portrait mods/the vanilla portraits directly so I can disable such a change easily.
Yes. Take a look at how Iron Shell does it.

Is it enough to just list only the portraits you want to show in player.faction? Or do they get added in addition to what vanilla/other mods define? If it's the former I should be golden.

Thanks anyways.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on September 05, 2022, 10:22:35 PM
Is there a good source of information on how to make a pirate-like faction avoid triggering sector-wide bounties?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 06, 2022, 06:03:18 AM
Is there a way to make a patch that excludes specific portraits from showing up in the player faction? I don't want to mess with any existing portrait mods/the vanilla portraits directly so I can disable such a change easily.
Yes. Take a look at how Iron Shell does it.

Is it enough to just list only the portraits you want to show in player.faction? Or do they get added in addition to what vanilla/other mods define? If it's the former I should be golden.

Thanks anyways.
If you only care about player faction so the former.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 06, 2022, 01:54:21 PM
I have another question, the answer to which may concern dark magic because I cannot find one in the API.  I want to modify the range of this weapon (or at least apply a modifier to the ranges of a WeaponGroupAPI) on that ship during a battle, but even after reading the obfuscated code behind MutableShipStatsAPI, CombatEngineAPI, and  WeaponArcAPI, I cannot find any method to this effect.  I suspect but cannot prove that the ShipAI determines modified weapon ranges by copying the base ranges (and that they are final) and then applying modifiers to these copies, and that the CombatEngine, upon determining that a WeaponAPI.isFiring(), does likewise and then spawning the appropriate DamagingProjectileAPI with somehow-modified numbers.

Does the underlying code of the game allow what I want to happen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on September 06, 2022, 11:06:46 PM
hello all, i have yet another question
if there an way to change the names and portraits off all people in an market when said people are created?
i did something similar to what i want here with 'pickFleetInflater' from an class that 'extends BaseCampaignPlugin', that let me change the captions of fleets into different looking captions, and was wondering if there was an way to do something like that for markets.
kind regards, from an very sleepy silly programmer, and thanks for any help given.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 07, 2022, 11:42:12 AM
Is there a good source of information on how to make a pirate-like faction avoid triggering sector-wide bounties?

I'm not sure exactly what you mean. System bounties are more likely in systems with markets with the "pirate activity" condition, but pay out for anything hostile to the posting facton. But you're saying "sector-wide" so I'm not sure if this is what you mean.


I want to modify the range of this weapon (or at least apply a modifier to the ranges of a WeaponGroupAPI) on that ship during a battle

You can add a WeaponRangeModifier to the ship's getListeners().

hello all, i have yet another question
if there an way to change the names and portraits off all people in an market when said people are created?

I don't think there's any callback when this happens, so the solution would likely involve a script that waits a bit, does it, and then removes itself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on September 07, 2022, 11:55:27 AM
How do I change the style of a variant skin when it comes to empty weapon covers? I can change the engine style just fine but adding a new tech or manufacturer field in the .skin file doesn't seem to do anything.

For example, the base Wolf has gray high tech weapon covers, but the Wolf (H) has orange low tech ones, whereas the base Brawler has yellow midline covers while the Brawler (TT) has high tech ones, so this seems possible, but I can't figure out how to do it for my own high tech variant of a low tech ship. Unless I create my own base variant and edit the .ship style field, the weapon covers in the codex still show up as orange.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 07, 2022, 12:01:08 PM
IIRC the covers color is automatically adjusted based on the average color of the ship sprite. You can provide a "coversColor" in the .skin file to override this value, but afaik there's no way to actually change it to a different set of covers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on September 07, 2022, 01:31:44 PM
IIRC the covers color is automatically adjusted based on the average color of the ship sprite. You can provide a "coversColor" in the .skin file to override this value, but afaik there's no way to actually change it to a different set of covers.

Thanks. With some tweaking I got it to look pretty close to what I intended. Is there a way to change the shield color as well, either via a .skin field or hullmod before/after ship creation effect?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 07, 2022, 01:59:54 PM
You can add a WeaponRangeModifier to the ship's getListeners().

Woo, thank you! :)

Also, the author of Quality Captains and I want but don't know how to programmatically override each vanilla skill with one from Quality Captains or, if Realistic Combat is loaded, Realistic Combat.  Overriding the sub-classes of each skill yields an error, but extending the classes and overriding the methods of them does not work either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 07, 2022, 03:54:28 PM
Hmm, your best bet might be to use SkillSpecAPI.addTag(Skills.TAG_NPC_ONLY) to manage which skills are actually shown in the character screen. You might also want to add Skills.TAG_PLAYER_ONLY to unused skills so that NPC officers don't pick them up, either - I *think* that should work, not 100% on it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on September 08, 2022, 01:34:26 AM
I noticed that some variant hull designations go by "firstWord variant secondWord" such as a Light Cruiser of the Attack variant being called a Light Attack Cruiser, while others go by "variant firstWord secondWord" such as a Combat Freighter of the Standard variant being called a Standard Combat Freighter. Is there a way to mod this behavior? The words "light, heavy, phase, fast" seem the only ones to trigger this behavior.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 08, 2022, 06:39:11 AM
Is there a good source of information on how to make a pirate-like faction avoid triggering sector-wide bounties?

I'm not sure exactly what you mean. System bounties are more likely in systems with markets with the "pirate activity" condition, but pay out for anything hostile to the posting facton. But you're saying "sector-wide" so I'm not sure if this is what you mean.
If this is about the Nexerelin faction bounties, those don't count factions that are marked as pirateFaction in their Nex configs.
(Factions with more non-pirate enemies are more likely to issue bounties, and it picks a random such faction for the "likely caused by X" string)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 08, 2022, 07:07:18 AM
I noticed that some variant hull designations go by "firstWord variant secondWord" such as a Light Cruiser of the Attack variant being called a Light Attack Cruiser, while others go by "variant firstWord secondWord" such as a Combat Freighter of the Standard variant being called a Standard Combat Freighter. Is there a way to mod this behavior? The words "light, heavy, phase, fast" seem the only ones to trigger this behavior.

Hardcoded. Sadly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 08, 2022, 07:49:33 AM
Hmm, your best bet might be to use SkillSpecAPI.addTag(Skills.TAG_NPC_ONLY) to manage which skills are actually shown in the character screen. You might also want to add Skills.TAG_PLAYER_ONLY to unused skills so that NPC officers don't pick them up, either - I *think* that should work, not 100% on it.

Excuse me, Alex, was this directed to my question about skills?  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 09, 2022, 06:27:09 AM
Two questions:

- Is it intentional that FleetLogisticsAPI.getShipMaintenanceSupplyCost(), despite its name, also includes supply use from repair and CR recovery? I don't suppose there's an easy method for me to get the maintenance-only supply cost other than counting myself?

- Alex, did you see my thread (https://fractalsoftworks.com/forum/index.php?topic=24909.0) here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 09, 2022, 09:13:49 AM
Excuse me, Alex, was this directed to my question about skills?  :)

Yes!

- Is it intentional that FleetLogisticsAPI.getShipMaintenanceSupplyCost(), despite its name, also includes supply use from repair and CR recovery? I don't suppose there's an easy method for me to get the maintenance-only supply cost other than counting myself?

Yes - iirc it was named before the terminology fully shook out and never renamed. And, unfortunately, no.

- Alex, did you see my thread (https://fractalsoftworks.com/forum/index.php?topic=24909.0) here?

I didn't; let me take a look.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 09, 2022, 01:44:16 PM
What justify an important people in the API?

I know story npcs should be placed in there, but what about reproducable (infinite, but requires a specific condition to spawn) contacts? Do they go in there too or rather what is the purpose of this api?

Also what is the point of checking them out or in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 09, 2022, 08:15:33 PM
Yes!

Thanks for clarifying!  I have another question.  I am writing a new version of VersionChecker, and  fetching the title of a mod forum thread would return the number of the latest version.  May I please code this new version of VersionChecker to do so?  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 10, 2022, 02:10:08 AM
How is production budget calculated?
I wanted to add an industry that increases it (even if a Heavy Industry is already present), but I'm not sure how to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 10, 2022, 07:23:06 AM
How is production budget calculated?
I wanted to add an industry that increases it (even if a Heavy Industry is already present), but I'm not sure how to.

it's 25k per unit of ship hulls produced
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 10, 2022, 07:26:43 AM
Ah I see, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on September 10, 2022, 08:03:15 AM
Hmm, your best bet might be to use SkillSpecAPI.addTag(Skills.TAG_NPC_ONLY) to manage which skills are actually shown in the character screen. You might also want to add Skills.TAG_PLAYER_ONLY to unused skills so that NPC officers don't pick them up, either - I *think* that should work, not 100% on it.
TAG_PLAYER_ONLY doesn't work on officer level-up for the base officer plugin (it doesn't check for that tag - OfficerManagerEvent does, and since FleetFactoryV3 relies on that, it works on both recruitable and NPC-fleet officers) but the mod can always fix that on its own by providing its own officer level-up plugin. Making them deprecated should work, too - it works on the levelup plugin and that trickles down to the other two.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on September 10, 2022, 01:18:38 PM
I have yet another random question, if someone is willing to answer:
is there an way to change / add to an commodities description using code? I want to add something like the thing weapons have were they show how mush cargo space each weapon takes.
thank you all once more for the help you all have given. it has saved me many long hours of headaches.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on September 10, 2022, 10:22:18 PM
Is it possible to set the max radius in hyperspace of a star system?

I am using the ConstellationGen methods to seperate the stars that I made and it uses the getMaxRadiusInHyperspace to seperate the stars, but the only way to increase the max radius in hyperspace is through using the autogenerateHyperspaceJumpPoints method in StarSystemAPI. Do we have other options  to increase the radius manually? I've been searching for a way but haven't found any.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 11, 2022, 05:24:01 PM
does the SHIP_LIMITED_TOOLTIP variant tag work as intended? (or am I misinterpreting it?)
I'm spawning a ship with lazylib's spawnShipOrWingDirectly which creates a fleetmember then spawns the ship & it seems not to apply correctly, the ship still has it's default tooltip when I select it in the command screen.
the text2 & text3 fields in the ship's desc seem to be filled out correctly, the only thing that seems like it'll be messing up will be the fact that the ship's getting spawned mid combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 11, 2022, 05:45:48 PM
How do I get all undeployed ships of a given fleetside in combat? CombatFleetManagerAPI doesn't hold any references to every fleet, doesnt give any way to get all of them, etc. it only seems to care about one single fleet.

Alternatively, I could just get all ships, deployed and undeployed.

EDIT: nevermind apparantly fleetmanager is jsut not initialized correctly until advance() in an everyframe
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WiC2021 on September 11, 2022, 09:28:52 PM
Hey Everyone,

I'm trying to make a custom weapon with custom sprites but based off of existing vanilla weapons when it comes to the .wpn file in order to understand the modding process. Vayra's intro to modding got me far enough to actually have my custom weapon show up in the mission refit and look relatively correct, however whenever I try to fire my weapon, the game crashes with the following:

Quote
48871 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.ship.A.void.ÖO0000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.void.createBeam(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.E.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.E.super(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.void.advance(Unknown Source)
   at com.fs.starfarer.combat.systems.G.advanceLinked(Unknown Source)
   at com.fs.starfarer.combat.systems.G.advance(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

I originally used the tachyon lance as my basis for the .wpn file, but had the same errors above. I figured it might have to do with the ["beamEffect":"com.fs.starfarer.api.impl.combat.TachyonLanceEffect"] script somehow having a broken path, so I switched to the High Intensity Laser since it doesnt have a beamEffect line but the error remains. There is probably something stupid i'm missing so apologies in advance!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 13, 2022, 07:10:11 AM
At a guess, there's something wrong with your beam properties somewhere although I can't tell what exactly from the error message. Compare to a working vanilla weapon and see what's different/missing.


Random thing that doesn't involve anything I'm working on but is bothering me:

How often do tooltips in general refresh? The ones in the character skills screen seem to do it every frame the button is moused over, which seems, uh, less than ideal.
I've heard of an issue where looking at a cargo screen with too many blueprint items in it causes a framerate drop, and was wondering if that could be related in any way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2022, 08:45:29 AM
(Sorry about the delay responding!)

What justify an important people in the API?

I know story npcs should be placed in there, but what about reproducable (infinite, but requires a specific condition to spawn) contacts? Do they go in there too or rather what is the purpose of this api?

Also what is the point of checking them out or in?

Basically it's a way to get at a unique NPC if they're needed for something and you're not, for example, just creating one on the spot or looking through a comm directory for a suitable one. So it depends entirely on what you need.

The "checking out" thing is meant to be a way to coordinate multiple things trying to involve an NCP in something (e.g. of they're already "checked out" for a specific purpose, they can't be "checked out" by something else for that purpose) but this isn't really used by the game.

I have another question.  I am writing a new version of VersionChecker, and  fetching the title of a mod forum thread would return the number of the latest version.  May I please code this new version of VersionChecker to do so?  :)

(VersonChecker is not vanilla.)

TAG_PLAYER_ONLY doesn't work on officer level-up for the base officer plugin (it doesn't check for that tag - OfficerManagerEvent does, and since FleetFactoryV3 relies on that, it works on both recruitable and NPC-fleet officers) but the mod can always fix that on its own by providing its own officer level-up plugin. Making them deprecated should work, too - it works on the levelup plugin and that trickles down to the other two.

Ah, thank you for the info! And, fixed this up.


Is it possible to set the max radius in hyperspace of a star system?

I am using the ConstellationGen methods to seperate the stars that I made and it uses the getMaxRadiusInHyperspace to seperate the stars, but the only way to increase the max radius in hyperspace is through using the autogenerateHyperspaceJumpPoints method in StarSystemAPI. Do we have other options  to increase the radius manually? I've been searching for a way but haven't found any.

Hmm, I don't think so. Let me add a setMaxRadiusInHyperspace() method. I suppose you could copy-paste the ConstellationGen methods, at least for the time being?

does the SHIP_LIMITED_TOOLTIP variant tag work as intended? (or am I misinterpreting it?)
I'm spawning a ship with lazylib's spawnShipOrWingDirectly which creates a fleetmember then spawns the ship & it seems not to apply correctly, the ship still has it's default tooltip when I select it in the command screen.
the text2 & text3 fields in the ship's desc seem to be filled out correctly, the only thing that seems like it'll be messing up will be the fact that the ship's getting spawned mid combat?

As far as I'm aware, it works - but it checks ship.getFleetMember().getVariant(), so perhaps there's some kind of disconnect there in doing this with spawnShipOrWingDirectly? For the omega, for example, it does work when they split and it looks to be adding the tag to ShipAPI.getVariant(), and using CombatFleetManagerAPI.spawnShipOrWing() to spawn the ships.


Random thing that doesn't involve anything I'm working on but is bothering me:

How often do tooltips in general refresh? The ones in the character skills screen seem to do it every frame the button is moused over, which seems, uh, less than ideal.
I've heard of an issue where looking at a cargo screen with too many blueprint items in it causes a framerate drop, and was wondering if that could be related in any way.

Either once when created or every frame, depends on the tooltip. Some need to be dynamic, but a bunch that don't strictly need to do it are still recreated every frame. It super doesn't matter performance-wise unless the tooltip creation code is doing something bad. And if it were, it'd still be an issue even if the tooltip was only created once, in that it would cause a frame drop when the tooltip is first shown.

It can't be the issue you're describing, since the tooltips aren't being created/recreated/etc unless they're actually being shown. So how many items there are in the cargo doesn't matter for this at all. At most one tooltip would be created at a time.

So, hmm. That issue might be caused by blueprint item rendering being a little heavier than for normal items? Or, perhaps, a modded item of a similar sort, that does something even more performance-heavy in its custom rendering? Really hard to say, though. It *could* also be tooltip-related, if an item's tooltip is doing something performance-heavy in whatever plugin method adds stuff to the tooltip, but in that case it would show up regardless of what other items might be in the cargo, and only when the tooltip is being shown.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 13, 2022, 12:32:33 PM

As far as I'm aware, it works - but it checks ship.getFleetMember().getVariant(), so perhaps there's some kind of disconnect there in doing this with spawnShipOrWingDirectly? For the omega, for example, it does work when they split and it looks to be adding the tag to ShipAPI.getVariant(), and using CombatFleetManagerAPI.spawnShipOrWing() to spawn the ships.


ty for the answer! I'll probably just switch back to using the vanilla method, I'm not hugely sure on why I used lazylib's method anyway

Quick edit - here's the code I'm using to spawn the ship & change the variant & it still doesn't work correctly, the only other difference I could think of is that I've only been testing in the sim?

code
Code

    @Override
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {

        //maybe redo spawn in / out vfx, maybe use particles?

        ShipAPI ship = (ShipAPI) stats.getEntity();
        ShipVariantAPI variant = stats.getVariant().clone();
        variant.addTag(Tags.SHIP_LIMITED_TOOLTIP);
        String varID = variant.getHullVariantId();
        Vector2f loc = ship.getLocation();
        CombatFleetManagerAPI fleetManager = Global.getCombatEngine().getFleetManager(ship.getOriginalOwner());
        Vector2f safeLoc = new Vector2f(findClearLocation(ship, loc));

        if (!doneOnce) {
            fleetManager.setSuppressDeploymentMessages(true);
            //todo - needs better facing determination
            ShipAPI otherShip = fleetManager.spawnShipOrWing(varID, safeLoc, ship.getFacing());
            fleetManager.setSuppressDeploymentMessages(false);
            doneOnce = true;

            otherShip.addListener(new clonedShipListener(ship, otherShip, maxLifeTime));
            ship.setCustomData(PairKey, otherShip.getId());
        }
    }   

[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on September 13, 2022, 02:44:27 PM
Is there an easy way to adjust commission stipend amounts on a per faction basis?

Ended up making a whole suggestion about it: https://fractalsoftworks.com/forum/index.php?topic=25309.0 (https://fractalsoftworks.com/forum/index.php?topic=25309.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 13, 2022, 06:19:05 PM
(VersonChecker is not vanilla.)

Yes, I just don't want to drive traffic to your site if it would bother you.  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2022, 08:51:39 PM
Quick edit - here's the code I'm using to spawn the ship & change the variant & it still doesn't work correctly, the only other difference I could think of is that I've only been testing in the sim?

Oh! You're spawning the other ship using the variant ID, which - if you're lucky - is going to be the stock variant ID (in which case it'll find and use the stock variant, without the added tag). If you're not lucky, the variant ID is some unique ID assigned to a refitted campaign variant, in which case it might not even spawn, since that ID would not be found in the map that has the id-to-variant mapping.

You probably want to use spawnFleetMember(). Or spawnShipOrWing(), with a known stock variant ID, and then add a tag to that stock variant. Basically, what you're doing - making a cloned copy of the variant - doesn't actually *do* anything since that variant never gets used.


Is there an easy way to adjust commission stipend amounts on a per faction basis?

Ended up making a whole suggestion about it: https://fractalsoftworks.com/forum/index.php?topic=25309.0 (https://fractalsoftworks.com/forum/index.php?topic=25309.0)

You can see the commission code - it's in FactionCommissionIntel. Off the top of my head, I don't think so. (Thank you for the suggestion; in all honesty I'm probably not going to touch it until I have a better notion for how I want all this to ultimately shape up/expand, if at all.)


(VersonChecker is not vanilla.)

Yes, I just don't want to drive traffic to your site if it would bother you.  :-\

... ah, right, I missed that part of it. I appreciate you asking! In all honesty, I'd rather not - I mean no offense here, but I feel like code that makes mods fetch stuff from the forum should probably be written by programmers with a little more experience, since it's quite easy to make a mistake of some consequence. On the face of it, making a copy of VersionChecker (I'm not sure if the license allows it, but that aside) doesn't seem like a great idea, either, at least not knowing the reasoning behind it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on September 13, 2022, 10:51:04 PM
Hmm, I don't think so. Let me add a setMaxRadiusInHyperspace() method. I suppose you could copy-paste the ConstellationGen methods, at least for the time being?

Made a simpler code for seperating them, a bit crude and might crash the game but works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on September 14, 2022, 05:35:32 AM
I am currently modding my own station defense drone similar to the Gargoyle that has a fairly long range weapon and can face enemies with its main gun. Everything from the summoning ability to the drone itself works fine, but I've noticed the drones will often get fixated on an enemy, and won't attempt to switch targets even when it's rotated out of view. Is there a way to force a station defense drone to always attack the closest enemy?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 14, 2022, 06:02:01 AM
Oh! You're spawning the other ship using the variant ID, which - if you're lucky - is going to be the stock variant ID (in which case it'll find and use the stock variant, without the added tag). If you're not lucky, the variant ID is some unique ID assigned to a refitted campaign variant, in which case it might not even spawn, since that ID would not be found in the map that has the id-to-variant mapping.

You probably want to use spawnFleetMember(). Or spawnShipOrWing(), with a known stock variant ID, and then add a tag to that stock variant. Basically, what you're doing - making a cloned copy of the variant - doesn't actually *do* anything since that variant never gets used.

ah, that makes some sense - I assumed that cloning a variant would assign the clone variant a unique id.
though it does seem to work using the campaign refitted variant, I'll try and see if using the cloned variant w/ a custom ID (smth like varID + "_clone") works, before falling back on spawnFleetMember
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 14, 2022, 08:21:50 AM
... ah, right, I missed that part of it. I appreciate you asking! In all honesty, I'd rather not - I mean no offense here, but I feel like code that makes mods fetch stuff from the forum should probably be written by programmers with a little more experience, since it's quite easy to make a mistake of some consequence. On the face of it, making a copy of VersionChecker (I'm not sure if the license allows it, but that aside) doesn't seem like a great idea, either, at least not knowing the reasoning behind it.

I apologize for having been vague.  I should have clarified that I have not written a new version of Version Checker but rather modified it to reduce the trouble modders have supporting it, fetch threads from the forum only with the code whereby Version Checker already fetches forum threads, and would not release this modification but rather personally test it to demonstrate that the Version Checker author, LazyWizard, should be include my modification in the next Version Checker release.  My reasoning is that many modders do not support Version Checker because its approach to checking whether the mod is updated requires the modder to follow a complicated and surprisingly-error-prone process of writing a custom .csv inside a hardcoded nested directory and including a separate .version file in the mod itself and maintaining another 'master' .version file at a separate link--all because VersionChecker was written before the StarsectorAPI could read .json files. 

This hassle had deterred me from supporting Version Checker for many versions of Realistic Combat, still deters other modders from supporting Version Checker, made me have to try several times to make it work, and even afterward ensnared a mod manager with a hidden gotcha error in the .csv I had to write for Version Checker.  After all this trouble, I thought, "There must be a better way", talked to much more experienced mod and mod-manager authors, and they agreed that there is. My better way would be simple enough for more modders to support, not require separate .version and master .version files, and be reliable enough to avoid tangling mod managers: the modder would include the download link and forum thread ID in mod_info.json and the current mod version number in the title of the forum thread, and Version Checker would check the title of the ID-indicated thread, fetched with its current thread-fetching code, for a mod version number and, if it found one, compare it to the one in mod_info.json.

So... um, may I please try my code out?  :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2022, 09:11:55 AM
Made a simpler code for seperating them, a bit crude and might crash the game but works.

(... I'm not too sure "might crash the game" and "works" are compatible with each other :) )

I am currently modding my own station defense drone similar to the Gargoyle that has a fairly long range weapon and can face enemies with its main gun. Everything from the summoning ability to the drone itself works fine, but I've noticed the drones will often get fixated on an enemy, and won't attempt to switch targets even when it's rotated out of view. Is there a way to force a station defense drone to always attack the closest enemy?

Hmm, I don't think so - it's just going to do what it does, which is mostly behaving like a normal ship that just can't move. You could write your own ship AI for it, but that's... involved. It might be worth it to make sure that you have the hull size set to FRIGATE, though, just in case it being not set to that is affecting its behavior.


ah, that makes some sense - I assumed that cloning a variant would assign the clone variant a unique id.
though it does seem to work using the campaign refitted variant, I'll try and see if using the cloned variant w/ a custom ID (smth like varID + "_clone") works, before falling back on spawnFleetMember

*thumbs up*


Spoiler
I apologize for having been vague.  I should have clarified that I have not written a new version of Version Checker but rather modified it to reduce the trouble modders have supporting it, fetch threads from the forum only with the code whereby Version Checker already fetches forum threads, and would not release this modification but rather personally test it to demonstrate that the Version Checker author, LazyWizard, should be include my modification in the next Version Checker release.  My reasoning is that many modders do not support Version Checker because its approach to checking whether the mod is updated requires the modder to follow a complicated and surprisingly-error-prone process of writing a custom .csv inside a hardcoded nested directory and including a separate .version file in the mod itself and maintaining another 'master' .version file at a separate link--all because VersionChecker was written before the StarsectorAPI could read .json files. 

This hassle had deterred me from supporting Version Checker for many versions of Realistic Combat, still deters other modders from supporting Version Checker, made me have to try several times to make it work, and even afterward ensnared a mod manager with a hidden gotcha error in the .csv I had to write for Version Checker.  After all this trouble, I thought, "There must be a better way", talked to much more experienced mod and mod-manager authors, and they agreed that there is. My better way would be simple enough for more modders to support, not require separate .version and master .version files, and be reliable enough to avoid tangling mod managers: the modder would include the download link and forum thread ID in mod_info.json and the current mod version number in the title of the forum thread, and Version Checker would check the title of the ID-indicated thread, fetched with its current thread-fetching code, for a mod version number and, if it found one, compare it to the one in mod_info.json.

So... um, may I please try my code out?  :'(
[close]

Wait, wait. Why would/does Verstion Checker fetch forum threads (aside from whatever code it might have letting the player open the forum thread)? It doesn't do this just to check the version - that's why the modder needs to host a .version file elsewhere, so that Version Checker doesn't hit the forum with a bunch of requests every time the game starts. This seems like a bad idea - I think, at least if my understanding is correct, that the thing you're simplifying away is the thing that makes Version Checker viable in the first place.

The inability to read mod_info.json - not just any .json file, but that one specifically for multiple mods - is *not* the reason for why a mod needs to host a file with its current version. Not hitting the forum with a mini-DoS is.

(It *is* the reason for being unable to get version data from mod_info.json and requiring the mod author to also include a .version file with their mod, but that's secondary here.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 14, 2022, 11:45:57 AM
Wait, wait. Why would/does Verstion Checker fetch forum threads (aside from whatever code it might have letting the player open the forum thread)? It doesn't do this just to check the version - that's why the modder needs to host a .version file elsewhere, so that Version Checker doesn't hit the forum with a bunch of requests every time the game starts. This seems like a bad idea - I think, at least if my understanding is correct, that the thing you're simplifying away is the thing that makes Version Checker viable in the first place.

Your understanding is correct, and now I'm glad I asked!  :o

Quote
The inability to read mod_info.json - not just any .json file, but that one specifically for multiple mods - is *not* the reason for why a mod needs to host a file with its current version. Not hitting the forum with a mini-DoS is.

Ahhh!  I don't want to hit your forum with a mini-DoS!  :-[  I won't even test this modification of VersionChecker as-is.

Quote
(It *is* the reason for being unable to get version data from mod_info.json and requiring the mod author to also include a .version file with their mod, but that's secondary here.)

Thank you so much for your patience and understanding response.  I guess a master copy of mod_info.json with the version number would be the next best alternative to reading the forum thread title.  That said, a local separate .version file would no longer be necessary if the .version file information could be kept in mod_info.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2022, 11:51:48 AM
Ok, whew, glad I wasn't missing something. Thank you for being so understanding about it!

And, yeah, you're right on about the .version file info potentially being kept in mod_info.json - at least, as far as my understanding of all this goes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 14, 2022, 12:05:13 PM
Ok, whew, glad I wasn't missing something. Thank you for being so understanding about it!

Haha, of course!  I know I don't know what I'm doing, so I ask first before hitting the big red button.  :)

Quote
And, yeah, you're right on about the .version file info potentially being kept in mod_info.json - at least, as far as my understanding of all this goes.

Eeeeee!   :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 14, 2022, 12:30:28 PM
ah, that makes some sense - I assumed that cloning a variant would assign the clone variant a unique id.
though it does seem to work using the campaign refitted variant, I'll try and see if using the cloned variant w/ a custom ID (smth like varID + "_clone") works, before falling back on spawnFleetMember

*thumbs up*

ah-ha! found the issue- lazylib's method uses the createFleetMember() method that takes a VariantID, not the one that takes a ShipVariantAPI; made my own version that takes a ShipVariantAPI & it all works fine now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2022, 12:47:11 PM
*thumbs up* all around :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 14, 2022, 07:13:28 PM
Is it possible for a shipsystem to instantly kill a ship after its activation uptime runs out? Bonus if it can make it unrecoverable

I know there are stuff like the Titan or IEDs that can explode but those don’t seem to be timer based or otherwise don’t seem to work for some odd reason
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2022, 08:30:42 AM
Is it possible for a shipsystem to instantly kill a ship after its activation uptime runs out? Bonus if it can make it unrecoverable

I know there are stuff like the Titan or IEDs that can explode but those don’t seem to be timer based or otherwise don’t seem to work for some odd reason

For non-recovery, you could add Tags.VARIANT_UNBOARDABLE to the variant.

For destroying the ship, you'd need to have a script (probably the system script, since that'd already be handy) apply a bunch of damage to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on September 16, 2022, 09:51:30 AM
I want to render something on the minimap-radar in the bottom-right corner of the screen in a mod.

When using the "create a custom campaign entity and use its render-method"-approach, whatever I render (using the rendering layer ABOVE) gets blocked by the radar, presumably because it's also rendered in the layer ABOVE with 100% alpha and the UI is last in the rendering order.

When I simply render everything in the advance-method of an EveryFrameScript, it works, but I have been told that that's not necessarily the safest thing to do.

Is there some (clean-ish) way to circumvent this problem, like e.g. place my custom campaign entity last in the render order?

If not, if it's easy to implement, would it be possible to add another rendering layer above ABOVE (like e.g. ABOVE_ABOVE or ABOVE_ALL) that's unused by the base game?

And possibly even offer some variant of EveryFrameScript with a render-method so that, in order to render something in the campaign-layer, one doesn't have to create a custom campaign entity?

Thanks in advance for answers! =)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 16, 2022, 10:12:34 AM
Hmm - if you want to render something on the radar, your best bet might be the CampaignTerrainPlugin.renderOnRadar() method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 17, 2022, 08:14:58 AM
My mod generally gives weapons more range, but ships still close to vanilla distances from enemy stations, sometimes even ramming them despite orders to avoid the station or defend a distant point.  How can I, or at least players using my mod, make the ships stay a safe distance from stations?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2022, 09:32:52 AM
Hmm, I'm not actually sure. Offhand, no way to do this comes to mind. You could try something like station.setStation(false) but that'll have other repercussions such as it probably not staying in one place, being able to receive orders/retreat, etc. So actually that'd probably be a very bad idea, scratch that. You *might* be able to do something via ship.getAIFlags() but I'm not sure; there's a good chance some of these get overridden/ignored if the target is a station.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 17, 2022, 10:07:03 AM
Hmm, I'm not actually sure. Offhand, no way to do this comes to mind. You could try something like station.setStation(false) but that'll have other repercussions such as it probably not staying in one place, being able to receive orders/retreat, etc. So actually that'd probably be a very bad idea, scratch that.

Well, if there's no other solution...

Edit: I tested this option, but the ships still closed to vanilla ranges.

Quote
You *might* be able to do something via ship.getAIFlags() but I'm not sure; there's a good chance some of these get overridden/ignored if the target is a station.

I thought of this too, and aw man, really? :'(  I wish there were some way to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 17, 2022, 11:54:49 AM
for some reason, my custom entity icon shows up on the map prior to being discovered even though it is discoverable.
Any pointers on what I *** up?

Code
	"IndEvo_Watchtower":{
"defaultName":"Watchtower", # used if name=null in addCustomEntity()
"defaultRadius":35, # used if radius<0 in addCustomEntity(),
"nameInText":"watchtower",
"shortName":"watchtower",
"aOrAn":"a",
"isOrAre":"is",
"customDescriptionId":"IndEvo_Watchtower",
"interactionImage":"graphics/illustrations/orbital_construction.jpg",
"icon":"graphics/icons/IndEvo_station1.png",
"iconWidth":10,
"iconHeight":10,
"sprite":"graphics/stations/IndEvo_station_03.png",
"spriteWidth":30,
"spriteHeight":30,
"renderShadow":false, #true,
"useLightColor":true,
"showInCampaign":true,
"showIconOnMap":true,
"showNameOnMap":false,
"scaleNameWithZoom":false,
"scaleIconWithZoom":true,
"tags":["objective", "story_critical", "IndEvo_watchtower"],
"layers":[STATIONS], # what layer(s) to render in. See CampaignEngineLayers.java for possible values
"pluginClass":"com.fs.starfarer.api.***.station.IndEvo_WatchtowerEntityPlugin"
},

Code
SectorEntityToken t = system.addCustomEntity(Misc.genUID(), faction.getDisplayName() + " Watchtower", "IndEvo_Watchtower", faction.getId(),null);
                    t.setOrbit(loc.orbit);
                    t.setDiscoverable(true);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2022, 12:00:48 PM
I thought of this too, and aw man, really? :'(  I wish there were some way to do it.

In all honesty, the ship AI isn't all *that* configurable, so this isn't super surprising. I'll see if I can do something at some point, but no promises.

for some reason, my custom entity icon shows up on the map prior to being discovered even though it is discoverable.
Any pointers on what I *** up?

Could you try Misc.makeDiscoverable()? That takes a couple of extra parameters (discovery XP and sensor profile) and I think in particularly not setting the latter might be the problem here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 17, 2022, 12:23:24 PM
In all honesty, the ship AI isn't all *that* configurable, so this isn't super surprising. I'll see if I can do something at some point, but no promises.

 :) :) :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 17, 2022, 01:02:52 PM
for some reason, my custom entity icon shows up on the map prior to being discovered even though it is discoverable.
Any pointers on what I *** up?

Could you try Misc.makeDiscoverable()? That takes a couple of extra parameters (discovery XP and sensor profile) and I think in particularly not setting the latter might be the problem here.
Hey, thank you - it was in BaseThemeGenerator, but that indeed fixed it <3
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2022, 01:05:23 PM
Ah, my bad - glad you were able to track it down anyway :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 18, 2022, 06:50:14 AM
Is there any clean way to run a script on a fleet after it interacts with an entity, but before it actually performs an action?

I want to spawn a fleet that attacks any hostile fleet thats about to interact with a planet that has satellites in orbit. The idea here is that the fleet will interrupt whatever action that fleet would have taken, such as raiding the planet. If the defender is destroyed, the attacked fleet can continue as normal.

"Clean" in this context means anything that isn't an everyframe script. Something performant and not janky.

I know reportFleetReachedEntity exists, but I don't think making a fleet enter combat in the listener would really prevent something like a raid. Then again, I haven't actually tried it. If this would work, please tell me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 18, 2022, 03:31:59 PM
Depending on what sort of entity it is, there are two options that come to mind. One is just providing a different rule with a higher score that fires off in this case and takes over the interaction. See: rule with id "marketOpen" for the default market interaction. After your rule fires and is finished, you could set a variable to make sure your rule can't fire again (i.e. have a "!$didThing" its conditions) and then run:

$didThing = true
FireBest OpenInteractionDialog

To get back into the normal interaction flow.


If the entity does not by default use rule interactions (i.e. it's a fleet, most likely - or a jump-point, or a planet without a market) then you could provide an implementation of CampaignPlugin.pickInteractionDialogPlugin() which would take over the interaction instead of the default dialog. This could actually also be done if the entity uses rules for its interactions by default, though in that case using rules would be cleaner/simpler since they're pretty much meant for this sort of thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 18, 2022, 05:58:01 PM
I think Niko means one NPC fleet interrupting another. I don't think there is any way to do that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 18, 2022, 06:23:09 PM
... ah, that makes sense. In that case, I think the answer is "no".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on September 19, 2022, 03:32:08 AM
Is there a quick and dirty (easy) way to stop pre combat views from displaying fighters? information isnt really that useful imo, and causes a lot of unnecessary clutter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 19, 2022, 05:15:33 AM
... ah, that makes sense. In that case, I think the answer is "no".

Damn, okay, thanks anyways.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 19, 2022, 06:59:40 AM
After your rule fires and is finished, you could set a variable to make sure your rule can't fire again (i.e. have a "!$didThing" its conditions) and then run:

Also, I never thought of this and to be honest this makes rules so much easier. I was jsut relying on the fact that rules can't call themselves.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2022, 11:37:47 AM
Is there a quick and dirty (easy) way to stop pre combat views from displaying fighters? information isnt really that useful imo, and causes a lot of unnecessary clutter.

I don't believe so.

Also, I never thought of this and to be honest this makes rules so much easier. I was jsut relying on the fact that rules can't call themselves.

(Ah, cool, glad that clicks! Half the trick with rules is doing stuff like that to intercept and re-route the flow as needed.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on September 19, 2022, 02:44:55 PM
more questions for you all, if you are wiling to answer.
1: how do I make an dialog option require and use an story point? i dont know were to look for this.
2: how do I make and give an administrator to the player?
3: I made an officer and added them to the players fleet, but they always end up at LV 1 and with no skills. im using Global.getFactory().createOfficerData() to make my Officer, with Global.getFactory().createPerson() to make my person (creating an officer requires an person), and would like it if they started with an skill. dose anyone know how to do so, so they can have an skill at LV 1?

thank you for all the help you all have chosen to give me. I'm very thankful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 20, 2022, 09:16:58 AM
more questions for you all, if you are wiling to answer.
1: how do I make an dialog option require and use an story point? i dont know were to look for this.
I'll just steal (and modify) Timid's example from the Discord:
Code
SetStoryOption <string: option ID> <int:storypoint> <string: bonus XP, see setting.json line 739> <string: sound id, i use ui_char_spent_story_point> "<String: Historian record entry>"

Example: SetStoryOption kweenSurvival 1 mentorOfficer ui_char_spent_story_point "Kween got saved through my genius actions"

Quote
2: how do I make and give an administrator to the player?
Create the admin if needed (OfficerManagerEvent.createAdmin is good), then Global.getSector().getCharacterData().addAdmin(person);

Quote
3: I made an officer and added them to the players fleet, but they always end up at LV 1 and with no skills. im using Global.getFactory().createOfficerData() to make my Officer, with Global.getFactory().createPerson() to make my person (creating an officer requires an person), and would like it if they started with an skill. dose anyone know how to do so, so they can have an skill at LV 1?
I'd recommend using the OfficerManagerEvent.createOfficer methods rather than trying to do it manually. Although you can also take the no-skills officer and call person.getStats().setSkillLevel on them to set their skills manually.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 21, 2022, 06:54:51 AM
Is there a way to unmodify the flux dissipation penalty or manueverability penalty when a ship is overloading?

It doesn't seem to be a MutableStat so I wonder if this mechanic just hardcoded?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 21, 2022, 07:43:48 AM
<checking> The dissipation rate is indeed hardcoded! There's no maneuverability penalty.

You could however add an AdvanceableListener to the ship and modify whatever you want there, based on the ship's current state.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on September 21, 2022, 08:22:34 AM
There's no maneuverability penalty.
I'm shocked, I just find it hard to turn or maneuver when a ship is overloaded. Is there any other debuffs that happens when a ship is overloading?

What about venting too?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 21, 2022, 08:57:41 AM
I'm shocked, I just find it hard to turn or maneuver when a ship is overloaded. Is there any other debuffs that happens when a ship is overloading?

Nope! Well, aside from the obvious of "can't fire or use shields" etc :)

What about venting too?

Same on all counts - no debuffs, rate multiplier is hardcoded, can use an AdvanceableListener to do whatever you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 21, 2022, 09:26:51 AM
How can I 'grab' the just-fired DamagingProjectileAPI of a WeaponAPI as in OnFireEffect?

Edit: Nevermind, not a good idea anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 22, 2022, 09:53:15 AM
is there a tag or a memKey that makes a CampaignFleet display built-in (or otherwise) weapon visuals?
I got a big gun that is clearly visible on a station and it gotta show up in the campaign layer station fleet visual but doesn't, making the thing look weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2022, 10:09:13 AM
I don't think there is, sorry! You might get around this, perhaps, by calling station.setFleetForVisual(null) and adding your own non-interactive entity that matches the location of the station and has the sprite you want to show (i.e. station with gun). I *think* that ought to work but it could get a bit messy keeping these in sync.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 22, 2022, 11:15:24 AM
I fixed it with absolutely genius legit moves

added module slot to the station and added the gun as module without bounds, that causes it to display it in the campaign
and then I added a hullmod to the module that sets the ship alpha to 0 on creation
since hullmods only apply themselves in dialogue previews and not on the campaign layer, the gun module is visible where I need it and removes itself for the preview where the weapon sprite is visible, and then I just replace it with a 1px blank sprite and have it kill itself in advanceInCombat so it doesn't mess with combat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 22, 2022, 11:47:33 AM
I fixed it with absolutely genius legit moves

QFT
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 22, 2022, 07:54:11 PM
What character encoding standards does Starsector support?  I know it supports the basic ASCII set, but what about fancier stuff like UTF-8?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 23, 2022, 08:22:05 PM
What kind of scenarios could generate this type of error?

For context, this occurs when a modular ship of mine has their core get destroyed (80% chance of break, 3 min pieces, 7 max). I have a hullmod on some of its modules that cause modules with a matching ID in their tags to explode, however the core doesnt have this hullmod, and it only seems to happen when the core dies.

EDIT: forgot... to fuckin,,,, assign bounds to a module. .

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 23, 2022, 08:40:11 PM
On that note, how about this one, too? it seems equally esoteric. Happened a few seconds after I went into the variant refit screen for my left heavy combat module on my satellite.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on September 24, 2022, 09:15:03 PM
Is there a way for a shipsystem to automatically regenerate ammo for ballistic/ammo weapons constantly while it is activated? I know that there is missile auto forge for missiles but there doesn’t seem to be code connected to it so I’m not sure what to do here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 25, 2022, 01:57:16 AM
How do you check if DevMode is on or not?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 25, 2022, 03:55:22 AM
Global.getSettings().isDevMode()



I am having trouble with playing custom music when I create a custom dialog directly in the campaign. I copied the way Sword of Eventide does it. I thought it was because the system I was in has custom music, but now I am not sure. Is there some surefire way to play music for a dialog?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheProtagonists on September 25, 2022, 05:26:54 AM
Is the amount of resources required/consumed when surveying and colonizing adjustable? If so where can I find them in the API?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: quintudiast on September 25, 2022, 06:00:29 AM
Does anybody know why the ship is duplicating when fighter/wings are deployed?

like this:
(https://imgur.com/a/uwvR8mD)

https://imgur.com/a/uwvR8mD (https://imgur.com/a/uwvR8mD)

CONTEXT:
i'm trying to make new ship mod
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2022, 09:57:58 AM
What character encoding standards does Starsector support?  I know it supports the basic ASCII set, but what about fancier stuff like UTF-8?

Take a look at the .fnt files! It's "ASCII plus a bit", basically.

On that note, how about this one, too? it seems equally esoteric. Happened a few seconds after I went into the variant refit screen for my left heavy combat module on my satellite.

If the ship is null, the bounds are null, or the ship sprite is null. Sounds like the same "didn't specify bounds" issue.

(Side note: attaching stack trace screenshots is not the most convenient thing. I know sometimes there's characters in there that the forum can't handle, but it seems ok most of the time.)


How do you check if DevMode is on or not?

Quickest way would be to try some devMode command to see if it works. Like Ctrl-Z in the campaign to turn off sensors and reveal everything, or something along those lines.


I am having trouble with playing custom music when I create a custom dialog directly in the campaign. I copied the way Sword of Eventide does it. I thought it was because the system I was in has custom music, but now I am not sure. Is there some surefire way to play music for a dialog?

I'd suggest trying this in a system that doesn't have custom music to figure out if that's the issue or not. The way SOE does it should work, generally, though - unless some other script is also constantly running and calling the same methods, fighting it for control of the music player.


Is the amount of resources required/consumed when surveying and colonizing adjustable? If so where can I find them in the API?

A bunch of static values in SurveyPluginImpl.

Does anybody know why the ship is duplicating when fighter/wings are deployed?

Need a bit more info :)

Could be something like a ship system that launches drones but is set to the ship's variant, or something like that, but it's hard to say just from this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on September 25, 2022, 12:16:34 PM
Re-post for Alex since nobody seems to have an answer in modding:

Quote
How do i go about adding a character to a station? typically, when you visit a station and pull up a comm listing of various contacts, you see all the individuals you can interact with. How would i add a custom individual to this list and instigate a conversation with them?

Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 25, 2022, 12:52:06 PM
I am having trouble with playing custom music when I create a custom dialog directly in the campaign. I copied the way Sword of Eventide does it. I thought it was because the system I was in has custom music, but now I am not sure. Is there some surefire way to play music for a dialog?

I'd suggest trying this in a system that doesn't have custom music to figure out if that's the issue or not. The way SOE does it should work, generally, though - unless some other script is also constantly running and calling the same methods, fighting it for control of the music player.

"Great" news, if I put a debugger breakpoint right after I set the custom music, it plays the music until I let the code move on and play the ability sound, after which it goes silent again. When the dialog closes the custom music resumes instead of the campaign music. Pretty sketchy that debugging changes the sound player's behavior.

I'll see if I can trigger my custom music after the ability sound plays - that seems to be what is cutting it off.


EDIT:

Moved starting code to the ability's activateImpl() method after the dialog is opened, which got the music to start. I got it to quit properly too by changing the end code to:

Code: java
Global.getSoundPlayer().pauseCustomMusic();
Global.getSoundPlayer().setSuspendDefaultMusicPlayback(false);

instead of

Code: java
Global.getSoundPlayer().setSuspendDefaultMusicPlayback(false);
Global.getSoundPlayer().restartCurrentMusic();

because it was playing the default encounter music for a second or else it kept playing the custom music or else...

Only complaint left is that it restarts the campaign music instead of resuming it, but that is minor.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 25, 2022, 01:37:18 PM
Take a look at the .fnt files! It's "ASCII plus a bit", basically.

Thanks! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2022, 02:51:30 PM
Quote
How do i go about adding a character to a station? typically, when you visit a station and pull up a comm listing of various contacts, you see all the individuals you can interact with. How would i add a custom individual to this list and instigate a conversation with them?

Thanks.

See: CoreLifecyclePluginImpl.createInitialPeople() for some code that does that. Basically, need to create a person, add them to the market, and add them to the comm directory. The "important people" stuff is optional.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: quintudiast on September 25, 2022, 04:30:22 PM
Quote
Need a bit more info :)

Could be something like a ship system that launches drones but is set to the ship's variant, or something like that, but it's hard to say just from this.

Solved!!

little bit tweak on collision radius that's unexpected though
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 25, 2022, 07:38:33 PM
Random thing that doesn't involve anything I'm working on but is bothering me:

How often do tooltips in general refresh? The ones in the character skills screen seem to do it every frame the button is moused over, which seems, uh, less than ideal.
I've heard of an issue where looking at a cargo screen with too many blueprint items in it causes a framerate drop, and was wondering if that could be related in any way.

Either once when created or every frame, depends on the tooltip. Some need to be dynamic, but a bunch that don't strictly need to do it are still recreated every frame. It super doesn't matter performance-wise unless the tooltip creation code is doing something bad. And if it were, it'd still be an issue even if the tooltip was only created once, in that it would cause a frame drop when the tooltip is first shown.

It can't be the issue you're describing, since the tooltips aren't being created/recreated/etc unless they're actually being shown. So how many items there are in the cargo doesn't matter for this at all. At most one tooltip would be created at a time.

So, hmm. That issue might be caused by blueprint item rendering being a little heavier than for normal items? Or, perhaps, a modded item of a similar sort, that does something even more performance-heavy in its custom rendering? Really hard to say, though. It *could* also be tooltip-related, if an item's tooltip is doing something performance-heavy in whatever plugin method adds stuff to the tooltip, but in that case it would show up regardless of what other items might be in the cargo, and only when the tooltip is being shown.
So I finally bothered to investigate after someone complained about Nex's new game blueprint picker. JVisualVM very quickly found the surprising cause:
Spoiler
Code: java
for (SpecialItemSpecAPI spec : Global.getSettings().getAllSpecialItemSpecs()) {
if (!spec.hasTag("package_bp")) continue;
Global.getSector().getPlayerFleet().getCargo().addSpecial(new SpecialItemData(spec.getId(), ""), 1);
}

(https://i.imgur.com/fWWfkER.jpg)
Help my FPS is now 8

(https://i.imgur.com/WwkoeVm.png)
Oh no! It's getting every ship contained in the blueprint, and checking whether the player knows each of them! In each of the package blueprints, every frame!
Maybe it should cache the results or something?
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 25, 2022, 08:01:16 PM
Oof, thanks for digging into it! Definitely a case of "the special item plugin doing something ill-advised". Added caching there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BigBrainEnergy on September 25, 2022, 09:30:07 PM
I have a question and this seems like the right place for it - I'm making my first mod and I want parts of the ship to be on top of the weapons. How do I do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 25, 2022, 09:39:17 PM
I think Niko means one NPC fleet interrupting another. I don't think there is any way to do that.

By the way;

This is actually halfway wrong! reportFleetReachedEntity SOMETIMES reports when a fleet reaches its entity (ive found that fleets reaching their target fleet that they want to kill, e.g. interceptions, dont report). I've been using this to spawn fleets onto hostile fleets and engaging them in battles.

And so far, it actually kinda seems like the action is interrupted. It seems like I've delayed both satbombs and raids doing this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on September 25, 2022, 09:44:45 PM
Is there a way to have a faction use random portraits from all available ones? or at least the ones available from the players.faction that is kind abashed together from all your installed mods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 26, 2022, 04:30:47 AM
I have a question and this seems like the right place for it - I'm making my first mod and I want parts of the ship to be on top of the weapons. How do I do that?

Deco weapons. Look at Iron Shell or Volkov Industrial Conglomerate ships. They use lots of deco covers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 26, 2022, 07:02:55 AM
How do I 100% prevent a fleet from disengaging, ever, in both 1. Interaction dialog and 2. autoresolve?

My fleets are basically psuedo-stations that I always want to hold. However, since the interaction plugin uses a combined fleet with a standard modular AI rather than their custom AI, they often try to disengage. A interaction plugin only goes so far, because I found that retreating from a battle doesnt return my pluginpick for the next interaction (which btw has one condition: The battle is not null, and the battle has satellites involved). I have FIGHT_TO_THE_LAST set on them, btw.

And in autoresolve, they seem to enjoy disengaging, which sucks, because the second their battle ends, they immediately despawn.

Setting their station status to true is impossible, because this prevents them from joining station battles, which is an important part of my mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 26, 2022, 07:04:50 AM
On that topic, is there any way, precluding everyframe scripts and hijacking the autoresolve pluginpick to detect when a battle between 2 AI fleets has been created, or at least, inject ships into one side of the battle before autoresolve runs? Everyframes are gross and not performant, and the autoresolve plugin pick doesnt seem to inject ships fast enough, becauaes my satellites seem unscathed in the first round of every AI engagement. Plus they only spawn when autoresolvepluginpick is called, which is weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2022, 08:54:36 AM
By the way;

This is actually halfway wrong! reportFleetReachedEntity SOMETIMES reports when a fleet reaches its entity (ive found that fleets reaching their target fleet that they want to kill, e.g. interceptions, dont report). I've been using this to spawn fleets onto hostile fleets and engaging them in battles.

And so far, it actually kinda seems like the action is interrupted. It seems like I've delayed both satbombs and raids doing this.

Oh, interesting! I'd completely forgotten this was a thing. Taking a brief look, this appears to be based on the fleet AI assignment-handling module, hmm. I guess if it works it works?

Is there a way to have a faction use random portraits from all available ones? or at least the ones available from the players.faction that is kind abashed together from all your installed mods?

Aside from manually bashing them all together into a .faction file, I don't think so.

How do I 100% prevent a fleet from disengaging, ever, in both 1. Interaction dialog and 2. autoresolve?

My fleets are basically psuedo-stations that I always want to hold. However, since the interaction plugin uses a combined fleet with a standard modular AI rather than their custom AI, they often try to disengage. A interaction plugin only goes so far, because I found that retreating from a battle doesnt return my pluginpick for the next interaction (which btw has one condition: The battle is not null, and the battle has satellites involved). I have FIGHT_TO_THE_LAST set on them, btw.

And in autoresolve, they seem to enjoy disengaging, which sucks, because the second their battle ends, they immediately despawn.

Setting their station status to true is impossible, because this prevents them from joining station battles, which is an important part of my mod.

Hmm, you might try creating a custom AI module for the fleet - if it's AI is instanceof ModularFleetAIAPI, you can call ModularFleetAIAPI.setTacticalModule() to provide a custom implementation of the tactical module. Then you can have its pickEncounterOption() method always return ENGAGE or whatever the enum is. That should prevent it from retreating.

I don't know what you mean by "retreating from a battle doesnt return my pluginpick for the next interaction". In general, it would help if you could be a little more clear - I find myself having to read between the lines quite a bit.

On that topic, is there any way, precluding everyframe scripts and hijacking the autoresolve pluginpick to detect when a battle between 2 AI fleets has been created, or at least, inject ships into one side of the battle before autoresolve runs? Everyframes are gross and not performant, and the autoresolve plugin pick doesnt seem to inject ships fast enough, becauaes my satellites seem unscathed in the first round of every AI engagement. Plus they only spawn when autoresolvepluginpick is called, which is weird.

Honestly, it sounds like you have some bugs in there, the things you're describing don't make a lot of sense. How can it be not "fast enough"? And the spawning thing...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 26, 2022, 09:11:09 AM


How do I 100% prevent a fleet from disengaging, ever, in both 1. Interaction dialog and 2. autoresolve?

My fleets are basically psuedo-stations that I always want to hold. However, since the interaction plugin uses a combined fleet with a standard modular AI rather than their custom AI, they often try to disengage. A interaction plugin only goes so far, because I found that retreating from a battle doesnt return my pluginpick for the next interaction (which btw has one condition: The battle is not null, and the battle has satellites involved). I have FIGHT_TO_THE_LAST set on them, btw.

And in autoresolve, they seem to enjoy disengaging, which sucks, because the second their battle ends, they immediately despawn.

Setting their station status to true is impossible, because this prevents them from joining station battles, which is an important part of my mod.

Hmm, you might try creating a custom AI module for the fleet - if it's AI is instanceof ModularFleetAIAPI, you can call ModularFleetAIAPI.setTacticalModule() to provide a custom implementation of the tactical module. Then you can have its pickEncounterOption() method always return ENGAGE or whatever the enum is. That should prevent it from retreating.

I don't know what you mean by "retreating from a battle doesnt return my pluginpick for the next interaction". In general, it would help if you could be a little more clear - I find myself having to read between the lines quite a bit.

On that topic, is there any way, precluding everyframe scripts and hijacking the autoresolve pluginpick to detect when a battle between 2 AI fleets has been created, or at least, inject ships into one side of the battle before autoresolve runs? Everyframes are gross and not performant, and the autoresolve plugin pick doesnt seem to inject ships fast enough, becauaes my satellites seem unscathed in the first round of every AI engagement. Plus they only spawn when autoresolvepluginpick is called, which is weird.

Honestly, it sounds like you have some bugs in there, the things you're describing don't make a lot of sense. How can it be not "fast enough"? And the spawning thing...

Sorry about being unclear, I admit I kinda just... post, things. Without thinking. I'll try to be more clear in the future.

Anyway! My fleets DO have a custom AI, that always returns either HOLD or HOLD_VS_STRONGER.
For the first thing-fleetInteractionPluginImpl uses battle.getCombinedFleetFor(allies) on whatever method it uses for determining the goal of the fleets engaged, I think it's pickEncounterOption? Whatever the case, the combinedfleet, despite being called on a battleside with only one fleet (my satellites with a custom ai), generates a fleet with the same name as the fleet, but with a standard vanilla AI. I looked into getCombinedFleet and it seems it should be getting the primary, which is again, the satellite fleet, but it's getting something else, which is weird.

It also seems that autoresolve uses getCombinedFleet(), which I'm pretty sure also won't use my custom AI, leading to autoresolve rounds with satellites resulting in a disengagement, at times.

The for the 2nd, I use a CampaignPlugin and a getInteractionDialogPlugin override to return a custom interaction dialog plugin that overrides the fleetWantsToDisengage, fleetWantsToEngage/Fight (I forgot the name), and fleetIsHoldingVsStronger, but this method is only returned if the provided interactionTarget is a fleet, who has a battle that has satellites involved in it. In these overrides, it gets the battleside that the provided fleet (the combined fleet) is in, and scans for any fleets with my satellite fleet memkey. If I find one, I get it, and then call super.method(foundFleet) so my custom AI is actually used. This doesn't seem to be called, though, when the player side retreats and is forced into a second round of combat, leading to a disengage attempt at times.

For the 3rd, I should clarify; I use a getAutoresolvePlugin method in my campaignplugin, that always returns null. It runs a method that returns a list of sectorentitytokens that have defense satellites that want to join the battle. I get the side they want to join, then spawn fleets onto the battle with battle.join(newSatelliteFleet, side), then return null. It seems that these satellite fleets that are spawned don't engage in the autoresolve round that this method is called in, as they don't take any damage in this "round", when the other ships do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 26, 2022, 09:17:05 AM
Thank you for elaborating! Taking a step back, hmm. Might you not have an easier time if you keep the satellites for the visuals, use some kind of combat plugin to spawn them in player-facing battles, and provide a custom autoresolve plugin that counts them for autoresolves? Trying to handle them as "fleets" when they're not, not really, doesn't seem like a viable way to go.

E.G. the core game does this with stations but there are *a ton* of hacks to make that work and you don't have the benefit of being able to make those kinds of hacks in core code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 26, 2022, 09:36:48 AM
Thank you for elaborating! Taking a step back, hmm. Might you not have an easier time if you keep the satellites for the visuals, use some kind of combat plugin to spawn them in player-facing battles, and provide a custom autoresolve plugin that counts them for autoresolves? Trying to handle them as "fleets" when they're not, not really, doesn't seem like a viable way to go.

E.G. the core game does this with stations but there are *a ton* of hacks to make that work and you don't have the benefit of being able to make those kinds of hacks in core code.

While I agree that it's a headache to handle things this way, it's also, in my eyes, essential for a lot of functionality of it.
For example, it's almost entirely impossible to have the behavior where fleets are interrupted apon interacting with the planet without having a fleet spawning and interrupting them, although I /guess/ I could give them an alternate assignment? But even then, it will remove a lot of expected functioality. Examples: Fleets moving into assist the battle against the satellites, the battle contributing to debris fields, the satellites spawning as derelicts (they dont, but I want them to), them contributing to a fleet's decision to disengage or engage, battle difficulty. It's also important to note that fleets moving to assist the battle is, in my eyes, pretty important behavior, since when a battle ends, all ships on the opposite side of a satellite fleet will be given a "grace" period where they can freely interact with the market. This is pretty important for stuff like raids.
It's also really nice to have them there, just to know whos currently fighting satellites. The player also won't be able to visually see the satellites and their variants as they move to engage, so it removes a little bit of decision making, there.

I'd argue trying to emulate most of the behavior of a fleet battle would be even more of a headache.
It also may surprise you to know that this system actually works very well, except for the autoresolve and disengagement. It doesn't actually have that many bugs as far as I can tell, with the exception of a bunch I invariably haven't discovered.

Also, I'm trying to minimize my use of plugins as much as I can, as they're incompatability hell (hence why I want to remove my interactiondialog plugin). But honestly, an autoresolve plugin might be the best bet, since the only other option is an everyframescript, and I like those even less due to the performance cost. Although I guess I could just slow down the execution of the everyframe, maybe? That'd help, I suppose.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wisdomcube2000 on September 29, 2022, 04:08:31 PM
Forgive the likely dumb noobish question, but I was making strikecraft for that AA mod and trying to equip some missiles/torpedoes to them. Problem is that setting the weapon mount to hidden doesn't hide those weapons (so they appear on top and obscure a good portion of the craft in a really ugly way), so is there a way to hide them? Or perhaps make them render below the hull? I wouldn't mind that with just the tips sticking out from under the wing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 29, 2022, 04:41:24 PM
Deco weapons can cover missiles. Look at the Iron Shell or Volkov Industrial Conglomerate mods for examples.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 29, 2022, 04:54:12 PM
How did you manage to make Starsector so free of bugs as it is?  It is remarkably stable and even tolerates some modding mistakes.  Do you have some monster test suite? :O
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 29, 2022, 05:22:08 PM
Is there a way to iterate over all of the constellations in a sector?
I can see getStarSystems, but iterating over every system to get it's constellation to get it's systems feels inefficient, even if I check for which systems I've looked at before.

How did you manage to make Starsector so free of bugs as it is?  It is remarkably stable and even tolerates some modding mistakes.  Do you have some monster test suite? :O

I'd wager that a decade+ of dev time & the "when it's ready" release schedule play 2 big parts in that
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2022, 05:43:57 PM
Is there a way to iterate over all of the constellations in a sector?
I can see getStarSystems, but iterating over every system to get it's constellation to get it's systems feels inefficient, even if I check for which systems I've looked at before.

Code
Set<Constellation> constellations = new HashSet<Constellation>();
for (StarSystemAPI system : CampaignEngine.getInstance().getStarSystems()) {
if (!system.isInConstellation()) continue;
Constellation c = system.getConstellation();
if (c != null) constellations.add(c);
}

Depending on what you're doing (i.e. almost anything) I wouldn't worry about inefficiency there. Each constellation has what, maybe 7-8 stars max? So it's just a constant factor, and the difference in the amount of time it takes to iterate the systems and the constellations is going to be negligible in practice. Unless you're doing it like 1000 times per frame for some reason, in which case that constant factor would matter a lot, but then there are also *other problems* :)

Possibly a good place to mention the "premature optimization is the root of all evil" dictum. Basically, the things that seem like they're going to be problems often just aren't, and performance bottlenecks often crop up in places you wouldn't expect. This doesn't mean that one shouldn't think about it ahead of time at least a little and not do obviously bad things, but just... there's a whole lot of stuff there's no reason to worry about.

(How might it be "evil" in this case? Well, let's say there was a list of constellations, separate from the list of star systems. That'd have to be maintained, so it'd be at least theoretically possible for the list of constellations to become out of sync with the stars that are in the game. Added complexity in the name of performance, and a new place with potential for bugs.)

How did you manage to make Starsector so free of bugs as it is?  It is remarkably stable and even tolerates some modding mistakes.  Do you have some monster test suite? :O

I'd wager that a decade+ of dev time & the "when it's ready" release schedule play 2 big parts in that

Players reporting bugs is also a huge part of it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on September 29, 2022, 06:22:11 PM
Players reporting bugs is also a huge part of it!

Wow... over a decade.  That's incredible.  o_o  I wish you riches, joy, and satisfaction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wisdomcube2000 on September 29, 2022, 09:05:28 PM
Deco weapons can cover missiles. Look at the Iron Shell or Volkov Industrial Conglomerate mods for examples.
Ah that is a clever workaround. Thanks for the guidance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 30, 2022, 05:06:04 AM
Is there any way to force a specific hull to always try to maintain a specific facing? I currently use an everyframescript to make it so that it's always /forced/ to face the way I want it to, but I like having the ship AI handle it more. I would also make a custom AI, but I sadly don't understand ship AI at all, as it's all obfuscated.

To elaborate a little more, I spawn ~3 satellites into combat under certain conditions, and give them a fixedPosition with setFixedPosition(). If they are at the bottom of the map, they are supposed to always try to look up. If they are at the top, they are supposed to always try to look down. I already handle this with a script, but I think it'd be way more "organic" if their AI just did it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 30, 2022, 06:47:29 AM
Is disabling turning entirely a non-option?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on September 30, 2022, 06:52:45 AM
Is disabling turning entirely a non-option?

That's what's currently happening with the script. The thing is, with a fixed location, the satellite never turns. Ever. Unless it's forced to turn, which it often is, due to flameouts and colissions. So it can be turned that way without the script, and it won't ever turn back to it's original orientation.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on September 30, 2022, 12:30:35 PM
That's what's currently happening with the script. The thing is, with a fixed location, the satellite never turns. Ever. Unless it's forced to turn, which it often is, due to flameouts and colissions. So it can be turned that way without the script, and it won't ever turn back to it's original orientation.
What about using .getFacing() and then turning it left and right as appropriate?



I want to check all the hullmods on a ship for certain tags as part of isApplicableToShip, but I know neither how to iterate though all of them, or how to check what tags they have. (Update: Resolved thanks to Ruddy)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 01, 2022, 02:29:30 AM
Is there a way to offset a shield's angle?

Edit: Follow-up question/statement:
Playing around with logistics hullmods, it seems that if I add isApplicableToShip, then it no longer checks the maximum number of logistics hullmods. However, looking through BaseLogisticsHullMod and BaseHullMod, I can't see why that is (or how to correct for it)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 01, 2022, 07:35:26 AM
That's what's currently happening with the script. The thing is, with a fixed location, the satellite never turns. Ever. Unless it's forced to turn, which it often is, due to flameouts and colissions. So it can be turned that way without the script, and it won't ever turn back to it's original orientation.
What about using .getFacing() and then turning it left and right as appropriate?

That's not ideal, because I'd just get really janky movement that can't be stopped, even if engines are flamed out. I want to do it through AI as that's the cleanest and most organic way to do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 01, 2022, 08:30:12 AM
Not sure if this is even the correct sub-forum to post this, but...

Is there a way to display more than just four saved variants in the Refit screen? I vaguely recall (in older releases of Starsector) a variant screen that showed a list of saved variants, rather than the current graphical presentation that is limited to said four variants.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2022, 09:36:04 AM
Is there any way to force a specific hull to always try to maintain a specific facing? I currently use an everyframescript to make it so that it's always /forced/ to face the way I want it to, but I like having the ship AI handle it more. I would also make a custom AI, but I sadly don't understand ship AI at all, as it's all obfuscated.

To elaborate a little more, I spawn ~3 satellites into combat under certain conditions, and give them a fixedPosition with setFixedPosition(). If they are at the bottom of the map, they are supposed to always try to look up. If they are at the top, they are supposed to always try to look down. I already handle this with a script, but I think it'd be way more "organic" if their AI just did it.

I don't think there is, no - sorry! (Drones can be set to do something kiiiinda similar with facings, but it's all specific to orbiting around a ship.)


Is there a way to offset a shield's angle?

I don't think so. Beyond scripting the shield angle directly, I suppose.

Edit: Follow-up question/statement:
Playing around with logistics hullmods, it seems that if I add isApplicableToShip, then it no longer checks the maximum number of logistics hullmods. However, looking through BaseLogisticsHullMod and BaseHullMod, I can't see why that is (or how to correct for it)?

This isn't really enough info, hmm. Though I suspect it's *probably* because you're not calling the superclass implementation of isApplicableToShip() and doing something useful with the results? If you provide your own implementation, that parent class method gets overridden by yours.


Is there a way to display more than just four saved variants in the Refit screen? I vaguely recall (in older releases of Starsector) a variant screen that showed a list of saved variants, rather than the current graphical presentation that is limited to said four variants.

There is not, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 01, 2022, 09:48:35 AM
Though I suspect it's *probably* because you're not calling the superclass implementation of isApplicableToShip() and doing something useful with the results?
Complete novice question, how would I do that?
This is what I have, how would I need to adjust it?
Code
@Override
public boolean isApplicableToShip(ShipAPI ship) {
        if (HullmodLib.BlockedByTag(ship, HLHmid)) return false;
return true;
}

@Override
public String getUnapplicableReason(ShipAPI ship) {
if (HullmodLib.BlockedByTag(ship, HLHmid)) {
String blocker = HullmodLib.BlockerName(ship, HLHmid);
return "Incompatible with "+blocker;
}
return null;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 01, 2022, 10:05:52 AM
Something like:

if (!super.isApplicableToship(ship)) return false;

And then a similar if statement in getUnapplicableReason(), returning super.getUnapplicableReason()


The basic logic is "if the parent class implementation says it's unapplicable, say it's unapplicable, and return the right reason for it"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 01, 2022, 10:32:26 AM
Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 01, 2022, 11:01:06 AM
I think I asked this before, but never got a response (unless I did, in which case, I'm dumb).

Can anyone help me figure out this really weird fleet behavior? I use the following code:

Code
        else { //no battle? fine, i'll MAKE MY OWN
            satelliteFleet.clearAssignments(); // just in case the hold assignment all satellite fleets get is *** with a few things
            satelliteFleet.addAssignmentAtStart(FleetAssignment.INTERCEPT, fleet, 999999999, null); // again, sanity
            fleet.addAssignmentAtStart(FleetAssignment.INTERCEPT, satelliteFleet, 1, null);

            BattleAPI newBattle = Global.getFactory().createBattle(satelliteFleet, fleet); // force the satellite to engage the enemy

            // removing the createBattle doesnt fix the god damn issue where fleets drift

            battleJoined = newBattle;
        }
to spawn a satellite fleet on top of a fleet and engage them in combat if they were not already engaged in battle. The code for spawning a satellite fleet is:
Code
    public CampaignFleetAPI spawnSatelliteFleet(@NotNull Vector2f coordinates, @NotNull LocationAPI location, boolean temporary, boolean dummy) {
        CampaignFleetAPI satelliteFleet = createSatelliteFleetTemplate();

        location.addEntity(satelliteFleet);
        satelliteFleet.setLocation(coordinates.x, coordinates.y);
        if (temporary) {
            niko_MPC_temporarySatelliteFleetDespawner script = new niko_MPC_temporarySatelliteFleetDespawner(satelliteFleet, this);
            satelliteFleet.addScript(script);
            satelliteFleet.getMemoryWithoutUpdate().set(niko_MPC_ids.temporaryFleetDespawnerId, script);
        }

        satelliteFleet.addAssignment(FleetAssignment.HOLD, location.createToken(coordinates), 99999999f);

        if (dummy) {
            newDummySatellite(satelliteFleet);
        }
        else {
            newSatellite(satelliteFleet);
        }

        return satelliteFleet;
    }
, and
Code
    public CampaignFleetAPI createSatelliteFleetTemplate() {

        CampaignFleetAPI fleet = Global.getFactory().createEmptyFleet(getCurrentSatelliteFactionId(), getSatelliteFleetName(), true);
       // fleet.setFaction(getCurrentSatelliteFactionId());
        setTemplateMemoryKeys(fleet);

        fleet.setAI(new niko_MPC_satelliteFleetAI((CampaignFleet) fleet));
        fleet.addEventListener(new niko_MPC_satelliteFleetDespawnListener());

        PersonAPI aiCaptain = new AICoreOfficerPluginImpl().createPerson(Commodities.GAMMA_CORE, "derelict", null);
        fleet.setCommander(aiCaptain);

        return fleet;
    }
. The fleet AI is nothing special, it only overrides wantsToJoin and pickEncounterOption.

This is only called when a fleet reaches their interaction target, through the reportFleetReachedEntity listener. This works perfectly except for the fact that fleets act REALLY weird when you I do this. In this case, the fleet we spawn on seems to maintain their velocity and not do the "normal" thing of stop and fight the enemy. This still happens if I give the satellite fleet a intercept order and not create a new battle (relying on the satellitefleet's AI to attack the fleet). Other fleets that attack the fleets behave normally.
If I force the satellitefleet into an orbit around the planet, the fleet will actually kind of /loop around/ (as if "orbitting" in a very loose fashion) the satellite fleet, but it still won't have the expected behavior of stopping. In this scenario, any external fleet coming in to fight will also do this weird "loop" instead of stopping and fighting.
In case you wonder what I mean by "expected behavior of stopping", I mean I've always seen fleets fighting eachother kinda bump into eachother before backing off just enough to get their fleet circle borders touching and then stopping.

A video illustrating what I mean: https://cdn.discordapp.com/attachments/824910699415207937/1025820788667985991/Jdk7_2022.10.01_-_13.24.53.02.mp4

Ideally, I'd be able to keep using the createBattle method, as I store the battle in a global list for future reference.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on October 01, 2022, 11:09:24 AM
Is there some trick to getting mercenaries to use a ship?

I have 4 skins for one of my ships (Persean, Sindrian, Hegemony, and Mercenary). The three main factions use theirs pretty often, but I've never seen the mercenary version show up. They do use the base version of the hull, but never their exclusive version.

I've gone thought the code multiple times, but it's all being used the same for all 4 types. No errors in the log for that ship, skin, or variant either. Also doesn't seem to be a mod conflict, as I've done runs with my mod being the only enabled one and still no sightings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 01, 2022, 09:54:35 PM
Is there some trick to getting mercenaries to use a ship?

I have 4 skins for one of my ships (Persean, Sindrian, Hegemony, and Mercenary). The three main factions use theirs pretty often, but I've never seen the mercenary version show up. They do use the base version of the hull, but never their exclusive version.

I've gone thought the code multiple times, but it's all being used the same for all 4 types. No errors in the log for that ship, skin, or variant either. Also doesn't seem to be a mod conflict, as I've done runs with my mod being the only enabled one and still no sightings.
Is this just for making the skin appear in the usual autogenerated merc fleets?
If so, check if they do know the ship (requires merc tag, mercs normally don't use any other ships) by entering factioninfo mercenary in console.


How do I get a list of markets producing a given commodity?

Currently I'm going through all markets in economy and checking if they have CommoditySourceType.LOCAL for my commodity (as specified in the market's MarketShareDataAPI). But this misses any markets that are net importers, e.g. supplies on Sindria.
CommodityMarketDataAPI.getSortedProducers looks like it'd be perfect, except there's no way to get a MarketAPI from a MarketShareDataAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on October 02, 2022, 07:17:39 AM
How does hullmod stat stacking work when using the modifyMult method on one stat?

Let us say I have a 3 hullmods that modify damage, one hullmod increases the damage by 2x, the second one reduces the damage by 1.25x and the last one increases it by 1.5x. Does it apply it one by one and if it does what determines the first one to be applied? if not how does those stats stack with each other then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 02, 2022, 09:21:20 AM
How does hullmod stat stacking work when using the modifyMult method on one stat?

Let us say I have a 3 hullmods that modify damage, one hullmod increases the damage by 2x, the second one reduces the damage by 1.25x and the last one increases it by 1.5x. Does it apply it one by one and if it does what determines the first one to be applied? if not how does those stats stack with each other then?
Why would it matter, it's all order agnostic?
5x2x0.5 = 0.5x5x2 = 5x0.5x2
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cry0genic on October 02, 2022, 09:23:52 AM
Is there a way of changing the illustrations that replaces the rotating 3D view of the planet when we dock for modded planets that doesn't need recompiling? Please correct me if I'm wrong, but the only way I know of is to open the source code for the planets, input setinteractionimage for the planet and then recompile it. Are there an easier way to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on October 02, 2022, 10:24:00 AM
Why would it matter, it's all order agnostic?
5x2x0.5 = 0.5x5x2 = 5x0.5x2
Oh yeah, brain farting again its around 2am here XD
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on October 02, 2022, 10:57:25 AM
Is there some trick to getting mercenaries to use a ship?

I have 4 skins for one of my ships (Persean, Sindrian, Hegemony, and Mercenary). The three main factions use theirs pretty often, but I've never seen the mercenary version show up. They do use the base version of the hull, but never their exclusive version.

I've gone thought the code multiple times, but it's all being used the same for all 4 types. No errors in the log for that ship, skin, or variant either. Also doesn't seem to be a mod conflict, as I've done runs with my mod being the only enabled one and still no sightings.
Is this just for making the skin appear in the usual autogenerated merc fleets?
If so, check if they do know the ship (requires merc tag, mercs normally don't use any other ships) by entering factioninfo mercenary in console.

Yeah, shows up in their list of ships when I run that.

And I have this in the mercenary.faction file, which is just how I did it for the 3 main factions:

Code
{
    "hullFrequency":{
        "hulls":{
            "stardust_plasmaburst":0.3,
            "stardust_plasmaburst_merc":0.7,
        },
    },
    "knownShips":{
        "hulls":[
            "stardust_plasmaburst_merc",
        ],
    },
}

Really odd that it won't show up. And I have spawned one into my fleet and used it fine, so nothing wrong with the ship itself. The mercenaries just...don't want to use it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 02, 2022, 11:29:06 AM
Does it have an assigned defaultShipRoles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on October 02, 2022, 11:44:34 AM
Does it have an assigned defaultShipRoles?

Yeah, in with the other 3 variants at the same weight (5).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 02, 2022, 01:57:47 PM
Why, on game load, specifically, when conditions are applied to a market, are like, half the variables null, of CampaignPlanets, specifically, market.getPrimaryEntity()? Name is null, id is null, hell SCRIPTS is null (which is causing a very annoying NPE in my mod).

I must ask: Why? BaseCampaignEntity has a lot of these things (like script) be assigned something not-null (like a new arraylist) on constructor, so why is this... happening?

I believe this is the 3rd stage of loading, btw.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 02, 2022, 03:20:10 PM
Testing out some code I modified from Content Unlocking Missions (added to a simulator mission's MissionDefinition.json) for reporting skills added to ship captains in those missions, and setting Combat Readiness (up to a fixed limit of 100) if a hullmod or skill raises a ship's max CR above the default of 70:
Quote
      api.addPlugin(new BaseEveryFrameCombatPlugin() {
         public void init(CombatEngineAPI engine) {}
         public void advance(float amount, List events) {
            if (Global.getCombatEngine().isPaused()) {
               return;
            }
            for (ShipAPI ship : Global.getCombatEngine().getShips()) {
               if (ship.getCustomData().get("poopystinky") == null) {
                  if (ship.getCaptain() != null && ship.getOwner() == 0 && ship.getCaptain().getStats().getSkillsCopy().size() > 4) {
                     String text = "";
                     for (int u = 4; u < ship.getCaptain().getStats().getSkillsCopy().size(); u++) {
                        if (u < ship.getCaptain().getStats().getSkillsCopy().size()-1) {text = text+(((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getLevel() > 1 ?  ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+"+, " :  ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+", ");} else {text = text+(((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getLevel() > 1 ? ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+"+." :  ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+".");}
                     }
                     if (ship.getFleetMember() != null && ship.getHullSize() != HullSize.FIGHTER) {
                        Global.getCombatEngine().getCombatUI().addMessage(1, ship.getFleetMember(), Misc.getPositiveHighlightColor(), ship.getName(), Misc.getTextColor(), "", Global.getSettings().getColor("standardTextColor"), "is skilled in "+text);
                     }
                  }
                  ship.setCurrentCR(ship.getCurrentCR()+ship.getMutableStats().getMaxCombatReadiness().getModifiedValue()); //Properly adds the max CR, for some reason it cannot be caught as FleetMemberAPI or this would have been easier...
                  ship.setCRAtDeployment(ship.getCRAtDeployment()+ship.getMutableStats().getMaxCombatReadiness().getModifiedValue()); //This only affects the "score" result of said mission, but the algorithm is mostly 100% since you have to basically LOSE ships to lose score. I don't think this needs setting, but eh couldn't help but tried.
                  if (ship.getCurrentCR() > 1.0f)
                     ship.setCRAtDeployment(1.0f);
                  ship.setCustomData("poopystinky", true); //Fires once per ship.
               }
            }
         }
      });
I managed to modify the code so that it doesn't CTD if fighter wings had skills of their own (test situation; some other mods' own hullmods which do that), but couldn't get it to not CTD if skills were added to the captain of a super-capital (as in, ship entry in ship_data.csv has the 'SHIP_WITH_MODULES' tag, and its .variant file has a 'modules' field).

Commenting out the following line prevents the CTD, but also won't show any added skills as the trade-off:

Global.getCombatEngine().getCombatUI().addMessage(1, ship.getFleetMember(), Misc.getPositiveHighlightColor(), ship.getName(), Misc.getTextColor(), "", Global.getSettings().getColor("standardTextColor"), "is skilled in "+text);

And clues on how to avert that, other than just commenting out said line?

EDIT: Added relevant crash data from starsector.log:
Quote
87564 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.<init>(Unknown Source)
   at com.fs.starfarer.E.C.super(Unknown Source)
   at com.fs.starfarer.combat.CombatState.addMessage(Unknown Source)
   at data.missions.ed_showcasewurg.MissionDefinition$1.advance(MissionDefinition.java:174)
   at com.fs.starfarer.title.Object.L$Oo.o00000(Unknown Source)
   at com.fs.starfarer.combat.A.new.o00000(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 02, 2022, 03:58:51 PM
Just do (ship != null) as well. Modules don't need captain pop-up (because they should be the same as their main ship).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 02, 2022, 04:40:57 PM
Just do (ship != null) as well. Modules don't need captain pop-up (because they should be the same as their main ship).
Made that change as follows:
Code
							if (ship.getFleetMember() != null && ship.getHullSize() != HullSize.FIGHTER && ship != null) {
Global.getCombatEngine().getCombatUI().addMessage(1, ship.getFleetMember(), Misc.getPositiveHighlightColor(), ship.getName(), Misc.getTextColor(), "", Global.getSettings().getColor("standardTextColor"), "is skilled in "+text);
}

Still got a CTD, with the following starsector.log segment:
Quote
115346 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.<init>(Unknown Source)
   at com.fs.starfarer.E.C.super(Unknown Source)
   at com.fs.starfarer.combat.CombatState.addMessage(Unknown Source)
   at data.missions.ed_showcasewurg.MissionDefinition$1.advance(MissionDefinition.java:184)
   at com.fs.starfarer.title.Object.L$Oo.o00000(Unknown Source)
   at com.fs.starfarer.combat.A.new.o00000(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)
So what did I do wrong? Added the 'ship != null' conditional check in the wrong location?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 02, 2022, 06:16:41 PM
Your ship != null check needs to be before the other two checks (since those already expect a non-null ship)

@niko Did you see this link (https://fractalsoftworks.com/forum/index.php?topic=15563) I showed you on Discord last time? It sounded like the problem you were having with the entity being disconnected from its market.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 02, 2022, 06:37:33 PM
Your ship != null check needs to be before the other two checks (since those already expect a non-null ship)

Made that change and still got the CTD:
Code
if (ship != null && ship.getFleetMember() != null && ship.getHullSize() != HullSize.FIGHTER) {
Global.getCombatEngine().getCombatUI().addMessage(1, ship.getFleetMember(), Misc.getPositiveHighlightColor(), ship.getName(), Misc.getTextColor(), "", Global.getSettings().getColor("standardTextColor"), "is skilled in "+text);
}
Attached starsector.log file snippet:
Quote
103061 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.<init>(Unknown Source)
   at com.fs.starfarer.E.C.super(Unknown Source)
   at com.fs.starfarer.combat.CombatState.addMessage(Unknown Source)
   at data.missions.ed_showcasewurg.MissionDefinition$1.advance(MissionDefinition.java:174)
   at com.fs.starfarer.title.Object.L$Oo.o00000(Unknown Source)
   at com.fs.starfarer.combat.A.new.o00000(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)
At a glance, the error message is identical, just pointing to a different line # (since I deleted some un-necessary / duplicate lines closer to the top), still points to the same line generating the CTD if not commented out).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 02, 2022, 06:37:59 PM
How do I get a list of markets producing a given commodity?

Currently I'm going through all markets in economy and checking if they have CommoditySourceType.LOCAL for my commodity (as specified in the market's MarketShareDataAPI). But this misses any markets that are net importers, e.g. supplies on Sindria.
CommodityMarketDataAPI.getSortedProducers looks like it'd be perfect, except there's no way to get a MarketAPI from a MarketShareDataAPI.

Iterating through the markets and calling CommodityOnMarketAPI.getMaxSupply() for the commodity you're interested in should do it.


I think I asked this before, but never got a response (unless I did, in which case, I'm dumb).

(... honestly, I have no idea!)

Is there a way of changing the illustrations that replaces the rotating 3D view of the planet when we dock for modded planets that doesn't need recompiling? Please correct me if I'm wrong, but the only way I know of is to open the source code for the planets, input setinteractionimage for the planet and then recompile it. Are there an easier way to do this?

Something needs to call that code - either using the console commands, or - as you say - by editing the sector gen files.


Why, on game load, specifically, when conditions are applied to a market, are like, half the variables null, of CampaignPlanets, specifically, market.getPrimaryEntity()? Name is null, id is null, hell SCRIPTS is null (which is causing a very annoying NPE in my mod).

I must ask: Why? BaseCampaignEntity has a lot of these things (like script) be assigned something not-null (like a new arraylist) on constructor, so why is this... happening?

I believe this is the 3rd stage of loading, btw.

Stuff's getting loaded, and you generally can't count on the order it's loaded in, and when the objects are instantiated from the savefile, the default constructor isn't called, iirc. So if your code runs midway through the load process it needs to be real careful about what it's using and to bail out if something is null that otherwise *can't* be null. Though it seems like mods wouldn't mostly be running into this sort of thing, hmm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 02, 2022, 06:45:03 PM

I think I asked this before, but never got a response (unless I did, in which case, I'm dumb).

(... honestly, I have no idea!)

Why, on game load, specifically, when conditions are applied to a market, are like, half the variables null, of CampaignPlanets, specifically, market.getPrimaryEntity()? Name is null, id is null, hell SCRIPTS is null (which is causing a very annoying NPE in my mod).

I must ask: Why? BaseCampaignEntity has a lot of these things (like script) be assigned something not-null (like a new arraylist) on constructor, so why is this... happening?

I believe this is the 3rd stage of loading, btw.

Stuff's getting loaded, and you generally can't count on the order it's loaded in, and when the objects are instantiated from the savefile, the default constructor isn't called, iirc. So if your code runs midway through the load process it needs to be real careful about what it's using and to bail out if something is null that otherwise *can't* be null. Though it seems like mods wouldn't mostly be running into this sort of thing, hmm.

1. No idea if I asked before, or no idea of what's going on?
2. I guess that makes sense, but I just assumed all objects in java HAD to have their constructor called apon being instantiated. Maybe this is some reflection magic I'm unfamiliar with.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 02, 2022, 06:53:12 PM
@TimeDiver

Hmm, manually log (with Global.getLogger(class)) whether each of the params in the addMessage call is null or otherwise invalid input?

Also the addMessage javadoc says you can feed it a ShipAPI directly instead of getting a FleetMemberAPI first, so might be worth trying that (even if it doesn't fix the crash the code is cleaner).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 02, 2022, 06:56:51 PM
1. No idea if I asked before, or no idea of what's going on?

The latter, unfortunately. I didn't dig into it in a ton of detail, but nothing surface-level came to mind.

Maybe this is some reflection magic I'm unfamiliar with.

(Yep! I remember being a bit surprised myself, but it makes sense that it'd have to work this way if you think about it...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on October 02, 2022, 07:20:27 PM
@TimeDiver

Hmm, manually log (with Global.getLogger(class)) whether each of the params in the addMessage call is null or otherwise invalid input?

Also the addMessage javadoc says you can feed it a ShipAPI directly instead of getting a FleetMemberAPI first, so might be worth trying that (even if it doesn't fix the crash the code is cleaner).
Thanks for the feedback, but I went with a kludge-y workaround; I changed the mission's flagship from the super-capital to another ship w/o modules (and applied the skill changes to that ship's captain instead) and just transfer over to the super-capital once the mission starts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 02, 2022, 07:51:51 PM
1. No idea if I asked before, or no idea of what's going on?

The latter, unfortunately. I didn't dig into it in a ton of detail, but nothing surface-level came to mind.

Apparantly, according to a bunch of people on the unofficial discord, the bug shown in the video is actually not isolated to my mod. It happens in a bunch of saves, with varying levels of modding, and just, randomly. I haven't dug too deep into this, but from the sounds of it, this could be less of a isolated incident and some kind of underlying issue, potentially, with vanilla, although I won't discount the major possibility of some weird mod schenanigan. Here's what I asked people, and their responses:
Spoiler
https://discord.com/channels/187635036525166592/512356777451323393/1026320489687285800

niko: heloo starsector gamers
[10:31 PM]niko: has anyone ever had a weird bit of behavior in campaign where fleets fighting eachother sometimes drift away from eachother
[10:31 PM]niko: i was told tjhis was a vanilla bug at some point and im curious to if iti s
[10:31 PM]Underdrown: yeah 2 times now
[10:31 PM]mrmagolor: I've seen it
[10:32 PM]niko: really?
[10:32 PM]niko: hm
[10:32 PM]niko: https://cdn.discordapp.com/attachments/824910699415207937/1025820788667985991/Jdk7_2022.10.01_-_13.24.53.02.mp4
[10:32 PM]LifeOnHigh: same
[10:32 PM]niko: did it look like this?
[10:32 PM]niko: in any capacity?
[10:32 PM]LifeOnHigh: yes
[10:32 PM]Underdrown: yep
[10:32 PM]niko: how much in terms of similarity
[10:32 PM]niko: scale of 0% to 100%
[10:32 PM]Underdrown: even more faster for me
[10:33 PM]LifeOnHigh: happens all the time for me
[10:33 PM]niko: they just
[10:33 PM]niko: infinitely drift apart?
[10:33 PM]Yholl: yeah it happens
[10:33 PM]Underdrown: yes
[10:33 PM]niko: as if the fleets maintained their velocity
[10:33 PM]niko: and final question has anyone encountered this with only libs/very light mods
[10:33 PM]niko: /no mods
[10:33 PM]niko: i ask
[10:33 PM]niko: because im wondering if is hould tell alex this is a vanilla bug
[10:35 PM]niko: 'cause if its a vanilla bug
[10:35 PM]niko: my mod has a 100% replication rate

https://discord.com/channels/187635036525166592/187635036525166592/1026321715556520037
[10:36 PM]niko: https://discord.com/channels/187635036525166592/512356777451323393/1026320440374874222

^ i require your feedback, read the thread on this and tell me your answers to the questions if youve got any
[10:36 PM]Lasersquid112: yes, fleets will occasionally float away in combat
[10:36 PM]niko: to a similar extent to the video shown?
[10:36 PM]niko: (also important to ask how heavily your game is modded)
[10:37 PM]Jaiden1121: ive seen them fly further
[10:37 PM]Jaiden1121: they even get hit by replicating minefields when flying in combat
[10:37 PM]niko: damn
[10:37 PM]niko: okay
[10:37 PM]niko: interesting
[10:37 PM]Lasersquid112: that's legit nothing lol
[10:37 PM]Lasersquid112: they can drift forever if the battle goes long enough
[10:38 PM]niko: aight im gonna tell alex 'bout this since
[10:38 PM]niko: they dont seem aware this might be a vanilla bug
[10:38 PM]dynz: 'might'
[10:38 PM]niko: or
[10:38 PM]niko: somethin
[10:38 PM]Jaiden1121: pfft keep it
[10:38 PM]niko: ...wait nevermind i still dont know how modded the games are
[10:38 PM]niko: fools tell me
[10:38 PM]Jaiden1121: mine is modded moderately lightly
[10:38 PM]Lasersquid112: i have like,,
[10:38 PM]Lasersquid112: 127 mods?
[10:38 PM]niko: jeesus
[10:38 PM]Lasersquid112: or something idk
10:43 PM]niko: could you like, elaborate a little, for the report im gonna make to em?
[10:43 PM]niko: like, when does it happen, in what context, etc
10:43 PM]niko: and how bad
[10:44 PM]Jaiden1121: it usually happens when two large fleets fight for a bit, albeit in my experience its happened most with stations
[10:44 PM]PixiCode: I've never seen drift that bad, but i have seen drift
[10:44 PM]niko: is there any notiucable difference in the context surrounding the battles that do this compared to normal battles
[10:45 PM]Jaiden1121: non station simply starts orbiting? i guess the station faster and faster, while still being able to be effected my environmental effects such as asteroids, or in my case, mines lol
[10:45 PM]niko: (ex. the incoming fleet is going mach 9)
[10:45 PM]PixiCode: I would like to help more but it happens so rarely I don't have any details
[10:45 PM]Jaiden1121: now that? i didnt look far enough into to notice
[10:45 PM]niko: interesting
[10:45 PM]niko: thats real interesting actually
[10:45 PM]niko: because it emulates behavior of my mod when i set an orbit on my satellites
[10:45 PM]niko: thanks
[10:45 PM]niko: thisll help
[close]


And here's the modlist of jaiden:
Spoiler
(https://i.imgur.com/dIZUnOl.png)
[close]
The only mods enabled in my game are magiclib, lazylib, MPC, and console commands.

What I find really interesting is what Jaiden said about fleets "orbitting" the fleet they're attacking-this behavior sounds suspiciously similar to what happens when I give my satellite fleet a orbit around the planet. If you remember in my original post, I said attacking fleets would loosely "orbit" the satellite fleet in that scenario, same thing that might be happening here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 02, 2022, 09:10:58 PM
So what did I do wrong? Added the 'ship != null' conditional check in the wrong location?
Yes, it should be first before the first 2 checks. You already got it with that answer
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on October 03, 2022, 09:14:42 AM
any way we can get smething like ShipAPI.get/setCustomData except for FleetMemberAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 03, 2022, 03:01:51 PM
Can a ShipAPI get its "factionid" of its side it's fighting on or is it just fairly limited to getOwner() being enemy, friendly, or hostile?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 03, 2022, 05:07:41 PM
Can a ShipAPI get its "factionid" of its side it's fighting on or is it just fairly limited to getOwner() being enemy, friendly, or hostile?

BattleSide is not bound to a faction. IT can be a mix of different factions. Try ShipAPI.getFleetMember().getFleet().getFaction(), or some variation of that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cry0genic on October 03, 2022, 08:21:11 PM
Something needs to call that code - either using the console commands, or - as you say - by editing the sector gen files.

That it is doable through console commands is a great relief. I'll now try to figure out how to do so through it, thanks for the reply!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2022, 06:48:08 PM
...
What I find really interesting is what Jaiden said about fleets "orbitting" the fleet they're attacking-this behavior sounds suspiciously similar to what happens when I give my satellite fleet a orbit around the planet. If you remember in my original post, I said attacking fleets would loosely "orbit" the satellite fleet in that scenario, same thing that might be happening here.

Thanks for the info, I'll keep an eye out for it!

Given that your stuff is directly messing with the fleet AI, however, it seems pretty likely that that's somehow the culprit, no?

any way we can get smething like ShipAPI.get/setCustomData except for FleetMemberAPI?

I'll keep it in mind! (In the meantime, you can keep some strings in the variant's tags, though that's going to be of limited usefulness...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 05, 2022, 03:46:38 AM
...
What I find really interesting is what Jaiden said about fleets "orbitting" the fleet they're attacking-this behavior sounds suspiciously similar to what happens when I give my satellite fleet a orbit around the planet. If you remember in my original post, I said attacking fleets would loosely "orbit" the satellite fleet in that scenario, same thing that might be happening here.

Thanks for the info, I'll keep an eye out for it!

Given that your stuff is directly messing with the fleet AI, however, it seems pretty likely that that's somehow the culprit, no?

It's possible, but given how the only extent of AI modification I do is this:
Spoiler
Code
public class niko_MPC_satelliteFleetAI extends ModularFleetAI {

    public niko_MPC_satelliteFleetAI(CampaignFleet campaignFleet) {
        super(campaignFleet);
    }

    @Override
    public boolean wantsToJoin(BattleAPI battle, boolean considerPlayTransponderStatus) {
        if (!niko_MPC_debugUtils.assertEntityHasSatellites(getFleet())) return true;

        niko_MPC_satelliteHandler handler = niko_MPC_satelliteUtils.getEntitySatelliteHandler(getFleet());
        niko_MPC_satelliteBattleTracker tracker = niko_MPC_satelliteUtils.getSatelliteBattleTracker();

        if (tracker.areSatellitesInvolvedInBattle(battle, handler)) {
            return false;
        }

        return true;
    }

   @Override
   public EncounterOption pickEncounterOption(FleetEncounterContextPlugin context, CampaignFleetAPI otherFleet, boolean pureCheck) {

        CampaignFleetAPI satelliteFleet = getFleet(); //todo: this *** sucks
        BattleAPI battle = satelliteFleet.getBattle();
        if (battle != null) {
            float effectiveHostileStrength = 0;
            for (CampaignFleetAPI hostileFleet : battle.getOtherSideFor(satelliteFleet)) {
                effectiveHostileStrength += hostileFleet.getEffectiveStrength();
            }
            if (satelliteFleet.getEffectiveStrength() < (effectiveHostileStrength)) {
                return EncounterOption.HOLD_VS_STRONGER;
            }
            else return EncounterOption.HOLD;
        }
        else {
            if ((satelliteFleet.getEffectiveStrength() < (otherFleet.getEffectiveStrength()))) {
                return EncounterOption.HOLD_VS_STRONGER;
            }
        }
        return EncounterOption.HOLD;
    }

    @Override
    public EncounterOption pickEncounterOption(FleetEncounterContextPlugin context, CampaignFleetAPI otherFleet) {
        return pickEncounterOption(context, otherFleet, false);
    }
}
[close]
which is an EXTENSION of ModularFleetAI, I have my doubts. This behavior is replicable even if I don't give the fleets an assignment as well (although the satellite fleet DOES have a Hold order always so it doesn't get flagged as "standing down" in the internals of AI). I'm not the person who works with the internal code every day, though, so I probably know less about this than you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 05, 2022, 03:55:58 AM
I absolutely see that battling drift away behavior in vanilla.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: boggled on October 05, 2022, 10:21:52 AM
In CampaignPlanet, the following methods are used to get and set the planet type:

Code
public String getTypeId() { return this.graphics.getType(); }

public void setTypeId(String var1) { this.type = var1; }

If you call setTypeId(), getTypeId() will continue to return the old value from graphics (which is a Planet object) until readResolve() is called and a new Planet object with the new type is set.

Code
protected Object readResolve() {
    super.readResolve();
    this.graphics = new Planet(this.type, this.radius, 0.0F, new Vector2f());

It appears that readResolve() can only be called when the save file is loaded, and there's no other way to update the Planet object with the new type until then, as type is private and has no setter method (and reflection is blocked).

This creates an issue because the Farming industry appears to use getTypeId() to figure out whether it's an aquaculture or not, and if the player terraforms the planet to or from a water world, then farming/aquaculture will be the wrong version until they reload the save.

It's possible I'm missing something - is there any way to update the type string stored in the graphics Planet object immediately for terraforming purposes?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on October 05, 2022, 01:57:55 PM
Am I missing a trick with weapon projectiles (.proj files)? Trying to create a ballistic projectile that splits on proximity:
   "behaviorSpec":{"behavior":"MIRV"
doesn't appear to work with:
   "specClass":"projectile",
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 05, 2022, 07:13:22 PM
I would like to add a weapon icon to a hull mods description through Tooltip.addImage

but...
WeaponSpecAPI.getHardpointSpriteName() and WeaponSpecAPI.getTurretSpriteName() might sometimes return weapons without barrels/recoil/missiles (like Needler)

and the ToolTipMakerAPI.addImage only accepts string not SpriteAPI. Does one exist where I can addImage through SpriteAPI or alternatively is there a way to grab the sprite image when it's displayed in codex or refit
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 05, 2022, 11:05:33 PM
I might have found a bug in the API: MissileSpecAPI.setFlightTime(float time) and MissileSpecAPI.setFlightTime(float time) do not change the flight time and flameout time of the MissileSpecAPI of every associated WeaponSpecAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Yunru on October 06, 2022, 12:28:36 AM
Am I missing a trick with weapon projectiles (.proj files)? Trying to create a ballistic projectile that splits on proximity:
   "behaviorSpec":{"behavior":"MIRV"
doesn't appear to work with:
   "specClass":"projectile",
The simplest way is to make the projectile a torpedo, although that does have some side effects.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 06, 2022, 07:40:55 AM
I absolutely see that battling drift away behavior in vanilla.

If you ever manage to snag a vanilla save where that's happening, I'd love to take a closer look! I don't think it's necessarily the same issue that NikoTheGuyDude is running into, though, the fleet movement in that video looked pretty fast and just different, to me at least. (I've seen some "battle drift" behavior before, though those causes iirc had been fixed.)

It's possible I'm missing something - is there any way to update the type string stored in the graphics Planet object immediately for terraforming purposes?

I'm not sure. What I can tell you is I was recently trying to do this, ran into no end of trouble, and added a PlanetAPI.changeType() method that takes care of a bunch of thorny under-the-hood details.


Am I missing a trick with weapon projectiles (.proj files)? Trying to create a ballistic projectile that splits on proximity:
   "behaviorSpec":{"behavior":"MIRV"
doesn't appear to work with:
   "specClass":"projectile",

You're right, it doesn't. IIRC the only behavior that works for ballistics is whatever the flak and simular use for proximity explosions.


I would like to add a weapon icon to a hull mods description through Tooltip.addImage

but...
WeaponSpecAPI.getHardpointSpriteName() and WeaponSpecAPI.getTurretSpriteName() might sometimes return weapons without barrels/recoil/missiles (like Needler)

and the ToolTipMakerAPI.addImage only accepts string not SpriteAPI. Does one exist where I can addImage through SpriteAPI or alternatively is there a way to grab the sprite image when it's displayed in codex or refit

There *is* no one sprite for weapons with barrels or missiles, it's composited together from the various pieces depending on how the weapon is set up. Your best bet might be to add something like TooltipMakerAPI.showCargo(), though that likely won't do quite what you want.

I might have found a bug in the API: MissileSpecAPI.setFlightTime(float time) and MissileSpecAPI.setFlightTime(float time) do not change the flight time and flameout time of the MissileSpecAPI of every associated WeaponSpecAPI.

The spec is clone()'ed when it's assigned to the various weapons. (Edit: having different missile stats in weapon_data.csv for weapons that share the same missile spec doesn't work, though, I don't think. I don't remember the details, if we're being honest! Now I'm wondering if maybe it *would* work now and if the clone() call is a more recent change. Regardless, though, not a bug!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 06, 2022, 08:07:12 AM
The spec is clone()'ed when it's assigned to the various weapons. (Edit: having different missile stats in weapon_data.csv for weapons that share the same missile spec doesn't work, though, I don't think. I don't remember the details, if we're being honest! Now I'm wondering if maybe it *would* work now and if the clone() call is a more recent change. Regardless, though, not a bug!)

Glad it's not a bug!   On the other hand, modifying the EngineSpecAPI of the ShipHullSpecAPI of the MissileSpecAPI of one WeaponSpecAPI modifies the same of all such MissileSpecAPI, despite their being cloned.  In other words, if I double the acceleration of the missile of the Harpoon (Single) and then double the acceleration of the missile of the Harpoon (double) then the acceleration of the Harpoon (double) will be four times what it originally was instead of two.  That is, the following code,

Code
private static void getEngineSpec(final WeaponSpecAPI weaponSpec) {
    return ((MissileSpecAPI) (weaponSpecAPI.getProjectileSpecAPI)).getEngineSpecAPI();
}

private static void doubleAcceleration(final WeaponSpecAPI weaponSpec) {
    engineSpec.setAcceleration(2 * getEngineSpec(weaponSpec).getAcceleration());
}

final WeaponSpecAPI
    harpoonMRMSingle = Global.getSettings().getWeaponSpec("harpoon_mrm_single"),
    harpoonMRM = Global.getSettings().getWeaponSpec("harpoon_mrm");

println("single: " + getAcceleration(harpoonMRMSingle));
println("rack: " + getAcceleration(harpoonMRM));

doubleAcceleration(harpoonMRMSingle);
println("single: " + getAcceleration(harpoonMRMSingle));
println("rack: " + getAcceleration(harpoonMRM));

doubleAcceleration(harpoonMRM);
println("single: " + getAcceleration(harpoonMRMSingle));
println("rack: " + getAcceleration(harpoonMRM));

would print

Code
single: 1000
rack: 1000

single: 2000
rack: 2000

single: 4000
rack: 4000

 :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 06, 2022, 08:17:18 AM
There *is* no one sprite for weapons with barrels or missiles, it's composited together from the various pieces depending on how the weapon is set up. Your best bet might be to add something like TooltipMakerAPI.showCargo(), though that likely won't do quite what you want.

Hmmmm that could work since I just need a sprite.. I'm just more afraid of the new CargoAPI constantly made and not being GCed. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cry0genic on October 06, 2022, 11:33:29 AM
How do I edit the save file to change the ownership of a station constructed by TASC?

Console command seemingly doesn't work because the string for its ID is too long at Epsilon Kupe Star System20734MiningStationMarket.

I am unable to change the ownership of the station properly by editing the <factionid> to the ID of the faction in question and <playerowned> to false.  So far, editing both fields made it so that the faction colors changed in the UI, but not in the campaign layer, where it's still designated to belong to the player.

Can someone explain which fields do I need to change to fully transfer the market into another faction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on October 06, 2022, 04:31:45 PM
hey all.
I'm trying to edit the upkeep cost of hazard pay on an world right now, and i cant seem to find anything about changing hazard pay at all
is there an way i can replace the hazard pay function with one of my own?
or if that's not possible is there a way to add an income / upkeep cost to an market with code?
thank you all for the help given in the past. i wish you all an good day.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 06, 2022, 07:05:27 PM
Are we still sure the difference between hardpoints and turrets still accurate?

There seems to be -50% recoil for hardpoints.
Hitpoints are doubled on hardpoints.
And they seem to render on top of turrets more,
but I question the turn rate penalties since I'm grabbing the weapon's hardpoint and turret turn rate and it's roughly -95% not -50%
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 06, 2022, 07:13:47 PM
How do I edit the save file to change the ownership of a station constructed by TASC?

Console command seemingly doesn't work because the string for its ID is too long at Epsilon Kupe Star System20734MiningStationMarket.

I am unable to change the ownership of the station properly by editing the <factionid> to the ID of the player and <playerowned> to false.  So far, editing both fields made it so that the faction colors changed in the UI, but not in the campaign layer, where it's still designated to belong to the player.

Can someone explain which fields do I need to change to fully transfer the market into another faction?
The Nex console command should just work if you use the human name with underscores instead of spaces (doesn't need to be an exact match), e.g. I just tested it with setmarketowner togar_mining_station hegemony

The issue you had with save editing is probably because you need to change the market faction as well as the entity faction (and ideally the submarket faction, and the factions of the people on the comm board... you can see where this gets troublesome)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Cry0genic on October 07, 2022, 09:35:02 AM
The Nex console command should just work if you use the human name with underscores instead of spaces (doesn't need to be an exact match), e.g. I just tested it with setmarketowner togar_mining_station hegemony

The issue you had with save editing is probably because you need to change the market faction as well as the entity faction (and ideally the submarket faction, and the factions of the people on the comm board... you can see where this gets troublesome)

Thank you for the help. It works now, and yes, I can see how troublesome it'd be to manually change everything one at a time through the save file, to say nothing of how long it takes to process the million+ lines present every time it's opened.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 07, 2022, 10:14:52 AM
On the other hand, modifying the EngineSpecAPI of the ShipHullSpecAPI of the MissileSpecAPI of one WeaponSpecAPI modifies the same of all such MissileSpecAPI, despite their being cloned.

Probably means the clone is not a "deep" copy, meaning for the engine slots (and possibly other things) it just copies references to the same objects instead of cloning the objects. You're pretty deep into "should not rely on this internal behavior and it could change at some random time without notice" territory, though :)


I'm just more afraid of the new CargoAPI constantly made and not being GCed. Thanks!

Unless you're storing the reference to that CargoAPI somewhere that's already leaking, this shouldn't be any kind of concern?


hey all.
I'm trying to edit the upkeep cost of hazard pay on an world right now, and i cant seem to find anything about changing hazard pay at all
is there an way i can replace the hazard pay function with one of my own?
or if that's not possible is there a way to add an income / upkeep cost to an market with code?
thank you all for the help given in the past. i wish you all an good day.

It's not adjustable on a per-market basis, short of changing the market's hazard rating. You can modify both income and upkeep pretty easily, though.

MarketAPI.getIncomeMult()
Industry.getIncome()
Industry.getUpkeep()

Etc. I'd recommend looking at how these and related are used to get an idea.


Are we still sure the difference between hardpoints and turrets still accurate?

There seems to be -50% recoil for hardpoints.
Hitpoints are doubled on hardpoints.
And they seem to render on top of turrets more,
but I question the turn rate penalties since I'm grabbing the weapon's hardpoint and turret turn rate and it's roughly -95% not -50%

Looking at the code, it seems like the turn rate of hardpoints should be set to a quarter of turreted/hidden weapons. There's a complication here that the turn rate gets a 5x boost when the weapon is not firing (unless it has a special AI hint), and the boosted rate is capped to 360 degrees per second, and this bonus only applies to turrets/hidden slots, not to hardpoints.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 07, 2022, 02:39:58 PM
Probably means the clone is not a "deep" copy, meaning for the engine slots (and possibly other things) it just copies references to the same objects instead of cloning the objects. You're pretty deep into "should not rely on this internal behavior and it could change at some random time without notice" territory, though :)

Thanks.  Ok, I'll check at each version!  (I hope the clone does become deep, now that you mention it)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 07, 2022, 09:10:03 PM
I'm just more afraid of the new CargoAPI constantly made and not being GCed. Thanks!

Unless you're storing the reference to that CargoAPI somewhere that's already leaking, this shouldn't be any kind of concern?
I'm only using this
Code
                CargoAPI FakeCargo = Global.getFactory().createCargo(false);
                FakeCargo.addWeapons(weapon.getId(), 1);
                tooltip.showCargo(FakeCargo, 1, true, opad);
in a addPostDescriptionSection for a hullmod.

Are we still sure the difference between hardpoints and turrets still accurate?

There seems to be -50% recoil for hardpoints.
Hitpoints are doubled on hardpoints.
And they seem to render on top of turrets more,
but I question the turn rate penalties since I'm grabbing the weapon's hardpoint and turret turn rate and it's roughly -95% not -50%

Looking at the code, it seems like the turn rate of hardpoints should be set to a quarter of turreted/hidden weapons. There's a complication here that the turn rate gets a 5x boost when the weapon is not firing (unless it has a special AI hint), and the boosted rate is capped to 360 degrees per second, and this bonus only applies to turrets/hidden slots, not to hardpoints.
Interesting.. is this 5x boost applied as an mult or modifyPercent and how does it get capped? like a math.max? Does this apply overall like no weapons should turn more than 360 degrees?

Or is this like if a weapon can spin 200 degrees, the 5x boost can only apply +160 degrees or +360 degrees?


Edit
Is there also a way to grab a ProjectileSpecAPI or a MissileSpecAPI from a MIRV sub ammunition missile while in a refit screen?

I'm unsure how I could grab it through
Code
((MissileSpecAPI)weapon.getSpec().getProjectileSpec()).getBehaviorJSON().getString("projectileSpec")
I tried
Code
Global.getSettings().getSpec(MissileSpecAPI.class, "sabot_warhead2", true)
and
Code
Global.getSettings().getJSONObject("sabot_warhead2")

Or is this feature unsupported?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 09, 2022, 06:06:16 PM
I'm only using this
Code
                CargoAPI FakeCargo = Global.getFactory().createCargo(false);
                FakeCargo.addWeapons(weapon.getId(), 1);
                tooltip.showCargo(FakeCargo, 1, true, opad);
in a addPostDescriptionSection for a hullmod.

Barring some terrible bug in vanilla, you've got nothing to worry about there.

Interesting.. is this 5x boost applied as an mult or modifyPercent and how does it get capped? like a math.max? Does this apply overall like no weapons should turn more than 360 degrees?

Or is this like if a weapon can spin 200 degrees, the 5x boost can only apply +160 degrees or +360 degrees?

IIRC it's a separate multiplier applied after all other modifiers (so, equivalent to modifyMult, but not actually that). And, yeah, 200 would turn into 360.


Edit
Is there also a way to grab a ProjectileSpecAPI or a MissileSpecAPI from a MIRV sub ammunition missile while in a refit screen?

I'm unsure how I could grab it through
Code
((MissileSpecAPI)weapon.getSpec().getProjectileSpec()).getBehaviorJSON().getString("projectileSpec")
I tried
Code
Global.getSettings().getSpec(MissileSpecAPI.class, "sabot_warhead2", true)
and
Code
Global.getSettings().getJSONObject("sabot_warhead2")

Or is this feature unsupported?

You'd need to call getSpec(MissileSpec.class - using an internal core class. You could then cast the result to MissileSpecAPI. (So, basically: unsupported "properly".)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 11, 2022, 08:25:07 AM
Orbital station code (OrbitalStation) will fetch any entity with the station tag as valid entity for the defensive station:

Code
	protected void ensureStationEntityIsSetOrCreated() {
if (stationEntity == null) {
for (SectorEntityToken entity : market.getConnectedEntities()) {
if (entity.hasTag(Tags.STATION)) {
stationEntity = entity;
usingExistingStation = true;
break;
}
}
}

if (stationEntity == null) {
stationEntity = market.getContainingLocation().addCustomEntity(
null, market.getName() + " Station", Entities.STATION_BUILT_FROM_INDUSTRY, market.getFactionId());
SectorEntityToken primary = market.getPrimaryEntity();
float orbitRadius = primary.getRadius() + 150f;
stationEntity.setCircularOrbitWithSpin(primary, (float) Math.random() * 360f, orbitRadius, orbitRadius / 10f, 5f, 5f);
market.getConnectedEntities().add(stationEntity);
stationEntity.setMarket(market);
}
}

now, I am adding a second station to the planet, and it fetches it and breaks.
could you maybe change that small section of code to

Code
if (entity.hasTag(Tags.STATION) && !entity.hasTag("NO_ORBITAL_STATION")) {
stationEntity = entity;
usingExistingStation = true;
break;
}

Many thanks,
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 14, 2022, 09:38:55 AM
Hmm, I'm not 100% sure that would fully resolve the issue. Even if it did, this is the sort of thing that I might easily break by making some other changes - I'd kind of recommend providing your own implementation of OrbitalStation if you're doing something like this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on October 14, 2022, 09:48:46 AM
That's what I did - I implemented my exact change, but I can't exactly adjust modded stations that are extending the OrbitalStation class.
It did resolve the issue without problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 14, 2022, 02:16:31 PM
While seeking the instance of a class my decompiler calls com.fs.starfarer.coreui.refit.C to work the dark magic of calling the inherited remove and addTooltip instance methods to replace the hardcoded armor tooltip of the refit screen

Code
package com.fs.starfarer.coreui.refit;

import ...

public class C extends v implements com.fs.starfarer.coreui.refit.L.o {
    ...
    public void addTooltips() {
        ...
        var6 = new StandardTooltipV2Expandable(var4, false) {
            public void createImpl(boolean var1) {
                this.addPara("Armor reduces the damage taken by a percentage that depends on the relative strength of the armor compared to the amount of damage, and blocks damage from getting through to the hull.", 0.0F);
                this.addPara("Each hit reduces the amount of armor that remains in the affected area, making each successive hit more and more powerful.", 10.0F);
                this.addPara("Damage applied in a single hit is much more effective at stripping away armor than the same damage distributed over multiple hits.", 10.0F);
                this.addPara("The \"hit strength\" of beam weapons - which do not score separate hits, but deal damage continuously - is based on their damage/second.", 10.0F);
                this.addPara("The effective armor value can not go below %s of its original value, even if it's stripped away entirely, and damage reduction from armor can not exceed %s.", 10.0F, var5, new String[]{Math.round(StarfarerSettings.String.class() * 100.0F) + "%", Math.round(StarfarerSettings.ÓÔ0000() * 100.0F) + "%"});
            }
        };
        this.addTooltip(this.öÓØ000, var6);
        ...
    }
    ...
}

to describe the armor mechanic conversion of my mod, I clambered up an intriguing obfuscated dependency tree to a class of the same name in a different package and found this "special shout out".

Quote from: Alex

"Nobody will ever pirate starfarer, because starfarer is not pirateable. It is not pirateable because I am so god damned good at writing top secret code like this. Are you not amazed by how truly awesome this code is. Well if you are not, balls to you then. Youve got some nerve, mister. Oh and another thing, just because I have this string in here does not mean that the crackers that will trying to cracj this software won't crack it. THey will crack it, but when they discover this special shout out they will not go on any further with their cracking efforts. They will simply say: Wow. These guys had heart. I will not"

;D

Do you know where the instance of com.fs.starfarer.coreui.refit.C is stored so I can call these methods to change the tooltip?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DanzyDanz on October 14, 2022, 06:46:36 PM
Don't know if this has ever been asked before, but how do you make a DP increase hullmod? Trying to start a hard mode ish game and haven't gotten any luck tweaking some mod files
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 14, 2022, 06:58:05 PM
That's what I did - I implemented my exact change, but I can't exactly adjust modded stations that are extending the OrbitalStation class.
It did resolve the issue without problem.

Ah! Added.

Do you know where the instance of com.fs.starfarer.coreui.refit.C is stored so I can call these methods to change the tooltip?

Sorry, no clue! I'd have to go digging around in obfuscation mappings. Probably not the best thread to ask for help with these, this kind of stuff is extremely "at your own risk".

Don't know if this has ever been asked before, but how do you make a DP increase hullmod? Trying to start a hard mode ish game and haven't gotten any luck tweaking some mod files

Take a look at com.fs.starfarer.api.impl.campaign.skills.DerelictContingent.Level1 - that's where the Derelict Operations skill does the decrease. Could also look at SupportDoctrine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wisdomcube2000 on October 14, 2022, 07:10:27 PM
Trying to make my own version of the phase cloak with the intention of changing the color. So I copied over the details in ship_systemscsv and the phasecloak system file (I changed next to nothing). In game it works, you hear the sound effects, you see the unique system name/details, but none of the glow effects work. I noticed even if I alter the _glow image names to something else that would normally have the game yelling at you about it missing, it doesn't care about those missing. Can anyone direct me to what I need to change? Thanks in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 14, 2022, 09:08:17 PM
Sorry, no clue! I'd have to go digging around in obfuscation mappings. Probably not the best thread to ask for help with these, this kind of stuff is extremely "at your own risk".

:(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 15, 2022, 04:14:29 AM
Looking at the code, it seems like the turn rate of hardpoints should be set to a quarter of turreted/hidden weapons. There's a complication here that the turn rate gets a 5x boost when the weapon is not firing (unless it has a special AI hint), and the boosted rate is capped to 360 degrees per second, and this bonus only applies to turrets/hidden slots, not to hardpoints.

Okay so.. this is weird!

If the weapon is a turret/hidden weapon and doesn't have that special AI hint, its turn rate is clamped to 360 degrees. Like even if you have a weapon that is 400 degrees, placing it on a turret/hidden mount would always limit to 360,

BUT if you have the special AI hint or you're placing it on a hardpoint, this 360 limit doesn't exist at all. In fact you can set 9999 turn rate in weapon.csv and get 9999(or 2499)  turn rate.

Does it seem like there should be a hard limit of 360 degree regardless of mount or ai hint then?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 15, 2022, 06:15:03 AM
Hi, is there a way to reference isActive() from a shipsystem set to replace shields (right click shipsystem) in the same way you can do it for the normal shipsystem via ship.system.isActive()?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on October 15, 2022, 06:00:59 PM
Hi, is there a way to reference isActive() from a shipsystem set to replace shields (right click shipsystem) in the same way you can do it for the normal shipsystem via ship.system.isActive()?

ship.getPhaseCloak.yadayada(), alternate defence systems are just phase cloaks in a janky trench coat

as for my acutal question - how often does a renderPlugin's render() method get called per-frame?
it seems to happen once while the game is unpaused & twice while the game is paused, though that also doesn't seem quite right

(https://cdn.discordapp.com/attachments/815735963090944010/1031003107708125284/render_plugin_jank.png)

here's 3 cutouts from something I'm drawing w/ the stencil buffer (so it's all one huge coloured quad in the background), the leftmost section is with the alpha being divided by 2 if the engine is paused, the middle is what it looks like when running normally & the rightmost is what it looks like with the normal alpha while the game is paused.
a 4th result I got was when I had the plugin only actually render stuff every other time render() was called if the game was paused - it had the brightness of the left one but flickered every other frame (might've just done it wrong ngl, 2 am coding doesn't lead to good code :p)

particularly though, why is the leftmost one (88,62,89) slightly darker than the middle one (95,65,97) if they should in theory have the same alpha as one is being rendered twice? (though, I guess that 2 layers of wouldn't quite blend to the same as one w/ double alpha somehow?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 15, 2022, 06:06:40 PM
ship.getPhaseCloak.yadayada(), alternate defence systems are just phase cloaks in a janky trench coat
This works, thanks!

I have another question - is it possible to rotate modules for a specific ship only? When I use this for example:

Code
SHIELD_MODULE.getStationSlot().setAngle(baseFacingRight+this.facingOffsetRight*smoothedAnimLast);

All ships of that type have that slot rotated at the same time, which is definitely not what I want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 16, 2022, 07:19:17 AM
Is the code on a hullmod? That might be why it happens on every ship since there's only one instance of a hullmod so code executes for everything w/ the mod installed. It should only affect the specific ship if its on an everyframe iirc
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 16, 2022, 07:30:44 AM
I am pretty sure weapon slots can not be modified on per-ship basis.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 16, 2022, 08:26:04 AM
maybe he can do it by changing the facing of the module itself instead of the slot
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 16, 2022, 04:03:04 PM
Trying to make my own version of the phase cloak with the intention of changing the color. So I copied over the details in ship_systemscsv and the phasecloak system file (I changed next to nothing). In game it works, you hear the sound effects, you see the unique system name/details, but none of the glow effects work. I noticed even if I alter the _glow image names to something else that would normally have the game yelling at you about it missing, it doesn't care about those missing. Can anyone direct me to what I need to change? Thanks in advance.

I'd recommend modifying the existing phasecloak.system file (after making a backup copy) one change at a time to narrow down where it's going wrong.

Okay so.. this is weird!

If the weapon is a turret/hidden weapon and doesn't have that special AI hint, its turn rate is clamped to 360 degrees. Like even if you have a weapon that is 400 degrees, placing it on a turret/hidden mount would always limit to 360,

BUT if you have the special AI hint or you're placing it on a hardpoint, this 360 limit doesn't exist at all. In fact you can set 9999 turn rate in weapon.csv and get 9999(or 2499)  turn rate.

Does it seem like there should be a hard limit of 360 degree regardless of mount or ai hint then?

Yeah, the non-turret rate should probably be clamped too, unless the weapon has that AI hint (which I think should preclude rate clamping, regardless); let me do that.


as for my acutal question - how often does a renderPlugin's render() method get called per-frame?

Could you clarify what you mean by "renderPlugin"?

Regardless, though, I'd be pretty surprised if it was getting called more than once per frame...

maybe he can do it by changing the facing of the module itself instead of the slot

Yeah, it'd have to be something like that - the slot objects are shared between all ships of that type, so changes to one would be changes to all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on October 16, 2022, 04:36:22 PM
as for my acutal question - how often does a renderPlugin's render() method get called per-frame?

Could you clarify what you mean by "renderPlugin"?

Regardless, though, I'd be pretty surprised if it was getting called more than once per frame...

specifically, a class that extends BaseCombatLayeredRenderingPlugin & is added to the engine through addLayeredRenderingPlugin(new renderPluginName()) (obvs not the actual code)

to me it'd be odd if it wasn't getting called more than once per frame, that's the only reasonable explanation I can think of?
unless there's some wierd jank with running combatEntityAPI.getOwner() on a shipAPI while the game is paused? (specifically because I've got one plugin running for owner 0 & one for owner 1, though that seems highly unlikely)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on October 16, 2022, 08:27:58 PM
maybe he can do it by changing the facing of the module itself instead of the slot
This worked, thank you very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 18, 2022, 09:02:12 AM
What's a good way to store data on a planetary condition? I'm confused as to how they work. Is it like hullmods, where the definition of the condition plugin is a singleton instance and thus cannot have any data stored on it?

Basically, I have a ton of data I'm currently storing through the memory of the market, but I kind of want to move it to the condition itself for convenience sake.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 18, 2022, 10:35:45 AM
specifically, a class that extends BaseCombatLayeredRenderingPlugin & is added to the engine through addLayeredRenderingPlugin(new renderPluginName()) (obvs not the actual code)

to me it'd be odd if it wasn't getting called more than once per frame, that's the only reasonable explanation I can think of?
unless there's some wierd jank with running combatEntityAPI.getOwner() on a shipAPI while the game is paused? (specifically because I've got one plugin running for owner 0 & one for owner 1, though that seems highly unlikely)

Ah - I mean, it's called once per layer during each frame. So if your plugin has multiple active layers (i.e. getActiveLayers() returns a set with more than one element) and you're not checking which layer it is in the render() method then you might see this sort of behavior.



What's a good way to store data on a planetary condition? I'm confused as to how they work. Is it like hullmods, where the definition of the condition plugin is a singleton instance and thus cannot have any data stored on it?

Basically, I have a ton of data I'm currently storing through the memory of the market, but I kind of want to move it to the condition itself for convenience sake.

You can just store the data in data members of the condition class. Make sure to have this in your condition class:
public boolean isTransient() {
   return false;
}

So that the data is actually stored in the savefile.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on October 19, 2022, 06:04:36 PM
question
what is the script that generates the generic combat battlefield? i mean one that spawns asteroids and objectives and stuff
is it in the API or obfuscated?
i'm just curious to take a look at it, to see if i can learn something from
but i can't find the script in the first place?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 20, 2022, 05:30:48 AM
question
what is the script that generates the generic combat battlefield? i mean one that spawns asteroids and objectives and stuff
is it in the API or obfuscated?
i'm just curious to take a look at it, to see if i can learn something from
but i can't find the script in the first place?

Not a script, its the BattleCreationPlugin i think
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 20, 2022, 08:10:42 AM
What's a good way to spawn a fleet that has a strict FP limit, using factions (maybe), so I can the officers, personality type, memflags, dmods, etc. all contained on the faction?
I'm currently not using a faction to spawn my fleets. This is because I learnt fleetfactory uses FP as a softcap, not a hardcap, but I never want FP to exceed a provided value. So, I have a method that manually injects variants into a fleet. My question, then, is how do I do this while maintaining the dmod rate, officers, etc. of a given faction? Would I have to use a fleet inflater or something?

Heres an example of what I mean: I want to spawn a fleet composed 100% out of a provided list of variants. I want this to be spawned using the derelict faction doctrine, but using the provided variants in place of the existing known ships list. I want them to have the same amount and type of dmods as a derelict fleet-the same types of officers, and the same memflags. This can be done with a faction, but I'd prefer to do it programatically by just passing a list of variants.
Assuming I do it programatically: How do I ensure that each member has the same characteristics as a normal derelict fleet member, as well as having the same autofit variance (just for variety)?
Assuming I do it with a faction: How do I ensure that the fleet never exceeds the provided FP limit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 20, 2022, 09:30:38 AM
Create a fleet using FleetFactory and then cull until you meet your FP requirements.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on October 20, 2022, 04:28:41 PM
Is there any way to hint to AI that a specific ship may be a better target than normal? For example: I have a modular ship, and one if its modules causes two big and very dangerous modules to explode if it dies. I want the AI to recognize the higher target value of said module.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on October 20, 2022, 06:14:15 PM
Anybody know an easy way to change the damage type of a projectiles proximity fuse to have different type to the projectile. Tried:

Code: .proj file
	"behaviorSpec":{	"behavior":"PROXIMITY_FUSE",
"damageType":KINETIC,

But alas, it does nothing. Also tried putting damageType under "explosionSpec":{ but it's still the same.

Alternatively, is there an easy way to change the projectiles damage type, providing it doesn't carry to the PROXIMITY_FUSE effect...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 20, 2022, 07:00:59 PM
If the projectile has a proximity fuse then it will almost never actually hit a target directly, so what are you trying to do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on October 21, 2022, 12:35:28 AM
If the projectile has a proximity fuse then it will almost never actually hit a target directly, so what are you trying to do?

I'm using it for a 'timed fused' by setting the range to 0 and shotRangeVariance to 0.3.

To effect is a direct fire weapons with rounds that detonate when near-maximum range. Ideally I'd like direct HE damage with a Kinetic Component when the fuse triggers. Currently it's all Kinetic which works fine but I'm also toying with a Frag/EMP version.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 21, 2022, 07:12:01 AM
Ahh, I think I see the issue - it happens when you actually get into the combat, not just when you join the battle in the campaign screen. Checking it out!

Edit: fixed this up! It would only affect allied fleets, and I *think* it would kick out the fleet commander regardless of what ship they were in, so, a pretty significant bug at that. Thank you for the report!

I don't *think* there's a particularly clean workaround, other than, say, undoing this in some combat plugin's init() method or something similar.
I've encountered a case where the bug also occurs for the player fleet under specific circumstances (https://fractalsoftworks.com/forum/index.php?topic=9175.msg379365#msg379365). It's rare enough that I don't feel like trying to fix it (especially given the conflicts involved with multiple mods overriding FIDPI, which would be needed to avoid breaking it when player changes flagships before the engagement), but I want to check: this is also covered by the fix in next Starsector version, right?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on October 22, 2022, 02:49:12 PM
hello once more everyone.
so i made an submarket the otherday. the idea was to use it as a 'kind of storage' for ships, but every time i add an ship to the submarket, leave them come back its gone. dose anyone know how to prevent this from happing
here is my code
Spoiler
public class AIRetrofit_Shipyard extends BaseSubmarketPlugin {
    @Override
    public void advance(float amount){
    }
    @Override
    public boolean isParticipatesInEconomy() {
        return false;
    }

    @Override
    public float getTariff() {
        return 0f;
    }

    @Override
    public boolean isFreeTransfer() {
        return true;
    }
    @Override
    public String getBuyVerb() {
        return "take";
    }

    @Override
    public String getSellVerb() {
        return "leave";
    }
    @Override
    public boolean showInCargoScreen() {
        return false;
    }
    @Override
    public boolean   isIllegalOnSubmarket(java.lang.String commodityId, SubmarketPlugin.TransferAction action){
        return false;
    }
    @Override
    public    boolean isMilitaryMarket(){
        return true;
    }
}

[close]
thanks again for all the help in the past. it has been very helpfull
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 22, 2022, 03:34:19 PM
Anybody know an easy way to change the damage type of a projectiles proximity fuse to have different type to the projectile.

Not possible through the data files.


@alaricdragon: hmm, nothing jumps out as being wrong there. I'd suggest making an exact copy of StoragePlugin, making sure that works how you'd like, and then incrementally changing it - one thing at a time - until you hit on whatever it is that's causing this behavior, somehow.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 23, 2022, 06:34:57 AM
Can a ship be hit if its bounds are a point?

EDIT: got off my lazy bum and tested: looks like no, except it can still collide with other ships' hulls.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 24, 2022, 06:14:30 AM
So e.g. TacticallyBombardColony and BaseDisruptIndustry have this:

Code: java
		addNoPenaltyFailureStages(Stage.FAILED_NO_PENALTY);
connectWithMarketDecivilized(Stage.BOMBARD, Stage.FAILED_NO_PENALTY, market);
setStageOnMarketDecivilized(Stage.FAILED_NO_PENALTY, createdAt);
connectWithHostilitiesEnded(Stage.BOMBARD, Stage.FAILED_NO_PENALTY, person, market);
setStageOnHostilitiesEnded(Stage.FAILED_NO_PENALTY, person, market);
Questions:
- Are both the connectWithHostilitiesEnded and setStageOnHostilitiesEnded calls needed, or do they do the same thing here (end the mission if the person faction is no longer hostile to the market faction)?
- Is the setStageOnMarketDecivilized call correct? Looks like it ends the mission if the issuer's market decivilizes, which I'm not sure is necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on October 24, 2022, 09:58:21 AM
The "no_drop_salvage" tag should do it.

Edit: at least, assuming a mod hasn't changed or added drop groups that don't respect that.

I'm unsure if this is the case. Just doing vanilla + my mod and the no_drop_salvage tag doesn't seem to work at least in the public version. Can still seem to recover hullmods found in random stations and ruin exploration.

no_drop works, but I would like for the fleet with the hullmods to drop them and not random stations outside.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killian on October 24, 2022, 10:49:18 AM
Anyone got any good resources on making ship systems? I want to make a toggle system that, whilst active, either;

A) causes all of a ship's missile weapons to gain increased rate of fire and reload speed, and periodic ammo regeneration (think missile autoforge + fast missile racks + ballistic ammo feed)

or

B) causes all of a ship's missile weapons to gain increased velocity, tracking, etc. (similar to the ECCM package hullmod, but beefed up)

With the cost of constant hardflux generation whilst active. I'd rather it be a toggle that does things periodically rather than a one-and-done fixed-duration thing, for the potential of absolutely redlining the ship's systems with the risk of overload (and maybe actual damage??) if you push too hard.

Unfortunately the search function hasn't been very helpful thusfar, and I've not worked with java nor the starsector APIs before, so I haven't much idea on where to begin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 24, 2022, 03:58:52 PM
Can a ship be hit if its bounds are a point?

EDIT: got off my lazy bum and tested: looks like no, except it can still collide with other ships' hulls.

Don't know what you're trying to do, but: would setting the ship's collision class to CollisionClass.NONE do the job? If that's no good for some reason, you could also try moving that one bounds point several battlefield lengths away from the center of the ship :)

Also: setting the collision radius to 0 *may* bypass the bounds check; I don't actually remember 100%.


- Are both the connectWithHostilitiesEnded and setStageOnHostilitiesEnded calls needed, or do they do the same thing here (end the mission if the person faction is no longer hostile to the market faction)?

Those do seem redundant, yeah. Just one or the other should do.

- Is the setStageOnMarketDecivilized call correct? Looks like it ends the mission if the issuer's market decivilizes, which I'm not sure is necessary.

Yeah, that's the intent. Not strictly necessary indeed; not sure there's much of a difference either way.

I'm unsure if this is the case. Just doing vanilla + my mod and the no_drop_salvage tag doesn't seem to work at least in the public version. Can still seem to recover hullmods found in random stations and ruin exploration.

no_drop works, but I would like for the fleet with the hullmods to drop them and not random stations outside.

Hmm, that's odd. You're not adding any drop groups yourself, are you? Just looking at how the vanilla drop groups are set up, this tag should work specifically for hullmod specs.


Anyone got any good resources on making ship systems? I want to make a toggle system that, whilst active, either;

Copying another toggle-type ship system (such as Fortress Shield) might be a good place to start.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killian on October 24, 2022, 04:20:56 PM
Anyone got any good resources on making ship systems? I want to make a toggle system that, whilst active, either;

Copying another toggle-type ship system (such as Fortress Shield) might be a good place to start.

Aha, right. I was missing that all the crunchy effects like costs and toggles are defined in the shipsystems.csv. Excellent. I think I can see how this'll work, just gotta fish through the API for the exact settings I need for the script itself.

I have most of it going now, but I don't see an easy "can cause overload" setting?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 24, 2022, 05:31:00 PM
Can a ship be hit if its bounds are a point?

EDIT: got off my lazy bum and tested: looks like no, except it can still collide with other ships' hulls.

Don't know what you're trying to do, but: would setting the ship's collision class to CollisionClass.NONE do the job? If that's no good for some reason, you could also try moving that one bounds point several battlefield lengths away from the center of the ship :)

Also: setting the collision radius to 0 *may* bypass the bounds check; I don't actually remember 100%.

Just theory-crafting for a ship system that makes the ship unable to be hit. Was hypothesizing NONE might make the AI not target it and thought of point bounds. 0 collision radius is also a good idea.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 24, 2022, 05:32:15 PM
How can I access the every WeaponSpecAPI corresponding to a weapon_data.csv row containing the SYSTEM tag, wherefore Global.getSettings().getAllWeaponSpecs() excludes every such WeaponSpecAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FelixG on October 25, 2022, 02:40:07 AM
I haven't seen a mod around that does it, but is there a mod, or a pointer in the files, that adjusts the scaling of the bounties to keep them from ballooning completely out of hand and spawning a half dozen capital ships when you have a smaller fleet?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on October 26, 2022, 01:46:13 PM
hello again all.
im sorry to bug you all again so soon, but i have another question:
how do i access ships stored in an submarket? I have tried
Code
cargo.getFleetData().getMembersListCopy()
but this and other methods that try to pass 'FleetMemberAPI' in submarkets always results in a crash, and I cant seem to find any other references to ships at all in the submarkets code.
again, thank you all for all the help freely given, its very nice to have help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 27, 2022, 02:37:53 AM
cargo.getMothballedShips()

(Javadoc mentions that initMothballedShips(String factionId) needs to be called first, not sure if game automatically does this already)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on October 28, 2022, 08:24:47 AM
common issue is we have to point out the ShipAPI.setCustomData method that actually modifies the underlying map and not a copy returned by ShipAPI.getCustomData. is it possible to make getCustomData return the original custom data map?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 28, 2022, 09:49:21 AM
Just theory-crafting for a ship system that makes the ship unable to be hit. Was hypothesizing NONE might make the AI not target it and thought of point bounds. 0 collision radius is also a good idea.

Ah! Not sure offhand if that'll change what the AI is doing or not, actually; it might indeed affect it.


How can I access the every WeaponSpecAPI corresponding to a weapon_data.csv row containing the SYSTEM tag, wherefore Global.getSettings().getAllWeaponSpecs() excludes every such WeaponSpecAPI?

Hmm, I don't think you can, actually. Let me add:

List<WeaponSpecAPI> getSystemWeaponSpecs();

To SettingsAPI.


cargo.getMothballedShips()

(Javadoc mentions that initMothballedShips(String factionId) needs to be called first, not sure if game automatically does this already)

(It does not, but in the specific case for a submkarket, the getCargo() method does this.)


common issue is we have to point out the ShipAPI.setCustomData method that actually modifies the underlying map and not a copy returned by ShipAPI.getCustomData. is it possible to make getCustomData return the original custom data map?

I don't think ShipAPI has either of these methods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on October 28, 2022, 09:53:20 AM
common issue is we have to point out the ShipAPI.setCustomData method that actually modifies the underlying map and not a copy returned by ShipAPI.getCustomData. is it possible to make getCustomData return the original custom data map?

I don't think ShipAPI has either of these methods.

sorry, it's CombatEntityAPI
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 28, 2022, 02:09:05 PM
common issue is we have to point out the ShipAPI.setCustomData method that actually modifies the underlying map and not a copy returned by ShipAPI.getCustomData. is it possible to make getCustomData return the original custom data map?

I don't think ShipAPI has either of these methods.

sorry, it's CombatEntityAPI

Ah, ok. I don't understand what the issue is, then - getCustomData() already does not return a copy.

... ahh. One thing that happens is if you removeCustomData() the last entry in the map, the underlying map will be set to null and re-allocated next time you call either getCustomData() or setCustomData(). So if you're hanging on to the reference to an older map - pre it being cleared by removeCustomData() - then it might look like getCustomData() is returning a "copy" (it'd be reallocating a new map because the old one was cleared out and null'ed).

So if you're holding on to a reference like that, I'd suggest ... not doing that :) It's not a great idea to hang on to some internals of a class precisely because things like this can and will happen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 28, 2022, 03:02:15 PM
Hmm, I don't think you can, actually. Let me add:

List<WeaponSpecAPI> getSystemWeaponSpecs();

To SettingsAPI.

Yaaaaaay! :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on October 28, 2022, 11:04:00 PM
common issue is we have to point out the ShipAPI.setCustomData method that actually modifies the underlying map and not a copy returned by ShipAPI.getCustomData. is it possible to make getCustomData return the original custom data map?

I don't think ShipAPI has either of these methods.

sorry, it's CombatEntityAPI

Ah, ok. I don't understand what the issue is, then - getCustomData() already does not return a copy.

... ahh. One thing that happens is if you removeCustomData() the last entry in the map, the underlying map will be set to null and re-allocated next time you call either getCustomData() or setCustomData(). So if you're hanging on to the reference to an older map - pre it being cleared by removeCustomData() - then it might look like getCustomData() is returning a "copy" (it'd be reallocating a new map because the old one was cleared out and null'ed).

So if you're holding on to a reference like that, I'd suggest ... not doing that :) It's not a great idea to hang on to some internals of a class precisely because things like this can and will happen.

ok. there's been some weird behavior people have been seeing where using
Code
ship.getCustomData().put("key", value)
and then trying to retrieve the value
Code
ship.getCustomData().get("key")
will return false.

(https://i.imgur.com/Xmzdpjf.png)
this is a specific example from someone earlier today where the key they set was immediately gone
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Whittle on October 29, 2022, 01:37:11 PM
Where is the script that calculates accessibility? I would like to create a version that takes active rings into account when calculating distance from core / distance to other colonies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 30, 2022, 02:56:13 PM
this is a specific example from someone earlier today where the key they set was immediately gone

That code is using "ship" and "weapon.getShip()", so possibly the two aren't the same in that context?


Where is the script that calculates accessibility? I would like to create a version that takes active rings into account when calculating distance from core / distance to other colonies.

It's modified in a number of places, check the references to MarketAPI.getAccessibilityMod() to see where.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on October 30, 2022, 03:14:19 PM
So, I went ahead and wrote an entire mod that allows the player to insure unique ships and, in the event of said ship's destruction, receive a fresh hull. The problem is, I didn't account for the fact that my references to each of the FleetMemberAPIs prevent the garbage collector from actually cleaning the objects up. I'm now left with no actual way to check if a ship has truly been obliterated or not since my current code relies on checking if the stored FleetMemberAPI being null (which it never will be while a reference to it is stored.)

My question is whether there's still any way for me to check if a ship is truly gone given these circumstances. If possible I'd like to avoid the "check the game world, markets, storage etc for the ship to see if it exists" approach because there are a number of mods that utilize their own storage systems that the base game API doesn't touch, so anyone using those mods could trick my mod into allowing them to duplicate unique ships.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 30, 2022, 03:19:23 PM
An excellent question :)

Take a look at com.fs.starfarer.api.impl.campaign.plog.SModRecord, in particular its use of WeakReference<FleetMemberAPI>, it's an approach (about the only one I could think of) to solving this exact problem.

Short of, yes, trying to search through everything and then still not accounting for whatever random way some mod might be storing a fleet member.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tsallast on October 30, 2022, 03:38:48 PM
I believe this is impossible, but is there any way to display "Heat" instead of "Flux" for a specific ship for the little combat indicator next to it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on October 30, 2022, 07:43:26 PM
An excellent question :)

Take a look at com.fs.starfarer.api.impl.campaign.plog.SModRecord, in particular its use of WeakReference<FleetMemberAPI>, it's an approach (about the only one I could think of) to solving this exact problem.

Short of, yes, trying to search through everything and then still not accounting for whatever random way some mod might be storing a fleet member.

It worked!!!

...Kind of. By changing all memory references of FleetMemberAPI to WeakReference<FleetMemberAPI> I was able to to get garbage collection to acknowledge that the FleetMemberAPI in question was due to be annihilated. The one problem I'm having is that garbage collection seems to happen on a completely arbitrary basis, so I may have to add a sentence or two in the upcoming forum post about how players need to save and load to force garbage collection if the station isn't recognizing that they have a redeemable ship hull. If you know a way to force garbage collection without saving and loading I'm all ears, but otherwise I'm pretty happy with how this turned out.

EDIT: saving/loading only seems to force garbage collection in dev mode, so it looks like I'll have to find a way around this unfortunately. See reply
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 30, 2022, 08:05:21 PM
Oops, duplicate post!  :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on October 30, 2022, 08:08:54 PM
An excellent question :)

Take a look at com.fs.starfarer.api.impl.campaign.plog.SModRecord, in particular its use of WeakReference<FleetMemberAPI>, it's an approach (about the only one I could think of) to solving this exact problem.

Short of, yes, trying to search through everything and then still not accounting for whatever random way some mod might be storing a fleet member.

It worked!!!

...Kind of. By changing all memory references of FleetMemberAPI to WeakReference<FleetMemberAPI> I was able to to get garbage collection to acknowledge that the FleetMemberAPI in question was due to be annihilated. The one problem I'm having is that garbage collection seems to happen on a completely arbitrary basis, so I may have to add a sentence or two in the upcoming forum post about how players need to save and load to force garbage collection if the station isn't recognizing that they have a redeemable ship hull. If you know a way to force garbage collection without saving and loading I'm all ears, but otherwise I'm pretty happy with how this turned out.

EDIT: saving/loading only seems to force garbage collection in dev mode, so it looks like I'll have to find a way around this unfortunately. See reply
It turns out regular old saving forces garbage collection, so it seems like telling players to do that might just be my solution. If there's an easy way to force garbage collection via the API (which there doesn't seem to be) I will be happy to implement it, but otherwise I'm very happy to just tell people to save their game since that doesn't seem like it requires a lot of effort on their part.

EDIT: I set up a script to run System.gc() when the player interacts with my station. This has completely solved all of my issues and eliminated the need for the player to save. Unless there's some sort of hidden consequences for doing this, I'm going to keep it this way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 30, 2022, 08:24:07 PM
A user has reported that my mod Realistic Combat yields this crash-to-desktop error

com.fs.starfarer.loading.specs.C cannot be cast to com.fs.starfarer.loading.specs.N

which I have traced this Realistic Combat method
Code
    private static void spawnRicochetProjectile(final DamagingProjectileAPI projectile,
                                                final Vector2f location,
                                                final float ricochetFacing,
                                                final ShipAPI ship)
    {
        Global.getCombatEngine().spawnProjectile(projectile.getSource(), projectile.getWeapon(),
                projectile.getWeapon().getId(), location, ricochetFacing, ship.getVelocity());
    }
with the Scy (https://fractalsoftworks.com/forum/index.php?topic=8010.0) mod installed.

I have searched the obfuscated code module com.fs.starfarer.loading.specs for both classes, finding com.fs.starfarer.loading.specs.N to be 'behind' WeaponSpecAPI, but have not found com.fs.starfarer.loading.specs.C.  Does this second obfuscated class exist, and if so, where?  I can only speculate about the ultimate cause of this bug: perhaps some consequence of my nigh-heretical meddling with dark magic to pursue unnatural ends has angered some hidden Power Behind the API.  :-[

Update: I have run my mod with Scy and received an almost identical error, which referred instead to
ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.class, which I have found in the obfuscated code and know to be the spec class for BeamAPI.

I then wrapped a try-catch block around this method and found an involved weapon: Nano-needle minigun Mk. 2 (id: SCY_minigun2).  This weapon has a BeamEffect

BeamEffect
Code: BeamEffect
//by Tartiflette, this script allow for a beam weapon to spawn bouncing projectiles on impact
//feel free to use it, credit is appreciated but not mandatory
package data.scripts.weapons;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponSize;
import com.fs.starfarer.api.util.IntervalUtil;
import data.scripts.util.MagicRender;
import java.awt.Color;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lwjgl.util.vector.Vector2f;

public class SCY_minigunEffect implements BeamEffectPlugin {
   
    private boolean runOnce=false, hasSmoke=false, large=false;
    private float TEXTURE_RANDOMNESS=2, GLOW_SIZE=40;
    private final IntervalUtil timer = new IntervalUtil (0.025f,0.075f);
    private final float M_TEXTURE_RANDOMNESS=5, M_GLOW_SIZE=60, L_TEXTURE_RANDOMNESS=30, L_GLOW_SIZE=80;
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {               
        //game paused, no script
        if (engine.isPaused()) {return;}
       
        if (!runOnce){
            runOnce=true;
            if(beam.getWeapon().getSize()==WeaponSize.MEDIUM){
                hasSmoke=true;
                TEXTURE_RANDOMNESS=M_TEXTURE_RANDOMNESS;
                GLOW_SIZE=M_GLOW_SIZE;
            } else if(beam.getWeapon().getSize()==WeaponSize.LARGE){
                hasSmoke=true;
                large=true;
                TEXTURE_RANDOMNESS=L_TEXTURE_RANDOMNESS;
                GLOW_SIZE=L_GLOW_SIZE;
            }
            return;
        }       
       
        timer.advance(amount);
        if(timer.intervalElapsed() && beam.getBrightness()>0.8f && MagicRender.screenCheck(0.1f, beam.getFrom())){

            beam.setPixelsPerTexel(15 + MathUtils.getRandomNumberInRange(-TEXTURE_RANDOMNESS, TEXTURE_RANDOMNESS));

            Vector2f from = beam.getFrom();
            Vector2f vel = beam.getSource().getVelocity();
            if(hasSmoke){
                float grey = MathUtils.getRandomNumberInRange(0.3f, 0.6f);
                if (Math.random()>0.5){
                    engine.addSmoothParticle(
                            MathUtils.getRandomPointInCircle(
                                    from,
                                    5
                            ),
                            new Vector2f (
                                    vel.x/2+MathUtils.getRandomNumberInRange(-5f, 5f),
                                    vel.y/2+MathUtils.getRandomNumberInRange(-5f, 5f)
                            ), 
                            MathUtils.getRandomNumberInRange(10f, 25f),
                            0.5f,
                            MathUtils.getRandomNumberInRange(1f, 5f),
                            new Color(grey,grey,grey,MathUtils.getRandomNumberInRange(0.02f, 0.08f) )
                    );
                } else {
                    engine.addSmokeParticle(
                            MathUtils.getRandomPointInCircle(
                                    from,
                                    5
                            ),
                            new Vector2f (
                                    vel.x/2+MathUtils.getRandomNumberInRange(-5f, 5f),
                                    vel.y/2+MathUtils.getRandomNumberInRange(-5f, 5f)
                            ), 
                            MathUtils.getRandomNumberInRange(10f, 25f),
                            0.5f,
                            MathUtils.getRandomNumberInRange(1f, 5f),
                            new Color(grey,grey,grey,MathUtils.getRandomNumberInRange(0.02f, 0.08f) )
                    );
                }
            }       
            engine.addSmoothParticle(
                    from,
                    vel,
                    MathUtils.getRandomNumberInRange(GLOW_SIZE-15, GLOW_SIZE+15),
                    0.5f,
                    0.05f,
                    new Color(255,50,25,128)
            );     
        }

        //on Hit, create impact effect
        if (beam.didDamageThisFrame()){           
            Vector2f end = beam.getTo(); 

            //splinters             
            float dir = VectorUtils.getAngle(beam.getDamageTarget().getLocation(), end);
            if (hasSmoke){
                engine.spawnProjectile(
                    beam.getSource(),
                    beam.getWeapon(),
                    "SCY_splinter1",
                    MathUtils.getRandomPointOnCircumference(end, 5),
                    dir + MathUtils.getRandomNumberInRange(-90, 90),
                    null
                );
                engine.spawnProjectile(
                    beam.getSource(),
                    beam.getWeapon(),
                    "SCY_splinter2",
                    MathUtils.getRandomPointOnCircumference(end, 5),
                    dir + MathUtils.getRandomNumberInRange(-90, 90),
                    null
                );
                if(large){                   
                    engine.spawnProjectile(
                        beam.getSource(),
                        beam.getWeapon(),
                        "SCY_splinter2",
                        MathUtils.getRandomPointOnCircumference(end, 5),
                        dir + MathUtils.getRandomNumberInRange(-90, 90),
                        null
                    );
                }
            } else {               
                //spawn a single splinters
                if(Math.random()>0.66){
                    engine.spawnProjectile(
                        beam.getSource(),
                        beam.getWeapon(),
                        "SCY_splinter1",
                        MathUtils.getRandomPointOnCircumference(end, 5),
                        dir + MathUtils.getRandomNumberInRange(-90, 90),
                        null
                    );
                } else if(Math.random()>0.5){
                    engine.spawnProjectile(
                        beam.getSource(),
                        beam.getWeapon(),
                        "SCY_splinter2",
                        MathUtils.getRandomPointOnCircumference(end, 5),
                        dir + MathUtils.getRandomNumberInRange(-90, 90),
                        null
                    );
                } 
            }             
        }
    }
}
[close]

which I have included should you want to read it.  I notice an association—my error report mentions the hidden class BeamSpec class, and the weapon involved has a BeamEffect—and now wonder if some interaction between this BeamEffect and the Global.getCombatEngine().spawnProjectile method has instead of my irreverent occult tampering caused the error.

Update: see message (https://fractalsoftworks.com/forum/index.php?topic=5061.msg380353#msg380353) below.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on October 31, 2022, 09:52:43 AM
A user has reported that my mod Realistic Combat yields this crash-to-desktop error

com.fs.starfarer.loading.specs.C cannot be cast to com.fs.starfarer.loading.specs.N

which I have traced this Realistic Combat method
Code
    private static void spawnRicochetProjectile(final DamagingProjectileAPI projectile,
                                                final Vector2f location,
                                                final float ricochetFacing,
                                                final ShipAPI ship)
    {
        Global.getCombatEngine().spawnProjectile(projectile.getSource(), projectile.getWeapon(),
                projectile.getWeapon().getId(), location, ricochetFacing, ship.getVelocity());
    }
with the Scy (https://fractalsoftworks.com/forum/index.php?topic=8010.0) mod installed.

I have searched the obfuscated code module com.fs.starfarer.loading.specs for both classes, finding com.fs.starfarer.loading.specs.N to be 'behind' WeaponSpecAPI, but have not found com.fs.starfarer.loading.specs.C.  Does this second obfuscated class exist, and if so, where?  I can only speculate about the ultimate cause of this bug: perhaps some consequence of my nigh-heretical meddling with dark magic to pursue unnatural ends has angered some hidden Power Behind the API.  :-[

Update: I have run my mod with Scy and received an almost identical error, which referred instead to
ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.class, which I have found in the obfuscated code and know to be the spec class for BeamAPI.

I then wrapped a try-catch block around this method and found an involved weapon: Nano-needle minigun Mk. 2 (id: SCY_minigun2).  This weapon has a BeamEffect

BeamEffect
Code: BeamEffect
//by Tartiflette, this script allow for a beam weapon to spawn bouncing projectiles on impact
//feel free to use it, credit is appreciated but not mandatory
package data.scripts.weapons;

import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.WeaponAPI.WeaponSize;
import com.fs.starfarer.api.util.IntervalUtil;
import data.scripts.util.MagicRender;
import java.awt.Color;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lwjgl.util.vector.Vector2f;

public class SCY_minigunEffect implements BeamEffectPlugin {
   
    private boolean runOnce=false, hasSmoke=false, large=false;
    private float TEXTURE_RANDOMNESS=2, GLOW_SIZE=40;
    private final IntervalUtil timer = new IntervalUtil (0.025f,0.075f);
    private final float M_TEXTURE_RANDOMNESS=5, M_GLOW_SIZE=60, L_TEXTURE_RANDOMNESS=30, L_GLOW_SIZE=80;
   
    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {               
        //game paused, no script
        if (engine.isPaused()) {return;}
       
        if (!runOnce){
            runOnce=true;
            if(beam.getWeapon().getSize()==WeaponSize.MEDIUM){
                hasSmoke=true;
                TEXTURE_RANDOMNESS=M_TEXTURE_RANDOMNESS;
                GLOW_SIZE=M_GLOW_SIZE;
            } else if(beam.getWeapon().getSize()==WeaponSize.LARGE){
                hasSmoke=true;
                large=true;
                TEXTURE_RANDOMNESS=L_TEXTURE_RANDOMNESS;
                GLOW_SIZE=L_GLOW_SIZE;
            }
            return;
        }       
       
        timer.advance(amount);
        if(timer.intervalElapsed() && beam.getBrightness()>0.8f && MagicRender.screenCheck(0.1f, beam.getFrom())){

            beam.setPixelsPerTexel(15 + MathUtils.getRandomNumberInRange(-TEXTURE_RANDOMNESS, TEXTURE_RANDOMNESS));

            Vector2f from = beam.getFrom();
            Vector2f vel = beam.getSource().getVelocity();
            if(hasSmoke){
                float grey = MathUtils.getRandomNumberInRange(0.3f, 0.6f);
                if (Math.random()>0.5){
                    engine.addSmoothParticle(
                            MathUtils.getRandomPointInCircle(
                                    from,
                                    5
                            ),
                            new Vector2f (
                                    vel.x/2+MathUtils.getRandomNumberInRange(-5f, 5f),
                                    vel.y/2+MathUtils.getRandomNumberInRange(-5f, 5f)
                            ), 
                            MathUtils.getRandomNumberInRange(10f, 25f),
                            0.5f,
                            MathUtils.getRandomNumberInRange(1f, 5f),
                            new Color(grey,grey,grey,MathUtils.getRandomNumberInRange(0.02f, 0.08f) )
                    );
                } else {
                    engine.addSmokeParticle(
                            MathUtils.getRandomPointInCircle(
                                    from,
                                    5
                            ),
                            new Vector2f (
                                    vel.x/2+MathUtils.getRandomNumberInRange(-5f, 5f),
                                    vel.y/2+MathUtils.getRandomNumberInRange(-5f, 5f)
                            ), 
                            MathUtils.getRandomNumberInRange(10f, 25f),
                            0.5f,
                            MathUtils.getRandomNumberInRange(1f, 5f),
                            new Color(grey,grey,grey,MathUtils.getRandomNumberInRange(0.02f, 0.08f) )
                    );
                }
            }       
            engine.addSmoothParticle(
                    from,
                    vel,
                    MathUtils.getRandomNumberInRange(GLOW_SIZE-15, GLOW_SIZE+15),
                    0.5f,
                    0.05f,
                    new Color(255,50,25,128)
            );     
        }

        //on Hit, create impact effect
        if (beam.didDamageThisFrame()){           
            Vector2f end = beam.getTo(); 

            //splinters             
            float dir = VectorUtils.getAngle(beam.getDamageTarget().getLocation(), end);
            if (hasSmoke){
                engine.spawnProjectile(
                    beam.getSource(),
                    beam.getWeapon(),
                    "SCY_splinter1",
                    MathUtils.getRandomPointOnCircumference(end, 5),
                    dir + MathUtils.getRandomNumberInRange(-90, 90),
                    null
                );
                engine.spawnProjectile(
                    beam.getSource(),
                    beam.getWeapon(),
                    "SCY_splinter2",
                    MathUtils.getRandomPointOnCircumference(end, 5),
                    dir + MathUtils.getRandomNumberInRange(-90, 90),
                    null
                );
                if(large){                   
                    engine.spawnProjectile(
                        beam.getSource(),
                        beam.getWeapon(),
                        "SCY_splinter2",
                        MathUtils.getRandomPointOnCircumference(end, 5),
                        dir + MathUtils.getRandomNumberInRange(-90, 90),
                        null
                    );
                }
            } else {               
                //spawn a single splinters
                if(Math.random()>0.66){
                    engine.spawnProjectile(
                        beam.getSource(),
                        beam.getWeapon(),
                        "SCY_splinter1",
                        MathUtils.getRandomPointOnCircumference(end, 5),
                        dir + MathUtils.getRandomNumberInRange(-90, 90),
                        null
                    );
                } else if(Math.random()>0.5){
                    engine.spawnProjectile(
                        beam.getSource(),
                        beam.getWeapon(),
                        "SCY_splinter2",
                        MathUtils.getRandomPointOnCircumference(end, 5),
                        dir + MathUtils.getRandomNumberInRange(-90, 90),
                        null
                    );
                } 
            }             
        }
    }
}
[close]

which I have included should you want to read it.  I notice an association—my error report mentions the hidden class BeamSpec class, and the weapon involved has a BeamEffect—and now wonder if some interaction between this BeamEffect and the Global.getCombatEngine().spawnProjectile method has instead of my irreverent occult tampering caused the error.

wonder if your mod tries to spawn a BeamAPI as a projectile
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on October 31, 2022, 10:53:27 AM
wonder if your mod tries to spawn a BeamAPI as a projectile

I am worried that it might be, but I had thought this check would stop that problem:

Code
        if (direct.get("compartment") <= 0 && object instanceof DamagingProjectileAPI) {
            DamagingProjectileAPI projectile = (DamagingProjectileAPI) object;
            if (Ricochet.isCaused(projectile, ship)) Ricochet.occur(projectile, ship);
            reportDamage(0, 0, direct.get("emp"), 0, object, ship);
            return;
        }

Here is my new ricochet check and driver code.  The error occurs in the method occur.

Methods Called
Code: Methods Called
public final class Ricochet {
    ...

    /**
     * Return whether this {@link DamagingProjectileAPI} could ricochet.
     * <p></p>
     * @param projectile {@link DamagingProjectileAPI} hitting the armor of a
     *                   {@link ShipAPI}
     * <p></p>
     * @return {@link Boolean} whether the {@link DamagingProjectileAPI} will
     *         bounce off the armor of a {@link ShipAPI}
     */
    private static boolean isAble(final DamagingProjectileAPI projectile) {
        return getDamageType(projectile) == KINETIC
                && projectile.getProjectileSpec() != null
                && projectile.getProjectileSpec().getOnHitEffect() == null;
    }

    /**
     * Return whether this {@link DamagingProjectileAPI} ricochets off this
     * {@link ShipAPI} this time.
     * <p></p>
     * @param projectile {@link DamagingProjectileAPI} hitting the armor of a
     *                   {@link ShipAPI}
     * <p></p>
     * @return {@link Boolean} whether the {@link DamagingProjectileAPI} will
     *         bounce off the armor of a {@link ShipAPI}
     */
    public static boolean isCaused(final DamagingProjectileAPI projectile, final ShipAPI ship) {
        return isAble(projectile)
                && Collision.getClosestSegment(projectile.getLocation(), ship) != null
                && Collision.isPointWithinBounds(getLocationBehind(projectile.getLocation(),
                                                 Misc.normalise(projectile.getVelocity())), ship)
                && PROBABILITY * 90 * Math.random() > Collision.getObliqueAngle(projectile, ship);
    }

    /**
     * Bounce a {@link DamagingProjectileAPI} off the armor of a
     * {@link ShipAPI} at the same angle it hit.
     * <p></p>
     * @param projectile {@link DamagingProjectileAPI} hitting the armor of a
     *                   {@link ShipAPI}
     * @param ship {@link ShipAPI} being hit
     */
    public static void occur(final DamagingProjectileAPI projectile, final ShipAPI ship) {
        Global.getCombatEngine().spawnProjectile(
            projectile.getSource(),
            projectile.getWeapon(),
            projectile.getWeapon().getId(),
            projectile.getLocation(),
            getRicochetFacing(getRicochetVector(projectile, ship)),
            ship.getVelocity()
        );
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 31, 2022, 05:52:15 PM
An excellent question :)

Take a look at com.fs.starfarer.api.impl.campaign.plog.SModRecord, in particular its use of WeakReference<FleetMemberAPI>, it's an approach (about the only one I could think of) to solving this exact problem.

Short of, yes, trying to search through everything and then still not accounting for whatever random way some mod might be storing a fleet member.

It worked!!!

...Kind of. By changing all memory references of FleetMemberAPI to WeakReference<FleetMemberAPI> I was able to to get garbage collection to acknowledge that the FleetMemberAPI in question was due to be annihilated. The one problem I'm having is that garbage collection seems to happen on a completely arbitrary basis, so I may have to add a sentence or two in the upcoming forum post about how players need to save and load to force garbage collection if the station isn't recognizing that they have a redeemable ship hull. If you know a way to force garbage collection without saving and loading I'm all ears, but otherwise I'm pretty happy with how this turned out.

EDIT: saving/loading only seems to force garbage collection in dev mode, so it looks like I'll have to find a way around this unfortunately. See reply
It turns out regular old saving forces garbage collection, so it seems like telling players to do that might just be my solution. If there's an easy way to force garbage collection via the API (which there doesn't seem to be) I will be happy to implement it, but otherwise I'm very happy to just tell people to save their game since that doesn't seem like it requires a lot of effort on their part.

EDIT: I set up a script to run System.gc() when the player interacts with my station. This has completely solved all of my issues and eliminated the need for the player to save. Unless there's some sort of hidden consequences for doing this, I'm going to keep it this way.

If you think you need to force garbage collection, you probably need to rethink what you are doing. It is a code smell; a red flag of bad design.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on November 01, 2022, 11:04:52 AM
So, it's weapon mirroring question time again!

I've got this working in almost every context. Combat, fleet screen, and refit all work correctly. There's just one spot that still has problems: the mouseover tooltip in the refit screen. See attached image. You'll note that the weapon on the ship is displayed correctly, while the weapon in the tooltip has a non-mirrored base sprite with a mirrored array of missiles.
(Interestingly, if you -click- on the weapon, the drop-down list correctly displays it in fully non-mirrored form, including in the mouseover tooltip.)

@Alex: How do I fix this? Maybe I'm missing something, but I don't see anything obvious in the API that would let me do... anything relevant. (I'm guessing that, under the hood, that tooltip is constructed from the WeaponSpecAPI object, without reference to the weapon's SpriteAPI objects?)

Code that I'm using to mirror a weapon, as called from a WeaponEffectPluginWithInit's init method:
Code

public static void mirror( WeaponAPI weapon ) {
if( weapon == null ) return;
weapon.ensureClonedSpec();

mirror( weapon.getBarrelSpriteAPI() );
mirror( weapon.getSprite() );
mirror( weapon.getUnderSpriteAPI() );

List<Vector2f> fireOffsets = weapon.getSpec().getHardpointFireOffsets();
List<Float> angleOffsets = weapon.getSpec().getHardpointAngleOffsets();
mirrorOffsets( fireOffsets, angleOffsets );

fireOffsets = weapon.getSpec().getTurretFireOffsets();
angleOffsets = weapon.getSpec().getTurretAngleOffsets();
mirrorOffsets( fireOffsets, angleOffsets );

fireOffsets = weapon.getSpec().getHiddenFireOffsets();
angleOffsets = weapon.getSpec().getHiddenAngleOffsets();
mirrorOffsets( fireOffsets, angleOffsets );
}

public static void mirror( SpriteAPI s ) {
if( s == null ) return;
s.setWidth( -s.getWidth() );
s.setCenter( -s.getCenterX(), s.getCenterY() );
}

public static void mirrorOffsets( List<Vector2f> fireOffsets, List<Float> angleOffsets ) {
for( int i = 0; i < fireOffsets.size(); i++ ) {
// ensureClonedSpec does -not- clone the individual Vector2f objects, so we have to make new ones.
// Fortunately, it does clone the lists, so we can actually make changes here.
Vector2f v = (Vector2f)fireOffsets.get( i );
fireOffsets.set( i, new Vector2f( v.getX(), -1f * v.getY() ) );
}
for( int i = 0; i < angleOffsets.size(); i++ ) {
angleOffsets.set( i, -1f * (Float)angleOffsets.get( i ) );
}
}

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on November 01, 2022, 12:29:27 PM
Is it possible to spawn a derelict, in combat, without destroying a ship? I'm planning to make debris fields spawn a bunch of bits and pieces of destroyed ships (among other things). How would I do this without spamming the chat with "ship destroyed"?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on November 01, 2022, 01:36:17 PM
I'm trying to do this:
Code
            engine.spawnEmpArc(
                ship,
                ourCoordinates,
                null,
                ship,
                DamageType.ENERGY,
                500f,
                2000f,
                5000f,
                "tachyon_lance_emp_impact",
                20f,
                Color(25, 100, 155, 255),
                Color(255, 255, 255, 255)
            )

, however, it NPES on the 3rd line of this method, in EmpArcEntity.class:
Code
    public WeightedRandomPicker<D.Oo> getPotentialTargets(boolean var1) {
        float var2 = this.maxRange;
        int var3 = this.source.getOriginalOwner();
        WeightedRandomPicker var4 = new WeightedRandomPicker();
.

This is really weird-it seems like this method is called every time spawnEmpArc is called, thereby trying to access a potentially null variable... when the documentation of spawnEmpArc says damagesource can be null. Am I misunderstanding this? Or is the documentation just incorrect?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2022, 02:41:17 PM
I believe this is impossible, but is there any way to display "Heat" instead of "Flux" for a specific ship for the little combat indicator next to it?

Yeah, I don't think so - sorry!

It worked!!!

...Kind of. By changing all memory references of FleetMemberAPI to WeakReference<FleetMemberAPI> I was able to to get garbage collection to acknowledge that the FleetMemberAPI in question was due to be annihilated. The one problem I'm having is that garbage collection seems to happen on a completely arbitrary basis, so I may have to add a sentence or two in the upcoming forum post about how players need to save and load to force garbage collection if the station isn't recognizing that they have a redeemable ship hull. If you know a way to force garbage collection without saving and loading I'm all ears, but otherwise I'm pretty happy with how this turned out.

EDIT: saving/loading only seems to force garbage collection in dev mode, so it looks like I'll have to find a way around this unfortunately. See reply

You could call System.gc() but that will definitely cause a noticeable hitch/frame drop.

Have you considered also trying to detect that the ship did in fact get destroyed by using a FleetEventListener or something similar? You could then just use the WeakReference to make sure you're not hanging on to the reference past the ship being gone, for whatever other reason.

EDIT: I set up a script to run System.gc() when the player interacts with my station. This has completely solved all of my issues and eliminated the need for the player to save. Unless there's some sort of hidden consequences for doing this, I'm going to keep it this way.

(Ah!)


@Alex: How do I fix this? Maybe I'm missing something, but I don't see anything obvious in the API that would let me do... anything relevant. (I'm guessing that, under the hood, that tooltip is constructed from the WeaponSpecAPI object, without reference to the weapon's SpriteAPI objects?)

Hmm, I don't think you could. My guess is at that point it's using the base, non-mirrored weapon spec. I'm guessing your code does the mirroring at some point after the weapon is actually mounted?

... I guess you might mess around with, like, adding mirrored weapons to the player cargo, but I don't think there's a callback pre opening the weapon picker dialog. I think you're probably sol on this one, to be honest.


Is it possible to spawn a derelict, in combat, without destroying a ship? I'm planning to make debris fields spawn a bunch of bits and pieces of destroyed ships (among other things). How would I do this without spamming the chat with "ship destroyed"?

I don't *think* so. But you could temporarily set its hullSize to FIGHTER to avoid those messages.


This is really weird-it seems like this method is called every time spawnEmpArc is called, thereby trying to access a potentially null variable... when the documentation of spawnEmpArc says damagesource can be null. Am I misunderstanding this? Or is the documentation just incorrect?

Oh wow, fixed that up. That line is completely unnecessary, too, just a leftover code fragment.


(@Liral: ahh, I'm not sure. And it's a bit much for me to really dive into right now, unfortunately!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on November 01, 2022, 03:10:55 PM
@Alex: How do I fix this? Maybe I'm missing something, but I don't see anything obvious in the API that would let me do... anything relevant. (I'm guessing that, under the hood, that tooltip is constructed from the WeaponSpecAPI object, without reference to the weapon's SpriteAPI objects?)

Hmm, I don't think you could. My guess is at that point it's using the base, non-mirrored weapon spec. I'm guessing your code does the mirroring at some point after the weapon is actually mounted?

... I guess you might mess around with, like, adding mirrored weapons to the player cargo, but I don't think there's a callback pre opening the weapon picker dialog. I think you're probably sol on this one, to be honest.
I think you're misunderstanding where the problem is. That's not the weapon picker dialog - the weapon picker dialog works fine; no mirroring happens in it.

What breaks is the mouseover tooltip when you have the weapon installed in a location that makes it mirror: it appears to be retrieving weapon offsets from the cloned weaponspec (where they've been mirrored, and have to be mirrored in order for the missile positioning on the ship to be correct), and then combining that with the un-mirrored weapon sprite (i.e., ignoring the weapons' adjustments to its SpriteAPI objects).

...This doesn't, necessarily, mean that I'm not sol with getting this to work without API changes, of course, but I figure it's worth clarifying.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 01, 2022, 06:35:27 PM
Ah, you're absolutely right, my apologies!

<after 15 minutes digging into it> ... my further apologies, you still appear to be sol. This is also fairly tricky code to change, I don't think I can do it with any expectation of it working right without something to test against. If you were to provide a very small mod that does this to a weapon, I could give it a go, but, full disclosure: I couldn't spend *too* much time on it, so if it e.g. doesn't get done in less than a half an hour it doesn't get done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on November 01, 2022, 07:07:10 PM
Fair enough, and thank you for taking a look! Here's your mini-mod; it makes resonator MRMs (and only resonator MRMs) mirror themselves when installed on the left side of a ship.

(I'd be inclined to suggest, as a possible quick & simple fix, adding a WeaponAPI.getOriginalSpec() method that, when someone calls ensureClonedSpec(), retains a reference to an original unmodified copy. Then use that when assembling the tooltip. ...But, well. I don't know what the actual code there looks like, and perhaps that's not actually quick or simple or even a relevant idea in the first place. Best of luck!)

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on November 02, 2022, 07:20:18 AM
I have a mod that adds combat effects for hyperstorms. I add a bunch of nebulae to the combat map, and then add a script that, periodically, checks for nearby ships, does some math, and based on the results, either does or doesnt add another script that spawns a mine with NONE colission class, no targetting indicator, nigh infinite hp, and deletes/spawns another mine of this type every 0.1 seconds, placing every mine in the direction of the source of a EMP arc that will try to hit the ship in a few seconds. The idea is that this adds a threat in the direction of the EMP arc, provoking the AI into raising shields and blocking the arc.

The AI reacts to this pretty decently, however, when in combat, the ships tend to neglect the mine that has 2k energy damage and 6.5k EMP damage sitting right behind it in favor of raising its shield against a kite 700 Su away. On top of that, the AI seems to think they can either hit or avoid the mine, and thus phased ships unphase to use EMP emitter, ships use flares, or phase skimmer to run away. I'm not against them using movement to get away, since the EMP doesnt hit them if they're outside of it's range, but I'd like to make them have a higher priority in blocking the mine, as well as not use PD systems on something they literally cannot hit (why does EMP emitter try to hit things with NONE colission class?).

On top of that, it just seems iffy that the AI doesn't even try to avoid the storming nebulae. Any ideas on how to make the ships avoid the nebulae?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on November 02, 2022, 07:33:32 AM
Also, on that note, I know I'm using internal classes (I've casted CombatNebulaAPI to the internal class A, and I've used A's getNebulaAt() method to get Cloud), but, is ther eany awy to get the radius of a nebula cloud? I'm currently just approximating the average with flat unchanged values, but I'd like more accurate measurements.

I also want to know if I can replace the nebula texture at all-I want to make hyperclouds generate with, well, the hypercloud texture.

A few questions about this class as well:
What is "tileHasNebula()"? What is the tile in this context? What kind of values would I have to give to actually get a true value?
I'm really curious about "chargeNearbyClouds()" and "dumpFlux()". You don't have to answer, but, are these used? If not, what were they gonna be used for??
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on November 02, 2022, 07:36:39 AM
And finally: How would I go about rendering terrain effects in combat?

Let's say I want to render a magnetic field (and storm) in combat, heavily zoomed in, focused on where the playerfleet is. Is it possible to render the effect in combat, animation and all? If so, what's the first steps to doing that? I'm really (never done it before) unfamiliar with like, rendering, and animations, and most types of combat graphics, so I'm pretty clueless here. The most I know to do is get the spriteAPI, and use addLayeredRenderingPlugin to render /something/, but NOT how to animate it.

Same goes for slipstreams, as that's another thing I'd want to render.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 02, 2022, 08:18:59 AM
(@Liral: ahh, I'm not sure. And it's a bit much for me to really dive into right now, unfortunately!)

 :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 02, 2022, 09:50:53 AM
Fair enough, and thank you for taking a look! Here's your mini-mod; it makes resonator MRMs (and only resonator MRMs) mirror themselves when installed on the left side of a ship.

(I'd be inclined to suggest, as a possible quick & simple fix, adding a WeaponAPI.getOriginalSpec() method that, when someone calls ensureClonedSpec(), retains a reference to an original unmodified copy. Then use that when assembling the tooltip. ...But, well. I don't know what the actual code there looks like, and perhaps that's not actually quick or simple or even a relevant idea in the first place. Best of luck!)

Thank you, I really appreciate that! And, that's an excellent suggestion, I was caught up in making the tooltip render the mirrored weapon, but this is *way* simpler. Did it in about 5 minutes and verified that it works using your test mod :)

(Can I just say, this is super cool? I mean, I've seen this before and I think we've talked about some of the details, but it's just so neat that this is even possible and that it works so cleanly!)


I have a mod that adds combat effects for hyperstorms. I add a bunch of nebulae to the combat map, and then add a script that, periodically, checks for nearby ships, does some math, and based on the results, either does or doesnt add another script that spawns a mine with NONE colission class, no targetting indicator, nigh infinite hp, and deletes/spawns another mine of this type every 0.1 seconds, placing every mine in the direction of the source of a EMP arc that will try to hit the ship in a few seconds. The idea is that this adds a threat in the direction of the EMP arc, provoking the AI into raising shields and blocking the arc.

The AI reacts to this pretty decently, however, when in combat, the ships tend to neglect the mine that has 2k energy damage and 6.5k EMP damage sitting right behind it in favor of raising its shield against a kite 700 Su away. On top of that, the AI seems to think they can either hit or avoid the mine, and thus phased ships unphase to use EMP emitter, ships use flares, or phase skimmer to run away. I'm not against them using movement to get away, since the EMP doesnt hit them if they're outside of it's range, but I'd like to make them have a higher priority in blocking the mine, as well as not use PD systems on something they literally cannot hit (why does EMP emitter try to hit things with NONE colission class?).

Honestly, this is just a "how it works is how it works" kind of situation - I don't know the answers to your questions offhand. My *guess* would be that CollsionClass.NONE is what's making the mine not register as a threat shields-wise but this is something you could test. It's entirely possible - likely, even - that CollisionClass.NONE mines are just not a thing the AI knows how to deal with, and it's not likely to learn unless I end up needing this sort of thing for vanilla.


On top of that, it just seems iffy that the AI doesn't even try to avoid the storming nebulae. Any ideas on how to make the ships avoid the nebulae?

Fleets used to do that, but now that it's a thing, they "go slow" instead. Take a look at some unused code in TacticalModule.updateAvoidList() to see how that was done.


Also, on that note, I know I'm using internal classes (I've casted CombatNebulaAPI to the internal class A, and I've used A's getNebulaAt() method to get Cloud), but, is ther eany awy to get the radius of a nebula cloud? I'm currently just approximating the average with flat unchanged values, but I'd like more accurate measurements.

There's no concept of a "radius", a nebula is a bunch of tiles that overlap to create the illusion of something smoother. Just in general, if you're doing this sort of stuff, you're pretty much on your own and I generally discourage it because it'll break horribly with every release. I'd much rather get API requests that make modding better for everyone than a bunch of mods using internals.

I also want to know if I can replace the nebula texture at all-I want to make hyperclouds generate with, well, the hypercloud texture.

You can use MissionDefinitionAPI.setNebulaTex() and .setNebulaMapTex().


A few questions about this class as well:
What is "tileHasNebula()"? What is the tile in this context? What kind of values would I have to give to actually get a true value?

(See: the bit about nebulas being tiles-based, and the bit about being on your own.)

I'm really curious about "chargeNearbyClouds()" and "dumpFlux()". You don't have to answer, but, are these used? If not, what were they gonna be used for??

IIRC waaaaay back nebulas used to be created when ships vented flux - it was never actually fleshed out and it was, not to put too fine a point on it, not good.


And finally: How would I go about rendering terrain effects in combat?

Let's say I want to render a magnetic field (and storm) in combat, heavily zoomed in, focused on where the playerfleet is. Is it possible to render the effect in combat, animation and all? If so, what's the first steps to doing that? I'm really (never done it before) unfamiliar with like, rendering, and animations, and most types of combat graphics, so I'm pretty clueless here. The most I know to do is get the spriteAPI, and use addLayeredRenderingPlugin to render /something/, but NOT how to animate it.

Same goes for slipstreams, as that's another thing I'd want to render.

You're on the right track here! You want a layered rendering plugin and then, well, just a bunch of OpenGL code rendering whatever you're rendering. For stuff like magnetic fields, take a look at the terrain plugin to see how it does its rendering.

For slipstreams, I would not recommend doing it in combat, performance would suffer. You'd want something different and much more performant that gets the basic feeling across.


(@Liral: ahh, I'm not sure. And it's a bit much for me to really dive into right now, unfortunately!)

 :'(

(Sorry! There's only so much deep-dive digging I can reasonably do, especially when it's to do with stuff that's not in the API and is being used in complicated ways and isn't easy for me to reproduce etc etc etc. If I know something offhand or something jumps out, I'm happy to answer, but if I don't, this kind of thing can get inordinately time-consuming.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on November 02, 2022, 10:27:35 AM
Honestly, this is just a "how it works is how it works" kind of situation - I don't know the answers to your questions offhand. My *guess* would be that CollsionClass.NONE is what's making the mine not register as a threat shields-wise but this is something you could test. It's entirely possible - likely, even - that CollisionClass.NONE mines are just not a thing the AI knows how to deal with, and it's not likely to learn unless I end up needing this sort of thing for vanilla.

Yeah, they probably just don't know how to handle it. They DO avoid it though! They raise shields, phase away-but they never prioritize it above anything theyre fighting.
I thought the mines the volatile rift beam or whatever that omega weapon is called had this type of colissionclass, though? (It DOES spawn mines, right?)

Fleets used to do that, but now that it's a thing, they "go slow" instead. Take a look at some unused code in TacticalModule.updateAvoidList() to see how that was done.
I meant in-combat, not campaign.

There's no concept of a "radius", a nebula is a bunch of tiles that overlap to create the illusion of something smoother. Just in general, if you're doing this sort of stuff, you're pretty much on your own and I generally discourage it because it'll break horribly with every release. I'd much rather get API requests that make modding better for everyone than a bunch of mods using internals.
Yeeeah that's about what I thought. And about being on my own-I know, i should've mentioned I know that I'm basically voiding my warranty doing this. I'll make an API request to expose the nebula manager further in a bit (as well as the clouds themselves), maybe.
As for now, since I've got no idea how the tiles work, until either 1. the game updates and my mod breaks horribly, or 2. the game updates with a more fleshed out nebula API, I'll just raycast in 8 directions until the raycasting value doesn't return CombatNebulaAPI.locationHasNebula(raycastingpoint) and approximate a radius/bounds based on the values I get.


Anyway, thanks for the response, really appreciate it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on November 02, 2022, 11:04:34 AM
Fair enough, and thank you for taking a look! Here's your mini-mod; it makes resonator MRMs (and only resonator MRMs) mirror themselves when installed on the left side of a ship.

(I'd be inclined to suggest, as a possible quick & simple fix, adding a WeaponAPI.getOriginalSpec() method that, when someone calls ensureClonedSpec(), retains a reference to an original unmodified copy. Then use that when assembling the tooltip. ...But, well. I don't know what the actual code there looks like, and perhaps that's not actually quick or simple or even a relevant idea in the first place. Best of luck!)

Thank you, I really appreciate that! And, that's an excellent suggestion, I was caught up in making the tooltip render the mirrored weapon, but this is *way* simpler. Did it in about 5 minutes and verified that it works using your test mod :)

(Can I just say, this is super cool? I mean, I've seen this before and I think we've talked about some of the details, but it's just so neat that this is even possible and that it works so cleanly!)
You can! I'd even say you did. Also, thank you, and thank you for fixing this! (For now, I guess I just won't mirror asymmetrical missile launchers in turret mounts unless someone goes into a config file and checks off 'do this thing that breaks graphics in some tooltips'.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 02, 2022, 11:43:42 AM
(Sorry! There's only so much deep-dive digging I can reasonably do, especially when it's to do with stuff that's not in the API and is being used in complicated ways and isn't easy for me to reproduce etc etc etc. If I know something offhand or something jumps out, I'm happy to answer, but if I don't, this kind of thing can get inordinately time-consuming.)

Aw, ok.  I have added the try-catch block to a hotfix I released yesterday, keeping the crash from happening, and will inform the Scy author about the bug and ask him to help me narrow its possible causes.  If I find something clearer, I will let you know.

(Meanwhile, I of all modders should wish to leave you free to develop your next release because I am eagerly awaiting its API improvements to replace (at least some of) my black magic!  ;D)

Best wishes, Alex.  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 04, 2022, 11:34:02 PM
Is there a way to access the modid string of a hullmod from the hullmod's corresponding class file? For example if a hullmod has the id "advanced_reactor" is it possible to extract that string as a variable inside the AdvancedReactor class? I'm guessing it involves the HullModSpecAPI getId() method but I don't know how to call it properly.

Thanks for the help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on November 05, 2022, 12:24:17 PM
Is there a way to access the modid string of a hullmod from the hullmod's corresponding class file? For example if a hullmod has the id "advanced_reactor" is it possible to extract that string as a variable inside the AdvancedReactor class? I'm guessing it involves the HullModSpecAPI getId() method but I don't know how to call it properly.

Thanks for the help.

the id field in applyEffectsBeforeShipCreation & applyEffectsAfterShipCreation are the hullmod's id
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on November 05, 2022, 02:01:58 PM
Is there a way to access the modid string of a hullmod from the hullmod's corresponding class file? For example if a hullmod has the id "advanced_reactor" is it possible to extract that string as a variable inside the AdvancedReactor class? I'm guessing it involves the HullModSpecAPI getId() method but I don't know how to call it properly.

Thanks for the help.
In addition to Ruddy's comment, BaseHullMod also includes a "spec" variable which is set to the HullModSpecAPI of the hullmod it belongs to. You can then grab that spec's ID with the method you mentioned.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WiC2021 on November 05, 2022, 11:29:21 PM
Does anyone know or have an example of a shipsystem that lets you choose where a pd_drone will spawn based on cursor position? Sort of like how the Doom mine strike works?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 06, 2022, 05:06:59 PM
(Apologies for the delay in responding, everyone! Been a busy couple of days with IRL stuff, not bad just busy.)

Yeah, they probably just don't know how to handle it. They DO avoid it though! They raise shields, phase away-but they never prioritize it above anything theyre fighting.
I thought the mines the volatile rift beam or whatever that omega weapon is called had this type of colissionclass, though? (It DOES spawn mines, right?)

Oh yeah, you're right about that. And they're CollisionClass.NONE, too. I don't honestly remember how it all works; it's possible there's a half-measures bandaid in the AI to make it work just well enough for that specific use case or some such. Also I think the AI considers not the mine but the time until and the specs of the actual explosion?

I'll make an API request to expose the nebula manager further in a bit (as well as the clouds themselves), maybe.

Thank you!

You can! I'd even say you did. Also, thank you, and thank you for fixing this! (For now, I guess I just won't mirror asymmetrical missile launchers in turret mounts unless someone goes into a config file and checks off 'do this thing that breaks graphics in some tooltips'.)

*thumbs up*

Does anyone know or have an example of a shipsystem that lets you choose where a pd_drone will spawn based on cursor position? Sort of like how the Doom mine strike works?

Nothing comes to mind for me, at least as far as vanilla goes.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 09, 2022, 11:03:51 AM
the id field in applyEffectsBeforeShipCreation & applyEffectsAfterShipCreation are the hullmod's id

Thanks, that was so obvious once you mentioned it.

I have another hullmod related question. I am trying to make a new hullmod that's similar to converted hangar with fewer restrictions. At its most basic it just adds an extra hangar slot to any ship, even those that already have hangar bays. Everything works except with this one edge case where if a ship has hangar bays, equips the hullmod, adds a new fighter to that bonus slot, then removes the hullmod, the OP cost for the new fighter won't get refunded. And if the hullmod is re-added the fighter will pop up again. Does anyone have a solution to this? In the case with ships that don't already have fighter slots the fighter removal step seems to be handled by something else besides the hullmod class.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on November 09, 2022, 12:34:18 PM
is it possible to add a custom damage texture to a ship on hit that disappears after sometime? was wondering if I could copy the disintigrator effect and modify it but not sure if its intended for that
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on November 09, 2022, 06:03:46 PM
hello once again all.
i have a question regarding the submarkets, and doing things to ships within said submarkets.
so adding a hullmod to a ship within a submarket, works fine. ican see it there when you look at the ship. moveing the ship to my fleet, it still says it has the hullmod. but if i open the retrofit screen of that ship, the hullmod vanishes. i have no idea what i am doing wrong.
i know its not the hullmod doing it, as if i add it in the retrofit screen, it works as intended.
hullmod is 0 op cost, and is unlocked and not hidden
here is the code i use to add the hullmod:
Code
List<FleetMemberAPI> ships = market.getSubmarket("AIRetrofit_ShipyardSubmarket").getCargo().getMothballedShips().getMembersListCopy();
for(FleetMemberAPI ship : ships){
ship.getVariant().addMod("AIRetrofit_ShipyardBase");
}
thank you all again for all the kind help you have been willing to give me in the past. -me
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2022, 12:45:20 PM
I have another hullmod related question. I am trying to make a new hullmod that's similar to converted hangar with fewer restrictions. At its most basic it just adds an extra hangar slot to any ship, even those that already have hangar bays. Everything works except with this one edge case where if a ship has hangar bays, equips the hullmod, adds a new fighter to that bonus slot, then removes the hullmod, the OP cost for the new fighter won't get refunded. And if the hullmod is re-added the fighter will pop up again. Does anyone have a solution to this? In the case with ships that don't already have fighter slots the fighter removal step seems to be handled by something else besides the hullmod class.

I'm not sure if that specific thing is addressable or not, but IIRC "not having to worry about edge cases of a similar nature" is part of why CH only works on ships with no fighter bays.

is it possible to add a custom damage texture to a ship on hit that disappears after sometime? was wondering if I could copy the disintigrator effect and modify it but not sure if its intended for that

Hmm - I mean, you could do something like that, I'm sure! Just a question of how much OpenGL code you're willing to writ to stencil a decal onto the hull.

hello once again all.
i have a question regarding the submarkets, and doing things to ships within said submarkets.
so adding a hullmod to a ship within a submarket, works fine. ican see it there when you look at the ship. moveing the ship to my fleet, it still says it has the hullmod. but if i open the retrofit screen of that ship, the hullmod vanishes. i have no idea what i am doing wrong.
i know its not the hullmod doing it, as if i add it in the retrofit screen, it works as intended.
hullmod is 0 op cost, and is unlocked and not hidden
here is the code i use to add the hullmod:
Code
List<FleetMemberAPI> ships = market.getSubmarket("AIRetrofit_ShipyardSubmarket").getCargo().getMothballedShips().getMembersListCopy();
for(FleetMemberAPI ship : ships){
ship.getVariant().addMod("AIRetrofit_ShipyardBase");
}
thank you all again for all the kind help you have been willing to give me in the past. -me

I'm not sure about the specific reason for the particular issue, but if you're going to make changes to a variant, you *need* to make sure that its VariantSource is REFIT and not e.g. STOCK. Otherwise you're going to change a global variant and affect all ships using it.

Basically, the process would be to make a copy of the variant using clone(), making changes to the copy, and setting the fleet member's variant to the copy. See the uses of ShipVariantAPI.clone() for some examples of code doing that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on November 11, 2022, 01:52:33 PM
Is there a way to get every loaded spriteAPI?
Getting worrily in-depth on a silly mod idea that'll let players "paint" in the combat layer w/ some opengl & allowing them to paste stickers arbitrarily through some extra menu would be a fun additon, though not essential well, none of it is but y'know.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on November 11, 2022, 02:47:42 PM
Is there any way to ensure a cloned ShipVariantAPI object from a MutableShipStatsAPI object?

For context: I'm trying to make a hullmod that replaces any vulcan cannons on fighters carried by a ship with fancy laser guns.

This means making a hullmod that implements applyEffectsToFighterSpawnedByShip(), which gives me a ShipAPI object for the fighter I'm working with.

ShipAPI has 'cloneVariant' and 'getVariant' methods, but making changes via ship.getVariant().addWeapon() does not actually change the fighters on the field.

If, instead, I get the ShipVariantAPI object via ShipAPI.getMutableStats().getVariant(), then changes I make apply... but they apply to all fighters on the field, rather than just the ones I tried to make changes to.

And/or, is there some other way I should be trying to do this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2022, 03:31:55 PM
Is there a way to get every loaded spriteAPI?
Getting worrily in-depth on a silly mod idea that'll let players "paint" in the combat layer w/ some opengl & allowing them to paste stickers arbitrarily through some extra menu would be a fun additon, though not essential well, none of it is but y'know.

I don't... think so?

Is there any way to ensure a cloned ShipVariantAPI object from a MutableShipStatsAPI object?

For context: I'm trying to make a hullmod that replaces any vulcan cannons on fighters carried by a ship with fancy laser guns.

This means making a hullmod that implements applyEffectsToFighterSpawnedByShip(), which gives me a ShipAPI object for the fighter I'm working with.

ShipAPI has 'cloneVariant' and 'getVariant' methods, but making changes via ship.getVariant().addWeapon() does not actually change the fighters on the field.

If, instead, I get the ShipVariantAPI object via ShipAPI.getMutableStats().getVariant(), then changes I make apply... but they apply to all fighters on the field, rather than just the ones I tried to make changes to.

And/or, is there some other way I should be trying to do this?

Hmm, I don't think that's going to work - the variant it's using for "what weapons are on the ship" (etc) is being passed around as a parameter in some internal methods, so you can't really get at that and change what it points to.

I'm not sure what the best way to do this might be. Perhaps spawning new fighters and quietly replacing the existing ones with them, from a script? It seems tricky, regardless.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silveressa on November 13, 2022, 02:33:15 AM
Just wondering where the values for the fluff text and actual scripts are for the "deal with prisoners" skill/ability?

(Working on a mod that gives the option of trying to recruit prisoners either as crew or marines for credits, instead of torturing them into serving you.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on November 13, 2022, 05:18:29 PM
Just wondering where the values for the fluff text and actual scripts are for the "deal with prisoners" skill/ability?

(Working on a mod that gives the option of trying to recruit prisoners either as crew or marines for credits, instead of torturing them into serving you.)
(Named) prisoners are a mod feature, so you'll want to adapt one of the two mods (a specific one) that implement this functionality.

Capture Officers and Crew doesn't have a public source that I could find in 15 seconds. Although you shouldn't be working from this mod anyway.
For Take No Prisoners, look in the src folder for the code (maybe ask presidentmattdamon for help if you can't find a specific function). Dialog text is in data/campaign/rules.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Silveressa on November 13, 2022, 08:26:37 PM

Capture Officers and Crew doesn't have a public source that I could find in 15 seconds. Although you shouldn't be working from this mod anyway.
For Take No Prisoners, look in the src folder for the code (maybe ask presidentmattdamon for help if you can't find a specific function). Dialog text is in data/campaign/rules.csv.

Thanks for this, it's been a while since I played SS, and I'd forgotten that feature was from a mod and not part of the core gameplay  :P. Regardless, now I know its another modders work  I don't plan on working from their mods specifically, but more using one of them as an example of how to organize the coding and layout so it functions as desired.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 18, 2022, 12:11:05 AM
I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

Also what are the string values that are returned for getAICoreId()? For example if the AI core is an alpha, does it return "alpha" or something else?

Finally, is there a way to replace the description of a ship with a new one upon adding a hullmod?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on November 18, 2022, 05:44:06 PM
is there a way to completely intercept an input and stop the game from acting on it?
I'm making an in-combat GUI & I'd like to have text fields in it if possible. (well, they'd be possible anyway, albeit extremely janky)
my best guess is that consume()'ing both the down & up event would do it, though I've not been able to think of a good way of tracking what event trails from another
(also, why is the list of keycodes seemingly non-standard? the VK_etc constants in java.awt.event didn't seem to match up with the ones the game returns)

I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

checking for the automated ship hullmod should be enough here, there's no way (afaik) to have an ai core pilot a ship otherwise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 18, 2022, 06:07:00 PM
I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

checking for the automated ship hullmod should be enough here, there's no way (afaik) to have an ai core pilot a ship otherwise.

The idea for the mod is to convert certain modded automated ships into human pilotable versions, but have the conversion hullmod instillation be invalid if the ship has an AI captain (especially an integrated one), but valid if the ship is currently unpiloted, so sadly just checking for the automated hullmod won't do. Although I suppose having an is ship being captained check is fine too.

I also had plans to make hullmods that would give bonuses that scale with the AI core grade, so it would be helpful to know how to check for captain status rather than just the hullmod's existence.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on November 19, 2022, 01:42:05 AM
Is it possible to get a projectileSpec or weaponSpec without spawning the weapon or projectile in combat? trying to get stats of a projectile for calculations purposes before spawning it in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on November 19, 2022, 08:03:03 AM
Is it possible to get a projectileSpec or weaponSpec without spawning the weapon or projectile in combat? trying to get stats of a projectile for calculations purposes before spawning it in.

yeah, Global.getSettings.getWeaponSpec("weaponId"); will return the weapon you want, then weaponSpecAPI.getProjectileSpec(); can get you the projectile.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on November 19, 2022, 10:50:19 AM
yeah, Global.getSettings.getWeaponSpec("weaponId"); will return the weapon you want, then weaponSpecAPI.getProjectileSpec(); can get you the projectile.
Nice, ty
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Amazigh on November 19, 2022, 11:19:39 PM
Is there a way to set a weapon to render under engine glows?

If not, (which is how it appears to be) would it be possible to add one? (pretty please alex)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2022, 10:30:13 AM
I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

See: WolfpackTactics.isFrigateAndOfficer() for an example of this sort of thing.


Also what are the string values that are returned for getAICoreId()? For example if the AI core is an alpha, does it return "alpha" or something else?

The id of the ai core "commodity" (from commodities.csv); see: the Commodities class, which has a bunch of data members with these ids for easy reference, e.g. Commodities.ALPHA_CORE etc.


Finally, is there a way to replace the description of a ship with a new one upon adding a hullmod?

Not that I can think of!


is there a way to completely intercept an input and stop the game from acting on it?
I'm making an in-combat GUI & I'd like to have text fields in it if possible. (well, they'd be possible anyway, albeit extremely janky)
my best guess is that consume()'ing both the down & up event would do it, though I've not been able to think of a good way of tracking what event trails from another

Hmm, maybe - consume() should in theory do it but I think that by the time you're getting these events the game has already acted on them in that frame? Not 100%; depends on where you're doing this from etc, I'd suggest just giving it a try?

(also, why is the list of keycodes seemingly non-standard? the VK_etc constants in java.awt.event didn't seem to match up with the ones the game returns)

They're constants from the org.lwjgl.input.Keyboard class IIRC; depending on what exactly you're talking about.


Is there a way to set a weapon to render under engine glows?

If not, (which is how it appears to be) would it be possible to add one? (pretty please alex)

I don't think so. Ahh, sorry, it'd be kind ofquite a pain!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on November 20, 2022, 03:39:02 PM
Hmm, maybe - consume() should in theory do it but I think that by the time you're getting these events the game has already acted on them in that frame? Not 100%; depends on where you're doing this from etc, I'd suggest just giving it a try?

They're constants from the org.lwjgl.input.Keyboard class IIRC; depending on what exactly you're talking about.

I'm doing it in the processInputPreCoreControls method of a baseEveryFrameCombatPlugin, rn I'm just checking for isKeyDownEvent() & consuming them (and I'd been hoping that that'd pre-emptively eat the input), I'll look for a workaround.

and ty for pointing me there, that seems to be the right class!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2022, 06:26:31 PM
Ah - if it's processInputPreCoreControls(), then it might do what you're expecting. I mean, the thing to do would be to test if it does?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 22, 2022, 08:20:25 AM
We are re-implementing the code that calculates damage to the hit cell and surrounding cells of an ArmorGridAPI and resulting damage (without any other modifiers) to the hull for our Starsector research project (https://fractalsoftworks.com/forum/index.php?topic=25536.135) but do not quite know how it works and cannot find any reference implementation or a rigorous specification for one, so I have proposed one below.  Is it exactly correct?   :D

Code
    private static float getPooledArmor(
        final int iHit,
        final int jHit,
        final ArmorGridAPI armorGrid,
    ) {
        float pooledArmor = 0;
        for (int i = 0; i < 5; i++)
            for (int j = 0; i < 5; j++)
                if ((i == 0 || i == 5) && (j == 0 || j == 5)) //skip corners
                    continue;
                else if (i == 0 || i == 5 || j == 0 || j == 5) //edges contribute half value
                    pooledArmor += 0.5 * armorGrid.getArmorValue(iHit + i, jHit + j);
                else //center 9 contribute full value
                    pooledArmor += armorGrid.getArmorValue(iHit + i, jHit + j);
        return pooledArmor;
    }
   
    private static float getHullDamage(
        final float damage,
        final float pooledArmor,
        final float armorRating,
        final float minimumArmorFactorForHullDamageReduction
    ) {
        return damage
               * damage
               / (damage + Math.max(pooledArmor, armorRating * minimumArmorFactorForHullDamageReduction));
    }
   
    private static float getArmorDamage(
        final boolean isBeam,
        final float damage,
        final float pooledArmor,
        final float maxArmorDamageReductionFactor,
        final DamageType damageType
    ) {
        float hitStrengthAgainstArmor = damage * (isBeam ? 0.5f : 1);
        switch (damageType) {
            case KINETIC: hitStrengthAgainstArmor *= 0.5;
            case HIGH_EXPLOSIVE: hitStrengthAgainstArmor *= 2;
            case FRAGMENTAETION: hitStrengthAgainstArmor *= 0.25f;
        }
        return hitStrengthAgainstArmor
               * Math.max(1 - maxArmorDamageReductionFactor,
                          hitStrengthAgainstArmor / (hitStrengthAgainstArmor + pooledArmor));
    }
   
    private static void damageArmorGrid(
        final int iHit,
        final int jHit,
        final float armorDamage,
        final ArmorGridAPI armorGrid
    ) {
       for (int i = 0; i < 5; i++)
            for (int j = 0; i < 5; j++)
                if ((i == 0 || i == 5) && (j == 0 || j == 5)) //skip corners
                    continue;
                else if (i == 0 || i == 5 || j == 0 || j == 5) //edges take half damage
                    armorGrid.setArmorValue(i, j, Math.max(0, armorGrid.getArmorValue(i,j) - 0.5 * armorDamage));
                else //center 9 take full damage
                    armorGrid.setArmorValue(i, j, Math.max(0, armorGrid.getArmorValue(i,j) - armorDamage)); 
    }
   
    private static void applyDamage(
        final boolean isBeam,
        final int iHit,
        final int jHit,
        final float damage,
        final float minimumArmorFactorForHullDamageReduction,
        final float maxArmorDamageReductionFactor,
        final DamageType damageType,
        final ShipAPI ship
    ) {
        final ArmorGridAPI armorGrid = ship.getArmorGrid();

        //calculate damage
        final float pooledArmor = getPooledArmor(armorGrid, iHit, jHit);
        final float hullDamage = getHullDamage(damage, pooledArmor, armorGrid.getArmorRating(), minimumArmorFactorForHullDamageReduction);
        final float armorDamage = getArmorDamage(isBeam, damage, pooledArmor, maxArmorDamageReductionFactor, damageType);
       
        //apply damage
        damageArmorGrid(iHit, jHit, armorDamage, armorGrid);
        ship.setHitpoints(Math.max(ship.getHitpoints() - hullDamage, 0)); //obviously makes ship disappear rather than explode, but we don't care about that effect
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on November 22, 2022, 08:35:16 AM
How to change the explosion effect when a missile runs out of flight time or fizzling?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Raif Redacted on November 22, 2022, 07:38:46 PM
Is it possible to create a new category of hullmod that applies a logistics-style two-at-once rule? I want to split the logistics hullmods into two categories: Supply and Science. Basically, toss the "find us more room for people and things, and be more efficient at it!" into one pile and then "Go do science for us!" into the other, but still apply the current logistics rule to both.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 22, 2022, 11:36:40 PM
Terminator and Borer drones don't show up as equippable even in devmode. I would like to have a custom drone mimic this behavior but I'm not sure what's triggering it or how to invoke it. Is this something that can be done to modded content?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on November 23, 2022, 05:27:44 AM
How to get a ships location in combat for that frame?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on November 23, 2022, 06:53:13 AM
How to get a ships location in combat for that frame?

ship.getLocation();
It's a function from combatEntityAPI, shipAPI inherits it from there since it extends combatEntityAPI
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on November 24, 2022, 02:12:16 AM
I am adding my BaseIntelPlugin-inherited class as a campaign message via
Code
void addMessage(IntelInfoPlugin intel, MessageClickAction action);
What I want to do is take the player to cargo screen each time he clicks message icon. Problem is, MessageClickAction enum has every UI tab except the one I need: cargo.
Code
	public static enum MessageClickAction {
FLEET_TAB,
REFIT_TAB,
INTEL_TAB,
CHARACTER_TAB,
INCOME_TAB,
COLONY_INFO,
INTERACTION_DIALOG,
NOTHING,
}
And even if it would have needed enum, that wouldn't solve the issue because

Code
public void actionPerformed(Object var1, Object var2) {
method in obfuscated "A" class that actually handles icon clicks does not account for cargo tab variant in its switch block:

Spoiler
Code
        if (var3 != null && var3.getAction() != null) {
            Object var7 = var3.getCustom();
            switch($SWITCH_TABLE$com$fs$starfarer$api$campaign$comm$CommMessageAPI$MessageClickAction()[var3.getAction().ordinal()]) {
            case 1:
                CampaignEngine.getInstance().getCampaignUI().showCoreUITab(CoreUITabId.FLEET, var7);
                break;
            case 2:
                if (var7 instanceof FleetMember) {
                    CampaignEngine.getInstance().getCampaignUI().showCoreUITab(CoreUITabId.REFIT, var7);
                } else {
                    CampaignEngine.getInstance().getCampaignUI().showCoreUITab(CoreUITabId.REFIT);
                }
                break;
            case 3:
                if (var7 == null) {
                    CampaignEngine.getInstance().getCampaignUI().showCoreUITab(CoreUITabId.INTEL, var3.getIntel());
                } else {
                    CampaignEngine.getInstance().getCampaignUI().showCoreUITab(CoreUITabId.INTEL, var7);
                }
                break;
            case 4:
                CampaignEngine.getInstance().getCampaignUI().showCoreUITab(CoreUITabId.CHARACTER);
                break;
            case 5:
            case 6:
                CampaignEngine.getInstance().getCampaignUI().showCoreUITab(CoreUITabId.OUTPOSTS, var7);
                break;
            case 7:
                if (var7 instanceof SectorEntityToken) {
                    InteractionDialogPlugin var6 = CampaignEngine.getInstance().getModAndPluginData().pickInteractionDialogPlugin((Object)null, (SectorEntityToken)var7);
                    if (var6 != null && !CampaignEngine.getInstance().getCampaignUI().isShowingDialog()) {
                        CampaignEngine.getInstance().getCampaignUI().showInteractionDialog(var6, (SectorEntityToken)var7);
                    }
                }
            case 8:
            }

        }
[close]

My question is: can I work around this issue to implement the desired behaviour? If not, can I request adding the option for cargo tab as MessageClickAction and expanding respective switch options, since it doesn't appear to be that much work to add?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 24, 2022, 05:06:52 PM
We are re-implementing the code that calculates damage to the hit cell and surrounding cells of an ArmorGridAPI and resulting damage (without any other modifiers) to the hull for our Starsector research project (https://fractalsoftworks.com/forum/index.php?topic=25536.135) but do not quite know how it works and cannot find any reference implementation or a rigorous specification for one, so I have proposed one below.  Is it exactly correct?   :D

If you're following the wiki, I believe what's there about the armor damage calculations is correct. Whether what you wrote is a correct implementation of that is a different question :)

How to change the explosion effect when a missile runs out of flight time or fizzling?

Without knowing what you mean by "effect" (visual? mechanical?) I'd say probably a script with custom code doing <whatever>?

Is it possible to create a new category of hullmod that applies a logistics-style two-at-once rule? I want to split the logistics hullmods into two categories: Supply and Science. Basically, toss the "find us more room for people and things, and be more efficient at it!" into one pile and then "Go do science for us!" into the other, but still apply the current logistics rule to both.

Take a look at BaseLogisticsHullMod, the limited-number-of-mods aspect is handled there. I think the easiest would be to keep the Logistics tag but also add tags for Supply and Science.


Terminator and Borer drones don't show up as equippable even in devmode. I would like to have a custom drone mimic this behavior but I'm not sure what's triggering it or how to invoke it. Is this something that can be done to modded content?

I think it *would* let you mount it in the campaign if you ever got your hands on it. The "edit variants" screen I think goes off it *not* having any autofit tags (like bomber5 or similar). So just copying the Terminator's tags in wing_data.csv should do it.


My question is: can I work around this issue to implement the desired behaviour? If not, can I request adding the option for cargo tab as MessageClickAction and expanding respective switch options, since it doesn't appear to be that much work to add?

I'm fairly sure this isn't supported, yeah. You may be able to open the cargo tab using CampaignUIAPI.showCoreUITab() but offhand no way to detect that the click is coming from a message comes to mind. Let me add this to my list, though, full disclosure, the list is long and this is rather low priority.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Raif Redacted on November 24, 2022, 07:15:52 PM
Is it possible to create a new category of hullmod that applies a logistics-style two-at-once rule? I want to split the logistics hullmods into two categories: Supply and Science. Basically, toss the "find us more room for people and things, and be more efficient at it!" into one pile and then "Go do science for us!" into the other, but still apply the current logistics rule to both.

Take a look at BaseLogisticsHullMod, the limited-number-of-mods aspect is handled there. I think the easiest would be to keep the Logistics tag but also add tags for Supply and Science.

Ok, found that. Turns out knowing nothing about this language makes it hard to adjust it. Who would have thought?

edit: I'm figuring it out. Thanks for the reply.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Argentum Rhodes on November 24, 2022, 11:11:29 PM
So very new to the forums. I was browsing some of the mods, and frequently play heavily modded Starsector. I was wondering if it would be possible to make a Strike Craft from like Arma Armatura land on an enemy ship. Since they have the functionality to land on friendly carriers to resupply. What made me think of this was Boarding utility from Creature. Could a strike craft if enemy shields were down land on enemy ship to do a boarding action?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 25, 2022, 01:50:43 PM
We are re-implementing the code that calculates damage to the hit cell and surrounding cells of an ArmorGridAPI and resulting damage (without any other modifiers) to the hull for our Starsector research project (https://fractalsoftworks.com/forum/index.php?topic=25536.135) but do not quite know how it works and cannot find any reference implementation or a rigorous specification for one, so I have proposed one below.  Is it exactly correct?   :D

If you're following the wiki, I believe what's there about the armor damage calculations is correct. Whether what you wrote is a correct implementation of that is a different question :)

I guess I'll verify with experiments!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 26, 2022, 04:07:49 PM
Thanks for answering my previous questions Alex  :)

Is there a way to access the phase cost and phase upkeep of a ship? getPhaseCloakActivationCostBonus() and     getPhaseCloakUpkeepCostBonus() seem to be stat bonuses that don't allow me to pull the base value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 27, 2022, 12:11:54 PM
So very new to the forums. I was browsing some of the mods, and frequently play heavily modded Starsector. I was wondering if it would be possible to make a Strike Craft from like Arma Armatura land on an enemy ship. Since they have the functionality to land on friendly carriers to resupply. What made me think of this was Boarding utility from Creature. Could a strike craft if enemy shields were down land on enemy ship to do a boarding action?

I honestly don't know offhand, it's the sort of thing you (or someone) would need to muck around with and see.  I suppose the answer is "yes" because it's possible to rig up entirely custom graphics for this, though - and you'd probably want to avoid the existing fighter mechanics more or less entirely. I don't think they'd help much and they could get in the way.


Is there a way to access the phase cost and phase upkeep of a ship? getPhaseCloakActivationCostBonus() and     getPhaseCloakUpkeepCostBonus() seem to be stat bonuses that don't allow me to pull the base value.

You could get the base values using ShieldSpecAPI.getPhaseCost() and getPhaseUpkeep().

The actual cost-to-use-on-this-ship values I think you could get by:
ship.getPhaseCloak().getFluxPerUse() and
ship.getPhaseCloak().getFluxPerSecond().

Don't forget to check if ship.getPhaseCloak() != null...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on November 28, 2022, 08:44:37 AM
Not sure if a bug or just a consequence of tampering where one does not belong, but here's what I've encountered:

I decided to swap a grid layout in ability tooltip with tables, as I could not achieve desired precision of column alignment with grids (had to use spaces for adjustments, which was not pleasant), and after making the replacement I found out that tables produce a constant sound of mousing-over whenever I do actually mouse over them. My guess was that it was due to the tooltip constantly re-rendering, and tables are created by default without said re-rendering in mind.

Precisely speaking, each created row is in some way a Button, therefore at creation it is assigned setMouseOverSound("ui_button_mouseover"). Initially I thought the UITable instance is responsible for this behaviour, and tried to call setItemsSelectable() on it, but it turned out to be false. In the end, with the help of kind Viravain and Lyravega I was able to fix this behaviour by calling setMouseOverSound(null) on each row, but it's not exactly an optimal or easiest solution.

Perhaps an argument could be added to beginTable() in TooltipMakerAPI to have the rows created be without mouse-over sound? Of course hardly any modder finds himself with an urge to shove a table in his ability tooltip, I understand, and it does seem like a bit of work to implement...

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on November 28, 2022, 08:14:14 PM
question
is planet renderer obfuscated? or i just simply can't find where it is?
i always assumed it's obfuscated, but then i stumbled on the corona renderer, which is actually exposed, so ehhhhhhhhhhh
can i have some concrete answer ?
i mean the whole thing that renders the 3d object ball with texture. can it be called somehow without creating a new sector entity? just for pure visuals?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2022, 12:38:31 PM
Not sure if a bug or just a consequence of tampering where one does not belong, but here's what I've encountered:

I decided to swap a grid layout in ability tooltip with tables, as I could not achieve desired precision of column alignment with grids (had to use spaces for adjustments, which was not pleasant), and after making the replacement I found out that tables produce a constant sound of mousing-over whenever I do actually mouse over them. My guess was that it was due to the tooltip constantly re-rendering, and tables are created by default without said re-rendering in mind.

Precisely speaking, each created row is in some way a Button, therefore at creation it is assigned setMouseOverSound("ui_button_mouseover"). Initially I thought the UITable instance is responsible for this behaviour, and tried to call setItemsSelectable() on it, but it turned out to be false. In the end, with the help of kind Viravain and Lyravega I was able to fix this behaviour by calling setMouseOverSound(null) on each row, but it's not exactly an optimal or easiest solution.

Perhaps an argument could be added to beginTable() in TooltipMakerAPI to have the rows created be without mouse-over sound? Of course hardly any modder finds himself with an urge to shove a table in his ability tooltip, I understand, and it does seem like a bit of work to implement...

Had a quick look - easy enough to add a check that should (I think) fixed this, but, I'm confused: if this is a tooltip of the sort that gets recreated every frame, then how are you mousing over the table without the mouse movement hiding the tooltip?

question
is planet renderer obfuscated? or i just simply can't find where it is?
i always assumed it's obfuscated, but then i stumbled on the corona renderer, which is actually exposed, so ehhhhhhhhhhh
can i have some concrete answer ?
i mean the whole thing that renders the 3d object ball with texture. can it be called somehow without creating a new sector entity? just for pure visuals?

It's obfuscated, sorry! I don't think there's an easy way to render it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on November 29, 2022, 09:58:02 PM
is there some hidden trick with fighters' engine controller?
i'm running a code to get where the fighter is trying to accelerate, but it is only returning accurate value for what seems to be the wing leader(?), and for other fighters in wing it returns 0, meaning none of the checks are ever true
Spoiler
Code
public static float getEngineAccelerationDirection(ShipAPI ship){
            float result=0;

            ShipEngineControllerAPI eng = ship.getEngineController();
            if(eng.isAccelerating()){result=ship.getFacing();}
            if(eng.isAcceleratingBackwards()){result=ship.getFacing()+180f;}
            if(eng.isStrafingLeft()){result=ship.getFacing()+90f;}
            if(eng.isStrafingRight()){result=ship.getFacing()-90f;}
            if(eng.isAccelerating()&&eng.isStrafingLeft()){result=ship.getFacing()+45f;}
            if(eng.isAccelerating()&&eng.isStrafingRight()){result=ship.getFacing()-45f;}
            if(eng.isAcceleratingBackwards()&&eng.isStrafingLeft()){result=ship.getFacing()+135f;}
            if(eng.isAcceleratingBackwards()&&eng.isStrafingRight()){result=ship.getFacing()-135f;}

            if(eng.isDecelerating()){result=VectorUtils.getFacing(ship.getVelocity())+180f;}

            return result;
        }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on November 30, 2022, 04:34:06 AM
Had a quick look - easy enough to add a check that should (I think) fixed this, but, I'm confused: if this is a tooltip of the sort that gets recreated every frame, then how are you mousing over the table without the mouse movement hiding the tooltip?

Ah, it's the same behaviour as with vanilla tooltips for sensor range and sensor profile: once the tooltip goes expanded, tooltip area encompasses mouse cursor and the tooltip does not go away until mouse is outside it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on November 30, 2022, 02:45:57 PM
[EDIT: Resolved!] Looks like my class files weren't getting put into the jar, which explains why the game couldn't find them. Opening up the jar file with 7zip was the key to figuring this out for me, at the advice of some folks on the discord.


Been getting an error for my code now that looks like it should be an easy fix, but I'm just not seeing what's wrong.

Code
34770 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [plugins.stardust_ModPlugin]
java.lang.RuntimeException: Error loading [plugins.stardust_ModPlugin]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: plugins.stardust_ModPlugin
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Which indicates to me that it can't find my mod plugin, but I'm not sure why not.

Code is compiled into Stardust_Ventures.jar. Zero errors compiling the jar, so all good there.

mod_info.json looks like this:
Spoiler
Code
{

    "id": "stardustventures",

    "name": "Stardust Ventures",

    "author": "Mephansteras",

    "version": "0.5.3 Alpha",

    "description": "A set of ships focused on exploration, surveying, and living outside the core worlds.",

    "gameVersion": "0.95.1a-RC6",

     "jars":["jars/Stardust_Ventures.jar"],

    "modPlugin":"plugins.stardust_ModPlugin"

}
[close]

Code for the mod plugin itself is this:
Spoiler
Code
package plugins;

import com.fs.starfarer.api.BaseModPlugin;
import java.lang.RuntimeException;
import java.lang.ClassNotFoundException;

import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.impl.campaign.procgen.ProcgenUsedNames;
import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.PluginPick;
import com.fs.starfarer.api.combat.MissileAIPlugin;
import com.fs.starfarer.api.campaign.CampaignPlugin;
import java.io.IOException;
import org.json.JSONException;
import java.lang.Exception;
import java.util.HashMap;

public class stardust_ModPlugin extends BaseModPlugin
{
    // basic ModPlugin code taken from theDragn's High Tech Expansion mod, but no longer reliant on kotlin
    // Thanks to theDragn for directing me to it!

    @Override
    public void onGameLoad(boolean newGame)
    {
        SectorAPI sector = Global.getSector();
        if (!sector.hasScript(stardust_FleetStatManager.class))
        {
            sector.addScript(new stardust_FleetStatManager());
        }
    }

}

The code has some unnecessary imports I haven't cleaned up yet, but I doubt they'd be causing this specific error./spoiler]


I'm assuming this is something like an IDE configuration problem, or maybe some reference I need that I'm missing?

Just not quite enough info in the log error to really tell me what I'm doing wrong, and I'm too new at Java to spot it.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on December 04, 2022, 02:12:29 PM
what are the requirements for a condition to show up in the planet search? Just marking it as "planetary" apparently is not enough.
Thanks for your time!

Edit - Answer: it requires extending BaseHazardCondition and an entry in condition_gen_data.csv, it does not have to be a planetary condition.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 04, 2022, 03:05:40 PM
is there some hidden trick with fighters' engine controller?

IIRC: yes. I forget exactly what it does but there's some hackery behind the scenes to make it look "right" for the wingmen, so that might explain the odd values you're seeing.

Ah, it's the same behaviour as with vanilla tooltips for sensor range and sensor profile: once the tooltip goes expanded, tooltip area encompasses mouse cursor and the tooltip does not go away until mouse is outside it.

(Ah, thank you - I forgot about that!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 04, 2022, 10:58:51 PM
is there some hidden trick with fighters' engine controller?

IIRC: yes. I forget exactly what it does but there's some hackery behind the scenes to make it look "right" for the wingmen, so that might explain the odd values you're seeing.

another question then, is it possible to make wing members behave independently? as in, not fly in formation?
or some other workaround?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2022, 08:46:30 AM
I think *theoretically* maybe yes because you can provide an entirely custom ship AI for them, but at a level of difficulty below that, I don't think so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on December 05, 2022, 10:24:39 AM
I'd like to add in a hullmod that reduces the chances of hitting an asteroid on the campaign map, but even after walking through a bunch of the code base I'm still not sure what I'd need to do to actually implement that effect.

I expect it'd be similar to the listener I already have in place that checks for ship hullmods in the fleet to improve maneuverability on the campaign map, so I have that in place.

What would be the best way to do this?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 05, 2022, 10:33:02 AM
Is there any way I can figure out what the exact cause of this crash is given that it's obfuscated?

Quote
1656302 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.ai.movement.maneuvers.RetreatManeuver.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.movement.maneuvers.RetreatManeuver.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.movement.maneuvers.int$o.o00000(Unknown Source)
   at com.fs.starfarer.combat.ai.movement.maneuvers.int.super(Unknown Source)
   at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)

I can't reproduce it and it only seems to happen very rarely, but I can only really can surmise it is related to a ship trying to retreat, and its likely related to my mod since others have reported a similar NPE while using it. Could something like calling ShipAPI.resetDefaultAI() cause it??
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2022, 11:54:02 AM
I'd like to add in a hullmod that reduces the chances of hitting an asteroid on the campaign map, but even after walking through a bunch of the code base I'm still not sure what I'd need to do to actually implement that effect.

I expect it'd be similar to the listener I already have in place that checks for ship hullmods in the fleet to improve maneuverability on the campaign map, so I have that in place.

What would be the best way to do this?

The only easy way to affect this is using Stats.NAVIGATION_PENALTY_MULT (see: Navigation.java for an example), but that affects all terrain penalties, not just asteroid impact chance.

The only other way would be to replace the vanilla AsteroidBeltTerrainPlugin with a custom one but that would be both more involved and less friendly to other mods.

Is there any way I can figure out what the exact cause of this crash is given that it's obfuscated?
...

I can't reproduce it and it only seems to happen very rarely, but I can only really can surmise it is related to a ship trying to retreat, and its likely related to my mod since others have reported a similar NPE while using it. Could something like calling ShipAPI.resetDefaultAI() cause it??

Do you by chance have any HullSize.FIGHTER ships that are not proper fighters but are treated as regular ships instead? If so: that could cause this, and should actually be fixed in the next release.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on December 05, 2022, 12:18:04 PM
I'd like to add in a hullmod that reduces the chances of hitting an asteroid on the campaign map, but even after walking through a bunch of the code base I'm still not sure what I'd need to do to actually implement that effect.

I expect it'd be similar to the listener I already have in place that checks for ship hullmods in the fleet to improve maneuverability on the campaign map, so I have that in place.

What would be the best way to do this?

The only easy way to affect this is using Stats.NAVIGATION_PENALTY_MULT (see: Navigation.java for an example), but that affects all terrain penalties, not just asteroid impact chance.

The only other way would be to replace the vanilla AsteroidBeltTerrainPlugin with a custom one but that would be both more involved and less friendly to other mods.

Hmm. Ok, thanks Alex! I'll take a look at NAVIGATION_PENALTY_MULT and see if I can make that work for what I'm thinking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 05, 2022, 06:12:49 PM
question
is there a way to apply dead ship's visuals (i.e. smoke and fire and explosions on surface) to a ship that _isn't_ dead
either entirely to the whole ship, or selectively as individual smoke plumes?
is any part of that directly accessible?
Spoiler
(https://i.imgur.com/lpuBXVs.jpg)
[close]
additionally, what are the steps that needs to be taken to resurrect a dead ship? setting hp to non-zero and setHulk to false and owner to player didn't fix it entirely, it still can't actually do anything

not even considering any particular application, just exploring the possibilities
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2022, 06:26:54 PM
question
is there a way to apply dead ship's visuals (i.e. smoke and fire and explosions on surface) to a ship that _isn't_ dead
either entirely to the whole ship, or selectively as individual smoke plumes?
is any part of that directly accessible?
Spoiler
(https://i.imgur.com/lpuBXVs.jpg)
[close]

This is GraphicsLib :)


additionally, what are the steps that needs to be taken to resurrect a dead ship? setting hp to non-zero and setHulk to false and owner to player didn't fix it entirely, it still can't actually do anything

not even considering any particular application, just exploring the possibilities

Not sure, haven't tried it myself! I'd imagine you need to call ship.resetDefaultAI() at some point, and CombatEntityAPI.setOwner(), but you would likely still have issues with CombatFleetManagerAPI thinking the ship is still disabled, when combat is over.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Arcangelus on December 05, 2022, 07:19:49 PM
Hello. I was wondering if there is any particular reason to save fleet data alongside the stats of a given captain.

A while ago, I was tinkering with the functions required to copy the stats from a captain to another. In this process, I noticed that there are 3 main structures that a given officer can take (according to the save file). Some are just a references, others contain all the expected data plus memory, and a third type that contains a copy of the fleet information inside the stats section.
This 3rd type is used for (at least) the position (pst) patrolCommander and the fleet section is non interactable (and apparently static). Direct duplicates of the officer in question keep this fleet info. The function getStats() copies this section as well, despite being unused (I manually removed the data from the save file just to test it) and there is no native way of interacting with it.
Manually removing the fleet section via save editing reveals no ills effects that I could see, albeit I never tried to do so on a commanding officer on active patrol.

I asked on discord about it way back on June, and the solution proposed was unable to remove this "junk data". As this "issue" only resulted in slightly larger save files at a time I was experimenting with the IDLE, I did not press further. However, the addition of a method to remove this data (whenever making getStats() ignore it or being able to target it directly) would be welcome.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 05, 2022, 07:35:26 PM
The officer data has a reference to the fleet data. How it ends up being laid out in the savefile is not super relevant; one of the places that reference this fleet data will end up having the actual data in the savefile included there, and other references will just... reference it. Where exactly the actual data is inserted in the file is not indicative of the behind-the-scenes structure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 08, 2022, 01:42:12 AM
Do you by chance have any HullSize.FIGHTER ships that are not proper fighters but are treated as regular ships instead? If so: that could cause this, and should actually be fixed in the next release.

Yeah, thats probably it. I'll keep hullsize as frigate in the mean time. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mechanica on December 08, 2022, 10:18:30 PM
is there a way to make a specific music track play when within specific systems?, could this be doable only on a per system basis or possibly via faction control?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on December 10, 2022, 01:20:12 AM
Is there a way to prevent a specific ship and it’s bp from generating in salvage/as derelicts during a new game start as part of a settings.json Boolean?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on December 10, 2022, 04:36:01 AM
For hullmods, is there a way to pull the ship.getFleetMember().getCaptain().getAICoreId() inside applyEffectsBeforeShipCreation? stats.getEntity() doesn't work outside of combat, so I'm kind of stuck.

Edit: never mind, after banging my head against this for hours I got it to work with:

Code
if (stats.getFleetMember() != null) String coreId = stats.getFleetMember().getCaptain().getAICoreId();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 10, 2022, 04:51:30 PM
Weird things, sometimes if I use addPara in TextPanelAPI, the paras will have a basic padding between lines. Meanwhile if I use textPanel.beginTooltip() and use tooltip.addPara(), the paras will be no padding between lines.

Is there any way to make the tooltip paras work like textpanel texts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2022, 05:37:29 PM
is there a way to make a specific music track play when within specific systems?, could this be doable only on a per system basis or possibly via faction control?

You can put the sound id (from sounds.json) of the music you want for that system into the system's memory, using the MusicPlayerPluginImpl.MUSIC_SET_MEM_KEY key.

Is there a way to prevent a specific ship and it’s bp from generating in salvage/as derelicts during a new game start as part of a settings.json Boolean?

For blueprints, you'd need to add the rare_bp tag for blueprints to be generated, so it'd just be a matter of not doing that. For derelicts, you'd need to make the ship not available to any faction.


Weird things, sometimes if I use addPara in TextPanelAPI, the paras will have a basic padding between lines. Meanwhile if I use textPanel.beginTooltip() and use tooltip.addPara(), the paras will be no padding between lines.

Is there any way to make the tooltip paras work like textpanel texts?

TooltipMakerAPI.addPara() takes a pad parameter, so just passing in some value >0 for that should do the job? I forget what the exact value TextPanelAPI uses; I think it's something like 1.5x the line height of the font.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on December 10, 2022, 10:54:08 PM
TooltipMakerAPI.addPara() takes a pad parameter, so just passing in some value >0 for that should do the job? I forget what the exact value TextPanelAPI uses; I think it's something like 1.5x the line height of the font.

Well I mean the padding between the lines not the paragraphs...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 11, 2022, 08:00:02 AM
Could you post a screenshot? The spacing between lines of the same paragraph should be the same (provided the font is the same), both use the same Label class which means the same code handles line wrapping/spacing/etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on December 11, 2022, 08:55:30 AM
I would like to add a weapon icon to a hull mods description through Tooltip.addImage
and the ToolTipMakerAPI.addImage only accepts string not SpriteAPI. Does one exist where I can addImage through SpriteAPI or alternatively is there a way to grab the sprite image when it's displayed in codex or refit
There *is* no one sprite for weapons with barrels or missiles, it's composited together from the various pieces depending on how the weapon is set up. Your best bet might be to add something like TooltipMakerAPI.showCargo(), though that likely won't do quite what you want.

I'm interested specifically in those simple shapes beneath weapon sprite that represent ballistic/missile/energy slots and sizes. I take it they are fully procedurally drawn with GL11 calls, right? Could there be any way for me to recreate these simple shapes (or shapes of similar design) with the color I want in TooltipMakerAPI? I looked around in StandardTooltipV2 and CargoTooltipFactory, but the process definitely eludes me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 11, 2022, 10:04:24 AM
Ah - yeah, it's a bunch of GL11 calls, and there isn't any way to easily duplicate that via the API, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on December 12, 2022, 12:48:19 AM
I've ran into an issue with
Code
addImage(String spriteName)
in TooltipMakerAPI. Method works when I pass "graphics/icons/cargo/whatever.png" with vanilla icons, but when I try to do the same with images in my mod graphics folders it doesn't render the sprite. I've double-checked with a sprite that was already working as part of BaseIntelPlugin-inheritor class
Code
public String getIcon() {
        return Global.getSettings().getSpriteName("intel", "forge_production_report");
    }
- it renders fine when appearing as campaign UI message icon (so game loads it), but fails to render via addImage in TooltipMakerAPI. Tinkered plenty with settings.json graphics categories and ids - nothing; another noticeable thing is that icons in vanilla cargo folders load alright, but all-white vanilla icons like those in graphics/ui/icons do not; so maybe there's some property of image files that needs to be adhered to.

Searched through forum, seems like people already had this issue pop up - not sure how it was resolved if was at all. My question  is: how do I use addImage() properly to get it to render images? What properties the images should have? Searched also through  various methods in API that concern sprites - not much luck with Javadocs.

Edit: resolved, problem was my own lack of attention when writing methods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 12, 2022, 07:37:16 AM
If a module on a ship is destryoed, is it possible to replace it with a new one during combat? I'd imagine this is a no go since it'd require a change to the variant or something and those dont seem to be something that can be reloaded in combat but figured id double check before proceeding with a (kind of) hacky alternative
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2022, 01:24:56 PM
If a module on a ship is destryoed, is it possible to replace it with a new one during combat? I'd imagine this is a no go since it'd require a change to the variant or something and those dont seem to be something that can be reloaded in combat but figured id double check before proceeding with a (kind of) hacky alternative

You couple probably "replace" it in the sense of "spawning another ship of the same type and variant at the same location" but linking it up with the same fleet member, making sure the game doesn't still think it was destroyed, etc, is going to be tricky. I think your best bet might be looking at the PhaseAnchor hullmod - it avoids these issues by triggering right before fatal damage is applied.

(Note: the javadoc for HullDamageAboutToBeTakenListener.notifyAboutToTakeHullDamage() is wrong; returning true is what makes the damage be negated. I've fixed up the javadoc just now.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on December 14, 2022, 07:53:53 AM
That works perfectly. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 17, 2022, 07:27:48 AM
not directly modding related, but is there a reason why a load of in-combat scripts (esp. like ship systems) run in the refit screen?
mostly asking because it's been annoying me lately, I keep forgetting to check for a ship's owner and the game just explodes on me because of it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2022, 08:51:23 AM
... yes? :)

(Seriously, though, it's just a "how it works".)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 17, 2022, 01:37:52 PM
fair heh, I wasn't entirely sure what answer I was expecting :D

though, an isInRefitScreen() or similar boolean would be nice for shipAPI, checking the owner feels overly wierd and janky even if it's technically correct
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2022, 01:55:54 PM
What *is* the owner in refit screen? I'd assume it's probably 0 but based on what you're saying it's 100?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 17, 2022, 03:03:07 PM
hmmmmm, I thought it was -1 (and a quick search in the unnoficial discord has meso confirming this in 2019), though after some testing it does seem to be 0.

...AH-HA! the original owner is -1 in the refit screen but the owner is 0; I didn't expect there to be a difference there.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 17, 2022, 03:16:28 PM
... ahh, interesting/neat/unintended!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 18, 2022, 11:50:15 PM
are weapon ai hints ignored by fighters? is there any way to make them work?
in particular the CONSERVE_FOR_ANTI_ARMOR and  GROUP_ALTERNATING in application to burst beams
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2022, 11:36:48 AM
are weapon ai hints ignored by fighters? is there any way to make them work?
in particular the CONSERVE_FOR_ANTI_ARMOR and  GROUP_ALTERNATING in application to burst beams

CONSERVE_FOR_ANTI_ARMOR is ignored by fighters, yeah. Your best bet is probably a fighter-specific copy of the weapon.

GROUP_ALTERNATING is for automatic weapon group generation only, it doesn't affect AI behavior. So for fighters, where whether the group is linked or alternating is just going to be specified in the variant, this hint doesn't apply.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 19, 2022, 08:56:00 PM
CONSERVE_FOR_ANTI_ARMOR is ignored by fighters, yeah. Your best bet is probably a fighter-specific copy of the weapon.
but it is a custom weapon made specifically for the fighter
how to make it only be used against armor?
it is a HE beam, and the fighter is happily shooting it at the shield
is there any way to prevent that? make the weapon only be used against armor?
aside from just manually disabling the weapon in everyframe script
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 20, 2022, 12:39:06 PM
My bad, I wasn't thinking straight. There's no way to do that, no. In the next release there's a "USE_LESS_VS_SHIELDS" AI hint which would - for a non-ammo-using-weapon - prevent it from being autofired into shields, but the fighter might still decide to fire it manually. Although, I forget if fighters do that or if they just set everything on autofire.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Drakzorg on December 20, 2022, 03:08:16 PM
How can I activate the transverse jump in the tutorial? In the last version it's disabled, so, what I need to modify in the game files to enable it again?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 21, 2022, 05:13:56 AM
is it possible to make ship's shadow (one that appears when taking off or landing) to appear  for a specific ship at all times, not just when taking off or landing ?
this shadow:
(https://i.imgur.com/SFaqYzB.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on December 21, 2022, 12:26:10 PM
How can I tell if a ship is controlled by the player? Not just the player's team but the actual ship he's controlling. I thought GetCaptain() might work but I want to be able to use it in missions too and getCaptain always return null.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 21, 2022, 01:20:40 PM
How can I activate the transverse jump in the tutorial? In the last version it's disabled, so, what I need to modify in the game files to enable it again?

You'd need to edit and recompile etc com.fs.starfarer.api.impl.campaign.abilities.FractureJumpAbility class. So: probably not the easiest thing in the world, not e.g. like editing a text file.

is it possible to make ship's shadow (one that appears when taking off or landing) to appear  for a specific ship at all times, not just when taking off or landing ?
this shadow:

Hmm, I don't believe so. (Might cause performance problems, too.)

How can I tell if a ship is controlled by the player? Not just the player's team but the actual ship he's controlling. I thought GetCaptain() might work but I want to be able to use it in missions too and getCaptain always return null.

You can check if it's == to the ship returned by Global.getCombatEngine().getPlayerShip()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on December 21, 2022, 01:39:03 PM
I don't assume it's possible to manipulate beam speed of weapons? I can't find a mutablestat of it, weaponapi has no method for it, so I just made copies of vanilla weapons with very high beam speed. Works, but I don't like it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on December 21, 2022, 01:57:07 PM
I'd also like to be able to tweak beam speed, if that's practical to expose in the API.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 22, 2022, 04:08:03 AM
a recent update to a mod had me digging around in AICoreOfficerPlugin and it gave me a few thoughts -

1 - is it possible to restrict what AI core types can be installed? e.g., if I have a special fancy automated ship and I only want my special fancy AI cores being installed in it, is that possible without janktm?
2 - is it possible to change what skills are available to AI cores? that mod I mentioned does have a custom AI core w/ a custom skill, but it doesn't appear in the picker menu to be reassigned.

(and to get a bit API request-y, if they're not currently possible, can we get methods to do them if they're not too much of a pain to implement?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on December 22, 2022, 06:47:57 AM
Question: How do I get the mouse position during combat? I want to know the relative bearing from a ship to the mouse.

Edit: Thank you thank you thank you Ruddygreat. You are a lifesaver.
(I edited instead of adding a replay to avoid thread-bloat).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 22, 2022, 08:06:13 AM
Question: How do I get the mouse position during combat? I want to know the relative bearing from a ship to the mouse.

Global.getCombatEngine().getPlayerShip().getMouseTarget(); is what you want
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2022, 10:46:22 AM
a recent update to a mod had me digging around in AICoreOfficerPlugin and it gave me a few thoughts -

1 - is it possible to restrict what AI core types can be installed? e.g., if I have a special fancy automated ship and I only want my special fancy AI cores being installed in it, is that possible without janktm?
2 - is it possible to change what skills are available to AI cores? that mod I mentioned does have a custom AI core w/ a custom skill, but it doesn't appear in the picker menu to be reassigned.

(and to get a bit API request-y, if they're not currently possible, can we get methods to do them if they're not too much of a pain to implement?)

For the skill picker, if the skill is npc_only, then it only shows that skill if it also has the "ai_core" tag.

For restricting which AI cores are used, hmm. I don't think it's currently possible without, as you say, jank - if you provide your own custom plugin for the cores you *don't* want on your ship, you'd still have to create a PersonAPI for that core ID, or the game would crash. I've changed it so that the game will skip over that core ID instead.

In the meantime your best bet might be to (jankily) create a person with no skills and a name like "CAN NOT INSTALL" or something :) And also to make sure that your plugin kicks in for *all* commodities with the ai_core tag, so that it can grab priority for your ship... er, hmm, you don't have access to which ship the core is being picked for either, do you? That seems like a problem.

Let me add a FleetMemberAPI parameter to the relevant methods... there, done. Actually, never mind - that has some complications. Sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on December 23, 2022, 01:57:14 PM
Is it possible to modify the damage a projectile will do right as it hits BEFORE it does it's damage? I want a projectile that loses damage with range.
I did this before by creating a weapon with only 1 damage and then adding the damage I really want afterward in the onHit event. But I'm hoping there is a better way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 23, 2022, 03:32:13 PM
Is it possible to modify the damage a projectile will do right as it hits BEFORE it does it's damage? I want a projectile that loses damage with range.
I did this before by creating a weapon with only 1 damage and then adding the damage I really want afterward in the onHit event. But I'm hoping there is a better way.

yeah, have the weapon's everyFrameEffect add a DamageDealtModifier listener to the ship that checks if the weapon deals damage, then checks for the difference between the projectile's start point & current position

you can look at the old version of the ballistic mastery skill for an example, iirc it should still be in the API (though it might be commented out)

Let me add a FleetMemberAPI parameter to the relevant methods... there, done. Actually, never mind - that has some complications. Sorry!

awww, unfortunate but thanks for giving it a shot!
and re: AI core skills - I was a little unclear in my post, I was thinking (well, hoping heh) more along the lines of providing a list of skills that I'd want the AI to have access to in the aiCoreOfficerPlugin, though I get the feeling that that'd also be annoyingly complicated to implement.

anyway, merry christmas, thanks for letting me pick your brain about this so close to the holidays!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 23, 2022, 03:40:40 PM
and re: AI core skills - I was a little unclear in my post, I was thinking (well, hoping heh) more along the lines of providing a list of skills that I'd want the AI to have access to in the aiCoreOfficerPlugin, though I get the feeling that that'd also be annoyingly complicated to implement.

Ahh, I see. Yeah, it's not really set up like that right now, to ask the plugin for available skills. I'll keep that in mind!

anyway, merry christmas, thanks for letting me pick your brain about this so close to the holidays!

You too, thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on December 24, 2022, 03:19:38 AM
hello! having an issue with my favorite save
is it, saveable?
pun intended
Spoiler
61074 [Thread-3] INFO  exerelin.campaign.intel.merc.MercDataManager  -   Loading merc company: rocketStars
61076 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Error loading
61076 [Thread-3] ERROR com.fs.starfarer.campaign.save.CampaignGameManager  - Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : java.lang.NullPointerException
cause-message       : null
method              : exerelin.campaign.intel.merc.MercContractIntel.readResolve()
class               : exerelin.campaign.intel.merc.MercContractIntel
required-type       : exerelin.campaign.intel.merc.MercContractIntel
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number         : 15831
class[1]            : java.util.ArrayList
converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[2]            : java.util.LinkedHashMap
converter-type[2]   : com.thoughtworks.xstream.converters.collections.MapConverter
class[3]            : com.fs.starfarer.campaign.rules.Memory
class[4]            : com.fs.starfarer.campaign.econ.Market
class[5]            : com.fs.starfarer.campaign.CampaignPlanet
class[6]            : com.fs.util.container.repo.ObjectRepository
class[7]            : com.fs.starfarer.campaign.StarSystem
class[8]            : com.fs.starfarer.campaign.CircularOrbit
class[9]            : com.fs.starfarer.campaign.CircularOrbitPointDown
class[10]           : com.fs.starfarer.campaign.CustomCampaignEntity
class[11]           : exerelin.campaign.ai.concern.PirateActivityConcern$RageEntry
class[12]           : java.util.HashSet
class[13]           : exerelin.campaign.ai.concern.PirateActivityConcern
class[14]           : exerelin.campaign.ai.MilitaryAIModule
class[15]           : exerelin.campaign.ai.StrategicAI
class[16]           : com.fs.starfarer.campaign.Faction
class[17]           : exerelin.campaign.ai.concern.HostileInSharedSystemConcern
class[18]           : exerelin.campaign.ai.concern.DevelopRelationsConcern
class[19]           : exerelin.campaign.ai.DiplomaticAIModule
class[20]           : com.fs.starfarer.campaign.econ.Submarket
class[21]           : com.fs.starfarer.campaign.econ.reach.ReachEconomy
class[22]           : com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper
class[23]           : com.fs.starfarer.campaign.econ.Economy
class[24]           : com.fs.starfarer.campaign.StarSystem$UpdateFromHyperspaceLocation
class[25]           : com.fs.starfarer.campaign.BaseLocation$LocationToken
class[26]           : com.fs.starfarer.campaign.Hyperspace
class[27]           : com.fs.starfarer.campaign.CampaignEngine
converter-type[3]   : com.fs.starfarer.campaign.save.oooO
version             : not available
-------------------------------
com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : java.lang.NullPointerException
cause-message       : null
method              : exerelin.campaign.intel.merc.MercContractIntel.readResolve()
class               : exerelin.campaign.intel.merc.MercContractIntel
required-type       : exerelin.campaign.intel.merc.MercContractIntel
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number         : 15831
class[1]            : java.util.ArrayList
converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[2]            : java.util.LinkedHashMap
converter-type[2]   : com.thoughtworks.xstream.converters.collections.MapConverter
class[3]            : com.fs.starfarer.campaign.rules.Memory
class[4]            : com.fs.starfarer.campaign.econ.Market
class[5]            : com.fs.starfarer.campaign.CampaignPlanet
class[6]            : com.fs.util.container.repo.ObjectRepository
class[7]            : com.fs.starfarer.campaign.StarSystem
class[8]            : com.fs.starfarer.campaign.CircularOrbit
class[9]            : com.fs.starfarer.campaign.CircularOrbitPointDown
class[10]           : com.fs.starfarer.campaign.CustomCampaignEntity
class[11]           : exerelin.campaign.ai.concern.PirateActivityConcern$RageEntry
class[12]           : java.util.HashSet
class[13]           : exerelin.campaign.ai.concern.PirateActivityConcern
class[14]           : exerelin.campaign.ai.MilitaryAIModule
class[15]           : exerelin.campaign.ai.StrategicAI
class[16]           : com.fs.starfarer.campaign.Faction
class[17]           : exerelin.campaign.ai.concern.HostileInSharedSystemConcern
class[18]           : exerelin.campaign.ai.concern.DevelopRelationsConcern
class[19]           : exerelin.campaign.ai.DiplomaticAIModule
class[20]           : com.fs.starfarer.campaign.econ.Submarket
class[21]           : com.fs.starfarer.campaign.econ.reach.ReachEconomy
class[22]           : com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper
class[23]           : com.fs.starfarer.campaign.econ.Economy
class[24]           : com.fs.starfarer.campaign.StarSystem$UpdateFromHyperspaceLocation
class[25]           : com.fs.starfarer.campaign.BaseLocation$LocationToken
class[26]           : com.fs.starfarer.campaign.Hyperspace
class[27]           : com.fs.starfarer.campaign.CampaignEngine
converter-type[3]   : com.fs.starfarer.campaign.save.oooO
version             : not available
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on December 24, 2022, 01:30:56 PM
Hello once again all. i have come with some more questions.

1) how does one change text on a commodity? (like marries and showing what combat XP they have for example)
2) how does one change the image of a commodity? (like crew and marries for example; when you get more of them, they have a new image with more of them in the background.)
3) i want to make a industry that outputs commodity's to my supply point / to the market that it is built on, but i don't quite understand the documentation or the code. does anyone know were I might find some examples of this?
4) is it possible to make a industry have more then one option for what it can upgrade into? if so how would I do that?

thank you all for the help in the past times. it has been so useful to my understanding of the games code and code in general.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 25, 2022, 05:26:21 PM
question
what exactly kills the station core with vast bulk hullmod when all modules are destroyed? there's nothing that would do that in the hullmod code itself, just the damage mults.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on December 25, 2022, 08:18:58 PM
I want to make sure a specific weapon has a restrictive firing arc on any ship it's put on. In it's script I have
Code
for (WeaponAPI weapon : ship.getAllWeapons())
{

if (weapon.getId().contains("SFB_PlasmaMauler"))
{
weapon.getSlot().setArc(1f);
}

}

After it runs, the firing arc is graphically updated to reflect the new one degree arc but the weapon can still traverse the old firing arc. This script gets called after the weapon fires for the first time. Is that too late to alter the arc? What am I doing wrong?

[edit]
While I'd still like to know why my code didn't work, I realized I can (and should) just give the weapon a turn rate of zero and that solves the problem.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 26, 2022, 12:40:37 PM
hello! having an issue with my favorite save
is it, saveable?
pun intended

Ah, sorry, this isn't the right thread for that - would you mind making a new post in the Bug Reports & Support (modded) subforum?

1) how does one change text on a commodity? (like marries and showing what combat XP they have for example)

See:
PlayerFleetPersonnelTracker

In particular, its implementation of the CommodityTooltipModifier and CommodityIconProvider interfaces.

2) how does one change the image of a commodity? (like crew and marries for example; when you get more of them, they have a new image with more of them in the background.)

This is hardcoded for personnel only, irrc.

3) i want to make a industry that outputs commodity's to my supply point / to the market that it is built on, but i don't quite understand the documentation or the code. does anyone know were I might find some examples of this?

(Not sure, sorry!)

4) is it possible to make a industry have more then one option for what it can upgrade into? if so how would I do that?

It's not, iirc. You'd have to go around the system to do that - i.e. some kind of dialog somewhere that then does stuff behind the scenes to achieve what you want.

question
what exactly kills the station core with vast bulk hullmod when all modules are destroyed? there's nothing that would do that in the hullmod code itself, just the damage mults.

A check in vanilla code; it blows up when it has no surviving module attached that has weapons or fighters.


After it runs, the firing arc is graphically updated to reflect the new one degree arc but the weapon can still traverse the old firing arc. This script gets called after the weapon fires for the first time. Is that too late to alter the arc? What am I doing wrong?

Yeah, I think it's too late at that point. Also, of note: I believe your code would change the firing arc on that mount for ALL ships of that type.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on December 27, 2022, 09:53:38 AM
Seems like "Dismiss" button in commodity market share screen uses either 16 or possibly 21 size Victor font, while in TooltipMakerAPI there's only setButtonFontVictor14(). Is there any way to work around this to get 100% vanilla button look?

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on December 28, 2022, 09:41:45 AM
Are industries transient? AKA, can I store data in them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 28, 2022, 11:14:19 AM
Seems like "Dismiss" button in commodity market share screen uses either 16 or possibly 21 size Victor font, while in TooltipMakerAPI there's only setButtonFontVictor14(). Is there any way to work around this to get 100% vanilla button look?

It's 20pt Orbitron, actually! Added to TooltipMakerAPI:

   void setButtonFontOrbitron20();
   void setButtonFontOrbitron20Bold();
   void setButtonFontOrbitron24();
   void setButtonFontOrbitron24Bold();

Are industries transient? AKA, can I store data in them?

You can, yes! (This should be fairly trivial to check, no? You can e.g. see it happening in OrbitalStation, and you could try a simple string with a custom value to see if it's in the savefile.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on December 29, 2022, 07:47:16 AM
Is there any way to mark a special item as installable in any industry that outputs commodities? Ideally, I'd just be able to use a API method for this, because I have something specific in mind, e.g. it should be installable in anything that either produces commodities or outputs production capacity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 29, 2022, 09:12:19 AM
Is there any way to mark a special item as installable in any industry that outputs commodities? Ideally, I'd just be able to use a API method for this, because I have something specific in mind, e.g. it should be installable in anything that either produces commodities or outputs production capacity.

I don't think so, not without editing the industry code - what's installable in an industry is governed by that industry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on December 29, 2022, 09:55:45 AM
Would really like to see certain parts of Industry be extendable from outside the class:
- items
- right-click menu in the market screen
- AI cores

Maybe also supply/demand.

Would definitely like to see the resource deposit condition script support multiple industries for each resource. Just change INDUSTRY to be List<String, List<String>> with each industry keyed to a list of commodities and adjust the code that reads the lists.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 29, 2022, 10:05:16 AM
Is there any way to mark a special item as installable in any industry that outputs commodities? Ideally, I'd just be able to use a API method for this, because I have something specific in mind, e.g. it should be installable in anything that either produces commodities or outputs production capacity.
Sortof? You can make a special item that is installable in a specific list of industries, via tags in its special_items.csv listing. See, for example, the sigma matter items in Dassault-Mikoyan Engineering.

However, that works only for vanilla industries;* it won't automagically be installable in mod-added industries. And that's probably a good thing; for example, the Shadowyards mod has a special Heavy Industry replacement industry that takes and consumes installable items to specialize itself; if you gave it an installable item it wasn't expecting - well, you might get a game crash, and you'd almost certainly get unexpected behavior.

* Edit: To clarify, yes, you could put a mod-added industry on the list. But you'd have to explicitly add it, which implies that you know about that industry and have tested the interactions with your installable item, rather than getting potential untested interactions with some random industry you've never heard of before.

Edit2: Also, if you want AI-controlled colonies to have proper item upgrade behavior for items installed in vanilla industries, there's a MagicLib module for that. Getting that working was surprisingly annoying. Again, see DME's Sigma Matter for an example of the module in use.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Harmful Mechanic on December 29, 2022, 10:18:12 AM
See, for example, the sigma matter items in Dassault-Mikoyan Engineering.
(Just a note here - that's the dev build, not anything generally accessible... yet.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 29, 2022, 10:22:54 AM
See, for example, the sigma matter items in Dassault-Mikoyan Engineering.
(Just a note here - that's the dev build, not anything generally accessible... yet.)
Oh, oops. >.<

...Right, okay, if someone need a simple demo of this, I can probably put something together.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on December 30, 2022, 01:27:35 PM
hello once more all. i come with two questions:
1) when raiding, were is the marine XP gain calculated? I have failed to find it in the MarketCMD for some reason.
2) how does one get the players marine's current XP based combat bonuses?
thank you all once more for the responses to my very silly questions in the past. it was very kind for you all to do so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 01, 2023, 01:12:45 AM
Seems like "Dismiss" button in commodity market share screen uses either 16 or possibly 21 size Victor font, while in TooltipMakerAPI there's only setButtonFontVictor14(). Is there any way to work around this to get 100% vanilla button look?

It's 20pt Orbitron, actually! Added to TooltipMakerAPI:

   void setButtonFontOrbitron20();
   void setButtonFontOrbitron20Bold();
   void setButtonFontOrbitron24();
   void setButtonFontOrbitron24Bold();

Big thanks, love me some API additions. One more question about tooltips: is there a way to add footer-tooltip widget "Press F1 for more info" and corresponding behaviour to tooltips of classes where 'boolean isTooltipExpandable();' is not present, say, to hullmod tooltips?

If it is impossible, then I'm left with simple addPara() and keyboard check, right? Can do with that, just wanted a bit more vanilla beauty. :)

Edit: since there is a Ballistic Rangefinder already and you are adding Missile Autoloader, seems like expandable hullmod tooltips are going to be necessary for vanilla too!

Edit 2: while I'm at it, might as well point out this (didn't want to make a separate thread for something so trifling): on some resolutions lower than 1600x900 header line in "Command" CoreUI tab overlaps with exit button graphic. Line needs to be shorter if insufficient display height causes said line to render too close to the top edge.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 01, 2023, 04:31:29 PM
Are ship images cached somewhere? I made some ships and then realized I forgot to resize the png files. After resizing them the game is still using the big ones.

[Edit] Turns out it saves the size in the .ship file and doesn't care what size the actual png file is. Solved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on January 01, 2023, 04:54:52 PM
I am currently making some hullmods based off of and requiring in game hullmods to work. I’m still wrapping my head around Java though and have quite a few gaps in knowledge.

At current I’m attempting to create a hullmod that requires Integrated Point Defense AI to be installed (I already know how to do this). The intended function for my hullmod is to remove the PD conversion applied small ballistic/energy weapons without affecting another of the other bonuses from Integrated Point Defense AI or accidentally stripping away PD capacity from weapons that already have it as a base feature.

I'm pretty sure the following is what applies the conversion.

Code
public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
List weapons = ship.getAllWeapons();
Iterator iter = weapons.iterator();
while (iter.hasNext()) {
WeaponAPI weapon = (WeaponAPI)iter.next();
// if (weapon.hasAIHint(AIHints.PD)) {
// weapon.get
// }
boolean sizeMatches = weapon.getSize() == WeaponSize.SMALL;
//sizeMatches |= weapon.getSize() == WeaponSize.MEDIUM;

if (sizeMatches && weapon.getType() != WeaponType.MISSILE) {
weapon.setPD(true);
}
}
}

if (weapon.hasAIHint(AIHints.PD)) {
//            weapon.get


I think I need something like an inverted version of this to target all weapons without the PD tag in weapon.csv that's on the applicable ship.

and then need to follow it up with weapon.setPD(false);

I'm just not sure how you'd write this out to function properly, I was really hoping to be able to use an unmodify, but don't think it's works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 01, 2023, 05:14:41 PM
1) when raiding, were is the marine XP gain calculated? I have failed to find it in the MarketCMD for some reason.
2) how does one get the players marine's current XP based combat bonuses?

See: com.fs.starfarer.api.impl.PlayerFleetPersonnelTracker, for both.

Something like PlayerFleetPersonnelTracker.getInstance().getMarineData().getXPLevel() for the second, btw; should return a number between 0 and 1. The values of that that correspond to the ranks are specified in the PersonnelRank enum.


Big thanks, love me some API additions. One more question about tooltips: is there a way to add footer-tooltip widget "Press F1 for more info" and corresponding behaviour to tooltips of classes where 'boolean isTooltipExpandable();' is not present, say, to hullmod tooltips?

If it is impossible, then I'm left with simple addPara() and keyboard check, right? Can do with that, just wanted a bit more vanilla beauty. :)

Edit: since there is a Ballistic Rangefinder already and you are adding Missile Autoloader, seems like expandable hullmod tooltips are going to be necessary for vanilla too!

Yeah, I don't think it's possible. And, yeah, I might end up having to add this at some point :)

Edit 2: while I'm at it, might as well point out this (didn't want to make a separate thread for something so trifling): on some resolutions lower than 1600x900 header line in "Command" CoreUI tab overlaps with exit button graphic. Line needs to be shorter if insufficient display height causes said line to render too close to the top edge.

Thank you, made a note!


I think I need something like an inverted version of this to target all weapons without the PD tag in weapon.csv that's on the applicable ship.

and then need to follow it up with weapon.setPD(false);

I'm just not sure how you'd write this out to function properly, I was really hoping to be able to use an unmodify, but don't think it's works.

What you want, I think, is to check weapon.getSpec().contains(AIHints.PD) and then if it doesn't, but weapon.hasAIHint(AIHints.PD) returns true, then that's a weapon that was set to be PD while it normally isn't, and you'd do weapon.setPD(false).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 02, 2023, 10:27:27 AM
I'm making a hullmod and I need to store the hullsize so I can get it later in an AdvanceableListener during combat. When I run Starsector it says it can't convert Object to int.
Code
private static Map mag = new HashMap();
static {
mag.put(HullSize.FRIGATE, 1);
mag.put(HullSize.DESTROYER, 2);
mag.put(HullSize.CRUISER, 3);
mag.put(HullSize.CAPITAL_SHIP, 4);
}
public int hs = 1;

@Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
this.hs = (int) mag.get(hullSize); // It doesn't like this line for some reason

    }

In another hullmod I do basically the same thing and it doesn't complain at all

Code
	private static Map mag = new HashMap();
static {
mag.put(HullSize.FRIGATE, 80f);
mag.put(HullSize.DESTROYER, 160f);
mag.put(HullSize.CRUISER, 160f);
mag.put(HullSize.CAPITAL_SHIP, 160f);
}

    @Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getCargoMod().modifyFlat(id, (Float) mag.get(hullSize)); // No problem here
stats.getFluxCapacity().modifyFlat(id, (Float) mag.get(hullSize) * -0.5f);
stats.getFluxDissipation().modifyFlat(id, -60f);

    }

I tried making it a float just to be 100% the same as the working one but it didn't make a difference. I'm not compiling into a .jar or .class file. I'm letting Starsector do the compiling, which has always worked fine for me before.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2023, 10:58:28 AM
Not sure about that, but: you should not store any data in hullmod class member variables, because there's only one instance (i.e. copy) of this class, so this data will be shared across ALL ships that use this hullmod.

What you want to do is create a custom data-holder class and stick it into CombatEngineAPI.getCustomData(), keying off the ID of the ship, so that you get a separate copy of the data for each ship in combat. For an example of this, see com.fs.starfarer.api.impl.hullmods.SharedFluxSink. In particular, this part:

String key = SINK_DATA_KEY + "_" + ship.getId();
FluxSinkData data = (FluxSinkData) engine.getCustomData().get(key);
if (data == null) {
   data = new FluxSinkData();
   engine.getCustomData().put(key, data);
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on January 02, 2023, 02:45:11 PM
Can which way the AI decides which facing to choose, especially when 'trading flux' 1v1, or going 'all-in' 1v1, be roughly predicted from weapon layout and opponent?  I ask because we want to calculate that facing for ship combat analysis. CapnHector tested a Conquest armed with kinetics on the left and high explosives on the right, and it presented the right side to the enemy early in 1v1 simulator engagements against a Dominator and an Aurora, while the enemy shields remained up.

https://fractalsoftworks.com/forum/index.php?topic=25536.msg384442#msg384442

I (more or less) reproduced the result and think the Conquest preferred the longer-ranged kinetics on its right side regardless of their damage type.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2023, 03:22:04 PM
IIRC which broadside is chosen does not look at damage types etc - just the weapon ranges and the distance to the target.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on January 02, 2023, 10:38:23 PM
IIRC which broadside is chosen does not look at damage types etc - just the weapon ranges and the distance to the target.

And is this true for ships generally, besides the Conquest?  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on January 03, 2023, 01:05:49 AM
Quote from: Alex
What you want, I think, is to check weapon.getSpec().contains(AIHints.PD) and then if it doesn't, but weapon.hasAIHint(AIHints.PD) returns true, then that's a weapon that was set to be PD while it normally isn't, and you'd do weapon.setPD(false).

Thanks for the reply, not yet able to implement it yet, still need a bit more experience. For the meantime I've opted for a lesser workaround.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 03, 2023, 06:51:44 AM
Is there any way to create a association between a debris field and the battle that spawned it, as well as, potentially, the specific engagement results that caused it to spawn?

Ex. if a hegemony and tritach fleet fight, hegemony loses 3 onslaughts, tritach loses 4 paragons, I want to be able to assocaite that debris field with 3 hegemony onslaughts vs 4 tritach paragons. I want to do this so I can spawn derelicts in-combat when you fight inside a debris field.

I was thinking a reportbattleoccured listener that would add a script that checks next frame for a debris field on the battle coordinates (or this frame), but this could get false positives potentially. It would probably be a lot easier with a terrain creation listener.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 03, 2023, 06:53:43 AM
I'm setting my text width override in TooltipMakerAPI and then adding text:

(first screenshot)
Code
        moduleInfoPanel.setTextWidthOverride(200f);
        String shortenedShipName = moduleInfoPanel.shortenString(member.getShipName(), 175);
        LabelAPI shipNameLabel = moduleInfoPanel.addPara(shortenedShipName, PanelConstants.PLAYER_COLOR, 2f);

All good. But as soon as I swap addPara() for addTitle(), width override gets seemingly ignored. Nothing else was changed, it is most certainly difference between addPara and addTitle. Did I do something wrong here? What did I overlook? Can I get identical to addTitle() formatting using addPara()?
 
(second screenshot)
Code
        moduleInfoPanel.setTextWidthOverride(200f);
        String shortenedShipName = moduleInfoPanel.shortenString(member.getShipName(), 175);
        LabelAPI shipNameLabel = moduleInfoPanel.addTitle(shortenedShipName, PanelConstants.PLAYER_COLOR);

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 03, 2023, 10:58:05 AM
And is this true for ships generally, besides the Conquest?  :D

This is for broadside ships deciding which broadside to use.

All good. But as soon as I swap addPara() for addTitle(), width override gets seemingly ignored. Nothing else was changed, it is most certainly difference between addPara and addTitle. Did I do something wrong here? What did I overlook? Can I get identical to addTitle() formatting using addPara()?

IIRC that method is only for addPara(). But you could emulate the same format as addTitle() by doing tooltip.setParaFont("graphics/fonts/orbitron12condensed.fnt"), I believe. The default title color is "tooltipTitleAndLightHighlightColor" in settings.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 03, 2023, 11:24:58 AM
All good. But as soon as I swap addPara() for addTitle(), width override gets seemingly ignored. Nothing else was changed, it is most certainly difference between addPara and addTitle. Did I do something wrong here? What did I overlook? Can I get identical to addTitle() formatting using addPara()?

IIRC that method is only for addPara(). But you could emulate the same format as addTitle() by doing tooltip.setParaFont("graphics/fonts/orbitron12condensed.fnt"), I believe. The default title color is "tooltipTitleAndLightHighlightColor" in settings.json.

Thank you, just what I needed! Incidentally, I was using Misc.getPlayerColor() as a substitute for title color (didn't know better), glad to be corrected.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on January 03, 2023, 12:22:20 PM
hey all, i got myself one last random question for now.
1) is there a way to replace PlayerFleetPersonnelTracker pacifically its GroundRaidObjectivesListener, with my own version of said class? i need to replace some things in it.
thank you again all for the kindness of helping me with the things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tranquility on January 03, 2023, 11:03:37 PM
Is there a way to force custom secondary and tertiary stars (as well as their orbiting planets) to show up on the Star Systems list in the Planets tab? I've been using the StarSystemAPI's setSecondary() and setTertiary() to set the second and third stars on my modded star systems, but they don't seem to make them show up on the Systems list at all. Nothing in the Core World .java files in data.scripts.world.systems seems to indicate how this is done, especially considering the Core World systems with two stars do have their second star show up on the list (not to mention that they also do setSecondary() too). If this information helps, I'm generating my modded star systems using onNewGameAfterProcGen(); I'm hoping that the point at which a system generates doesn't affect whether the Star System list will show the secondary and tertiary stars.

On a related note, the orbiting Ta'xet star in the Tia-Ta'xet system doesn't have its own corona yet, nor is it set as a secondary star in the TiaTaxet.java file (it also doesn't show up on the Star Systems list either). If nothing else, maybe that can be fixed in the next update?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 04, 2023, 01:41:19 AM
Code
setHighlightBrightness(float highlightBrightness)
in ButtonAPI doesn't seem to work as one would expect: that highlight would be less pronounced when mousing over button. In fact, whether I pass 0.0001f or 900f as argument doesn't seem to change anything at all (calling the method right after creating ButtonAPI instance). Is this method supposed to work only under certain conditions? If yes, are there any other ways I can influence degree of color change when button is moused over on?

Edit: another question - is tooltip background of some vanilla UI tooltips created using 32x32 sprite (ui/bgs/panel00_center.png), or with equivalent amount of GL11-drawn lines?
In other words, are few calls of one big background sprite rendering preferable to considerably more numerous GL11 calls of vertex rendering? Or is there no difference, granted custom UI panel environment?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on January 04, 2023, 07:11:54 AM
This is for broadside ships deciding which broadside to use.

Wow have you thought of everything over the years!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 04, 2023, 10:03:23 AM
Thank you, just what I needed! Incidentally, I was using Misc.getPlayerColor() as a substitute for title color (didn't know better), glad to be corrected.

Glad that did it!

hey all, i got myself one last random question for now.
1) is there a way to replace PlayerFleetPersonnelTracker pacifically its GroundRaidObjectivesListener, with my own version of said class? i need to replace some things in it.
thank you again all for the kindness of helping me with the things.

That might be a little tricky. You'd need to look at the places it's being used and do some careful surgery. The cleanest way to go might be to leave it in Sector memory, under $core_personnelTracker (so that the game doesn't keep trying to re-create it), and to remove it from Global.getSector().getGenericPlugins() and from Global.getSector().getListenerManager().

And then to add your version to those places. Also, the MercsOnTheRunBarEvent directly references PlayerFleetPersonnelTracker (it probably shouldn't), so you'd need to provide another version of that that works with your implementation.


Is there a way to force custom secondary and tertiary stars (as well as their orbiting planets) to show up on the Star Systems list in the Planets tab? I've been using the StarSystemAPI's setSecondary() and setTertiary() to set the second and third stars on my modded star systems, but they don't seem to make them show up on the Systems list at all. Nothing in the Core World .java files in data.scripts.world.systems seems to indicate how this is done, especially considering the Core World systems with two stars do have their second star show up on the list (not to mention that they also do setSecondary() too). If this information helps, I'm generating my modded star systems using onNewGameAfterProcGen(); I'm hoping that the point at which a system generates doesn't affect whether the Star System list will show the secondary and tertiary stars.

I think you might need to set the StarSystemType for the system, via system.setType().


On a related note, the orbiting Ta'xet star in the Tia-Ta'xet system doesn't have its own corona yet, nor is it set as a secondary star in the TiaTaxet.java file (it also doesn't show up on the Star Systems list either). If nothing else, maybe that can be fixed in the next update?

Thank you, let me make a note.


Code
setHighlightBrightness(float highlightBrightness)
in ButtonAPI doesn't seem to work as one would expect: that highlight would be less pronounced when mousing over button. In fact, whether I pass 0.0001f or 900f as argument doesn't seem to change anything at all (calling the method right after creating ButtonAPI instance). Is this method supposed to work only under certain conditions? If yes, are there any other ways I can influence degree of color change when button is moused over on?

This only affects the brightness when the button is .highlight()'ed - a more permanent, non-mouse-over state like e.g. for the currently-selected tab in a UI with several tabs.
Let me add:
   float getGlowBrightness();
   void setGlowBrightness(float glowBrightness);
To ButtonAPI.

Edit: another question - is tooltip background of some vanilla UI tooltips created using 32x32 sprite (ui/bgs/panel00_center.png), or with equivalent amount of GL11-drawn lines?
In other words, are few calls of one big background sprite rendering preferable to considerably more numerous GL11 calls of vertex rendering? Or is there no difference, granted custom UI panel environment?

I'm fairly sure the tooltip background is generally just a black quad. In places where it's not, generally something like graphics/fx/scanline11.png would be used. I wouldn't use GL11 lines for something like this, no - it's a lot of lines and the performance impact would generally be significant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 04, 2023, 11:06:08 AM
This only affects the brightness when the button is .highlight()'ed - a more permanent, non-mouse-over state like e.g. for the currently-selected tab in a UI with several tabs.

Huh, turns out I was woefully mistaken about the very nature of the methods I was calling. Perhaps some form of short hint-like Javadoc in ButtonAPI could be of use for the future modders like me?

Although, what moved me to tinker with highlight brightness was the fact that there appeared to be next to no difference in button color when mousing over it, because I called highlight() on it right after creation, so I thought mouseover is what highlight() is for, said highlight being a manual call to the mouseover state. Testing again right now:

Creating ButtonAPI like this:

Code
        ButtonAPI toggleButtonInstance = capacityPanel.addButton(status, null,
                Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), Alignment.MID,
                CutStyle.ALL, 75f, 25f, 2f);
        if (capacity.isToggledOn()) {
            toggleButtonInstance.highlight();
        }

Two relevant colors are base player and dark player colors. Button is immediately recreated on click via remove/add parent component, so gets created in a finished state. Such a setup produces an unsatisfactory result with almost no visual telling if button is moused over, see attached picture. I am able to work around this (not to perfect satisfaction, sadly), just thought it might be thought-provoking.

Edit: excuse my poor wording, problem was a bit different: color of the button is identical when mousing over it whether it is in an enabled or disabled state. That's what I deemed unsatisfactory at the time, perhaps the issue is in the eye of the beholder. Indeed, thinking it over and everything makes plenty of sense - tab buttons are supposed to be like this, and for having one button for disable/enable there are area checkboxes. My fault, sorry!

Let me add:
   float getGlowBrightness();
   void setGlowBrightness(float glowBrightness);
To ButtonAPI.

You are my hero, sir!

I'm fairly sure the tooltip background is generally just a black quad. In places where it's not, generally something like graphics/fx/scanline11.png would be used. I wouldn't use GL11 lines for something like this, no - it's a lot of lines and the performance impact would generally be significant.

I see, thank you. Now thinking about it, can't even recall where I got this idea that something had that striped background...

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 04, 2023, 03:21:36 PM
Is there any way to spawn a hulk in combat, and then split it? I ask because I was recently told that setHulk(true), or some similar method, would automatically force a ship to become a hulk. I'm not sure of how true this is, but in the case it's wrong, all I want is some way to just create derelicts in combat without messing around with post-battle loot/creating the death message.

I also want the resulting ship to be dead, so split() works, and I'm not sure if setHulk(true) kills a ship or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tranquility on January 04, 2023, 08:58:10 PM
I think you might need to set the StarSystemType for the system, via system.setType().

It worked! I set the appropriate type for the custom binary and trinary star systems, and I was able to get those systems to display their secondary/tertiary stars on the Star Systems list. Thank you, Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 05, 2023, 04:11:11 PM
I'd like to add an option to the player's choices when he has the option to stabilize cargo pods floating in space. Where would I do that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on January 07, 2023, 10:07:33 AM
Are InstallableItemEffects singletons, or does an instance of this exist for every item? Ex. if I install 3 nanoforgres on 3 worlds, do those 3 nanoforges each have their own instance of this class?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on January 07, 2023, 10:27:29 AM
Hey Alex, could you add a way for ships to house drone-fighters only. Currently the only way is through the automated ship hullmod and there's nothing in the hullmod itself that governs this so I'm guessing it's handled elsewhere.

It would be nice if we could, for example, remove the mining pods from the Shepherd and upgrade it to carry wasps... or worse...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on January 07, 2023, 10:43:33 AM
Hey Alex, could you add a way for ships to house drone-fighters only. Currently the only way is through the automated ship hullmod and there's nothing in the hullmod itself that governs this so I'm guessing it's handled elsewhere.

It would be nice if we could, for example, remove the mining pods from the Shepherd and upgrade it to carry wasps... or worse...

You can do this yourself already; make a FighterOPCostModifier listener that checks for the auto_fighter tag or similar, if it doesn't find the tag set the op cost to 10k (I'd imagine automated ship basically does this behind the scenes)
the fighter / weapon op cost mod listeners are super powerful tools, you can mess around with them to do basically anything to op costs
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on January 07, 2023, 11:01:47 AM
You can do this yourself already; make a FighterOPCostModifier listener that checks for the auto_fighter tag or similar, if it doesn't find the tag set the op cost to 10k (I'd imagine automated ship basically does this behind the scenes)
the fighter / weapon op cost mod listeners are super powerful tools, you can mess around with them to do basically anything to op costs

I get what you're saying (although I would struggle given my sub-par java-skills). But it feels somewhat silly and redundant to re-implement something Alex has already implemented. It's the same with adding AI officers to ships, Alex has already done the work but it's hidden behind the scenes. Adding something like drone_fighters and ai_officer as ship hints to enable them would be a useful feature.

It also saves the headaches when you, me and Scooby-Doo make 3 different implementations and the bugs are blamed on Alex by someone who doesn't know the difference.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 07, 2023, 11:17:54 AM
Is there any way to spawn a hulk in combat, and then split it? I ask because I was recently told that setHulk(true), or some similar method, would automatically force a ship to become a hulk. I'm not sure of how true this is, but in the case it's wrong, all I want is some way to just create derelicts in combat without messing around with post-battle loot/creating the death message.

I also want the resulting ship to be dead, so split() works, and I'm not sure if setHulk(true) kills a ship or not.

I think you'd just want to apply a bunch of damage to it. I don't think just .setHulk() would do everything you want, iirc it's just a flag for some of the aspects of it. And if you apply the damage judiciously, you'd get damaged armor etc.


I'd like to add an option to the player's choices when he has the option to stabilize cargo pods floating in space. Where would I do that?

Look for "# CARGO PODS" (without the quotes) in rules.csv!


Are InstallableItemEffects singletons, or does an instance of this exist for every item? Ex. if I install 3 nanoforgres on 3 worlds, do those 3 nanoforges each have their own instance of this class?

Take a look in ItemEffectsRepo; it's all handled there. The entirety of the relevant code is in mod-land!


(Re: drone fighters etc - this isn't the right thread for outright functionality requests, but I'll keep it in mind!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Warppy on January 07, 2023, 02:00:16 PM
Hello, I'm completely new here so I wanted to ask a few things.

I've played starsector for quite some time, but I had some disagreements with a couple of vanilla ships [though I love most of them]. One that I couldn't really stomach was Colossus Mk.II I just didn't think Ludic Path would have modified Colossus in such a way.

So, I've "modded" a micro rework of that ship, that has these features:
Spoiler
- Unlike Mk. III; Mk. II is not a multi-purpose ship, it is a hammer of divine wrath. Pathers have no reason to keep so much unused cargo space in their variant of Colossus. Instead, of (relatively) large cargo space, there's an inbuilt expanded missile racks mod. So you get 10 salvos of barrage instead of 5.

- As the main intended armament is the inbuilt Hammer Barrage, there is little reason to install a better flux capacitors and vents. For that reason, Mk. II. keeps weak flux stats of Cargo Colossus, rather than upgraded stats of Mk. III [though technically not really because safety overdrives doubles flux dissipation anyways]. Pathers also made the shield arc a bit smaller, because they could.

- Instead of flux capacity for shielding, pathers have made Colossus more durable with 1000 armour, rather than just 300 or 600.

- But with so much armour on their ship, all but two of Colossus' turrets have become more like casemates, having only very small (45°) turning arc and awkward angles of fire, with four weapon placements turned into awkward hardpoints entirely. Of those four,  they managed to turn two side facing ballistics turrets into composite hardpoints, but they are still side facing, making them awkward for use of most missile weapons.

(https://lh3.googleusercontent.com/NmQbRPtRQt1pBjcr-MqHRuL8jR5a_a1hu7ziXXw7WciNgQbTNMt56bi80ljfKJWq16GSCADcKt9JhNLV1yAamZ_Gp0LQ-Kvj15489Y4llP2yt7NsBLmh36sRtSW01zMH4IINcMVZLp0RTzrzmq_QQd0y6UE8EW5d-QFOg1ZS04xRHYULNUPTgBVjjohZQ6lHn4EJYBlY_Gq5tmQLwMydRpoYyEyj14TrLloF7TRwJsQD0OsdWsCUjr6vT4SramuDZ96lfBTiknfwK9uEJ5t9NVDVJ_pmGIAEMb_bxhYuywrjQ8XB1aukO0ZHChpsnvIMClGReRmwJgfwbWGu4Q2apteaO8_ZHskofH0zizu7RMKYdz_ZJPKR34cPLPzlkteW9y8LEphwttb7XHK5Y1nJfpscSSJXr7Q1kuQfdfy2RdqRywX0bC7QE-h4twKeDsmt-g8QfPv5TVJ_YDuCuC-CZPHBfsBYCe75H2Oi47SBp-w8EvXFgAHC8cbSBlCwa6qoghLzWghhgyxjQV8Ph1Mh5McafPfT5WPKc1guDzLHiCJ2Mt-AnkelM-olbR2aSnXnjaZ8aG_XFpwViIC4uRlUWxyuGMfOlXOPyoyCHLy4nT4rs6Nj8r-q7SM5gF52lYn7x6ET8DqYIqG-fUovMuI0nfu7i8Zlmun-gIupo3Nl8Ir6AwkrHw9Yd9z_prca3Mg76PPutfxShyG4VW133Uci3MlgGdwH-ns0Yg9g3Ay7Ru2zPHQpeJsfDhrXJpe5Qu8terz7VmiLRa_Dykqpu8SmWLgMJEaOjkRUairuEWFi9bBpcxNDO-XojEJrViRCdOmqLPHVwqAeQGJq_0MU-eEEI_X8tXK7AtfBA-ZC3wRVLBa1Yrw78fxekqiPN_nvBeYK1H-xuSnEi0W6AlAlg-2w1W3Z7s0Ft-yBR8sYAkAogUacW3zLBy1utSLrWOHqoGXWVnVREc6zNOcbb8Rw3iw=w1062-h576-no?authuser=0)
[close]

As you can tell, the reason I wrote "modded" in parentheses is that none of my changes is really something that requires any proper modding work. I for example don't even know how I would approach changing weapon ports graphically. I would not compare what I did with what I see actual modders do here.

So what I'm meaning to ask, would sharing a "mod" like one mentioned above be a bad thing? I know it's low effort compared to what I usually see here. Would posting something like that get me in any trouble due to how basic it is?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on January 08, 2023, 06:23:12 AM
Hello, I'm completely new here so I wanted to ask a few things.

I've played starsector for quite some time, but I had some disagreements with a couple of vanilla ships [though I love most of them]. One that I couldn't really stomach was Colossus Mk.II I just didn't think Ludic Path would have modified Colossus in such a way.

So, I've "modded" a micro rework of that ship, that has these features:

Looks like a fine start to me and what you've done makes a kind of sense. I'm not a fan of the Colossus as-is and if I had to tweak it I'd pretty much start out like you have, it's a no brainer adding expanded missile racks.


As you can tell, the reason I wrote "modded" in parentheses is that none of my changes is really something that requires any proper modding work. I for example don't even know how I would approach changing weapon ports graphically. I would not compare what I did with what I see actual modders do here.

So what I'm meaning to ask, would sharing a "mod" like one mentioned above be a bad thing? I know it's low effort compared to what I usually see here. Would posting something like that get me in any trouble due to how basic it is?

The only people who wouldn't consider what you're doing as modding are over-pretentious egoists. It's a mod, create a thread and post it, hopefully you'll get some feedback on what to tweak and improve and if you need direction ask. My first foray into Starsector modding was pretty much the the same as yours, a few tweaks, then it was reskinning existing ships before making my own... etc. If you you don't want to create your own sprites there's a whole thread of free-to-use for you https://fractalsoftworks.com/forum/index.php?topic=12896.0 (https://fractalsoftworks.com/forum/index.php?topic=12896.0)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 10, 2023, 08:23:10 AM
That sounds like a lot of fun! And kind of reminds me of making similar personal mods for Morrowind :)

It probably wouldn't end up in the mod index (super small mods *generally* don't), but there's absolutely no reason why you shouldn't post it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheLemu on January 10, 2023, 12:43:11 PM
Is there any way of increasing the amount of levels an administrator can possess?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on January 10, 2023, 03:01:41 PM
Quick question, where is factions threatening you and reducing your growth if you settle in their system handled? Looking to override that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on January 11, 2023, 06:40:11 AM
I have noticed that we will get a new ship explosion animation!  Will we get to use the old animation too, how much control will we have over the new animation, and will the spikes and sphere be 'baked in' together, or will they be two pieces?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 11, 2023, 04:45:35 PM
Quick question, where is factions threatening you and reducing your growth if you settle in their system handled? Looking to override that.
That's a Nex function, and you can't currently override it for a specific faction/system except by making the faction non-territorial in its .faction file.
(in vanilla they just go straight to trying to satbomb the offending colony)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 12, 2023, 04:18:18 AM
Tracked down a savegame load failure a couple of people were having with Nex. Now I'm like, why does this happen??

Context: I have a CampaignFleetAPI stored in an intel item. I was trying to inflate the fleet in readResolve, but this caused an NPE.
It turns out, trying to access the fleet's faction data in any way causes the NPE, because the faction doesn't have its spec loaded:

Code: java
	FactionAPI faction = offeredFleet.getFaction();
Faction trueFaction = (Faction)faction;

/* Uncomment this line to reload trueFaction's spec and thus prevent the exception that breaks loading the game */
/* trueFaction.getSpec(); */
log.info(String.format("Preparing to inflate merc fleet for faction %s", faction));
log.info(String.format("Faction name is %s", faction.getDisplayName()));
1508912 [Thread-2] INFO  exerelin.campaign.intel.merc.MercContractIntel  - Preparing to inflate merc fleet for faction sindrian_diktat
1508921 [Thread-2] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Error loading
1508921 [Thread-2] ERROR com.fs.starfarer.campaign.save.CampaignGameManager  - Failed calling method
[...]
Caused by: java.lang.NullPointerException: Cannot invoke "com.fs.starfarer.loading.J.this.Object()" because "this.spec" is null
   at com.fs.starfarer.campaign.Faction.getDisplayName(Unknown Source)
   at exerelin.campaign.intel.merc.MercContractIntel.readResolve(MercContractIntel.java:84)
   at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
   at java.base/java.lang.reflect.Method.invoke(Method.java:577)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 12, 2023, 11:01:17 AM
How can I get all projectiles within a certain range of a specific missile?

Also, do projectiles have mass like a ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on January 12, 2023, 12:20:56 PM
How can I get all projectiles within a certain range of a specific missile?

Also, do projectiles have mass like a ship?

for the projectiles check, something like this should work

Code
            //use whatever for the missile
            //getCheckIterator gets everything in a square area centered on the first param

            MissileAPI missile = null;         
            Iterator<Object> iter = engine.getAllObjectGrid().getCheckIterator(missile.getLocation(), width, height);
            while (iter.hasNext()) {
                Object next = iter.next();
                if (next instanceof DamagingProjectileAPI) {
                    //yada yada do your stuff here
                    //will need to do a second distance check in here if you want to make sure it's a circular area instead of a square
                }
            }

and no, projectiles have no mass.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 12, 2023, 12:23:30 PM
Is there any way of increasing the amount of levels an administrator can possess?

Hmm, you could do something like checking for the presence of an admin in a reportPlayerOpenedMarket() method and then tweaking it with code.


Tracked down a savegame load failure a couple of people were having with Nex. Now I'm like, why does this happen??

Context: I have a CampaignFleetAPI stored in an intel item. I was trying to inflate the fleet in readResolve, but this caused an NPE.
It turns out, trying to access the fleet's faction data in any way causes the NPE, because the faction doesn't have its spec loaded:

Right, loading-order stuff like this can happen sometimes and it's a huge pain. I think the way you're working around it seems reasonable? Or am I missing something and is there still a problem? Generally though the solution for this sort of thing is "avoid the situation and lazy-load at some later point" etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on January 12, 2023, 03:48:46 PM
and no, projectiles have no mass.

Depends on their spawn type and impact value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 12, 2023, 03:52:34 PM
I guess it's more accurate to say they don't have a *meaningful* mass - the impact values are basically just some random stuff from about 10 years ago that didn't pan out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 12, 2023, 06:21:39 PM
I think you might need to set the StarSystemType for the system, via system.setType().
about that
is there a (safe) way to make system with
several stars orbiting a non-star center
several stations orbiting the stars
AND several stations orbiting a non-star center
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on January 13, 2023, 02:49:17 AM
Right, loading-order stuff like this can happen sometimes and it's a huge pain. I think the way you're working around it seems reasonable? Or am I missing something and is there still a problem? Generally though the solution for this sort of thing is "avoid the situation and lazy-load at some later point" etc.
Yeah the workaround is perfectly fine, I was just annoyed that the faction wasn't loading its own def on its own readResolve.

Anyway new question: How often is a hub mission recreated? I've got a case where leaving the conversation, undocking and redocking with the market causes a new instance to be created (verified with a log message in the constructor), but I dunno if it's devmode-specific.
(Trying to fix an issue where leaving the convo and then asking about the mission again sometimes changes the mission target, whose picking logic exists outside the hub mission)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 13, 2023, 08:56:47 AM
I'd like to modify the parameters of a projectile (missile) after launch.

I have an OnFireEffectPlugin and in the OnFire method I can make some changes like setMaxFlightTime, setDamageAmount, and setHitpoints. Is there any way to set missile parameters that are normally set by the weapon in the weapon_data.CSV? I'd like to change proj speed and impact, among others.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sombra on January 15, 2023, 08:12:21 AM
Hi! I'm working on a bigger mod which puts "Discovery: Freelancer" into Starsector. (Check this if you are curious!) (https://www.youtube.com/@noir2128/videos)

I have a few questions where googling was rather unhelpful.

1. How can I make new ships (non-vanilla ships) randomly spawn as derelicts, so you can find them via exploration?

2. I would like to add a new system, but I do not want it to show up on the hyperspace map, making it only accessible via Nascent Gravity Well. I've found the file that spawns a certain system that is only accessible this way, but how would I go about implementing it?

3. I would like to add a faction that exclusively spawns out of nowhere in hyperspace, without a base or planet. How would I go about that, and are there mods that do that?

4. I would like to keep my mod independent from Nexerelin, so it can be played without it. Is there a way to...
a) add faction blueprints to the trait picker screen from Nexerelin, so that if a player chooses "Make your own faction!", they can start with the tech package of faction X, without having Nexerelin being an essential mod to make my mod work?
b) make the factions of my mod automatically be recognized by Nexerelin without Nexerelin being an essential mod to make my mod work?

Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2023, 09:57:18 AM
about that
is there a (safe) way to make system with
several stars orbiting a non-star center
several stations orbiting the stars
AND several stations orbiting a non-star center

As far as having it show "correctly" in the visual representation of the star system? I don't think so.

Yeah the workaround is perfectly fine, I was just annoyed that the faction wasn't loading its own def on its own readResolve.

The vagaries of xstream! Guessing there's a good reason for why it happens sometimes, but, yeah.

Anyway new question: How often is a hub mission recreated? I've got a case where leaving the conversation, undocking and redocking with the market causes a new instance to be created (verified with a log message in the constructor), but I dunno if it's devmode-specific.
(Trying to fix an issue where leaving the convo and then asking about the mission again sometimes changes the mission target, whose picking logic exists outside the hub mission)

Generally speaking the missions get created when the hub is shown and then aborted when the hub is exited. So the important thing is to make sure that mission creation is deterministic to the extent that that's possible.


I'd like to modify the parameters of a projectile (missile) after launch.

I have an OnFireEffectPlugin and in the OnFire method I can make some changes like setMaxFlightTime, setDamageAmount, and setHitpoints. Is there any way to set missile parameters that are normally set by the weapon in the weapon_data.CSV? I'd like to change proj speed and impact, among others.

The missile has mutable stats, like a ship - except, oops, this isn't exposed in the API. Added MissileAPI.getStats(). Beyond that, I'm not sure how you'd go about this.



Hi! I'm working on a bigger mod which puts "Discovery: Freelancer" into Starsector. (Check this if you are curious!) (https://www.youtube.com/@noir2128/videos)

Hi - very cool!


1. How can I make new ships (non-vanilla ships) randomly spawn as derelicts, so you can find them via exploration?

I don't think there's a super easy/clean way; see: SalvageSpecialAssigner.getNearbyFactions() for how the factions for derelict ships get picked. Basically it's: independents, mercenaries, and pirates, plus whatever factions have colonies within 15 light-years of the location.

You could add your own copy of NearbyEventsEvent that would spawn some additional derelicts now and again; that might be the best way.

2. I would like to add a new system, but I do not want it to show up on the hyperspace map, making it only accessible via Nascent Gravity Well. I've found the file that spawns a certain system that is only accessible this way, but how would I go about implementing it?

I'm not sure what you mean, exactly - aside from copy-pasting this and modifying it?

3. I would like to add a faction that exclusively spawns out of nowhere in hyperspace, without a base or planet. How would I go about that, and are there mods that do that?

I don't know about mods that do that, but, yeah, you would basically add a script that spawns fleets (or adds routes to the RouteManager.getInstance()), depending on what exactly you wanted. This is very much doable with code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 15, 2023, 05:15:09 PM
is it possible to get the goal target angle for an individual weaponAPI ?
as in, angle where the weapon is actively turning right now to, but not yet facing
cause weapons in the same weapon group can aim and fire at different things, so it must be on individual per-weapon basis
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 15, 2023, 05:35:32 PM
You'd need to provide a custom weapon AI for it via ModPlugin.pickWeaponAutofireAI(). Which would involve doing more work than just providing the angle - it'd also need to say when to fire, check for friendly fire danger, respect any applicable weapon AI hints (such as it being PD or not), etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 15, 2023, 07:42:58 PM
You'd need to provide a custom weapon AI for it via ModPlugin.pickWeaponAutofireAI(). Which would involve doing more work than just providing the angle - it'd also need to say when to fire, check for friendly fire danger, respect any applicable weapon AI hints (such as it being PD or not), etc.
nonono
i'm not trying to make weapon do anything
i'm just trying to get what exactly is it doing
in this case it looks like it's turning to aim at a specific point of a specific ship
the ship will no longer be there when the weapon finishes turning due to being slow
but i want to know where the weapon is trying to aim at this current moment
is it possible?
something like weapon.whatAreYouAimingAt, which returns float or vector2f
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 16, 2023, 05:34:02 AM
Is there a way I can intercept damage to a shield right before it is applied and modify it? If so, has the damage at that point already been affected by any damage modifiers based on damage type, shield efficiency or other things?


I want to create a different type of shield where it doesn't create flux when hit but there is a total amount of damage it can take per battle before shutting down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on January 16, 2023, 05:36:47 AM
Is there a way I can intercept damage to a shield right before it is applied and modify it? If so, has the damage at that point already been affected by any damage modifiers based on damage type, shield efficiency or other things?


I want to create a different type of shield where it doesn't create flux when hit but there is a total amount of damage it can take per battle before shutting down.

make damageTakenModifier listener & add it to the target ship, they get run before hits get fully processed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 16, 2023, 01:35:33 PM
nonono
i'm not trying to make weapon do anything
i'm just trying to get what exactly is it doing
in this case it looks like it's turning to aim at a specific point of a specific ship
the ship will no longer be there when the weapon finishes turning due to being slow
but i want to know where the weapon is trying to aim at this current moment
is it possible?
something like weapon.whatAreYouAimingAt, which returns float or vector2f

Ahhh, I'm sorry, totally misread what you meant.

AutofireAIPlugin.getTarget() should do it.

You'd get at it by using WeaponGroupAPI.getAutofirePlugin(WeaponAPI weapon).

Stuff could be null at times - the target, or the plugin (possibly, if the weapon is not on autofire at that point; I don't 100% remember).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 16, 2023, 07:29:44 PM
I want to make a hull mod that will be built-in only. If I set no_drop in the hull_mods.csv and don't include it in any blueprint will that be enough or is there some other way to do it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Redeye43 on January 17, 2023, 11:26:05 AM
I'm trying to figure out how to make universal mounts capable of mounting any smaller weapon- the json doesn't seem to have anything to fix it, does anyone have any ideas as to how? Did I just blatantly miss something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on January 17, 2023, 11:37:25 AM
I'm trying to figure out how to make universal mounts capable of mounting any smaller weapon- the json doesn't seem to have anything to fix it, does anyone have any ideas as to how? Did I just blatantly miss something?

as far as I know you just can't, mounts can only mount smaller weapons that are the same type (and only one size down).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 18, 2023, 10:07:38 AM
I want to make a hull mod that will be built-in only. If I set no_drop in the hull_mods.csv and don't include it in any blueprint will that be enough or is there some other way to do it?

There are a number of hullmods like that in vanilla; you can check hull_mods.csv to see how that's done. (No tags needed, and a value of "TRUE" in the "hidden" column.)

I'm trying to figure out how to make universal mounts capable of mounting any smaller weapon- the json doesn't seem to have anything to fix it, does anyone have any ideas as to how? Did I just blatantly miss something?

as far as I know you just can't, mounts can only mount smaller weapons that are the same type (and only one size down).

Right, it's just how it works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on January 18, 2023, 01:13:26 PM
What could explain a ship.getRepairTracker().getMaxCR() call returning 0.21f?

ship.getRepairTracker().setCR(0.7f) properly sets the ship's CR to 70%, but ship.getRepairTracker().setCR(ship.getRepairTracker().getMaxCR()) sets the ship's CR to 21%, so I have to assume that there's something weird going on with the getMaxCR() function. This has remained true for every ship I have tested.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 18, 2023, 01:20:59 PM
Not having enough crew can reduce max CR.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on January 18, 2023, 01:30:48 PM
Not having enough crew can reduce max CR.
I consistently end up with 21% CR regardless of how many crew members are in my fleet (I've even added code to add the minimum crew of each ship before running the CR call)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 19, 2023, 09:50:04 AM
Is there an event or something I can subscribe to when a ship dies? I'd like to create a big explosion if the ship has something like a self_destruct hull mod I'm planning on making.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 19, 2023, 04:05:21 PM
What could explain a ship.getRepairTracker().getMaxCR() call returning 0.21f?

ship.getRepairTracker().setCR(0.7f) properly sets the ship's CR to 70%, but ship.getRepairTracker().setCR(ship.getRepairTracker().getMaxCR()) sets the ship's CR to 21%, so I have to assume that there's something weird going on with the getMaxCR() function. This has remained true for every ship I have tested.

Have you looked at the CR tooltip for that fleet member in the fleet view? It should list all the factors currently affecting its maximum CR, iirc.

Is there an event or something I can subscribe to when a ship dies? I'd like to create a big explosion if the ship has something like a self_destruct hull mod I'm planning on making.

Take a look at the implementation of PhaseAnchor; it does something similar (well, minus an explosion).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 19, 2023, 07:52:23 PM
Is there a way to keep AI fleet commander from ordering specific ships to retreat ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 19, 2023, 08:48:23 PM
Is there a way to keep AI fleet commander from ordering specific ships to retreat ?

Not on a per-ship basis, no. You could have a script catch this and cancel the orders until the AI runs out of command points.

You can also prevent the entire enemy side from retreating by setting Global.getCombatEngine()getContext().aiRetreatAllowed = false
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on January 20, 2023, 03:55:01 PM
A projectile can be made to only have a proximity detonation near missiles by giving vsMissileRange a value other than 0 and giving range a value of 0, but how do you make a projectile detonate on proximity with both missiles and fighters but not ships?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 21, 2023, 08:37:53 AM
Can I call showCustomDialog() - which shows a panel - on a same instance of InteractionDialogAPI while already showing a custom panel through showCustomVisualDialog()? In other words, I have a dialog and a custom panel. I have some button in that panel which I want to have a confirm window (so that it would not close the main custom panel when appearing). Is that possible to implement at all? Tried to create another delegate - button just stops reacting.

In general the relationship between dialog, delegate, panel and plugin is not entirely clear to me - able to get it work, but chiefly through trial and error.

Edit: Also, is it possible to emulate behaviour of button-behaving text labels like, say, "Production capacity per month" label in custom production tab? Namely, glow and sound on mouseover. I understand that given render() I can probably implement my own version from scratch, but really would like to stick to vanilla implementations.

Edit 2: There's one more thing that has been bothering me for quite some time: fleetMember icon which is added by addShipList() in TooltipMakerAPI has 2 widgets for officer and permamods apart from main sprite. The issue is that permamods widget has one little black stripe in place even when there are no actual permamods - completely invisible on the black background but gets painfully obvious when placed on a highlighted/colored panel. See attached.

There are ways to work around this (which, regrettably, involve turning off the icon button and therefore losing access to member tooltip), so no big deal at all. Just hope it gets changed some time in the future.

Edit 3: Also: having a very insidious glitch with my TooltipMakerAPI objects with scrolling list. Button objects stays interactive even when scrolled away beyond the tooltip panel border and even beyond parent custom panel border.  Tried additional custom panel containers, tried various configs of setForceProcessInput() - no luck. Strangely enough, when I designed my first scrollable list this issue never came up - despite panel/tooltip configs being much the same. I believe I can work around this by disabling ship icon button and setting mouseover sound of checkbox to null, but that's not particularly desirable for me in terms of user experience. Might there be something I overlooked? See second attached for visual on the problem.

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 22, 2023, 12:23:52 AM
deleted

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 22, 2023, 08:00:05 AM
A projectile can be made to only have a proximity detonation near missiles by giving vsMissileRange a value other than 0 and giving range a value of 0, but how do you make a projectile detonate on proximity with both missiles and fighters but not ships?

Fairly sure it's not set up to be configured that way. It's probably possible to script this behavior explicitly though that seems like a decent amount of work.


Can I call showCustomDialog() - which shows a panel - on a same instance of InteractionDialogAPI while already showing a custom panel through showCustomVisualDialog()? In other words, I have a dialog and a custom panel. I have some button in that panel which I want to have a confirm window (so that it would not close the main custom panel when appearing). Is that possible to implement at all? Tried to create another delegate - button just stops reacting.

It won't work, no.

Edit: Also, is it possible to emulate behaviour of button-behaving text labels like, say, "Production capacity per month" label in custom production tab? Namely, glow and sound on mouseover. I understand that given render() I can probably implement my own version from scratch, but really would like to stick to vanilla implementations.

I don't think making these is exposed via the API - sorry!


Edit 2: There's one more thing that has been bothering me for quite some time: fleetMember icon which is added by addShipList() in TooltipMakerAPI has 2 widgets for officer and permamods apart from main sprite. The issue is that permamods widget has one little black stripe in place even when there are no actual permamods - completely invisible on the black background but gets painfully obvious when placed on a highlighted/colored panel. See attached.

Made a note to take a look, thought I'd fixed that but maybe I'm thinking about the fleet screen.


Edit 3: Also: having a very insidious glitch with my TooltipMakerAPI objects with scrolling list. Button objects stays interactive even when scrolled away beyond the tooltip panel border and even beyond parent custom panel border.  Tried additional custom panel containers, tried various configs of setForceProcessInput() - no luck. Strangely enough, when I designed my first scrollable list this issue never came up - despite panel/tooltip configs being much the same. I believe I can work around this by disabling ship icon button and setting mouseover sound of checkbox to null, but that's not particularly desirable for me in terms of user experience. Might there be something I overlooked? See second attached for visual on the problem.

Huh, that's very odd. Nothing comes to mind immediately as a problem. If you have a minimal snippet of code I can run somewhere (i.e. probably pasting it into some existing intel item) to reproduce this behavior, I can take a look!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 22, 2023, 08:52:54 AM
Edit 3: Also: having a very insidious glitch with my TooltipMakerAPI objects with scrolling list. Button objects stays interactive even when scrolled away beyond the tooltip panel border and even beyond parent custom panel border.  Tried additional custom panel containers, tried various configs of setForceProcessInput() - no luck. Strangely enough, when I designed my first scrollable list this issue never came up - despite panel/tooltip configs being much the same. I believe I can work around this by disabling ship icon button and setting mouseover sound of checkbox to null, but that's not particularly desirable for me in terms of user experience. Might there be something I overlooked? See second attached for visual on the problem.

Huh, that's very odd. Nothing comes to mind immediately as a problem. If you have a minimal snippet of code I can run somewhere (i.e. probably pasting it into some existing intel item) to reproduce this behavior, I can take a look!

This placeholder list class that I quickly cobbled together has the same issue persisting - tested it in my custom panel tab as I do not work with intel items, but believe it should reproduce given CustomPanelAPI and CustomUIPanelPlugin.
Spoiler
Code
package forgprod.abilities.interaction.panel.components.tabs;

import java.util.ArrayList;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CustomUIPanelPlugin;
import com.fs.starfarer.api.combat.ShipVariantAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.ui.*;
import com.fs.starfarer.api.util.Misc;

public class PlaceholderTab {

    public static CustomPanelAPI create(CustomPanelAPI panel, float width, CustomUIPanelPlugin plugin) {
        CustomPanelAPI placeholderTab = panel.createCustomPanel(width, 400f, plugin);
        TooltipMakerAPI list = addList(placeholderTab);
        placeholderTab.addUIElement(list).inMid();
        panel.addComponent(placeholderTab).inTL(4f, 4f);
        return placeholderTab;
    }


    private static TooltipMakerAPI addList(CustomPanelAPI placeholderTab) {
        TooltipMakerAPI listPanel = placeholderTab.createUIElement(400f, 100f, true);
        List<ShipVariantAPI> blueprints = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            blueprints.add(Global.getSettings().getVariant("crig_Standard"));
        }
        float summaryOffset = 0f;
        for (ShipVariantAPI blueprint : blueprints) {
            addBlueprintEntry(listPanel, blueprint);
            summaryOffset += 9f;
        }
        listPanel.addSpacer(-summaryOffset);
        return listPanel;
    }

    private static void addBlueprintEntry(TooltipMakerAPI listPanel, ShipVariantAPI blueprint) {
        ButtonAPI checkbox = listPanel.addAreaCheckbox("", null, Misc.getDarkPlayerColor(),
                Misc.getDarkPlayerColor(), Misc.getDarkPlayerColor(),
                300f, 30f, 1f);
        checkbox.getPosition().setXAlignOffset(0f);
        listPanel.addSpacer(0f);
        listPanel.getPrev().getPosition().setXAlignOffset(-15f);
        FleetMemberAPI dummyMember = Global.getFactory().createFleetMember(FleetMemberType.SHIP, blueprint);
        List<FleetMemberAPI> memberAsList = new ArrayList<>();
        memberAsList.add(dummyMember);
        listPanel.addShipList(1, 1, 30f, Misc.getDarkPlayerColor(), memberAsList, 0f);
        UIComponentAPI hullIcon = listPanel.getPrev();
        hullIcon.getPosition().setYAlignOffset(30f);
        listPanel.addSpacer(10f);
        listPanel.getPrev().getPosition().setXAlignOffset(25f);
    }

}
[close]

Also, thank you for your time and effort in answering all of the questions and explaining things. I don't think even Tynan holds a candle to you in modding support department!

Edit:

I don't think making these is exposed via the API - sorry!

Any chance this could be exposed in the future?

Made a note to take a look, thought I'd fixed that but maybe I'm thinking about the fleet screen.

To clarify on the issue: black stripe shows on mouseover if the background is not black, without mouseover stripe does not appear.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on January 22, 2023, 09:37:32 AM
Huh, that's very odd. Nothing comes to mind immediately as a problem. If you have a minimal snippet of code I can run somewhere (i.e. probably pasting it into some existing intel item) to reproduce this behavior, I can take a look!

the issue also shows up when fighting a large enough fleet, ships in the list will still be mouse-overable even if they've been scrolled off the bottom of the main visible area
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 23, 2023, 11:59:58 AM
This placeholder list class that I quickly cobbled together has the same issue persisting - tested it in my custom panel tab as I do not work with intel items, but believe it should reproduce given CustomPanelAPI and CustomUIPanelPlugin.
the issue also shows up when fighting a large enough fleet, ships in the list will still be mouse-overable even if they've been scrolled off the bottom of the main visible area

Oh, yikes - thank you! Turns out this was a general issue affecting mouseover events inside *nested* scrollable areas, specifically. Fixed this up and verified the issue (and the fix) with both the test code and the large-fleet case.


Any chance this could be exposed in the future?

... yes, it actually already is, I think. There's a new TooltipMakerAPI.addLabelledValue() method.

To clarify on the issue: black stripe shows on mouseover if the background is not black, without mouseover stripe does not appear.

Ahh, ok - this'll be fixed for the next release, then; the fix I thought I'd made didn't cover the glow case.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 23, 2023, 06:42:03 PM
question
does .setDamageAmount() actually function as intended when applied to proximity fuze mines? does it affect the explosion damage? and the amount of danger enemy AI feels when inside explosion range?
testing results are inconclusive and ambiguous in the extreme
some clarification?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 23, 2023, 11:00:54 PM
Oh, yikes - thank you! Turns out this was a general issue affecting mouseover events inside *nested* scrollable areas, specifically. Fixed this up and verified the issue (and the fix) with both the test code and the large-fleet case.
... yes, it actually already is, I think. There's a new TooltipMakerAPI.addLabelledValue() method.
Ahh, ok - this'll be fixed for the next release, then; the fix I thought I'd made didn't cover the glow case.

Absolutely glorious, thank you sir. Ecstatic for the release, just can't bear the wait!

Wanted to make some more less pressing inquiries in the mean time:

1. There are relationship bars (can be added by method in TooltipMakerAPI), percentage bars in the fleet tab for hull and CR, and also bars with sliders in settings window. From what I've gathered, relationship bars are hardly suitable for anything but relationships themselves as they are not customizable and always show status string like ("Welcoming"), while proper bars and sliders are outside of reach of modders completely.

While I am able to worm my way around this with use of buttons, checkboxes and text fields (sadly, result looks nothing like vanilla), and other modders employed section headings for the same purpose, kinda wanted to ask you: are there any plans to give us proper, vanilla-looking bars and sliders?

2. It seems that addShipIcons() in TooltipMakerAPI is not quite ideal for the many purposes modders have come to use it for. For example, it is ill-suited for displaying ship images bigger than 128x128, and also does not render weaponry. Is there any way for me to display ships in custom panels (or, ideally, in tooltip instance) the way fleet or refit tab does them?

3. What kind of interactable buttons ship list in refit tab and hull list in blueprint tab use for entry items? Currently using area checkboxes (which can be made borderless only through color shenanigans, and that introduces its own problems), but it seems like there are proper method for borders in obfuscated code. Would it be possible for me, given the current API, to emulate vanilla ship lists precisely?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 25, 2023, 06:27:12 AM
Is it possible to swap out built-in fighter wing for another? There doesn't seem to be any method akin to ShipVariantAPI's addWeapon (though imagine changing this would involve HullSpecAPI anyway)

I guess swapping to another hull with the alternate built-in fighter would be feasible..?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on January 25, 2023, 10:34:41 AM
Is it possible to swap out built-in fighter wing for another? There doesn't seem to be any method akin to ShipVariantAPI's addWeapon (though imagine changing this would involve HullSpecAPI anyway)

I guess swapping to another hull with the alternate built-in fighter would be feasible..?

you can use setWingId(), something like this should work? (though I've not tested it)

Code
        for (String wingId : variant.getWings()) {
            if (wingId.equals("wingToReplace")) {
                variant.setWingId(variant.getWings().indexOf(wingId), "otherWingID");
            }
        }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 25, 2023, 05:31:36 PM
variant.setWingId() doesn't seem to do anything,
but             
variant.getWing(variant.getWings().indexOf(wingId)).setId("otherWingID");
changes the wing..however, there is some odd behavior.

1.) Wing data in refit screen isn't updated - Ex. If original wing was terminator, and I swap to talons, mousing over the wing still displays info for terminator

2.) Wing doesnt seem to deploy fully if there is a discrepancy between the two wings sizes - this seems to occur when the original wing has less members than the wing swapped to. Going off the above example w/ terminators and talons, the first 2 members deploy immediately but others goes through normal refit process before launching

I tried to use variant.refreshBuiltInWings() to see if it would resolve the above two, but doesn't seem to have any visible effect..

3.) If there are multiple built-in wings, all of them are swapped, irregardless of wing index used

Code
    private final int WING1_INT = 0;
    @Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
{
            stats.getVariant().getWing(WING1_INT).setId("talon_wing");
stats.getVariant().setWingId(WING1_INT,"talon_wing");
stats.getVariant().refreshBuiltInWings();
       
    }

is there something im overlooking?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on January 25, 2023, 05:53:14 PM
Is it possible to swap out built-in fighter wing for another? There doesn't seem to be any method akin to ShipVariantAPI's addWeapon (though imagine changing this would involve HullSpecAPI anyway)

I guess swapping to another hull with the alternate built-in fighter would be feasible..?

See Roider Union's MIDAS and Tracker Swap hullmods.

Tracker Swap is what the player sees, but the actual switching code must be in MIDAS (which is built in) because Tracker Swap can't switch back to the original wing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on January 26, 2023, 03:37:09 AM
Just wondering, what's the official stance on using edited in game assets (Assets originating from the default game)? For example palette swapping a hullmod icon to use for a new hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 26, 2023, 11:26:55 AM
Absolutely glorious, thank you sir. Ecstatic for the release, just can't bear the wait!

:)

1. There are relationship bars (can be added by method in TooltipMakerAPI), percentage bars in the fleet tab for hull and CR, and also bars with sliders in settings window. From what I've gathered, relationship bars are hardly suitable for anything but relationships themselves as they are not customizable and always show status string like ("Welcoming"), while proper bars and sliders are outside of reach of modders completely.

While I am able to worm my way around this with use of buttons, checkboxes and text fields (sadly, result looks nothing like vanilla), and other modders employed section headings for the same purpose, kinda wanted to ask you: are there any plans to give us proper, vanilla-looking bars and sliders?

Nothing like plans, maybe at some point? There's a lot of UI bits to potentially make API accessible. The "Event" bars will be addable, though, and I think possible to repurpose.

2. It seems that addShipIcons() in TooltipMakerAPI is not quite ideal for the many purposes modders have come to use it for. For example, it is ill-suited for displaying ship images bigger than 128x128, and also does not render weaponry. Is there any way for me to display ships in custom panels (or, ideally, in tooltip instance) the way fleet or refit tab does them?

Yeah, the ship icons are not meant to be displayed at a large size, hence "icon". I don't think the custom ship view is available via the API; wouldn't be a bad thing to add... at some point.

3. What kind of interactable buttons ship list in refit tab and hull list in blueprint tab use for entry items? Currently using area checkboxes (which can be made borderless only through color shenanigans, and that introduces its own problems), but it seems like there are proper method for borders in obfuscated code. Would it be possible for me, given the current API, to emulate vanilla ship lists precisely?

I don't think it can be easily emulated; it's using some stuff that's not exposed.


Just wondering, what's the official stance on using edited in game assets (Assets originating from the default game)? For example palette swapping a hullmod icon to use for a new hullmod.

This isn't a problem at all. For example, people use bits of vanilla ships etc all the time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 26, 2023, 07:02:23 PM
Where would I find a good example of adding a timed effect to a ship?

For example, I want to make a weapon that, when it hits shields, decreases the max shield coverage on that ship by ten degrees for 10 seconds. Multiple hits would stack, each with their own timer.

Bonus question: will there be a problem if the above method reduces the shield arc to 0 or negative?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 28, 2023, 10:29:00 AM
Where would I find a good example of adding a timed effect to a ship?

For example, I want to make a weapon that, when it hits shields, decreases the max shield coverage on that ship by ten degrees for 10 seconds. Multiple hits would stack, each with their own timer.

Hmm - DisintegratorEffect in vanilla, perhaps? It's the effect for the special Disintegrator weapon. There's some extra stuff for particle effects but it's still a timed effect.

Bonus question: will there be a problem if the above method reduces the shield arc to 0 or negative?

Probably not but I'm not 100% on that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on January 28, 2023, 10:00:18 PM
Is it possible to close a CustomDialogDelegate via code? I created a fancy custom panel that allows the player to easily select a weapon or fighter wing from their cargo, and it works entirely as it should, but I haven't found a single way to close the panel without the player pressing Confirm or Cancel. As the item selection is handled via buttons, I'd like to have a way to close the custom panel when the button is pressed (without closing the parent interaction dialog).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on January 28, 2023, 10:38:35 PM
Is it possible to close a CustomDialogDelegate via code? I created a fancy custom panel that allows the player to easily select a weapon or fighter wing from their cargo, and it works entirely as it should, but I haven't found a single way to close the panel without the player pressing Confirm or Cancel. As the item selection is handled via buttons, I'd like to have a way to close the custom panel when the button is pressed (without closing the parent interaction dialog).

In addition, please add a getBarrelSpriteName() function to the WeaponSpecAPI. It's currently impossible to render the barrels of weapons in a custom panel without manually entering the ID (which is infeasible if you're dealing with thousands of modded weapons).

Edit: a way to render missiles in their launchers would be nice too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 29, 2023, 06:50:19 PM
It looks like the upkeep for a Size 3 colony with Vast Ruins is half what it should be. Here's what I've been looking at.

I've been digging into the TechMining code and have been looking at the upkeep. The basegame TechMining.java has the following:
Code: java
public void apply() {
  super.apply(false);

  int size = market.getSize();

  int max = 0;
  if (market.hasCondition(Conditions.RUINS_VAST)) {
    max = 4;
  } else if (market.hasCondition(Conditions.RUINS_EXTENSIVE)) {
    max = 3;
  } else if (market.hasCondition(Conditions.RUINS_WIDESPREAD)) {
    max = 2;
  } else if (market.hasCondition(Conditions.RUINS_SCATTERED)) {
    max = 1;
  }

  size = Math.min(size, max);

  applyIncomeAndUpkeep(size);

  if (!isFunctional()) {
    supply.clear();
  }

  market.addTransientImmigrationModifier(this);
}
According to the wiki the TechMining building should have an upkeep of (ruins size - 2) * 500cr. In the above code the "size = Math.min(size, max);" line produces values of the following for a Size 3 colony:

1 - Scattered Ruins
2 - Widespread Ruins
3 - Extensive Ruins
3 - Vast Ruins

Going further, the "applyIncomeAndUpkeep(size);" function in the "BaseIndustry.java" file then gets a sizeOverride = 1/2/3/3, which would:
Code
protected void applyIncomeAndUpkeep(float sizeOverride) {
  float size = market.getSize();
  if (sizeOverride >= 0) size = sizeOverride;
  float sizeMult = getSizeMult(size);
  sizeMult = Math.max(1, sizeMult - 2);

...

  int upkeep = (int) (getSpec().getUpkeep() * sizeMult);

...

}
This means that sizeMult becomes: 1/1/1/1, or 500/500/500/500cr upkeep costs for a Size 3 colony.

When following the chain through with a Size 4+ colony, this becomes: 1/2/3/4 > 1/1/1/2 > 500/500/500/1000cr upkeep costs for the colony.

It just looks like the upkeep for a Size 3 colony with Vast Ruins is half what it should be (according to the Wiki). Am I correct? Is this intended?

(I know I know, it seems weird that I'm asking about this minor thing. I'm trying to understand the TechMining code and this looked odd to me - trying to be sure that I'm translating it correctly.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 30, 2023, 12:11:17 AM
Is it possible to swap out built-in fighter wing for another? There doesn't seem to be any method akin to ShipVariantAPI's addWeapon (though imagine changing this would involve HullSpecAPI anyway)

I guess swapping to another hull with the alternate built-in fighter would be feasible..?

See Roider Union's MIDAS and Tracker Swap hullmods.

Tracker Swap is what the player sees, but the actual switching code must be in MIDAS (which is built in) because Tracker Swap can't switch back to the original wing.
ohoho, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 30, 2023, 02:30:18 AM
It's currently impossible to render the barrels of weapons in a custom panel without manually entering the ID (which is infeasible if you're dealing with thousands of modded weapons).

Spoiler
Code
        ShipVariantAPI variant = module.getParentFleetMember().getVariant();
        List<String> slots = variant.getNonBuiltInWeaponSlots();
        if (slots.size() == 0) return;
        WeaponSpecAPI firstSlotWeapon = variant.getWeaponSpec(slots.get(0));
        Object spriteGunName;
        Class<?> weaponClass = firstSlotWeapon.getClass();
        MethodHandles.Lookup lookup = MethodHandles.lookup();
        Class<?> methodClass = Class.forName("java.lang.reflect.Method", false, Class.class.getClassLoader());
        MethodHandle getMethodName = lookup.findVirtual(methodClass, "getName", MethodType.methodType(String.class));
        MethodHandle unreflect = lookup.findVirtual(lookup.getClass(), "unreflect", MethodType.methodType(MethodHandle.class, methodClass));
        Object getSpriteMethod = null;
        for (Object method : weaponClass.getDeclaredMethods()) {
            String checkedMethodName = (String) getMethodName.invoke(method);
            if (checkedMethodName.equals("getTurretGunSpriteName")) {
                getSpriteMethod = method;
                break;
            }
        }
        MethodHandle spriteGetterMH = null;
        if (getSpriteMethod != null) {
            spriteGetterMH = (MethodHandle) unreflect.invoke(lookup, getSpriteMethod);
            spriteGunName = spriteGetterMH.invoke(firstSlotWeapon);
        } else {
            return;
        }
        String weaponSprite = firstSlotWeapon.getTurretSpriteName();
        String weaponSpriteUnder = (String) spriteGunName;
        modulePanel.addImage(weaponSprite, 0f);
        UIComponentAPI main = modulePanel.getPrev();
        main.getPosition().setXAlignOffset(150f);
        main.getPosition().setYAlignOffset(20f);
        float mainWidth = main.getPosition().getWidth();
        modulePanel.addImage(weaponSpriteUnder, 0f);
        UIComponentAPI under = modulePanel.getPrev();
        under.getPosition().rightOfMid(main, -(mainWidth));
        modulePanel.addImage(weaponSprite, 0f);
        UIComponentAPI test = modulePanel.getPrev();
        test.getPosition().rightOfMid(under, 10f);
[close]

[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on January 30, 2023, 02:14:37 PM
I'd like to make a bounty where the fleet will retreat when encountered (and you are forced to chase down their ships because they are being assassinated!) However, doing this in a way like reducing fleet points massively allows the player to autoresolve. Is there a way to force/allow the player to do a chasing fleeing enemy scenario without allowing the autoresolve option?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 30, 2023, 04:34:33 PM
Is it possible to close a CustomDialogDelegate via code? I created a fancy custom panel that allows the player to easily select a weapon or fighter wing from their cargo, and it works entirely as it should, but I haven't found a single way to close the panel without the player pressing Confirm or Cancel. As the item selection is handled via buttons, I'd like to have a way to close the custom panel when the button is pressed (without closing the parent interaction dialog).

I don't think so, let me make a note.



In addition, please add a getBarrelSpriteName() function to the WeaponSpecAPI. It's currently impossible to render the barrels of weapons in a custom panel without manually entering the ID (which is infeasible if you're dealing with thousands of modded weapons).

Added these to ProjectileWeaponSpecAPI!


Edit: a way to render missiles in their launchers would be nice too.

Ah, sorry - that's more involved.


It just looks like the upkeep for a Size 3 colony with Vast Ruins is half what it should be (according to the Wiki). Am I correct? Is this intended?

(I know I know, it seems weird that I'm asking about this minor thing. I'm trying to understand the TechMining code and this looked odd to me - trying to be sure that I'm translating it correctly.)

... I'm going to assume the code is correct, though if we're being honest, I don't remember what was intended here. It could definitely use another look at some point.


I'd like to make a bounty where the fleet will retreat when encountered (and you are forced to chase down their ships because they are being assassinated!) However, doing this in a way like reducing fleet points massively allows the player to autoresolve. Is there a way to force/allow the player to do a chasing fleeing enemy scenario without allowing the autoresolve option?

I think the way to do this would be to provide your own BattleCreationPluginImpl for that specific battle which ignores the stuff specified in BattleCreationContext and creates a retreat-type scenario regardless. I'm not 100% sure this would play nice with everything in FleetInteractionDialogPluginImpl. You might need to change the FleetGoal for each side in the passed-in BattleCreationContext and just in general make sure the various battle-ending outcomes work properly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on January 30, 2023, 10:58:39 PM
Constructors for implementations of ship systems are public and accept ship instance and system spec - so theoretically I can create instance of second ship system. BUT: I reckon there are plenty of things, features and calls that assume only a single system on the ship.

What I need the shipsystem instance for is the DroneAI constructor - I want to assign a vanilla AI to manually-spawned ship. Is that something realistic at all? My ultimate goal here is to hijack vanilla movement AI for my custom AI that would only provide target location and facing to vanilla implementations. I think I can do something of that spirit with BasicEngineAI, which allows for setting heading and facing - in absolute angles, if I understood correctly. What purpose BasicEngineAI serves and what can I make it do for me?

If that is not feasible or if asking questions about vanilla obfuscations is not permitted - is there any possible resources or help on constructing movement AI from scratch, or am I on my own here?

Edit: figured out BasicEngineAI and hijacking the movement part, now interested in getting rid of the jerkiness, which is quite resembling movements of vanilla fighters, while I require smooth movement of station drones. Saw the SmoothMovementModuleCombatCopy - is that what I need? Does this mean that velocity shenanigans are inevitable if precise locomotion is required?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 31, 2023, 12:35:12 AM
With my techmining mod I am getting to the point of doing drop groups and special code to determine what kinds of things would be appropriate to the planet which is being mined.

However I don't know how to tell the game "hey, use my custom extended techmining code instead of the base-game code". So that this code:

Code: java
package data.scripts.wta_industry;

/*
  ...imports here...
 */

public class wta_TechMining extends TechMining {

/*
 ... my code here ...
 */

}

I don't know how to say "TechMining, you're now using that ^^^ code up there".

Help on this will be much appreciated. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AnMGQfan on January 31, 2023, 09:35:42 AM
Hi.
I am just starting to make mod and I want to know if it is possible to make my modded ships only spawn as derelict ship (better if I can make them rarer the closer we are to civilised space).
thx in advance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 31, 2023, 10:59:45 AM
Saw the SmoothMovementModuleCombatCopy - is that what I need? Does this mean that velocity shenanigans are inevitable if precise locomotion is required?

Given what you're trying to do, you probably just want to write some code that manually sets the velocity (or, heck, even the location) of the ship and makes the engines burn in the right way to make it look like they're doing that. Otherwise, you have to try to get really precise movement by giving commands to the ship's engines, and that's just not going to be *that* precise, since the minimum it can do is a frame's worth of acceleration.


I don't know how to say "TechMining, you're now using that ^^^ code up there".

Help on this will be much appreciated. :)

You want to provide your own copy of industries.csv which points to your new TechMining class.


Hi.
I am just starting to make mod and I want to know if it is possible to make my modded ships only spawn as derelict ship (better if I can make them rarer the closer we are to civilised space).
thx in advance.

Hmm - I don't see why not, though this seems like something you'd need to write custom code to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 31, 2023, 11:06:13 AM
I don't know how to say "TechMining, you're now using that ^^^ code up there".

Help on this will be much appreciated. :)

You want to provide your own copy of industries.csv which points to your new TechMining class.
As a note, just changing industries.csv will only apply to newly-constructed tech-mining; if someone installs your mod mid-game, you need to take additional steps.

I'd suggest taking a look at my Planetary Shield (https://fractalsoftworks.com/forum/index.php?topic=14990.0) mod, which includes code that does a replacement of existing planetary shield installations on initial mod activation. It shouldn't be too hard to modify that for your needs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 31, 2023, 11:08:32 AM
I don't know how to say "TechMining, you're now using that ^^^ code up there".

Help on this will be much appreciated. :)
You want to provide your own copy of industries.csv which points to your new TechMining class.
Brilliantly easy, thank you Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 31, 2023, 11:16:07 AM
I don't know how to say "TechMining, you're now using that ^^^ code up there".

Help on this will be much appreciated. :)

You want to provide your own copy of industries.csv which points to your new TechMining class.
As a note, just changing industries.csv will only apply to newly-constructed tech-mining; if someone installs your mod mid-game, you need to take additional steps.

I'd suggest taking a look at my Planetary Shield (https://fractalsoftworks.com/forum/index.php?topic=14990.0) mod, which includes code that does a replacement of existing planetary shield installations on initial mod activation. It shouldn't be too hard to modify that for your needs.
Going the extra mile, eh? Will have a look-see tonight.

I should expect that uninstalling my mod would require the player to first remove all existing TechMining infrastructure?

What if I set TechMining to be a Structure rather than an Infrastructure?

What might that do to existing Infrastructure, or (on removal) do to a Structure suddenly switching back to Infrastructure when the planet is already maxed out with Infrastructure?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 31, 2023, 11:23:00 AM
I should expect that uninstalling my mod would require the player to first remove all existing TechMining infrastructure?
It's actually worse than that - to allow uninstalling, all existing tech-mining would need to be removed, including any tech-mining on NPC planets, and then the game would need to be run for two months in-game time, otherwise the end-of-month cost summaries will crash the game looking for your implementation of tech-mining.

If you want an uninstall-like option, the best I was able to do was to include a settings switch that restores vanilla behavior.

What if I set TechMining to be a Structure rather than an Infrastructure?

What might that do to existing Infrastructure, or (on removal) do to a Structure suddenly switching back to Infrastructure when the planet is already maxed out with Infrastructure?
Setting tech mining to be a structure rather than an industry will just work.

Setting it back will also 'just work', but planets that find themselves over the industry cap will suffer a -5 stability penalty. (This stability penalty is a vanilla mechanic, intended for the case of "Someone gets a hypershunt tap up and running, builds an extra industry, and then has a shipping shortage on transplutonics".)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 31, 2023, 12:02:11 PM
I should expect that uninstalling my mod would require the player to first remove all existing TechMining infrastructure?
It's actually worse than that - to allow uninstalling, all existing tech-mining would need to be removed, including any tech-mining on NPC planets, and then the game would need to be run for two months in-game time, otherwise the end-of-month cost summaries will crash the game looking for your implementation of tech-mining.

If you want an uninstall-like option, the best I was able to do was to include a settings switch that restores vanilla behavior.
Is that tech-mining on NPC planets in the vanilla game, or something that happens with other mods like Nexrellin etc?

If tech-mining returns a special item, what does the NPC planet do with it?
Quote
What if I set TechMining to be a Structure rather than an Infrastructure?

What might that do to existing Infrastructure, or (on removal) do to a Structure suddenly switching back to Infrastructure when the planet is already maxed out with Infrastructure?
Setting tech mining to be a structure rather than an industry will just work.

Setting it back will also 'just work', but planets that find themselves over the industry cap will suffer a -5 stability penalty. (This stability penalty is a vanilla mechanic, intended for the case of "Someone gets a hypershunt tap up and running, builds an extra industry, and then has a shipping shortage on transplutonics".)
Cool, so the game can potentially handle the extra industrial. Apart from the crash potential above, so I’d have to do like you and provide a vanilla settings switch.

It’s tempting to take the lazy-mans way and say “not removable, test on a copy of your game”.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 31, 2023, 12:10:53 PM
I should expect that uninstalling my mod would require the player to first remove all existing TechMining infrastructure?
It's actually worse than that - to allow uninstalling, all existing tech-mining would need to be removed, including any tech-mining on NPC planets, and then the game would need to be run for two months in-game time, otherwise the end-of-month cost summaries will crash the game looking for your implementation of tech-mining.

If you want an uninstall-like option, the best I was able to do was to include a settings switch that restores vanilla behavior.
Is that tech-mining on NPC planets in the vanilla game, or something that happens with other mods like Nexrellin etc?

It's any tech-mining that's using your code. So, if you just change industries.csv, the only tech-mining that needs to be removed for an uninstall is any that were constructed after the mod is installed. It's all tech-mining if you do like my mod does and scan through all colonies to replace vanilla tech-mining with your own implementation.

If tech-mining returns a special item, what does the NPC planet do with it?
As for return of special items: to the best of my knowledge, tech-mining on AI colonies doesn't actually do anything. So, it doesn't return any special items or put the occasional unusual item up in the markets, and by the same token, it doesn't install special items because it doesn't generate any in the first place. Changing this behavior is certainly something a mod could do, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 31, 2023, 12:48:34 PM
Is that tech-mining on NPC planets in the vanilla game, or something that happens with other mods like Nexrellin etc?

It's any tech-mining that's using your code. So, if you just change industries.csv, the only tech-mining that needs to be removed for an uninstall is any that were constructed after the mod is installed. It's all tech-mining if you do like my mod does and scan through all colonies to replace vanilla tech-mining with your own implementation.

If tech-mining returns a special item, what does the NPC planet do with it?
As for return of special items: to the best of my knowledge, tech-mining on AI colonies doesn't actually do anything. So, it doesn't return any special items or put the occasional unusual item up in the markets, and by the same token, it doesn't install special items because it doesn't generate any in the first place. Changing this behavior is certainly something a mod could do, though.
Is it possible to scan through and only affect the player’s colonies?

Since tech-mining on AI colonies does nothing, and changing that behavior would definitely be feature-creep. Leave that sort of thing to the mod authors who have Factions actively expanding and growing by settling new colonies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 31, 2023, 01:57:13 PM
Is it possible to scan through and only affect the player’s colonies?
Technically yes, but I don't recommend it: that would interface poorly with Nexerelin's ability for the player to capture NPC colonies. I'd think it'd be better to simply replace everything and just have your tech-mining implementation not do anything if it's not at a player-controlled colony.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on January 31, 2023, 02:34:41 PM
is there a listener that i can attach to a ship that advances while combat is paused? hullmod's advance doesn't, and neither does an AdvanceableListener.

edit: alternatively, is there any kind of script/listener that i can add to the combat engine that is easy to clean up when combat ends? i am trying to draw onto the UI but only when the ship is alive and controlled by the player.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 31, 2023, 03:43:23 PM
Is it possible to scan through and only affect the player’s colonies?
Technically yes, but I don't recommend it: that would interface poorly with Nexerelin's ability for the player to capture NPC colonies. I'd think it'd be better to simply replace everything and just have your tech-mining implementation not do anything if it's not at a player-controlled colony.
Funny how a personal project has morphed into something that needs to be able to coexist with big mods. Originally I hadn’t thought of releasing - guess that I’ll have to now.

I’ll try to get it to replace everything. If someone wants to uninstall they can revert to a prior save - I’m probably not gonna be able to do better than that since some of the base TechMining code is static functions and cannot be overridden, only rewritten.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on January 31, 2023, 04:09:07 PM
Anyone know of any examples of visual effects that travel around a shield from the point of impact? For example, I want two particles (or whatever) to travel in different directions around the shield from the point it is hit by a shot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 31, 2023, 07:02:58 PM
Is it possible to scan through and only affect the player’s colonies?
Technically yes, but I don't recommend it: that would interface poorly with Nexerelin's ability for the player to capture NPC colonies. I'd think it'd be better to simply replace everything and just have your tech-mining implementation not do anything if it's not at a player-controlled colony.
Funny how a personal project has morphed into something that needs to be able to coexist with big mods. Originally I hadn’t thought of releasing - guess that I’ll have to now.
Oh, hah, that does change the context a bit, yeah. If it's only meant for personal use then sure! Do whatever! For that context, you could just use Alex's original suggestion of changing industries.csv and not worry about replacing existing installations; as long as you know what's going on, it's a non-issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on January 31, 2023, 07:36:45 PM
Oh, hah, that does change the context a bit, yeah. If it's only meant for personal use then sure! Do whatever! For that context, you could just use Alex's original suggestion of changing industries.csv and not worry about replacing existing installations; as long as you know what's going on, it's a non-issue.
Naw, you-all have put the suggestions my way. It’d be rude to not at least try.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 01, 2023, 01:45:59 AM
How do I determine if a colony/market is within 10ly of a Coronal Hypershunt?

-edit-

Actually don%u2019t worry - checking for this isn%u2019t necessary.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on February 02, 2023, 03:56:15 PM
is there an advance or GUI drawing listener/plugin that runs after all other advance methods?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on February 02, 2023, 04:52:20 PM
Can a projectile have more than one onHitEffect?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 02, 2023, 07:12:51 PM
It can only have one plugin, but that plugin can have as many effects as you want.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 02, 2023, 07:18:13 PM
is there a way to somehow remove/change the "-class" part of the hull name for the specifiic ship?
so the getHullNameWithDashClass returns only the name, or some custom string instead of "-class" ?
for example, if i want to change the hound so everywhere in the ui where it shows "Hound-class"  it will instead show "Hound" or "Hound-senpai" or something equally silly
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 03, 2023, 01:32:12 AM
How do I write to the Starsector logfile?

The reason is in the attached image - my custom TechMining code gave me two Soil Nanites, when it should only have given one.



[attachment deleted by admin]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 03, 2023, 05:19:13 AM
How do I write to the Starsector logfile?

The reason is in the attached image - my custom TechMining code gave me two Soil Nanites, when it should only have given one.

import these 2 packages
Code
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
and put this at the top of any class that you want to use logging in (then use log.debug("your message here") to actually log something)
Code
    private static final Logger log = Global.getLogger(<your classname here>.class);

    static {
        log.setLevel(Level.ALL);
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on February 03, 2023, 06:23:12 AM
I want to make a "goo gun". It fires projectiles that stick to a ship for ten seconds and slow it down. I'm pretty sure I can do the non-graphics stuff but I have some questions about sprites.

How do I attach a sprite to a ship and can I make it auto-remove after a certain time?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 03, 2023, 10:54:13 AM
How do I write to the Starsector logfile?

The reason is in the attached image - my custom TechMining code gave me two Soil Nanites, when it should only have given one.

import these 2 packages
Code
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
and put this at the top of any class that you want to use logging in (then use log.debug("your message here") to actually log something)
Code
    private static final Logger log = Global.getLogger(<your classname here>.class);

    static {
        log.setLevel(Level.ALL);
    }
Log4J vulnerability FTW LOL!

Thank you! :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 03, 2023, 07:37:02 PM
Logging found the issue:
Code
598329 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Farmland - item_soil_nanites
598329 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: FINAL RESULT - item_soil_nanites
598329 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Final item (if any) - item_soil_nanites
598329 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Progress bar value - 0.100000024
598330 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Special items so far - 1
598330 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Enhanced multiplier - 1.5
It was the Enhanced Multiplier (multEnhanced) in here which was the issue - having 1.5 (first techmining find + Alpha AI + SP Improvement) gives single items an x2 multiplier, I suppose in the back-end somewhere it rounds up:
Code: java
CargoAPI result = SalvageEntity.generateSalvage(random, 1f, 1f, multEnhanced, 1f, dropValue, dropRandom);
Instead I put the multipliers into the drop value groups:
Code: java
    // what planets will have left over after a couple of centuries of sporadic looting and damage from combat/environment/meteors
    d = new DropData();
    d.chances = colonySize;
    d.group = "wta_ruins_sized";
    d.value = 10000 * ruinsSize;
    d.valueMult = multEnhanced;
    dropValue.add(d);
And changed to this:
Code: java
CargoAPI result = SalvageEntity.generateSalvage(random, 1f, 1f, 1f, 1f, dropValue, dropRandom);
Thanks! :D

PS: My logging code is now set up as follows, starting with my settings.json:
Code
{
##############################################################
# Settings for Whisper's Techmining Alteration
  # Tweak at your own risk
##############################################################

  # the monthly rate at which ruins decay by size of ruins
  "wta_ruins_decayrate_scattered": 0.97,
  "wta_ruins_decayrate_widespread": 0.98,
  "wta_ruins_decayrate_expansive": 0.995,
  "wta_ruins_decayrate_vast": 0.9999,
 
  # whether to write to logfile (default false)
  "wta_logging": false,
}
And the code:
Code: java
  // when wta_logging in the settings.json is true, allow writing to logs
  public static boolean wta_logging = Global.getSettings().getBoolean("wta_logging");

  /*
   * code from Ruddygreat for logging
   */
  private static final Logger log = Global.getLogger(wta_TechMining.class);
  static {
    log.setLevel(Level.ALL);
  }
 
  // if wta_logging enabled write to starsector log
  private void wtaDebug(String message) {
    if (wta_logging) {
      log.debug(message);
    }
  }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 03, 2023, 10:17:24 PM
In a mod, I created a player.faction file with empty "known<stuff>" fields (https://github.com/Zsar/starsector-harsher-equipment-restrictions/blob/master/data/world/factions/player.faction) and expected to start a new game with no blueprints. I start with all vanilla "base_bp" blueprints. Why?

... Should I report this as a bug? The vanilla player.faction file contains the "base_bp" tag in all "tags" fields, so I kind of expected it to actually do something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 04, 2023, 02:32:51 AM
question
what are possible existing types of shipsystems?
for the "Type" field in the .system file
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 04, 2023, 04:20:12 AM
In a mod, I created a player.faction file with empty "known<stuff>" fields (https://github.com/Zsar/starsector-harsher-equipment-restrictions/blob/master/data/world/factions/player.faction) and expected to start a new game with no blueprints. I start with all vanilla "base_bp" blueprints. Why?

... Should I report this as a bug? The vanilla player.faction file contains the "base_bp" tag in all "tags" fields, so I kind of expected it to actually do something?

most (all?) of the game's files get merged instead of overwritten where possible, you'll need to specify that you want to overwrite it in your mod_info.json file
look at archean order for an example of that iirc
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 04, 2023, 04:24:15 AM
I mean... I do want it to merge though? Lest I have to copy - and maintain on patch - everything else I do not care to change?

... Might it be more maintainable to use a ModPlugin for this? Looking at the .csv files where I have to copy whole rows to change one single cell, I am starting to feel like editing the data files is a bad idea to begin with?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 04, 2023, 12:02:08 PM
How do I determine if the owner of a planet is player-owned? Not sure where to start looking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on February 04, 2023, 01:23:23 PM
What/where do I mod to make it so arms dealers always let you use your own blueprints? I've heard sometimes you can use your own but I've never actually had that option so it must be rare. I'd like to make it greater since I don't like building colonies but I want to produce ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 04, 2023, 05:41:22 PM
How do I determine if the owner of a planet is player-owned? Not sure where to start looking.

MarketAPI has a method to check the owning faction. I think if(MarketAPI.getFactionId().equals("player")) should work
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 04, 2023, 06:15:19 PM
How do I determine if the owner of a planet is player-owned? Not sure where to start looking.

MarketAPI has a method to check the owning faction. I think if(MarketAPI.getFactionId().equals("player")) should work

Awesome, thank you. :)

--edit--

Found it, it's: market.isPlayerOwned()

/thumbsup
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 04, 2023, 07:33:03 PM
did anyone ever actually use weapon.getGlowSpriteAPI().setAlphaMult(...)
i can't seem to make it function
and i can't find any actual use in vanilla or mods
i suspect that it should allow to glow the glow sprite when the weapon isn't firing
but i see no actual effect
upd: i figure that i see no effect because there is no glow to affect. but i see no null error either.

is there a way to actually force weapon (decorative or otherwise) to glow on demand, not when firing ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 05, 2023, 01:39:05 AM
I have a situation in my code where passing a code-generated item crashes the game.

The code:
Code: java
    // if we have a special item to add
    if (wta_specialitemfound != "") {
      d = new DropData();
      d.chances = 1;
      d.addCustom(wta_specialitemfound, 1f);
      dropRandom.add(d);
    }

The "wta_specialitemfound" that is generated:
Code
wta_farming_1:item_fullerene_spool:wta_ai_cores

The two custom items in there are drop groups:
Code
item_biofactory_embryo,wta_farming_1,10
item_drone_replicator,wta_farming_1,10
item_soil_nanites,wta_farming_1,10
Code
alpha_core,wta_ai_cores,1
beta_core,wta_ai_cores,2
gamma_core,wta_ai_cores,5

Is the crashing happening because this particular function ("d.addCustom(wta_specialitemfound, 1f);") doesn't like having drop groups included it? IE it must only have basic items in the generated list?

--edit--

Here's the erroring part of the log:

Code
728616 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Farmland - wta_farming_1
728616 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: FINAL RESULT - wta_farming_1:item_fullerene_spool:wta_ai_cores
728627 [Thread-7] INFO  sound.public  - Cleaning up music with id [miscallenous_corvus_campaign_music.ogg]
728657 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
java.lang.RuntimeException: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at com.fs.starfarer.api.impl.campaign.procgen.DropGroupRow.<init>(DropGroupRow.java:151)
at com.fs.starfarer.api.impl.campaign.procgen.SalvageEntityGenDataSpec$DropData.addCustom(SalvageEntityGenDataSpec.java:112)
at data.scripts.wta_industry.wta_TechMining.generateCargoForGatheringPoint(wta_TechMining.java:743)
at com.fs.starfarer.api.impl.campaign.CoreScript.doCustomProduction(CoreScript.java:998)
at com.fs.starfarer.api.impl.campaign.CoreScript.reportEconomyMonthEnd(CoreScript.java:1100)
at com.fs.starfarer.campaign.CampaignEngine.reportEconomyMonthEnd(Unknown Source)
at com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper.doEndOfMonthStuff(Unknown Source)
at com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper.nextFrame(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
at org.json.JSONObject.<init>(JSONObject.java:184)
at org.json.JSONObject.<init>(JSONObject.java:311)
at com.fs.starfarer.api.impl.campaign.procgen.DropGroupRow.parseData(DropGroupRow.java:127)
at com.fs.starfarer.api.impl.campaign.procgen.DropGroupRow.<init>(DropGroupRow.java:149)
... 16 more
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 05, 2023, 01:47:14 PM
did anyone ever actually use weapon.getGlowSpriteAPI().setAlphaMult(...)
i can't seem to make it function
and i can't find any actual use in vanilla or mods
i suspect that it should allow to glow the glow sprite when the weapon isn't firing
but i see no actual effect
upd: i figure that i see no effect because there is no glow to affect. but i see no null error either.

is there a way to actually force weapon (decorative or otherwise) to glow on demand, not when firing ?

I think I ran into this before and the problem is the glow sprite has to be rendering? I bypassed it for some ship system decos by coloring the glow sprite manually and using it as the deco weapon's normal sprite - I could edit the alpha of that as I wanted since it is always rendered.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 05, 2023, 01:54:36 PM
I have fixed the above code by splitting the input string as follows:

Code
    wtaDebug("wtaLOG: Final item (if any) - " + wta_specialitemfound);
    wtaDebug("wtaLOG: Giving to player now.");
   
    // if we have a special item to add
    if (wta_specialitemfound != "") {
      d = new DropData();
      d.chances = 1;
      String[] wta_items = wta_specialitemfound.split(":");
      for (String wta_item : wta_items) {
        d.addCustom(wta_item, 1f);
      }
      /* d.addCustom(wta_specialitemfound, 1f); */
      dropRandom.add(d);
    }
   
    wtaDebug("wtaLOG: Colony size - " + colonySize);
    wtaDebug("wtaLOG: Ruins size - " + ruinsSize);
    wtaDebug("wtaLOG: Progress bar value - " + wta_ruins_specialprogressbar);
    wtaDebug("wtaLOG: Special items so far - " + wta_ruins_specialitemsfound);
    wtaDebug("wtaLOG: Enhanced multiplier - " + multEnhanced);

I'm scratching my head though - it still crashes occasionally.

Unless it *really doesn't like custom drop-groups* - in which case I'm stuffed. It'd require some really nasty drop-group-creation to take the place of the entire "addCustom" section. I'm not even sure that'd be possible.

I *really* don't want to be coding the custom drop-groups, that's way less flexible.

Possible lateral way around this - to get the individual contents of the custom drop groups and "addCustom" them as individual base items? If that's even possible?

Ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 05, 2023, 02:49:20 PM
This is a weird misc-modding question, but I would like to know how the replacement rate work in a simple manner.

We know they decrease when it is replacing fighters but by how much? Does the replacement time matter? What's the difference between replacing two broadswords out of three at the same time vs replacing one broadsword out of three twice? Talons are recorded to get replaced faster and maintain a higher replacement rate than replacing broadswords.

How do the replacement rates recover? Do they recover but the depletion is greater than the recovery? Does Combat Readiness matter here? We know they matter at 0% CR when it suddenly goes down to 0% Replacement Rate.

There's not really a guide that we can rely on and at best players speculate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2023, 03:35:50 PM
is there a listener that i can attach to a ship that advances while combat is paused? hullmod's advance doesn't, and neither does an AdvanceableListener.

edit: alternatively, is there any kind of script/listener that i can add to the combat engine that is easy to clean up when combat ends? i am trying to draw onto the UI but only when the ship is alive and controlled by the player.

CombatEngineAPI.addPlugin()/removePlugin() should be what you want, I think?


is there an advance or GUI drawing listener/plugin that runs after all other advance methods?

EveryFrameCombatPlugin.renderInUICoords() and .renderInWorldCoords()


is there a way to somehow remove/change the "-class" part of the hull name for the specifiic ship?
so the getHullNameWithDashClass returns only the name, or some custom string instead of "-class" ?
for example, if i want to change the hound so everywhere in the ui where it shows "Hound-class"  it will instead show "Hound" or "Hound-senpai" or something equally silly

If it has the STATION hint, which is... going to have some side effects, let's say. If the hull doesn't have a name, though, just the unmodified designation will be used.


I want to make a "goo gun". It fires projectiles that stick to a ship for ten seconds and slow it down. I'm pretty sure I can do the non-graphics stuff but I have some questions about sprites.

How do I attach a sprite to a ship and can I make it auto-remove after a certain time?

Check the Disinitegrator on-hit effect; it does something fairly similar!


Log4J vulnerability FTW LOL!

(Just FYI, the version of log4j the game comes with does not have this vulnerability! Not that it would matter much if it did - the game is not a server that accept requests and can be made to log arbitrary things externally.)


In a mod, I created a player.faction file with empty "known<stuff>" fields (https://github.com/Zsar/starsector-harsher-equipment-restrictions/blob/master/data/world/factions/player.faction) and expected to start a new game with no blueprints. I start with all vanilla "base_bp" blueprints. Why?

JSON arrays are usually (with the exception of a few hardcoded ones) merged by appending their contents, so the way you're providing it in your .player file doesn't actually do anything. The way to accomplish what you want is 1) have a special string "core_clearArray" as the only member in those arrays (I know, I know), or 2) specify player.faction in the "replace" section of your mod_info.json.

IIRC there may be some problems if there are no blueprints in the player faction to start with. Not sure what would happen to fleet spawning etc and just in general there *may* be places in the code that assume the player has *something*.

question
what are possible existing types of shipsystems?
for the "Type" field in the .system file

public static enum ShipSystemType {
   WEAPON,
   ENGINE_MOD,
   SHIELD_MOD,
   STAT_MOD,
   FAST_RELOAD,
   AMMO_RELOAD,
   TELEPORTER,
   PHASE_CLOAK,
   DISPLACER,
   DRONE_LAUNCHER,
   EMP,
}


What/where do I mod to make it so arms dealers always let you use your own blueprints? I've heard sometimes you can use your own but I've never actually had that option so it must be rare. I'd like to make it greater since I don't like building colonies but I want to produce ships.

Arms dealers don't. It depends on the contact types; see CustomProductionContract for details.



I'm scratching my head though - it still crashes occasionally.
...
Ideas?

Would need to see the error message!


This is a weird misc-modding question, but I would like to know how the replacement rate work in a simple manner.

We know they decrease when it is replacing fighters but by how much? Does the replacement time matter? What's the difference between replacing two broadswords out of three at the same time vs replacing one broadsword out of three twice? Talons are recorded to get replaced faster and maintain a higher replacement rate than replacing broadswords.

How do the replacement rates recover? Do they recover but the depletion is greater than the recovery? Does Combat Readiness matter here? We know they matter at 0% CR when it suddenly goes down to 0% Replacement Rate.

There's not really a guide that we can rely on and at best players speculate.

A per-bay rate is computed, and the final rate - that is then used for all the bays for actual fighter replacement times - is the average for all bays. Unused bays count as always having 100% rate.

The per-bay computation is:
If the wing is at max members: increase the rate by 1% per second, modified by REPLACEMENT_RATE_INCREASE_MULT
If the wing is not at max members: decrease the rate by 1% per second, modified by REPLACEMENT_RATE_DECREASE_MULT, and x0.5 if the ship has the fighters pulled back
Then: rate = max(rate, minFighterReplacementRate)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 05, 2023, 04:56:24 PM
I'm scratching my head though - it still crashes occasionally.
...
Ideas?

Would need to see the error message!
Apologies, my brains are toast. Here it is:
Code
674311 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.procgen.DropGroupRow.getBaseUnitValue(DropGroupRow.java:190)
at com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageEntity.generateSalvage(SalvageEntity.java:991)
at data.scripts.wta_industry.wta_TechMining.generateCargoForGatheringPoint(wta_TechMining.java:765)
at com.fs.starfarer.api.impl.campaign.CoreScript.doCustomProduction(CoreScript.java:998)
at com.fs.starfarer.api.impl.campaign.CoreScript.reportEconomyMonthEnd(CoreScript.java:1100)
at com.fs.starfarer.campaign.CampaignEngine.reportEconomyMonthEnd(Unknown Source)
at com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper.doEndOfMonthStuff(Unknown Source)
at com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper.nextFrame(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I'm going to try another way instead of using the "addCustom" code, in case it's that. Checking the drop groups now, to be certain that I've not stuffed those as well.

I was joking about Log4J - I know the game isn't connected as a server to the internet. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2023, 05:10:40 PM
Looking at DropGroupRow line 190 - which btw is in the api code, so you can look at it too! - seems to indicate that the commodity spec for whatever dropped is null. So probably a mixed up ID somewhere?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 05, 2023, 05:41:16 PM
And this code:
Code
    // if we have a special item to add
    if (wta_specialitemfound != "") {
      d = new DropData();
      d.chances = 1;
      String[] wta_items = wta_specialitemfound.split(":");
      // weight the array length +1, so 2x the chance of the first item in the array being chosen
      int wta_random = random.nextInt(wta_items.length + 1);
      if (wta_random > 0) {
        wta_random--;
      }
      String wta_item = wta_items[wta_random];
      wtaDebug("-----------------------");
      wtaDebug("wtaLOG: Item to drop -- " + wta_random + "/" + wta_item);
      wtaDebug("-----------------------");
      // if it starts with wta_ then use group, else use addCustom
      if (wta_item.substring(0,3) == "wta_") {
        d.group = wta_item;
      } else {
        d.addCustom(wta_item, 1f);
      }
/*      for (String wta_item : wta_items) {
        d.addCustom(wta_item, 1f);
      } */
      /* d.addCustom(wta_specialitemfound, 1f); */
      dropRandom.add(d);
    }

Crashed again with this drop group:
Code
item_biofactory_embryo,wta_farming_2,10
item_dealmaker_holosuite,wta_farming_2,10
item_drone_replicator,wta_farming_2,10
item_soil_nanites,wta_farming_2,10

And this error:
Code
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Farmland - wta_farming_2
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: FINAL RESULT - wta_farming_2:item_fullerene_spool:wta_ai_cores
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Final item (if any) - wta_farming_2:item_fullerene_spool:wta_ai_cores
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Giving to player now.
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - -----------------------
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Item to drop -- 0/wta_farming_2
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - -----------------------
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Colony size - 4
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Ruins size - 3
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Progress bar value - 0.7768688
1008785 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Special items so far - 3
1008786 [Thread-3] DEBUG data.scripts.wta_industry.wta_TechMining  - wtaLOG: Enhanced multiplier - 1.470299
1008794 [Thread-7] INFO  sound.public  - Cleaning up music with id [miscallenous_corvus_campaign_music.ogg]
1008828 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.procgen.DropGroupRow.getBaseUnitValue(DropGroupRow.java:190)
at com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageEntity.generateSalvage(SalvageEntity.java:991)
at data.scripts.wta_industry.wta_TechMining.generateCargoForGatheringPoint(wta_TechMining.java:780)
at com.fs.starfarer.api.impl.campaign.CoreScript.doCustomProduction(CoreScript.java:998)
at com.fs.starfarer.api.impl.campaign.CoreScript.reportEconomyMonthEnd(CoreScript.java:1100)
at com.fs.starfarer.campaign.CampaignEngine.reportEconomyMonthEnd(Unknown Source)
at com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper.doEndOfMonthStuff(Unknown Source)
at com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper.nextFrame(Unknown Source)
at com.fs.starfarer.campaign.econ.Economy.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
1009013 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [miscallenous_corvus_campaign_music.ogg]
1009013 [Thread-9] INFO  sound.OooO  - Playing music with id [miscallenous_corvus_campaign_music.ogg]

I'm taking a break, this is doing my head in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 05, 2023, 06:00:35 PM
This:
if (wta_item.substring(0,3) == "wta_")

Is not going to work. == compares references, not string contents. You want:
wta_item.substring(0,3).equals("wta_")

Or, really:
wta_item.startsWith("wta_")

Stepping through the code with a debugger can be really helpful in cases like this. Or just adding more logging statements to make sure it's actually taking the path you think it's taking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 05, 2023, 08:36:29 PM
This:
if (wta_item.substring(0,3) == "wta_")

Is not going to work. == compares references, not string contents. You want:
wta_item.substring(0,3).equals("wta_")

Or, really:
wta_item.startsWith("wta_")

Stepping through the code with a debugger can be really helpful in cases like this. Or just adding more logging statements to make sure it's actually taking the path you think it's taking.

HAHAH! You can tell that I've never programmed Java. It *really* shows.

The "startsWith("wta_")" sorted the issue, many thanks Alex.

Now I need to sort the logic for optional items - too much same-same is happening. Logic bugs.

Looks like this mod is a goer though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 05, 2023, 08:43:25 PM
Is there a good way to (in a ModPlugin, likely #onApplicationLoad) find specifically all blueprint package definitions the game knows of (and their tag for use in #hasTag of FighterWingSpecAPI, etc.)?

Currently I am using a pretty unmaintainable (https://github.com/Zsar/starsector-harsher-equipment-restrictions/commit/2c6b00cb352ce4d11a1847df67cda50a18ee5f93#diff-8ec69cfaa9d95d6861b776c82054455fb41293d2b1b4854cb2a7d4d76cad5638) manual and heuristic approach (aka "the worst way to do it") and I'd like to use a more solid solution.

They are defined in data/config/settings.json field blueprint_packages but SettingsAPI does not seem to have a corresponding getter?

(I am trying to pick all hulls and weapons part of a package and add an individual blueprint to them. Next I'd like to make the packages themselves less likely to be dropped, presumably via their rarity field.)

addendum: Found a way - is that as good as it gets or is there a more elegant one?
Spoiler
Code
private void addIndividualBlueprintsToItems() {
final SettingsAPI settings = Global.getSettings();
final List<String> blueprintTags = this.getAccessibleBlueprintPackageTags(settings);
blueprintTags.add(Tags.WEAPON_REMNANTS);
blueprintTags.add("derelict");

final List<FighterWingSpecAPI> wings = settings.getAllFighterWingSpecs();
for (final FighterWingSpecAPI wing : wings) {
if (this.isBlueprintDroppableAndGroupedAndNotRare(wing, blueprintTags)) {
wing.addTag(Items.TAG_RARE_BP);
}
}
final List<ShipHullSpecAPI> ships = settings.getAllShipHullSpecs();
for (final ShipHullSpecAPI ship : ships) {
if (this.isBlueprintDroppableAndGroupedAndNotRare(ship, blueprintTags)) {
ship.addTag(Items.TAG_RARE_BP);
}
}
final List<WeaponSpecAPI> weapons = settings.getAllWeaponSpecs();
for (final WeaponSpecAPI weapon : weapons) {
if (this.isBlueprintDroppableAndGroupedAndNotRare(weapon, blueprintTags)) {
weapon.addTag(Items.TAG_RARE_BP);
}
}
}

private List<String> getAccessibleBlueprintPackageTags(final SettingsAPI settings) {
// I miss Java 17... -Zsar 2023-02-06
/* return settings.getAllSpecialItemSpecs().stream()
*   .filter(item -> item.hasTag("package_bp"))
*   .filter(item -> !item.hasTag(Tags.NO_DROP))
*   .map(SpecialItemSpecAPI::getParams)
*   .collect(Collectors.toList());
*/
final ArrayList<String> blueprintPackages = new ArrayList<String>();
final List<SpecialItemSpecAPI> specialItems = settings.getAllSpecialItemSpecs();
for (final SpecialItemSpecAPI item : specialItems) {
if (item.hasTag("package_bp") && !item.hasTag(Tags.NO_DROP)) {
blueprintPackages.add(item.getParams());
}
}
return blueprintPackages;
}

private boolean isBlueprintDroppableAndGroupedAndNotRare(final FighterWingSpecAPI wing, final List<String> blueprintTags) {
// I miss Java 17... -Zsar 2023-02-06
/* && blueprintTags.stream().anyMatch(tag -> wing.hasTag(tag)) */
boolean hasAnyBlueprintTag = false;
for (final String tag : blueprintTags) {
hasAnyBlueprintTag = wing.hasTag(tag);
if (hasAnyBlueprintTag)
break;
}
return !wing.hasTag(Tags.NO_DROP) // e.g. Terminator Drone
&& !wing.hasTag(Items.TAG_RARE_BP) // NO_OP
&& hasAnyBlueprintTag
;
}

private boolean isBlueprintDroppableAndGroupedAndNotRare(final ShipHullSpecAPI ship, final List<String> blueprintTags) {
// I miss Java 17... -Zsar 2023-02-06
/* && blueprintTags.stream().anyMatch(tag -> ship.hasTag(tag)) */
boolean hasAnyBlueprintTag = false;
for (final String tag : blueprintTags) {
hasAnyBlueprintTag = ship.hasTag(tag);
if (hasAnyBlueprintTag)
break;
}
return !ship.getHints().contains(ShipTypeHints.STATION) // e.g. Mothership
&& !ship.hasTag(Items.TAG_NO_DEALER) // e.g. Merlon
&& !ship.hasTag(Items.TAG_RARE_BP) // NO_OP
&& hasAnyBlueprintTag;
}

private boolean isBlueprintDroppableAndGroupedAndNotRare(final WeaponSpecAPI weapon, final List<String> blueprintTags) {
// I miss Java 17... -Zsar 2023-02-06
/* && blueprintTags.stream().anyMatch(tag -> weapon.hasTag(tag)) */
boolean hasAnyBlueprintTag = false;
for (final String tag : blueprintTags) {
hasAnyBlueprintTag = weapon.hasTag(tag);
if (hasAnyBlueprintTag)
break;
}
return !weapon.hasTag(Items.TAG_RARE_BP) // NO_OP
&& hasAnyBlueprintTag;
}
[close]

addendum 2: Found the drop chance for blueprints in data/campaign/procgen/drop_groups.csv . There is no good way to access an individual group from within the ModPlugin, is there?

If I change a line in the file, it may be "half as much" today, but after the next patch it might well be anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 05, 2023, 09:10:54 PM
So I'm not sure if this is a bug, but what is the justification for the zero-flux engine boost applying a flat +10 to the turn rate of ships?

I thought it was probably that ships could turn to a higher velocity at 20% of the zero-flux engine boost's speed but applying a small flat boost to the zero-flux boost of top speed (from 50 to 60) seems to be not the case here (did not go from 10 to 12).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 06, 2023, 05:18:21 AM
Is there a good way to (in a ModPlugin, likely #onApplicationLoad) find specifically all blueprint package definitions the game knows of (and their tag for use in #hasTag of FighterWingSpecAPI, etc.)?

 not actually relevant
you can iterate over every specialItemSpecAPI that's currently loaded through Global.getSettings().getAllSpecialItemSpecs(), then check if they have the "package_bp" tag (might not bee completely foolproof, but every vanilla package has it), the code would look something like this
Code
            for (SpecialItemSpecAPI spec : Global.getSettings().getAllSpecialItemSpecs()) {
                if (spec.hasTag("package_bp")) {
                   
                }
            }

alternatively, you could check for the type of plugin that the spec uses like this, though this might also miss some modded edge cases

Code
            for (SpecialItemSpecAPI spec :Global.getSettings().getAllSpecialItemSpecs()) {
                if (spec.getNewPluginInstance(null) instanceof MultiBlueprintItemPlugin) {
                   
                }
            }
(also blueprint packages are specal items & defined in /data/campaign/special_items.csv, settings.json just loads their graphics)
[close]

EDIT : wait I completely misunderstood your post; yeah you've got the right solution there afaik, though doing the instanceof check might be a good second thing to do.

as for actually getting the items to drop, I'd use a showLootListener (tbh this might have been the better option from the start) to intercept any loot before it's show to the player & just replace any bp packs with some loot that you'd manually generated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2023, 10:02:34 AM
addendum: Found a way - is that as good as it gets or is there a more elegant one?

That looks good to me.

addendum 2: Found the drop chance for blueprints in data/campaign/procgen/drop_groups.csv . There is no good way to access an individual group from within the ModPlugin, is there?

If I change a line in the file, it may be "half as much" today, but after the next patch it might well be anything.

I think you may be able to get them using Global.getSettings().getAllSpecs(DropGroupRow.class)

Since the DropGroupRow class is not an interface but the actual class that's stored in the spec store, and is also in the API code.



So I'm not sure if this is a bug, but what is the justification for the zero-flux engine boost applying a flat +10 to the turn rate of ships?

I thought it was probably that ships could turn to a higher velocity at 20% of the zero-flux engine boost's speed but applying a small flat boost to the zero-flux boost of top speed (from 50 to 60) seems to be not the case here (did not go from 10 to 12).

Not a bug; the flat modifier is there to give slow capitals a reasonable turn rate with the boost.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 06, 2023, 10:09:13 AM
What are the conventional ways to detect whether the ShipAPI instance is a child module in refit screen? Of course, both

Code
        if (ship.isStationModule()) return false;
and
Code
        if (ship.getParentStation() != null) return false;
fail to produce expected result.

I resorted to use of awful hacks like
Code
        if (ship.getHullSpec().getCargo() == 0f) return false;
and
Code
        ship.getVariant().getHints().contains(ShipHullSpecAPI.ShipTypeHints.UNBOARDABLE)
to deal with this issue.

From what I've gathered, the circumstance is pretty tricky in terms of vanilla code; I think this problem can be solved with introduction of specific vanilla shiptype hint by Alex himself (e.g. "IS_MODULE") that everyone will be expected to put on their modded child modules in ship_data.csv. How does this sound?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 06, 2023, 10:54:09 AM
as for actually getting the items to drop, I'd use a showLootListener (tbh this might have been the better option from the start) to intercept any loot before it's show to the player & just replace any bp packs with some loot that you'd manually generated.

FWIW: @Alex' suggestion produced a rather elegant solution:
Spoiler
Code
private static final String DROP_GROUP_COMMODITY_TAGS = "tags";
private static final String BLUEPRINT_PACKAGE_TAG = "package_bp"; // FIXME: Should be a non-mod constant! -Zsar 2023-06-06

@Override
public void onApplicationLoad() {
final SettingsAPI settings = Global.getSettings();
this.addIndividualBlueprintsToItems(settings);
this.halveBlueprintPackageDropChance(settings);
}

private void halveBlueprintPackageDropChance(final SettingsAPI settings) {
final Collection<Object> specs = settings.getAllSpecs(DropGroupRow.class);
for (final Object spec : specs) {
final DropGroupRow dropGroupRow = (DropGroupRow) spec;
final String commodity = dropGroupRow.getCommodity();
if (!commodity.startsWith(DropGroupRow.ITEM_PREFIX)) {
continue;
}
try {
final JSONObject json = new JSONObject("{" + commodity + "}");
final JSONObject item = json.getJSONObject(DropGroupRow.ITEM_PREFIX);
final JSONArray tags = item.getJSONArray(DROP_GROUP_COMMODITY_TAGS);
for (int i = 0; i < tags.length(); ++i) {
final String tag = tags.getString(i);
if (BLUEPRINT_PACKAGE_TAG.equals(tag)) {
dropGroupRow.setFreq(dropGroupRow.getFreq() / 2.f);
break;
}
}
}
catch (final JSONException wrongCommodity) {
continue;
}
}
}
[close]
I think this is a much better idea, because it does - exactly, not more than - The Right Thing(TM), irrespective of mod order and main game version changes (outside of API breaking ones, but that is of course fine).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on February 06, 2023, 09:14:13 PM
Is there a way to point to a Constellation in a bar event?


Intel has
public SectorEntityToken getMapLocation(SectorMapAPI map)
and you can use the map like so:  map.getConstellationLabelEntity(constellation)
to give you a SectorEntityToken.

Dialogs, however, have this:
dialog.getVisualPanel().showMapMarker(sectorEntityToken, etc);


Is there a way to create a S.E.T. for the constellation within BaseBarEvent?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on February 06, 2023, 10:58:56 PM
Interesting, is possible to modify size of NPC ships? Lets say I want to return back crazy pirate armadas as they was in 091 and older versions of the game? And if not possible, I'd like to have ability to configure this in 096.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on February 07, 2023, 04:58:06 AM
I'm looking to make a hullmod that removes the negative aspects of the Converted Hanger and Converted Cargo Bay. The slight snag I've run into is the speed reduction and damage taken, both hullmods pull the effect from the Defective Manufactory  D-Mod.

Code
public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
new DefectiveManufactory().applyEffectsToFighterSpawnedByShip(fighter, ship, id);
}

Is there a way to unmodify/undo the above code? I've thought of a couple of workarounds, but they both have their own disadvantages.

1: Make my Hullmod apply counter stats a Multiplier of 1.33333 for speed and -25 Percent for the damage taken, this should be fairly simple to implement, but I fear would have weird interactions with any other hullmods that change the severity of D-Mods. Which this technically counts as I believe.

2: Rewrite alternative versions of the 2 hullmods to not reference Defective Manufactory and just have the stat changes contained within. This is a bit more work and probably overall neater than my first option, but has the potential to run afoul of any other mods that modify those two hullmods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 07, 2023, 09:32:29 AM
Is there a way to determine if the Ruins condition is from the Collapse or because someone Saturation-Bombed a colony into oblivion? (Or even abandoned a colony, leaving the ruins of their own.)

In these situations it seems to me that:

* Special items will never be found
* food, domestic, and luxury items will be findable for a time (not degraded)

Essentially I don’t want players abusing the Techmining mechanic by Sat-Bombing a target and colonizing to get special items. Or colonizing a planet that an opponent has Sat-Bombed to oblivion. Or colonizing, abandoning, colonizing again to Techmine their own ruins (assuming that abandoning a colony leaves ruins - it feels like it should).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 07, 2023, 10:02:18 PM
Is there some non-obvious background drop for special items when Techmining? I just had 2x Soil Nanites (expected) and 1x Plasma Dynamo (not expected) drop during testing. (Mining 2 planets at once.)

-edit-

Think I figured it - its the %u201Citem_:%u2026%u201D drop group. The chance is just really, really low for special items.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 07, 2023, 11:20:28 PM
Is it possible to create a planetary condition that gives a hazard rating bonus for a certain faction and haz rating penalty to any other faction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 08, 2023, 09:00:18 AM
How do one use LabelAPI.computeTextHeight(string)? Is it what the height would be had the text been vertically rendered? For a 65 tall PositionAPI, the call returned me 998 when I passed same string as I did to original addPara().

I want to ask the same question. No matter how long is the input string, the return is always 15. Doesn't look like the method's any good at all. Is there any other way I can get Y-axis offset for real text height so that I do not get a clipping once the dynamic string grows beyond initial size?

Looking at Stellar Networks source, seems like Jaghaimo did gave up on this too - no usages of this method in code.

Edit: turns out I needed to call getPosition().getHeight(), which indeed returns correct height of the label instance - problem solved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 08, 2023, 03:46:44 PM
Is there a way to point to a Constellation in a bar event?

Intel has
public SectorEntityToken getMapLocation(SectorMapAPI map)
and you can use the map like so:  map.getConstellationLabelEntity(constellation)
to give you a SectorEntityToken.

Dialogs, however, have this:
dialog.getVisualPanel().showMapMarker(sectorEntityToken, etc);

Is there a way to create a S.E.T. for the constellation within BaseBarEvent?

Those entities are temporary ones created when the map is opened. I'm not sure pointing to that specific entity matters - you could create a custom entity and set its location to the location of the constellation and that should do the trick.


Interesting, is possible to modify size of NPC ships? Lets say I want to return back crazy pirate armadas as they was in 091 and older versions of the game? And if not possible, I'd like to have ability to configure this in 096.

"maxShipsInAIFleet" in settings.json, though you might need to change other stuff (in code) to make them actually larger. Fleet spawning is generally specific to whatever that specific fleet is for so there's no one-size-fits-all solution aside from, say, reducing fleet points across the board or some such.


1: Make my Hullmod apply counter stats a Multiplier of 1.33333 for speed and -25 Percent for the damage taken, this should be fairly simple to implement, but I fear would have weird interactions with any other hullmods that change the severity of D-Mods. Which this technically counts as I believe.

You could do this and also factor in ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT); which is how the impact of d-mods is modified.

2: Rewrite alternative versions of the 2 hullmods to not reference Defective Manufactory and just have the stat changes contained within. This is a bit more work and probably overall neater than my first option, but has the potential to run afoul of any other mods that modify those two hullmods.

Or this, yeah. You've covered the two ways that come to mind of doing this.


Is there a way to determine if the Ruins condition is from the Collapse or because someone Saturation-Bombed a colony into oblivion? (Or even abandoned a colony, leaving the ruins of their own.)

The market memory will have $wasCivilized in it for sat-bombed ruins.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 09, 2023, 03:43:59 AM
So I am adding an intel to intel manager. This intel has several objects stored in its fields, including an ArrayList of objects and one big child object (custom panel assembler) Saving the game - it loads, but only if I didn't manipulate field objects in any way - if there's something stored in ArrayList, the game silently closes on load without any exception thrown.

What do I do? Tried to unload the intel into persistent data while the game saves, tried to remove the intel before the save and add brand new one after save and on game load - doesn't do the trick. I'm not particular about saving the data in intel object now, I just want the game to work with my intel without throwing a white flag.

Last lines in log:

Code
201875 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 38
201875 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading stage 39 - last

Edit: resolved by manually clearing all data before intel removal.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 09, 2023, 04:33:37 AM
Would someone please explain to me how drop groups etc work - because I appear to be doing something very, very wrong with mine. :(

Referencing the attached image. By the presence of Ore I know that this particular "First Find" has included the following drop group:
Code
heavy_machinery,wta_ruins_mining1,10
metals,wta_ruins_mining1,40
ore,wta_ruins_mining1,30
supplies,wta_ruins_mining1,20

According to the Wiki: "An example of "dropValue" might be "drop 10,000 credits worth of fuel, supplies, metals, and heavy machinery". The actual value will be within 50% of the target amount." In the following code:
Code
    // does it have at least moderate stuff to mine?
    if (getOre() > 1) {
      d = new DropData();
      d.chances = colonySize;
      d.group = "wta_ruins_mining1";
      d.value = 2000 * ruinsSize;
      d.valueMult = multEnhanced;
      dropValue.add(d);
    }

colonySize = 3 (just founded)
ruinsSize = 1 (scattered ruins)
multEnhanced = 1.25 (first drop + Alpha AI Core)

The above code has:

* Chosen the Ore (30% chance) as one of the choices
* 2000cr * 1 (ruinsSize) = 2000cr --- I will assume the worst case, under that by 50%, or only 1000cr of Ore
* 1000cr * 1.25 = 1250cr worth of ore
* 1250cr / 10 cr (Ore cost) = 125 ore

So the 10 Ore in my screenshot is approximately 8% of the Ore which I was expecting to have been returned as a minimum.

It gets worse, there are 2x more drop groups which would have been added (metals, supplies, heavy machinery, fuel). One of those should have had 3 choices at 3000cr value, and the second should have had 9 more choices at 3000cr. The returned 4x fuel (ie 1000 / 25 = 40) are nowhere near what I'm thinking should have been returned.

Please help me figure out what it is that I've messed up so badly.

--edit--

Okay, figured it out. I'm a damn idiot.

The value is the total pie, divided by the number of choices. Each choice then becomes (totalvalue / choices) amount of X chosen item from the drop group.

So to have it work like I was thinking, I will need to multiply the pie-size by the number of choices first. In this case, the colony size.

--edit-edit--

Or if I want to be more "realistic", it could be: 3000 * ruinsSize * ruinsSize * colonySize

Though it might be somewhat overboard for Vast Ruins on a size 6 Colony.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 09, 2023, 05:08:31 AM
Have you stepped through your code in a debugger and confirmed your values? Sometimes I have been sure that X must be Y, but it's really Z.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on February 09, 2023, 08:13:14 AM
Hi all, having an issue with Hiver Swarm and figured I'd ask here. I have numerous requests to have their commodities not show up on the Stellar Networks Mod tabs. I have tried reaching out there but it looks like Jaghaimo has not replied to his mod questions since 09/22. I was wondering if there was a way to have their commodities not report to the com relay? Either that or if someone knows how to implement the blacklist feature of that mod, I have tried several methods with no success, please teach me. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 09, 2023, 09:01:47 AM
Have you stepped through your code in a debugger and confirmed your values? Sometimes I have been sure that X must be Y, but it's really Z.

Thanks, yah they are correct - I wrote them to the log to double-check the values are right.

I will look again in a bit, maybe something will jump out at me.

--edit--

ID10T Error, PEBKAC.

Figured the issue, I will update the original post with the answer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 09, 2023, 09:23:57 AM
I have tried reaching out there but it looks like Jaghaimo has not replied to his mod questions since 09/22.

Looks like Jaghaimo was last active on the 1st according to his profile. He will probably be on again soon. Try PMing him - that is more likely to catch his attention.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2023, 10:10:10 AM
So I am adding an intel to intel manager. This intel has several objects stored in its fields, including an ArrayList of objects and one big child object (custom panel assembler) Saving the game - it loads, but only if I didn't manipulate field objects in any way - if there's something stored in ArrayList, the game silently closes on load without any exception thrown.

Potential red flag here is storying any UI stuff in the savefile. You generally don't want to do that - at best it's unnecessary save bloat, and at worst you'd end up with the entire game's UI getting serialized in the savefile, most likely bricking it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on February 09, 2023, 10:11:44 AM
Is there a way to determine if the Ruins condition is from the Collapse or because someone Saturation-Bombed a colony into oblivion? (Or even abandoned a colony, leaving the ruins of their own.)

The market memory will have $wasCivilized in it for sat-bombed ruins.

Thanks Alex. I searched for $wasCivilized and have come up with the following: if (market.getMemoryWithoutUpdate().getBoolean("$wasCivilized"))

It returns false for non-sat-bombed stuff, I'll do a full test over the weekend.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 09, 2023, 10:50:05 AM
Potential red flag here is storying any UI stuff in the savefile. You generally don't want to do that - at best it's unnecessary save bloat, and at worst you'd end up with the entire game's UI getting serialized in the savefile, most likely bricking it.

Good to know, thanks! Just to make sure I understood correctly: I want UI objects to be created on-the-spot in each game session, and prevent UI objects (which are stored in the intel instance for the interaction purposes, for example, button checking which, seemingly, has to be done through the intel method) from entering the save alongside intel instance at all, is that right?

This is how my modplugin looks:

Spoiler
Code
    override fun onGameLoad(newGame: Boolean) {
        super.onGameLoad(newGame)
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }

    override fun beforeGameSave() {
        super.beforeGameSave()
        val intel: EntryWriter = Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) as EntryWriter
        intel.clearIntelData()
        Global.getSector().intelManager.removeIntel(intel)
    }

    override fun afterGameSave() {
        super.afterGameSave()
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }
[close]

So theoretically, intel instance is not going to be in the save at all now. Am I safe?

Edit: while we're at it, should I also avoid putting a HashMap with keys of FleetMemberAPIs (or, more generally, any references to FleetMemberAPIs) in persistent data? If yes, should I use their UUIDs instead and retrieve instances by IDs after load?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 09, 2023, 11:31:06 AM
Good to know, thanks! Just to make sure I understood correctly: I want UI objects to be created on-the-spot in each game session, and prevent UI objects (which are stored in the intel instance for the interaction purposes, for example, button checking which, seemingly, has to be done through the intel method) from entering the save alongside intel instance at all, is that right?

This is how my modplugin looks:

Spoiler
Code
    override fun onGameLoad(newGame: Boolean) {
        super.onGameLoad(newGame)
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }

    override fun beforeGameSave() {
        super.beforeGameSave()
        val intel: EntryWriter = Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) as EntryWriter
        intel.clearIntelData()
        Global.getSector().intelManager.removeIntel(intel)
    }

    override fun afterGameSave() {
        super.afterGameSave()
        if (Global.getSector().intelManager.getFirstIntel(EntryWriter::class.java) == null) {
            Global.getSector().intelManager.addIntel(EntryWriter())
        }
    }
[close]

So theoretically, intel instance is not going to be in the save at all now. Am I safe?

Theoretically! I think you'd have an easier time using the "transient" keyword on the data members for whatever data you're clearing, since that'll basically do the same thing - transient variables don't go in the savefile.

Edit: while we're at it, should I also avoid putting a HashMap with keys of FleetMemberAPIs (or, more generally, any references to FleetMemberAPIs) in persistent data? If yes, should I use their UUIDs instead and retrieve instances by IDs after load?

That should be fine, though I'm not sure what's behind the question.

(With storing fleet members long term, the tricky part can be being able to tell if they're still around anywhere - storage, fleets, referred to by some other script. So it just depends on what you're doing. I've been using WeakReference to get around those types of problems in vanilla, but I don't know if that's applicable to what you're doing or not.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 09, 2023, 10:07:58 PM
Theoretically! I think you'd have an easier time using the "transient" keyword on the data members for whatever data you're clearing, since that'll basically do the same thing - transient variables don't go in the savefile.

That is precisely the thing I didn't knew I needed! Rewrote with transient, and now all the important data is preserved and I don't need any clunky modplugin methods (and those revolting nullability shenanigans), and everything is much better! Thank you good sir.

That should be fine, though I'm not sure what's behind the question.
(With storing fleet members long term, the tricky part can be being able to tell if they're still around anywhere - storage, fleets, referred to by some other script. So it just depends on what you're doing. I've been using WeakReference to get around those types of problems in vanilla, but I don't know if that's applicable to what you're doing or not.)

What I have are companion objects for each fleetmember in player fleet with a certain hullmod, said objects describing stats and state of their modded features - they have a property field with parent FleetMember. Have assignment and cleanup methods in place that are called fairly frequently, so I'm sure all the references to fleetmembers no longer in fleet are promptly removed.

Since you say it's fine in general and I don't store members that shouldn't be around (and I didn't notice any problems during playtesting), it should be fine. Thanks again!

Edit: have another question - is it possible to emulate behaviour of refit screen's ship name text field in circumstances of large intel description? In other words, I want to save string of textfield each time it is modified - could use a normal "Save" button right next to it, but that's not ideal for my taste.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BreenBB on February 10, 2023, 12:44:42 AM
Interesting it is possible to modify UI for skill selection screen? Both for Player and Officer, and if not, can I suggest it for new version? I'd like to have wider choice of skills for officer, so it less a random gamble, and to have option to make skills like they was in 091 or 06 versions of the game when they had multiple levels, 3 or 10 instead of just base skill and upgrading it to elite one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NuclearStudent on February 11, 2023, 12:21:40 PM
Is there a way to override the Codex and F1 displays of ship stats to show an arbitrary string?

Specifically, I want to display a range of possible ship stats, and have some code that randomly sets values for each individual ship instance.

My fallback plan for handling my problem is to have all stats set to 10, but have the real stats instanced as soon as the battle begins. Mostly just a "looking nice" thing that I'd prefer not to.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2023, 03:52:37 PM
Since you say it's fine in general and I don't store members that shouldn't be around (and I didn't notice any problems during playtesting), it should be fine. Thanks again!

Yeah, this sounds fine!

Edit: have another question - is it possible to emulate behaviour of refit screen's ship name text field in circumstances of large intel description? In other words, I want to save string of textfield each time it is modified - could use a normal "Save" button right next to it, but that's not ideal for my taste.

Hmm - you might be able to query its contents every frame in a plugin that runs when the game is paused. And that you add when the player is viewing the intel and remove when they're not.


Interesting it is possible to modify UI for skill selection screen? Both for Player and Officer, and if not, can I suggest it for new version? I'd like to have wider choice of skills for officer, so it less a random gamble, and to have option to make skills like they was in 091 or 06 versions of the game when they had multiple levels, 3 or 10 instead of just base skill and upgrading it to elite one.

I don't believe it supports multiple skill levels beyond making skills elite (which, under the hood, are "level 2" skills). You could give officers more skill choices by implementing your own version of OfficerLevelupPlugin, though.


Is there a way to override the Codex and F1 displays of ship stats to show an arbitrary string?

Specifically, I want to display a range of possible ship stats, and have some code that randomly sets values for each individual ship instance.

My fallback plan for handling my problem is to have all stats set to 10, but have the real stats instanced as soon as the battle begins. Mostly just a "looking nice" thing that I'd prefer not to.

I don't think there is, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 12, 2023, 01:25:20 AM
Hmm - you might be able to query its contents every frame in a plugin that runs when the game is paused. And that you add when the player is viewing the intel and remove when they're not.

Could you clarify which methods or listeners can be used to tell if certain intel item is currently being viewed, and possibly to report event of opening and closing description panel? There's
Code
reportPlayerClickedOn()
and
Code
notifyPlayerAboutToOpenIntelScreen()
, but I'm not sure if this is what I'm looking for.

Tried also to put relevant code into own
Code
advance()
of intel item (as it itself implements EveryFrameScript), but the method just doesn't get called even with
Code
runWhilePaused()
set to return true.

Edit: also facing that same challenge with "Show on map" functionality that Jaghaimo had:

Also, is it possible to tap into "Show on map" button (or recreate its functionality)? I'd like to add a custom button with a different SectorEntityToken to intel's one.
It's not currently possible, no. Best you could do is swap out what the getMapLocation() method on the intel returns...
That would be enough if there was a way to trigger the button click without actually clicking it... Oh. Oooooh. Swap token with desired one, use AWT keyboard to send S, swap back. Custom show location buttons here I come!

In the case of large, custom-panel-powered description this solution doesn't work out of the box, since the vanilla showOnMap button shouldn't be seen by player (looks ugly with its unmodifiable position), and therefore must be immediately cleaned-up by resetting returns of getMapLocation() back to null. The problem is, if I make the reset right from the execution of buttonPressConfirmed(), the map doesn't show up at all.

Perhaps this can be worked around by placing the reset code in advance() method and call that after map has been shown - if only I could capture that event, and if I could either get own intel's advance() working or have starting and closing conditions to satellite advance(). But, nonetheless: I think this calls for a proper showTokenOnMap() method in IntelInfoPlugin.

Edit 2: Figured out that for advance() to work intel should be added to sector as script; but that didn't help me to solve either problem. In advance(), getMapLocation() returns are reset back to null, map's showing fine, but pesky button still persists even after calling                 
Code
bufferedUI.updateUIForItem(this)
In any case, such a workaround is not satisfactory for me, since the button is visible for a few frames before map is actually opened. It's no biggie, my mod will have to do without such a feature, but these API constraints sure do not spark joy.

Edit 3: while working with campaign entities, noticed an OCD-unfriendly typo in Valhalla System - Valkyrie has a space before its name:

Code
			// Valkyrie jump
JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("valkyrie_jump", " Valkyrie Jump-point");

Edit 4: I want to emulate behaviour of skill buttons in Character tab. Speaking more broadly, I want buttons with arbitrary images/textures on them. And I want them in tooltip instances and large intel descriptions, not just in custom panels with work-from-scratch GL11. Is this realistic at all or am I out of luck?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 12, 2023, 01:42:05 PM
is it intentional that there's one(?) frame at the end of a system's activation where unapply() hasn't yet been called but isOn() returns false?
I've been having some behaviour w/ a system script that hopefully could only be explained by that, though I can't really think of a way to conclusively prove it.
another candidate might be some wierd interaction between the order that advanceableListeners & system scripts are run in?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 13, 2023, 01:15:49 AM
double post, to remove
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 13, 2023, 05:26:09 PM
Hi Alex, I am adding

Code
public static Map<String, Float> CSVReading = new HashMap<>();
in the ModPlugin where it reads some of the .csv that I cannot access from the API regularly.

My question is whether a hullmod importing this CSVReading in the ModPlugin might keep it around and not get garbage collected.

Code
import static data.hullmods.ModPlugin.CSVReading;

CSVReading.get(string);
in that type of manner.


--------
On a different note, I would like an explanation of how economyTier works because the various examples seem confusing to do and fiddling with the values doesn't seem to reproduce any meaningful differentiation on what the column does.

I'm also trying to accomplish where a modded commodity is able to satisfy a vanilla commodity's need. Like selling custom red metal into feeding metal's demands.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on February 15, 2023, 12:00:41 AM
Got a few questions.
Does
Code
weapon.getSpec().getMaxRange();
get the maximum range of a weapon as dictated by the weapon.csv? or does it get the current maximum range? (In the case something else has modified it)

While testing a few beam weapons (including clones) I noticed that vanilla beam weapons produce an ambient glow around the firing ship and near the target, if you clone the weapon it does not get this glow, the mod Lightshow can make this happen, but where does it happen in normal settings? It does not seem to be in the weapon.csv or individual weapon files.

On a similar note some of the vanilla beam weapons like the graviton beam have a differently proportioned core size than a clone of it with the same setting, how can you alter this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 15, 2023, 03:00:10 AM
Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 15, 2023, 03:04:10 AM
Code
public static Map<String, Float> CSVReading = new HashMap<>();
[...]

My question is whether a hullmod importing this CSVReading in the ModPlugin might keep it around and not get garbage collected.
Dunno if the game does anything funny with ClassLoaders, but generally, if data is declared "static", it will stick around until the application terminates. More to the point, the only way to get rid of it is to garbage collect the ClassLoader that loaded the class it's defined in.
(... Might have changed in more recent Java versions, I am not quite up to date, but should definitely still be the case in 7 and 8.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on February 15, 2023, 04:20:47 AM
Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)

You can edit the submarket's contents with (I think) an EconomyUpdateListener, or you can replace the submarket's plugin, or you can use a custom black market submarket for your markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on February 15, 2023, 11:10:01 AM
Got a few questions.
Does
Code
weapon.getSpec().getMaxRange();
get the maximum range of a weapon as dictated by the weapon.csv? or does it get the current maximum range? (In the case something else has modified it)

...
Yes, the former.
it get the current maximum range? (In the case something else has modified it)
WeaponAPI.getRange() will return from this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 17, 2023, 11:12:24 AM
(Sorry about the delayed responses! I... kind of just forgot to check this.)


In the case of large, custom-panel-powered description this solution doesn't work out of the box, since the vanilla showOnMap button shouldn't be seen by player (looks ugly with its unmodifiable position), and therefore must be immediately cleaned-up by resetting returns of getMapLocation() back to null. The problem is, if I make the reset right from the execution of buttonPressConfirmed(), the map doesn't show up at all.

Could you clarify what extactly you're trying to do? I get a vague idea from what you wrote, but it's mostly about the problems you're having and not what you're trying to *do* so it's harder to interpret. E.G. I don't understand why "the map doesn't show up at all" is a problem since it sounds like that's what you want?

(That said, chances are it's probably not doable within the current API...)


Edit 3: while working with campaign entities, noticed an OCD-unfriendly typo in Valhalla System - Valkyrie has a space before its name:

Fixed, ty!

Edit 4: I want to emulate behaviour of skill buttons in Character tab. Speaking more broadly, I want buttons with arbitrary images/textures on them. And I want them in tooltip instances and large intel descriptions, not just in custom panels with work-from-scratch GL11. Is this realistic at all or am I out of luck?

I don't think - at least, no that I recall - that there are any methods in the API to create similar buttons. (You *could* implement your own, processing clicks etc in a custom UI element, though that's obviously a bunch of work and not something I'd really suggest.)

is it intentional that there's one(?) frame at the end of a system's activation where unapply() hasn't yet been called but isOn() returns false?
I've been having some behaviour w/ a system script that hopefully could only be explained by that, though I can't really think of a way to conclusively prove it.
another candidate might be some wierd interaction between the order that advanceableListeners & system scripts are run in?

Does the system have 0 "down" duration? Looking at the code, I think this may happen then, yeah - there'll be one frame where the effect level is 1, the state is it charging down, and unapply() will not have been called yet. I wouldn't call this intentional but it's not something I want to touch at this point - it could break something very subtle.



Hi Alex, I am adding

Code
public static Map<String, Float> CSVReading = new HashMap<>();
in the ModPlugin where it reads some of the .csv that I cannot access from the API regularly.

My question is whether a hullmod importing this CSVReading in the ModPlugin might keep it around and not get garbage collected.

Code
import static data.hullmods.ModPlugin.CSVReading;

CSVReading.get(string);
in that type of manner.

This is not a problem for several reasons.
1) The data is already referenced from a static variable so it won't be garbage collected regardless; its expected lifetime is the entire application session (unless you null out that pointer)
2) Hull mod scripts are singletons
3) You're not storing a reference to this data in those, anyway


--------
On a different note, I would like an explanation of how economyTier works because the various examples seem confusing to do and fiddling with the values doesn't seem to reproduce any meaningful differentiation on what the column does.

I'm also trying to accomplish where a modded commodity is able to satisfy a vanilla commodity's need. Like selling custom red metal into feeding metal's demands.

It affects the order in which the commodity demand calculation is run. If it's "wrong" it should still work out, just may take a few more iterations for the economy engine. Generally the lower on the chain the commodity the lower this value should be. E.G. ore -> metals -> heavy machinery, etc.


While testing a few beam weapons (including clones) I noticed that vanilla beam weapons produce an ambient glow around the firing ship and near the target, if you clone the weapon it does not get this glow, the mod Lightshow can make this happen, but where does it happen in normal settings? It does not seem to be in the weapon.csv or individual weapon files.

This sounds like a mod feature!

On a similar note some of the vanilla beam weapons like the graviton beam have a differently proportioned core size than a clone of it with the same setting, how can you alter this?

IIRC there's nothing special here, so copy-pasting the gravitonbeam weapon file with a different weapon ID should produce the same result. But if you want a differently proportioned core, you can provide a different beam texture. See hil.wpn for an example for how to provide a custom texture.


Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)

You can specify the plugin in data/campaign/submarkets.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 17, 2023, 09:57:07 PM
Could you clarify what extactly you're trying to do? I get a vague idea from what you wrote, but it's mostly about the problems you're having and not what you're trying to *do* so it's harder to interpret. E.G. I don't understand why "the map doesn't show up at all" is a problem since it sounds like that's what you want?

What I want to have is functionality of vanilla hardcoded "Show on map" button. And I want to have this functionality tied to an arbitrary button I can place anywhere in panel I want. See attached for the visual on what happens if I enable vanilla button.

(That said, chances are it's probably not doable within the current API...)

I'm pretty sure that's the case, yeah!

I don't think - at least, no that I recall - that there are any methods in the API to create similar buttons. (You *could* implement your own, processing clicks etc in a custom UI element, though that's obviously a bunch of work and not something I'd really suggest.)

Right, that's understandable. Given that the answer "this is not doable within the current API" is a fairly frequent outcome of my questions, I'd like to ask a bit more general question. Example would be best here. ButtonAPI has one implementor class which is "public class OoO0 extends Q implements oo, ButtonAPI, com.fs.starfarer.ui.e.oo" in my obfuscation variant. Among methods that do not exist in ButtonAPI implementing class has:


In recent patchnotes, you added

My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API? ButtonAPI's being just an example, there are plenty of cases like this - had a comment on getTurretGunSpriteName(), where the method was right there in the class but it required indirect reflection to get to use it - said method being added by you in upcoming patch too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 18, 2023, 03:14:04 AM
My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API?
They might not work as expected. Many fields are read at one time into e.g. ScriptStore. If their setters were exposed, you could set there - to no effect. If their getters were exposed you might get the idea to change the value by reflection - to no effect. This would make the - largely undocumented - API much harder to use by adding "Red Herrings".

See e.g. L implements SubmarketSpecAPI : It has a getter #getScriptClass . But at game start, SpecStore passes the current data into ScriptStore. After this point, if we changed the script class of a Submarket, this would not have an effect, so it's better to hide the method than to expose it without comment.

Notes:
Looking at the first method you listed, OoO0#setSkipPlayingPressedSoundOnce , I cannot find any caller for the respective getter #isSkipPlayingPressedSoundOnce (discounting that IDEA is notoriously unreliable with finding those in libraries). So, if you could call this setter - what good would it do? It would be but clutter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 18, 2023, 03:26:14 AM
My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API?
They might not work as expected. Many fields are read at one time into e.g. ScriptStore. If their setters were exposed, you could set there - to no effect. If their getters were exposed you might get the idea to change the value by reflection - to no effect. This would make the - largely undocumented - API much harder to use by adding "Red Herrings".

See e.g. L implements SubmarketSpecAPI : It has a getter #getScriptClass . But at game start, SpecStore passes the current data into ScriptStore. After this point, if we changed the script class of a Submarket, this would not have an effect, so it's better to hide the method than to expose it without comment.

Notes:
  • SpecStore throws a RuntimeException, if you try to replace existing entries, so the method is quite literally useless after the first time it's been called.
  • Even better, of course, would be to write proper JavaDoc onto it, because we might still sensibly use the getter for informational purposes, e.g. while debugging.

Looking at the first method you listed, OoO0#setSkipPlayingPressedSoundOnce , I cannot find any caller for the respective getter #isSkipPlayingPressedSoundOnce (discounting that IDEA is notoriously unreliable with finding those in libraries). So, if you could call this setter - what good would it do? It would be but clutter.

I think you might be misunderstanding what my point essentially is. Let me put it this way:

There are tools and functionality that are present and usable through reflection in the original (obfuscated) code, which are not exposed in the API. Why they are not exposed?

There might be specific cases that have tricky ways about their workings and effects, yes. I'm not particular about those - it's understandable that some parts of code are intertwined to such a degree that exposure could take too much work or could have undesirable side effects and consequenses. Those are not what my question is about. At the same time, there are cases where there is nothing tricky about methods which one might want to use, except the fact that they are in the obfuscated code.

Looking at the first method you listed, OoO0#setSkipPlayingPressedSoundOnce , I cannot find any caller for the respective getter #isSkipPlayingPressedSoundOnce (discounting that IDEA is notoriously unreliable with finding those in libraries). So, if you could call this setter - what good would it do? It would be but clutter.

I don't think this fact has any significance at all. My IntelliJ cannot find any usages of any method in the class we are talking about - doesn't mean it doesn't get called. Not to mention that the very notion of "clutter" when it comes to modding API of Starsector sounds absolutely nonsensical to me. There was a time when I, being a novice modder, thought that half of PositionAPI is clutter. Now I think there are no useless methods in the API whatsoever - it's just you didn't found use for them yet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 18, 2023, 03:36:08 AM
Ah, fair! Well... I'd presume that those just fell under the bus and their exposure may be requested in the API request thread (https://fractalsoftworks.com/forum/index.php?topic=4900.0)? At the end of the day, the decision what to include and what to exclude in an interface is a manual one and mistakes will happen.

Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)

You can edit the submarket's contents with (I think) an EconomyUpdateListener, or you can replace the submarket's plugin, or you can use a custom black market submarket for your markets.
You can specify the plugin in data/campaign/submarkets.csv.
Sorry I have to bring this up again, cannot get it to work.

So, I have written a replacement for BlackMarketPlugin that extends it and overrides only #updateCargoPrePlayerInteraction .
I tried the following to get it into the game:

- replace the SubmarketSpecAPI with one containing my plugin instead of the original
Does not work, original has already been read into SpecStore and ScriptStore and they do not allow replacement.

- add a submarkets.csv like this:
Code
id,name,faction,desc,script,icon,order
black_market,,,,data.scripts.zsar.harsherequipmentrestrictions.HarsherBlackMarketPlugin,,
Does not work - csv rows are replaced, not merged. Because specs are registered before the ModPlugin can do anything, I cannot manually add merging code either. (Or can I?)

- make the fully qualified class name identical to that of the original, hoping for this part of the documentation:
Quote
Replace
The following file types are always replaced:
[...]
  • Scripts (.java)
Does not work, I cannot extend the original that way. (Or can I?)

So... yes, well. How do I make black markets use my replacement plugin?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on February 18, 2023, 05:06:28 AM
Yes, the former.
Thanks for the reply, still a bit hazy on what does what specifically.
This sounds like a mod feature!
I did a lot of digging around turns out it's Graphics Lib that adds those glows, I've had it installed for so long I thought it was a vanilla feature.
IIRC there's nothing special here, so copy-pasting the gravitonbeam weapon file with a different weapon ID should produce the same result. But if you want a differently proportioned core, you can provide a different beam texture. See hil.wpn for an example for how to provide a custom texture.
Turns out this was an unintended side effect of having the wrong parts of a duplicated weapon file left in place from another mod. Thanks for the heads up that these weren't normal effects
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 18, 2023, 08:44:09 AM
what layer does a BaseEveryFrameCombatPlugin's renderInUICoords() method render on?
or is it all of them? having some wierdness with colours that could be explained by this; the alpha of anything I render seems to be set to full

edit : did a test w/ a sprite & it seems like the alpha is just getting thrown away, is there any way for me to fix this on my end? attached a screenshot below.
 large image
(https://cdn.discordapp.com/attachments/824910699415207937/1076837559109435514/screenshot1672.png)
[close]

Does the system have 0 "down" duration? Looking at the code, I think this may happen then, yeah - there'll be one frame where the effect level is 1, the state is it charging down, and unapply() will not have been called yet. I wouldn't call this intentional but it's not something I want to touch at this point - it could break something very subtle.

and ty for the explanation! iirc (I changed it after asking the question heh) it had a down of one, though I managed to fix it by just having unapply() set a bool that my script checked for.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on February 18, 2023, 12:42:01 PM
hello once more all, i have yet one more random question
does anyone know how to create a pop-up notification like the one that tech mining gives at the end of each month?
thanks again for all the responses to my random questions in the past
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 18, 2023, 08:42:04 PM
hello once more all, i have yet one more random question
does anyone know how to create a pop-up notification like the one that tech mining gives at the end of each month?
thanks again for all the responses to my random questions in the past

Either create your intel instance and add that to manager, or just use    void addMessage(IntelInfoPlugin intel, MessageClickAction action); from CampaignUIAPI

Code
			ProductionReportIntel intel = new ProductionReportIntel(gatheringPoint, data, 
totalCost + weaponCost, prod.getAccruedProduction(),
wantedToDoProduction && unableToDoProduction);
Global.getSector().getIntelManager().addIntel(intel);
Code
    private static void addReportMessage() {
        ForgeProductionReport intel = new ForgeProductionReport();
        Global.getSector().getCampaignUI().addMessage(intel);
    }

There's also methods that take Strings instead of intel instances as an argument, in case you don't want anything fancy: addMessage(String text)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 20, 2023, 12:21:44 AM
issue resolved
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on February 20, 2023, 12:53:13 AM
What is the correct usage of CombatEngineAPI.spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, String projSpecId, Vector2f point, float angle, Vector2f shipVelocity);?

Every time I have tried to use it, it crashes with a nullpointerexception in the constructor of either MovingRay or BallisticProjectile. For example calling this method with non-null variables, and with the strings "lightdualac" and "lightdualac_shot" will cause a crash. This makes it impossible to spawn projectiles that are indirectly spawned via MIRV missiles, e.g. the "sabot_warhead2" projectile. Can this be clarified please?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NinjaSiren on February 20, 2023, 01:32:01 AM
how do you get if a planetary market has a com relay, via code?

Is it like this? sector.getEntityById(Entities.COMM_RELAY) / sector.getEntityById(Entities.COMM_RELAY_MAKESHIFT)

I am unsure
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 20, 2023, 04:59:16 AM
I need to get tags of specific IntelInfoPlugins. How do I get a hold of SectorMapAPI instance in order to call Set<String> getIntelTags(SectorMapAPI map)? Searched through, all the usages are only extensions of caller methods, nothing returns SectorMapAPI.

Edit: I'm pretty sure I can't get that instance and by extension can't get tags, because what most likely happens is that map instance is generated only in obfuscated code and stays there. If this is correct I'd like to request respective API additions.

Edit 2: How "void setHidden(boolean hidden)" in IntelInfoPlugin is supposed to work? I have my intels, I set the boolean to true, debugger shows the field is indeed true - but the...

Oh God... In the process of writing this I looked into the BaseIntelPlugin and realized that what I thought to be a completely legit mechanism of making the intel visible/hidden (as implied by the javadoc comment) is actually not a functioning feature at all. I guess I can't set intel items to be hidden/shown after all:

Code
	public boolean isHidden() {
// never mind; handled by making comm relay in Galatia non-functional until the jump-point is stabilized
// but procurement missions etc generated inside Galatia still show up, so: need to do this
return TutorialMissionIntel.isTutorialInProgress(); 
//return hidden != null;
}

public void setHidden(boolean hidden) {
if (hidden) {
this.hidden = hidden;
} else {
this.hidden = null;
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 20, 2023, 02:48:46 PM
My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API? ButtonAPI's being just an example, there are plenty of cases like this - had a comment on getTurretGunSpriteName(), where the method was right there in the class but it required indirect reflection to get to use it - said method being added by you in upcoming patch too.

Mainly time and a reason to do it. Exposing everything that could be reasonably exposed via the API would be a very substantial undertaking, and a lot of older stuff specifically wasn't written with it in mind. Stuff gets added to the API, generally speaking when:
1) I need to use it from code that's outside of core, or
2) Someone asks for it

So, given that second one - just added these and a few more to ButtonAPI :)

(There are some cases where the methods are unsuitable for external use for whatever reason, but that I think is fairly rare. But e.g. exposing specific things from within core code that aren't exposed at all may be another matter, a rats nest of dependencies that has to all be exposed in some way...)


what layer does a BaseEveryFrameCombatPlugin's renderInUICoords() method render on?
or is it all of them? having some wierdness with colours that could be explained by this; the alpha of anything I render seems to be set to full

edit : did a test w/ a sprite & it seems like the alpha is just getting thrown away, is there any way for me to fix this on my end? attached a screenshot below.

Above all of them, and below the rest of the UI. No idea what's going on with the sprite - did you set its blend mode to something weird? This has nothing to do with where it's being rendered, I don't think; looks to me like some kind of error on your end more than likely!


What is the correct usage of CombatEngineAPI.spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, String projSpecId, Vector2f point, float angle, Vector2f shipVelocity);?

Every time I have tried to use it, it crashes with a nullpointerexception in the constructor of either MovingRay or BallisticProjectile. For example calling this method with non-null variables, and with the strings "lightdualac" and "lightdualac_shot" will cause a crash. This makes it impossible to spawn projectiles that are indirectly spawned via MIRV missiles, e.g. the "sabot_warhead2" projectile. Can this be clarified please?

Hmm - it's used a bunch of times in the API for things like mines, some Omega weapons, etc. Also, data.scripts.plugins.TestCombatPlugin calls this to spray a bunch of lightmg shots, and I recall this working.

how do you get if a planetary market has a com relay, via code?

Is it like this? sector.getEntityById(Entities.COMM_RELAY) / sector.getEntityById(Entities.COMM_RELAY_MAKESHIFT)

I am unsure

You can do:
market.hasCondition(Conditions.COMM_RELAY)

It's a hidden condition that doesn't show up and the comm relay script iirc manages it under the hood.


I need to get tags of specific IntelInfoPlugins. How do I get a hold of SectorMapAPI instance in order to call Set<String> getIntelTags(SectorMapAPI map)? Searched through, all the usages are only extensions of caller methods, nothing returns SectorMapAPI.

I'm pretty sure you can just pass in null for the map; intel plugins are supposed to handle that. The vanilla ones do (unless I messed up); I just added a comment to the javadoc to make this expectation clear. Worst case you could do this in a try/catch block, *shudder*.


Oh God... In the process of writing this I looked into the BaseIntelPlugin and realized that what I thought to be a completely legit mechanism of making the intel visible/hidden (as implied by the javadoc comment) is actually not a functioning feature at all. I guess I can't set intel items to be hidden/shown after all:

Oh wow, my apologies :(

Ah, this is a bug, actually - in the dev version, this code already has:
return TutorialMissionIntel.isTutorialInProgress() || hidden != null;
So looks like it came up or was reported and I fixed it up at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on February 20, 2023, 03:48:23 PM
I want to create an "OnHit" event that, if it hits a shield on a target with less than 360 degree shields, will do some random damage to a non-shielded point on the ship. In other words, it would do damage just like the target was shot from that direction hitting armor and hull as normal.

Vectors confuse me so any help on how to manipulate the direction from the original shot to a random point on the unshielded arc would be appreciated.

(https://i.ibb.co/mchjY1d/random-Damage.png) (https://ibb.co/qrmS4Xh)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on February 20, 2023, 09:53:25 PM

What is the correct usage of CombatEngineAPI.spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, String projSpecId, Vector2f point, float angle, Vector2f shipVelocity);?

Every time I have tried to use it, it crashes with a nullpointerexception in the constructor of either MovingRay or BallisticProjectile. For example calling this method with non-null variables, and with the strings "lightdualac" and "lightdualac_shot" will cause a crash. This makes it impossible to spawn projectiles that are indirectly spawned via MIRV missiles, e.g. the "sabot_warhead2" projectile. Can this be clarified please?

Hmm - it's used a bunch of times in the API for things like mines, some Omega weapons, etc. Also, data.scripts.plugins.TestCombatPlugin calls this to spray a bunch of lightmg shots, and I recall this working.

Yeah the problem is that there are two spawnProjectile methods defined, and TestCombatPlugin only uses the one that takes a weaponID (which works flawlessly). The problem is that the second overload that takes a weaponID and a projectileID is always crashing whenever i try to use it, and I can't get it to not crash with a lot of different input combinations.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NinjaSiren on February 21, 2023, 06:55:53 AM
My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API? ButtonAPI's being just an example, there are plenty of cases like this - had a comment on getTurretGunSpriteName(), where the method was right there in the class but it required indirect reflection to get to use it - said method being added by you in upcoming patch too.

Mainly time and a reason to do it. Exposing everything that could be reasonably exposed via the API would be a very substantial undertaking, and a lot of older stuff specifically wasn't written with it in mind. Stuff gets added to the API, generally speaking when:
1) I need to use it from code that's outside of core, or
2) Someone asks for it

So, given that second one - just added these and a few more to ButtonAPI :)

(There are some cases where the methods are unsuitable for external use for whatever reason, but that I think is fairly rare. But e.g. exposing specific things from within core code that aren't exposed at all may be another matter, a rats nest of dependencies that has to all be exposed in some way...)


what layer does a BaseEveryFrameCombatPlugin's renderInUICoords() method render on?
or is it all of them? having some wierdness with colours that could be explained by this; the alpha of anything I render seems to be set to full

edit : did a test w/ a sprite & it seems like the alpha is just getting thrown away, is there any way for me to fix this on my end? attached a screenshot below.

Above all of them, and below the rest of the UI. No idea what's going on with the sprite - did you set its blend mode to something weird? This has nothing to do with where it's being rendered, I don't think; looks to me like some kind of error on your end more than likely!


What is the correct usage of CombatEngineAPI.spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, String projSpecId, Vector2f point, float angle, Vector2f shipVelocity);?

Every time I have tried to use it, it crashes with a nullpointerexception in the constructor of either MovingRay or BallisticProjectile. For example calling this method with non-null variables, and with the strings "lightdualac" and "lightdualac_shot" will cause a crash. This makes it impossible to spawn projectiles that are indirectly spawned via MIRV missiles, e.g. the "sabot_warhead2" projectile. Can this be clarified please?

Hmm - it's used a bunch of times in the API for things like mines, some Omega weapons, etc. Also, data.scripts.plugins.TestCombatPlugin calls this to spray a bunch of lightmg shots, and I recall this working.

how do you get if a planetary market has a com relay, via code?

Is it like this? sector.getEntityById(Entities.COMM_RELAY) / sector.getEntityById(Entities.COMM_RELAY_MAKESHIFT)

I am unsure

You can do:
market.hasCondition(Conditions.COMM_RELAY)

It's a hidden condition that doesn't show up and the comm relay script iirc manages it under the hood.


I need to get tags of specific IntelInfoPlugins. How do I get a hold of SectorMapAPI instance in order to call Set<String> getIntelTags(SectorMapAPI map)? Searched through, all the usages are only extensions of caller methods, nothing returns SectorMapAPI.

I'm pretty sure you can just pass in null for the map; intel plugins are supposed to handle that. The vanilla ones do (unless I messed up); I just added a comment to the javadoc to make this expectation clear. Worst case you could do this in a try/catch block, *shudder*.


Oh God... In the process of writing this I looked into the BaseIntelPlugin and realized that what I thought to be a completely legit mechanism of making the intel visible/hidden (as implied by the javadoc comment) is actually not a functioning feature at all. I guess I can't set intel items to be hidden/shown after all:

Oh wow, my apologies :(

Ah, this is a bug, actually - in the dev version, this code already has:
return TutorialMissionIntel.isTutorialInProgress() || hidden != null;
So looks like it came up or was reported and I fixed it up at some point.

thanks, will test this
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 21, 2023, 01:32:43 PM
Above all of them, and below the rest of the UI. No idea what's going on with the sprite - did you set its blend mode to something weird? This has nothing to do with where it's being rendered, I don't think; looks to me like some kind of error on your end more than likely!

ah-ha, thank you!
I didn't touch the blending at all ... which included forgetting to set the cap that turned it on, fixed that and it all works fine now!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 22, 2023, 12:56:14 AM
is it possible to change the time for how long the hit glow stays on the beam end point after beam is no longer hitting anything ?

is it possible to change how long the takeoff/landing animation plays for a given fighter, or all fighters in wing? and get the current progress of said animation?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 22, 2023, 08:30:01 AM
Can I get a FleetEncounterContextPlugin with populated DataForEncounterSide? Currently it seems that only CampaignEventListener#reportEncounterLootGenerated provides such a structure to mod-reachable code, but that one always has empty #disabledInLastEngagement, #destroyedInLastEngagement members, even if spawned from an ending battle where I observed ships being disabled/destroyed.

I kind of expect to get one from CampaignEventListener#reportBattleFinished but cannot find a way.

... Going to put that into the API requests thread, if not, but wanted to ask here first in case I am just blind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 22, 2023, 09:55:29 AM
Having some issues with my mod and thought it might be of some interest.
Spoiler
70396 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException: com.fs.starfarer.campaign.BaseLocation$LocationToken cannot be cast to com.fs.starfarer.campaign.BaseCampaignEntity
java.lang.ClassCastException: com.fs.starfarer.campaign.BaseLocation$LocationToken cannot be cast to com.fs.starfarer.campaign.BaseCampaignEntity
   at com.fs.starfarer.campaign.BaseLocation.getEntityById(Unknown Source)
   at fleetjour.scripts.panel.Common.findTargetEntity(Common.kt:85)
[close]

What basically happens is that I fetch SectorEntityToken ID of the system's center through getCenter(); store this ID in field of my class, and then fetch SectorEntityToken by this ID through public SectorEntityToken getEntityById(String var1).

BUT. If the star system in question is a nebula, it has LocationToken as its center, while getEntityById method has this code:

Code
        if (this.idToEntity.containsKey(var1)) {
            BaseCampaignEntity var2 = (BaseCampaignEntity)this.idToEntity.get(var1);
            if (var2.getContainingLocation() != null && var2.getContainingLocation().getAllEntities().contains(var2)) {
                return var2;
            }
        }

And that is the source of my crash right there, since LocationToken doesn't cast to BaseCampaignEntity. The question is: is this a vanilla implementation shortcoming or am I simply doing it wrong? I'm able to get rid of the crash by retrieving star of the system instead of its center, so it's nothing major - just putting this out there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 22, 2023, 12:44:09 PM

What is the correct usage of CombatEngineAPI.spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, String projSpecId, Vector2f point, float angle, Vector2f shipVelocity);?

Every time I have tried to use it, it crashes with a nullpointerexception in the constructor of either MovingRay or BallisticProjectile. For example calling this method with non-null variables, and with the strings "lightdualac" and "lightdualac_shot" will cause a crash. This makes it impossible to spawn projectiles that are indirectly spawned via MIRV missiles, e.g. the "sabot_warhead2" projectile. Can this be clarified please?

Hmm - it's used a bunch of times in the API for things like mines, some Omega weapons, etc. Also, data.scripts.plugins.TestCombatPlugin calls this to spray a bunch of lightmg shots, and I recall this working.

Yeah the problem is that there are two spawnProjectile methods defined, and TestCombatPlugin only uses the one that takes a weaponID (which works flawlessly). The problem is that the second overload that takes a weaponID and a projectileID is always crashing whenever i try to use it, and I can't get it to not crash with a lot of different input combinations.

Ah, thank you for clarifying! ... it looks like this method is fundamentally broken. It may have worked at some point in the past, but basically: the projectile spec is cloned and has some values set for it when it is modified to apply to a specific weapon. Different weapons can use the same projectile spec and have different stats such as max range, though this is mostly only done with missiles. So the spec this method tries to use is the "base" spec unmodified by any specific weapon's stats. Among the other things it's missing, it doesn't have a damage component specified, which causes the NPE.

I'm going to deprecate the method and add a note in the javadoc. As the code is right now, using a projecile spec not associated with a specific weapon doesn't make conceptual sense, it needs a weapon to draw a bunch of its stats from.

is it possible to change the time for how long the hit glow stays on the beam end point after beam is no longer hitting anything ?

is it possible to change how long the takeoff/landing animation plays for a given fighter, or all fighters in wing? and get the current progress of said animation?

I don't think so, on any of the counts - sorry! You could perhaps try using ship.getAlphaMult() as a rough proxy for the progress of the landing animation.


Can I get a FleetEncounterContextPlugin with populated DataForEncounterSide? Currently it seems that only CampaignEventListener#reportEncounterLootGenerated provides such a structure to mod-reachable code, but that one always has empty #disabledInLastEngagement, #destroyedInLastEngagement members, even if spawned from an ending battle where I observed ships being disabled/destroyed.

I kind of expect to get one from CampaignEventListener#reportBattleFinished but cannot find a way.

... Going to put that into the API requests thread, if not, but wanted to ask here first in case I am just blind.

The vanilla implementation of this - FleetEncounterContext - gets this data populated, let me see. Ah - this happens in FleetInteractionDialogPluginImpl.backFromEngagement(). That plugin calls:
context.processEngagementResults(result);

With "result" being the data passed in to backFromEngagement() which has this info.


What basically happens is that I fetch SectorEntityToken ID of the system's center through getCenter(); store this ID in field of my class, and then fetch SectorEntityToken by this ID through public SectorEntityToken getEntityById(String var1).

BUT. If the star system in question is a nebula, it has LocationToken as its center, while getEntityById method has this code:

Code
        if (this.idToEntity.containsKey(var1)) {
            BaseCampaignEntity var2 = (BaseCampaignEntity)this.idToEntity.get(var1);
            if (var2.getContainingLocation() != null && var2.getContainingLocation().getAllEntities().contains(var2)) {
                return var2;
            }
        }

And that is the source of my crash right there, since LocationToken doesn't cast to BaseCampaignEntity. The question is: is this a vanilla implementation shortcoming or am I simply doing it wrong? I'm able to get rid of the crash by retrieving star of the system instead of its center, so it's nothing major - just putting this out there.

Thank you! This is a vanilla issue; fixed this up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on February 22, 2023, 03:02:47 PM
Can I get a FleetEncounterContextPlugin with populated DataForEncounterSide? Currently it seems that only CampaignEventListener#reportEncounterLootGenerated provides such a structure to mod-reachable code, but that one always has empty #disabledInLastEngagement, #destroyedInLastEngagement members, even if spawned from an ending battle where I observed ships being disabled/destroyed.

I kind of expect to get one from CampaignEventListener#reportBattleFinished but cannot find a way.

... Going to put that into the API requests thread, if not, but wanted to ask here first in case I am just blind.

The vanilla implementation of this - FleetEncounterContext - gets this data populated, let me see. Ah - this happens in FleetInteractionDialogPluginImpl.backFromEngagement(). That plugin calls:
context.processEngagementResults(result);

With "result" being the data passed in to backFromEngagement() which has this info.
Sorry, I formulated badly. This EngagementResultAPI is produced by #getResult of a specific instance of BattleAutoresolverPluginImpl only created in and for case AUTORESOLVE_PURSUE of method FleetInteractionDialogPluginImpl#optionSelected . It cannot possibly contain the results of other kinds of battle, even if the player is involved in them.

There is also no listener that will provide the moment in time, when it is save to read the resulting context, e.g. via reflection access to FleetInteractionDialogPluginImpl#context . Nor is it possible to extend FleetInteractionDialogPluginImpl, as its constructor is called explicitly instead of Factory or Singleton access. All callers are themselves plugins and it might be possible to replace some of them, but e.g. CoreCampaignPluginImpl probably can't be (or at least I find no methods that would allow doing that).

So, yes, technically I can obtain some populated DataForEncounterSide, but even for the player fleet I will only ever get it from a delegated pursuit, not from any other battle. AI vs AI battles are right out (surprisingly - I'd kind of expect the BattleAutoresolverPluginImpl to handle them as well... - so maybe/hopefully I am mistaken).

I should have asked whether I can get it reliably, without concern about the specific kind of engagement, commander of fleets involved or other "magic" environmental variables. Getting one only for player-delegated pursuits technically is "getting", yes - but also pretty useless.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 22, 2023, 03:31:16 PM
not sure if that's intended behavior or not
but does _under sprite of the weapon not respect render order?
i have a gun that only has an _under sprite specified for it
it goes into small built-in slot
changing renderOrderMod of that slot seems to have no effect whatsoever, it still renders below the deco weapon in the large slot
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 22, 2023, 04:15:39 PM
Sorry, I formulated badly. This EngagementResultAPI is produced by #getResult of a specific instance of BattleAutoresolverPluginImpl only created in and for case AUTORESOLVE_PURSUE of method FleetInteractionDialogPluginImpl#optionSelected . It cannot possibly contain the results of other kinds of battle, even if the player is involved in them.

There is also no listener that will provide the moment in time, when it is save to read the resulting context, e.g. via reflection access to FleetInteractionDialogPluginImpl#context . Nor is it possible to extend FleetInteractionDialogPluginImpl, as its constructor is called explicitly instead of Factory or Singleton access. All callers are themselves plugins and it might be possible to replace some of them, but e.g. CoreCampaignPluginImpl probably can't be (or at least I find no methods that would allow doing that).

So, yes, technically I can obtain some populated DataForEncounterSide, but even for the player fleet I will only ever get it from a delegated pursuit, not from any other battle. AI vs AI battles are right out (surprisingly - I'd kind of expect the BattleAutoresolverPluginImpl to handle them as well... - so maybe/hopefully I am mistaken).

I should have asked whether I can get it reliably, without concern about the specific kind of engagement, commander of fleets involved or other "magic" environmental variables. Getting one only for player-delegated pursuits technically is "getting", yes - but also pretty useless.

Ah, yeah, I see. There's no listener at that point so you're probably out of luck. And what the default BattleAutoresolverPluginImpl does as far as tracking this sort of info is also an implementation detail that you probably couldn't rely on too much, anyway.

It *is* possible to replace CoreCampaignPluginImpl - you'd need to SectorAPI.unregisterPlugin() and then provide your own implementation. More to the point, though, you don't *have* to do that, you can provide your own implementation that returns a different interaction dialog plugin with a higher priority. So e.g.

CoreCampaignPluginImpl has:
return new PluginPick<InteractionDialogPlugin>(new FleetInteractionDialogPluginImpl(), PickPriority.CORE_GENERAL);

And your plugin might have:
return new PluginPick<InteractionDialogPlugin>(new YourFleetInteractionDialogPluginImpl(), PickPriority.MOD_GENERAL);

Note that this is likely to be a bad idea since multiple mods doing this could be, and likely would be, incompatible with each other.

not sure if that's intended behavior or not
but does _under sprite of the weapon not respect render order?
i have a gun that only has an _under sprite specified for it
it goes into small built-in slot
changing renderOrderMod of that slot seems to have no effect whatsoever, it still renders below the deco weapon in the large slot

Intended behavior; it renders right over the ship sprite (well, and right over the d-hull overlay, if any). Your best would probably be to have an _under sprite for the deco weapon and finagle the slot order so it comes out right. ... this does point to a broader issue of weapons with _under sprites not working well with ships that have decorative weapons, though, doesn't it, hmm. I'll keep it in mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 22, 2023, 04:42:50 PM
not sure if that's intended behavior or not
but does _under sprite of the weapon not respect render order?
i have a gun that only has an _under sprite specified for it
it goes into small built-in slot
changing renderOrderMod of that slot seems to have no effect whatsoever, it still renders below the deco weapon in the large slot

Intended behavior; it renders right over the ship sprite (well, and right over the d-hull overlay, if any). Your best would probably be to have an _under sprite for the deco weapon and finagle the slot order so it comes out right. ... this does point to a broader issue of weapons with _under sprites not working well with ships that have decorative weapons, though, doesn't it, hmm. I'll keep it in mind.

maybe also consider adding RENDER_UNDER_ABOVE render hint, similar to RENDER_BARREL_BELOW, to force the _under sprite to render on top of everything else. this can have oh so many possibilities, pillbox-like weapons, just to name a few...
or an option to suspend base/barrel rotation?

speaking of sprites actually, can frame animation be applied to the  barrel sprite at all? or even, to the base and barrel sprite, as two different animations?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on February 24, 2023, 05:19:19 PM
I want to make a shipSystem that has an active duration in seconds equal to the fleet points value of the ship it's installed on. How would I do that? Also, is each shipSystem a singleton that is shared by all ships that have that system?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 25, 2023, 10:40:05 AM
speaking of sprites actually, can frame animation be applied to the  barrel sprite at all? or even, to the base and barrel sprite, as two different animations?

Hmm, I don't think so. It's assumed that the base animation handles an animated barrel, if that's a thing for the weapon.


I want to make a shipSystem that has an active duration in seconds equal to the fleet points value of the ship it's installed on. How would I do that?

You'd probably need to handle this in the system script, using ShipSystemAPI.deactivate() when appropriate.


Also, is each shipSystem a singleton that is shared by all ships that have that system?

You can check this by having a system script with a constructor, logging some stuff there (or putting a breakpoint there) and seeing when that's called.

(It's not a singleton, a new copy is instantiated for each ship.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on February 26, 2023, 02:00:35 PM
I made a ship that carries a firgate. It deploys thefrigate at thestart of combat with spawnShipOrWing(). I'm using a mod that tracks kills and ship experience and I wanted to give the launching ship credit for anything the dynamically-spawned frigate kills. I successfully did this by calling pf.setParentStation(ship);, where pf is the frigate.

The only problem I'm having is that if the frigate gets too far from the parent ship the frigate stops firing all of its weapons. Once the parent ship gets back within about 1500 to 2000 of the frigate it starts firing again. Any idea what could be causing this behavior?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2023, 05:57:16 PM
... no idea, honestly - nothing comes to mind as a possible cause. I'm very surprised that calling setParentStation() on the ship doesn't break things horribly, though, wow.

Ok, well, maybe one idea - could it be a fog of war issue, perhaps? A quick way to check would be to turn the fog of war off in dev mode (by pressing Ctrl-F).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on February 28, 2023, 12:21:00 AM
is it possible to change this text for one specific ability?
the "press F1 for more info"
(https://i.imgur.com/KltmeuW.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 28, 2023, 01:12:25 AM
is it possible to change this text for one specific ability?
the "press F1 for more info"
Spoiler
(https://i.imgur.com/KltmeuW.png)
[close]

Yes, but only on runtime with use of some serious reflection, and the underlying frame graphics is not going to accomodate those changes, said frame being un-modifiable due to method names being obfuscated too. In other words: no, not realistically possible.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2023, 02:00:11 PM
It is, however, possibly to *remove* this text - along with the ability to expand the tooltip - by having AbilityPlugin.isTooltipExpandable() return false.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 01, 2023, 04:33:10 AM
what would be the safest way to detect the event of missile being killed by PD fire?
to make stuff happen
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 01, 2023, 05:59:04 PM
Hmm, probably with a DamageTakenModifier added to the Global.getCombatEngine().getListenerManager().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 01, 2023, 06:30:55 PM
You could use an OnFireEffectPlugin to push the resulting MissileAPIs into a managed ArrayList (somewhere else, in a public static) that gets checked each Advance() by a Plugin; if it's hitpoints <=0.0f then <do stuff>
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 02, 2023, 11:36:28 AM
hello once again all. i have yet more questions.
does anyone know how to add bonus XP to the player?
and how would one go about finding the amount of bonus XP given when you scuttle / sell a ship with a S-Mod?
thank you all once more for all the help in the past. it helped me make things i think are cool.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on March 02, 2023, 12:35:21 PM
I am (trying to) create a bar/contact event where the player may provide a donor ship to be converted into a variant ship, e.g. a Tarsus for a Condor or a Brawler for a Brawler (TT).

Is there a way to allow the player to select one (or any specific number) of a list of ships?

Currently I am mis-using two successive InteractionDialogAPI#showFleetMemberRecoveryDialogs (one to select the donors and one to select the conversions) but the FleetMemberPickerListener those use as callback can only react to the whole list of selections, not to individual picks.

I see that #showCustomProductionPicker with CustomProductionPickerDelegate would at least offer a monetary limit. My problem is that one ship may offer more than one conversion option and then, at the latest, I really have to restrict selection to one of these options. (E.g. the pirates may convert a Buffalo (A) into either Buffalo (P) or Buffalo Mk.2, but not into both.)

... Alternatively, I think I can use CustomVisualDialogDelegate to build my own selection screen from scratch - is there a good (or indeed any) way to clone the look of an existing screen, so I need not manually keep it consistent on version updates?

(The more I think about it, the more I think it's a deal breaker to select more than exactly one donor ship - I'd want to take e.g. D-Mods into account for the price of the conversion and at that point, I'll have different price factors for each of the conversion entries, so CustomProductionPickerDelegate will definitely no longer suffice.)

Addendum: Narf, I was blind! The monstrous InteractionDialogAPI#showFleetMemberPickerDialog will do just fine, I just somehow did not see it. ... I presume there are no constants around to keep the five display parameters (from okText to iconSize) consistent with the rest of the game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on March 02, 2023, 01:38:05 PM
Is there a way to open a CustomPanelAPI while in Combat?
Been looking around and ive only found an obfuscated solution, that being to create a new obfuscated implementation of an interaction dialog and starting the custom panel through that.

Code
var dialog= com.fs.starfarer.ui.newui.o0Oo(parametersHere)
dialog.show(0.2f, 0.1f)
For obvious reasons id much prefer a non-obfuscated solution, is there one?
Im specificly looking for this so that i can open a panel in the main menu of the game through an EveryFrameCombatPlugin
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on March 02, 2023, 04:01:32 PM
Is there a way of preventing a (missile) weapon from receiving additional ammunition from hullmods/skills?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on March 02, 2023, 06:17:21 PM
is there a way we can get a method to modify a missile's max speed and acceleration?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 02, 2023, 06:53:56 PM
Is there a way of preventing a (missile) weapon from receiving additional ammunition from hullmods/skills?

Combat plugin that looks at each weapon and looks at the weapon's spec, then drops the weapon's ammo if it is above the spec's max.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 03, 2023, 10:12:33 AM
does anyone know how to add bonus XP to the player?

MutableCharacterStatsAPI has:
void addBonusXP(long bonusXp, boolean withMessage, TextPanelAPI textPanel, boolean topScreenMessage);

Not 100% sure if it's in the currently-out version, though.

and how would one go about finding the amount of bonus XP given when you scuttle / sell a ship with a S-Mod?

Misc.getBonusXPForScuttling(FleetMemberAPI member)


Addendum: Narf, I was blind! The monstrous InteractionDialogAPI#showFleetMemberPickerDialog will do just fine, I just somehow did not see it. ... I presume there are no constants around to keep the five display parameters (from okText to iconSize) consistent with the rest of the game?

Ah, glad you spotted that! No constants, no - though there probably should be :)


Is there a way to open a CustomPanelAPI while in Combat?
Been looking around and ive only found an obfuscated solution, that being to create a new obfuscated implementation of an interaction dialog and starting the custom panel through that.

...
Im specificly looking for this so that i can open a panel in the main menu of the game through an EveryFrameCombatPlugin

Hmm - what about using SettingsAPI.createCustom() and then using EveryFrameCombatPlugin.renderInUICoords() to render it?

... ah, crap, CustomPanelAPI and all the classes it's derived from don't have the relevant rendering/input processing methods exposed; let me add those to the API.


is there a way we can get a method to modify a missile's max speed and acceleration?

That should be doable via MissileAPI.getEngineStats() though I'm not sure if that's in the currently-out version or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on March 03, 2023, 11:47:56 AM
is there a way we can get a method to modify a missile's max speed and acceleration?

That should be doable via MissileAPI.getEngineStats() though I'm not sure if that's in the currently-out version or not.

that's the missing link in the current version, actually. thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on March 05, 2023, 12:34:37 PM
How many names are practical to put into the planetary names file? Will the game start to bog down at 1000, 5000, etc?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 05, 2023, 12:53:01 PM
How many names are practical to put into the planetary names file? Will the game start to bog down at 1000, 5000, etc?

A lot.

For example, it will take about 15,000 names to hit 1 MB of RAM usage:
https://stackoverflow.com/questions/31206851/how-much-memory-does-a-string-use-in-java-8

Only way to be sure would be to write a program that generates a file with X thousands of names in it and see if Starsector chugs when you have it load them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: WhisperDSP on March 05, 2023, 01:01:40 PM
Probably don't want to hit 15k names then, given the base memory settings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 06, 2023, 09:12:54 AM
Yeah, testing this would be about the only way to find out. I'd expect it's quite a lot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on March 07, 2023, 09:30:29 AM
How are you supposed to load csv files from the base game? When I ran Global.getSettings().loadCSV("data/hulls/ship_data.csv"); it was loading the ship_data.csv of one of the mods enabled. Is this some sort of bug?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 07, 2023, 10:47:25 AM
Hmm, I'm not sure that you can. That method is going to grab whatever the (I think) last enabled mod is that has that file in it. IIRC the method intended for loading files from the mod's own folder.

I want to say that people are doing this, though? So there may be a way I'm not thinking of right now.

Edit:
Added to SettingsAPI:
   JSONObject loadJSON(String filename, boolean withMods);
   JSONArray loadCSV(String filename, boolean withMods);
      To allow loading of vanilla files
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 07, 2023, 11:25:59 AM
I was going to suggest using getMergedSpreadsheetDataForMod();, it should also work for this purpose?

something like Global.getSettings().getMergedSpreadsheetDataForMod("id", "data/hulls/ship_data.csv", "yourmodid"); should do it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 07, 2023, 05:35:47 PM
Is it possible/feasible to use custom AIHints for weapons that don't do anything other than act as hidden identifier for further scripting? I don't strictly need the capacity per se, but it would simplify matters greatly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RoboticManiac on March 08, 2023, 12:28:24 AM
Is it possible to increase the amount of fleets in the game? Meaning a higher density of pirate, patrol, salvagers etc fleets flying around? And how might one go about doing so, should it be possible?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 08, 2023, 12:56:02 AM
Is it possible/feasible to use custom AIHints for weapons that don't do anything other than act as hidden identifier for further scripting? I don't strictly need the capacity per se, but it would simplify matters greatly.

no, but you can just use custom tags, they're just a list of arbitrary strings so you can stick w/e in there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 08, 2023, 05:30:51 AM
Is it possible/feasible to use custom AIHints for weapons that don't do anything other than act as hidden identifier for further scripting? I don't strictly need the capacity per se, but it would simplify matters greatly.

no, but you can just use custom tags, they're just a list of arbitrary strings so you can stick w/e in there.

Would you happen to know what method you'd need to look for them? I know how to check a weapon for hints, it's display name or Id, but not tags.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 08, 2023, 05:34:04 AM
WeaponAPI.getSpec().getTags(); will give you the full list, then you can just .contains(); it to check for specific tags
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 08, 2023, 05:54:21 AM
WeaponAPI.getSpec().getTags(); will give you the full list, then you can just .contains(); it to check for specific tags

Cheers, didn't even know that method existed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 08, 2023, 01:35:11 PM
Is it possible to increase the amount of fleets in the game? Meaning a higher density of pirate, patrol, salvagers etc fleets flying around? And how might one go about doing so, should it be possible?

Ah - not in a super straightforward way like tweaking a few config values; you'd need to dig through the code that handles each of these things and adjust it separately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xaiier on March 08, 2023, 10:10:47 PM
Why do...

WeaponSlotAPI.setArc(float arc);
WeaponSlotAPI.setAngle(float angle);

...apply to the visuals, but don't update the behavior?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on March 09, 2023, 06:00:27 AM
Hello all, I am looking for some guidance to solve an issue that has come up with Hiver Swarm. They show up as a target for missions given in the bar such as having one of their planets a trade target destination. Today I received a message from a player who said they were doing the red planet missions that the 2nd guy you have to talk to after the old spacer was on a Hiver world. Since they are hostile to all factions it would make those missions not completable.

Histidine was kind enough to point me in the direction of a command I did find on the SS API website, market.setInvalidMissionTarget(true) so if I understand it correctly then that *should* effect vanilla missions but there are so many files that effect a faction's market I am unsure where that would go in the Hiver faction market creation process. Any help would be appreciated, thank you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 09, 2023, 06:43:53 AM
Is it safe to save instances of BaseIntelPlugin in persistent data? What about a planet's custom data? I thought it would be safe to do so since BaseIntelPlugin does not reference any other UI elements, but I'm told it can still cause issues. Thanks for any help!

...apply to the visuals, but don't update the behavior?
What behavior isn't being updated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 09, 2023, 08:17:53 AM
Is it safe to save instances of BaseIntelPlugin in persistent data? What about a planet's custom data? I thought it would be safe to do so since BaseIntelPlugin does not reference any other UI elements, but I'm told it can still cause issues. Thanks for any help!

...apply to the visuals, but don't update the behavior?
What behavior isn't being updated?

Edit for more context:
I have good reason to believe that my newest mod has caused save corruption for a user. They're sometimes getting this error when saving:
Spoiler
7324113 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving stage 2
7324113 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Saving stage 3
7327332 [Thread-3] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Error saving game
7327332 [Thread-3] ERROR com.fs.starfarer.campaign.save.CampaignGameManager  -
java.lang.StackOverflowError
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.DynamicProxyMapper.serializedClass(DynamicProxyMapper.java:47)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.PackageAliasingMapper.serializedClass(PackageAliasingMapper.java:69)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.ClassAliasingMapper.serializedClass(ClassAliasingMapper.java:64)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.ArrayMapper.serializedClass(ArrayMapper.java:45)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.DefaultImplementationsMapper.serializedClass(DefaultImplementationsMapper.java:64)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.EnumMapper.serializedClass(EnumMapper.java:61)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.LambdaMapper.serializedClass(LambdaMapper.java:58)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.mapper.AnnotationMapper.serializedClass(AnnotationMapper.java:128)
   at com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass(MapperWrapper.java:121)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:231)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hallField(AbstractReflectionConverter.java:274)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:250)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.<init>(AbstractReflectionConverter.java:213)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMa rshal(AbstractReflectionConverter.java:144)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.mars hal(AbstractReflectionConverter.java:90)
   at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
   at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)

Repeats ~200 times
[close]
And the end of their save file is filled with this nonsense afterward:
Spoiler
<oo0000 cl="java.nio.DirectFloatBufferU" z="291814">
<mark>-1</mark>
<position>0</position>
<limit>400</limit>
<capacity>400</capacity>
<address>2043140605536</address>
<offset>0</offset>
<isReadOnly>false</isReadOnly>
<att cl="java.nio.DirectByteBuffer" z="291815">
<mark>-1</mark>
<position>0</position>
<limit>1600</limit>
<capacity>1600</capacity>
<address>2043140605536</address>
<offset>0</offset>
<isReadOnly>false</isReadOnly>
<bigEndian>false</bigEndian>
<nativeByteOrder>true</nativeByteOrder>
<cleaner z="291816">
<referent cl="java.nio.DirectByteBuffer" ref="291815"></referent>
<queue z="291817">
<lock z="291818"></lock>
<queueLength>0</queueLength>
</queue>
<next z="291819">
<referent cl="java.nio.DirectByteBuffer" z="291820">
<mark>-1</mark>
<position>0</position>
<limit>16</limit>
<capacity>16</capacity>
<address>2038711492576</address>
<offset>0</offset>
<isReadOnly>false</isReadOnly>
<bigEndian>false</bigEndian>
<nativeByteOrder>true</nativeByteOrder>
<cleaner ref="291819"></cleaner>
</referent>
<queue ref="291817"></queue>
<next z="291821">
<referent cl="java.nio.DirectByteBuffer" z="291822">
<mark>-1</mark>
<position>0</position>
<limit>32</limit>
<capacity>32</capacity>
<address>2043214702512</address>
<offset>0</offset>
<isReadOnly>false</isReadOnly>
<bigEndian>false</bigEndian>
<nativeByteOrder>true</nativeByteOrder>
<cleaner ref="291821"></cleaner>
</referent>
<queue ref="291817"></queue>
<next z="291823">
[close]
I can't think of anything that would cause something like that other than an endless recursion loop caused by trying to save a looping reference.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2023, 08:55:38 AM
Why do...

WeaponSlotAPI.setArc(float arc);
WeaponSlotAPI.setAngle(float angle);

...apply to the visuals, but don't update the behavior?

Hmm - at a guess, this might be because by the time you're calling these, the ship is already created and deployed.

Hello all, I am looking for some guidance to solve an issue that has come up with Hiver Swarm. They show up as a target for missions given in the bar such as having one of their planets a trade target destination. Today I received a message from a player who said they were doing the red planet missions that the 2nd guy you have to talk to after the old spacer was on a Hiver world. Since they are hostile to all factions it would make those missions not completable.

Histidine was kind enough to point me in the direction of a command I did find on the SS API website, market.setInvalidMissionTarget(true) so if I understand it correctly then that *should* effect vanilla missions but there are so many files that effect a faction's market I am unsure where that would go in the Hiver faction market creation process. Any help would be appreciated, thank you.

Red Planet is not actually checking for isInvalidMissionTarget(), though it should be - fixed this up. It *is* checking for market.isHidden(), though, so you might try that.

You'd want to do this in code somewhere - possibly in your ModPlugin.onNewGameAfterEconomyLoad()


Is it safe to save instances of BaseIntelPlugin in persistent data? What about a planet's custom data? I thought it would be safe to do so since BaseIntelPlugin does not reference any other UI elements, but I'm told it can still cause issues. Thanks for any help!

If I'm understanding the question correctly, for BaseIntelPlugin it should be fine - the vanilla game does this all the time. "A planet's custom data" I'm not 100% sure what you mean - could you clarify?


Edit for more context:
I have good reason to believe that my newest mod has caused save corruption for a user. They're sometimes getting this error when saving:

I can't think of anything that would cause something like that other than an endless recursion loop caused by trying to save a looping reference.

Looping references should be fine - this is, again, something that happens all the time and is handled by xstream. It's very weird that it's writing bytebuffers into the savefile, though. It might help to see more of it, if you have it - could you email it to me?

At a guess, rather than being a recursion loop issue, it may just be an issue with the data structure itself going very deep for some reason - not infinite, but deep enough to cause a stack overflow. So the question is what is this actually rooted in and what's getting into the savefile that shouldn't be. Though, if my guess is right, the issue isn't just that it's getting into the savefile, but also with it growing to the extent that it's a problem, too.

Edit: to be clear, it would be really helpful (well, probably) to see where this stuff *starts* in the save. Or better, the whole save.

Edit #2: seeing a "next" element in there makes me think it's some kind of linked list or perhaps linked hashmap that gets added to in an unbounded fashion. That would explain the stack overflow exception, too - when a long linked list is serialized by xstream, chances are it would happen depth-first.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 09, 2023, 04:35:18 PM
Thanks for the help, Alex! I suspect the issue isn't caused by the intel items being saved in persistent data, but by a TooltipMaker field that I overlooked in a different intel (one that is saved normally). I can't remove the field or make it transient now without creating a save incompatibility, so I'm just making sure it's null before being saved. That's an easy fix, but the intel items being saved to persistent data is integral to the structure of the mod, so I'm hesitant to change it. Other than the fields they inherit from BaseIntelPlugin and some primitives, the intel items I'm saving also have a reference to the planet they're attached to, if that matters.

If I'm understanding the question correctly, for BaseIntelPlugin it should be fine - the vanilla game does this all the time. "A planet's custom data" I'm not 100% sure what you mean - could you clarify?
Something like this:
Code: java
        List<BaseIntelPlugin> intelList = new ArrayList<>();
        intelList.add(intel1);
        intelList.add(intel2);
        planet.getCustomData().put("myIntelListKey", intelList);
Looping references should be fine - this is, again, something that happens all the time and is handled by xstream. It's very weird that it's writing bytebuffers into the savefile, though. It might help to see more of it, if you have it - could you email it to me?
I'll ask the user to upload or email it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 09, 2023, 05:09:39 PM
is there a way to check which specific launch port the individual ShipAPI fighter is launching from ?
calling fiighter.getWing.getSource returns the whole bay from which the wing belongs, and i can get individual port locations from it
but not which fighter was launched from where
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2023, 06:21:42 PM
Thanks for the help, Alex! I suspect the issue isn't caused by the intel items being saved in persistent data, but by a TooltipMaker field that I overlooked in a different intel (one that is saved normally). I can't remove the field or make it transient now without creating a save incompatibility, so I'm just making sure it's null before being saved.

That makes sense, it would be a problem. You could easily end up with the entire game UI in there. Not sure how it'd end up with a stack overflow, but.

I think making a field transient is fine save-compatibility-wise as long as your intel class can handle it being null when the game is loaded.

That's an easy fix, but the intel items being saved to persistent data is integral to the structure of the mod, so I'm hesitant to change it. Other than the fields they inherit from BaseIntelPlugin and some primitives, the intel items I'm saving also have a reference to the planet they're attached to, if that matters.

Just to emphasize, saving intel items is not a problem. This happens *all the time*. I think literally every single intel item you see in vanilla is in the savefile.

is there a way to check which specific launch port the individual ShipAPI fighter is launching from ?
calling fiighter.getWing.getSource returns the whole bay from which the wing belongs, and i can get individual port locations from it
but not which fighter was launched from where

Oh, hmm - pretty sure there isn't, sorry! Your best bet might be checking the location of the fighter and then comparing that against the launch port locations, if you're able to access those.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 09, 2023, 06:52:24 PM
Oh, hmm - pretty sure there isn't, sorry! Your best bet might be checking the location of the fighter and then comparing that against the launch port locations, if you're able to access those.
yes, i'm already doing that
problem is, fighters don't seem to spawn directly from the launch port location, but somewhere nearby, so i can't exactly catch them even immediately on launch even
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2023, 08:07:03 PM
yes, i'm already doing that
problem is, fighters don't seem to spawn directly from the launch port location, but somewhere nearby, so i can't exactly catch them even immediately on launch even

Ah - looking at the code, you're right, it's in a random location in a 20x20 square centered on the launch port.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xaiier on March 09, 2023, 08:16:35 PM
Why do...

WeaponSlotAPI.setArc(float arc);
WeaponSlotAPI.setAngle(float angle);

...apply to the visuals, but don't update the behavior?

Hmm - at a guess, this might be because by the time you're calling these, the ship is already created and deployed.

Well, yes...but you can move them around in combat no problem. It would be nice if the reorientation worked as well.

It would also be nice if there was a way to access them directly, without having to fetch them via the weapons. Though I suppose it's that way because these slots are, unlike the global hull spec, unique per ship and only generated for mounted weapons.

EDIT: Ok, I swear this worked yesterday...but now multiple ships on the field are interfering with eachother...maybe I don't understand this as well as I thought...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on March 09, 2023, 10:38:10 PM
Alex, thank you so much for all your help! I released a patch that prevents the tooltip maker from being saved but doesn't change the way the intel plugins are saved. Being confident that that is the correct solution is a huge weight off my mind.

I think making a field transient is fine save-compatibility-wise as long as your intel class can handle it being null when the game is loaded.
I though so too, but after setting it to transient I couldn't load a test save. Maybe because I didn't configure xstream for that class? *shrug* It doesn't appear in the save file now that it's set to null all the time, so I'll just have to put up with it being there until the next breaking update.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 09, 2023, 11:02:43 PM
I've been mucking about with an Iterator to see if I can get it to affect specific weapons.

Code
@Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {

        List weapons = ship.getAllWeapons();
        Iterator iter = weapons.iterator();
        while (iter.hasNext()) {

            WeaponAPI weapon = (WeaponAPI)iter.next();

            boolean test = (weapon.getSpec().getTags().contains("jeff"));
            if (test) {
                ship.getMutableStats().getBallisticRoFMult().modifyMult(id, 5f);
            }
        }
    }

I originally based this off of the iterator used for the PD AI . The above works as long as the "jeff" condition is met, but it applies the effects to all the relevant weapons on the ship, not just the one that meets the requirement. I suspect that the ship.getMutableStats() is to blame, but is there anyway to transition from weapon to getMutableStats to allow them to be used without applying to everything?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on March 10, 2023, 10:26:53 AM
Is there a method in the API, outside of the VisualPanelAPI showPlanetInfo(), that can be used to display the Planet Graphic?
Would be quite useful to have for Custom UI Screens.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on March 10, 2023, 11:20:33 AM
Hello all, I am looking for some guidance to solve an issue that has come up with Hiver Swarm. They show up as a target for missions given in the bar such as having one of their planets a trade target destination. Today I received a message from a player who said they were doing the red planet missions that the 2nd guy you have to talk to after the old spacer was on a Hiver world. Since they are hostile to all factions it would make those missions not completable.

Histidine was kind enough to point me in the direction of a command I did find on the SS API website, market.setInvalidMissionTarget(true) so if I understand it correctly then that *should* effect vanilla missions but there are so many files that effect a faction's market I am unsure where that would go in the Hiver faction market creation process. Any help would be appreciated, thank you.

Red Planet is not actually checking for isInvalidMissionTarget(), though it should be - fixed this up. It *is* checking for market.isHidden(), though, so you might try that.

You'd want to do this in code somewhere - possibly in your ModPlugin.onNewGameAfterEconomyLoad()

I have tried several different version attempts to get this to work with no success and have gone though every listed faction mod's Modplugin looking for an example of market.isHidden() and could not find one use of that code. The best I could hamfist is the following code which though it doesn't crash, it also doesn't hide the market.
Code
     @Override
    public void onNewGameAfterEconomyLoad() {
        MarketAPI market = Global.getSector().getEconomy().getMarket("HIVER_Arokor");
        if (market != null) {
market.isHidden();
}
}
So clearly I am doing something wrong but I am so new to Java that I have no idea where I made the wrong turn or if I am even heading in the correct direction. Any help in the proper code structure of using market.isHidden() would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on March 10, 2023, 12:02:33 PM
Hello all, I am looking for some guidance to solve an issue that has come up with Hiver Swarm. They show up as a target for missions given in the bar such as having one of their planets a trade target destination. Today I received a message from a player who said they were doing the red planet missions that the 2nd guy you have to talk to after the old spacer was on a Hiver world. Since they are hostile to all factions it would make those missions not completable.

Histidine was kind enough to point me in the direction of a command I did find on the SS API website, market.setInvalidMissionTarget(true) so if I understand it correctly then that *should* effect vanilla missions but there are so many files that effect a faction's market I am unsure where that would go in the Hiver faction market creation process. Any help would be appreciated, thank you.

Red Planet is not actually checking for isInvalidMissionTarget(), though it should be - fixed this up. It *is* checking for market.isHidden(), though, so you might try that.

You'd want to do this in code somewhere - possibly in your ModPlugin.onNewGameAfterEconomyLoad()

I have tried several different version attempts to get this to work with no success and have gone though every listed faction mod's Modplugin looking for an example of market.isHidden() and could not find one use of that code. The best I could hamfist is the following code which though it doesn't crash, it also doesn't hide the market.
Code
     @Override
    public void onNewGameAfterEconomyLoad() {
        MarketAPI market = Global.getSector().getEconomy().getMarket("HIVER_Arokor");
        if (market != null) {
market.isHidden();
}
}
So clearly I am doing something wrong but I am so new to Java that I have no idea where I made the wrong turn or if I am even heading in the correct direction. Any help in the proper code structure of using market.isHidden() would be greatly appreciated.


"isHidden" checks if its hidden or not, you are looking for "setHidden(true)"
Why alex mentioned "isHidden()" is because the Red Planet Code checks to see if the market isHidden, and if its true, it wont run the mentioned code, which you can achieve by using setHidden.
But keep in mind that setting a Market to Hidden does more than just that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2023, 12:09:14 PM
It would also be nice if there was a way to access them directly, without having to fetch them via the weapons. Though I suppose it's that way because these slots are, unlike the global hull spec, unique per ship and only generated for mounted weapons.

EDIT: Ok, I swear this worked yesterday...but now multiple ships on the field are interfering with eachother...maybe I don't understand this as well as I thought...

I was going to say... yeah, this isn't going to work at all, they're all shared. The only way to do this is to call WeaponAPI.ensureClonedSpec() and then adjust the *weapon* spec to move the firing-points around.

Alex, thank you so much for all your help! I released a patch that prevents the tooltip maker from being saved but doesn't change the way the intel plugins are saved. Being confident that that is the correct solution is a huge weight off my mind.

Nice!

I though so too, but after setting it to transient I couldn't load a test save. Maybe because I didn't configure xstream for that class? *shrug* It doesn't appear in the save file now that it's set to null all the time, so I'll just have to put up with it being there until the next breaking update.

Hmm - last time I did this was yesterday, so just making it transient definitely isn't the problem and does *not* require any config changes to xstream. The general use pattern is to make sure to initialize the field in your Object readResolve() {...} method. That should make sure that by the time anything tries to access it it's not null.

Well, this is for lists and such; for a tooltip maker I guess you'd just need to check anywhere you use it.


I originally based this off of the iterator used for the PD AI . The above works as long as the "jeff" condition is met, but it applies the effects to all the relevant weapons on the ship, not just the one that meets the requirement. I suspect that the ship.getMutableStats() is to blame, but is there anyway to transition from weapon to getMutableStats to allow them to be used without applying to everything?

Yeah, you're making a change to a stat that applies to every weapon on the ship. What you want to do - to affect specific weapons like you're trying to - is to add an implementation of WeaponRangeModifier the ship, via ship.addListener(). The HighScatterAmp class has a commented out example of how one might do that.


Is there a method in the API, outside of the VisualPanelAPI showPlanetInfo(), that can be used to display the Planet Graphic?
Would be quite useful to have for Custom UI Screens.

Ahh, I don't believe so; my apologies. I definitely see what you mean, though, that'd be very nice. Not sure when/if I'll have time to add this sort of thing, but I'll keep it in mind!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on March 10, 2023, 12:17:52 PM
Quote
   
Quote
Is there a method in the API, outside of the VisualPanelAPI showPlanetInfo(), that can be used to display the Planet Graphic?
    Would be quite useful to have for Custom UI Screens.
Ahh, I don't believe so; my apologies. I definitely see what you mean, though, that'd be very nice. Not sure when/if I'll have time to add this sort of thing, but I'll keep it in mind!

Nothing to important as of now (atleast for me), would just be nice to have for my Debug UI, so that it could display a planet, and not its flat texture.
Would definitly have its other useages aswell though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 10, 2023, 12:50:13 PM
Yeah, you're making a change to a stat that applies to every weapon on the ship. What you want to do - to affect specific weapons like you're trying to - is to add an implementation of WeaponRangeModifier the ship, via ship.addListener(). The HighScatterAmp class has a commented out example of how one might do that.

I have actually done that successfully for base range modifications, I'm looking to do stuff like rate of fire, flux costs, ammo/sec, etc. Those aren't present in the regular modifier interfaces, is it possible to implement them from their "home" file or would you need them to be in a custom interface file, if that's possible to do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 10, 2023, 08:04:49 PM
Tracked down a savegame load failure a couple of people were having with Nex. Now I'm like, why does this happen??

Context: I have a CampaignFleetAPI stored in an intel item. I was trying to inflate the fleet in readResolve, but this caused an NPE.
It turns out, trying to access the fleet's faction data in any way causes the NPE, because the faction doesn't have its spec loaded:

Code: java
	FactionAPI faction = offeredFleet.getFaction();
Faction trueFaction = (Faction)faction;

/* Uncomment this line to reload trueFaction's spec and thus prevent the exception that breaks loading the game */
/* trueFaction.getSpec(); */
log.info(String.format("Preparing to inflate merc fleet for faction %s", faction));
log.info(String.format("Faction name is %s", faction.getDisplayName()));
Update: There's a problem with this workaround, the code compiled on Windows is incompatible with the Linux version of the game (and vice-versa) due to differing obsfucated names of methods. (Even though the obsfucated methods aren't called directly from mod code)
e.g. loading the save with a Linux-built jar while on Windows:
Caused by: java.lang.NoSuchMethodError: com.fs.starfarer.campaign.Faction.getSpec()Lcom/fs/starfarer/loading/if;
   at exerelin.campaign.intel.merc.MercContractIntel.readResolve(MercContractIntel.java:82)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at com.thoughtworks.xstream.core.util.SerializationMembers.callReadResolve(SerializationMembers.java:78)
   ... 322 more

The other way around, taken from someone's post in my thread:
cause-exception     : java.lang.NoSuchMethodError
cause-message       : com.fs.starfarer.campaign.Faction.getSpec()Lcom/fs/starfarer/loading/J;
method              : exerelin.campaign.intel.merc.MercContractIntel.readResolve()
class               : exerelin.campaign.intel.merc.MercContractIntel
required-type       : exerelin.campaign.intel.merc.MercContractIntel

(Gotta say, obsfucated method names are pretty annoying in general, it makes a bunch of errors people sometimes have impossible to easily figure out)

I expect I'll just slap a try-catch block there and accept that the fleet may not be reinflated on load sometimes, but in the meantime is there a workaround?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 10, 2023, 08:48:48 PM
I have actually done that successfully for base range modifications, I'm looking to do stuff like rate of fire, flux costs, ammo/sec, etc. Those aren't present in the regular modifier interfaces, is it possible to implement them from their "home" file or would you need them to be in a custom interface file, if that's possible to do?

Ah, gotcha. It's not set up to be modified per-weapon this way.


Context: I have a CampaignFleetAPI stored in an intel item. I was trying to inflate the fleet in readResolve, but this caused an NPE.
It turns out, trying to access the fleet's faction data in any way causes the NPE, because the faction doesn't have its spec loaded:

...

I expect I'll just slap a try-catch block there and accept that the fleet may not be reinflated on load sometimes, but in the meantime is there a workaround?

I think - as you say - the workaround is to not do this in readResolve() and have the code handle the fleet not being inflated/inflating it when needed etc. If too many things all *have* to get their data members set up in readResolve() and start kicking other classes to do some data initialization to make that possible it's pretty easy to end up in a circular dependency type of situation. IIRC this happened to me at one point when going down a very similar rabbit hole.

Though, the way you're trying it - doing a very targeted .getSpec() to just init a specific field, and one not dependent on anything that can be in a savefile - *is* pretty safe. Let me add FactionAPI.initSpecIfNeeded().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on March 11, 2023, 12:37:41 AM
"isHidden" checks if its hidden or not, you are looking for "setHidden(true)"
Why alex mentioned "isHidden()" is because the Red Planet Code checks to see if the market isHidden, and if its true, it wont run the mentioned code, which you can achieve by using setHidden.
But keep in mind that setting a Market to Hidden does more than just that.
That worked, thank you so much. Pretty bonehead move on my part now that I see it. :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 11, 2023, 04:32:56 AM
Ah, gotcha. It's not set up to be modified per-weapon this way.

Thanks for the response, it's nice to know what is and isn't currently possible as to pursue more feasible endeavors.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on March 11, 2023, 08:17:45 AM
Does anyone know if "onHitEffect": triggers with "behaviorSpec":{"behavior":"PROXIMITY_FUSE", ???

I'm hoping not but it would be good to know either way.

Edit: Nevermind, just found a dirty way to test it and it appears not  :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 13, 2023, 12:27:30 AM
I think I understand the mechanics of how missiles work, I would appreciate if anyone could confirm/deny/correct my potentially flawed body of knowledge.


Just looking muck about with a Missile Hullmod which alters some of these stats and wanted a firmer understanding before I mess about too much with them.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 13, 2023, 01:11:41 PM
is there a better way than this to set a portion of a beam's damage to hard flux?
This does work, though I seem to remember that there was a method for it it that just let you set a fraction of damage dealt to be hard flux
also for clarification, is there a specific reason to use .getModifier().modifyX() & returning the mod id over just manually setting the damage & returning null?

code
Code
    public static class palindromeBuiltinBeamHardFluxListener implements DamageDealtModifier {

           @Override
        public String modifyDamageDealt(Object param, CombatEntityAPI target, DamageAPI damage, Vector2f point, boolean shieldHit) {

            if (param instanceof BeamAPI) {
                if (((BeamAPI) param).getWeapon().getId().equals("SBSS_palindromeBuiltin_Pulse")) {
                    Global.getCombatEngine().applyDamage(target, point, (damage.getDamage() * damage.getDpsDuration()) / 2f, damage.getType(), 0f, false, false, ((BeamAPI) param).getSource());
                    damage.getModifier().modifyMult("the sneaky", 0.5f);
                    return "the sneaky";
                }
            }

            return null;
        }
    }
[close]

edit : cleaned up my code a little
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 13, 2023, 03:33:18 PM
  • “Launch speed” is the initial speed at which the missile is fired from the ship. My assumption is it travels at this speed for 1 second covering the same amount of distance. Using the Reaper Torpedo as an example it has a Launch Speed of 100, so I assume it travels 100 units before the next step.
This is incorrect, the missile starts doing whatever it's going to do - depending on its AI - as soon as it's launched. In the case of the Reaper and other dumbfire missiles, it'll just accelerate immediately.

is there a better way than this to set a portion of a beam's damage to hard flux?

Not 100% sure, but this looks fine to me!

also for clarification, is there a specific reason to use .getModifier().modifyX() & returning the mod id over just manually setting the damage & returning null?

Yes. The damage object is persistent in some cases - for example, a beam, or a projectile that passed through missiles and deals damage multiple times. The id allows the damage modifiers to be cleaned up and the damage restored to its original state. Otherwise e.g. your half-damage modifier would have already been applied next time your damage modifier plugin runs.[/list]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 13, 2023, 11:24:15 PM
is it possible to force beam spec weapon actually load and render the _barrel sprite ?
even if it deosn't actually recoil? for purposes of manually handling it via script
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on March 14, 2023, 09:16:16 AM
how do I make a hullmod apply an effect only to weapons of a certain size?
eg. apply a range and damage buff to only mediums and debuff smalls
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 14, 2023, 05:27:04 PM
is it possible to make a hullmod's tooltip expandable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 14, 2023, 07:00:01 PM
how do I make a hullmod apply an effect only to weapons of a certain size?
eg. apply a range and damage buff to only mediums and debuff smalls

As someone who's just been attempting to do similar, it seems that while range or base range can be done for different weapon sizes, it appears that you cannot currently alter damage for weapon sizes, types yes, sizes no.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 15, 2023, 02:45:05 AM
is it possible to make a hullmod's tooltip expandable?

yes, technically

you can have your addPostDescriptionSection check for key presses sing Keyboard.isKeyPressed(); from lwjgl & use that to toggle a boolean that shows the extra stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 15, 2023, 05:45:28 AM
is it possible to make a hullmod's tooltip expandable?

yes, technically

you can have your addPostDescriptionSection check for key presses sing Keyboard.isKeyPressed(); from lwjgl & use that to toggle a boolean that shows the extra stuff.
that's actually backwards
i was wondering if i could hijack the tooltip expander to do stuff instead of actually expanding the tooltip
which i can do. but not with hullmod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 15, 2023, 06:00:07 AM
So I've been testing the following boolean statement.
Code
boolean turn1 = weapon.getTurnRate() > 25f;
At current I have it hooked up to a listener on a weapon range modifier for testing purposes. Problem is it seems to be getting the weapons turn rate speed + it's idle bonus speed. What this means in testing using a light autocannon which shouldn't not get the boost and a light mortar that should, that both get the bonus, at least until you start firing which drops the bonus speed and invalidates the conditions for the light autocannon.

Is there anyway to get the unmodified turn speed? I couldn't seem to find a way at the time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 16, 2023, 11:17:09 AM
how do I make a hullmod apply an effect only to weapons of a certain size?
eg. apply a range and damage buff to only mediums and debuff smalls

You can add a DamageDealtModifier to the ship. See the EnergyWeaponMastery skill class for an example of doing this, or HighScatterAmp for doing something similar but not from a hullmod.

is it possible to force beam spec weapon actually load and render the _barrel sprite ?
even if it deosn't actually recoil? for purposes of manually handling it via script

I don't believe so.

So I've been testing the following boolean statement.
Code
boolean turn1 = weapon.getTurnRate() > 25f;
At current I have it hooked up to a listener on a weapon range modifier for testing purposes. Problem is it seems to be getting the weapons turn rate speed + it's idle bonus speed. What this means in testing using a light autocannon which shouldn't not get the boost and a light mortar that should, that both get the bonus, at least until you start firing which drops the bonus speed and invalidates the conditions for the light autocannon.

Is there anyway to get the unmodified turn speed? I couldn't seem to find a way at the time.

Hmm - weapon.getSpec().getTurnRate()? This will not include the effect of stuff like Advanced Turret Gyros etc; if you really needed that you could compute the value using the relevant turn rate stat for the weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ciago92 on March 16, 2023, 01:14:43 PM
I'd like to be able to design the system I spawn in when I start a new game, and I'm hoping to be able to have it change based on selections made in the new game menus*. Are there any mods out there that do anything in the same ballpark (and hopefully would also be okay with me using their code as a template)?


*Basically like Nexerline in design (sliders for numbers, and various options set through use of the menus) except with options like number of randomly generated planets, number of volcanic planets, number of terran planets, etc. Maybe even something like the own faction planet modifier Nex has, though hopefully in the menus before setup as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on March 16, 2023, 06:55:06 PM
I'd like to be able to design the system I spawn in when I start a new game, and I'm hoping to be able to have it change based on selections made in the new game menus*. Are there any mods out there that do anything in the same ballpark (and hopefully would also be okay with me using their code as a template)?


*Basically like Nexerline in design (sliders for numbers, and various options set through use of the menus) except with options like number of randomly generated planets, number of volcanic planets, number of terran planets, etc. Maybe even something like the own faction planet modifier Nex has, though hopefully in the menus before setup as well.

Adverary (https://fractalsoftworks.com/forum/index.php?topic=25821.0) lets you create a customizeable starsystem with outside configs if its just for personal use.
My own Library mod Lunalib lets you create ingame mod configs which can be changed before new game creation, which you could use to modify your systems generation. (https://fractalsoftworks.com/forum/index.php?topic=25658)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 16, 2023, 08:11:33 PM
Hmm - weapon.getSpec().getTurnRate()? This will not include the effect of stuff like Advanced Turret Gyros etc; if you really needed that you could compute the value using the relevant turn rate stat for the weapon.

I should have added I already tried that methodology, it did not work.
(https://i.imgur.com/QWb3Csx.png)
This is what I got attempting to write it out manually and if I tried to compile it after I get this:
(https://i.imgur.com/RLXeegM.png)
I went and had a look inside of WeaponSpecAPI and there's no entry for getTurnRate in there only get/setTurnRateStr which is just the string entry for turn rate if I'm correct.

For context I want to make a hullmod that can set the PD tag to True if a number of conditions are met and one of those is a base turn speed of X or higher.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on March 17, 2023, 06:27:34 AM
Is it possible to modify the AI vs AI auto-combat logic? For example, if I want to make the combats last longer or bias  fights that include an AI fleet from the player's faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on March 17, 2023, 08:20:50 AM
Does anyone know how to make a module turn around properly? I tried putting axial rotation and anchor rotation on it but it refuses to turn around like the shield modules on high tech stations

also how to make ship visual appear before obtaining a ship? like how bar missions do it, preferably without using mem flags
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2023, 10:14:29 AM
I went and had a look inside of WeaponSpecAPI and there's no entry for getTurnRate in there only get/setTurnRateStr which is just the string entry for turn rate if I'm correct.

Ah! Must only be in the dev version at this point; it'll be available in the next release.


Is it possible to modify the AI vs AI auto-combat logic? For example, if I want to make the combats last longer or bias  fights that include an AI fleet from the player's faction.

You could provide your own implementation of BattleAutoresolverPluginImpl that could do that. To make the combat last longer - I don't think you could modify the time between "rounds" but you could have your plugin's resolve() method do less damage to each fleet so the overall battle would be longer.

Does anyone know how to make a module turn around properly? I tried putting axial rotation and anchor rotation on it but it refuses to turn around like the shield modules on high tech stations

Hmm. I'd suggest copy-pasting the shield module and making incremental changes to see what's making it not work in your case, then.

also how to make ship visual appear before obtaining a ship? like how bar missions do it, preferably without using mem flags

Take a look at the HandMeDownFreighter class, the callAction() method specifically.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 18, 2023, 12:59:00 PM
is there a way to make a mine not collide with anything but still register as a danger to the AI?
Looking at the reality disruptor, it's got almost everything I want there, but since it uses a ROCKET type projectile it can't decelerate to it's top speed
(or could I just use a PHASE_CHARGE type proj w/ no collision class & copy the rest from the reality disruptor?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 18, 2023, 04:38:41 PM
Ah! Must only be in the dev version at this point; it'll be available in the next release.

Cheers, I can just put the idea on the backburner for now then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Weavy on March 19, 2023, 03:43:18 PM
Hey so I want to make an UI mod, just have the player's portrait show up in the event screen, like when you're talking to someone, any time you make text decisions basically.
Have no ideea where to start though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 19, 2023, 04:22:25 PM
question
is it possible to somehow embed into TooltipMakerAPI or CustomPanelAPI an inventory item (be it a commodity, a special item, or a weapon), so that it would behave the same way as it does in the inventory on hover, display the native popup info tooltip (and not a manually recreated copy thereof)?
or maybe embed a 1x1 cell of loot cargo window, and put a specified item in there?
something similar to how addShipList works
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on March 19, 2023, 08:18:41 PM
could you add a setter for wing size launched from a launch bay?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2023, 08:36:21 AM
is there a way to make a mine not collide with anything but still register as a danger to the AI?
Looking at the reality disruptor, it's got almost everything I want there, but since it uses a ROCKET type projectile it can't decelerate to it's top speed
(or could I just use a PHASE_CHARGE type proj w/ no collision class & copy the rest from the reality disruptor?)

I think so, yeah. Also, I believe ROCKET *would* decelerate to its top speed.

Hey so I want to make an UI mod, just have the player's portrait show up in the event screen, like when you're talking to someone, any time you make text decisions basically.
Have no ideea where to start though.

Not sure offhand how you'd do that without changing literally every interaction where you want that to happen, hmm.



question
is it possible to somehow embed into TooltipMakerAPI or CustomPanelAPI an inventory item (be it a commodity, a special item, or a weapon), so that it would behave the same way as it does in the inventory on hover, display the native popup info tooltip (and not a manually recreated copy thereof)?
or maybe embed a 1x1 cell of loot cargo window, and put a specified item in there?
something similar to how addShipList works

Hmm - have you tried TooltipMakerAPI.showCargo()? It's intended as the addShipList() equivalent for cargo.


could you add a setter for wing size launched from a launch bay?

Sorry! Not that simple, unfortunately. Your best bet might be something like how ReserveWingStats does it but with a very very long duration for the replacement fighters... and probably tracking the number of fighters with a script and fudging things as needed. Not 100% sure on the details or whether this could be *quite* made to emulate more fighters in a wing, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Weavy on March 21, 2023, 09:42:16 AM

Hey so I want to make an UI mod, just have the player's portrait show up in the event screen, like when you're talking to someone, any time you make text decisions basically.
Have no ideea where to start though.

Not sure offhand how you'd do that without changing literally every interaction where you want that to happen, hmm.


Wow that sounds like it'd be a lot of work. Thanks for the answer
I don't know much about gui technology honestly, so I was hoping it was gonna be something simple, like a base template file for the event screen where you could just plug in components and it'd render them conditionally, like asp
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on March 21, 2023, 10:01:25 AM
could you add a setter for wing size launched from a launch bay?

Sorry! Not that simple, unfortunately. Your best bet might be something like how ReserveWingStats does it but with a very very long duration for the replacement fighters... and probably tracking the number of fighters with a script and fudging things as needed. Not 100% sure on the details or whether this could be *quite* made to emulate more fighters in a wing, though.

i was actually looking to decrease the amount of fighters in a wing. thanks though, going to stick with reducing launch bays to 1 and just having a less potent effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 21, 2023, 05:44:27 PM
Hmm - have you tried TooltipMakerAPI.showCargo()? It's intended as the addShipList() equivalent for cargo.
i did, and it works, and i was using it quite a lot before asking
however, unlike addShipList, it does not produce an info tooltip on mouse hover
unless there's some extended option or method to allow that
nor does it allow to choose the icon size
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on March 22, 2023, 10:11:08 AM
Having some issues with my mod and thought it might be of some interest.
Spoiler
Spoiler
70396 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException: com.fs.starfarer.campaign.BaseLocation$LocationToken cannot be cast to com.fs.starfarer.campaign.BaseCampaignEntity
java.lang.ClassCastException: com.fs.starfarer.campaign.BaseLocation$LocationToken cannot be cast to com.fs.starfarer.campaign.BaseCampaignEntity
   at com.fs.starfarer.campaign.BaseLocation.getEntityById(Unknown Source)
   at fleetjour.scripts.panel.Common.findTargetEntity(Common.kt:85)
[close]

What basically happens is that I fetch SectorEntityToken ID of the system's center through getCenter(); store this ID in field of my class, and then fetch SectorEntityToken by this ID through public SectorEntityToken getEntityById(String var1).

BUT. If the star system in question is a nebula, it has LocationToken as its center, while getEntityById method has this code:

Code
        if (this.idToEntity.containsKey(var1)) {
            BaseCampaignEntity var2 = (BaseCampaignEntity)this.idToEntity.get(var1);
            if (var2.getContainingLocation() != null && var2.getContainingLocation().getAllEntities().contains(var2)) {
                return var2;
            }
        }
[close]
And that is the source of my crash right there, since LocationToken doesn't cast to BaseCampaignEntity. The question is: is this a vanilla implementation shortcoming or am I simply doing it wrong? I'm able to get rid of the crash by retrieving star of the system instead of its center, so it's nothing major - just putting this out there.

A little follow-up for these damned nebulas and their goddamned LocationToken centers: Misc.getDistanceToPlayerLY() produces NPE when passed nebula center SET in unexplored system and player fleet SET sitting in another star system.

Spoiler
Code
104820 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.util.Misc.getDistanceToPlayerLY(Misc.java:594)
at fleetjour.scripts.panel.EntitySelectorPanel.shouldNotDisplayByDistance(EntitySelectorPanel.kt:176)
at fleetjour.scripts.panel.EntitySelectorPanel.createEntitiesSelector(EntitySelectorPanel.kt:135)
at fleetjour.scripts.panel.WriterPanelAssembly.renderEntitiesContainer(WriterPanelAssembly.kt:186)
at fleetjour.scripts.panel.WriterPanelAssembly.assemblePanel(WriterPanelAssembly.kt:94)
at fleetjour.scripts.EntryWriter.createLargeDescription(EntryWriter.kt:96)
[close]

Not asking anything since I can probably solve this by cramming more checks in the code, just thought this could be worth looking at.

Edit: examination with a debugger reminded me that I'm actually working here with a nebula's star, and ID of said star, when passed as an argument to the infamous getEntityByID(), returns null. In other words, idToEntity HashMap of the nebula does not contain the object that is held in the "star" field of the nebula star system instance.

The more I look at this, the more I get a feeling that this is me making some stupid mistake. Wouldn't turn down a help.

Edit 2: managed to butcher my way through the issue with obscene amounts of dirty checks, though I'm sure it will break eventually because of some case I did not foreseen. What's unfortunate is that I cannot make it any less hacky because API seems to behave in... remarkable ways.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 22, 2023, 06:16:50 PM
Get the nebula's center, not its star, then get the hyperspace anchor, then get LY dist of that to the player.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on March 22, 2023, 07:28:23 PM
Get the nebula's center, not its star, then get the hyperspace anchor, then get LY dist of that to the player.

Right; the issue with center is that it's a LocationToken. It gives ClassCastException when retrieved by ID from a starsystem instance, and so in my code I avoid all those. Another thing of note that it was not the wrong choice of entity vs its anchor in hyperspace kind of issue, since the Misc.getDistanceToPlayerLY() is supposed to handle that by calling entity.getLocationInHyperspace() in return block, and in fact, other entities in-system do not require separately getting their anchors.

Thanks for the advice though; so far I solved my issue, but will keep your method in mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on March 23, 2023, 05:43:21 PM
I want to create a tug that carries pods, like modules on a station. Are there any examples of how to add a module to a ship? I tried but got a null reference exception.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 23, 2023, 06:30:22 PM
i did, and it works, and i was using it quite a lot before asking
however, unlike addShipList, it does not produce an info tooltip on mouse hover
unless there's some extended option or method to allow that
nor does it allow to choose the icon size

Ah, gotcha! Not sure how I can do about this right now, but that'd be a nice improvement to make to it at some point.

A little follow-up for these damned nebulas and their goddamned LocationToken centers: Misc.getDistanceToPlayerLY() produces NPE when passed nebula center SET in unexplored system and player fleet SET sitting in another star system.

java.lang.NullPointerException
   at com.fs.starfarer.api.util.Misc.getDistanceToPlayerLY(Misc.java:594)
   at fleetjour.scripts.panel.EntitySelectorPanel.shouldNotDisplayByDistance(EntitySelectorPanel.kt:176)
   at fleetjour.scripts.panel.EntitySelectorPanel.createEntitiesSelector(EntitySelectorPanel.kt:135)
   at fleetjour.scripts.panel.WriterPanelAssembly.renderEntitiesContainer(WriterPanelAssembly.kt:186)
   at fleetjour.scripts.panel.WriterPanelAssembly.assemblePanel(WriterPanelAssembly.kt:94)
   at fleetjour.scripts.EntryWriter.createLargeDescription(EntryWriter.kt:96)

Looking at the code for Misc.getDistanceToPlayerLY(), this seems like you're literally just passing null in as a parameter. I don't think that method could reasonably throw an NPE in any other way.* (Probably due to the already-established and fixed-in-dev bug with getEntityByd()).

*Unless, like, Global.getSector() returns null, in which case there'd be bigger problems.

I want to create a tug that carries pods, like modules on a station. Are there any examples of how to add a module to a ship? I tried but got a null reference exception.

Hmm, the stations in vanilla? They're probably more complex than what you'd ideally want, though; not aware offhand of any specific mod to look at for something simpler.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 23, 2023, 07:59:45 PM
another question, is it possible to get the image path for the empty mount cover that the weapon slot would be using otherwise if it was empty
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on March 23, 2023, 08:30:19 PM
Looking at the code for Misc.getDistanceToPlayerLY(), this seems like you're literally just passing null in as a parameter. I don't think that method could reasonably throw an NPE in any other way.*

Right, that's entirely correct - the method in Misc isn't a culprit, it's just where the null manifested itself. The issue is with null's origin, which, again, appears to be getEntityByd().

Probably due to the already-established and fixed-in-dev bug with getEntityByd().

But. This isn't the same ClassCastException I reported earlier, doesn't have to do with LocationToken. The syntax that gave me null was (roughly) this:

Code
            val nebula: StarSystemAPI = targetLocation
            var starID: String = nebula.star.id
            var entityInstance: SectorEntityToken? = nebula.getEntityById(starID)   // This returns null.

That's precisely what I wrote in the edit:

Edit: examination with a debugger reminded me that I'm actually working here with a nebula's star, and ID of said star, when passed as an argument to the infamous getEntityByID(), returns null. In other words, idToEntity HashMap of the nebula does not contain the object that is held in the "star" field of the nebula star system instance..

In other words, (going by my memory here), ID of the nebula star (instance type is CampaignPlanet, but it classifies as nebula_center) is something like "system_901", and it's nowhere to be found in idToEntity collection - the planets it contains have ID pattern like "system_901:planet_01".

I solved this issue by working entirely around it; it still might be worth looking at.

Edit: Answer to the question "why do you have to do this the long way with string IDs": because I'm storing the strings in the intel draft item instead of storing SectorEntityToken references. I need the strings.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 23, 2023, 09:10:10 PM
Ah, right, my bad! Looks like the nebula center isn't actually added to its location, it's just there for certain things (such as the map) but doesn't exist as an object in that location.

Edit: Answer to the question "why do you have to do this the long way with string IDs": because I'm storing the strings in the intel draft item instead of storing SectorEntityToken references. I need the strings.

Is there any specific reason for *that*, though? There very well might be but nothing comes to mind. Why not just store the references?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on March 23, 2023, 09:37:01 PM
Ah, right, my bad! Looks like the nebula center isn't actually added to its location, it's just there for certain things (such as the map) but doesn't exist as an object in that location.

Thanks for the clarification; is that something you are going to fix, or is that something modders should be aware of and not use the API in the way I used it?

It's just that over the course of the work on this topic I had far more trouble than usual amount; the issue is that star systems need to have a reliable SectorEntityToken reference in-system that is always not-null. Because now it appears to me that "star" field of the StarSystemAPI was never intended as that, my question is: are we going to get that in the next update with the fixing of getEntityByID() LocationToken ClassCastException? Because I also looked at initNonStarCenter() - it, IIRC, also returns LocationToken. If we are not, I'd really like to have that.

Edit: Answer to the question "why do you have to do this the long way with string IDs": because I'm storing the strings in the intel draft item instead of storing SectorEntityToken references. I need the strings.
Is there any specific reason for *that*, though? There very well might be but nothing comes to mind. Why not just store the references?

Hmm - no any restrictive reason, to be honest. I just figured it would be a better coding practice, as I do vaguely recall you giving some advice on storing IDs of the instances instead of instances themselves (with ShipVariantAPI, etc.), and also I thought that the references to SET persisting somewhere could prevent them from being cleaned in case that was supposed by some other code blocks.

And to look at it that way: if I didn't went the string route, some bugs would be left undiscovered!  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 23, 2023, 09:43:38 PM
Thanks for the clarification; is that something you are going to fix, or is that something modders should be aware of and not use the API in the way I used it?

The latter, I'm afraid. I don't remember the details now but there's likely a reason for how it is.


It's just that over the course of the work on this topic I had far more trouble than usual amount; the issue is that star systems need to have a reliable SectorEntityToken reference in-system that is always not-null. Because now it appears to me that "star" field of the StarSystemAPI was never intended as that, my question is: are we going to get that in the next update with the fixing of getEntityByID() LocationToken ClassCastException? Because I also looked at initNonStarCenter() - it, IIRC, also returns LocationToken. If we are not, I'd really like to have that.

What about storing a star system name and getting the star system using SectorAPI.getStarSystem()? Using an in-system entity to store a system seems a little... roundabout.


Hmm - no any restrictive reason, to be honest. I just figured it would be a better coding practice, as I do vaguely recall you giving some advice on storing IDs of the instances instead of instances themselves (with ShipVariantAPI, etc.), and also I thought that the references to SET persisting somewhere could prevent them from being cleaned in case that was supposed by some other code blocks.

Ah! There was probably a specific reason for whatever I'd said; e.g. for variants if you're storing a stock variant you'd want to store the id since that wouldn't normally even go into the savefile.

And to look at it that way: if I didn't went the string route, some bugs would be left undiscovered!  ;D

Indeed :D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on March 23, 2023, 09:53:41 PM
It's just that over the course of the work on this topic I had far more trouble than usual amount; the issue is that star systems need to have a reliable SectorEntityToken reference in-system that is always not-null. Because now it appears to me that "star" field of the StarSystemAPI was never intended as that, my question is: are we going to get that in the next update with the fixing of getEntityByID() LocationToken ClassCastException? Because I also looked at initNonStarCenter() - it, IIRC, also returns LocationToken. If we are not, I'd really like to have that.

What about storing a star system name and getting the star system using SectorAPI.getStarSystem()? Using an in-system entity to store a system seems a little... roundabout.

I'm sorry, I was very careless with my wording. Actually, it's not that I want to store the system - that's not a problem. I wanted to have a default fallback entity in system that would be reliable to always be there. Here's my current solution:

Spoiler
Code
    fun selectDefaultTargetEntity(intel: EntryWriter): String {
        val targetLocation = this.findTargetLocation(intel)
        if (targetLocation.isHyperspace) {
            val closestAnchor = this.findClosestJumpPoint()
            return closestAnchor.id
        } else if (targetLocation is StarSystemAPI) {
            val targetSystem: StarSystemAPI = targetLocation
            var center: SectorEntityToken? = targetSystem.star
            center?: let {
                center = fetchFirstEligibleEntity(targetSystem)
            }
            return center!!.id
        }
        return Global.getSector().playerFleet.id
    }

    fun fetchFirstEligibleEntity(system: StarSystemAPI): SectorEntityToken {
        val allEntities = system.allEntities
        val filtered = allEntities.filter { token ->
            token is BaseCampaignEntity && !token.isDiscoverable && token.sensorProfile == 0f
        }
        return filtered[0]
    }

And the UI display method that utilizes aforementioned methods:

Code
    fun createEntitiesSelector(assembly: WriterPanelAssembly, selectorPanel: CustomPanelAPI): CustomPanelAPI {
// Boilerplate.
        var inputEntities = this.getSortedEntities(assembly)
        val targetSystem = Common.findTargetLocation(assembly.parent) as StarSystemAPI
        val explored = targetSystem.isEnteredByPlayer
        if (!explored) {
            val defaultEntity = Common.selectDefaultTargetEntity(assembly.parent) // Default entity fetching.
            var entityInstance: SectorEntityToken? = targetSystem.getEntityById(defaultEntity)
            entityInstance?: let {
                entityInstance =  targetSystem.star}
            inputEntities = arrayListOf(entityInstance!!)
        }
// UI display.
    }
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 23, 2023, 09:59:11 PM
Is there any reasonable method to blanket force a faction to use a hullmod if it meets the hullmod's requirements? For context I'm looking to apply cosmetic shield hullmods to various factions.

Also does anyone know if there's any plans to include a setPD_Only & setAnti_Ftr methods to WeaponSpecAPI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 26, 2023, 01:10:30 AM
what are the options for making a module render above weapons mounted on the core ship?
or, alternatively, making the weapons (all, or some in particular), render below modules mounted on the same ship?
i'm sure it was asked 9000 times already
but, what is the current situation in that regard, as it stands now? and is anything planned to change for the next patch, regarding render order?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on March 26, 2023, 06:17:05 PM
Is there a way to open a CustomPanelAPI while in Combat?
Been looking around and ive only found an obfuscated solution, that being to create a new obfuscated implementation of an interaction dialog and starting the custom panel through that.

...
Im specificly looking for this so that i can open a panel in the main menu of the game through an EveryFrameCombatPlugin

Hmm - what about using SettingsAPI.createCustom() and then using EveryFrameCombatPlugin.renderInUICoords() to render it?

... ah, crap, CustomPanelAPI and all the classes it's derived from don't have the relevant rendering/input processing methods exposed; let me add those to the API.

Hope this ends up working, since being able to open CustomPanelAPIs from the Main Menu & Combat would allow me to do something for my Mod Settings Panel like in the gif below, which uses some of the obfuscated code to open one. But that would of course make it not work on MacOS or Linux. Instead i am currently adding an option to the new-game dialog which opens this panel, since the new game dialog allows opening a CustomPanelAPI through its InteractionDialogPlugin, but having it accessible from the Main Menu would be very preferable.

(https://imgur.com/UAhJED8.gif)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 26, 2023, 08:04:35 PM
I'm sorry, I was very careless with my wording. Actually, it's not that I want to store the system - that's not a problem. I wanted to have a default fallback entity in system that would be reliable to always be there.

Ah, gotcha.


Is there any reasonable method to blanket force a faction to use a hullmod if it meets the hullmod's requirements? For context I'm looking to apply cosmetic shield hullmods to various factions.

I think you'd need to override DefaultFleetInflater or some other such.

Also does anyone know if there's any plans to include a setPD_Only & setAnti_Ftr methods to WeaponSpecAPI?

You want to spec.getAIHints().add(<whatever enum value from WeaponAPI.AIHints>), I think.


what are the options for making a module render above weapons mounted on the core ship?
or, alternatively, making the weapons (all, or some in particular), render below modules mounted on the same ship?
i'm sure it was asked 9000 times already
but, what is the current situation in that regard, as it stands now? and is anything planned to change for the next patch, regarding render order?

I don't think it's doable, although it's pretty close to it - module weapons are rendered above all of the ships if the module has a CombatEngineLayers.STATION_WEAPONS_LAYER rendering layer. CombatEngineLayers is exposed in the API, but the ship's current layers aren't; I've just added this method to ShipAPI:

EnumSet<CombatEngineLayers> getActiveLayers();

So, in the next release, removing that layer from the return value of this set should make the module weapon rendering follow the "normal" rules.

... but having it accessible from the Main Menu would be very preferable.

I'll make a note to take a look at that; not sure how doable this is within the given time constraints but maybe a quick and easy way will come to mind. (Very cool, btw!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 27, 2023, 04:05:50 AM
You want to spec.getAIHints().add(<whatever enum value from WeaponAPI.AIHints>), I think.

Did some experimenting and this works a treat
Code
weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.PD_ONLY);

As to DefaultFleetInflater haven't even began to look at stuff like that yet, might just leave it alone for now and just implement my idea for players and maybe variants.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 27, 2023, 04:28:54 AM
I don't think it's doable, although it's pretty close to it - module weapons are rendered above all of the ships if the module has a CombatEngineLayers.STATION_WEAPONS_LAYER rendering layer.
out of curiosity
in what exact scenario does this ever happen?
from my observation, module's weapons always render below parents's weapons, however module itself can render above parent's hull
and if module has BELOW_PARENT hint, then both it and all it's weapons will render below the parent, ignoring all other conditions
in which situation could module's weapons render above parent's weapons?

example:
parent is marked in green
module marked in blue
ring is a decorative weapon, mounted on module
tube-looking thing is a large ballistic turret
the deco mounted on module is rendering above parent, but below all parent's weapons
Spoiler
(https://i.imgur.com/P6dzhnn.png)
[close]
interestingly, this was not always the case, i remember struggling with this exact ship several years ago, and then all module's weapons rendered above all parent's weapons. which was an unwanted effect then, but i utilized it on another ship, to "fake" a module being above parent and all weapons, by simply putting a copy of it's own sprite on the module as a deco weapon. was surprised when it suddenly stopped working out of the blue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 27, 2023, 06:22:37 PM
Ah, double-checking this, I believe only the parent station body gets the STATION_WEAPONS_LAYER hint added to it. So its weapons should render above all of the modules.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 27, 2023, 11:52:50 PM
Ah, double-checking this, I believe only the parent station body gets the STATION_WEAPONS_LAYER hint added to it. So its weapons should render above all of the modules.
not hint, per se
also, what actually applies that property?
just having any station module type slots? something assigned to those slots?
at what point does a ship stop being just a ship and becomes a station
removing the SHIP_WITH_MODULES hint changed nothing
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 28, 2023, 08:33:49 AM
2.5 simple questions -

is there a way to prevent venting from deactivating a system? I've got one that I want the ship to be able to vent during but nothing's stuck out at me
(also is there a way to tell a ship's AI to be more aggressive? that system summons a copy of the ship that uses it & I'd like for it to care less about meaningless things like "self-preservation" & "ammo conservation" :p)

and 2, is there a way to have an "under" sprite on a gun rotate with the weapon? I've got a gun with the RENDER_BARREL_BELOW renderHint & I want the barrel to have something render under it while it recoils, though the "under" image just stays in place

edit : one extra thing that I just noticed - is it possible for a weapon to have a recoiling barrel & glow at the same time?
edit 2 : cross-referenced with another mod and it seems like RENDER_BARREL_BELOW is what's messing with this, is that intentional?

edit 3 : false alarm, it was just the animation type!

 image for context, left is what I want (manually lined up), right is what currently happens
(https://cdn.discordapp.com/attachments/432809739164844032/1090296834683052172/image.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2023, 10:09:57 AM
just having any station module type slots? something assigned to those slots?

For that specific property, just having a module in a module slot, yes. Or, more precisely: when such a module is spawned in combat.


is there a way to prevent venting from deactivating a system? I've got one that I want the ship to be able to vent during but nothing's stuck out at me

and 2, is there a way to have an "under" sprite on a gun rotate with the weapon? I've got a gun with the RENDER_BARREL_BELOW renderHint & I want the barrel to have something render under it while it recoils, though the "under" image just stays in place

No and no, at least as far as I'm aware.


(also is there a way to tell a ship's AI to be more aggressive? that system summons a copy of the ship that uses it & I'd like for it to care less about meaningless things like "self-preservation" & "ammo conservation" :p)

You can override ModPlugin.pickShipAI() and set up a ShipAIConfig with the flags you want. See CoreLifecyclePluginImpl for an example of how Automated ships are made more aggressive. You could also do this without overriding pickShipAI() - I think you could use Global.getSettings().createDefaultShipAI(ship, config) and then ship.setShipAI().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on March 28, 2023, 06:58:15 PM
Is there a way to set a weapon in a slot so that it cannot be removed, aside from the default way of assigning the weapon type in the .ship file? By using
Code
variant.getWeaponSpec(slot).setMountType(WeaponType.BUILT_IN);
I've managed to get a hullmod to set particular weapons to be built in, and they even show a white circle in the fitting window, but the altered weapons can still be removed from the ship.

Also is there a way to temporarily disable the Undo button in ship fitting? I imagine it keeps a snapshot of the player's ship and inventory state. Would it be possible to erase this state or just disable the button for a time?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on March 29, 2023, 02:11:47 AM
is it possible, in any way at all, to spawn a customVisualDialog, or some part thereof, or just a customPanel with buttons in it
from inside the refit screen
without closing the refit screen
or in some other way make an interactive popup with several buttons in it, that pops up in response to some action in the refit screen
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MrTwister on March 29, 2023, 04:40:24 AM
Hey all! I'm playing around with modding again and have a question:

Is it possible to add story point enhancements to certain normal start planet industries during new game sector generation?

For example, this is the code from vanilla Magec system New Maxios, which is adding Corrupted Nanoforge to the Orbital Works industry.
(from Magec.json file)

Is it possible to add a green (story point) enhancement to the orbital works in a similar fashion somehow?
Thanks for your kind tips!

"....

{
   "starSystem":"magec",
   "markets":[
      {
         "entities":["new_maxios"],
         "faction":"independent",
         "size":5,
         "startingConditions":[
            #"hydroponics_complex",
            "population_5",
            "ore_moderate",
         ],
         "industries":[
            "population",
            "spaceport",
            "mining",
            #"lightindustry",
            "orbitalstation",
            "grounddefenses",
            "commerce",
            ["orbitalworks", "corrupted_nanoforge"],
         ],
      },


...."
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 29, 2023, 12:05:25 PM
hello once more everyone. i have question again:
1) is there a way to tell if a NPC is important somehow? like if they are story relevant, or a player contact / future contact?
2) is there a way to get the bonus XP fraction you would get from perm installing a hullmod?
3) is there a way to get the amount of bonus XP the player gets from spending a story point when it gives back 100% bonus XP?
thank you all for all the kind help in the past. it helps me make thing i think are cool =)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 30, 2023, 10:47:57 AM
for that first one you can do Global.getSector().getImportantPeople().containsPerson(person); on a personAPI, it might not be 100% accurate (iirc it won't grab contacts?), but it should be good enough. besides, there's probably a check somewhere else for if a person is a contact, try searching "contact" in baseHubMission; that's where they get generated from.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on March 30, 2023, 01:34:22 PM
Is there a way to offset a weapons range for the AI?

Case example:
I currently have a mining blaster blaster that fires bolts that explode within 20% of max range. The explosion is triggered by "behaviorSpec":{"behavior":"PROXIMITY_FUSE", in the .proj file.
If I set the weapons range to 600 the projectile explodes somewhere between 480-600
However, I would like the AI to treat the weapons range as 500 to prevent wasting flux on an early detonation.

I have found a workaround:
By setting the shot range to a negative, in this case "shotRangeVariance":-0.2, the weapon detonates at up to 20% range after max range
Reduce the weapons range to 500, the AI respects this as the weapons range
Bolts now detonate at 500-600 range

While this is an ideal workaround for the current weapon there are a couple of issues.
1 - It's not intended behavior
2 - It's abusable, if I set the range to -4.0 the player can fire the weapon at up to 2500 but the AI treats it as 500.
3 - There's no damage drop off with range, this is ideal for my use... don't 'fix' it!


So if I have a workaround why am I asking? Because I have a giant shotgun!

(https://i.postimg.cc/Df5yBD34/Untitled.gif)

Ideally I would like to set the range somewhere in the middle of the scatter, the current method only works for the near or far end.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on March 30, 2023, 07:34:47 PM
@Great Wound:

To the best of my knowledge, no, you can't do that. You'd have to write a custom AutofireAIPlugin class that implements the desired behaviors, including getting an appropriate target and obeying AI Flags, and write a ModPlugin that forces your weapon to use this. If you're looking for an implementation to draw inspiration from, feel free to look at StandardAutoFireAI in the MT AI that is in Rebal's files. It does some things you don't need and you'll need to implement your own target-sorter, etc. (i.e., don't just drop this into your project and expect it to compile, heh), but it's better than starting from scratch.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on March 30, 2023, 07:55:46 PM
Or you could write a script that detonates the projectiles in the desired range. Lot easier than writing an AI script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2023, 12:14:59 PM
Is there a way to set a weapon in a slot so that it cannot be removed, aside from the default way of assigning the weapon type in the .ship file? By using
Code
variant.getWeaponSpec(slot).setMountType(WeaponType.BUILT_IN);
I've managed to get a hullmod to set particular weapons to be built in, and they even show a white circle in the fitting window, but the altered weapons can still be removed from the ship.

Also is there a way to temporarily disable the Undo button in ship fitting? I imagine it keeps a snapshot of the player's ship and inventory state. Would it be possible to erase this state or just disable the button for a time?

Ah, sorry - I don't think so, on either count.

is it possible, in any way at all, to spawn a customVisualDialog, or some part thereof, or just a customPanel with buttons in it
from inside the refit screen
without closing the refit screen
or in some other way make an interactive popup with several buttons in it, that pops up in response to some action in the refit screen

Hmm, nothing comes to mind, I don't *think* that's doable.

Is it possible to add a green (story point) enhancement to the orbital works in a similar fashion somehow?
Thanks for your kind tips!

You'd need to do it with code, probably in ModPlugin.onEconomyLoad().

market.getIndustry(Industries.ORBITAL_WORKS).setImproved(true) or something similar!


hello once more everyone. i have question again:
1) is there a way to tell if a NPC is important somehow? like if they are story relevant, or a player contact / future contact?
2) is there a way to get the bonus XP fraction you would get from perm installing a hullmod?
3) is there a way to get the amount of bonus XP the player gets from spending a story point when it gives back 100% bonus XP?
thank you all for all the kind help in the past. it helps me make thing i think are cool =)

ContactIntel.playerHasContact() for contacts.

For being story-relevant,  don't believe so.

For hullmod bonus XP: Misc.getBuildInBonusXP()

3) is a little tricky because there's both immediate bonus XP that the player gets right away, which is enough to gain the next story point, and "deferred" bonus XP which will be given when the player reaches maximum level. In MutableCharacterStatsAPI, there's:
long getBonusXPForSpendingStoryPointBeforeSpendingIt();
Which returns the immediately-gained bonus XP.

But it's missing:
long getTotalBonusAndDeferredXPForStoryPoint();
Which I've just added.


So if I have a workaround why am I asking? Because I have a giant shotgun!

Very cool! I was going to suggest something similar as far as the approach :)

Nothing comes to mind as far as making it use the middle of the range as the effective range, though, hmm.

Or you could write a script that detonates the projectiles in the desired range. Lot easier than writing an AI script.

(Right!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 02, 2023, 05:47:10 AM
I made a missile with the tag PD_ONLY but it still fires at ships when the enemy ship launches missiles (and also fires at the missiles like I want it to). Is there something else I need to set up so that they only target other missiles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 02, 2023, 12:42:00 PM
what type of entity are in-combat asteroids?
I've seen combatAsteroidAPI, though that seems entirely unrelated to everything; it's just got a sprite getter method & doesn't extend CEAPI or anything.

edit much later : also, what's the radius that multiple damage numbers get merged together at? doing something that involves a lot of small projs spread over an area & I'd like for them to all show up as one number 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 02, 2023, 07:24:05 PM
Found an issue with this overload of VisualPanelAPI.showCore(CoreUITabId tabId, SectorEntityToken other, Object custom, CoreInteractionListener listener);

- Be hostile to pirates
- Dock at Garnir or someplace
- Be barred from trading ($tradeMode = NONE)
- Call showCore with an intel param because you wanted to open a specific intel item
Code: java
		InteractionDialogAPI dialog = Global.getSector().getCampaignUI().getCurrentInteractionDialog();
SectorEntityToken entity = dialog.getInteractionTarget();
IntelInfoPlugin intel = null;

dialog.getVisualPanel().showCore(CoreUITabId.INTEL, entity, intel, new NexUtilsGUI.NullCoreInteractionListener());
- As long as you don't close the resulting core UI screen, you can trade with the market by going to the Crew/Cargo tab

To fix this we could get an overload of showCore with a CoreUITradeMode param, but if using the existing overload, maybe it should read $tradeMode from entity memory?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on April 03, 2023, 12:55:16 PM
i noticed two potential bugs when dealing with weapon damage:
1. using modifyPercent on weapon.getDamage().getModifier() did not have any effect on a Hammer's damage
2. modifying weapon.getDamage().getMultiplier does modify the damage, but is shared across all weapons of the same type and is not reset to 1 when combat ends, so the new multiplier carries into the next instance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2023, 11:17:17 AM
I made a missile with the tag PD_ONLY but it still fires at ships when the enemy ship launches missiles (and also fires at the missiles like I want it to). Is there something else I need to set up so that they only target other missiles?

It still needs the regular PD hint, perhaps it's missing that?


what type of entity are in-combat asteroids?
I've seen combatAsteroidAPI, though that seems entirely unrelated to everything; it's just got a sprite getter method & doesn't extend CEAPI or anything.

It's a CombatEntityAPI. The other interface is mainly just to mark it as an asteroid.


edit much later : also, what's the radius that multiple damage numbers get merged together at? doing something that involves a lot of small projs spread over an area & I'd like for them to all show up as one number

Looks like it's hardcoded to 75 units from the center of the floaty to the impact point.


i noticed two potential bugs when dealing with weapon damage:
1. using modifyPercent on weapon.getDamage().getModifier() did not have any effect on a Hammer's damage
2. modifying weapon.getDamage().getMultiplier does modify the damage, but is shared across all weapons of the same type and is not reset to 1 when combat ends, so the new multiplier carries into the next instance.

Right. What you want is missile.getDamage().getModifier().


To fix this we could get an overload of showCore with a CoreUITradeMode param, but if using the existing overload, maybe it should read $tradeMode from entity memory?

Ahh, thank you - nice catch! Added an extra overload with that param. (Hesitant to change the existing behavior just in case it breaks something non-obvious; a bit late in the release cycle for that.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on April 04, 2023, 02:42:58 PM
i noticed two potential bugs when dealing with weapon damage:
1. using modifyPercent on weapon.getDamage().getModifier() did not have any effect on a Hammer's damage
2. modifying weapon.getDamage().getMultiplier does modify the damage, but is shared across all weapons of the same type and is not reset to 1 when combat ends, so the new multiplier carries into the next instance.

Right. What you want is missile.getDamage().getModifier().

that's what i ended up using with a listener, was just confusing at first. i thought WeaponAPIs were unique per-weapon so it made sense to me at the time that i could modify the DamageAPI to modify all the projectiles coming out of the weapon rather than using a listener
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2023, 03:57:54 PM
Ah yeah, that makes sense. It looks like missiles, when they spawn, grab a copy of the weapon spec's DamageAPI instead of using the weapon's DamageAPI, which is why your change wasn't working. It seems like it should be using the weapon's copy of it so that things like you tried work as one might expect, but it's also not something I want to touch right now, not without a very, very good reason.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 06, 2023, 08:12:29 AM
I'm fairly sure my hub mission's stage trigger for Stage.COMPLETED isn't being called after calling setCurrentStage(Stage.COMPLETED, dialog, memoryMap); from code  >:( >:( >:( >:( >:(

Code: java
		beginStageTrigger(Stage.COMPLETED);
this.triggerRunScriptAfterDelay(0f, new Script() {
@Override
public void run() {
Global.getLogger(this.getClass()).info("ho ho ho ho ho");  /* don't get no log message */
}
});
triggerSetGlobalMemoryValuePermanent("$sunrider_mission2_missionCompleted", true);  /* nor my global memory flags */
triggerSetGlobalMemoryValuePermanent("$sunrider_mission2_doneOrSkipped", true);
endTrigger();
If so, this is one of the reasons I don't like doing things in triggers (another reason being that I can't change them after mission generation)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 06, 2023, 09:35:40 AM
Hmm, a bunch of vanilla stuff uses beginStageTrigger(Stage.COMPLETED). Just double-checked and it definitely works in the general case.

A delay of 0 for triggerRunScriptAfterDelay() *should* work - looking at the code, it seems like that case is accounted for - but I suppose there's an outside possibility that's a problem.

Also checked the SVN history and not seeing anything obvious that might account for it working in the dev version and not working for you.

Dumb idea: any chance that the wrong Stage enum is getting imported somehow, either for this or for when you're setting which stage completes the mission? Seems like it'd require having stuff in multiple files (or a fully-qualified wrong Stage, perhaps pasted in by the IDE), though.

Barring that: do you have a minimal mission setup code where it doesn't work so I could try to reproduce it?

If so, this is one of the reasons I don't like doing things in triggers (another reason being that I can't change them after mission generation)

I mean, it'll work for some things and not for others, it's not like you *have* to try to use it for things where it doesn't fit! I definitely wouldn't and don't; there's plenty of times when doing things in other ways makes more sense.

(Let me add BaseHubMission.getTriggers(), though, that seems like it could be useful for some hackery.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 07, 2023, 07:31:00 PM
Quickly implemented a mission inside my test mod.
Download (https://www.dropbox.com/s/sqqdscrzvczejbk/Testmod_missionForAlex_2023-04-08.zip?dl=1); source in jars/ folder
EDIT: forgot to mention, will need LazyLib to compile (but probably not to run)

Dock at a market, go to the bar and select the highlighted mission option.
Instructions are written in the dialog, but partly duplicated here:

Somewhat relatedly, my IDE recently pointed out that the unused-in-vanilla setCompletedKey method exists, which does (some of) what I wanted anyway. Huh.

(Let me add BaseHubMission.getTriggers(), though, that seems like it could be useful for some hackery.)
Oh that might be useful. Might be too late in the dev cycle for it, but could triggers get string IDs with setters, so we can look for a specific trigger?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 08, 2023, 09:56:15 AM
Thank you! *facepalm* it was indeed not getting called if the stage change was via setCurrentStage(), but would if the stage changed "naturally". Fixed this up; my bad - I totally didn't see this in your original post, even though, reading it back again, you said this very clearly. I just didn't make the distinction somehow that it works one way and not the other.

Oh that might be useful. Might be too late in the dev cycle for it, but could triggers get string IDs with setters, so we can look for a specific trigger?

Hmm - seems easy to do in a non-disruptive way. There's already getCurrentTrigger(), so - added a (default null) id field with getters and setters to MissionTrigger. You would:
beginTrigger() // however
getCurrentTrigger().setId(id)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 09, 2023, 06:23:07 AM
There's no significant advantage to using SectorAPI's persistentData over its MemoryAPI, is there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 09, 2023, 07:21:44 AM
There's no significant advantage to using SectorAPI's persistentData over its MemoryAPI, is there?

From what i saw & understand both really are just Hashmaps, but MemoryAPI has some utility wrapped around its Hashmap, were as Persistent Data is quite literally just a Hashmap.
Just using MemoryAPI is probably better in most cases because you always have the variable available in rules.csv in case you ever need them and you can print entity & global entries in devmode.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 09, 2023, 08:45:34 AM
Is there a way for a hullmod to apply an effect to a weapon being removed from a hull? Alternatively is there a way to have a hullmod lock certain weapons into a ship (modular weapons in modular slots) as long as the hullmod is present?

Context: I have a few hullmods both current and planned that alter weaponSpec modifiers that are permanent (even if the hullmod that changed them is removed) I have the means to restore the previous values if the granting hullmod is removed via a hidden hullmod, but it does noting if you just strip the weapons out that are left with their now altered parameters and no way to tell them apart from "clean" versions of the same weapon.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 09, 2023, 09:33:24 AM
There's no significant advantage to using SectorAPI's persistentData over its MemoryAPI, is there?

From what i saw & understand both really are just Hashmaps, but MemoryAPI has some utility wrapped around its Hashmap, were as Persistent Data is quite literally just a Hashmap.
Just using MemoryAPI is probably better in most cases because you always have the variable available in rules.csv in case you ever need them and you can print entity & global entries in devmode.

Right. That said I'd *generally* use persistentData for larger/more complicated objects, i.e. things you wouldn't refer to from rules.


Is there a way for a hullmod to apply an effect to a weapon being removed from a hull? Alternatively is there a way to have a hullmod lock certain weapons into a ship (modular weapons in modular slots) as long as the hullmod is present?

Context: I have a few hullmods both current and planned that alter weaponSpec modifiers that are permanent (even if the hullmod that changed them is removed) I have the means to restore the previous values if the granting hullmod is removed via a hidden hullmod, but it does noting if you just strip the weapons out that are left with their now altered parameters and no way to tell them apart from "clean" versions of the same weapon.

I think there may be a misconception here, what you're doing sounds like it can't work. If you change a weapon spec, it changes the stats for ALL copies of that weapon, there'd be no "clean" version. The only exception is if you call the WeaponAPI.ensureClonedSpec() method in combat, which will make a copy of that weapon spec just for the duration of the combat. Outside of combat, your changes would not be retained.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 09, 2023, 05:11:56 PM

I think there may be a misconception here, what you're doing sounds like it can't work. If you change a weapon spec, it changes the stats for ALL copies of that weapon, there'd be no "clean" version. The only exception is if you call the WeaponAPI.ensureClonedSpec() method in combat, which will make a copy of that weapon spec just for the duration of the combat. Outside of combat, your changes would not be retained.

I definitely did have a misconception, I wrongly assumed that weapon spec changes were by individual weapon and not the entire entry. As a follow up question, can you make dynamic weapon clones for combat? I haven't used any before.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 09, 2023, 06:34:06 PM
Not clones of weapons, but clones of their spec so it can be changed. I think it's been used to, for example, make the fire points move / fire angles change to create beams that sweep, that sort of thing.

WeaponAPI.ensureClonedSpec() is the method that makes a copy of the spec in combat.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 09, 2023, 06:58:52 PM
Not clones of weapons, but clones of their spec so it can be changed. I think it's been used to, for example, make the fire points move / fire angles change to create beams that sweep, that sort of thing.

WeaponAPI.ensureClonedSpec() is the method that makes a copy of the spec in combat.

So if I wanted a hullmod that implements spec changes such as
Code
weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.PD_ONLY);
I would need to use
Code
WeaponAPI.ensureClonedSpec()
and my previous line under
Code
public void advanceInCombat(ShipAPI ship, float amount) {
and that should create spec clones of weapons that meet the conditions only on ships with the hullmod and as soon as combat is over they revert to their default spec?

I just finished up writing and testing this:
Code
public void advanceInCombat(ShipAPI ship, float amount) {

        if (!ship.isAlive()) return;

        List weapons = ship.getAllWeapons();
        Iterator iter = weapons.iterator();
        while (iter.hasNext()) {
            WeaponAPI weapon = (WeaponAPI) iter.next();

            // Not Missile check
            boolean notMissile = weapon.getType() != WeaponAPI.WeaponType.MISSILE;

            // PD tag checkers
            boolean pdAlsoOrig = weapon.getSpec().getAIHints().contains(WeaponAPI.AIHints.PD_ALSO);
            boolean pdAlsoCon = weapon.hasAIHint(WeaponAPI.AIHints.PD_ALSO);
            boolean antiFtrOrig = weapon.getSpec().getAIHints().contains(WeaponAPI.AIHints.ANTI_FTR);
            boolean antiFtrCon = weapon.hasAIHint(WeaponAPI.AIHints.ANTI_FTR);
            boolean pdOnlyOrig = weapon.getSpec().getAIHints().contains(WeaponAPI.AIHints.PD_ONLY);
            boolean pdOnlyCon = weapon.hasAIHint(WeaponAPI.AIHints.PD_ONLY);

            // PD Tag Amalgamation
            boolean posCheck = (pdAlsoOrig || pdAlsoCon || antiFtrOrig || antiFtrCon || pdOnlyOrig || pdOnlyCon);

            if (notMissile && posCheck) {

                weapon.ensureClonedSpec(); {
                    weapon.getSpec().getAIHints().add(WeaponAPI.AIHints.PD);
                    weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.PD_ALSO);
                    weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.PD_ONLY);
                    weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.ANTI_FTR);
                    weapon.getSpec().addTag("pd_up");
                }
            }
        }

It seems to do what I want it to do; setting the PD tag on any weapon that has the PD_ALSO, PD_ONLY or ANTI_FTR whilst removing these tags and as soon as the hullmod is removed it reverts back to normal, can anyone spot any potentially disastrous issues in the above code?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 10, 2023, 07:33:30 AM
This looks good to me! Nice!

(*not to say that I might not be missing something looking it over)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 10, 2023, 10:41:58 AM
Just wondering, would you be willing to say where / how the little armour grid readout in the bottom left of the UI is rendered?
Asking in particular because I've made a little thing that renders the player's (and their target's) armour grid over the ships & I've never been entirely happy with the way it's just a square (even though it's technically accurate for the full grid), I'll put an example screenshot below.

example
(https://cdn.discordapp.com/attachments/825068217361760306/1071208550933733428/image.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 11, 2023, 10:44:48 AM
IIRC it uses the ship sprite as a stencil to only render the grid that overlaps the sprite, if that's what you're asking. As in, using GL_STENCIL_TEST etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 11, 2023, 01:50:19 PM
huh, will need to look into that more, I've done some messing with the stencil test but not much, ty!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on April 12, 2023, 05:06:25 AM
is it possible to move individual barrel of a weapon via script?
like when it fires in alternating mode and barrels recoil one by one
but without firing, just move it directly via everyframe script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jujuteux on April 12, 2023, 02:04:08 PM
What application do you use to make your .bin files for musics?
i've been losing my mind trying to find one that isn't long since dead, doesn't work or even supports .bin files
i even just tried opening a .bin file, putting the .ogg files in there and saving but that doesn't work either for starsector

i'm making a hullmod that makes the game play a music during combat but it doesn't work except for playUISound, which won't pause when the game is paused

here's an excerpt of code:
Code
    boolean ranOnce = false;
    boolean startnext = false;
    float fastcounter = 0;
    List<Beat> beatList; //timecode, size

    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {
        Global.getLogger(this.getClass()).info("corburn spam");
        Global.getSoundPlayer().playSound("system_corrupt_burn_drive_activate", 1f, 1f, ship.getLocation(), ship.getVelocity());
        if(Global.getCombatEngine().getTotalElapsedTime(false) < 5f){
            return;
        }
        if(startnext){//runs once, starts at false until ranOnce check ran
            Global.setSoundPlayer(Global.getSoundPlayer());
            Global.getLogger(this.getClass()).info("cara2");
            Global.getSoundPlayer().playSound("caramelldansen", 1f, 1f, ship.getLocation(), ship.getVelocity());
            Global.getSoundPlayer().pauseMusic();
            startnext = false;

        }
        if(!ranOnce){//runs once, starts at false
            Global.getLogger(this.getClass()).info("cara1");
            Global.getSoundPlayer().playSound("caramelldansen", 1f, 1f, ship.getLocation(), ship.getVelocity());
            ranOnce = true;
            startnext = true;
        }

        startCounter += amount;

        if(isFuntime(startCounter)){
            counter += amount;

            if(counter>0.4f){
                counter -= 0.4f;
                Global.getLogger(this.getClass()).info("corrburn loop");
                Global.getSoundPlayer().playSound("system_corrupt_burn_drive_activate", 1f, 1f, ship.getLocation(), ship.getVelocity());

                ship.getSpriteAPI().setColor(Color.getHSBColor((float) Math.random(), 1f, 1f));

                createRipple(ship, 1f);

            }
        }

for some unknown reason, the game won't play that first everyframe spam, the startnext check nor the ranOnce
but will happily run the "corrburn loop" done every 0.4s (no it's not a clipping issue i think, that sound is like 5s long)

here's what the log looks like (with some excerpts for ease of read
Spoiler
40957 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [miscallenous_main_menu.ogg]
40958 [Thread-9] INFO  sound.OooO  - Playing music with id [miscallenous_main_menu.ogg]
61123 [Thread-3] INFO  com.juj.hullmods.RaveMod  - cara1
61125 [Thread-3] INFO  com.juj.hullmods.RaveMod  - cara2
62127 [Thread-7] INFO  sound.public  - Cleaning up music with id [miscallenous_main_menu.ogg]
62478 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [miscallenous_main_menu.ogg]
62479 [Thread-9] INFO  sound.OooO  - Playing music with id [miscallenous_main_menu.ogg]
63906 [Thread-3] INFO  exerelin.combat.RestoreCommanderPlugin  - Fleet data is null, skipping
(...)
63910 [Thread-3] INFO  exerelin.combat.RestoreCommanderPlugin  - Fleet data is null, skipping
65207 [Thread-7] INFO  sound.public  - Cleaning up music with id [miscallenous_main_menu.ogg]
65481 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [battle_ambience_01.ogg]
65482 [Thread-9] INFO  sound.OooO  - Playing music with id [battle_ambience_01.ogg]
85370 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
85770 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
86169 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
86554 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
(...)
[close]

i thought it was the sound player wanting to get some air at first as the combat starts, so i gave it a 5s delay before starting, but it did precisely nothing extra, it's like the thread waits for the hullmod to play a sound to somehow wipe it off the face of the earth until it decides only the loop is allowed
(it does the same if i swap that other sound with the music)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 13, 2023, 06:17:52 AM
Been mucking about with a timer script in java, but can't seem to get it to work when applying it to a hullmod. Has anyone had any luck in setting up a simple timer to pull a float from?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 13, 2023, 06:46:39 AM
is there a reliable way to determine what fighters have been spawned through FighterLaunchBayAPI.setExtraDeployments() & which ones were just spawned normally?
I've tried checking the index of the fighters in the wing but that just updates automatically (and also currently launching / returning fighters don't get included in the list), so I'm kinda stumped

Been mucking about with a timer script in java, but can't seem to get it to work when applying it to a hullmod. Has anyone had any luck in setting up a simple timer to pull a float from?

I'd use the vanilla intervalUtil class, with the min & max time set to the same value.
though you'll also encounter some wierd behaviour here since there's only once instance of every hullmod running at a time, the timer will advance faster the more ships have it

Vanilla implementations solve this by putting the interval into the ship's customData, though I generally prefer to use an advanceableListener attached to the ship (in applyAfterShipCreation) to entirely replace the hullmod's advance() method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2023, 12:20:33 PM
is it possible to move individual barrel of a weapon via script?
like when it fires in alternating mode and barrels recoil one by one
but without firing, just move it directly via everyframe script?

I don't think so, sorry! It's a single sprite and the game slices it up into pieces and moves them independently and none of that is exposed.

is there a reliable way to determine what fighters have been spawned through FighterLaunchBayAPI.setExtraDeployments() & which ones were just spawned normally?

If you check fighter.getFighterTimeBeforeRefit() and it's not some astronomically high value chances are it's an extra deployment. Unless the system that spawned it gives those deployments an astronomically high uptime.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 13, 2023, 02:11:35 PM
If you check fighter.getFighterTimeBeforeRefit() and it's not some astronomically high value chances are it's an extra deployment. Unless the system that spawned it gives those deployments an astronomically high uptime.

ty, that does work!
though that still doesn't count fighters that are in the launch / landing animation, guessing that's because they technically aren't part of the wing yet or somethng?
Specifically concerned with the launch / landing because I want to have a visual effect immediately apply to the additional fighters when they're launched (and an extra thing when they get recalled)
(also also, would there be a way to have them all immediately launch, instead of the slight delay that setFastReplacements still incurs?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 15, 2023, 08:42:41 AM
How would you cast the return value from "getSavedOptionList" in OptionsPanelAPI in to a non obfuscated equivelance?
I only found the "Option" (from com.fs.starfarer.api.campaign.rules) class but that doesnt seem to be connected to the returned value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 15, 2023, 09:23:53 AM
though that still doesn't count fighters that are in the launch / landing animation, guessing that's because they technically aren't part of the wing yet or somethng?
Specifically concerned with the launch / landing because I want to have a visual effect immediately apply to the additional fighters when they're launched (and an extra thing when they get recalled)
(also also, would there be a way to have them all immediately launch, instead of the slight delay that setFastReplacements still incurs?)

The launched ones should be part of the wing; returning fighters stop being part of the wing when they start to return, i.e. well before the landing animation.

I don't think there's any way to have them all launch right away.

How would you cast the return value from "getSavedOptionList" in OptionsPanelAPI in to a non obfuscated equivelance?
I only found the "Option" (from com.fs.starfarer.api.campaign.rules) class but that doesnt seem to be connected to the returned value.

There's com.fs.starfarer.ui.newui.OptionPanel.Option

What're you trying to do, exactly? Perhaps I can extend the API to make it possible in a more straightforward way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 15, 2023, 02:37:32 PM


How would you cast the return value from "getSavedOptionList" in OptionsPanelAPI in to a non obfuscated equivelance?
I only found the "Option" (from com.fs.starfarer.api.campaign.rules) class but that doesnt seem to be connected to the returned value.

There's com.fs.starfarer.ui.newui.OptionPanel.Option

What're you trying to do, exactly? Perhaps I can extend the API to make it possible in a more straightforward way.

We were looking in to if it would be possible to add "pages" to the dialog options in market screens, as different mods tend to add so many that it runs out of space, so the idea was to get the market dialog through the campaign ui, copy all options, and paste them across different pages if there are enough.

Il look in to what you mentioned.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on April 15, 2023, 02:41:55 PM
We were looking in to if it would be possible to add "pages" to the dialog options in market screens, as different mods tend to add so many that it runs out of space, so the idea was to get the market dialog through the campaign ui, copy all options, and paste them across different pages if there are enough.
(Small context note - the fact that the options are "overflowing" on the base market menu is one of the most common complaints I've seen in recent months, Lukas has been discussing how to fix it, and adding "pages" that can be toggled with a "Next Page" dialogue option was the most realistic approach we landed on.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 15, 2023, 04:04:06 PM
Hmm. Is something like this adequate?

https://i.imgur.com/oent4ik.gif

It does have the shortcoming of losing the default keyboard shortcuts for options above 9. And I'm not super happy that in a way this encourages having more options in these kinds of dialogs; imo they work best UI-wise when the number of options is limited...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 15, 2023, 04:28:13 PM
Quote
There's com.fs.starfarer.ui.newui.OptionPanel.Option

Doesnt seem to exist on my side, might be obfuscated or not on the current build.

Hmm. Is something like this adequate?

https://i.imgur.com/oent4ik.gif

It does have the shortcoming of losing the default keyboard shortcuts for options above 9. And I'm not super happy that in a way this encourages having more options in these kinds of dialogs; imo they work best UI-wise when the number of options is limited...

It would help, because people will add options to the market menu no matter if this exists or not (As is already the case), even when its not the nicest solution.
If you find another solution that would be fine too, its mostly that modders already like adding to the main market menu, and it causes to stack up when you run multiple of such mods.

Also while somewhat off topic and beyond this thread but on a similar issue, would changing the colony structures menu in to a scroll bar be possible aswell? Hartley has made a mod that allows for more than 12 structures, but it is very janky, and 12 structures just isnt enough when playing with mods. Of course the vanilla limit could still just be 12, but a mod could modify the limit, beyond which it would smoothy enable a scroll-bar for any further structures.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 15, 2023, 05:26:05 PM
Doesnt seem to exist on my side, might be obfuscated or not on the current build.

Likely the former.

Also while somewhat off topic and beyond this thread but on a similar issue, would changing the colony structures menu in to a scroll bar be possible aswell? Hartley has made a mod that allows for more than 12 structures, but it is very janky, and 12 structures just isnt enough when playing with mods. Of course the vanilla limit could still just be 12, but a mod could modify the limit, beyond which it would smoothy enable a scroll-bar for any further structures.

Hmm - not super likely to be honest, at least not right now. I'll keep it in mind!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 15, 2023, 06:20:28 PM
Clearly the solution is to fold the main market menu into the colony menu.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 16, 2023, 11:59:56 AM
Where do I change the color od the damage numbers for Hull and armor? I have difficulty distinguishing between teh green and red. I'd like to change one to yellow.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 17, 2023, 07:14:32 AM
Where do I change the color od the damage numbers for Hull and armor? I have difficulty distinguishing between teh green and red. I'd like to change one to yellow.

Oh hmm, these are actually hardcoded. My apologies! I'll make a note about extracting these to settings.json at some point.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: basileus on April 17, 2023, 11:14:35 AM
Is it possible to programmatically create/propagate user input events to be consume()d?

Is there a timeline for a verdict on the Java8 migration?  Will this happen by 0.96 or later?

On a scale of 1 to 10, how excited would modders be to be able to create custom panels using a Webview?  (HTML5, CSS, and JavaScript)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 17, 2023, 11:50:07 AM
Is it possible to programmatically create/propagate user input events to be consume()d?

I don't think so.

Is there a timeline for a verdict on the Java8 migration?  Will this happen by 0.96 or later?

Definitely not 0.96a, *possible* for 0.96.1a but that depends.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Munchkin9 on April 17, 2023, 02:16:34 PM
How do you change the rewards of bar event assignments? Such as SpySat, pirate raid sector bounty, etc?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 17, 2023, 03:03:11 PM
hello once again everyone. i come with questions:
1)is there a way to run code when the player clicks on a item/commodity in there cargo bay?
2)is there a way to save data from a item/commodity or a stack of items to memory (so the data is save persistent)?
3)is there a way to change the cargo space a item/commodity uses using code?
thank you all again for past help =)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on April 17, 2023, 09:50:47 PM
is it possible to get the length of the sound
or detect the event of when playSound stops playing
so i can play several sounds consecutively without delay
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 18, 2023, 01:28:19 AM
Is it possible to implement a SR NOR Latch into advanceInCombat in order to memorise the state of local booleans?
(https://upload.wikimedia.org/wikipedia/commons/a/a8/SR-NOR-latch.png)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 18, 2023, 06:11:19 AM
Is it possible to implement a SR NOR Latch into advanceInCombat in order to memorise the state of local booleans?

in short - yes, you can use code to emulate digital logic. (and strictly speaking, an sr latch is just a boolean variable)

though I suspect that this is a useless non-answer for your case, what are you trying to do specifically?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: tomatopaste on April 18, 2023, 08:45:12 AM
Is it possible to implement a SR NOR Latch into advanceInCombat in order to memorise the state of local booleans?
(https://upload.wikimedia.org/wikipedia/commons/a/a8/SR-NOR-latch.png)

yes
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on April 18, 2023, 09:23:56 AM
Is it possible to implement a SR NOR Latch into advanceInCombat in order to memorise the state of local booleans?

Fortunately, your computer comes with at least several million of these. You can utilize them by declaring a boolean in java and setting it to either true or false.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 18, 2023, 05:32:12 PM
I'm trying to build a Beam with a sound windup during delay, firing loop, and final sound. What, exactly, do fireSoundOne, fireSoundTwo and fireSoundThree do, when a Beam is firing? I originally set it up like the Tachyon Lance... which just defines fireSoundTwo. I want all three sounds to be unique.

I've seen that one of the "new" weapons uses fireSoundThree, but not the other two. What are these doing? There isn't any definition in beam_weapon.sample.

[EDIT]
OK, so 2 is always looping. 1 never appears to play. I'll try defining all three and see what I get.

Tachyon Lance, on the other hand, does not loop and has three sounds. Whaaaa?

[EDIT2]
OK... if all three are defined, you get fireSoundOne, then fireSoundTwo loops until the Beam is finished, but fireSoundThree doesn't play. Weird, lol.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 18, 2023, 05:47:05 PM
fireSoundOne plays once when the beam is fired
fireSoundTwo is the beam loop

fireSoundThree, is, as far as I can tell, not a string that is found anywhere in the codebase, including weapon definition files.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 18, 2023, 05:52:54 PM
It's in Cryoflux.wpn:

"fireSoundThree":"cryoflamer_loop",

(note: I'm still a version behind, so maybe that got fixed in the current build)

So, er, how does the Tachyon Lance do the special noise when it resets? Just an EveryFrame script that catches it and checks state?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 18, 2023, 05:55:56 PM
Ah, that's not in the code now; not sure when that got cleaned up.

So, er, how does the Tachyon Lance do the special noise when it resets? Just an EveryFrame script that catches it and checks state?

I don't know what you mean. It's only got one sound defined in the .wpn file - fireSoundTwo - and it plays an EMP hit effect with its beamEffect script.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 18, 2023, 06:02:02 PM
Ah, so what I think is the third sound must just be the Flux meter resetting or something. I always hear a "whoosh" at the end of firing it in tests and presumed that was what the last sound was for, lol- a cue to the player that the weapon has reset and is ready to shoot again. That seems like something that would be super-easy to do; just play a sound at <location> when weapon reaches <recharge level>. I'll look into that; I'm doing some weapons with pretty absurd chargeup / chargedown times and want clear audio cues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on April 18, 2023, 07:48:59 PM
Is there a way for a hullmod to apply an effect to a weapon being removed from a hull? Alternatively is there a way to have a hullmod lock certain weapons into a ship (modular weapons in modular slots) as long as the hullmod is present?

Context: I have a few hullmods both current and planned that alter weaponSpec modifiers that are permanent (even if the hullmod that changed them is removed) I have the means to restore the previous values if the granting hullmod is removed via a hidden hullmod, but it does noting if you just strip the weapons out that are left with their now altered parameters and no way to tell them apart from "clean" versions of the same weapon.

This isn't a conclusive answer since I'm just an amateur modder myself, but when I attempted to do this, the conclusion I came to was no, it's not really possible. You can do very hacky things with hullmods to simulate item pinning and transformations, such as causing a slot to always have a weapon, or always swap a weapon. You can also do things like look through inventory and delete or swap items as players receive them from unequipping. But what will mess you up is the undo button. Because everything you're trying to do is with hullmods, and hullmods that aren't built in can be removed as well with undo, players hitting undo will cause unintended behavior such as creating duplicates or causing items to disappear, or leaving the wrong type of item in inventory. Also, setting the weapon type to BUILT_IN with a hullmod unfortunately doesn't actually make it built in, and lets players remove a weapon that they now can't re-equip. So far I haven't found a way to have a fire and forget method to change the nature of a weapon and make it unequippable without faking it with inventory swaps behind the scenes, and undo just ruins that on every attempt unless you're doing something very specific such as using an "always on" built-in hullmod to make sure a type of tagged/untagged item never end up in a slot.

One potential workaround I heard but haven't explored is to make a hullmod that describes the weapon changes to players, but doesn't actually make them until combat starts. I have no idea if that'll make a difference, however, even if you could get it to work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 18, 2023, 07:55:21 PM
Is it possible to implement a SR NOR Latch into advanceInCombat in order to memorise the state of local booleans?

in short - yes, you can use code to emulate digital logic. (and strictly speaking, an sr latch is just a boolean variable)

though I suspect that this is a useless non-answer for your case, what are you trying to do specifically?

I have some cosmetic hullmods in the works that dynamically changes the base colour of shields in combat as a ships flux level rises (It's really just 1 script, but with different starting colour values). An issue I ran into however is these new values completely overwrite the colour change from fortress shield. I made an IF statement to counteract this, but now have the issue of an instant colour change as opposed to the gradual transition that fortress shield normally has.

The issue I'm having Is I need to use local booleans and/or floats and they need to be initialised, for everything to work properly they need to start off as false/0f, but as soon as the conditions that change these values are missing they default back to false/0f.

What I'm aiming for is:

- Boolean "Start" is by default false.
- As soon as a ship with fortress shield turns on fortress shield I want "Start" to be true and stay true after fortress shield is turned off.
* With "Start" as a local boolean it will default back to false at this point.
- As soon as fortress shield turns off and shields are still on and "Start" is true a timer will start for about 5 seconds (variable) after this is complete or shields are turned off while "Start" is still true, then "Start" will be reset to false.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 18, 2023, 08:30:49 PM
@ctuncks: Ah, so you want to catch the state of something changing a shield's values in real time, then. So you just check the ship's MutableStats, get the size of bonus for <shield stuff> at the very start when the ship's brand new to the simulation, then check it again during play to see if it's different for <reasons>. If yes, quit running your real-time modification of shield colors, or initiate a fade transition or whatnot.

You could also simply check for the presence of that particular System and check its state, to see if it's on, but that won't be a good generalized solution.

@vicegrip:  The problem here is that hullmods apply their effects in a few specific contexts: before ship creation, when it's just a VariantAPI, or after, and "after" means when it's a full-fledged ShipAPI in the sim or combat.

So you're talking "making them after combat starts" there, but it's easy to implement in the current BaseHullMod system.

So what do you want this to do, exactly, that requires all this? Turn a Decorative into a functional weapon that's effectively like a Built In? If so, doing it in AfterShipCreation() is probably the appropriate time, but there you'll end up with other problems, such as, "what weapon group will this be assigned to", that would require some careful thought.

I've often thought that Hull Mods should have a couple of methods: AfterVariantHasBeenChanged() and AfterHullModHasBeenRemoved() that are specifically triggered by player changes to Variants in the ship editor, to allow for behaviors like this a little more gracefully. The Dock interface is one of the weird places in SS, where it's not quite a ship and it's not quite a Variant, either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 19, 2023, 02:12:05 AM
After studying some of PureTilt's hullmods I believe I've come up with a workable solution to my issue.

Code
public void advanceInCombat(ShipAPI ship, float amount) {

        Map<String, Object> customCombatData = Global.getCombatEngine().getCustomData();

        float shieldTest = 0f;
        if (customCombatData.get("ZDA_Test" + ship.getId()) instanceof Float)
            shieldTest = (float) customCombatData.get("ZDA_Test" + ship.getId());

// How fast shieldTest increases.
        if (ship.getSystem().isOn())
            shieldTest += 0.0175f;

// Upper Limit of shieldTest
        if (shieldTest > 5f)
            shieldTest = 5f;

// How fast shieldTest decerases.
        if (ship.getShield().isOn() && !ship.getSystem().isOn())
            shieldTest -= 0.0175f;

// Lower Limit of shieldTest
        if (shieldTest < 0f)
            shieldTest = 0f;

// Reset of shieldTest when shield is off.
        if (ship.getShield().isOff() && !ship.getSystem().isOn())
            shieldTest = 0f;

        ship.getMutableStats().getBallisticWeaponRangeBonus().modifyFlat("test", shieldTest * 80f);

        customCombatData.put("ZDA_Test" + ship.getId(), shieldTest);

    }

Using custom combat data I can generate a persistent float value that increases/decreases periodically as long as the conditions are true, acting as a pseudo clock, which is good enough for me. While messing about though I did find that custom data doesn't seem to interact well with booleans, even if they're booleans that are derived from the custom data floats.

The above test was just testing the concept and I like to use range for it since it's relatively easy to measure against.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 19, 2023, 10:03:44 AM
Using custom combat data I can generate a persistent float value that increases/decreases periodically as long as the conditions are true, acting as a pseudo clock, which is good enough for me. While messing about though I did find that custom data doesn't seem to interact well with booleans, even if they're booleans that are derived from the custom data floats.

Custom Data is just a Map attached to a CombatEntity, it shouldnt handle primitive types differently than a normal map, so not quite sure what you mean with the "doesn't seem to interact well with booleans" part.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 19, 2023, 12:19:30 PM
is there a way to get a ship's center of mass offset from it's sprite (if that makes sense)?
my particular case is renderAtCenter()'ing (well, doing something equivalent) a sprite, if you just do it without an offset then the final sprite will end up misaligned from the ship 99% of the time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on April 19, 2023, 09:13:09 PM
After studying some of PureTilt's hullmods I believe I've come up with a workable solution to my issue.
That'll work for that specific case, but I'd suggest checking against the values of each shield-related stat's state vs. what it is when the ShipAPI's initialized. Remember, there are other Systems out there that will effect Shields in a different way, but may also be using custom effects. For a general-purpose system, it probably needs a broader approach.

For example, check the value of ship.getMutableStats().getShieldAbsorptionMult().getModifiedValue(). This is pretty cheap (you're fetching an Object's Object reference, then a value from that, then running a very teeny method).

Here's a little cleanup of that code; I hope you find it useful!
Spoiler
public void advanceInCombat(ShipAPI ship, float amount) {
   //If we don't pass Go, then...
   //Note that we're explicitly *not* creating a copy of the custom data here; we're checking it directly. Also, checking for NPE.
   //Populating the custom data should be done in a once-and-done that only applies to ships that need it.
   if (Global.getCombatEngine().getCustomData().get("ZDA_Test" + ship.getId()) != null && Global.getCombatEngine().getCustomData().get("ZDA_Test" + ship.getId())  instanceof Float)
   {
      float shieldTest = 0f;
      shieldTest = (Float) Global.getCombatEngine().getCustomData().get("ZDA_Test" + ship.getId());
      
      //Branch optimizations
      if(ship.getSystem().isActive() || ship.getSystem().isOn() || ship.getSystem().isChargeup()){
         if(ship.getShield() != null && ship.getShield().isOn()){
             shieldTest += 0.0175f;
         }
      } else {
         shieldTest -= 0.0175f;
      }
      //Clean limiter function here
      shieldTest = Math.min(Math.max(shieldTest, 0f), 5f);

      ship.getMutableStats().getBallisticWeaponRangeBonus().modifyFlat("test", shieldTest * 80f);

      Global.getCombatEngine().getCustomData().put("ZDA_Test" + ship.getId(), shieldTest);      
   }
}
[close]

is there a way to get a ship's center of mass offset from it's sprite
Absolutely. Get the ship's hull JSON and read the offsets directly from there.

Here's a working example that gets you most of the way there:

Spoiler
                        //Get all Variants in the game.
         List<ShipHullSpecAPI> theVariants = Global.getSettings().getAllShipHullSpecs();
                        //This uses a Stream... Alex, you've finally updated to Java 7+, right?
         theVariants.forEach(variantID -> {            
            if(variantID != null && variantID.getBaseHull() != null && variantID.getBaseHull().getShipFilePath() != null){
                                        //If nothing borked, we now have something we can go get in the SS filesystem.
               String path = "data/hulls/" + variantID.getBaseHullId() + ".ship";
               //Global.getLogger(YOUR_FANCY_CLASS_NAME_HERE.class).log(Level.ERROR,"Hey, We've Got A Path: " + path);
               
               //Now we look through each mod's sub-directory to find the actual file, essentially.
               for(ModSpecAPI mod : Global.getSettings().getModManager().getAvailableModsCopy()){
                  String modID = mod.getId();               
                  try{
                     JSONObject thisBaseHull = Global.getSettings().loadJSON(path, modID);
                     

                     /*<GET THE OFFSET DATA HERE, STORE SOMEWHERE ELSE>*/

                     //Global.getLogger(YOUR_FANCY_CLASS_NAME_HERE.class).log(Level.ERROR,"Hey, we've found that JSON data you wanted: " + YOUR_DATA_HERE);
                  } catch(Throwable ex) {
                     //Global.getLogger(YOUR_FANCY_CLASS_NAME_HERE.class).log(Level.ERROR,"Oops! We didn't find the JSON at: " + path + " in: " + modID);
                  }
               }
            }
         });
[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 20, 2023, 05:21:32 AM
Is ther eany way in campaign to tell when a ship was built? I.e. The year, month and day in-game when a ship was created? Is there any interaction between game date and ships that I could see as an example?

A couple of things I'd like to do:
I'd like to prevent certain weapons being added before a certain game year.
Have a ship suffer accelerated CR decline if it's older than X years.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 20, 2023, 06:01:34 AM
@ Lukas04

I mucked a little bit more around for whatever reason when I use the custom data floats. they seem to work fine if you just use them as values, but as soon as I use them with an "if" statement (that doesn't alter the float value) whether directly or to set a boolean it seems to lock into the true setting.

@ xenoargh

I copied your example code whole-cloth and it doesn't seem to work the way my previous entry did unfortunately, I have however taken a few pointers from it to pare it down to:
Code
public void advanceInCombat(ShipAPI ship, float amount) {

        Map<String, Object> customCombatData = Global.getCombatEngine().getCustomData();

        float shieldTest = 0f;
        if (customCombatData.get("ZDA_Test" + ship.getId()) instanceof Float)
            shieldTest = (float) customCombatData.get("ZDA_Test" + ship.getId());
       
        if (ship.getSystem().isOn()) {
            shieldTest += 0.0175f;
        } else if ((ship.getShield().isOn() && !ship.getSystem().isOn())) {
            shieldTest -= 0.0175f;
        } else {
            shieldTest = 0f;
        }

        shieldTest = Math.min(Math.max(shieldTest, 0f), 5f);

        customCombatData.put("ZDA_Test" + ship.getId(), shieldTest);

        ship.getMutableStats().getBallisticWeaponRangeBonus().modifyFlat("test", shieldTest * 80f);

    }


Your concerns for other system weirdness is valid, but ultimately I'm only intending to use the code for ships with fortress shield (and it'll be changing colour not ballistic weapon range).

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 20, 2023, 10:12:58 AM
Is ther eany way in campaign to tell when a ship was built? I.e. The year, month and day in-game when a ship was created? Is there any interaction between game date and ships that I could see as an example?

There isn't, no. I think probably the best you could do is track ships present in the player fleet. (You'd probably need to use WeakReference to avoid gradual memory leaks; see SModRecord for an example of that.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 20, 2023, 12:51:46 PM
Absolutely. Get the ship's hull JSON and read the offsets directly from there.

huh, never thought that the .getShipFilePath() method would ever turn out to be useful, ty!

EDIT: and for anyone who cares, this is what my final code ended up looking like, just a tad shorter than xeno's reccomendation :p
code
Code
        try {
            JSONArray coords = Global.getSettings().loadJSON(ship.getHullSpec().getShipFilePath().replaceAll("\\\\", "/")).getJSONArray("center");

            float spriteXoffset = sprite.getWidth() / 2f - coords.getInt(0);
            float spriteYoffset = sprite.getHeight() / 2f - coords.getInt(1);

            /*
            * todo will need to make this account for x offset as well, rn the center of the ship needs to be down the centerline of the ship
            */
           
            offset = (float) Math.sqrt((spriteXoffset * spriteXoffset) + (spriteYoffset * spriteYoffset));

        } catch (JSONException | IOException ignored) {}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: basileus on April 20, 2023, 01:21:04 PM
Code
public void advanceInCombat(ShipAPI ship, float amount) {

        Map<String, Object> customCombatData = Global.getCombatEngine().getCustomData();

        final String key = "ZDA_Test" + ship.getId();
        float shieldTest = customCombatData.get(key) instanceof Float
        ? (float) customCombatData.get(key)
        : 0f;
       
        if (ship.getSystem().isOn()) {
            shieldTest += 0.0175f;
        } else if (ship.getShield().isOn()) {
            shieldTest -= 0.0175f;
        } else {
            shieldTest = 0f;
        }

        shieldTest = Math.min(Math.max(shieldTest, 0f), 5f);

        customCombatData.put(key, shieldTest);

        ship.getMutableStats().getBallisticWeaponRangeBonus().modifyFlat("test", shieldTest * 80f);

    }

I'm not a Java guy, so I am a little curious if the explicit typecasting to (float) is necessary in the immediate aftermath of the instanceof Float check.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AtlanticAccent on April 20, 2023, 03:16:50 PM
Code
public void advanceInCombat(ShipAPI ship, float amount) {

        Map<String, Object> customCombatData = Global.getCombatEngine().getCustomData();

        final String key = "ZDA_Test" + ship.getId();
        float shieldTest = customCombatData.get(key) instanceof Float
        ? (float) customCombatData.get(key)
        : 0f;
       
        if (ship.getSystem().isOn()) {
            shieldTest += 0.0175f;
        } else if (ship.getShield().isOn()) {
            shieldTest -= 0.0175f;
        } else {
            shieldTest = 0f;
        }

        shieldTest = Math.min(Math.max(shieldTest, 0f), 5f);

        customCombatData.put(key, shieldTest);

        ship.getMutableStats().getBallisticWeaponRangeBonus().modifyFlat("test", shieldTest * 80f);

    }

I'm not a Java guy, so I am a little curious if the explicit typecasting to (float) is necessary in the immediate aftermath of the instanceof Float check.

I assume that key is for data only your mod ever reads and writes? In which case I wouldn't bother doing any type checks at all and do a naked cast, ie:
Code
float shieldTest = (float) customCombatData.get(key);
Otherwise, if you really want to do type checking you can try using a try/catch and catch the (potential but highly unlikely) ClassCastException
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 20, 2023, 03:58:45 PM
I assume that key is for data only your mod ever reads and writes? In which case I wouldn't bother doing any type checks at all and do a naked cast, ie:
Code
float shieldTest = (float) customCombatData.get(key);
Otherwise, if you really want to do type checking you can try using a try/catch and catch the (potential but highly unlikely) ClassCastException

One thing worth noting is that this:
float shieldTest = (float) customCombatData.get(key);

Will throw a NullPointerException if the key is not present in the map, so you still want to check to make sure it's present before casting.

So will this:
float shieldTest = (Float) customCombatData.get(key);

However, this will not (note the capital-case Float on both sides:
Float shieldTest = (Float) customCombatData.get(key);

And instead, if the key is not in the map, then shieldTest will be null. So you'd get your NPE when trying to use it in an expression that tries to convert it to a regular float :)

Main point being that you don't strictly speaking need a type check, but you probably want a null check somewhere unless you're very, very careful about how you structure your code and make sure a null is impossible. But probably even then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: basileus on April 20, 2023, 06:02:41 PM
That was insightful.  Thanks to both of you.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: jujuteux on April 21, 2023, 12:53:08 AM
Hi, alex.

i'm currently checking the whole Personality.csv file and trying to add new ones (mainly for changing descriptions and names)
and i bumped on the fact that there's not actually any difference between reckless and aggressive in the csv
(https://i.imgur.com/zwaMrHu.png)
is the whole AI mechanic handled by checking for the name or ID?
that might actually cause some problems since i'm basically duplicating those personalities and just changing names, ID and desc

if it can't be fixed, can you consider making something so you can create your own personalities outside of the csv? like unobfuscating the personality code.

thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 21, 2023, 05:18:54 PM
How do I add a listener to a projectile?

I want to create a projectile that, if shot down by pd, will spawn an emp arc to the nearest target within range. I've added listeners to ships but I don't see a similar method for projectiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 21, 2023, 07:40:32 PM
How do I add a listener to a projectile?

I want to create a projectile that, if shot down by pd, will spawn an emp arc to the nearest target within range. I've added listeners to ships but I don't see a similar method for projectiles.

you can't add a listener directly to a projectile, but I've got a similar thing that I do this (see below) for.

code
here's the onFire effect that adds the fired projectile to a list of projectiles that a "manager" class iterates over
getFirstListenerofClass is a lil method I made that's effectively just Ship().getListeners(classname.class).get(0);, but a little fancified.
Code
public class lightspikeDriverOnFire implements OnFireEffectPlugin {

    @Override
    public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) {

        lightspikeDriverEFS.lsdActualEfs listener = getFirstListenerOfClass(weapon.getShip(), lightspikeDriverEFS.lsdActualEfs.class);

        if (listener == null) return;

        listener.addProj(projectile);

    }
}
and here's the actual manager class, in the form of an EveryFrameWeaponEffect that adds an advanceableListener to the ship (though tbh that could probably just be done in the onfire, check if it's null, if yes add one, if no use the existing one)
Code
public class lightspikeDriverEFS implements EveryFrameWeaponEffectPlugin {

    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
        if (!weapon.getShip().hasListenerOfClass(lsdActualEfs.class)) {
            weapon.getShip().addListener(new lsdActualEfs(weapon.getShip()));
        }
    }

    public static class lsdActualEfs implements AdvanceableListener, DamageDealtModifier {

        protected final ShipAPI ship;
        private final ArrayList<DamagingProjectileAPI> projs = new ArrayList<>();

        public lsdActualEfs(ShipAPI ship) {
            this.ship = ship;
        }

        public void addProj(DamagingProjectileAPI proj) {
            projs.add(proj);
        }

        @Override
        public void advance(float amount) {

            for (DamagingProjectileAPI proj : new ArrayList<>(projs)) {

               /*
               * do your checking here, probably just a CombatEngineAPI.isEntityInPlay(); check on the projectile before spawning the arcs or so
               * also, that for loop creates a new arrayList to prevent concurrentModificationExceptions when removing projectiles from the list so that you don't need to do a second loop over the list
               */
           
            }
        }
    }
}
[close]
this method technically has a few pitfalls (particularly if the projectile is spawned using spawnProjectile() without manually calling the onFire for it), but it works well enoughtm for me to not be bothered by it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 22, 2023, 05:29:14 PM
How do I add a listener to a projectile?

I want to create a projectile that, if shot down by pd, will spawn an emp arc to the nearest target within range. I've added listeners to ships but I don't see a similar method for projectiles.

you can't add a listener directly to a projectile, but I've got a similar thing that I do this (see below) for.

this method technically has a few pitfalls (particularly if the projectile is spawned using spawnProjectile() without manually calling the onFire for it), but it works well enoughtm for me to not be bothered by it

Thank you. With your help I was able to make what I wanted. Code below.

Code
package data.scripts.weapons;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.OnFireEffectPlugin;
import java.util.Random;
import java.lang.Math;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.loading.WeaponSlotAPI;
import com.fs.starfarer.api.combat.GuidedMissileAI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lazywizard.lazylib.combat.CombatUtils;
import com.fs.starfarer.api.combat.listeners.AdvanceableListener;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.console.Console;
import org.lazywizard.lazylib.CollisionUtils;
import com.fs.starfarer.api.combat.FluxTrackerAPI;
import com.fs.starfarer.api.loading.DamagingExplosionSpec;
import com.fs.starfarer.api.combat.listeners.AdvanceableListener;
// import com.fs.starfarer.api.combat.listeners.DamageDealtModifier;
import java.awt.Color;
import java.util.*;
import org.lwjgl.util.vector.Vector2f;
import static com.fs.starfarer.api.util.Misc.ZERO;

public class SFB_Nuclear_Torpedo_OnFireEffect implements OnFireEffectPlugin {

   
    public void onFire(final DamagingProjectileAPI projectile, final WeaponAPI weapon, final CombatEngineAPI engine) {

if (weapon.getShip() != null) {

if (!weapon.getShip().hasListenerOfClass(nuclearListener.class)) {
            weapon.getShip().addListener(new nuclearListener(weapon.getShip()));
}
SFB_Nuclear_Torpedo_OnFireEffect.nuclearListener listener = getFirstListenerOfClass(weapon.getShip(), SFB_Nuclear_Torpedo_OnFireEffect.nuclearListener.class);

listener.addProj(projectile);
}


    }

public static nuclearListener getFirstListenerOfClass(ShipAPI ship, Class listenerClass) {

        if (!ship.hasListenerOfClass(listenerClass)) {
            return null;
        }
        nuclearListener listener = (nuclearListener)ship.getListeners(listenerClass).get(0);
        return  listener;
    }


public static class nuclearListener implements AdvanceableListener /*, DamageDealtModifier */ {

        protected final ShipAPI ship;
        private final ArrayList<DamagingProjectileAPI> projs = new ArrayList<DamagingProjectileAPI>();
private final ArrayList<DamagingProjectileAPI> deadProjs = new ArrayList<DamagingProjectileAPI>();

private static final Color ARC_FRINGE_COLOR = new Color(85, 60, 205, 225);
private static final Color ARC_CORE_COLOR = new Color(235, 175, 235, 255);
private static final int NUM_ARCS = 3f;

        public nuclearListener(ShipAPI ship) {
            this.ship = ship;
        }

        public void addProj(DamagingProjectileAPI proj) {
            projs.add(proj);
        }

public boolean isHarmless(MissileAPI m) {
        return m.isFizzling() || m.isExpired() || m.isFading();
}

        @Override
        public void advance(float amount) {

            Iterator<DamagingProjectileAPI> iter = projs.iterator();
while (iter.hasNext()) {
CombatEngineAPI engine = Global.getCombatEngine();
if (engine.isPaused() ) {
return;
}

DamagingProjectileAPI proj = (DamagingProjectileAPI)iter.next();

if ( isHarmless((MissileAPI)proj) || proj.didDamage() ) {
//projs.remove(proj);
continue;
}


if (proj.getHitpoints() > 300 ) {
continue;
}


java.lang.Object missileAI = proj.getAI();
if (missileAI == null ) {
continue;
}

CombatEntityAPI target = ((GuidedMissileAI)missileAI).getTarget();

//CombatEntityAPI target = proj.getDamageTarget(); // wrong. This is what it damaged
if (target == null) {
continue;
}


Vector2f projPos = proj.getLocation();
Vector2f targetPos = target.getLocation();
float distance = MathUtils.getDistanceSquared(projPos, targetPos) ;
if (distance > 250000f) { // range 500 = 250000
continue;
}

// At this point the projectile should have zero hp, not have done damage, and be within range.

SpawnEMP(target, proj);
Console.showMessage("proj in arraylist " + projs.size());
// clear out dead missles. Need a better way.
if (!deadProjs.contains(proj)){
deadProjs.add(proj);
}

             
           
            }

for (DamagingProjectileAPI deadProjectile : deadProjs) {
if (projs.contains(deadProjectile)) {
projs.remove(deadProjectile);
}
}

deadProjs.clear();

        }

public void SpawnEMP(CombatEntityAPI target, DamagingProjectileAPI proj) {
//Console.showMessage( proj.getHitpoints() + " hp" + " Boom!");
CombatEngineAPI engine = Global.getCombatEngine();
for (int x = 0 ; x < NUM_ARCS; x++) {
engine.spawnEmpArcPierceShields(proj.getSource(),
proj.getLocation(),
proj,
target,
DamageType.ENERGY,
0f, // damage
750f, // emp damage
500f, // range
"shock_repeater_emp_impact", // sound
8f, // thickness
ARC_FRINGE_COLOR, // fringe
ARC_CORE_COLOR // core color
);
}

proj.setHitpoints(0f);
}
    }

}

One difference from yours is that I iterate through the original arraylist instead  of creating a copy inside the advance() method. Isn't creating a copy of the arraylist expensive? Sinec advance runs every frame I'm concerned about performance.

I want to remove the dead projectiles but, like you said, doing so causes an error within the loop. The sources say it should work this way but it gave an error. Anyway, since I don't expect to spam thousands of missiles in a given battle I can live with this. Thanks again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on April 22, 2023, 07:53:12 PM
As a more general question is there any noticeable technical disadvantages of running several mods that would otherwise be in a single amalgamation? I'm contemplating whether I should roll my cosmetic shield hullmods into my current WIP mod or create a separate one just for them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on April 23, 2023, 05:12:28 AM
Not really. AFAIK only the UI replacement mods have to be separate. It is mainly a choice on how you want to present your content to the user.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 23, 2023, 12:24:33 PM
Is there any way to programmatically change the burst size of a weapon during combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Bee on April 23, 2023, 02:55:05 PM
Hey, I'm sure this has been asked before (though I had a quick look and couldn't find it), but how do I make a ship available to use in NPC fleets?

I just got started on trying to make a ship pack mod cause I decided to try kitbashing and found it quite fun, but the first ship I made refuses to appear in my faction's fleets even though I had it prioritized. It doesn't work even if it's the only non-default blueprint I got and it doesn't work if I use console commands to learn all blueprints to ensure that all weapons its variants use can be produced by my faction. I used the ship editor and made sure all variants have goalVariant set to true but the ship still refused to appear in the 'typical heavy patrol' window, no matter how often I pressed 'regenerate'.

I tried setting the rarity in the csv to 1, leaving it blank or setting it to a different number as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 23, 2023, 02:59:17 PM
you'll need at least an entry in default_ship_roles.json as well (look at vanilla for an example), without them the game doesn't know when to spawn the ship so it simply won't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on April 24, 2023, 11:23:44 AM
is there any function that gets called / boolean that I can check right on the final frame of combat?
I'm generating some textures for shader stufftm & I don't want to eat everyone's vram, I know there's CombatEngineAPI.isCombatOver(), but for some reason I've got it in my head that it gets set to true as soon as the "you can claim victory" popup appears & idrk a good way to test that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on April 24, 2023, 12:03:43 PM
is it possible to add a jitter to a piece of hulk??

I can add a jitter to an intact hulk(ship not broken into pieces) but I can't do that for pieces of hulk debris
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on April 24, 2023, 09:35:03 PM
In a ship system's unapply() method, when using MutableShipStatsAPI unmodify() does it unmodify only what was changed in apply() or does it revert the stats to their base values? In other words if a hullmod adds 10% to getEnergyWeaponDamageMult and a ship system adds 50%, would calling unmodify() drop the energy weapon damage to 110% or 100% of the base value?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on April 24, 2023, 09:44:36 PM
Hey, I'm sure this has been asked before (though I had a quick look and couldn't find it), but how do I make a ship available to use in NPC fleets?

I just got started on trying to make a ship pack mod cause I decided to try kitbashing and found it quite fun, but the first ship I made refuses to appear in my faction's fleets even though I had it prioritized. It doesn't work even if it's the only non-default blueprint I got and it doesn't work if I use console commands to learn all blueprints to ensure that all weapons its variants use can be produced by my faction. I used the ship editor and made sure all variants have goalVariant set to true but the ship still refused to appear in the 'typical heavy patrol' window, no matter how often I pressed 'regenerate'.

I tried setting the rarity in the csv to 1, leaving it blank or setting it to a different number as well.

You will need to add loadout variants for the ship. You can see the original in data\world\factions\default_ship_roles.json and should create your own that follows the format of the original, but listing only your ship variants under the appropriate rolls. Upping the hullfrequency\hulls value of your ship in your data\world\factions\(myfaction).faction file should also make the hull appear more frequently in NPC fleets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 25, 2023, 04:38:12 AM
In a ship system's unapply() method, when using MutableShipStatsAPI unmodify() does it unmodify only what was changed in apply() or does it revert the stats to their base values? In other words if a hullmod adds 10% to getEnergyWeaponDamageMult and a ship system adds 50%, would calling unmodify() drop the energy weapon damage to 110% or 100% of the base value?

unmodify() will unmodify all changes made to the stat from everywhere. What you wanna do is use unmodify(id), which will only remove changes of that stat under that id.

So in your apply do something like modifyMult("namehere_shipsystem", 2f) and in your unapply do unmodify("namehere_shipsystem")
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 25, 2023, 01:59:22 PM
hello once more everyone. I'm here to ask way to many questions again. (is this to many questions to ask at once? I ran out of things to code.)
so my questions:
1) is it possible to add a item to the players cargo that they can nether see or interact with?
2) is it possible to run code when the player opens / closes there cargo bay?
3) is it possible to edit the effective number of crew for crewing starships in your fleet? (like a mutable stat or something?)
4) is it possible to replace the system that causes the player to loss crew at the end of combat (or baring that, a way to run code whenever that runs?)

when opening the cargo bay, at the bottom left on top of the 'burn level' bar there is a bunch of cargo information:
5) is it possible to change 'the number crew in fleet, and the number needed to meet the minimum requirements on all ships in the fleet' text, number of crew, and number of required crew?
6) is it possible to change the little number that shows the amount of marines in the players fleet?
7) is it possible to change the 'Personnel capacity' text and number of personnel in fleet? (it also has a blue bar showing how full it is, in cause its not clear what 'Personnel Capacity' is)
Basically, I want to change all the blue things.

thank you reading my question list. and thanks for past awensers to the questions that i ask at random
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Bee on April 25, 2023, 03:58:48 PM
you'll need at least an entry in default_ship_roles.json as well (look at vanilla for an example), without them the game doesn't know when to spawn the ship so it simply won't.

Thanks, that worked!

Some mods I looked at for reference had different groups in there (patrol sizes?), gonna have to look into those more!
Initially I just put the hull on the list instead of a variant and was wondering why the game kept crashing :p
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on April 27, 2023, 07:10:59 AM
Is there a way to uniquely identify a piece of hulk from a fragmented ship??

Trying to do some stuff with floating hulks instead of it being floating walls that block projectiles
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 27, 2023, 12:00:12 PM
hello once more everyone. I'm here to ask way to many questions again. (is this to many questions to ask at once? I ran out of things to code.)
so my questions:
1) is it possible to add a item to the players cargo that they can nether see or interact with?
2) is it possible to run code when the player opens / closes there cargo bay?
3) is it possible to edit the effective number of crew for crewing starships in your fleet? (like a mutable stat or something?)
4) is it possible to replace the system that causes the player to loss crew at the end of combat (or baring that, a way to run code whenever that runs?)

when opening the cargo bay, at the bottom left on top of the 'burn level' bar there is a bunch of cargo information:
5) is it possible to change 'the number crew in fleet, and the number needed to meet the minimum requirements on all ships in the fleet' text, number of crew, and number of required crew?
6) is it possible to change the little number that shows the amount of marines in the players fleet?
7) is it possible to change the 'Personnel capacity' text and number of personnel in fleet? (it also has a blue bar showing how full it is, in cause its not clear what 'Personnel Capacity' is)
Basically, I want to change all the blue things.

thank you reading my question list. and thanks for past awensers to the questions that i ask at random

I think the answer to most of these, except for #4, is no. And #4 requires replacing the vanilla FleetInteractionDialogPlugin implementation, which will both be fairly complicated and incompatible with other mods that need to do this for any other reason. Not knowing exactly what you want to accomplish, I think with regard to specifics, your best bet would probably be to work through the existing Crew commodity, and not completely around it.


Is there a way to uniquely identify a piece of hulk from a fragmented ship??

Trying to do some stuff with floating hulks instead of it being floating walls that block projectiles

I don't understand the question. If you have a reference to that ShipAPI object - of the floating piece of hulk - then that uniquely identifies it, no? I think I'm missing what you're asking.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 27, 2023, 10:46:28 PM
I think the answer to most of these, except for #4, is no. And #4 requires replacing the vanilla FleetInteractionDialogPlugin implementation, which will both be fairly complicated and incompatible with other mods that need to do this for any other reason. Not knowing exactly what you want to accomplish, I think with regard to specifics, your best bet would probably be to work through the existing Crew commodity, and not completely around it.
That is unfortunate. Without being able to at least do 3, 4 is kinda useless.
As for what I was doing, 1 and 2 were me trying to find a way around having my changes to the survey plugin be cluttered. Unimportant for the most part. 3,4,5 was me trying to find a way to upgrade crew replacer so it could allow people to mod in new types of ship crew to the game. 7 was the same for passengers. 6 was just something that was bugging me.
I don't think working with crew would be helpful here. I could in theory simulate other commodities acting as ship crew by having them increase / decrease the number of crew in your fleet, but I can already foresee all sorts of issues with that. Many I don't think I would beable to fix.
Thanks for the awenser regardless though. Hope my words cleared up my objectives.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 28, 2023, 08:32:54 AM
Yeah - it does sound like what you had in mind is really going against the grain of how the game wants to do things, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: slamminabw on April 28, 2023, 10:41:13 AM
Is there an updated guide on creating your own faction mod or a custom faction mod that would make a relatively simple template for me to use?

I'm assisting on the Battlestar Galactica mod, but would like to make my own custom faction mod. Unfortunately a lot of the BSG code is older, even if it still works, and I'm worried about starting their for my own mod. Most of the guides seem outdated. I downloaded the Outer Rim Alliance mod to explore as a template, and the amount of integration and complexity made it difficult for me to piece apart.

Not looking to use custom ships or weapons at this point. Simply a vanilla style faction, with vanilla assets, spawned on a new planet. I've got the faction file sorted, more so struggling to understand/find clarity on spawning the planet. Any nudge in the right direction would be appreciated! Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 29, 2023, 01:24:48 AM
I have a freshly spawned (same simframe) fleet in hyperspace, I'm trying to get it to enter a star system with Global.getSector().doHyperspaceTransition, but it appears in the system immediately without any animation and able to move immediately after the change in location. What causes this?

EDIT: Also I may as well ask:

- Is there a way to set an orbital station/battlestation/star fortress's combat readiness to 1%, suppressing its normal applyCRToStation() behavior?
I've tried setting CR every frame, applying a -1 flat modifier to max CR, and even setting the station fleet's AI mode to false so it needs crew it doesn't have (actually it doesn't, stations have zero skeleton crew). Nothing seems to work :|
For now I just apply the malfunction etc. modifiers directly to the ship stats, though that has the problem of player visibility. (EDIT2: This doesn't seem to work either?! :-X Perhaps because I'm only applying it to the station center?)

- I don't suppose there's a way to make the admiral AI know it can deploy ships from the side of the map in regular battles when I give it (a clone of) the Force Concentration skill?

Is there an updated guide on creating your own faction mod or a custom faction mod that would make a relatively simple template for me to use?
[...]
Not looking to use custom ships or weapons at this point. Simply a vanilla style faction, with vanilla assets, spawned on a new planet. I've got the faction file sorted, more so struggling to understand/find clarity on spawning the planet. Any nudge in the right direction would be appreciated! Thank you!
For generating a star system, the wiki has one guide (https://starsector.fandom.com/wiki/Intro_to_Modding#Custom_Star_System). There are also examples in the Starsector folder, see starsector-core\data\scripts\world (if you're on Windows, the Mac/Linux path is slightly different).

Note that the approach described on the wiki adds the markets in code (e.g. sets their size, resource conditions and the like). The base game uses economy .json files for those, examples of which are in data/campaign/econ.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 29, 2023, 10:11:20 AM
I have a freshly spawned (same simframe) fleet in hyperspace, I'm trying to get it to enter a star system with Global.getSector().doHyperspaceTransition, but it appears in the system immediately without any animation and able to move immediately after the change in location. What causes this?

Hmm. The hyperspace transition works off the visible ships in the "campaign fleet view" - once they all warp out, the transition happens. There's a good chance that for a newly created fleet, the view is empty, so the transition happens right away. I didn't test this, though; just a hypothesis.

Depending on what you're doing, I'd probably attach a script to it that waits a second or two and then does the transition.


EDIT: Also I may as well ask:

- Is there a way to set an orbital station/battlestation/star fortress's combat readiness to 1%, suppressing its normal applyCRToStation() behavior?
I've tried setting CR every frame, applying a -1 flat modifier to max CR, and even setting the station fleet's AI mode to false so it needs crew it doesn't have (actually it doesn't, stations have zero skeleton crew). Nothing seems to work :|
For now I just apply the malfunction etc. modifiers directly to the ship stats, though that has the problem of player visibility. (EDIT2: This doesn't seem to work either?! :-X Perhaps because I'm only applying it to the station center?)

Short of overriding the industry with a copy that uses a subclass that does whatever you want, nothing somes to mind. I mean, it seels like you could set the CR in combat, right? But I think you're asking about doing this in the campaign layer. Am I missing something? (Yeah, you'd need to apply whatever changes to all the modules; they're basically independent ships as far as the game is concerned. For example, the Targeting Supercomputer hullmod needs to be on each module, etc.)


- I don't suppose there's a way to make the admiral AI know it can deploy ships from the side of the map in regular battles when I give it (a clone of) the Force Concentration skill?

I don't think so. In the next release you'll be able to create an AdmiralAIPlugin and pass it in to do whatever. In the current one, you could I think do this by forcing that side to not have an admiral AI (in the BattleCreationPlugin implementation) and then having an every frame plugin do the job.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on April 30, 2023, 05:16:36 AM
- A delay between the fleet spawning and doing the transition didn't seem to fix it. Although if I'm in hyperspace looking at the fleet when it spawns, the transition animation works correctly on both ends of the jump.
The workaround I ended up using was to add the fleet directly to the star system at [99999, 99999] and use the hyperspace transition to do an 'in-system jump' to the intended destination.

-I ended up using a combat plugin to set the CR, yeah. Although I then ran into an interesting issue: setting CR (only in-combat? haven't tested) seems to barely do anything for a station's modules, as in when I set their CR to zero they could still use their shields and experienced no malfunctions, although fighter replacement rate was zero as expected.
EDIT: Getting and applying the CombatReadinessPlugin to the ships after setting their CR seems to do the job.


Anyway while I'm here, a bug report and a 'working as designed but I want to complain':
- When a fleet is generated with FleetParamsV3.flagshipVariantId specified, and that variant is a SHIP_WITH_MODULES (station_small_Standard will do), mousing over it in the campaign map CTDs. I guess you can't set a fleet member's variant to a ship with modules if it wasn't already one?
286701 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 1
java.lang.ArrayIndexOutOfBoundsException: 1
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus.getStatus(Unknown Source)
   at com.fs.starfarer.ui.super.OoOO.o00000(Unknown Source)
   at com.fs.starfarer.ui.super.OoOO.o00000(Unknown Source)
   at com.fs.starfarer.ui.super.OoOO.new(Unknown Source)
   at com.fs.starfarer.campaign.ui.O0OO.o00000(Unknown Source)

- I'm not sure that FleetFactoryV3.addCommanderAndOfficersV2 should override the fleet commander's rank and post ID (lines 1001-1002) if it's passed a premade commander in the params.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 30, 2023, 06:38:31 AM
What determines if a ship shows up for purchase on the regular, military, or black market screens?

Also, I have ship designs in my default_ship_roles.json file. Do I also have to have those specific hull IDs in a blueprint that a fction can make or can ships in the default_ship_Roles.json still show up even of no faction has them listed as known?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 30, 2023, 10:12:06 AM
- A delay between the fleet spawning and doing the transition didn't seem to fix it. Although if I'm in hyperspace looking at the fleet when it spawns, the transition animation works correctly on both ends of the jump.
The workaround I ended up using was to add the fleet directly to the star system at [99999, 99999] and use the hyperspace transition to do an 'in-system jump' to the intended destination.

Hmm, that's a bit strange, since I think when random NPC fleets jump in-system - and the player had not seen them before up until that point - the animation still works. I wonder what the difference is.

-I ended up using a combat plugin to set the CR, yeah. Although I then ran into an interesting issue: setting CR (only in-combat? haven't tested) seems to barely do anything for a station's modules, as in when I set their CR to zero they could still use their shields and experienced no malfunctions, although fighter replacement rate was zero as expected.
EDIT: Getting and applying the CombatReadinessPlugin to the ships after setting their CR seems to do the job.

Ahh - looking at the code, the Ship class will apply the CombatReadinessPlugin effect only if the ship's peak time has run out, so that makes sense.


Anyway while I'm here, a bug report and a 'working as designed but I want to complain':
- When a fleet is generated with FleetParamsV3.flagshipVariantId specified, and that variant is a SHIP_WITH_MODULES (station_small_Standard will do), mousing over it in the campaign map CTDs. I guess you can't set a fleet member's variant to a ship with modules if it wasn't already one?
286701 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 1
java.lang.ArrayIndexOutOfBoundsException: 1
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus.getStatus(Unknown Source)
   at com.fs.starfarer.ui.super.OoOO.o00000(Unknown Source)
   at com.fs.starfarer.ui.super.OoOO.o00000(Unknown Source)
   at com.fs.starfarer.ui.super.OoOO.new(Unknown Source)
   at com.fs.starfarer.campaign.ui.O0OO.o00000(Unknown Source)


Right, yeah - changing the number of modules on a FleetMember (either from zero, as in your case, or from e.g. 2 to 3) does not work/is not supported.

- I'm not sure that FleetFactoryV3.addCommanderAndOfficersV2 should override the fleet commander's rank and post ID (lines 1001-1002) if it's passed a premade commander in the params.

Looks like that's fixed in the in-dev version - there's an "if (params.commander == null) {" check before it does that.


What determines if a ship shows up for purchase on the regular, military, or black market screens?

I don't actually remember the details, but the code for this is all exposed in the implementations of the submarket plugins. IIRC the open market gets some of the faction's military ships but of lower quality. And the black market has pirate ships, plus some market-faction stuff, more if stability is low.

Also, I have ship designs in my default_ship_roles.json file. Do I also have to have those specific hull IDs in a blueprint that a fction can make or can ships in the default_ship_Roles.json still show up even of no faction has them listed as known?

You need to add it to the faction's known ships; you can take a look at just about any faction file for an example of how that's set up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on May 01, 2023, 03:28:45 AM
I'm interested in the way in which shipbounds work. Are the bounds array points evaluated in the order they are listed, so by insertion order? Say I want to draw a representation of said bounds. Is attempting to avoid intersections altogether (for example, by triangulating the set of points via ear clipping or Delaunay algorithm) a mistake? (I think it is, looking at Paragon or Wasp).

I'm also interested in the way coordinates listed in shipfile work. Do I understand it correctly that a ship center is evaluated from 0,0 as a top left corner of ship sprite and then all the other points like bounds, weapon points and the like are evaluated from 0,0 as ship center?

Where can I gather more info about it, meaning the way in which shipfile is meant to be constructed and the way in which it is evaluated by game code?

Edit: also - how the case of 2 identical bound points is being handled? Should the shipfile never have bound point duplicates, or is it perfectly acceptable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 01, 2023, 12:27:52 PM
I'm also interested in the way coordinates listed in shipfile work. Do I understand it correctly that a ship center is evaluated from 0,0 as a top left corner of ship sprite and then all the other points like bounds, weapon points and the like are evaluated from 0,0 as ship center?

0,0 in the sprite is the bottom left, but yeah that's otherwise correct.

Where can I gather more info about it, meaning the way in which shipfile is meant to be constructed and the way in which it is evaluated by game code?

you can just Global.getSettings.loadJson() the .ship file path (conveniently gettable from the ship's spec), then use the various JSONObject methods to get the values from it, as far as I know the game does it like that as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 02, 2023, 09:34:42 AM
What makes a faction generate personal bounties? I'm making a new faction and can't seem to make it give bounties no matter what I try.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 02, 2023, 10:17:54 AM
I'm interested in the way in which shipbounds work. Are the bounds array points evaluated in the order they are listed, so by insertion order? Say I want to draw a representation of said bounds. Is attempting to avoid intersections altogether (for example, by triangulating the set of points via ear clipping or Delaunay algorithm) a mistake? (I think it is, looking at Paragon or Wasp).

The order they're listed; I'm not sure what "insertion order" would mean here. Overlaps are definitely ok.

Where can I gather more info about it, meaning the way in which shipfile is meant to be constructed and the way in which it is evaluated by game code?

I'm not sure if any of the community ship editors are open-source, but if so: that might be a good way to go. The wiki might also have some stuff about it? Not sure, to be honest.

Edit: also - how the case of 2 identical bound points is being handled? Should the shipfile never have bound point duplicates, or is it perfectly acceptable?

... I don't remember offhand. I think it's *probably* handled, but not 100% sure.


What makes a faction generate personal bounties? I'm making a new faction and can't seem to make it give bounties no matter what I try.

Hmm - PersonBountyIntel.pickFaction() is probably the method you want to look at. Basically, it requires that the faction have a market meeting certain criteria, e.g. "not hidden" etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 02, 2023, 10:50:14 AM
What makes a faction generate personal bounties? I'm making a new faction and can't seem to make it give bounties no matter what I try.

Hmm - PersonBountyIntel.pickFaction() is probably the method you want to look at. Basically, it requires that the faction have a market meeting certain criteria, e.g. "not hidden" etc.

Got it! Turns out a plugin needs to be added with methods (I did ongameload and onnewgame) to add the faction id to "SharedData.getData().getPersonBountyEventData().isParticipating"). Thanks Alex!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 02, 2023, 12:07:04 PM
Ahh, glad you got it! I forgot about that completely :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Bee on May 02, 2023, 02:13:11 PM
Hello! I've been having some trouble with adding a campaign system to my mod and saw this post (https://fractalsoftworks.com/forum/index.php?topic=25209.0) about getting them to work without compiling anything with using vanilla systems as a base. I copied the Yma system as a starting point and took a look at the Periphery mod as Great Wound suggested to the original poster of that thread, with a data/world/generators.csv and all, but whenever I try to generate a sector, the game crashes and I get this popup.

popup image
(https://cdn.discordapp.com/attachments/546116685309018122/1103062871501459516/image.png)
[close]
error in log
25411 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException: data.scripts.world.systems.Calcari cannot be cast to com.fs.starfarer.api.campaign.SectorGeneratorPlugin
java.lang.ClassCastException: data.scripts.world.systems.Calcari cannot be cast to com.fs.starfarer.api.campaign.SectorGeneratorPlugin
   at com.fs.starfarer.loading.O00O.super(Unknown Source)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.N.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.OoO0.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.oooO.Ò00000(Unknown Source)
   at com.fs.starfarer.ui.oooO.processInput(Unknown Source)
   at com.fs.starfarer.ui.V.o00000(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

I had a quick look and compared the modded system to mine and added "import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;" in the same place, assuming that said plugin not being imported was the problem, but apparently I get the issue regardless of whether or not it's there? Sorry if this is a kinda obvious issue, I'm admittedly not very knowledgeable about programming.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 03, 2023, 08:38:31 AM
The way you're doing it, you'll want to have your class be declared like this:

public class Calcari implements SectorGeneratorPlugin
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Bee on May 03, 2023, 09:20:57 AM
The way you're doing it, you'll want to have your class be declared like this:

public class Calcari implements SectorGeneratorPlugin

That solved it, thank you!

And what'd you know, the other modded system I had a look at for reference also had that, and I simply missed it...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 03, 2023, 12:49:59 PM
What’s the best way to call a function at the very end of a battle? Specifically, I’d like to modify the CR of every single ship left on the field as the battle ends. Is there a simple trigger for that somewhere?

EDIT: a function that checks the boolean "Global.getCombatEngine().isCombatOver()" seems serviceable. However, the script doesn't run when I claim victory via esc instead of letting the battle end naturally... Does anyone have better suggestions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on May 05, 2023, 10:19:37 AM
@Alex What's going on here?

Spoiler
Code
383713 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoSuchMethodError: com.fs.starfarer.api.ui.TooltipMakerAPI.addImageWithText(F)V
java.lang.NoSuchMethodError: com.fs.starfarer.api.ui.TooltipMakerAPI.addImageWithText(F)V
at forgprod.abilities.interaction.panel.components.Sidebar.addFrameBox(Sidebar.java:77)
at forgprod.abilities.interaction.panel.components.Sidebar.createFrame(Sidebar.java:64)
at forgprod.abilities.interaction.panel.components.Sidebar.create(Sidebar.java:39)
at forgprod.abilities.interaction.panel.ControlPanelAssembly.addComponents(ControlPanelAssembly.java:79)
at forgprod.abilities.interaction.panel.ControlPanelAssembly.renderPanel(ControlPanelAssembly.java:72)
at forgprod.abilities.interaction.ControlPanelPlugin.init(ControlPanelPlugin.java:28)
at forgprod.abilities.interaction.wrappers.ControlDialogDelegate.init(ControlDialogDelegate.java:29)
at com.fs.starfarer.ui.newui.return.<init>(Unknown Source)
at com.fs.starfarer.ui.newui.classsuper.showCustomVisualDialog(Unknown Source)
at forgprod.abilities.interaction.wrappers.ControlInteractionPlugin.optionSelected(ControlInteractionPlugin.java:41)
at forgprod.abilities.interaction.wrappers.ControlInteractionPlugin.init(ControlInteractionPlugin.java:32)
at com.fs.starfarer.ui.newui.classsuper.o?0000(Unknown Source)
at com.fs.starfarer.ui.newui.classsuper.<init>(Unknown Source)
at com.fs.starfarer.ui.newui.classsuper.<init>(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.showInteractionDialog(Unknown Source)
at forgprod.abilities.ForgeProductionAbility.pressButton(ForgeProductionAbility.java:116)
[close]

Here is the relevant code:

Spoiler
Code
    private static void addFrameBox(TooltipMakerAPI sidebarFrame, float width) {
        TooltipMakerAPI sidebarBoxContainer = sidebarFrame.beginImageWithText(null, 2f);
        Color baseBoxColor = Misc.interpolateColor(PanelConstants.DARK_PLAYER_COLOR,
                PanelConstants.BRIGHT_PLAYER_COLOR, 0.5f);
        Color boxColor = Misc.scaleColorOnly(baseBoxColor, 0.9f);
        sidebarBoxContainer.addAreaCheckbox("", null, PanelConstants.PLAYER_COLOR,
                boxColor, PanelConstants.PLAYER_COLOR,
                width, 503, 0f);
        sidebarBoxContainer.getPrev().getPosition().setXAlignOffset(-245f);
        sidebarFrame.addImageWithText(2f);
    }
[close]

Tried to comment one such line - seems like the problem is universal for addImageWithText() methods.

The signature of method did change from void to UIPanel -
Code
UIPanelAPI addImageWithText(float pad);
, but I fail to see how that could be of issue since the call never used a return value earlier. The exception complains about no such method, but it is clearly there - perhaps signature mismatch is the culprit? If so, how do I deal with it?

Edit: right, it's the signature mismatch:

Code
   L5
    LINENUMBER 77 L5
    ALOAD 0
    FCONST_2
    INVOKEINTERFACE com/fs/starfarer/api/ui/TooltipMakerAPI.addImageWithText (F)V (itf)
   L6

Tried to delete the jar and rebuild - not so fast, Intellij uses .class files to quick build. Need to delete the whole /out folder, and voila:

Code
   L5
    LINENUMBER 77 L5
    ALOAD 0
    FCONST_2
    INVOKEINTERFACE com/fs/starfarer/api/ui/TooltipMakerAPI.addImageWithText (F)Lcom/fs/starfarer/api/ui/UIPanelAPI; (itf)
    POP
   L6

Edit 2: Looking right now through updated TooltipMakerAPI methods I catch myself really appreciating work on the methods and changes that were added this update. It really is heartwarming to see. Thanks for your hard work - I am sure you as well will appreciate the result in the form of the new glorious content that will be created using these new possibilities.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Big Bee on May 06, 2023, 06:59:51 AM
Is there a way to combine "heatseeker" and "MIRV" behaviours for missiles?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SiriusClean on May 06, 2023, 04:32:21 PM
Hello,

i have a weird problem with my custom faction.
The Faction uses my custom ship and weapon set,
but only spawns ships with no weapons.

If i enable the base_bp in the .FACTION file,
only the vanilla ships will spawn with weapons and then only with vanilla weapons equipped.
Every custom ship, weapon and variant is working normaly in simulation
and can be used by the player in campaign with no problems.
I checked my files and compared them with some other mod files(diableavionics,XhanEmpire, etc.),
but i couldnt find the cause of that problem.

.FACTION:
Spoiler
Code
{
id:"hive_fleet",
"color":[107,142,35,255],

"baseUIColor":[107,142,35,255],
"secondaryUIColor":[255,255,255,255],
"secondarySegments":2,
"darkUIColor":[107,142,35,255],
"gridUIColor":[107,142,35,255],

"displayName":"Hive",
"displayNameWithArticle":"the Hive",

"logo":"graphics/factions/hive_fleet.png",
"crest":"graphics/factions/crest_hive_fleet.png",

"shipNamePrefix":"QG",

    "shipNameSources":{
"SPACE":1,
"JAPANESE":1,
},
"names":{
"myth":1,
"JAPANESE":1,
},

# variantOverrides restricts hulls to listed variants and adjusts their probability
"variantOverrides":{
},

# multiplier for how often hulls show up in the faction's fleets
"hullFrequency":{
"tags":{
},
"hulls":{
},
},
# ships the faction gets access to when importing S&W out-of-faction
"shipsWhenImporting":{
"tags":["hive_full_bp"],
"hulls":[
"hive_hunter",
"hive_swarmer",
"hive_breeder",
"hive_queen",
"hive_novus",
"hive_strikus",
"hive_feeder",
"hive_galioth",
],
},
"knownShips":{
"tags":["hive_full_bp"],
"hulls":[
"hive_hunter",
"hive_swarmer",
"hive_breeder",
"hive_queen",
"hive_novus",
"hive_strikus",
"hive_feeder",
"hive_galioth",

],
},
# listing ships here will make the faction mostly use them even if other hulls become available
"priorityShips":{
"tags":[],
"hulls":[
],
},
"knownFighters":{
"tags":["hive_full_bp"],
"fighters":[

],
},
"priorityFighters":{
"tags":[],
"fighters":[],
},
"knownWeapons":{
"tags":["hive_full_bp","base_bp"],
"weapons":[
"hive_horngun_small",
"hive_reaper_gun",
"hive_mutagen_lance",
"hive_stinger_af",
"hive_viper_launcher",
"hive_hydra_cannon",
"hive_zerg_launcher",
],
},
"priorityWeapons":{
"tags":[],
"weapons":[],
},
"knownHullMods":{
"tags":["base_bp"],
"hullMods":[
"turretgyros",
"armoredweapons",
"augmentedengines",
"autorepair",
"expanded_deck_crew",
"magazines",
"missleracks",
"heavyarmor",
"insulatedengine",
"targetingunit",
"nav_relay",
"operations_center",
"fluxbreakers",
"surveying_equipment",
"efficiency_overhaul",
"escort_package",
"assault_package",
"converted_fighterbay",
],
},
[close]

Maybe somebody can help me with that?

edit:

The ships will spawn with the variant hullmods and names but nothing more.

default_ship_roles.json:
Spoiler
Code
{
"combatSmallForSmallFleet":{
"hive_strikus_fleet_standard":10,
"hive_swarmer_patrol":4,
"hive_swarmer_heavy_support":8,
"hive_novus_light_support":8,
},

"combatSmall":{
"hive_strikus_fleet_standard":10,
"hive_swarmer_patrol":6,
"hive_swarmer_heavy_support":4,
"hive_novus_light_supression":2,
"hive_novus_light_support":12
},

"combatMedium":{
"hive_hunter_fleet_standard":10,

},

"combatLarge":{
"hive_galioth_siege_support":6

},

"combatCapital":{
},

"combatFreighterLarge":{
"hive_feeder_supply_ship":10
},

"freighterSmall":{
},

"tankerSmall":{
},

"civilianRandom":{
},

"carrierSmall":{
},

"personnelMedium":{
},

"carrierMedium":{
"hive_breeder_fleet_standard":10
},

"carrierLarge":{
},

"carrierCapital":{
"hive_queen_fleet_standard":10
},
}
[close]

hive_swarmer_heavy_support.variant:
Spoiler
Code
{
  "variantId": "hive_swarmer_heavy_support",
  "hullId": "hive_swarmer",
  "displayName": "Hive Swarmer Support",
  "goalVariant": true,
  "fluxCapacitors": 0,
  "fluxVents": 7,
  "permaMods": [],
  "hullMods": [
    "armoredweapons",
    "auxiliarythrusters",
    "hardened_subsystems",
    "missleracks"
  ],
  "weaponGroups": [
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0001": "hive_horngun_small"
      }
    },
    {
      "autofire": false,
      "mode": "LINKED",
      "weapons": {
        "WS0003": "hive_stinger_af",
        "WS0004": "hive_stinger_af"
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
        "WS0002": "hive_reaper_gun",
        "WS0005": "hive_reaper_gun",
        "WS0006": "hive_reaper_gun"
      }
    }
  ],
  "modules": [],
  "wings": []
}
[close]





Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on May 06, 2023, 09:22:36 PM
Is there a way to mark a created battle as a simulation?
To make sure that ships used in it dont suffer real damage & have the button for leaving the sim available.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 07, 2023, 09:08:40 AM
Edit 2: Looking right now through updated TooltipMakerAPI methods I catch myself really appreciating work on the methods and changes that were added this update. It really is heartwarming to see. Thanks for your hard work - I am sure you as well will appreciate the result in the form of the new glorious content that will be created using these new possibilities.

Glad you got it sorted out! And, ahh, thank you! <3 You are correct, it's always a real treat to see what people come up with using this stuff :)


Is there a way to combine "heatseeker" and "MIRV" behaviours for missiles?

Not natively, but I think it could be done with a custom missile AI.


i have a weird problem with my custom faction.
The Faction uses my custom ship and weapon set,
but only spawns ships with no weapons.

Hi - hmm. Do your weapons have tags that tell autofit what they're for? Like "kinetic11", "he8", whatever - you can take a look at the vanilla weapons for examples. The number is how good the weapon is at that role. If none are specified, then I suspect autofit would not use them.


Is there a way to mark a created battle as a simulation?
To make sure that ships used in it dont suffer real damage & have the button for leaving the sim available.

Not in a way that's exposed; it's buried in:
AppDriver.getInstance().getSession().containsKey(CampaignState.RUN_SIMULATOR_TOKEN)

But I don't think that'd do what you want - for example, damage is applied in the FleetEncounterContext implementation in FleetInteractionDialogPluginImpl, and that doesn't care about whether it's a simulation or not, so you'd need to override those.

Of possible interest, in CombatEngineAPI:
void setCustomExit(String buttonTitle, String confirmString);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kirschbra on May 07, 2023, 11:27:09 AM
Regarding the new update, is it not possible to even try to incorperate 0.95 mods?  they are orange in the mod list and I can't even get it to click,  but Alex has in the mod catagorize list that ones in yellow may still work.  But I can't even try to enable them, am I doing something wrong or is there a work around, or is it just not possible until they are updated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on May 07, 2023, 12:45:45 PM

Is there a way to mark a created battle as a simulation?
To make sure that ships used in it dont suffer real damage & have the button for leaving the sim available.

Not in a way that's exposed; it's buried in:
AppDriver.getInstance().getSession().containsKey(CampaignState.RUN_SIMULATOR_TOKEN)

But I don't think that'd do what you want - for example, damage is applied in the FleetEncounterContext implementation in FleetInteractionDialogPluginImpl, and that doesn't care about whether it's a simulation or not, so you'd need to override those.

Of possible interest, in CombatEngineAPI:
void setCustomExit(String buttonTitle, String confirmString);

Hmm, will look in to that. How would i go about overwriting that?
In my current use case im starting a battle from a dialog using a BCC and the dialog.startBattle() method while my CustomPanel is open, the context for my usage is basicly creating a simulation where someone could try out a modular weapon before crafting it, and after the battle it just returns to the custom panel.

For ending the combat, i just temporarily made a everyframe plugin that detects an escape press and ends the combat through the combat engine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Inventor Raccoon on May 07, 2023, 02:15:20 PM
Having an odd issue that only arose with 0.96a - I made it a habit of loading JSON/CSV data in the mod plugin, and storing said data there to be checked when required (e.g in a BattleCreationPlugin or an EveryFrameCombatPlugin), but it seems like the data is somehow made null before it gets to that point. Easy (if less-than-ideal) to bypass by just loading it every time it's required but I imagine it'd be ideal not to have to do that, and I'm not sure what the cause might be since the patch notes don't seem to mention anything relevant.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on May 07, 2023, 09:37:40 PM
It looks like the new setting for toggling auto strafe/turn isn't exposed through SettingsAPI. Is that so? Am I just missing a way to get/set it via getBoolean/setBoolean? One of my mods does something very similar, so I'd like to disable that feature if this new setting is on.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on May 07, 2023, 09:45:38 PM
Having an odd issue that only arose with 0.96a - I made it a habit of loading JSON/CSV data in the mod plugin, and storing said data there to be checked when required (e.g in a BattleCreationPlugin or an EveryFrameCombatPlugin), but it seems like the data is somehow made null before it gets to that point. Easy (if less-than-ideal) to bypass by just loading it every time it's required but I imagine it'd be ideal not to have to do that, and I'm not sure what the cause might be since the patch notes don't seem to mention anything relevant.
Maybe just write a generic storage class where you can expose whatever you've put in during initialization into public statics? I've done that for a few things.

Also, are you absolutely sure that whatever is returning null isn't because, say, a JSON read failed during a Try-->Catch or something to that effect?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 08, 2023, 02:39:30 AM
I'm having some wierd behaviour with applying an smod effect to a built-in only hullmod, am I just doing something wrong or is there more to it?

I have hasSmodEffect() returning true & the effect shows up properly in the refit screen, but when I go to actually s-mod the hullmod it'll either not show up at all (if HIDDEN is set to true in the csv) or refuse to be S-modded (if HIDDEN isn't true but showInRefitScreenModPickerFor() returns false), any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Timid on May 08, 2023, 11:34:38 AM
Working with lights and stufferino for graphicliberino

How would Prox-fused weapons, Phase CL, Canister Flak, Orion/Nova's ship system be detected to apply fun effects?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 08, 2023, 07:18:20 PM
Regarding the new update, is it not possible to even try to incorperate 0.95 mods?  they are orange in the mod list and I can't even get it to click,  but Alex has in the mod catagorize list that ones in yellow may still work.  But I can't even try to enable them, am I doing something wrong or is there a work around, or is it just not possible until they are updated?
Any mod that doesn't require code will very likely work just by editing its mod_info.json file to reference the current Starsector version. (But anything that uses MagicLib is guaranteed to break until it's edited for ML's new package names).

Hmm, will look in to that. How would i go about overwriting that?
In my current use case im starting a battle from a dialog using a BCC and the dialog.startBattle() method while my CustomPanel is open, the context for my usage is basicly creating a simulation where someone could try out a modular weapon before crafting it, and after the battle it just returns to the custom panel.

For ending the combat, i just temporarily made a everyframe plugin that detects an escape press and ends the combat through the combat engine.
Enter a battle by instantiating a derived class of FleetInteractionDialogPluginImpl. The code I worked on before did this, but might need a different way if you're going through a custom panel:
Code: java
final MyInteractionDialogPlugin plugin = new MyInteractionDialogPlugin(args);
dialog.setPlugin(plugin);
dialog.setInteractionTarget(enemyFleet);
plugin.init(dialog);

Anyway, you can replace the FIDP's FleetEncounterContext with your own in the dialog plugin's constructor. Alternatively, in the FIDP's backFromEngagement method, just don't call context.processEngagementResults().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 08, 2023, 07:26:05 PM
I'm having some wierd behaviour with applying an smod effect to a built-in only hullmod, am I just doing something wrong or is there more to it?

I have hasSmodEffect() returning true & the effect shows up properly in the refit screen, but when I go to actually s-mod the hullmod it'll either not show up at all (if HIDDEN is set to true in the csv) or refuse to be S-modded (if HIDDEN isn't true but showInRefitScreenModPickerFor() returns false), any ideas?

Hmm, I have a feeling this may not be doable. It was not designed for mods that are not also normally installable on a hull and the difficulties you're running into are a result of that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on May 09, 2023, 04:06:05 AM
Regarding the new update, is it not possible to even try to incorperate 0.95 mods?  they are orange in the mod list and I can't even get it to click,  but Alex has in the mod catagorize list that ones in yellow may still work.  But I can't even try to enable them, am I doing something wrong or is there a work around, or is it just not possible until they are updated?
Any mod that doesn't require code will very likely work just by editing its mod_info.json file to reference the current Starsector version. (But anything that uses MagicLib is guaranteed to break until it's edited for ML's new package names).

Hmm, will look in to that. How would i go about overwriting that?
In my current use case im starting a battle from a dialog using a BCC and the dialog.startBattle() method while my CustomPanel is open, the context for my usage is basicly creating a simulation where someone could try out a modular weapon before crafting it, and after the battle it just returns to the custom panel.

For ending the combat, i just temporarily made a everyframe plugin that detects an escape press and ends the combat through the combat engine.
Enter a battle by instantiating a derived class of FleetInteractionDialogPluginImpl. The code I worked on before did this, but might need a different way if you're going through a custom panel:
Code: java
final MyInteractionDialogPlugin plugin = new MyInteractionDialogPlugin(args);
dialog.setPlugin(plugin);
dialog.setInteractionTarget(enemyFleet);
plugin.init(dialog);

Anyway, you can replace the FIDP's FleetEncounterContext with your own in the dialog plugin's constructor. Alternatively, in the FIDP's backFromEngagement method, just don't call context.processEngagementResults().

Thanks, il try it out later!
I think it should work aslong as i make sure to set the dialog plugin back to the old one after the battle is done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 09, 2023, 06:19:00 AM
Hmm, I have a feeling this may not be doable. It was not designed for mods that are not also normally installable on a hull and the difficulties you're running into are a result of that.

Time to see if I can trick the game into letting it be improved!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on May 10, 2023, 10:58:25 AM
I'm trying to refresh the industry screen without having to exit/enter the entire dialogue, something that the new buttons seem to do on press, but doesn't appear to be accessible from the outside.
Any way to get at that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on May 12, 2023, 12:00:18 AM
How can I determine to which ship a Terminator Drone belongs?  No API method I have tried yields this answer.

MethodResult
ShipAPI.isFighter()true
ShipAPI.isDrone()false
ShipAPI.getWing()null
ShipAPI.getWing().getSourceShip()NullPointerException
ShipAPI.getDroneSource()null
ShipAPI.getFleetMember()null
Global.getCombatEngine().getFleetManager(0).getDeployedFleetMembernull

I have inspected the Terminator Drone object and found a reference to its source in the obfuscated field launchingShip, which the API ironically lets you set but not get.  Please help because my mod therefore attributes Terminator Drone damage to a null entry in the CombatDamageData, of which the relevant game code seeks a corresponding FleetMember after the battle and then crashes to desktop with a NullPointerException.

I get a crash once the battle is over, if a Tempest's terminator drone hits an enemy ship. starsector.log has this error:

88876 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.computeFPHullDamage(FleetEncounterContext.java:1970)
   at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.processEngagementResul ts(FleetEncounterContext.java:247)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.backFromEng agement(FleetInteractionDialogPluginImpl.java:594)
   at com.fs.starfarer.campaign.CampaignState.prepare(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)

The mods I have are:
LazyLib
MagicLib
GraphicsLib
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 12, 2023, 04:45:57 AM
how do you set a weapon to "rest" in the center of it's firing arc?
I'm doing some stuff using the DEM drone & a semi-custom drone AI (using a script to control it's movement), but the weapons seemingly always want to point at 0,0 when I've not given them a target through the fire shipCommand

and an addendum to this now that I'm messing with normal fighters as well; is there a way to stop a fighter's AI from moving it without replacing the whole AI?
I'm giving commands to a fighter in an EveryFrameCombatPlugin but the AI still seems to be fighting against them (If I set thew AI to null they'll go exactly where they're told to, otherwise they drift & bounce wierdly)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on May 12, 2023, 12:30:35 PM
I noticed that there's now ProjectileWeaponSpecAPI.setRequiresFullCharge, but I'm not sure how to use it. I assume it means that you can fire a weapon at partial charge with partial strength, but after setting this to false, I don't notice any change in the weapon's behavior. I'm still unable to fire any weapons at partial charge.

Does anyone have any idea how to get this feature to work?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Argonaut on May 13, 2023, 08:55:13 AM
I'm sure my problem is very basic.
I setup a project in VSCode with jdk 1.7 and i'm running an empty class, but i get the following issue:
(https://i.ibb.co/mFfXGLK/error-compilation.png) (https://ibb.co/0VHFcgL)

My only library dependencies are taken from Starsector's core folder, and even leaving EFModPlugin to only contain an empty class still causes the same error.
My mod_info.JSON contains:
Code
    "jars":["jars/EF.jar"],
    "modPlugin":"data/scripts/EFModPlugin"
As stupid as it looks, i have no clue what the problem could be after looking at it for a long time, so any help would be appreciated.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 13, 2023, 09:07:28 AM
it needs to be data.scripts.EFModPlugin
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tocks13 on May 13, 2023, 09:28:58 AM
Before diving into the documentation and trying to find clues in the Documentation:
Is there a "simple" way to hook into the conversation dialog to execute a method with the last written text as parameter whenever something is written in the dialog, without writing custom dialog for everything?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2023, 09:37:37 AM
I'm trying to refresh the industry screen without having to exit/enter the entire dialogue, something that the new buttons seem to do on press, but doesn't appear to be accessible from the outside.
Any way to get at that?

Hmm, I don't think so, sorry!


How can I determine to which ship a Terminator Drone belongs?  No API method I have tried yields this answer.

I think the only way is to use ship.getWing() before the drone is converted into a missile and hold on to that info. At least, that's the only thing that comes to mind.


how do you set a weapon to "rest" in the center of it's firing arc?
I'm doing some stuff using the DEM drone & a semi-custom drone AI (using a script to control it's movement), but the weapons seemingly always want to point at 0,0 when I've not given them a target through the fire shipCommand

and an addendum to this now that I'm messing with normal fighters as well; is there a way to stop a fighter's AI from moving it without replacing the whole AI?
I'm giving commands to a fighter in an EveryFrameCombatPlugin but the AI still seems to be fighting against them (If I set thew AI to null they'll go exactly where they're told to, otherwise they drift & bounce wierdly)

They should just do this automatically after some time; it's hard to say what you might be doing that's overriding that, hmm.

For fighters: I guess you could set its location directly?

I noticed that there's now ProjectileWeaponSpecAPI.setRequiresFullCharge, but I'm not sure how to use it. I assume it means that you can fire a weapon at partial charge with partial strength, but after setting this to false, I don't notice any change in the weapon's behavior. I'm still unable to fire any weapons at partial charge.

Does anyone have any idea how to get this feature to work?

Ah, this shouldn't have been exposed; it's a holdover from when there was a different type of weapon - "pulse" weapons that required the button to be held down to charge and fired on release. It was too fiddly and was abandoned.


Before diving into the documentation and trying to find clues in the Documentation:
Is there a "simple" way to hook into the conversation dialog to execute a method with the last written text as parameter whenever something is written in the dialog, without writing custom dialog for everything?

Hmm, not that I can think of. That'd require the text panel to have a listener for that sort of thing and that doesn't exist. (Or I suppose some kind of code injection...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Argonaut on May 13, 2023, 09:39:06 AM
it needs to be data.scripts.EFModPlugin

Where, in the package name? If i do that it won't even compile and the IDE reports an error... EFModPlugin is a class in data/scripts after all
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 13, 2023, 10:38:29 AM
it needs to be data.scripts.EFModPlugin

Where, in the package name? If i do that it won't even compile and the IDE reports an error... EFModPlugin is a class in data/scripts after all

ah yeah, I probably should've been more specific- replace the slashes in the modPlugin field w/ dots & it should work.
paths inside compiled .jar files are represented as dots instead of slashes (no idea why tbh), think like how you call a method with "blah.Methodname"

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tocks13 on May 13, 2023, 11:10:37 AM


Before diving into the documentation and trying to find clues in the Documentation:
Is there a "simple" way to hook into the conversation dialog to execute a method with the last written text as parameter whenever something is written in the dialog, without writing custom dialog for everything?

Hmm, not that I can think of. That'd require the text panel to have a listener for that sort of thing and that doesn't exist. (Or I suppose some kind of code injection...)

Too bad.
Since I'm too impatient/lazy to read all the lore etc, which I don't want to miss, I was hoping to make it easier on me by hooking a text to speech system into the Dialog.
But it seems like that is going to be harder/more work intensive, than hoped, if at all possible.

Is it possible to overwrite standard dialog scripts to enhance them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 13, 2023, 03:56:50 PM
Ah! There's actually a setting in data/config/settings.json that could be useful for this:
writeInteractionTextToFile
The comment around there tells where the text file is located.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tocks13 on May 13, 2023, 05:09:53 PM
Ah! There's actually a setting in data/config/settings.json that could be useful for this:
writeInteractionTextToFile
The comment around there tells where the text file is located.

Uh, that sounds promising.
Have to look how and when it writes it to the file, but that makes it a little bit easier, though still a little bit whacky.
But thanks for the Infos so far!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 14, 2023, 04:37:23 AM
Does MEMORY_KEY_ALLOW_PLAYER_BATTLE_JOIN_TOFF actually do anything?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on May 14, 2023, 06:59:47 PM
How does    ShipAPI.setLayer(CombatEngineLayers layer)  work with modules?

it looks like it works but modules will still render beneath the weapons of the parent ship? Is that expected behavior?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 14, 2023, 07:07:17 PM
BaseHubMission.triggerSpawnShipGraveyard seems to have an NPE (stacktrace from Java 17, but also happens on 8 )

Code: java
        triggerSpawnShipGraveyard(Factions.REMNANTS, 2, 2, loc);
        triggerSpawnShipGraveyard(Factions.PERSEAN, 4, 6, loc);
385638 [Thread-2] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException: Cannot read field "ship" because "this.data" is null
java.lang.NullPointerException: Cannot read field "ship" because "this.data" is null
        at com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin.readResolve(DerelictShipEntityPlugin.java:347) ~[starfarer.api.jar:?]
        at com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin.init(DerelictShipEntityPlugin.java:245) ~[starfarer.api.jar:?]
        at com.fs.starfarer.campaign.CustomCampaignEntity.<init>(Unknown Source) ~[port_obf.jar:?]
        at com.fs.starfarer.campaign.BaseLocation.addCustomEntity(Unknown Source) ~[port_obf.jar:?]
        at com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.addSalvage Entity(BaseThemeGenerator.java:1495) ~[starfarer.api.jar:?]
        at com.fs.starfarer.api.impl.campaign.missions.hub.BaseHubMission.spawnDerelict(BaseHubMission.java:2743) ~[starfarer.api.jar:?]
        at com.fs.starfarer.api.impl.campaign.missions.hub.BaseHubMission.spawnDerelict(BaseHubMission.java:2731) ~[starfarer.api.jar:?]
        at com.fs.starfarer.api.impl.campaign.missions.hub.BaseHubMission.spawnShipGraveya rd(BaseHubMission.java:2771) ~[starfarer.api.jar:?]
        at com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers$SpawnShipGraveyardAction.doAction(HubMissionWithTriggers.java:285) ~[starfarer.api.jar:?]
        at com.fs.starfarer.api.impl.campaign.missions.hub.BaseHubMission.runTriggers(BaseHubMission.java:1165) ~[starfarer.api.jar:?]

EDIT: Worked around by overriding spawnShipGraveyard to set the DerelictType for each ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on May 16, 2023, 03:55:53 PM
hey all, its me again. with 3 more questions:
1) how do i add a special item to a sub-markets cargo?
2) how do i save data to a special item? (so the data on it is save persistent)
3) is it possible to change the credit cost of special items on a per stack basis?
thanks all for responding to my silly questions again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SwagMcTwerkster on May 17, 2023, 09:19:22 AM
Is beam weapons hit strength aka. the "half beam DPS" a 0.5 multiplier or a divisor of 2, and if it is a divisor does the calculation happen before or after damage types are considered(Graviton, HIL)?

Because, with HIL for example, 500*0.5*2 and 500/2*2 are different from 500*2/2 if the order of calculation is from left to right.


Nevermind, just had a four hour brainfart, sorry.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TalRaziid on May 17, 2023, 03:45:43 PM
Hey folks, can anyone guide me through how to add a new commodity to the game that will be produced by Heavy Industry?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 17, 2023, 04:18:40 PM
hey all, its me again. with 3 more questions:
1) how do i add a special item to a sub-markets cargo?
2) how do i save data to a special item? (so the data on it is save persistent)

Roider's Union HQ submarket does both of these (src/scripts/campaign/submarkets/Roider_UnionHQSubmarketPlugin). It is basically just getting the submarket's cargo and adding a special item to it.

Code: java
getCargo().addSpecial(new SpecialItemData(Roider_Items.UNION_HQ_BP, Roider_Industries.UNION_HQ), 1);
Note that you need to avoid adding it multiple times as the market updates. My impl removes it each update before adding it.

Also special item data is limited to one String.


Hey folks, can anyone guide me through how to add a new commodity to the game that will be produced by Heavy Industry?

Best I can tell you is to take a look at the resource deposit market condition plugin because adding commodities to existing industries is a pain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: PCCL on May 17, 2023, 08:28:54 PM
What property defines a ship as "disabled"? And is there a method on the API where we can interact with that? Specifically, I'm trying to "revive" a ship that's dead by setting its hull level above zero and removing the "disabled" effect. I tried "setHulk(false)" but that doesn't seem to do the trick.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sajberhippien on May 17, 2023, 10:42:56 PM
Having never modded the game, but having some experience modding other games, would it be a lot of work to learn how to make a mod that simply customizes SP costs for various vanilla actions? Basically, I wanna adjust SP costs so that the things I find myself almost always spending points on get more expensive, while slightly increasing general SP gains (but I know how to do the latter by looking at this (https://fractalsoftworks.com/forum/index.php?topic=20535.0) mod).

Most of the guides and tools seem directed at 'content mods', on adding weapons and ships, on spriting etc but I've no interest in that.

TBC, I'm not asking in the 'minor questions' thread in the hopes of getting a full guide on how to do this, I just wanna know if the learning curve is too high for it to be worth bothering with. And obviously, if it's not possible to mod such changes to the base game, I'd love to know that as well.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 18, 2023, 03:37:20 AM
How are you supposed to use checkbox (TooltipMakerAPI.addCheckbox) in intel? It has no data property (like Button or AreaButton does), so it will not fire IntelInfoPlugin.buttonPressConfirmed method.

Also, thank you for the row pressed functionality! I see `IntelInfoPlugin.tableRowClicked` which makes me wonder whether you just forgot about `Object data` for checkbox (preferable, since addCheckbox returns ButtonAPI which implies same behaviour as other ButtonAPI objects), or meant to add `IntelInfoPlugin.checkboxClicked` instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on May 18, 2023, 09:31:25 AM
Noticed some odd behavior with the shieldHit parameter of OnHitEffectPlugin.onHit. If the damage amount is 0, shieldHit is always false regardless of whether the projectile actually hit shields or not. And if the damage amount is less than 1, there seems to be a random chance of shield hits not registering as shield hits, specifically if the projectile is fading when it hits. I wonder if this is intended behavior. Is shieldHit checking to see if the target's flux was raised by the shot instead of checking if the projectile is within range and inside the shield's arc?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: YerRob on May 18, 2023, 01:08:47 PM
How does the game load multiple sprites with the same name and path?
More specifically, if im using a skin pack that, for example, turns a purple ship into a yellow one, will the game keep both sprites in memory, or only the last loaded in?
Cause if it keeps both loaded in, then that would mean skin pack mods are horrible for Vram
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 18, 2023, 06:08:42 PM
Having never modded the game, but having some experience modding other games, would it be a lot of work to learn how to make a mod that simply customizes SP costs for various vanilla actions? Basically, I wanna adjust SP costs so that the things I find myself almost always spending points on get more expensive, while slightly increasing general SP gains (but I know how to do the latter by looking at this (https://fractalsoftworks.com/forum/index.php?topic=20535.0) mod).
A bunch of story point costs (well, the bonus XP values at least) are in settings.json's bonusXP table; also note the three values above it for a few actions that cost multiple points.
Mods may have story point events in code that aren't accessible in this way however.

How are you supposed to use checkbox (TooltipMakerAPI.addCheckbox) in intel? It has no data property (like Button or AreaButton does), so it will not fire IntelInfoPlugin.buttonPressConfirmed method.
You've likely already worked this out, but for an intel plugin, best I can come up with is storing the checkbox in a transient collection and having a 'confirm' button or somesuch that checks their states (or checking in advance() I guess).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2023, 11:59:15 AM
Sorry I haven't had much time to respond here while working on the hotfixes!

Does MEMORY_KEY_ALLOW_PLAYER_BATTLE_JOIN_TOFF actually do anything?

If any fleet on a side has this flag in memory, the player can join that side without having their transponder be on. There are iirc other considerations too, but e.g. in vanilla it's used to allow the player to join battles on the side of pirates in a system where you have a deal with the station king - without requiring you to be non-hostile with pirates - and it works.


How does    ShipAPI.setLayer(CombatEngineLayers layer)  work with modules?

it looks like it works but modules will still render beneath the weapons of the parent ship? Is that expected behavior?

Yeah, this is expected behavior. Station weapons render above all of their modules; otherwise there's some weirdness with e.g. armor modules rendering above guns of the modules they protect, etc.


BaseHubMission.triggerSpawnShipGraveyard seems to have an NPE (stacktrace from Java 17, but also happens on 8 )

Thank you, fixed! Looks like it was related to it trying to spawn civilian-type derelicts for factions that didn't have any civilian ships.


1) how do i add a special item to a sub-markets cargo?
2) how do i save data to a special item? (so the data on it is save persistent)
3) is it possible to change the credit cost of special items on a per stack basis?
thanks all for responding to my silly questions again.

1) Using SubmarketPlugin.getCargo()
2 & 3) You can't; the game treats items of the same type as completely interchangeable

Also special item data is limited to one String.

That's technically true but writing actual custom data to that is not a good idea, I don't think? ... unless that causes the game to not stack those items with each other anymore? Hmm. Maybe I'm wrong here.


What property defines a ship as "disabled"? And is there a method on the API where we can interact with that? Specifically, I'm trying to "revive" a ship that's dead by setting its hull level above zero and removing the "disabled" effect. I tried "setHulk(false)" but that doesn't seem to do the trick.

I'm not sure that's doable. It'd need its AI set, and probably the owner set to 0 or 1 (hulks have owner == 100). Also the battle will have recorded that ship as being disabled, so you'd need to handle whatever post-battle effects of that.


Having never modded the game, but having some experience modding other games, would it be a lot of work to learn how to make a mod that simply customizes SP costs for various vanilla actions? Basically, I wanna adjust SP costs so that the things I find myself almost always spending points on get more expensive, while slightly increasing general SP gains (but I know how to do the latter by looking at this (https://fractalsoftworks.com/forum/index.php?topic=20535.0) mod).

Most of the guides and tools seem directed at 'content mods', on adding weapons and ships, on spriting etc but I've no interest in that.

TBC, I'm not asking in the 'minor questions' thread in the hopes of getting a full guide on how to do this, I just wanna know if the learning curve is too high for it to be worth bothering with. And obviously, if it's not possible to mod such changes to the base game, I'd love to know that as well.

Thanks!

Hi! The costs are not all externalized in one place and iirc certain ones are hardcoded (such as the cost to elite a skill or to respec, I think), so it'd be a mixed bag.


How are you supposed to use checkbox (TooltipMakerAPI.addCheckbox) in intel? It has no data property (like Button or AreaButton does), so it will not fire IntelInfoPlugin.buttonPressConfirmed method.
You've likely already worked this out, but for an intel plugin, best I can come up with is storing the checkbox in a transient collection and having a 'confirm' button or somesuch that checks their states (or checking in advance() I guess).

This is definitely an oversight, fixed. (Leaving the original methods as @Deprecated.)


Noticed some odd behavior with the shieldHit parameter of OnHitEffectPlugin.onHit. If the damage amount is 0, shieldHit is always false regardless of whether the projectile actually hit shields or not. And if the damage amount is less than 1, there seems to be a random chance of shield hits not registering as shield hits, specifically if the projectile is fading when it hits. I wonder if this is intended behavior. Is shieldHit checking to see if the target's flux was raised by the shot instead of checking if the projectile is within range and inside the shield's arc?

That parameter is just checking if the damage to shields was >0.


How does the game load multiple sprites with the same name and path?
More specifically, if im using a skin pack that, for example, turns a purple ship into a yellow one, will the game keep both sprites in memory, or only the last loaded in?
Cause if it keeps both loaded in, then that would mean skin pack mods are horrible for Vram

I think (depending on how this is done, I suppose), the game probably won't even try to load the original sprite and will only load the new one. But that really depends on what you mean by "skin pack" etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on May 19, 2023, 06:36:15 PM
Also special item data is limited to one String.

That's technically true but writing actual custom data to that is not a good idea, I don't think? ... unless that causes the game to not stack those items with each other anymore? Hmm. Maybe I'm wrong here.

IDK, I have not tried to exploit it. Ship blueprints do not stack and IIRC they are the same item with different data.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 19, 2023, 08:41:35 PM
Yeah, that's definitely a point. I wonder if this could be made to work for e.g. something like survey data that's aware of what planet it's for, etc, hmm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on May 20, 2023, 06:06:27 AM
Thanks Alex!

Two new things:


This is probably working as designed but still annoyed me trying to track it down: CustomUIPanelPlugin.buttonPressed doesn't get called if the button is inside a nested panel that doesn't have its own plugin. So the innermost button-holding panels all need to have the code to handle the button press, whereas in my existing implementation I can just have the outermost panel handle all presses and the dumb element holder panels can be dumb element holder panels.
Some testing
My plugin:
Code: java
public class TestCustomUIPanelPlugin extends BaseCustomUIPanelPlugin {

    protected String name;

    public TestCustomUIPanelPlugin(String name) {
        this.name = name;
    }

    @Override
    public void buttonPressed(Object buttonId) {
        log.info(String.format("Button %s pressed picked up by panel plugin %s", buttonId, name));
    }
}

Test code 1:
Code: java
	public static void panelTest(InteractionDialogAPI dialog) {
VisualPanelAPI vp = dialog.getVisualPanel();
CustomUIPanelPlugin plugin = new TestCustomUIPanelPlugin("Outer");
CustomPanelAPI panel = vp.showCustomPanel(600, 800, plugin);

TooltipMakerAPI tooltip = panel.createUIElement(400, 96, false);
tooltip.addButton("test", "my button ID", 60, 24, 3);
panel.addUIElement(tooltip).inTL(0, 0);
}
Result: "Button my button ID pressed picked up by panel plugin Outer"
OK, fine

Test code 2: Instead of adding the button to the outer panel, we nest it inside another panel:
Code: java
		CustomUIPanelPlugin plugin2 = new TestCustomUIPanelPlugin("Inner");
boolean usePlugin2 = true;
CustomPanelAPI subPanel = panel.createCustomPanel(400, 96, usePlugin2 ? plugin2 : null);
panel.addComponent(subPanel).inTL(0, 0);

TooltipMakerAPI tooltip = subPanel.createUIElement(400, 96, false);
tooltip.addButton("test", "my button ID", 60, 24, 3);
subPanel.addUIElement(tooltip).inTL(0, 0);
Result: "Button my button ID pressed picked up by panel plugin Inner"
Actually causes some problems for my current code, but fine, this is valid.

Test code 3: Same as before, but we set usePlugin2 to false, so the inner panel has no plugin.
Result: (no log message)
[close]
Button presses seem to already be able to propagate "upwards" or such, e.g. an intel plugin can pick them up even if the button is in a custom panel. Perhaps this functionality should be applied here as well?


How is the base repair rate of ships determined? I feel like its interaction with supplies-to-recover stats results in some potentially 'screwy', in unpredictable ways, behavior re. repair costs.

Here I have a Facet with seemingly modest damage that costs 265 supplies to repair. It has a 5% CR/deployment and 20% CR recovery/day, so it burns four times its deploy cost just for one day of repairs, multiplied by 5.52 days. This makes the thing a noob trap!
(https://i.imgur.com/oe3E0VH.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 20, 2023, 10:55:44 AM
This is probably working as designed but still annoyed me trying to track it down: CustomUIPanelPlugin.buttonPressed doesn't get called if the button is inside a nested panel that doesn't have its own plugin. So the innermost button-holding panels all need to have the code to handle the button press, whereas in my existing implementation I can just have the outermost panel handle all presses and the dumb element holder panels can be dumb element holder panels.
...
Button presses seem to already be able to propagate "upwards" or such, e.g. an intel plugin can pick them up even if the button is in a custom panel. Perhaps this functionality should be applied here as well?

Hmm, yeah, it might make sense to do that; I'll keep it in mind!

(Perhaps obvious, but kind of the "standard" solution to keeping the innermost panels "dumb" would be to provide them with a plugin that's just a wrapper around your base plugin and passes through the buttonPressed() call. This is more or less equivalent to passing in an ActionListener or whatever to a button, in typical UI code architecture...)


How is the base repair rate of ships determined? I feel like its interaction with supplies-to-recover stats results in some potentially 'screwy', in unpredictable ways, behavior re. repair costs.

Here I have a Facet with seemingly modest damage that costs 265 supplies to repair. It has a 5% CR/deployment and 20% CR recovery/day, so it burns four times its deploy cost just for one day of repairs, multiplied by 5.52 days. This makes the thing a noob trap!
(https://i.imgur.com/oe3E0VH.png)

It's just this, in settings.json:
"baseRepairRateFrigate":10,
"baseRepairRateDestroyer":7,
"baseRepairRateCruiser":5,
"baseRepairRateCapital":3,

So the cost per day ends up being real high because of the 5% CR/deployment and the high recovery rate. Those stats would not line up like that if this was intended for player use, naturally!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: YerRob on May 20, 2023, 01:46:21 PM

How does the game load multiple sprites with the same name and path?
More specifically, if im using a skin pack that, for example, turns a purple ship into a yellow one, will the game keep both sprites in memory, or only the last loaded in?
Cause if it keeps both loaded in, then that would mean skin pack mods are horrible for Vram

I think (depending on how this is done, I suppose), the game probably won't even try to load the original sprite and will only load the new one. But that really depends on what you mean by "skin pack" etc.

Thank you, with skin pack i meant the ones where you just overwrite the ship graphics with another one by using the same paths and names, similarly to diable avionic's skin packs.
Good to know that the game skips overwritten images, here i was doing some nonsense shell script folder merging in worries of vram issues.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on May 21, 2023, 12:26:21 PM
How does one force a specific intel plugin to open?

Global.getSector().campaignUI.showCoreUITab(CoreUITabId.INTEL, intel) only opens the intel screen. I'd use IntelUIAPI.selectItem() but I don't know how to get a intel UI instance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 21, 2023, 02:33:14 PM
To add to that, it looks like an old method from the days intel was displayed / managed differently. All usages in the API are commented, and instead a real IntelInfoPlugin object is created, and added via `addMessage`. Does anything still use CommMessageAPI?

Quote
CommMessageAPI to select in intel tab, or FleetMemberAPI to select in refit tab
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2023, 02:52:00 PM
How does one force a specific intel plugin to open?

Global.getSector().campaignUI.showCoreUITab(CoreUITabId.INTEL, intel) only opens the intel screen. I'd use IntelUIAPI.selectItem() but I don't know how to get a intel UI instance.

I think you can just pass in an IntelInfoPlugin instead of a CommMessageAPI; the comment is old.

To add to that, it looks like an old method from the days intel was displayed / managed differently. All usages in the API are commented, and instead a real IntelInfoPlugin object is created, and added via `addMessage`. Does anything still use CommMessageAPI?

Quote
CommMessageAPI to select in intel tab, or FleetMemberAPI to select in refit tab

I'm not 100% sure; it may be used under the hood in places, but I don't think it's used anywhere in the API. Could be forgetting something though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NikoTheGuyDude on May 21, 2023, 03:54:31 PM
How does one force a specific intel plugin to open?

Global.getSector().campaignUI.showCoreUITab(CoreUITabId.INTEL, intel) only opens the intel screen. I'd use IntelUIAPI.selectItem() but I don't know how to get a intel UI instance.

I think you can just pass in an IntelInfoPlugin instead of a CommMessageAPI; the comment is old.

I actually tried that initially. It behaves highly inconsistently.

Code
    fun openIntel() {
        val handler = getHandlerWithUpdate() ?: return
        val intel = handler.manipulationIntel ?: return
        Global.getSector().campaignUI.showCoreUITab(CoreUITabId.INTEL, intel)
       // Global.getSector().campaignUI.showCoreUITab(CoreUITabId.INTEL, intel)
    }

This code sometimes opens one of the RELATED intel pieces, or JUST the intel screen, or just a random intel tab. Manipulation intel, by the way, is a unique intel instance for each "handler" class. I've breakpointed it and confirmed that the local val, intel, is usually different from what actually gets opened.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 21, 2023, 03:59:20 PM
Hmm - it's literally the same method that gets called when you click on a new intel item in the lower left to open up that item in the intel screen, with the intel plugin as a parameter, so I strongly suspected it does work. Not sure what you're doing differently, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on May 21, 2023, 06:24:13 PM
Hi, is there a way to stop a mod from being built-in via s-mod?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TheDeviL234 on May 21, 2023, 06:34:31 PM
is it possible to rotate a sprite less than 90 degrees without losing detail or introducing blur? if not, then how does the game deal with ships turning in any direction?
i'm not a graphics guy and this is giving me a headache.

photoshop rotation algorithms as an example:
Spoiler
(https://i.ibb.co/wL5yGxX/sprite-rotation.png) (https://ibb.co/pPY2V98)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 22, 2023, 04:43:52 AM
is there a generic "when the player interacts with something in the campaign" listener?
Particularly, I'm wanting to add a skill to every fleet commander of a given faction & the FleetInflationListener doesn't seem like the right thing for the job

Hi, is there a way to stop a mod from being built-in via s-mod?
look at safety overrides' CSV line, iirc the tag is "no_build_in"
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dentrone on May 22, 2023, 06:40:09 AM
I have no idea how to get Rugged Construction hullmod code. In csv it says com.fs.starfarer.api.impl.hullmods.RuggedConstruction
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on May 22, 2023, 09:11:28 AM
I have no idea how to get Rugged Construction hullmod code. In csv it says com.fs.starfarer.api.impl.hullmods.RuggedConstruction

Most of the available source code can be found in starsector-core/starfarer.api.zip
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 22, 2023, 09:25:54 AM
is it possible to rotate a sprite less than 90 degrees without losing detail or introducing blur? if not, then how does the game deal with ships turning in any direction?
i'm not a graphics guy and this is giving me a headache.

Right, it's not possible. Pixels on a monitor are on an aligned grid (which I guess is a simplifcation, but good enough for thinking about this) and fundamentally turning a sprite meaning math has to happen to make it look alright. But yeah, things will get at least a little blurred when that happens.

is there a generic "when the player interacts with something in the campaign" listener?
Particularly, I'm wanting to add a skill to every fleet commander of a given faction & the FleetInflationListener doesn't seem like the right thing for the job

I think a FleetInflationListener might be your best bet - it'll happen on interaction, and also on mouseover. And whenever some code forces a fleet to be inflated. But generally that seems to be what you'd want for adding a commander skill, I think?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on May 22, 2023, 11:19:12 AM
ahhh, ty!
I thought that it'd only happen when it got force-inflated, though it makes sense that it happens on mouseover / interaction as well.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 23, 2023, 06:46:00 AM
How can I tell which skills can free lance admins have?

Also, I'm trying to display them using tooltip maker but neither addSkillPanel nor addSkillPanelOneColumn seems to work - are these methods hardcoded to just officer skills? Seems different to `printSkills` behaviour used in rules.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 24, 2023, 04:36:30 PM
How can I tell which skills can free lance admins have?

Also, I'm trying to display them using tooltip maker but neither addSkillPanel nor addSkillPanelOneColumn seems to work - are these methods hardcoded to just officer skills? Seems different to `printSkills` behaviour used in rules.csv.

Hmm yeah, those methods look hardcoded to print officer skills only.

For which skills: this is how they're picked in OfficerManagerEvent -

List<String> allSkillIds = Global.getSettings().getSortedSkillIds();
Code
for (String skillId : allSkillIds) {
SkillSpecAPI skill = Global.getSettings().getSkillSpec(skillId);
if (skill.hasTag(Skills.TAG_DEPRECATED)) continue;
if (skill.hasTag(Skills.TAG_PLAYER_ONLY)) continue;
if (skill.hasTag(Skills.TAG_AI_CORE_ONLY)) continue;
if (skill.isAdminSkill()) {
picker.add(skillId);
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on May 24, 2023, 08:04:34 PM
Hi! So, I've been working on updating Mirror (https://fractalsoftworks.com/forum/index.php?topic=25579.0), and noticed that I'd missed mirroring the Assault Chaingun and the Thumper.

Unfortunately, it seems that my current code cannot correctly mirror these weapons: Modifications made to the SpriteAPI returned by WeaponAPI.getSprite() only affect the first frame of the animation, and AnimationAPI seems to only be concerned with the integer value indicating what frame is currently active, without allowing access to SpriteAPI objects for other frames.

Is there a mechanism I'm missing that would allow me to make this work correctly for animated weapons, or is that simply not doable with the current version of Starsector?


Edit: Nevermind, got this working! Hadn't noticed the existence of EveryFrameWeaponEffectPluginWithAdvanceAfter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SteelSirokos on May 28, 2023, 05:41:46 PM
This isn't exactly a modding question, but this seems like the most relevant place to ask it.

What exactly was changed with the launcher rendering code in 0.96a? I had managed to get an Adoptium release of JRE 19 (specifically Temurin-19.0.2+7) working smoothly with 0.95a, but when I set up the same exact environment in my 0.96a installation the launcher instantly crashes with nothing but a blue rectangle rendered when I run starsector.bat.

(https://litter.catbox.moe/siw3x2.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 28, 2023, 07:25:03 PM
@Wyvern: glad you got it figured out!

@SteelSirokos: nothing comes to mind, but, hmm - are you running java with... whatever the option is to turn off classfile verification? It's possible that it's obfuscated in a way that it can't handle. IIRC you have to add -noverify in the beginning of the commandline, too - right after "java" - or it doesn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RoboticManiac on May 28, 2023, 10:47:56 PM
Anyone have an AI image generator that they'd use to generate ship sprites? I can't draw worth a damn and would like to try my hand at modding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: erik17 on May 29, 2023, 08:58:12 AM
Hey, first time modder trying to do something probably impossible and I want to confirm. I saw this mod Particle Engine (https://fractalsoftworks.com/forum/index.php?topic=26453.0) and wanted to use it to replace ship contrail sprites in combat with particles instead, so the contrails would behave realistically with turns, etc.

My plan was to replace the base ShipEngineControllerAPI extendFlame method, which I assume is what handles the contrail sprites, with a new method that uses the particle engine.

However, I can't for the life of me figure out how to do that from the modding API documentation. I'm guessing it's out of scope of the API, and I'd need to actually replace the core jar file with one that has my code in it? But that seems like a generally frowned upon approach for mod compatibility reasons. I've tried searching this forum a ton looking for info and I saw mention of other mods like nex doing that way back when, presumably pre-modding-API, so it should be possible, right?

My other thought was to make a plugin do the overwrite in the onApplicationLoad hook, but I'm having trouble finding details on how to actually go about doing what I want there. Is it possible to register a subclass of ShipEngineControllerAPI somehow so that whatever part of the core code instantiates ShipAPIs knows to use my modded one instead of the default?

I'm a professional dev but never touched java, so I don't need complete handholding, just some pointers. I couldn't find any other posts answering questions quite like this, but I might just not have found the right method name to search for
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on May 30, 2023, 05:43:45 PM
hello once again everyone. i have a small handful of questions again.
1) how does one set a stacks SpecialItemData after said stack has been created?
2) how does one remove a stack from that cargo its in? im trying from its own BaseSpecialItemPlugin, but nothing works
   - i have tried: stack.getCargo().removeStack(stack); stack.setSize(0); stack = null; and any combination of all of them.
3) how does one make it so a items max stack size is 1? i have tried changing stack size in the special item CSV to no effect.
thanks for the past help with the questions. i like modding this game.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jaghaimo on May 31, 2023, 05:18:08 AM
How can I tell if there are any accepted missions from a given Contact (identified as either ContactIntel or PersonAPI)?

What I have (which works, but I am not too happy with) is:
Code
    public static boolean hasActiveMission(PersonAPI person) {
        List<IntelInfoPlugin> missions = Global.getSector().getIntelManager().getIntel(BaseHubMission.class);
        for (IntelInfoPlugin mission : missions) {
            if (mission.isEnded()) {
                continue;
            }
            PersonAPI missionPerson = ((BaseHubMission) mission).getPerson();
            if (missionPerson == person) {
                return true;
            }
        }
        return false;
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 31, 2023, 08:56:08 AM
Hey, first time modder trying to do something probably impossible and I want to confirm. I saw this mod Particle Engine (https://fractalsoftworks.com/forum/index.php?topic=26453.0) and wanted to use it to replace ship contrail sprites in combat with particles instead, so the contrails would behave realistically with turns, etc.

My plan was to replace the base ShipEngineControllerAPI extendFlame method, which I assume is what handles the contrail sprites, with a new method that uses the particle engine.

However, I can't for the life of me figure out how to do that from the modding API documentation. I'm guessing it's out of scope of the API, and I'd need to actually replace the core jar file with one that has my code in it? But that seems like a generally frowned upon approach for mod compatibility reasons. I've tried searching this forum a ton looking for info and I saw mention of other mods like nex doing that way back when, presumably pre-modding-API, so it should be possible, right?

My other thought was to make a plugin do the overwrite in the onApplicationLoad hook, but I'm having trouble finding details on how to actually go about doing what I want there. Is it possible to register a subclass of ShipEngineControllerAPI somehow so that whatever part of the core code instantiates ShipAPIs knows to use my modded one instead of the default?

I'm a professional dev but never touched java, so I don't need complete handholding, just some pointers. I couldn't find any other posts answering questions quite like this, but I might just not have found the right method name to search for

Hi! ShipEngineControllerAPI is not a plugin, it's not set up to be replaced with a different implementation, so that approach wouldn't work. Generally, for Starsector, the convention is that if an interface name ends with API, it's just there to expose core functionality, while if the name ends in Plugin, it's something that can be replaced by an alternative implementation.

This should be doable, though; I know of mods that have replaced engine graphics. Ah, here it is:
https://fractalsoftworks.com/forum/index.php?topic=22693.0

Might be worth checking out for the general approach.


hello once again everyone. i have a small handful of questions again.
1) how does one set a stacks SpecialItemData after said stack has been created?
2) how does one remove a stack from that cargo its in? im trying from its own BaseSpecialItemPlugin, but nothing works
   - i have tried: stack.getCargo().removeStack(stack); stack.setSize(0); stack = null; and any combination of all of them.
3) how does one make it so a items max stack size is 1? i have tried changing stack size in the special item CSV to no effect.
thanks for the past help with the questions. i like modding this game.

1) I don't think you can
2) removeStack() should work but doing it from BaseSpecialItemPlugin seems like it'd be trouble. The UI would not update, I don't think, and it might crash, depending.
3) I don't think you can unless you set CargoAPI.setUnlimitedStacks(false);


How can I tell if there are any accepted missions from a given Contact (identified as either ContactIntel or PersonAPI)?

What I have (which works, but I am not too happy with) is:

That looks good to me. It's not tracked anywhere explicitly so this sort of thing seems like it's the best/only option. Might use HubMission.class instead of BaseHubMission.class, though that's probably academic.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on May 31, 2023, 09:59:15 AM
I have a custom ship in my mod that is equipped with an Accelerated Ammo Feeder as the ship's main system but also an Orion Drive system instead of shields using shield type:PHASE and defense id:orion_device in ship_data.csv. The two systems work in player hands but AI seems to only be able to use the one I place in system id. Is there a method for allowing the AI to use both of these systems at once?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on May 31, 2023, 10:09:23 AM
I have a custom ship in my mod that is equipped with an Accelerated Ammo Feeder as the ship's main system but also an Orion Drive system instead of shields using shield type:PHASE and defense id:orion_device in ship_data.csv. The two systems work in player hands but AI seems to only be able to use the one I place in system id. Is there a method for allowing the AI to use both of these systems at once?

Do you have special_allows_system_use and system_allows_special_use listed as tags for that ship in ship_data.csv?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on May 31, 2023, 10:21:20 AM
I have a custom ship in my mod that is equipped with an Accelerated Ammo Feeder as the ship's main system but also an Orion Drive system instead of shields using shield type:PHASE and defense id:orion_device in ship_data.csv. The two systems work in player hands but AI seems to only be able to use the one I place in system id. Is there a method for allowing the AI to use both of these systems at once?

Do you have special_allows_system_use and system_allows_special_use listed as tags for that ship in ship_data.csv?
Yes. I have these under tags;
rare_bp, special_allows_system_use, system_allows_special_use
AI does not use the Orion Drive at all. It does however get used if I switch the systems around between F and right click, however whichever system is assigned to right click is not used at all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on May 31, 2023, 12:41:48 PM
The ship system AI does not support this system being in a right-click slot on the ship; most ship system AI's don't as this is a relatively new addition.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on May 31, 2023, 02:21:09 PM
The ship system AI does not support this system being in a right-click slot on the ship; most ship system AI's don't as this is a relatively new addition.
Is there any (current or planned) way around this or is this an engine limitation? I would hate to rework what I think is such a great idea for a ship.  :'(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on May 31, 2023, 06:36:16 PM
Making a custom version of the shipsystem and your own AI for it would do the job
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on May 31, 2023, 07:35:15 PM
Does anyone know why engine.applyDamage does not seem to work when used in an unapply method? I keep getting an NPE at the refit screen and there should not be any nulls in the engine variable then(or triggering in refit screen) so I dunno what is happening here.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: itBeABruhMoment on May 31, 2023, 08:58:17 PM
Is there any listeners that run after the player closes an interaction dialog?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on May 31, 2023, 11:37:25 PM
Is it possible to get and modify a missile's engine slot through code?

much like how I can get and modify a ship's engine slots.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 01, 2023, 03:03:20 AM
Does anyone know why engine.applyDamage does not seem to work when used in an unapply method? I keep getting an NPE at the refit screen and there should not be any nulls in the engine variable then(or triggering in refit screen) so I dunno what is happening here.

the refit screen is a wierd not-quite-combatEngine implementation, though Global.getCombatEngine() annoyingly doesn't return null.
just have the unapply() return if the ship's original owner is -1
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 02, 2023, 05:32:19 AM
is there a way to create a spriteAPI that uses an arbitrary textureID / replace the terxtureID that an already-created spriteAPI uses?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 02, 2023, 10:50:40 AM
The ship system AI does not support this system being in a right-click slot on the ship; most ship system AI's don't as this is a relatively new addition.
Is there any (current or planned) way around this or is this an engine limitation? I would hate to rework what I think is such a great idea for a ship.  :'(
Making a custom version of the shipsystem and your own AI for it would do the job

Right! I *may* end up doing this for some vanilla system AI's at some point, but chances are that would happen if I needed to put them on a right-click for something in vanilla.

Is there any listeners that run after the player closes an interaction dialog?

I don't think so, offhand. But you can check ListenerUtil and CampaignEventListener to make sure.


the refit screen is a wierd not-quite-combatEngine implementation, though Global.getCombatEngine() annoyingly doesn't return null.
just have the unapply() return if the ship's original owner is -1

(Depending on the specific NPE, this may be a good idea, or it might not be sufficient...)


Is it possible to get and modify a missile's engine slot through code?

much like how I can get and modify a ship's engine slots.

Hmm, I ... don't know? It'd make it easier on me to know what you're doing with a ship so I can easily check if missiles expose the same functionality or not, rather than trying to guess and dig around in ShipAPI and related.

is there a way to create a spriteAPI that uses an arbitrary textureID / replace the terxtureID that an already-created spriteAPI uses?

SettingsAPI.getSprite(), various methods. No way to change an existing SpriteAPI.

Note that the sprite must already be loaded by the game. The way to do this for arbitrary sprites is to add them to a subsection of the "graphics" section in settings.json.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Foraven on June 02, 2023, 02:50:08 PM
What does control what ships are sold and where? I want to understand what can be done with several of the mods I am using that either their ships are not sold anywhere or they end up so common that they replace vanilla ships on the market. I have played a mostly stock game of 0.96a and never had a problem finding ships... But some mods just seem to flood the markets once they are added and vanilla ships are no where to be seen...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 02, 2023, 05:41:39 PM
SettingsAPI.getSprite(), various methods. No way to change an existing SpriteAPI.

Note that the sprite must already be loaded by the game. The way to do this for arbitrary sprites is to add them to a subsection of the "graphics" section in settings.json.

mhm, that's a shame
I'm messing around with generating textures on the fly for some silly things & being able to wrap them in a spriteAPI would be nice for feeding them into some vanilla things, though I can still do almost everything I want to w/o it
(Though I could alos do some wierd stuff with dummy textures & overwriting their data but I get the feeling that'll break somehow :p)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Orochi on June 02, 2023, 09:55:02 PM
In the age_gen_data.csv, which lives in the procgen file, there are two values, 'maxExtraOrbits" and 'minExtraOrbits'

What exactly do these do? Because the number of orbits seems to primarily controlled by the 'minOrbits' and 'maxOrbits' value in star_gen_data.csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on June 03, 2023, 03:39:56 AM
When a player encounters a fleet and enters the dialog window where they can choose open a comm link, move in to engage, etc, is that enter dialog event something I could use to modify ships in the listed fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on June 03, 2023, 03:58:08 AM
Hmm, I ... don't know? It'd make it easier on me to know what you're doing with a ship so I can easily check if missiles expose the same functionality or not, rather than trying to guess and dig around in ShipAPI and related.

Some of the methods I tried for engine controller didn't work on missiles, iirc. like forcing a flameout or change flamelevel etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on June 04, 2023, 05:21:18 PM
Hi, is there a way to let an AI know that an incoming Kinetic projectile has an HE component to it under the hood? The idea is to stop the AI from bringing down it's shield for a projectile that has a higher HE vs Kinetic damage component - but it's important that the projectile itself remains Kinetic (because it impacts first as Kinetic).

Alternatively, would it be possible to make it so that, upon hit, I can insert some Kinetic damage BEFORE the primary projectile, set to HE, gets resolved for damage?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on June 05, 2023, 05:36:15 AM
Hi, is there a way to let an AI know that an incoming Kinetic projectile has an HE component to it under the hood? The idea is to stop the AI from bringing down it's shield for a projectile that has a higher HE vs Kinetic damage component - but it's important that the projectile itself remains Kinetic (because it impacts first as Kinetic).

Alternatively, would it be possible to make it so that, upon hit, I can insert some Kinetic damage BEFORE the primary projectile, set to HE, gets resolved for damage?

on a technical level there are 2 solutions to this -
1 - give the weapon the DANGEROUS hint
2 - use a DamagedealtModifier listener to change a portion of the damage to he / ke as needed

but on a design / concept level, why are you making something that's almost purpose-built to abuse the AI?
if it's KE + HE, it's better to just make it deal energy damage & avoid AI problems altogether imo.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: sajberhippien on June 05, 2023, 07:06:41 AM
Having never modded the game, but having some experience modding other games, would it be a lot of work to learn how to make a mod that simply customizes SP costs for various vanilla actions? Basically, I wanna adjust SP costs so that the things I find myself almost always spending points on get more expensive, while slightly increasing general SP gains (but I know how to do the latter by looking at this (https://fractalsoftworks.com/forum/index.php?topic=20535.0) mod).
A bunch of story point costs (well, the bonus XP values at least) are in settings.json's bonusXP table; also note the three values above it for a few actions that cost multiple points.
Mods may have story point events in code that aren't accessible in this way however.

Thank you! That helps a lot. 'Avoid pursuit through clever maneuvering' is surely gonna go from 100% to like, 25%...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 05, 2023, 12:15:42 PM
What does control what ships are sold and where? I want to understand what can be done with several of the mods I am using that either their ships are not sold anywhere or they end up so common that they replace vanilla ships on the market. I have played a mostly stock game of 0.96a and never had a problem finding ships... But some mods just seem to flood the markets once they are added and vanilla ships are no where to be seen...

The game basically creates a fake fleet for that particular faction and puts ships from it into the market. There are more details/nuance, but that's at the heart of it. It's also possible for mods to use code to directly modify what's for sale, so, it's just hard to say.

Some of the methods I tried for engine controller didn't work on missiles, iirc. like forcing a flameout or change flamelevel etc.

Ah! Forgive my eminently unhelpful answer, but in that case, the methods likely just don't work for missiles :)

When a player encounters a fleet and enters the dialog window where they can choose open a comm link, move in to engage, etc, is that enter dialog event something I could use to modify ships in the listed fleets?

What event, specifically?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on June 05, 2023, 02:51:35 PM
Query. I've encountered something rather odd and am unsure if its actually just my installation. (Mostly stock Starsector with Dev mod active and Nexerelin active only when I'm playtesting the mod I'm building: Star Trek Eras)

So I've add vast bulk to a station. Every time I do and play test, battles in edit variants, the vessel do not move in on the station to attack. Or rather, they get just within range and do not attack at all. They take a heavy beating, just sitting there until they die.

When I remove vast bulk, the ships move in and fires everything they've got. Is this possibly a bug, an issue with Edit Variants, or just my install? [Note, I've had and updated the same installation for a couple of years now]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on June 05, 2023, 04:17:56 PM

When a player encounters a fleet and enters the dialog window where they can choose open a comm link, move in to engage, etc, is that enter dialog event something I could use to modify ships in the listed fleets?

What event, specifically?

I'm trying to do the following:
1.) Have mod_info.json load MyModPlugin extends BaseModPlugin
2.) onNewGame() myModPlugin creates a new custom FleetEncounterListener extends BaseCampaignEventListener
3.) Every time FleetEncounterListener hears player fleet interacting with another fleet in the dialog window (@override reportShownInteractionDialog?) do something, for example reduce combat readiness to the player flagship.

The dialog in question is the one players have whenever two fleets meet and they get to choose to talk to the enemy captain, engage, perform s-maneuver to force an engagement or run away, or do emergency repairs, etc. Maybe I'm not initializing the listener properly, or not coding in the right method, but the game never seems to get to the "do something" part. I'm wondering if I'm on the right path.

Edit: Not sure what I was doing wrong earlier but I got it to work. I guess I need to ask a followup question. In this scenario, how would I check the player is interacting with a fleet, and not say a buoy? I imagine it could be done with checking if the SectorEntityToken from InteractionDialogAPI.getInteractionTarget() is an instance of CampaignFleetAPI, but I'm not sure if this is right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 06, 2023, 12:18:41 PM
Query. I've encountered something rather odd and am unsure if its actually just my installation. (Mostly stock Starsector with Dev mod active and Nexerelin active only when I'm playtesting the mod I'm building: Star Trek Eras)

So I've add vast bulk to a station. Every time I do and play test, battles in edit variants, the vessel do not move in on the station to attack. Or rather, they get just within range and do not attack at all. They take a heavy beating, just sitting there until they die.

When I remove vast bulk, the ships move in and fires everything they've got. Is this possibly a bug, an issue with Edit Variants, or just my install? [Note, I've had and updated the same installation for a couple of years now]

Vast Bulk is intended to be added to components that are indestructible and not meant for other ships to target intentionally. Since the station becomes indestructible, the AI-controlled ships do not target it. Basically, adding Vast Bulk to anything with weapons or fighters mounted is a mistake.


I'm trying to do the following:
1.) Have mod_info.json load MyModPlugin extends BaseModPlugin
2.) onNewGame() myModPlugin creates a new custom FleetEncounterListener extends BaseCampaignEventListener
3.) Every time FleetEncounterListener hears player fleet interacting with another fleet in the dialog window (@override reportShownInteractionDialog?) do something, for example reduce combat readiness to the player flagship.

The dialog in question is the one players have whenever two fleets meet and they get to choose to talk to the enemy captain, engage, perform s-maneuver to force an engagement or run away, or do emergency repairs, etc. Maybe I'm not initializing the listener properly, or not coding in the right method, but the game never seems to get to the "do something" part. I'm wondering if I'm on the right path.

Edit: Not sure what I was doing wrong earlier but I got it to work. I guess I need to ask a followup question. In this scenario, how would I check the player is interacting with a fleet, and not say a buoy? I imagine it could be done with checking if the SectorEntityToken from InteractionDialogAPI.getInteractionTarget() is an instance of CampaignFleetAPI, but I'm not sure if this is right.

Thank you for the details!

What you're trying to do should work, but not everything like that would work because the reportShownInteractionDialog() method is called after the dialog is shown. So for example it might be too late to add or remove a ship since the existing UI of the dialog might already be created and might not update to show that kind of change. But e.g. the CR change should get picked up, I think.

Re: checking if it's a fleet: yeah, that's exactly right!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on June 06, 2023, 06:35:20 PM
Query. I've encountered something rather odd and am unsure if its actually just my installation. (Mostly stock Starsector with Dev mod active and Nexerelin active only when I'm playtesting the mod I'm building: Star Trek Eras)

So I've add vast bulk to a station. Every time I do and play test, battles in edit variants, the vessel do not move in on the station to attack. Or rather, they get just within range and do not attack at all. They take a heavy beating, just sitting there until they die.

When I remove vast bulk, the ships move in and fires everything they've got. Is this possibly a bug, an issue with Edit Variants, or just my install? [Note, I've had and updated the same installation for a couple of years now]

Vast Bulk is intended to be added to components that are indestructible and not meant for other ships to target intentionally. Since the station becomes indestructible, the AI-controlled ships do not target it. Basically, adding Vast Bulk to anything with weapons or fighters mounted is a mistake.


@Alex  Thanks for the explaination. I don't know why my brain wasn't clicking on why vast bulk wasn't working on a weaponized entity. I kinda of figured it out after playing around. I honestly had never used Vast Bulk before as an option on a station, so I slapped it on without properly understanding its use case as a hullmod.

Thank you so much for the answer! It's certainly helped a lot!

Another quick question that you don't need to answer. Will there a future option for a hullmod kinda of like vast bulk but less OP by a great magnitude? I noticed that the absorbtion of all damage is actually kind of useful in battle. So taking hits on exposed hull that is absorbed by armor is actually an interesting concept. As the damage is absorbed, the armor burns away from the rest of the vessel until leaving it it completed unarmored. It'd be interesting to see it applied to special use case ships, maybe a retrofitted tanker to bust through "blockades".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ivan Fullbright on June 06, 2023, 09:58:47 PM
Is there any way to change a ship's style (as in, from hull_styles.json) in a skin? I was looking at the Brawler (TT) as an example, but it seems like that just changes the engines. The biggest difference in styles is the red vs blue shields, which doesn't come into play in that specific case, but there's also a couple of misc changes involved like color-matched d-mod and damage overlays that might be nice to have for similar altered-tech-level skins.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nona on June 07, 2023, 12:27:28 AM
Hello helloooooo I'm drawing a hull sprite but it doesn't look similar enough to vanilla's artstyle to me and I've been staring at it for too long, does anyone here have suggestions? Thank you!

Spoiler
(https://i.imgur.com/oXePH51.png)
(https://i.imgur.com/zAjI3Od.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on June 08, 2023, 11:32:22 PM
I'm trying to do the following:
1.) Have mod_info.json load MyModPlugin extends BaseModPlugin
2.) onNewGame() myModPlugin creates a new custom FleetEncounterListener extends BaseCampaignEventListener
3.) Every time FleetEncounterListener hears player fleet interacting with another fleet in the dialog window (@override reportShownInteractionDialog?) do something, for example reduce combat readiness to the player flagship.

The dialog in question is the one players have whenever two fleets meet and they get to choose to talk to the enemy captain, engage, perform s-maneuver to force an engagement or run away, or do emergency repairs, etc. Maybe I'm not initializing the listener properly, or not coding in the right method, but the game never seems to get to the "do something" part. I'm wondering if I'm on the right path.

Edit: Not sure what I was doing wrong earlier but I got it to work. I guess I need to ask a followup question. In this scenario, how would I check the player is interacting with a fleet, and not say a buoy? I imagine it could be done with checking if the SectorEntityToken from InteractionDialogAPI.getInteractionTarget() is an instance of CampaignFleetAPI, but I'm not sure if this is right.

Thank you for the details!

What you're trying to do should work, but not everything like that would work because the reportShownInteractionDialog() method is called after the dialog is shown. So for example it might be too late to add or remove a ship since the existing UI of the dialog might already be created and might not update to show that kind of change. But e.g. the CR change should get picked up, I think.

Re: checking if it's a fleet: yeah, that's exactly right!

Thanks, I noticed the ordering issue too but luckily I still got what I wanted to work :)

Is there any way to change a ship's style (as in, from hull_styles.json) in a skin? I was looking at the Brawler (TT) as an example, but it seems like that just changes the engines. The biggest difference in styles is the red vs blue shields, which doesn't come into play in that specific case, but there's also a couple of misc changes involved like color-matched d-mod and damage overlays that might be nice to have for similar altered-tech-level skins.

When I was trying to do this, the workaround I ended up using was to create a dummy .ship copy of the base hull with its own entry in ship_data.csv, but under the right tech style, then have the skin reference the new base hull. You can even get the descriptions hooked up so that everything looks right when seen by the player. Just hide the base hull from the codex and don't add it to default_ship_roles.json and the player will never see it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on June 09, 2023, 11:32:13 AM
Is there any way of reseting colony UI i mean i have managed by reverse enginniering code from Grand Colonies to detect market which is currently seen on ColonyUI remotley, and i wanted to reset UI like it is done when one of buttons is pressed. Where i can look for code that executes that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on June 10, 2023, 09:36:19 AM
ive got a pernicious error that i cant seem to find the origin of
Spoiler
329893 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoClassDefFoundError: particleengine/IEmitter
java.lang.NoClassDefFoundError: particleengine/IEmitter
   at unthemedweapons.combat.scripts.EnergyTorpedoEffect.onFire(EnergyTorpedoEffect.java:83)
   at com.fs.starfarer.combat.entities.ship.A.J.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.J.fireProjectile(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.new.Óo0000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.new.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.new.Ô00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.J.advance(Unknown Source)
   at com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
   at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: particleengine.IEmitter
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 21 more
[close]
any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: float on June 10, 2023, 10:13:11 AM
ive got a pernicious error that i cant seem to find the origin of
Spoiler
329893 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NoClassDefFoundError: particleengine/IEmitter
java.lang.NoClassDefFoundError: particleengine/IEmitter
   at unthemedweapons.combat.scripts.EnergyTorpedoEffect.onFire(EnergyTorpedoEffect.java:83)
   at com.fs.starfarer.combat.entities.ship.A.J.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.J.fireProjectile(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.new.Óo0000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.new.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.D.o00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.trackers.new.Ô00000(Unknown Source)
   at com.fs.starfarer.combat.entities.ship.A.J.advance(Unknown Source)
   at com.fs.starfarer.combat.systems.oOoO.advanceLinked(Unknown Source)
   at com.fs.starfarer.combat.systems.oOoO.advance(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.fire(Unknown Source)
   at com.fs.starfarer.combat.entities.Ship.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: particleengine.IEmitter
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 21 more
[close]
any ideas?

Is your Particle Engine version out of date? Latest version (0.5) introduced IEmitter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 10, 2023, 10:29:28 AM
Is there any way to change a ship's style (as in, from hull_styles.json) in a skin? I was looking at the Brawler (TT) as an example, but it seems like that just changes the engines. The biggest difference in styles is the red vs blue shields, which doesn't come into play in that specific case, but there's also a couple of misc changes involved like color-matched d-mod and damage overlays that might be nice to have for similar altered-tech-level skins.

You should be able to use a "style" field for this.

(Sorry for the delayed response, btw!)

Another quick question that you don't need to answer. Will there a future option for a hullmod kinda of like vast bulk but less OP by a great magnitude? I noticed that the absorbtion of all damage is actually kind of useful in battle. So taking hits on exposed hull that is absorbed by armor is actually an interesting concept.

I think in many ways, that's just... armor :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ivan Fullbright on June 10, 2023, 01:38:57 PM
Is there any way to change a ship's style (as in, from hull_styles.json) in a skin? I was looking at the Brawler (TT) as an example, but it seems like that just changes the engines. The biggest difference in styles is the red vs blue shields, which doesn't come into play in that specific case, but there's also a couple of misc changes involved like color-matched d-mod and damage overlays that might be nice to have for similar altered-tech-level skins.

You should be able to use a "style" field for this.

(Sorry for the delayed response, btw!)


No worries, thanks for the response! I wasn't sure if the style field could be changed by skins since I hadn't seen any examples of it, I suppose I could have just tried it to see... lesson learned  :o
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on June 10, 2023, 03:15:57 PM
Hello helloooooo I'm drawing a hull sprite but it doesn't look similar enough to vanilla's artstyle to me and I've been staring at it for too long, does anyone here have suggestions? Thank you!

It's too smooth/blurred, I just ran it through a quick sharpen filter:

Spoiler
(https://i.postimg.cc/1txzVSB6/Screenshot-from-2023-06-10-23-11-57.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nona on June 10, 2023, 06:14:50 PM
Hello helloooooo I'm drawing a hull sprite but it doesn't look similar enough to vanilla's artstyle to me and I've been staring at it for too long, does anyone here have suggestions? Thank you!

It's too smooth/blurred, I just ran it through a quick sharpen filter:

Spoiler
(https://i.postimg.cc/1txzVSB6/Screenshot-from-2023-06-10-23-11-57.png)
[close]

I'll try that, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on June 11, 2023, 01:43:44 AM
Is there a way for a hullmod on a module to check for the presence of a hullmod on the core ship?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 11, 2023, 08:49:48 AM
Is there a way for a hullmod on a module to check for the presence of a hullmod on the core ship?

In the refit screen, or for the purposes of hullmod installation requirements, I don't think so. In combat, yes - see the com.fs.starfarer.api.impl.hullmods.SharedFluxSink class for an example of doing something similar, though it's just checking other modules, not the core ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on June 11, 2023, 04:26:44 PM
Is there a way for a hullmod on a module to check for the presence of a hullmod on the core ship?

In the refit screen, or for the purposes of hullmod installation requirements, I don't think so. In combat, yes - see the com.fs.starfarer.api.impl.hullmods.SharedFluxSink class for an example of doing something similar, though it's just checking other modules, not the core ship.

Ah, thanks. I ended up using a built-in core hullmod to manipulate modules based on the presence or absence of other hullmods on the core ship itself, which worked out well.

Speaking of modules, I have another question. I'm not sure if this is a bug or if I'm missing something, but I have a ship that has a module, and on this module is a fighter bay with a built in fighter. So, no autofit issues. Normally, this wing always deploys to assist the core ship without being under its direct control. However, the wing never deploys when the ship is in enemy hands.

It's the weirdest thing. I could literally have one copy of the variant fight against itself in the simulator, and only the player controlled one will deploy its module fighters. What might be causing this and how do I avoid it? Station fighters seem to deploy just fine when fighting against them, so I'm not sure what's causing this. I even tried a version with no hullmod code touching it in any way and the behavior is still the same.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on June 12, 2023, 12:36:25 AM
Is there any way of modyfing  or infuencing default industry Tooltips like downgrade to upgrade to options ? As i know there is new plugin that eneables you to add more options to tooltip  but what about modyfing existing ones?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 12, 2023, 08:26:12 AM
Speaking of modules, I have another question. I'm not sure if this is a bug or if I'm missing something, but I have a ship that has a module, and on this module is a fighter bay with a built in fighter. So, no autofit issues. Normally, this wing always deploys to assist the core ship without being under its direct control. However, the wing never deploys when the ship is in enemy hands.

It's the weirdest thing. I could literally have one copy of the variant fight against itself in the simulator, and only the player controlled one will deploy its module fighters. What might be causing this and how do I avoid it? Station fighters seem to deploy just fine when fighting against them, so I'm not sure what's causing this. I even tried a version with no hullmod code touching it in any way and the behavior is still the same.

... weird! I have no idea. As you say, stations do work, though, so I'd suggest using that as a starting point and making gradual changes towards your setup until you isolate what's going wrong. It *is* possible that it's a vanilla bug; not aware of anything like that, but still.

Is there any way of modyfing  or infuencing default industry Tooltips like downgrade to upgrade to options ? As i know there is new plugin that eneables you to add more options to tooltip  but what about modyfing existing ones?

You'd have to replace the class that implements the industry. These tooltips are created in the BaseIndustry.createTooltip() method, depending on the "mode" parameter.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on June 12, 2023, 03:19:59 PM
Speaking of modules, I have another question. I'm not sure if this is a bug or if I'm missing something, but I have a ship that has a module, and on this module is a fighter bay with a built in fighter. So, no autofit issues. Normally, this wing always deploys to assist the core ship without being under its direct control. However, the wing never deploys when the ship is in enemy hands.

It's the weirdest thing. I could literally have one copy of the variant fight against itself in the simulator, and only the player controlled one will deploy its module fighters. What might be causing this and how do I avoid it? Station fighters seem to deploy just fine when fighting against them, so I'm not sure what's causing this. I even tried a version with no hullmod code touching it in any way and the behavior is still the same.
... weird! I have no idea. As you say, stations do work, though, so I'd suggest using that as a starting point and making gradual changes towards your setup until you isolate what's going wrong. It *is* possible that it's a vanilla bug; not aware of anything like that, but still.

So with some more sleuthing, I've managed to trace the problem down to the module itself not spawning on any other ship except for the player. Even though in the ship deployment window you can see graphically the module is attached to the ship, by the time it shows up in battle the module is gone. I have no idea what might cause this since the module is just a part of the variant file and isn't being dynamically spawned or even interacted with by modded code. I'm also testing this in the simulator so the game shouldn't be autofitting anything.

Edit: omg I think I figured it out. The ships were missing the SHIP_WITH_MODULES hint. What a face palming moment. If I hadn't stumbled across the station mechanics guide I would have never figured it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Prophet-x on June 13, 2023, 11:31:33 AM
How to make a weapon's sprite render below the ship's or module's sprite? I know it is viable to use a deco weapon to cover the weapon, however in practice if the deco weapon is too large it will have some issues displaying the damage decal as the deco weapon will only display damage decal when the center of the weapon is hit and the decal on the deco weapon is less dense bright compared to the decal generated on the hull. I konw there are a lot of layers in the combat engine, so is it possible to manually to set the weapon sprite's render layer below the ship's layer? I think this could contribute to some cool designs and having the ability to display weapon below the ship could, in some ways, make ships have more three-dimensional feelings (I suppose :P).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 13, 2023, 04:13:11 PM
Edit: omg I think I figured it out. The ships were missing the SHIP_WITH_MODULES hint. What a face palming moment. If I hadn't stumbled across the station mechanics guide I would have never figured it out.

Glad you got it figured out, at any rate :)

How to make a weapon's sprite render below the ship's or module's sprite? I know it is viable to use a deco weapon to cover the weapon, however in practice if the deco weapon is too large it will have some issues displaying the damage decal as the deco weapon will only display damage decal when the center of the weapon is hit and the decal on the deco weapon is less dense bright compared to the decal generated on the hull. I konw there are a lot of layers in the combat engine, so is it possible to manually to set the weapon sprite's render layer below the ship's layer? I think this could contribute to some cool designs and having the ability to display weapon below the ship could, in some ways, make ships have more three-dimensional feelings (I suppose :P).

I don't believe this is possible. (Well, I suppose one might use multiple deco weapons to get around the issue you describe...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FireBlitz8404 on June 13, 2023, 05:36:14 PM
Just started the game back up again after awhile and got a bunch of mods as normal ya.
So the mod menu is not allowing me to activate mods not matching the exact version type.
How do I force the mods on?

(I edited the enabled_mods.json but it resets after closing the game and is annoying to change everytime.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: manictiger on June 14, 2023, 01:47:46 PM
It's supposed to be an 8 frame animation.  Ship editor won't let me add it at all.

(http://Decorative not working.jpg)

Spoiler
{
   "id":"shield_anim",  # this id must match what's in the spreadsheet
   "specClass":"projectile",
   "type":"DECORATIVE",
   "size":"MEDIUM",
   #"everyFrameEffect":"com.fs.starfarer.api.impl.combat.BlinkerEffect",
   #"showDamageWhenDecorative":false,
   #"renderBelowAllWeapons":true,
   #"renderHints":["RENDER_ADDITIVE"],
   "turretSprite":"graphics/weapons/decorative/shield_anim_00.png",
   "hardpointSprite":"graphics/weapons/decorative/shield_anim_00.png",   
   "numFrames":8,
   "frameRate":4,
   "alwaysAnimate":"true",
   "turretOffsets":[0, 0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[0, 0],
   "hardpointAngleOffsets":[0],   
   "fringeColor":[255,255,255,255],
   "coreColor":[255,255,255,255],
   "glowColor":[255,255,255,255],
   "width":1.0,
   "textureType":ROUGH,
   "textureScrollSpeed":1.0,
   "pixelsPerTexel":1.0,   
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 14, 2023, 02:22:36 PM
If the spectype's PROJECTILE, you need a named reference to, you guessed it, a .proj file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: manictiger on June 14, 2023, 04:15:08 PM
If the spectype's PROJECTILE, you need a named reference to, you guessed it, a .proj file.

Switched it back to "beam" and it's still not working.  I just want it to animate the shield as a decorative.  There's no tutorial anywhere, so I'm just blindly stumbling through the dark trying to figure this out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on June 14, 2023, 06:32:38 PM
No problem, let's see if I can help properly then.

Here's a standard Decorative I use:
Spoiler
{
   "specClass":"beam",
   "id":"thruster_fighter_sm",
   "type":"DECORATIVE",
   "size":"SMALL",
   
   "showDamageWhenDecorative":true,

   "turretSprite":"graphics/FX/nothing.png",
   "hardpointSprite":"graphics/FX/nothing.png",

   "turretOffsets":[0,0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[0,0],
   "hardpointAngleOffsets":[0],

   "fringeColor":[255,255,255,0],
   "coreColor":[255,255,255,0],
   "glowColor":[255,255,255,0],

   "width":1.0,
   "textureType":ROUGH,
   "textureScrollSpeed":1.0,
   "pixelsPerTexel":1.0,
}
[close]

I would think that if these lines were added, you should be good?

   "numFrames":8,
   "frameRate":4,
   "alwaysAnimate":"true",

If not, let me know. You're sure that you've loaded the mod in question in the ship editor, I presume?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: manictiger on June 15, 2023, 12:44:51 AM
No problem, let's see if I can help properly then.

Here's a standard Decorative I use:
Spoiler
{
   "specClass":"beam",
   "id":"thruster_fighter_sm",
   "type":"DECORATIVE",
   "size":"SMALL",
   
   "showDamageWhenDecorative":true,

   "turretSprite":"graphics/FX/nothing.png",
   "hardpointSprite":"graphics/FX/nothing.png",

   "turretOffsets":[0,0],
   "turretAngleOffsets":[0],
   "hardpointOffsets":[0,0],
   "hardpointAngleOffsets":[0],

   "fringeColor":[255,255,255,0],
   "coreColor":[255,255,255,0],
   "glowColor":[255,255,255,0],

   "width":1.0,
   "textureType":ROUGH,
   "textureScrollSpeed":1.0,
   "pixelsPerTexel":1.0,
}
[close]

I would think that if these lines were added, you should be good?

   "numFrames":8,
   "frameRate":4,
   "alwaysAnimate":"true",

If not, let me know. You're sure that you've loaded the mod in question in the ship editor, I presume?

Thank you!!!  That did it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FunkyBacon on June 16, 2023, 12:36:44 AM
Edit: Nevermind, found the reason. Apparently the 'System' tag in weapon_data.csv makes weapons not spawn even when specified!

Question regarding devmode and weapon spawning through the console commands. I have added a bunch of my own weapons for a mod hopefully soon to be released.
I am trying to spawn a certain weapon from that mod but every time it autocorrects it to a different but similar weapon. The weapon files etc. all are pointing to the right places from what I can tell. Other weapons I can spawn just fine.

Does anyone know how I can circumvent this autocorrect issue? Double "" doesn't seem to do anything except change the autocorrect from Micro>Small to Micro>Medium.   ???

Thanks!

Edit:
It's actually not showing up under "list weapons" command despite being loaded according to the logs. The base weapon it is based on is being loaded and displayed under list weapons so maybe I forgot an extra file somewhere that differs from other weapons... search continues.

Spawn Logs:
Spoiler
783129 [Thread-3] INFO  org.lazywizard.console.Console  - > addweapon ancient_micro_drone_launcher
783131 [Thread-3] INFO  org.lazywizard.console.Console  - Added 1 of weapon Ancient_Small_Drone_Launcher to player inventory.
876670 [Thread-3] INFO  org.lazywizard.console.Console  - > addweapon ancient_micro_drone_launcher 20
876670 [Thread-3] INFO  org.lazywizard.console.Console  - Added 20 of weapon Ancient_Small_Drone_Launcher to player inventory.
1144705 [Thread-3] INFO  org.lazywizard.console.Console  - > addweapon ancient_small_drone_Launcher
1144705 [Thread-3] INFO  org.lazywizard.console.Console  - Added 1 of weapon Ancient_Small_Drone_Launcher to player inventory.
1155254 [Thread-3] INFO  org.lazywizard.console.Console  - > addweapon ancient_medeium_drone_launcher
1155254 [Thread-3] INFO  org.lazywizard.console.Console  - Added 1 of weapon Ancient_Medium_Drone_Launcher to player inventory.
1184904 [Thread-3] INFO  org.lazywizard.console.Console  - > addweapon Ancient_Micro_Drone_Launcher
1184904 [Thread-3] INFO  org.lazywizard.console.Console  - Added 1 of weapon Ancient_Small_Drone_Launcher to player inventory.
1192030 [Thread-3] INFO  org.lazywizard.console.Console  - > addweapon "Ancient_Micro_Drone_Launcher"
1192030 [Thread-3] INFO  org.lazywizard.console.Console  - Added 1 of weapon Ancient_Medium_Drone_Launcher to player inventory.
[close]

Logs
Spoiler
6492 [Thread-3] INFO  com.fs.starfarer.loading.WeaponSpreadsheetLoader  - Applying data from weapon_data.csv to [Ancient_Micro_Drone_Launcher]
6258 [Thread-3] INFO  com.fs.starfarer.loading.WeaponSpecLoader  - Loading weapon [data\weapons\Ancient_Micro_Drone_Launcher.wpn]
6259 [Thread-3] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Pearlabyss\Star Sector\Starsector\starsector-core\..\mods\BC-304 (data\weapons\Ancient_Micro_Drone_Launcher.wpn)]
6071 [Thread-3] INFO  com.fs.starfarer.loading.WeaponSpecLoader  - Loading projectile [data\weapons\proj\Ancient_Micro_Drone_Launcher.proj]
6072 [Thread-3] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Pearlabyss\Star Sector\Starsector\starsector-core\..\mods\BC-304 (data\weapons\proj\Ancient_Micro_Drone_Launcher.proj)]
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Spitton on June 16, 2023, 02:50:32 AM
How to mod custom music into Starsector,i want to make it selectable with Nexelerin as my faction market/encounter music without replacing or adding files to the core file systems
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on June 16, 2023, 07:52:17 PM
For that, you can make a fake faction and add the tracks to its market/encounter music (also needs a sounds.json file with the relevant entries, ofc). [Explanation of how to do this omitted]

Next time I'll add a list to add custom tracks directly for that picker without making a new faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on June 17, 2023, 08:56:58 AM
Is there some way to determine which ship is currently selected in the command HUD (the thing that opens via TAB-key) in combat?

Code
Global.getEngine().getCombatUI().getMainTargetReticleTarget()
seems to always return null.

Same for getAllTargetRecticleTargets and getEntityToFollowV2.

Is that intentional? Am I missing something?

Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 17, 2023, 05:45:18 PM
Is there some way to determine which ship is currently selected in the command HUD (the thing that opens via TAB-key) in combat?

I don't believe there is. The "reticle" stuff is for what's moused over/targeted in the combat view using the R key.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on June 18, 2023, 02:30:21 AM
I don't believe there is. The "reticle" stuff is for what's moused over/targeted in the combat view using the R key.

Ahh, thank you! So it's essentially the same as Global.getEngine().getPlayerShip().getShipTarget()?

Is there any chance you might add a method to get the ships currently selected in the command HUD? That would be awesome!

But of course I also understand if that isn't a priority for you.

Anyhow, thank you for the answer, I appreciate it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 18, 2023, 12:50:01 PM
Yeah, it's the same. I'll... keep in mind! Would help if I knew exactly what the use case is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DesperatePeter on June 19, 2023, 01:00:07 AM
Yeah, it's the same. I'll... keep in mind! Would help if I knew exactly what the use case is.

Thank you!

In my mod, Advanced Gunnery Control (https://fractalsoftworks.com/forum/index.php?topic=21280.0) (if you have a few moments to spare, you can watch the first ~15 seconds of the youtube video at the top of the first page), the user can press a hotkey to open up a GUI to configure what different weapon groups are supposed to do when set to autofire. By default, it opens the GUI for the currently deployed flagship. The user can also target an ally via R-Key to set up modes for the ally. This works great for setting up modes for nearby allies, but doesn't really work for far-away allies and becomes nigh-impossible, when playing battles from the command HUD without a flagship deployed.
Therefore, it would be very cool to be able to query which ship is currently selected in the command HUD (if it is open) to let people configure far-away ships.

I actually already found a solution that seems to work, but it's kind of ugly, so if there was a simple method like Global.getCombatEngine().getCombatUi().getShip(s)CurrentlySelectedInCommandHUD(), that would be awesome!

Thank you for your time!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on June 20, 2023, 04:18:15 PM
hello again to you all. i have returned with more questions:
1) is it possible to get a list of the skills that a randomly generated officer / admin can spawn with / gain as they level up?
2) how do i get the possible officer personality from a fleet doctrine? i tried doctrine.getAggression(), only to realize that aggression 4 includes both aggressive and reckless officers, and I was wondering if there was a easy way to get a random officer personality / the full list of possible officer personalities for a given faction?
3) how mush does it cost to hire a given admin or officer at different levels?
thanks for reading my silly questions. i really like modding this game for some reason, and you all awensering my questions have made this mush more enjoyable, so thanks for that =)

edit: more questions because i have no patience:
4) (in the rules.csv) what rule is ran that shows the 'found a market' screen?
5) can i trigger the 'found a market' screen with code?
thanks again and things bye
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on June 25, 2023, 03:27:59 AM
Currently, non-bomber fighter behavior when attacking is to either crowd over the target (default) or attempt to make a wider pass if they have the relative speed to do so (with the attack_at_an_angle tag).
In old versions of Starsector, I remember a fighter behavior of circle-strafing targets while firing at them. Is it still possible to enable this for select wings? Thank you for any answers.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on June 25, 2023, 10:34:15 AM
Have question concerning hull files. First is Shrike, which has renderModProperty in one of its weapon slots:

Spoiler
Code
        {
            "angle": 0,
            "arc": 210,
            "id": "WS 001",
            "renderOrderMod":10,
            "locations": [
                31,
                0
            ],
            "mount": "TURRET",
            "size": "SMALL",
            "type": "ENERGY"
        },
[close]

Second is Sunder, which has a "position" point field in its weapon slots in addition to the usual "location" one:

Spoiler
Code
    "weaponSlots": [
        {
            "angle": 0,
            "arc": 5,
            "id": "WS 001",
            "locations": [
                27,
                48
            ],
            "mount": "HARDPOINT",
            "position": [
                51,
                80
            ],
            "size": "SMALL",
            "type": "MISSILE"
        },
        {
            "angle": 0,
            "arc": 5,
            "id": "WS 002",
            "locations": [
                29,
                30
            ],
            "mount": "HARDPOINT",
            "position": [
                121,
                50
            ],
            "size": "MEDIUM",
            "type": "ENERGY"
        },
        {
            "angle": 0,
            "arc": 5,
            "id": "WS 003",
            "locations": [
                42,
                0
            ],
            "mount": "HARDPOINT",
            "position": [
                131,
                0
            ],
            "size": "LARGE",
            "type": "ENERGY"
        },
        {
            "angle": 0,
            "arc": 5,
            "id": "WS 004",
            "locations": [
                29,
                -30
            ],
            "mount": "HARDPOINT",
            "position": [
                121,
                -50
            ],
            "size": "MEDIUM",
            "type": "ENERGY"
        },
        {
            "angle": 0,
            "arc": 5,
            "id": "WS 005",
            "locations": [
                27,
                -48
            ],
            "mount": "HARDPOINT",
            "position": [
                51,
                -75
            ],
            "size": "SMALL",
            "type": "MISSILE"
        },
        {
            "angle": 75,
            "arc": 190,
            "id": "WS 006",
            "locations": [
                11,
                18
            ],
            "mount": "TURRET",
            "position": [
                -22,
                65
            ],
            "size": "SMALL",
            "type": "BALLISTIC"
        },
        {
            "angle": -75,
            "arc": 190,
            "id": "WS 007",
            "locations": [
                11,
                -18
            ],
            "mount": "TURRET",
            "position": [
                -24,
                -65
            ],
            "size": "SMALL",
            "type": "BALLISTIC"
        },
        {
            "angle": 180,
            "arc": 270,
            "id": "WS 008",
            "locations": [
                -50,
                0
            ],
            "mount": "TURRET",
            "position": [
                -124,
                0
            ],
            "size": "SMALL",
            "type": "BALLISTIC"
        }
    ],
[close]

My question is: what is the business of those properties there?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on June 25, 2023, 10:46:13 AM
hello again to you all. i have returned with more questions:

Hi - sorry about taking a while to respond! In all honest, I kind of forgot to check this thread.


1) is it possible to get a list of the skills that a randomly generated officer / admin can spawn with / gain as they level up?

See: OfficerLevelupPluginImpl, OfficerManagementEvent

2) how do i get the possible officer personality from a fleet doctrine? i tried doctrine.getAggression(), only to realize that aggression 4 includes both aggressive and reckless officers, and I was wondering if there was a easy way to get a random officer personality / the full list of possible officer personalities for a given faction?

FactionAPI.getPersonalityPicker().pick()

3) how mush does it cost to hire a given admin or officer at different levels?

You can search for "salary" in settings.json; the relevant values should be there.

4) (in the rules.csv) what rule is ran that shows the 'found a market' screen?
5) can i trigger the 'found a market' screen with code?

surveyOptionPerformSurvey
OpenCoreTab CARGO OPEN


Currently, non-bomber fighter behavior when attacking is to either crowd over the target (default) or attempt to make a wider pass if they have the relative speed to do so (with the attack_at_an_angle tag).
In old versions of Starsector, I remember a fighter behavior of circle-strafing targets while firing at them. Is it still possible to enable this for select wings? Thank you for any answers.

There have likely been changes in fighter AI, but generally speaking "crowd over the target" and "strafe around it and fire" are, iirc, more or less the same behavior, depending on how relative velocities line up. Not 100% sure on that, but there's no way to set it, regardless.

Have question concerning hull files. First is Shrike, which has renderModProperty in one of its weapon slots:

This makes the front-middle turret render above the medium turret. Visually, it looks like it's "higher" on the hull, but by default larger weapons render on top of smaller ones (with different rules for hardpoints - which iirc are below turrets - and missiles that show missiles on the sprite, which are below other stuff, etc.

Second is Sunder, which has a "position" point field in its weapon slots in addition to the usual "location" one:

Old and unused.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on June 27, 2023, 05:03:51 AM
Alright, here's a bit of an odd one. Apparently this hullmod causes incredible slowdowns on combat, down to 1 FPS, and I don't know why. I am aware that everyframes have the capability to be incredibly laggy but idk what really is causing problems here. I must note also that significant slowdowns only occur in large fleet battles and FPS impact was negligible when only 1-2 ships were present.

Spoiler
package DE.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.CombatAssignmentType;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.magiclib.util.MagicRender;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;


public class AndradaResonator extends BaseHullMod {
    // Thanks for Nia's Adlerauge effect script for parts of this
    private static final float RANGE = 1000f;
    private static boolean isBuffed = false;
    private static final String id = "andradamodulator_data";
    public static final Color JITTER_COLOR = new Color(200,0,120,255);
    public static final Color JITTER_UNDER_COLOR = new Color(140,0,120,255);
    private final List<ShipAPI> affectedships = new ArrayList<ShipAPI>();
   
    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {
        CombatEngineAPI engine = Global.getCombatEngine();
        List<ShipAPI> shiplist = CombatUtils.getShipsWithinRange(ship.getLocation(), RANGE);
        MagicRender.objectspace(
                // this needs to be loaded in settings.json, and then you can just stick in the file path
                Global.getSettings().getSprite("graphics/DE/fx/de_drivecircle.png"),
                // what the ring will be centered on. In this case, the ship using the system. what "ship" means
                // was determined in the second part of this public void thingamajig.
                ship,
                new Vector2f(),
                new Vector2f(),
                // the radius of the circle will be about half this
                new Vector2f(2000, 2000),
                new Vector2f(-100, -100),
                0,
                120,
                // set to true to make the ring turn with the ship
                false,
                // the color, obviously. I don't think the alpha value really works, instead I'm using a
                // very transparent sprite
                new Color(200,0,120,255),
                true,
                0.5f,
                0f,
                0.5f,
                true
        );
        for (ShipAPI ship2 : shiplist) {
            if (ship2.getVariant().hasHullMod("andrada_mods") && ship2.getOwner() == ship.getOwner() && ship2 != ship) {
                //String str4 = String.format("In range: %s, has hull mod %s, same owner %s", MathUtils.isWithinRange(ship2, ship, RANGE), ship2.getVariant().hasHullMod("andrada_mods"), ship2.getOwner() == ship.getOwner());
                //Global.getLogger(this.getClass()).info(str4);
                // will apply when ship is in range
                List<ShipAPI> purgelist = new ArrayList<ShipAPI>();
                affectedships.add(ship2);
                for (ShipAPI target : affectedships) {
                    // check if our dear target is still truly in range
                    if (MathUtils.getDistance(target.getLocation(), ship.getLocation()) <= RANGE && target.isAlive() && !isBuffed) {
                        target.getMutableStats().getMaxSpeed().modifyFlat(id, 10f);
                        target.getMutableStats().getAcceleration().modifyPercent(id, 20f);
                        target.getMutableStats().getDeceleration().modifyPercent(id, 20f);
                        target.getMutableStats().getEnergyWeaponFluxCostMod().modifyPercent(id, 10f);
                        target.getMutableStats().getEnergyWeaponRangeBonus().modifyPercent(id, 10f);
                        target.getMutableStats().getEnergyRoFMult().modifyPercent(id, 10f);
                        target.getMutableStats().getEnergyRoFMult().modifyPercent(id, 10f);
                        target.getMutableStats().getTimeMult().modifyPercent(id, 5f);
                        //target.setJitter(this, JITTER_COLOR, 0.5f, 1, 0, 0);
                        //target.setJitterUnder(this, JITTER_UNDER_COLOR, 0.5f, 3, 0f, 0);
                        isBuffed = true;
                    } else {
                        // he's not! rattle em code!
                        // applies when ship is out of range
                        target.getMutableStats().getMaxSpeed().unmodifyFlat(id);
                        target.getMutableStats().getAcceleration().unmodify(id);
                        target.getMutableStats().getDeceleration().unmodify(id);
                        target.getMutableStats().getEnergyWeaponFluxCostMod().unmodify(id);
                        target.getMutableStats().getEnergyWeaponRangeBonus().unmodify(id);
                        target.getMutableStats().getEnergyRoFMult().unmodify(id);
                        target.getMutableStats().getEnergyRoFMult().unmodify(id);
                        target.getMutableStats().getTimeMult().unmodify(id);
                        purgelist.add(target);
                        isBuffed = false;
                    }
                }
                // removes ship from the affected ships list
                for (ShipAPI purge : purgelist) {
                    affectedships.remove(purgelist);
                    //purgelist.clear();
                }
            }
        }
        // clears affected ships list when combat ends
        if (engine.isCombatOver()) {
            affectedships.clear();
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on June 27, 2023, 06:35:34 PM
You are checking your entire affectedships list for each ship in shiplist every frame. Move the affectedships and purgelist for-loops out of the shiplist for-loop.

Also you don't have to check every frame. For example, you could check every 0.166 seconds (6 times per second) using an IntervalUtil.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on June 30, 2023, 12:39:59 PM
is there an AI flag or similar that forces fighters to use all weapons for point defense? i spawned terminator drones, but i did disable their AI so that i could control all of their movement without issue, and they do not use even point defense weapons on missiles.

edit:

this turned out to be because the drones had autofire on the PD weapon groups disabled. i enable autofire using this code:
Code
                        if (!group.isAutofiring()) {
                            ship.giveCommand(ShipCommand.TOGGLE_AUTOFIRE, null, index);
                        }
on the same frame that the drone is spawned, but some groups end up not having autofire enabled anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kothyxaan on June 30, 2023, 12:53:55 PM
Looking for help: I want to make Ballistic Range Finder work for small ships too

I have extracted the .class and changed it to a java and added frigate to the classes of ship that can use the ballistic range finder. When I try to load the game I get an error message


Spoiler
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
//myone removed  import com.fs.starfarer.api.impl.hullmods.BallisticRangefinder;
import com.fs.starfarer.api.loading.WeaponSlotAPI;
import com.fs.starfarer.api.ui.Alignment;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;

public class BallisticRangefinder extends BaseHullMod {
  public static float BONUS_MAX_1 = 800.0F;
 
  public static float BONUS_MAX_2 = 800.0F;
 
  public static float BONUS_MAX_3 = 900.0F;
 
  public static float BONUS_SMALL_1 = 100.0F;
 
  public static float BONUS_SMALL_2 = 100.0F;
 
  public static float BONUS_SMALL_3 = 200.0F;
 
  public static float BONUS_MEDIUM_3 = 100.0F;
 
  public static float HYBRID_MULT = 2.0F;
 
  public static float HYBRID_BONUS_MIN = 100.0F;
 
  public void applyEffectsBeforeShipCreation(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats, String id) {}
 
  public static WeaponAPI.WeaponSize getLargestBallisticSlot(ShipAPI ship) {
    if (ship == null)
      return null;
    WeaponAPI.WeaponSize largest = null;
    for (WeaponSlotAPI slot : ship.getHullSpec().getAllWeaponSlotsCopy()) {
      if (!slot.isDecorative() &&
        slot.getWeaponType() == WeaponAPI.WeaponType.BALLISTIC && (
        largest == null || largest.ordinal() < slot.getSlotSize().ordinal()))
        largest = slot.getSlotSize();
    }
    return largest;
  }
 
  public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
    WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
    if (largest == null)
      return;
    float small = 0.0F;
    float medium = 0.0F;
    float max = 0.0F;
    switch (largest) {
      case null:
        small = BONUS_SMALL_3;
        medium = BONUS_MEDIUM_3;
        max = BONUS_MAX_3;
        break;
      case MEDIUM:
        small = BONUS_SMALL_2;
        max = BONUS_MAX_2;
        break;
      case SMALL:
        small = BONUS_SMALL_1;
        max = BONUS_MAX_1;
        break;
    }
    ship.addListener(new RangefinderRangeModifier(small, medium, max));
  }
 
  public String getDescriptionParam(int index, ShipAPI.HullSize hullSize) {
    return null;
  }
 
  public boolean shouldAddDescriptionToTooltip(ShipAPI.HullSize hullSize, ShipAPI ship, boolean isForModSpec) {
    return false;
  }
 
  public void addPostDescriptionSection(TooltipMakerAPI tooltip, ShipAPI.HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
    float pad = 3.0F;
    float opad = 10.0F;
    Color h = Misc.getHighlightColor();
    Color bad = Misc.getNegativeHighlightColor();
    Color t = Misc.getTextColor();
    Color g = Misc.getGrayColor();
    WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
    tooltip.addPara("Utilizes targeting data from the ship's largest ballistic slot to benefit certain weapons, extending the base range of typical ballistic weapons to match similar but larger weapons. Also benefits hybrid weapons. Point-defense weapons are unaffected.",
       
        opad, h, new String[] { "ship's largest ballistic slot", "base range" });
    tooltip.addPara("The range bonus is based on the size of the largest ballistic slot, and the increased base range is capped, but still subject to other modifiers.",
        opad);
    tooltip.addSectionHeading("Ballistic weapon range", Alignment.MID, opad);
    tooltip.addPara("Affects small and medium ballistic weapons.", opad);
    float col1W = 120.0F;
    float colW = (int)((width - col1W - 12.0F) / 3.0F);
    float lastW = colW;
    tooltip.beginTable(Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), Misc.getBrightPlayerColor(),
        20.0F, true, true,
        new Object[] { "Largest b. slot", Float.valueOf(col1W), "Small wpn", Float.valueOf(colW), "Medium wpn", Float.valueOf(colW), "Range cap", Float.valueOf(lastW) });
    Color c = null;
    if (largest == WeaponAPI.WeaponSize.SMALL) {
      c = h;
    } else if (largest == WeaponAPI.WeaponSize.MEDIUM) {
      c = h;
    } else {
      c = g;
    }
    tooltip.addRow(new Object[] {
          Alignment.MID, c, "Small / Medium",
          Alignment.MID, c, "+" + (int)BONUS_SMALL_1,
          Alignment.MID, g, "---",
          Alignment.MID,
          c, (int)BONUS_MAX_1 });
    if (largest == WeaponAPI.WeaponSize.LARGE) {
      c = h;
    } else {
      c = g;
    }
    tooltip.addRow(new Object[] {
          Alignment.MID, c, "Large",
          Alignment.MID, c, "+" + (int)BONUS_SMALL_3,
          Alignment.MID, c, "+" + (int)BONUS_MEDIUM_3,
          Alignment.MID,
          c, (int)BONUS_MAX_3 });
    tooltip.addTable("", 0, opad);
    tooltip.addSectionHeading("Hybrid weapon range", Alignment.MID, opad + 7.0F);
    tooltip.addPara("Affects hybrid weapons (those that can fit into both ballistic and energy slots) of all sizes.",
        opad);
    col1W = 120.0F;
    colW = (int)((width - col1W - lastW - 15.0F) / 3.0F);
    tooltip.beginTable(Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), Misc.getBrightPlayerColor(),
        20.0F, true, true,
        new Object[] { "Largest b. slot", Float.valueOf(col1W), "Small", Float.valueOf(colW), "Medium", Float.valueOf(colW), "Large", Float.valueOf(colW), "Range cap", Float.valueOf(lastW) });
    c = null;
    if (largest == WeaponAPI.WeaponSize.SMALL) {
      c = h;
    } else if (largest == WeaponAPI.WeaponSize.MEDIUM) {
      c = h;
    } else {
      c = g;
    }
    tooltip.addRow(new Object[] {
          Alignment.MID, c, "Small / Medium",
          Alignment.MID, c, "+" + (int)(BONUS_SMALL_1 * HYBRID_MULT),
          Alignment.MID, c, "+" + (int)HYBRID_BONUS_MIN,
          Alignment.MID,
          c, "+" + (int)HYBRID_BONUS_MIN,
          Alignment.MID, c, (int)BONUS_MAX_1 });
    if (largest == WeaponAPI.WeaponSize.LARGE) {
      c = h;
    } else {
      c = g;
    }
    tooltip.addRow(new Object[] {
          Alignment.MID, c, "Large",
          Alignment.MID, c, "+" + (int)(BONUS_SMALL_3 * HYBRID_MULT),
          Alignment.MID, c, "+" + (int)(BONUS_MEDIUM_3 * HYBRID_MULT),
          Alignment.MID,
          c, "+" + (int)HYBRID_BONUS_MIN,
          Alignment.MID, c, (int)BONUS_MAX_3 });
    tooltip.addTable("", 0, opad);
    tooltip.addSectionHeading("Interactions with other modifiers", Alignment.MID, opad + 7.0F);
    tooltip.addPara("Since the base range is increased, this modifier - unlike most other flat modifiers - is increased by percentage modifiers from other hullmods and skills.",
       
        opad);
  }
 
  public float getTooltipWidth() {
    return 412.0F;
  }
 
  public boolean isApplicableToShip(ShipAPI ship) {
    WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
    if (ship != null && largest == null)
      return false;
    return (getUnapplicableReason(ship) == null);
  }
 
  public String getUnapplicableReason(ShipAPI ship) {
    WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
    if (ship != null && largest == null)
      return "Ship has no ballistic weapon slots";
    if (ship != null &&
      ship.getHullSize() != ShipAPI.HullSize.CAPITAL_SHIP &&
      ship.getHullSize() != ShipAPI.HullSize.DESTROYER &&
      ship.getHullSize() != ShipAPI.HullSize.CRUISER &&
      ship.getHullSize() != ShipAPI.HullSize.FRIGATE)
      return "Can only be installed on destroyer-class hulls and larger";
    return null;
  }
}

[close]

Also I want to make a hullmod that regenerates ammo. Maybe 25% per 3 minutes or a set amount. No idea how to do this. Anyone able to help me?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on June 30, 2023, 03:09:36 PM
Looking for help: I want to make Ballistic Range Finder work for small ships too...

Try using the source file in starfarer.api.zip\com\fs\starfarer\api\impl\hullmods\ rather than decompiling the .class file. You'll need to change the package to your mod directory as well, but other than that it should work better.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on June 30, 2023, 04:05:36 PM
How can I determine to which ship a Terminator Drone belongs?  No API method I have tried yields this answer.

I think the only way is to use ship.getWing() before the drone is converted into a missile and hold on to that info. At least, that's the only thing that comes to mind.

Thanks for replying!  Huh, I guess I could have some persistent storage, which would be tricky since I have my code as a listener...

Speaking of tricky, why is Global.getCombatEngine().isUIHudShowing` inverted, returning true when the UI is hidden and false when not?  I slip up so often I have had to invert the function to get the expected result and store the result as a boolean.

Edit: My apologies, it finally works as indicated now.  Woo!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kothyxaan on July 02, 2023, 01:56:56 PM
Looking for help: I want to make Ballistic Range Finder work for small ships too...

Try using the source file in starfarer.api.zip\com\fs\starfarer\api\impl\hullmods\ rather than decompiling the .class file. You'll need to change the package to your mod directory as well, but other than that it should work better.
Thanks for the reply.
I don't know how to edit .class files. I used JD-GUI to open it up, copy pasted the .class info (that seems to be opened in a .java format) into a .java file. I have the hullmod.csv pointing to it. It just doesn't work. JD-GUI doesn't let me edit the file itself.
Meh.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Shogouki on July 02, 2023, 02:50:31 PM
I have a, possibly touchy, question.  It's regarding mods that are no longer listed for download and no longer in development.  Basically I have a couple mods that I REALLY enjoy and want to use with the new RC of Starsector, but they weren't updated from RC0.95.1.  I wondered if it's ok to ask for help here about getting assistance in getting them working with the new RC for my use only?  I would not disrespect the creators and they would only be used by me for my games.  Thanks for any help and if this isn't allowed I won't ask about it again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 05, 2023, 07:28:57 PM
Hmm. I think better to err on the side of not doing it, in this case, just to avoid setting that precedent. I appreciate you asking!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 06, 2023, 04:07:09 PM
I have a ship in my mod that has a module and I am running into an issue. I can only set this module in a .variant file, but can't do so in the .ship or .skin file. This leads the ships being sold on the market not having this module, since an empty hull isn't making use of a .variant file but the default shipName_Hull variant. How could I get this module to show up on the default hull? I've seen it done for ships in other mods such as the Cathedral or Locomotive but I can't figure out how they're managing it.

Currently I am trying to use a permanent hullmod to set the module but I keep getting a NullPointerException when using stats.getVariant().setModuleVariant(slotID, variant) in applyEffectsBeforeShipCreation, and I'm not really sure what's causing it.

Edit: I've managed to track the problem down to this:
Code
@Override	
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
ShipVariantAPI module = Global.getSettings().getVariant("myModuleVariantID"); <--works fine
stats.getVariant().setModuleVariant("SM 1", module); <--does nothing
}
On a variant equipped with the module, accessing the string variant.getModuleVariant("SM 1").getHullVariantId() returns either "myModuleVariantID" or "myModuleShipID_0" if the hull is stripped, which is fine. But trying the same with the above code on a ship without the module throws a NullPointerException, so the module is never being set. Accessing module.getHullVariantId() also returns "myModuleVariantID" so the issue must be with setModuleVariant(), but I can't figure it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 06, 2023, 05:44:23 PM
sorry if this is the wrong place to post this
anyone familiar with this issue?
ive got about one hundred mods
im thinking it my be the frontier mod?
im at a loss though off hand
thanks in advance

Spoiler
4939184 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at data.scripts.plugins.SotfBattleCreationPluginImpl.getObjectivePicker(SotfBattleCreationPluginImpl.java:800)
   at data.scripts.plugins.SotfBattleCreationPluginImpl.addObjectives(SotfBattleCreationPluginImpl.java:513)
   at data.scripts.plugins.SotfBattleCreationPluginImpl.initBattle(SotfBattleCreationPluginImpl.java:221)
   at com.fs.starfarer.campaign.CampaignState.startBattle(Unknown Source)
   at com.fs.starfarer.ui.newui.W.startBattle(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.FleetInteractionDialogPluginImpl.optionSelec ted(FleetInteractionDialogPluginImpl.java:1204)
   at com.fs.starfarer.ui.newui.W$1.super(Unknown Source)
   at com.fs.starfarer.ui.newui.OoOO.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.classnew.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.classnew.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.R.processInput(Unknown Source)
   at com.fs.starfarer.ui.o000.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.o000.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.OoOO.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.R.processInput(Unknown Source)
   at com.fs.starfarer.ui.O00o$Oo.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.R.processInput(Unknown Source)
   at com.fs.starfarer.ui.o000.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.o000.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.O00o.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.R.processInput(Unknown Source)
   at com.fs.starfarer.ui.o000.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.o000.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.public.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.newui.W.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.R.processInput(Unknown Source)
   at com.fs.starfarer.ui.o000.dispatchEventsToChildren(Unknown Source)
   at com.fs.starfarer.ui.o000.processInputImpl(Unknown Source)
   at com.fs.starfarer.ui.R.processInput(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.processInput(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: BirdWanderer on July 06, 2023, 05:56:43 PM
See if there's an update available for Secrets of the Frontier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 06, 2023, 06:48:39 PM
I have a ship in my mod that has a module and I am running into an issue. I can only set this module in a .variant file, but can't do so in the .ship or .skin file. This leads the ships being sold on the market not having this module, since an empty hull isn't making use of a .variant file but the default shipName_Hull variant. How could I get this module to show up on the default hull? I've seen it done for ships in other mods such as the Cathedral or Locomotive but I can't figure out how they're managing it.

Currently I am trying to use a permanent hullmod to set the module but I keep getting a NullPointerException when using stats.getVariant().setModuleVariant(slotID, variant) in applyEffectsBeforeShipCreation, and I'm not really sure what's causing it.

You are on the wrong track. For a ship with modules, you need:
- a .ship file with a station module slot
- a .ship file for the module
- a .variant file for the module
- a .variant file for the ship with the module's variant in the module slot
- an entry in ship_data.csv for the module
- an entry for the ship with the SHIP_WITH_MODULES tag
- an entry in default_ship_roles.json for the ship variant
- the faction knows the ship

The ship should spawn in faction markets with its module.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 06, 2023, 09:38:40 PM
I have a ship in my mod that has a module and I am running into an issue. I can only set this module in a .variant file, but can't do so in the .ship or .skin file. This leads the ships being sold on the market not having this module, since an empty hull isn't making use of a .variant file but the default shipName_Hull variant. How could I get this module to show up on the default hull? I've seen it done for ships in other mods such as the Cathedral or Locomotive but I can't figure out how they're managing it.

Currently I am trying to use a permanent hullmod to set the module but I keep getting a NullPointerException when using stats.getVariant().setModuleVariant(slotID, variant) in applyEffectsBeforeShipCreation, and I'm not really sure what's causing it.

You are on the wrong track. For a ship with modules, you need:
- a .ship file with a station module slot
- a .ship file for the module
- a .variant file for the module
- a .variant file for the ship with the module's variant in the module slot
- an entry in ship_data.csv for the module
- an entry for the ship with the SHIP_WITH_MODULES tag
- an entry in default_ship_roles.json for the ship variant
- the faction knows the ship

The ship should spawn in faction markets with its module.

Thanks for the list, but I have every single one of these already. The ship works fine when spawned in fleet because
Quote
- a .variant file for the ship with the module's variant in the module slot
is what's being spawned. However, when a ship is spawned on the market, it comes with zero equipped weapons, fighters, or optional hullmods. As far as I can tell, that's because the game is loading a default empty ship variant called customShipId_Hull. Since the module variant is only being loaded inside standard ship variants, where modules are treated as optional equipment, the default empty ship never loads with the module. I've yet to find a way to either edit the empty customShipId_Hull.variant directly or add the module via code onto customShipId_Hull. That's my current issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on July 07, 2023, 12:33:19 PM
I have to check if a fleet member is in a Submarket Storage Fleet and get the cargo of said Submarket.
Is there a way to get that info from only FleetMemberAPI or do I have to manually iterate all submarkets in the sector to check if it's stuck in there?

Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 07, 2023, 05:51:52 PM
Upon further investigation I've found some mods have ships with modules that simply show up in the market when empty with all their modules, despite not doing anything fancy with the code. The one I'm looking at right now always shows up as Custom even when it has no d-mods, rather than Hull. What could be causing the ships to show up correctly on the market in one case but not the other?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 07, 2023, 07:02:01 PM
You are on the wrong track. For a ship with modules, you need:
- a .ship file with a station module slot
- a .ship file for the module
- a .variant file for the module
- a .variant file for the ship with the module's variant in the module slot
- an entry in ship_data.csv for the module
- an entry for the ship with the SHIP_WITH_MODULES tag
- an entry in default_ship_roles.json for the ship variant
- the faction knows the ship

The ship should spawn in faction markets with its module.

Thanks for the list, but I have every single one of these already.

I am the author of the Roider Union mod which is full of ships with modules which spawn just fine in markets. You are missing a step or doing something extra. I suggest making a simple modular ship following just this list, then once it is working try to figure out what is wrong with your previous ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 07, 2023, 07:47:10 PM
I am the author of the Roider Union mod which is full of ships with modules which spawn just fine in markets. You are missing a step or doing something extra. I suggest making a simple modular ship following just this list, then once it is working try to figure out what is wrong with your previous ships.

Upon further testing I have found the root of the problem, and it appears to have nothing to do with me missing any of the steps. When the game generates an empty shipID_Hull variant of a ship for sale on the market, it will seek out a variant of that ship with modules and add an empty moduleID_Hull version of each module variant to its station slots, with the variant name "Custom". However, when the game generates an empty shipID_Hull variant of a skin, this step never takes place. My modded ships were defined in .skin files, so the modules aren't being generated correctly. I will have to either redefine my skins as base ships, or find a way to generate the module through code. If anyone knows how to do the latter and make setModuleVariant actually work, that would be great.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 07, 2023, 08:00:57 PM
Upon further testing I have found the root of the problem, and it appears to have nothing to do with me missing any of the steps. When the game generates an empty shipID_Hull variant of a ship for sale on the market, it will seek out a variant of that ship with modules and add an empty moduleID_Hull version of each module variant to its station slots, with the variant name "Custom". However, when the game generates an empty shipID_Hull variant of a skin, this step never takes place. My modded ships were defined in .skin files, so the modules aren't being generated correctly. I will have to either redefine my skins as base ships, or find a way to generate the module through code. If anyone knows how to do the latter and make setModuleVariant actually work, that would be great.

Are you sure? This seems contingent on the modular ship having some kind of non-default _Hull variant defined; skins and non-skins are largely treated the same in the game and the game creates a distinct hull spec for each skin.


... or do I have to manually iterate all submarkets in the sector to check if it's stuck in there?

Pretty sure you need to do that, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 08, 2023, 02:04:25 AM
Upon further testing I have found the root of the problem, and it appears to have nothing to do with me missing any of the steps. When the game generates an empty shipID_Hull variant of a ship for sale on the market, it will seek out a variant of that ship with modules and add an empty moduleID_Hull version of each module variant to its station slots, with the variant name "Custom". However, when the game generates an empty shipID_Hull variant of a skin, this step never takes place. My modded ships were defined in .skin files, so the modules aren't being generated correctly. I will have to either redefine my skins as base ships, or find a way to generate the module through code. If anyone knows how to do the latter and make setModuleVariant actually work, that would be great.

Are you sure? This seems contingent on the modular ship having some kind of non-default _Hull variant defined; skins and non-skins are largely treated the same in the game and the game creates a distinct hull spec for each skin.

Yes I'm sure. The results are pretty wild. In my mod I have:

module ship: [empty string], id: vice_emp_emitter, designation: Emitter
module variant: vice_emp_module, hullId: vice_emp_emitter, displayName: EMP

flyable ship: Atlas (Base), id: vice_atlas_base, weaponSlot: "SM 1" of type STATION_MODULE
skin: Mimesis, skinHullId: vice_mimesis, baseHullId: vice_atlas_base
skin variant: vice_azure_fire, hullId: vice_mimesis, module: "SM 1" vice_emp_module

Turning on base_bp so everything shows up, here are the results:

When the vice_azure_fire skin variant spawns, it has a module named "EMP Emitter", variantId: vice_emp_module
Spoiler
(https://i.imgur.com/dJv4dRd.png)
[close]

When the vice_mimesis_Hull empty skin variant spawns, it has no module equipped.
Spoiler
(https://i.imgur.com/5o1Gjsj.png)
[close]

But when the vice_atlas_base_Hull empty ship variant spawns, it has a module named "Custom Emitter", variantId: vice_emp_emitter_0
Spoiler
(https://i.imgur.com/DdEpy7R.png)
[close]

So in summary, a fitted skin variant meant for fleets loads the proper module variant, an empty hull skin variant never loads modules, and an empty hull ship variant will load a default module even if it has no player added ship variants. It will somehow search out the module's hullId from a related skin variant to generate the module instead.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 10, 2023, 02:28:37 PM
Hi, is there a way to set a weapon so that it does not benefit from any range bonuses at all? There is a weapon I would like to have just one unchanging range, no matter what. Or attacking the same problem from a different angle, is it possible to set a weapon's maximum range by code in-game? Perhaps that could work too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on July 11, 2023, 05:50:56 AM
is there any way of adding  additinal factors to Colony theats , for example having station gives bonuses to defence and gives minus points to event ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 11, 2023, 09:05:05 AM
Yes I'm sure. The results are pretty wild. In my mod I have:

Oh wow, alright. Thank you for all the details! Dug into this (finally) and fixed it up; was a bug in the loading code that was *trying* to do this but grabbing the id of the base hull instead of the actual hull.


Hi, is there a way to set a weapon so that it does not benefit from any range bonuses at all? There is a weapon I would like to have just one unchanging range, no matter what. Or attacking the same problem from a different angle, is it possible to set a weapon's maximum range by code in-game? Perhaps that could work too.

I think you should be able to do this by adding a WeaponRangeModifier to the ship, but you'd have to hand-compute the range bonus and then return its inverse as the multiplier. You might also be able to avoid it by setting the weapon type to UNIVERSAL or some such; I'm not 100% sure offhand how that works.


is there any way of adding  additinal factors to Colony theats , for example having station gives bonuses to defence and gives minus points to event ?

Yes, see the various methods in HostileActivityEventIntel, e.g. addActvity() etc. I'm not sure I'd mess with it in your shoes, though - I'm currently doing a fairly extensive rework of that system, for the .1 release, and given how that's shaping up, I don't think negative modifiers would make much sense.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: superjosh250 on July 11, 2023, 02:17:51 PM
I had a quick query. When I was looking through the mission definition java, I noticed that that planet's could be accessed and placed into the mission. I was curious as to whether or not a custom entity could be accessed and placed into a mission definition file like the planet.


EXAMPLE: api.addPlanet(0, 0, 500f, "aurorian", 300f, true); is it possible to use api.customEntity (x,x,xxx,"xxx",xxx,true) or however it should be put in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on July 11, 2023, 07:23:15 PM
I think you should be able to do this by adding a WeaponRangeModifier to the ship, but you'd have to hand-compute the range bonus and then return its inverse as the multiplier. You might also be able to avoid it by setting the weapon type to UNIVERSAL or some such; I'm not 100% sure offhand how that works.
Thanks for the reply! I will look into WeaponRangeModifier, but do UNIVERSAL weapons ignore bonuses from stuff like Integrated Targeing Unit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 11, 2023, 08:28:24 PM
Is it possible to fake in-faction suppliers in an isolated market group? Like supplying hidden pirate bases from the core pirate markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 12, 2023, 10:13:43 AM
is it intentional that player ship controls get processed before processInputPreCoreControls() of a BaseEveryFrameCombatPlugin gets run?
I think I've asked this before but I never did any testing to confirm if it was the case; but using the below example plugin (and intellij's hotswapping feature to swap the consumeAll boolean) it's pretty clear that ship controls don't care about whether the Event is consumed or not, they'll get run anyway

example plugin
Code
public class inputConsumptionTest extends BaseEveryFrameCombatPlugin {

    @Override
    public void processInputPreCoreControls(float amount, List<InputEventAPI> events) {
       
        boolean consumeAll = false;
        if (consumeAll) {
            for (InputEventAPI i : events) {
                i.consume();
            }
        }
    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: justnewaccount3131 on July 12, 2023, 01:18:20 PM
is there a mod that allows me to filter planet conditions? (and resources would be nice too) - simply as a key word search

e.g. I have scanned a *lot* of planets and I am looking for a dark/extreme cold planet that was a good place for a colony with fusion torch. but I am not sure where it was exactly, and how high the danger rating got.

or I found a planet with a floating continent, and want to find it on that list.

I can search for names, but not conditions or resources. e.g. "I want to find a planet I scanned that had +3 ores" -- really time consuming to scroll through the list

I apologize if this is the wrong place to ask that... I looked and I did not want to start a thread, and found no other place.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Shogouki on July 12, 2023, 09:18:00 PM
Hmm. I think better to err on the side of not doing it, in this case, just to avoid setting that precedent. I appreciate you asking!

Thanks for the response! 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zsar on July 13, 2023, 04:53:12 AM
Does the weapon hint USE_LESS_VS_SHIELDS work on weapons without charges and without ammunition?

Given that the naming convention differs from CONSERVE* I'd expect it to work, but putting it on the Phase Lance I find that very hard to verify (which admittedly is expected: if the effect were easily observed, it would likely be too strong).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 13, 2023, 08:45:15 AM
Thanks for the reply! I will look into WeaponRangeModifier, but do UNIVERSAL weapons ignore bonuses from stuff like Integrated Targeing Unit?

I think so but not 100% sure.


Is it possible to fake in-faction suppliers in an isolated market group? Like supplying hidden pirate bases from the core pirate markets.

Sort of? See PirateBaseIntel.commodityUpdated() - you could do the same sort of thing but base the quantities on what's available from the markets you want to act as the suppliers.


is it intentional that player ship controls get processed before processInputPreCoreControls() of a BaseEveryFrameCombatPlugin gets run?
I think I've asked this before but I never did any testing to confirm if it was the case; but using the below example plugin (and intellij's hotswapping feature to swap the consumeAll boolean) it's pretty clear that ship controls don't care about whether the Event is consumed or not, they'll get run anyway

I don't think player ship controls get processed before processInputPreCoreControls(). But a lot of player ship controls are not input-event-based, but rather input-state-based. E.G. turning left reacts to the W key being down, not to any kind of input event, etc. Some of the ship controls are event based, for example weapon group selection, etc - anything that doesn't work on an "as long as the key is held down" basis.


is there a mod that allows me to filter planet conditions? (and resources would be nice too) - simply as a key word search

e.g. I have scanned a *lot* of planets and I am looking for a dark/extreme cold planet that was a good place for a colony with fusion torch. but I am not sure where it was exactly, and how high the danger rating got.

or I found a planet with a floating continent, and want to find it on that list.

I can search for names, but not conditions or resources. e.g. "I want to find a planet I scanned that had +3 ores" -- really time consuming to scroll through the list

I apologize if this is the wrong place to ask that... I looked and I did not want to start a thread, and found no other place.

Not the right thread, yeah, but all good. Perhaps this is what you're looking for?
https://fractalsoftworks.com/forum/index.php?topic=27210.msg402033#msg402033



Does the weapon hint USE_LESS_VS_SHIELDS work on weapons without charges and without ammunition?

Given that the naming convention differs from CONSERVE* I'd expect it to work, but putting it on the Phase Lance I find that very hard to verify (which admittedly is expected: if the effect were easily observed, it would likely be too strong).

It does not work for weapons without ammo/charges; all of the logic is based around conserving charges. (And, fair point about the naming; CONSERVE_VS_SHIELDS would be a much better name.) I think if you set the Phase Lance to have 1 ammo (and presumably a recharge rate such that it maintains the original rate of fire, or whatever you like) it will mostly work, though the AI may choose to manually fire it at inopportune times since for manual fire, it only checks that the charges are not maxed - which means it'd be happy to use up the only charge. I've tweaked it so that it should work in this case, too.

But as-is, this approach should work for autofire (where it does check to not use up the last charge), and with careful ship group selection, you might avoid it getting selected for manual fire anyway.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on July 13, 2023, 08:57:17 AM
Is it possible to fake in-faction suppliers in an isolated market group? Like supplying hidden pirate bases from the core pirate markets.

Sort of? See PirateBaseIntel.commodityUpdated() - you could do the same sort of thing but base the quantities on what's available from the markets you want to act as the suppliers.

Maybe I could set up a fake market in the isolated market group and let it supply the desired commodities. Seems like a fast track into unintended interactions hell, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: justnewaccount3131 on July 13, 2023, 02:05:23 PM

Not the right thread, yeah, but all good. Perhaps this is what you're looking for?
https://fractalsoftworks.com/forum/index.php?topic=27210.msg402033#msg402033



thank you!

(it won't work for modded conditions. the reason I have trouble finding the info quickly is because I run 57 mods now - in Linux by the way with no issues... and I scanned so many planets.

there are a lot of these domain artifacts now that give bonuses based on specific conditions, and when you're far enough in the game, it becomes kinda necessary to sift through planets one by one for a loong time to find e.g. farmland, but no rare ores and no gases.

if I even could look for "farmland", it would make things so much quicker. but the search ingame only works with planet names.

I assume it's a lot of work to mod that in, if nobody has done that yet...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AtlanticAccent on July 14, 2023, 08:39:33 AM
Hi!

Would it be possible to get an explanation of how
Code
OptionPanelAPI.getSavedOptionList()
and
Code
OptionPanelAPI.restoreSaveOptions()
work? I understand that they were only created for debugging purposes, but they potentially open up some interesting possiblities.

Most notably, manipulating the order of options in an option panel. Many option panels have a final "Leave" or similar option, and appending any new options will result in them appearing after the "Leave" option. Unfortunately using the mentioned methods and reordering the returned list seems to break the leave functionality and any previous shortcuts assigned to the reordered options.

Of course, if the answer is "that's absolutely not how you're supposed to use any of this" I'd accept that  ;D
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 14, 2023, 02:55:02 PM
is there a way to see what renderHints a weapon has?
I'm doing something that involves rendering weapons manually & I've run into a problem where weapons that rely on the RENDER_BARREL_BELOW hint end up getting obscured by their barrels (and vice versa for those without it) with no way to manually check for it.

late addition : what fonts does the refit screen use for weapon names in the picker & the text in weapon descriptions?
it seems like victor14 / 16 for the weapon names & insignia12 for the descs / other text, but they don't quite look right in game (when rendered using lazylib's lazyFont)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 15, 2023, 03:49:53 PM
Hi!

Would it be possible to get an explanation of how
Code
OptionPanelAPI.getSavedOptionList()
and
Code
OptionPanelAPI.restoreSaveOptions()
work? I understand that they were only created for debugging purposes, but they potentially open up some interesting possiblities.

Most notably, manipulating the order of options in an option panel. Many option panels have a final "Leave" or similar option, and appending any new options will result in them appearing after the "Leave" option. Unfortunately using the mentioned methods and reordering the returned list seems to break the leave functionality and any previous shortcuts assigned to the reordered options.

Of course, if the answer is "that's absolutely not how you're supposed to use any of this" I'd accept that  ;D

Hi! Hmm, really? I wouldn't actually expect reordering that list to break shortcuts; all restoreSavedOptions() does is clear the options and re-add them with the same data that they were added with originally. It would actually not preserve shortcuts anyway, except for the auto-added ones for the defaultLeave, cutCommLink, and cutCommLink2 options.

For option-ordering, though, there's a sorting parameter in rules, e.g.:
<sort value>:<option id>:<option text>


is there a way to see what renderHints a weapon has?

Checked - this is not exposed in the API, sorry!

late addition : what fonts does the refit screen use for weapon names in the picker & the text in weapon descriptions?
it seems like victor14 / 16 for the weapon names & insignia12 for the descs / other text, but they don't quite look right in game (when rendered using lazylib's lazyFont)

If it looks like those it's probably those; there aren't any being used that are similar to those but *not* those.

Not sure what you mean by "picker" but if it's the "weapon picker dialog in the refit screen" then the weapon names in that use the same font as the descriptions - insignia12, not victor.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 16, 2023, 11:36:09 AM
Not sure what you mean by "picker" but if it's the "weapon picker dialog in the refit screen" then the weapon names in that use the same font as the descriptions - insignia12, not victor.
ty for clarification!
and yeah, I should've been more specific but I meant the weapon name here at the top of the statcard
(https://cdn.discordapp.com/attachments/432809739164844032/1130192825032642691/image.png)


Checked - this is not exposed in the API, sorry!
(and, technically not the right thread but can you please expose the renderHints to the API?)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 16, 2023, 02:37:08 PM
and yeah, I should've been more specific but I meant the weapon name here at the top of the statcard

Ah, that's orbitron 12. Victor is all-caps.

(and, technically not the right thread but can you please expose the renderHints to the API?)

I'll keep it in mind!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AtlanticAccent on July 16, 2023, 03:25:03 PM
For option-ordering, though, there's a sorting parameter in rules, e.g.:
<sort value>:<option id>:<option text>

Ah, this actually kind of cuts right to what I'm dealing with. Rules.csv doesn't work for adding options to the top level FleetInteractionDialogImpl, so I'm appending my options through code, hence why they're always last.

Not really sure what you can do with that information though, because as we've said, this is pretty far beyond how you're supposed to do this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Obsidian Actual on July 17, 2023, 06:16:07 PM

Not the right thread, yeah, but all good. Perhaps this is what you're looking for?
https://fractalsoftworks.com/forum/index.php?topic=27210.msg402033#msg402033



thank you!

(it won't work for modded conditions. the reason I have trouble finding the info quickly is because I run 57 mods now - in Linux by the way with no issues... and I scanned so many planets.

there are a lot of these domain artifacts now that give bonuses based on specific conditions, and when you're far enough in the game, it becomes kinda necessary to sift through planets one by one for a loong time to find e.g. farmland, but no rare ores and no gases.

if I even could look for "farmland", it would make things so much quicker. but the search ingame only works with planet names.

I assume it's a lot of work to mod that in, if nobody has done that yet...)

There used to be a mod called Explore the Galaxy (https://fractalsoftworks.com/forum/index.php?topic=21800.0) which adds custom Console Commands that allowed you to filter your current game.

It has not been officially updated for game version 0.96 -- you can attempt to force it to work via the usual "mod_info.json gameVersion" hack, but no guarantees.

(And no, it has not been integrated into the latest version of Stelnet yet, as per this post (https://fractalsoftworks.com/forum/index.php?topic=20836.msg393704;topicseen#msg393704).)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on July 18, 2023, 10:20:05 AM
got this error on world gen
any ideas?
Spoiler
328035 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.addPlanet(Unknown Source)
   at data.scripts.world.systems.HS_Neue_Jangala.generate(HS_Neue_Jangala.java:108)
   at data.scripts.world.HyperionGen.generate(HyperionGen.java:67)
   at data.scripts.HyperionModPlugin.onNewGame(HyperionModPlugin.java:34)
   at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.public.dismiss(Unknown Source)
   at com.fs.starfarer.ui.impl.L.dismiss(Unknown Source)
   at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
   at com.fs.starfarer.ui.n.buttonPressed(Unknown Source)
   at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
   at com.fs.starfarer.ui.I.processInput(Unknown Source)
   at com.fs.starfarer.ui.W.super(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 18, 2023, 07:41:52 PM
Ah, this actually kind of cuts right to what I'm dealing with. Rules.csv doesn't work for adding options to the top level FleetInteractionDialogImpl, so I'm appending my options through code, hence why they're always last.

Not really sure what you can do with that information though, because as we've said, this is pretty far beyond how you're supposed to do this.

Ahh - yeah, hm. That's just going to be hard to mod without providing your own custom implementation, which there are some good reasons for not doing, so it's tough. Not really sure what to suggest!

got this error on world gen
any ideas?

java.lang.NullPointerException
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   ...
   at data.scripts.world.systems.HS_Neue_Jangala.generate(HS_Neue_Jangala.java:108)

Probably an issue either with the line of code that calls this, or with the planet definition.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 19, 2023, 04:43:17 PM
Is there a way to obtain the modules of a ship as ShipAPIs from a ship's MutableShipStatsAPI? I can cast ship = (ShipAPI) stats.getEntity() to turn the stats into a ship, and I can also retrieve the ShipVariantAPI of the modules, but I'm not sure how to convert the ShipVariantAPI to a ShipAPI, or if there's a better way to pull the module ShipAPIs directly.

Edit: Never mind, I managed to loop through Global.getCombatEngine().getShips() and check each ship for getParentStation().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 20, 2023, 09:15:04 AM
do Global.getSettings().getScreenHeightPixels() & Global.getSettings().getScreenWidthPixels() return the width of the game window or the screen that the game's being displayed on?
(and are the non-pixel methods "better" to use for ui scaling / other res compatibility?)

Is there a way to obtain the modules of a ship as ShipAPIs from a ship's MutableShipStatsAPI?

if stats.getEntity isn't null, you can then do getChildModulesCopy on the ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 20, 2023, 10:07:48 AM
do Global.getSettings().getScreenHeightPixels() & Global.getSettings().getScreenWidthPixels() return the width of the game window or the screen that the game's being displayed on?
(and are the non-pixel methods "better" to use for ui scaling / other res compatibility?)

The actual window size. And, yes; you'd generally only want to use the *Pixels methods for things that care about actual pixels, such as mouse positioning or glScissor or some such. (Note that for mouse input events, the event coordinates would already be scaled and not in-actual-pixels; I mean for methods like Mouse.setCursorPosition().)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 20, 2023, 06:43:15 PM
question
i just noticed that weapon.getSlot().getLocation().set() is a thing now, and it actually moves a weapon around the ship
this is very cool, and i will definitely make use of that for some purpose
problem is, it affects the entire hull spec, not just one specific shipAPI entity
so, my question is, is there some clean way to make it only affect one ship? without delving into semi-obfuscated methodhandle witchcraft? there is and ensureClonedSpec for weaponAPI, which is used for making changes to weapons fire offsets and stuff. is there something similar to that but for ship/hull/spec/variant ? nothing i tried so far seemed to work, so i'm uncertain on actual use case...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 20, 2023, 07:19:52 PM
Is there a way to edit the angle and arc of a weapon slot on only a particular variant of a ship? I can use addBuiltInMod on a ShipHullSpecAPI and have the built-in mod only show up on the current ship, but doing anything to its WeaponSlotAPI seems to affect all variants.

Also, where might I look to see how the script that spawns Remnant fleets from Nexus stations works? I am trying to do the same for a modded Remnant splinter faction, and would really appreciate the help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on July 20, 2023, 08:38:09 PM
deleted
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 22, 2023, 12:56:18 PM
question
i just noticed that weapon.getSlot().getLocation().set() is a thing now, and it actually moves a weapon around the ship
this is very cool, and i will definitely make use of that for some purpose
problem is, it affects the entire hull spec, not just one specific shipAPI entity
so, my question is, is there some clean way to make it only affect one ship? without delving into semi-obfuscated methodhandle witchcraft? there is and ensureClonedSpec for weaponAPI, which is used for making changes to weapons fire offsets and stuff. is there something similar to that but for ship/hull/spec/variant ? nothing i tried so far seemed to work, so i'm uncertain on actual use case...

No, I don't think there's any way around it.

You can use WeaponSpecAPI.ensureClonedSpec() and move the fire offsets, though that won't move the weapon itself.

Is there a way to edit the angle and arc of a weapon slot on only a particular variant of a ship? I can use addBuiltInMod on a ShipHullSpecAPI and have the built-in mod only show up on the current ship, but doing anything to its WeaponSlotAPI seems to affect all variants.

I don't think so.


Also, where might I look to see how the script that spawns Remnant fleets from Nexus stations works? I am trying to do the same for a modded Remnant splinter faction, and would really appreciate the help.

Take a look at com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantStationFleetManager
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 22, 2023, 06:12:31 PM

Also, where might I look to see how the script that spawns Remnant fleets from Nexus stations works? I am trying to do the same for a modded Remnant splinter faction, and would really appreciate the help.

Take a look at com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantStationFleetManager

Thanks! Is there an example of RemnantStationFleetManager being called in the sourcecode? I'm not sure what are the proper input paramaters for a typical fully built remnant_station2.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 22, 2023, 06:25:11 PM
If you open up the source in an IDE, there should be an option "References" or "Show References" or something similar. That's super handy for navigating code like this.

In this case it's in com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantThemeGenerator, but I'd seriously recommend learning to use this functionality, including the shortcut for it; it's hard to imagine coding without this kind of capability these days, it'll save you so much time!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on July 23, 2023, 01:22:53 AM
Yes I'm sure. The results are pretty wild. In my mod I have:

Oh wow, alright. Thank you for all the details! Dug into this (finally) and fixed it up; was a bug in the loading code that was *trying* to do this but grabbing the id of the base hull instead of the actual hull.

Thanks for the bug fix. :)  I forgot to ask earlier but was this related to setModuleVariant seemingly not working as well?

2) Also, how do I calculate the getUnusedOP for the current ship in the devmode variant editor?

3) Is there a way for a hullmod on a fighter to determine the ShipAPI of the carrier to which it is currently fitted?

Edit: Figured out the second question. For anyone else wondering, I just learned that
Code
MutableCharacterStatsAPI char = Global.getFactory().createPerson().getFleetCommanderStats();
works for plugging into getUnusedOP on the variant editor.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 24, 2023, 08:49:00 AM
(tbh not entirely sure if this should go here or the bugs subforum, but it's more modding related imo)

I'm having some very strange behaviour using Global.getCombatEngine().getFleetManager().spawnFleetMember() & it feels like a bug- it seems like calling the method multiple times on the same fleetMemberAPI will always return the first shipAPI that got spawned from that FMAPI, despite also correctly spawning a new ship.

my code is (effectively) this & I'm using it to "refit" ships mid-combat by swapping out weapons in the fleetmember's variant, then respawning it in the same place.

 code
Code

   /*
   * targetShip is chosen by the player, this method then gets called when the player presses a key after selecting what weapon to swap
   * newShip is then returned to the plugin & takes targetShip's place, ideally allowing for a seamless transfer between the two ships
   * however, the wrong ship gets returned from spawnFleetMember & a duplicate ship is spawned after removeEntity() is called on a ship that's already been removed
   */

    public ShipAPI respawnShip(ShipAPI targetShip, String slotID, String replacementWeapID){
       
        FleetMemberAPI targetFMAPI = targetShip.getFleetMember();
        ShipVariantAPI targetVariant = targetFMAPI.getVariant();

        targetVariant.addWeapon(slotID, replacementWeapID);

        int owner = targetShip.getOriginalOwner();
        Vector2f loc = new Vector2f(targetShip.getLocation());
        float facing = targetShip.getFacing();

        log.debug("target ship deets");
        log.debug(targetShip.getId());
        log.debug(targetShip.hashCode());

        Global.getCombatEngine().removeEntity(targetShip);

        Global.getCombatEngine().getFleetManager(owner).setSuppressDeploymentMessages(true);
        ShipAPI newShip = Global.getCombatEngine().getFleetManager(owner).spawnFleetMember(targetFMAPI, loc, facing, 0f);
        Global.getCombatEngine().getFleetManager(owner).setSuppressDeploymentMessages(false);

        log.debug("new ship deets");
        log.debug(newShip.getId());
        log.debug(newShip.hashCode());

       return newShip;
    }
}
[close]

I can get around the bug by simply creating new fleetMembers, though I don't want to do that for campaign & mod compatibility reasons- since it's supposed to be the same ship, after all- would a fix (or a workaround using the current API) be possible?

also, is there a way to get the current maximum vents / caps for a ship variant?

Late edit : also decided to post a little demo of the whole in-combat refitting (using the fleetmember copying method) because it's been fun to make, video below
 tech demo video thing
https://youtu.be/VOWJOogTueg
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on July 24, 2023, 04:05:53 PM
How does the game calculate the targeting ellipse for a ship?

And, while we're on the topic, is there any way to manually set such things?

(By 'targeting ellipse' I mean the shortcut the game takes for enemy AI to decide whether the ship is in range of its guns or not. This is the shape that gets used for targeting calculations, and the reason that, for example, the AI will sometimes try to fire beam weapons at a Conquest when they can't quite reach.)

Context: I work on a mac, and have zero interest in getting the existing ship editor running on my machine. So I am, instead, making my own little ship display tool; it's not an editor, but it loads up an existing ship file and lets me see what's going on. I'd like for it to be able to display the targeting ellipse, but I don't know how that's calculated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 24, 2023, 04:23:34 PM
2) Also, how do I calculate the getUnusedOP for the current ship in the devmode variant editor?

Edit: Figured out the second question. For anyone else wondering, I just learned that
Code
MutableCharacterStatsAPI char = Global.getFactory().createPerson().getFleetCommanderStats();
works for plugging into getUnusedOP on the variant editor.

I think passing in null would also work :)

3) Is there a way for a hullmod on a fighter to determine the ShipAPI of the carrier to which it is currently fitted?

You could implement applyEffectsAfterShipCreation() and then you'd have access to the fighter's ShipAPI, which you can use to get its wing etc etc.


(tbh not entirely sure if this should go here or the bugs subforum, but it's more modding related imo)

I'm having some very strange behaviour using Global.getCombatEngine().getFleetManager().spawnFleetMember() & it feels like a bug- it seems like calling the method multiple times on the same fleetMemberAPI will always return the first shipAPI that got spawned from that FMAPI, despite also correctly spawning a new ship.

I can get around the bug by simply creating new fleetMembers, though I don't want to do that for campaign & mod compatibility reasons- since it's supposed to be the same ship, after all- would a fix (or a workaround using the current API) be possible?

Hmm, that behavior seems possible. Definitely not a bug, though; I'd imagine the assumption that there is a 1-1 mapping between ShipAPI (except in the case of fighters) and FleetMemberAPI and DeployedFleetMemberAPI is made in many parts of the code. If you somehow got this to work with a single FleetMember here, it'd probably just fail somewhere else.


also, is there a way to get the current maximum vents / caps for a ship variant?

CoreAutofitPlugin.getBaseMax(HullSize size) and then modifying it by the relevant stats. Or, simpler (i.e. code that already does this for you):

SkillsChangeRemoveVentsCapsEffect.getMaxVents(HullSize size, MutableCharacterStatsAPI stats) and .getMaxCaps(HullSize size, MutableCharacterStatsAPI stats)

Late edit : also decided to post a little demo of the whole in-combat refitting (using the fleetmember copying method) because it's been fun to make, video below

Wow, that's super cool! Wow.


How does the game calculate the targeting ellipse for a ship?

And, while we're on the topic, is there any way to manually set such things?

(By 'targeting ellipse' I mean the shortcut the game takes for enemy AI to decide whether the ship is in range of its guns or not. This is the shape that gets used for targeting calculations, and the reason that, for example, the AI will sometimes try to fire beam weapons at a Conquest when they can't quite reach.)

Context: I work on a mac, and have zero interest in getting the existing ship editor running on my machine. So I am, instead, making my own little ship display tool; it's not an editor, but it loads up an existing ship file and lets me see what's going on. I'd like for it to be able to display the targeting ellipse, but I don't know how that's calculated.

It's not an ellipse, rather, it's IIRC 4 sections of ellipses, one for each quadrant. It's based on the size of the ship sprite - the image dimensions. Or the collision radius, if the image dimensions are too large, though it gets less accurate at that point. Hm, it's difficult to explain the formula concisely because it's been a while and I don't remember it 100%. Basically it places the ship center on an rectangle based on the size of the sprite/collision radius, and then fits an ellipse section to each quadrant.

You can also use Misc.getTargetingRadius(Vector2f from, CombatEntityAPI target, boolean considerShield) to get the actual value from any angle for a specific ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on July 24, 2023, 04:47:07 PM
How does the game calculate the targeting ellipse for a ship?

And, while we're on the topic, is there any way to manually set such things?

(By 'targeting ellipse' I mean the shortcut the game takes for enemy AI to decide whether the ship is in range of its guns or not. This is the shape that gets used for targeting calculations, and the reason that, for example, the AI will sometimes try to fire beam weapons at a Conquest when they can't quite reach.)

Context: I work on a mac, and have zero interest in getting the existing ship editor running on my machine. So I am, instead, making my own little ship display tool; it's not an editor, but it loads up an existing ship file and lets me see what's going on. I'd like for it to be able to display the targeting ellipse, but I don't know how that's calculated.

It's not an ellipse, rather, it's IIRC 4 sections of ellipses, one for each quadrant. It's based on the size of the ship sprite - the image dimensions. Or the collision radius, if the image dimensions are too large, though it gets less accurate at that point. Hm, it's difficult to explain the formula concisely because it's been a while and I don't remember it 100%. Basically it places the ship center on an rectangle based on the size of the sprite/collision radius, and then fits an ellipse section to each quadrant.

You can also use Misc.getTargetingRadius(Vector2f from, CombatEntityAPI target, boolean considerShield) to get the actual value from any angle for a specific ship.
Yeah, I was aware that it was four segments. Sounds like the centerpoint is just the center of the ship's collision radius, with each cardinal direction then based on the smaller of sprite size or collision radius. Does this mean that a ship sprite with extra whitespace around the edges is going to have a larger targeting ellipse? Or is it based on max/min values of the ship's bounds?
...I guess I can just write up a test mod and work that out for myself, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 24, 2023, 04:54:26 PM
Does this mean that a ship sprite with extra whitespace around the edges is going to have a larger targeting ellipse?

IIRC yes; that's where capping it with some fraction of the collision radius comes in.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on July 24, 2023, 04:58:14 PM
Does this mean that a ship sprite with extra whitespace around the edges is going to have a larger targeting ellipse?

IIRC yes; that's where capping it with some fraction of the collision radius comes in.
Oh, I'd assumed that particular corner case was for things like the midline station core that can have sprites significantly larger than their collision radius. Huh. Well, I can probably work it out via in-game testing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on July 24, 2023, 06:37:16 PM
hello again its me again with yet more questions.
1) how do i display the skills a given admin has to a TooltipMakerAPI? i tried TooltipMakerAPI.addSkillPanel(person,pad), but it only seemed to work for officers.
2) is there a way to find the max level and max elite skills that the players officers can have?
thanks again for awensering questions in the past. it has been useful and stuff.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 25, 2023, 08:43:32 AM
<my message>
<your response>

yeah, I figured that what I was doing was janky at best after seeing that no one had done it despite how simple it was, though the single fleetmember approach only seemed to manifest issues after trying to automatically re-select the ship (admittedly, with only bare minimum campaign testing to make sure that I could add / remove weapons from the player's inventory correctly); I'll probably be able to do a manual search to find the "correct" shipAPI.

Wow, that's super cool! Wow.

ty! the idea's been on my mind for a while but I was just never bored enough to give it a crack all I need to do now is find a real use for it

and for a question - how do you determine the turning / accuracy strengths for a weapon that doesn't have one explicitly defined in weapon_data.csv? I'm guessing it's just a number comparison, though having the specific breakpoints would be nice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 25, 2023, 10:04:44 AM
1) how do i display the skills a given admin has to a TooltipMakerAPI? i tried TooltipMakerAPI.addSkillPanel(person,pad), but it only seemed to work for officers.

I don't think that's supported, sorry!

2) is there a way to find the max level and max elite skills that the players officers can have?
thanks again for awensering questions in the past. it has been useful and stuff.

Using:
OfficerLevelupPlugin plugin = (OfficerLevelupPlugin) Global.getSettings().getPlugin("officerLevelUp");

And then .getMaxEliteSkills(PersonAPI person) for that specific officer. Or you can create a new PersonAPI and set its fleet to be the player's fleet and pass that in. And then getMaxLevel() for the level.


and for a question - how do you determine the turning / accuracy strengths for a weapon that doesn't have one explicitly defined in weapon_data.csv? I'm guessing it's just a number comparison, though having the specific breakpoints would be nice.

Here you go!

public String getAccuracyDisplayName() {
   if (maxSpread <= 0) return "Perfect";
   if (maxSpread <= 2) return "Excellent";
   if (maxSpread <= 5)return "Good";
   if (maxSpread <= 10) return "Medium";
   if (maxSpread <= 15) return "Poor";
   if (maxSpread <= 20) return "Very Poor";
   return "Terrible";
}

public String getTurnRateDisplayName() {
   if (turnRate <= 0) return "Can't turn";
   if (turnRate <= 5) return "Very Slow";
   if (turnRate <= 15)return "Slow";
   if (turnRate <= 25) return "Medium";
   if (turnRate <= 35) return "Fast";
   if (turnRate <= 50) return "Very Fast";
   return "Excellent";
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on July 25, 2023, 12:36:09 PM
ty!
though there's currently no getter for a weaponSpec's turnRate (only a weaponAPI's after stat modifications), could that be exposed to the API?
rn I'm just creating a fake weapon for it which works, but isn't strictly accurate.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on July 25, 2023, 02:55:58 PM
Hm, it's difficult to explain the formula concisely because it's been a while and I don't remember it 100%. Basically it places the ship center on an rectangle based on the size of the sprite/collision radius, and then fits an ellipse section to each quadrant.

You can also use Misc.getTargetingRadius(Vector2f from, CombatEntityAPI target, boolean considerShield) to get the actual value from any angle for a specific ship.
Would you be willing to share the code involved? Because, uh, it's definitely not working quite the way you explained it. Start up a game with the console commands mod, put a sunder into simulation, and run the showbounds command - this provides a nice visual display of where the targeting ellipse actually is (using the exact Misc.getTargetingRadius method you mentioned). The displayed targeting ellipse for the Sunder is reasonable! But it definitely extends forwards further than the edge of the sprite. And further than the ship's collision radius, too. So I'm not sure what's going on here.

The Sunder's also weird in having a shield radius larger than its collision radius, so maybe there's an actual bug to be fixed here somewhere?

(I'd also, on a somewhat less minor-question note, request the ability to provide a ship-specific implementation of that method - it's a bit of a niche use-case, but some mod ships would benefit greatly from being able to provide better targeting data. ...And arguably some vanilla ships, too; the Conquest, for example, would be better approximated as a box than a set of elliptical curves. Though any such method would need to be strongly-optimized for performance.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 26, 2023, 12:27:38 PM
ty!
though there's currently no getter for a weaponSpec's turnRate (only a weaponAPI's after stat modifications), could that be exposed to the API?
rn I'm just creating a fake weapon for it which works, but isn't strictly accurate.

Added!


Would you be willing to share the code involved?

The relevant portion:
Spoiler
      float w = ship.getSprite().getWidth();
      float h = ship.getSprite().getHeight();
      
      float cx = ship.getSprite().getCenterX();
      float cy = ship.getSprite().getCenterY();
      
      // offY > 0 means ship center is towards aft
      // offY < 0 means ship center is towards fore
      float offY = 0;
      if (cy != -1) {
         offY = h / 2f - cy;
      }
      float offX = 0;
      if (cx != -1) {
         offX = w / 2f - cx;
      }
      
      float ar = w / h;
      
      
      float targetFacing = ship.getFacing();
      float angleFromTargetToShooter = Utils.getAngleInDegrees(ship.getLocation(), from);
      
      float diff = Utils.getAngleDiff(targetFacing, angleFromTargetToShooter);
      boolean fromBack = false;
      boolean fromLeft = false;
      if (diff > 90) {
         diff = 180 - diff;
         fromBack = true;
      }
      if (Utils.getClosestTurnDirection(targetFacing, angleFromTargetToShooter) > 0) {
         fromLeft = true;
      }

      float r = ship.getCollisionRadius();
      //r = Math.max(w / 2f, h / 2f);
      r = h / 2f;
      r = Math.min(r, ship.getCollisionRadius());
      
      float rFront = r;
      float rSide = r * ar;

      if (fromBack) {
         rFront -= offY;
      } else {
         rFront += offY;
      }
      
      if (fromLeft) {
         rSide -= offX;
      } else {
         rSide += offX;
      }
      
      float a = Math.min(rFront, rSide);
      float b = Math.max(rFront, rSide);
      
      // 0: from straight ahead (top)
      // 90: from the left
      // 180: from the back (below)
      // 270: from the right
      float normalizedAngle = Utils.normalizeAngle(angleFromTargetToShooter - targetFacing - 90f);
      
      float rTheta;
      if (rFront > rSide) {
         rTheta = (a * b) /
            (float)Math.sqrt(Math.pow(b * (float)Math.cos(Math.toRadians(normalizedAngle)), 2f) +
                       Math.pow(a * (float)Math.sin(Math.toRadians(normalizedAngle)), 2f));
      } else {
         rTheta = (a * b) /
            (float)Math.sqrt(Math.pow(b * (float)Math.sin(Math.toRadians(normalizedAngle)), 2f) +
                         Math.pow(a * (float)Math.cos(Math.toRadians(normalizedAngle)), 2f));
      }
      
      return rTheta + 10f;
[close]

The Sunder's also weird in having a shield radius larger than its collision radius, so maybe there's an actual bug to be fixed here somewhere?

Oh oops, that's a bug.

(I'd also, on a somewhat less minor-question note, request the ability to provide a ship-specific implementation of that method - it's a bit of a niche use-case, but some mod ships would benefit greatly from being able to provide better targeting data. ...And arguably some vanilla ships, too; the Conquest, for example, would be better approximated as a box than a set of elliptical curves. Though any such method would need to be strongly-optimized for performance.)

And most things have enough of a fudge-factor that this doesn't matter *too* much... I mean, I can see the potential benefit, but not for the effort involved. (Which, not astronomical, but just in comparison with the payoff.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on July 26, 2023, 12:50:22 PM
Would you be willing to share the code involved?

The relevant portion:
Spoiler
      float w = ship.getSprite().getWidth();
      float h = ship.getSprite().getHeight();
      
      float cx = ship.getSprite().getCenterX();
      float cy = ship.getSprite().getCenterY();
      
      // offY > 0 means ship center is towards aft
      // offY < 0 means ship center is towards fore
      float offY = 0;
      if (cy != -1) {
         offY = h / 2f - cy;
      }
      float offX = 0;
      if (cx != -1) {
         offX = w / 2f - cx;
      }
      
      float ar = w / h;
      
      
      float targetFacing = ship.getFacing();
      float angleFromTargetToShooter = Utils.getAngleInDegrees(ship.getLocation(), from);
      
      float diff = Utils.getAngleDiff(targetFacing, angleFromTargetToShooter);
      boolean fromBack = false;
      boolean fromLeft = false;
      if (diff > 90) {
         diff = 180 - diff;
         fromBack = true;
      }
      if (Utils.getClosestTurnDirection(targetFacing, angleFromTargetToShooter) > 0) {
         fromLeft = true;
      }

      float r = ship.getCollisionRadius();
      //r = Math.max(w / 2f, h / 2f);
      r = h / 2f;
      r = Math.min(r, ship.getCollisionRadius());
      
      float rFront = r;
      float rSide = r * ar;

      if (fromBack) {
         rFront -= offY;
      } else {
         rFront += offY;
      }
      
      if (fromLeft) {
         rSide -= offX;
      } else {
         rSide += offX;
      }
      
      float a = Math.min(rFront, rSide);
      float b = Math.max(rFront, rSide);
      
      // 0: from straight ahead (top)
      // 90: from the left
      // 180: from the back (below)
      // 270: from the right
      float normalizedAngle = Utils.normalizeAngle(angleFromTargetToShooter - targetFacing - 90f);
      
      float rTheta;
      if (rFront > rSide) {
         rTheta = (a * b) /
            (float)Math.sqrt(Math.pow(b * (float)Math.cos(Math.toRadians(normalizedAngle)), 2f) +
                       Math.pow(a * (float)Math.sin(Math.toRadians(normalizedAngle)), 2f));
      } else {
         rTheta = (a * b) /
            (float)Math.sqrt(Math.pow(b * (float)Math.sin(Math.toRadians(normalizedAngle)), 2f) +
                         Math.pow(a * (float)Math.cos(Math.toRadians(normalizedAngle)), 2f));
      }
      
      return rTheta + 10f;
[close]
Thanks!

(I'd also, on a somewhat less minor-question note, request the ability to provide a ship-specific implementation of that method - it's a bit of a niche use-case, but some mod ships would benefit greatly from being able to provide better targeting data. ...And arguably some vanilla ships, too; the Conquest, for example, would be better approximated as a box than a set of elliptical curves. Though any such method would need to be strongly-optimized for performance.)

And most things have enough of a fudge-factor that this doesn't matter *too* much... I mean, I can see the potential benefit, but not for the effort involved. (Which, not astronomical, but just in comparison with the payoff.)
Fair enough.

In vanilla, this mostly comes up with beam weaponry against a Conquest, where, at the angles the conquest likes to sit itself at, you can frequently see an attacker's beams just not quite reaching hull.

But that's one case where it doesn't quite work versus lots of cases where it does, and vanilla doesn't have any C-shaped capitals (Blackrock Drive Yards' teleporting capital ship comes to mind), which is where this request be would be most relevant. ...And I suppose you could probably manage something with a multi-module ship if you're putting together something with a truly problematic shape.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on July 27, 2023, 05:56:25 AM
I'm looking once again to add hullmods to preexisting fleets and it's been suggested to me to use a fleet inflation listener to do so. I however don't know how to implement it properly, I've been trawling through some mods trying to find a good example of one being used, but have come up dry so far.
Could anyone either suggest a mod which makes good usage of one So I can take a look, or perhaps otherwise direct me to how to use one please?


RuddyGreat helped me out with a solution, ok to ignore the above now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on July 27, 2023, 05:19:33 PM
hello again all you kind people. i am back. with more questions.
1) is there a way to determine if a market is in a 'cut off' (no jump points in system) with code.
2) is there a way to find out if the 'world im interacting with' / 'my interaction target' is being cut off because of 'hostile activity' with code
thank you all again for answering my questions once more. its very helpful in doing strange things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2023, 07:51:04 AM
hello again all you kind people. i am back. with more questions.
1) is there a way to determine if a market is in a 'cut off' (no jump points in system) with code.
2) is there a way to find out if the 'world im interacting with' / 'my interaction target' is being cut off because of 'hostile activity' with code
thank you all again for answering my questions once more. its very helpful in doing strange things.

1) You can use system.hasTag(SYSTEM_CUT_OFF_FROM_HYPER) which *should* in theory be set for a system that's inaccessible, but whether it actually will be is up to whoever made the system. You could also just check if the system has any jump-points! system.getJumpPoints().isEmpty() should do it.

2) I'm not sure what "cut off" means in this context. You can check market.hasCondition(Conditions.HOSTILE_ACTIVITY) or something similar to see if it has the condition, or you could check its accessibility if you care about it in a more general sense.

(Sorry for the delayed response, btw!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on July 31, 2023, 06:29:11 PM
2) I'm not sure what "cut off" means in this context. You can check market.hasCondition(Conditions.HOSTILE_ACTIVITY) or something similar to see if it has the condition, or you could check its accessibility if you care about it in a more general sense.
im attempting to refer to what happens when you try to interact with a object on the map, and you cant because there is a hostile fleet nearby. it says something about there being 'a hostile fleet tracking your movement nearby' (or something like that), and talks about how you cant do anything well there is a hostile fleet right next to you.

also quick question because its bugging me, do you happen to know were the class/function 'TooltipMakerAPI.addSkillPanel(person,pad);' is implemented? i want to edit the code to work with admin skills, but am unable to find it anywhere in starsector core, for some reason.

and thank you for your responses. understanding a program can be hard sometimes and the answers i receive on this tread help a lot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on July 31, 2023, 08:59:35 PM
Re: nearby hostiles - ahh, I see! Generally that's checked in rules, using the HostileFleetNearbyAndAware command. If you wanted to check this in code, you could create a new instance of it and call its .execute() method. The problem is that it's not *guaranteed* that this is all that's checked for; a specific interaction may be checking for something else, and there's no general flag that's set for this state. So whatever you do would likely need to be on a case-by-case basis, checking what the rules do in that specific situation.

Re: TooltipMakerAPI.addSkillPanel(person,pad) - it's outside the API, in core vanilla code that's not (easily) mod-accessible, so you're kind of on your own there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on August 02, 2023, 06:39:24 AM
Is there any way to prevent hostile activity from counting a fleet towards its "Hostile Fleet Destroyed" counter? Certain things become easy to farm nearby player colonies and it breaks the system entirely.
So just looking for a way to blacklist a fleet from the system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: johnaaron on August 02, 2023, 07:15:49 AM
Is there a way to turn off certain combat messages completely (e.g. combat readiness warnings)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 02, 2023, 08:19:00 PM
Is there any way to prevent hostile activity from counting a fleet towards its "Hostile Fleet Destroyed" counter? Certain things become easy to farm nearby player colonies and it breaks the system entirely.
So just looking for a way to blacklist a fleet from the system.

You could try setting HostileActivityEventIntel.FP_PER_POINT to some very high value situationally (i.e. when the battle about to be reported is one you want to exclude). It'd still net at least one point, though. (Also: changes to the HA system will I *think* make this mostly moot in the .1 release?)

Is there a way to turn off certain combat messages completely (e.g. combat readiness warnings)?

I don't think so, but you could turn off the sounds by setting their volume to zero in data/config/sounds.json.

cr_playership_critical
cr_allied_critical
cr_playership_malfunction
cr_allied_malfunction
cr_playership_warning
cr_allied_warning
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: johnaaron on August 04, 2023, 04:48:20 AM
If I want to disable d-mod removal from the Hull Restoration skill, I can just treat the .skill like a .json and remove these lines right? (level2, level4A, level4B)

Code
{
"id":"hull_restoration",
"governingAptitude":"industry",
"compressHullmods":false,
"scope":"FLEET",
"effectGroups":[
{
"requiredSkillLevel":1,
"effectBasedOnLevel":false,
"effects":[
{"type":"FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level1"},
// REMOVE {"type":"ALL_SHIPS_IN_FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level2"},
// REMOVE {"type":"FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level4A"},
// REMOVE {"type":"FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level4B"},
{"type":"ALL_SHIPS_IN_FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level3"},
]
},
],
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on August 04, 2023, 11:44:47 PM
When writing a save, does the game have anything that would serialize a variant with source REFIT as a STOCK variant?

Context: Been trying to confirm the origin of a bug where a ship, having been transferred from player fleet to an NPC fleet, loses its variant after save/load.
(The NPC fleet had fleet.setInflated(true); and fleet.setInflater(null); called after the fleet members were added to it; all the variants also had their sources set to REFIT and tagged as no_autofit)

If I want to disable d-mod removal from the Hull Restoration skill, I can just treat the .skill like a .json and remove these lines right? (level2, level4A, level4B)

Code
{
"id":"hull_restoration",
"governingAptitude":"industry",
"compressHullmods":false,
"scope":"FLEET",
"effectGroups":[
{
"requiredSkillLevel":1,
"effectBasedOnLevel":false,
"effects":[
{"type":"FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level1"},
// REMOVE {"type":"ALL_SHIPS_IN_FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level2"},
// REMOVE {"type":"FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level4A"},
// REMOVE {"type":"FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level4B"},
{"type":"ALL_SHIPS_IN_FLEET", "script":"com.fs.starfarer.api.impl.campaign.skills.HullRestoration$Level3"},
]
},
],
}
Assuming those are the right effect levels in the skill's java class, that should work yes. (Note that Starsector uses '#' for JSON comments)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 07, 2023, 12:47:23 PM
When writing a save, does the game have anything that would serialize a variant with source REFIT as a STOCK variant?

Context: Been trying to confirm the origin of a bug where a ship, having been transferred from player fleet to an NPC fleet, loses its variant after save/load.
(The NPC fleet had fleet.setInflated(true); and fleet.setInflater(null); called after the fleet members were added to it; all the variants also had their sources set to REFIT and tagged as no_autofit)

I'm sorry about the delayed response! Been plugging away at stuff and, in all honesty, just forgetting to check this thread often enough.

Ah, hmm, it will do that - if variant.getOriginalVariant() returns non-null, the game will set the ship to that when it deflates the fleet prior to saving. I think calling variant.setOriginalVariant(null) in addition to what you were doing should sort it out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on August 08, 2023, 01:44:25 PM
Edit: found the solution for my question so nvm.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on August 10, 2023, 01:45:12 PM
hello once again my fellow life forms. i have returned with another set of questions
1) is there any way to run code right after a player founds a market, like some type of 'market founded listener'?
2) how do i grey out options (so you cant click on them), like what happens with 'establish a colony' when in a system with no hyperspace accuses?
once more i thank all you kind people for answering all of my previous of my silly questions. its very kind of you all.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 10, 2023, 04:52:22 PM
hello once again my fellow life forms. i have returned with another set of questions
1) is there any way to run code right after a player founds a market, like some type of 'market founded listener'?
2) how do i grey out options (so you cant click on them), like what happens with 'establish a colony' when in a system with no hyperspace accuses?
once more i thank all you kind people for answering all of my previous of my silly questions. its very kind of you all.

1 - Add a PlayerColonizationListener with Global.getSector().getListenerManager().addListener()

2 - OptionPanelAPI.setEnabled()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 10, 2023, 09:01:49 PM
How can I let all ships naturally accelerate past the 600 speed limit?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 11, 2023, 10:52:44 AM
How can I let all ships naturally accelerate past the 600 speed limit?

You can't, it's a hardcoded limit. Part of the reason it exists is for collision reliability etc; I'd imagine things start breaking down visibly at some point after that's exceeded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on August 12, 2023, 09:48:26 AM
There is a cool hull mod that creates mines using engine.spawnProjectile(). It passes in null for the weaponAPI parameter and creates a "mineLayer1" projectile. I wanted to change it to create a "sabot" projectile. However, that projectile has an OnHitEffect that has projectile.getWeapon().get.... which results in a null reference exception.
How can I pass an appropriate weaponAPI to spawnProjectile() so that any other script calling getWeapon on the projectile won't be null?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 13, 2023, 10:21:30 AM
You can use CombatEngineAPI.createFakeWeapon(shipId, weaponId) to create a sabot (or whatever) weapon and use that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 13, 2023, 10:53:30 AM
Is there any way to change the ShotBehaviorSpecAPI of a MissileSpecAPI once it has loaded from its JSON?  I ask because I have noticed that I cannot adjust the firing distance of a DEM missile.  I can see an obfuscated method to do it; also, the method name seems misspelled: setBehavor (and getBehavor) are both missing an 'i' between 'v' and 'o'.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 13, 2023, 10:57:13 AM
You can change the JSONObject returned by ShotBehaviorSpecAPI.getParams(); that should have an effect but may or may not work across the board, depending.

(Yeah, that looks like it's misspelled. Ah well.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on August 13, 2023, 11:44:12 AM
Is there any way to stop a weapon from firing while it is in burst?
Im making a shipsystem that will apply to all modules of the ship, but one one modules has the system itself, so i cant rely on the shipsystems "noFiring" for the other modules.

To clarify, im able to stop further firing from weapons, but i cant figure out how to example, stop a Squall from firing the moment i activate the effect, and due to how long those fire id rather find a way to disable their current burst.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 13, 2023, 12:47:17 PM
Hmm. When a ship system has noFiring, under the hood it results in:
ship.blockCommandForOneFrame(CommandType.USE_SELECTED_GROUP);
ship.setHoldFireOneFrame(true);

But I don't think that would stop a firing weapon, either. The only thing that comes to mind is WeaponAPI.disable() - I expect that would do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on August 13, 2023, 01:03:28 PM
You can change the JSONObject returned by ShotBehaviorSpecAPI.getParams(); that should have an effect but may or may not work across the board, depending.

(Yeah, that looks like it's misspelled. Ah well.)

Wow, snappy!  Thanks for the answer.  I wonder how to make it work because the following code works when changing the specs but ends up, somehow, with null values for triggerDistance and preferredMinFireDistance:
Code
final float distance = payloadWeaponSpec.getMaxRange() * 3;
final JSONArray distanceRange = new JSONArray(new float[]{distance, distance});
behaviorSpec.getParams().put("triggerDistance", distanceRange);
behaviorSpec.getParams().put("preferredMinFireDistance", distanceRange);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on August 13, 2023, 03:35:16 PM
Hmm. When a ship system has noFiring, under the hood it results in:
ship.blockCommandForOneFrame(CommandType.USE_SELECTED_GROUP);
ship.setHoldFireOneFrame(true);

But I don't think that would stop a firing weapon, either. The only thing that comes to mind is WeaponAPI.disable() - I expect that would do it.

any way to hide the particles and such that come from using the disable method though?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 13, 2023, 04:01:10 PM
I don't think so. Yeah, this isn't... ideal. Let me make a note about a possible API addition here.

(You could also ship.setPhased(true) for one frame and set the collision class back to its original value - that might do the trick. Might have some other unintended consequences during that one frame, though, such as confusing missiles that are targeting it etc.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on August 13, 2023, 05:54:53 PM
You can use CombatEngineAPI.createFakeWeapon(shipId, weaponId) to create a sabot (or whatever) weapon and use that.

Thanks. This worked perfectly.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on August 14, 2023, 02:02:06 AM
I don't think so. Yeah, this isn't... ideal. Let me make a note about a possible API addition here.

(You could also ship.setPhased(true) for one frame and set the collision class back to its original value - that might do the trick. Might have some other unintended consequences during that one frame, though, such as confusing missiles that are targeting it etc.)

The issue here is that its already a phase system so i dont think that would work either haha, basicly making a rightclick phase that can apply to all modules of a ship, and things like squalls continuing to fire on the modules is the crux of the issue.

Il probably just avoid missile mounts on it for now since those tend to have the issue the most.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 14, 2023, 09:59:46 AM
Ahh, interesting! Reading the code a little more, if you give the module a version of phase cloak - as a ship system - with an AI of NONE, that should make firing weapons get interrupted when the module is phased. And if the AI is NONE it would not get used otherwise. At least, I think this would work.

The downside being that the module would not be able to have another ship system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on August 14, 2023, 07:40:02 PM
How should I handle situations where NPC fleets don't have a commander? Or their commander exists but doesn't have stats?

People are getting crashes with my mod because I'm modifying NAVIGATION_PENALTY_MULT. This is fine most of the time, but if there is nothing to reference for that the game crashes with a null pointer exception.

I'm trying to set things up so my code gracefully handles this situation, and still ends with the NPC fleet getting the bonus correctly.
Code in question
Code
    private static void applyHarmonics(CampaignFleetAPI fleet)
    {
        PersonAPI commander = fleet.getCommander();
        MutableCharacterStatsAPI commanderStats;
        if (commander == null)
        {
            commander = Global.getFactory().createPerson();
            fleet.setCommander(commander);
        }

        if (fleet.isPlayerFleet())
        {
            commanderStats = Global.getSector().getPlayerStats();
        }
        else
        {
            commanderStats = commander.getFleetCommanderStats();
        }

        if (commanderStats == null)
        {
            commander.setStats(new CharacterStats());
        }


        float currentNavPenalty = commanderStats.getDynamic().getStat(Stats.NAVIGATION_PENALTY_MULT).getModifiedValue();

        FleetDataAPI fleetData = fleet.getFleetData();
        MutableFleetStatsAPI fleetStats = fleetData.getFleet().getStats();
        boolean hasHarmonics = fleetStats.hasMod(HARMONIC_ID);
        boolean hasHarmonicMod = false;

        for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
            if (member.getVariant().hasHullMod("stardust_WarpHarmonicResonator"))
            {
                hasHarmonicMod = true;
                break;
            }
        }

        if (hasHarmonics == false && hasHarmonicMod == true)
        {
            commanderStats.getDynamic().getStat(Stats.NAVIGATION_PENALTY_MULT).modifyFlat(HARMONIC_ID,
                    -0.01f * stardust_WarpHarmonicResonator.NAVIGATION_PENALTY_REDUCTION);
            MutableStat fleetChecked = new MutableStat(0.0F);
            fleetStats.addTemporaryModMult(365f, HARMONIC_ID, HARMONIC_DESC, 1f, fleetChecked);
        }
        else if (hasHarmonics == true && hasHarmonicMod == false)
        {
            //commanderStats.getDynamic().getStat(Stats.NAVIGATION_PENALTY_MULT).modifyFlat(HARMONIC_ID,
            //        0.01f * stardust_WarpHarmonicResonator.NAVIGATION_PENALTY_REDUCTION);
            commanderStats.getDynamic().getStat(Stats.NAVIGATION_PENALTY_MULT).unmodify(HARMONIC_ID);
            fleetStats.removeTemporaryMod(HARMONIC_ID);
        }

    }
[close]

The chunk of code at the top is what I have in to handle things, but it still doesn't solve my problem. When it gets down to grabbing the current Nav Penalty, it crashes out on the null pointer because even if I do create a commander and initialize Stats for them.

What do I need to do to get this to work properly?

I could catch the errors so it doesn't crash, but I'd much rather have it put the game into a correct state so NPC fleets also get the intended bonus from this ship being in their fleet.

[update]
I have noticed that
Code
commanderStats = fleet.getCommanderStats();
ends up giving me nulls much less often. Does not help for what to do if nulls show up, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on August 14, 2023, 08:49:17 PM
Is there a way to make a certain type of missile more resistant to emp effects? Some weapons/effects like the emp system just seem to shut the missile down regardless of its hit points.

Assuming there is no built in way, would this work: Make an everyFrame listener and attach it to the missile and check if it had had its engine turned off before its duration expired and then turn it back on? Would it still have its target?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on August 15, 2023, 05:26:54 AM
Ahh, interesting! Reading the code a little more, if you give the module a version of phase cloak - as a ship system - with an AI of NONE, that should make firing weapons get interrupted when the module is phased. And if the AI is NONE it would not get used otherwise. At least, I think this would work.

The downside being that the module would not be able to have another ship system.

Yeah we are planning to give them different systems so that wont work, we will just avoid letting it have missiles for now and il use the new API feature that you marked down on your notes once thats available someday, thanks for looking in to it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 15, 2023, 09:13:44 AM
How should I handle situations where NPC fleets don't have a commander? Or their commander exists but doesn't have stats?

People are getting crashes with my mod because I'm modifying NAVIGATION_PENALTY_MULT. This is fine most of the time, but if there is nothing to reference for that the game crashes with a null pointer exception.
...

It would help to see the actual error! Looking at internal code, it seems very nearly impossible that you would get a null return value from either fleet.getCommander() or fleet.getCommanderStats(), so something other than what you're describing is probably happening. (It *is* possible that one of the methods might cause an NPE under some specific circumstances, but that's different.)

Is there a way to make a certain type of missile more resistant to emp effects? Some weapons/effects like the emp system just seem to shut the missile down regardless of its hit points.

Assuming there is no built in way, would this work: Make an everyFrame listener and attach it to the missile and check if it had had its engine turned off before its duration expired and then turn it back on? Would it still have its target?

missile.setEmpResistance(<number of times the missile will ignore being hit by the EMP system and similar>)

Well, not exactly ignore - it'll still take damage - but it will avoid the instant flameout effect.


Yeah we are planning to give them different systems so that wont work, we will just avoid letting it have missiles for now and il use the new API feature that you marked down on your notes once thats available someday, thanks for looking in to it!

*thumbs up* - added WeaponAPI.stopFiring().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on August 15, 2023, 10:09:33 AM
How should I handle situations where NPC fleets don't have a commander? Or their commander exists but doesn't have stats?

People are getting crashes with my mod because I'm modifying NAVIGATION_PENALTY_MULT. This is fine most of the time, but if there is nothing to reference for that the game crashes with a null pointer exception.
...

It would help to see the actual error! Looking at internal code, it seems very nearly impossible that you would get a null return value from either fleet.getCommander() or fleet.getCommanderStats(), so something other than what you're describing is probably happening. (It *is* possible that one of the methods might cause an NPE under some specific circumstances, but that's different.)

That's good to know. I didn't see any cases where the fleet didn't have a commander, personally, but was told it could happen.

I did get issues with this code:
Code
    PersonAPI commander = fleet.getCommander();
    MutableCharacterStatsAPI commanderStats = commander.getFleetCommanderStats();

Where getting the stats from the fleet's commander, rather than the fleet, would give me nulls when trying to actually access stats. Which I'm guessing just means that I was doing it wrong.

If fleet.getCommanderStats will always get me a correct set that won't end up with null pointers, I should be good. I'll keep an eye out and get you specific errors if I end up with any using that method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 15, 2023, 11:13:39 AM
Ah! So here's the deal:

person.getFleetCommanderStats();
Returns the stats for the fleet commander of an officer in that fleet. It'll work if called on the fleet commander, provided it's not default shared "return this instead of null" commander.

Basically if you check that it's not:
fleet.getCommander().isDefault()

Then you have a commander you can work with and modify their stats etc. Otherwise you should probably just abort as a failsafe - or, I suppose, create a new person and set them to command the fleet.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mephansteras on August 15, 2023, 12:49:46 PM
Good to know. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on August 16, 2023, 02:23:51 AM
Code
        PersonAPI ve_rimmy = Global.getFactory().createPerson();
        ve_rimmy.setId("ve_rimmy");
        ve_rimmy.setName(new FullName("Rimmy","Wingman", FullName.Gender.MALE));
        ve_rimmy.setPortraitSprite(Global.getSettings().getSpriteName("characters","rimmy"));
        ve_rimmy.setRankId(Ranks.POST_STATION_COMMANDER);
        ve_rimmy.setPostId(Ranks.POST_STATION_COMMANDER);
        ve_rimmy.setFaction("independent");
        Global.getSector().getImportantPeople().addPerson(ve_rimmy);
        brixton.getMarket().getCommDirectory().addPerson(Global.getSector().getImportantPeople().getPerson("ve_rimmy"));

I can make an important person and give them the Station Commander rank. This however does not actually make them the Station Commander (And thus appear on the market page as the Administrator.) I also tried POST_ADMINISTRATOR with a similar result. How can I make a specific NPC the admin of a market?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 16, 2023, 09:52:23 AM
Via MarketAPI.setAdministrator() or something similar, iirc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on August 16, 2023, 12:20:05 PM
hello again everyone. i have returned with yet another random question:
1) today i learned on the found a market screen, (the one that runs when you run 'OpenCoreTab CARGO OPEN') there is a second check that prevents you from founding a market in a system with no jump points (cut off from hyper space). i was wondering if there is a way to disable, or otherwise interact with this check?
thanks to you all again for awensering questions again. its very kind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on August 16, 2023, 02:50:03 PM
Via MarketAPI.setAdministrator() or something similar, iirc.

Code
brixtonMarket.setAdmin(ve_rimmy);

This compiles fine but does nothing.

Code
brixtonMarket.setAdmin(People.getPerson("ve_rimmy"));

Same as well. Odd. There are no errors, it compiles fine and yet it doesn't seem to work. Market still gets populated with a generic NPC.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 16, 2023, 05:47:12 PM
Try also calling MarketAPI.addPerson. This works for me:

Code: java
			market.setAdmin(person);
market.getCommDirectory().addPerson(person, 0);
market.addPerson(person);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on August 17, 2023, 05:49:30 AM
Try also calling MarketAPI.addPerson. This works for me:

Code: java
			market.setAdmin(person);
market.getCommDirectory().addPerson(person, 0);
market.addPerson(person);

Code
        PersonAPI ve_rimmy = Global.getFactory().createPerson();
        ve_rimmy.setId("ve_rimmy");
        ve_rimmy.setName(new FullName("Rimmy","Wingman", FullName.Gender.MALE));
        ve_rimmy.setPortraitSprite(Global.getSettings().getSpriteName("characters","rimmy"));
        ve_rimmy.setRankId(Ranks.POST_STATION_COMMANDER);
        ve_rimmy.setPostId(Ranks.POST_STATION_COMMANDER);
        ve_rimmy.setFaction("independent");
        Global.getSector().getImportantPeople().addPerson(ve_rimmy);
        brixton.getMarket().getCommDirectory().addPerson(Global.getSector().getImportantPeople().getPerson("ve_rimmy"));
        brixtonMarket.setAdmin(People.getPerson("ve_rimmy"));
        brixtonMarket.setAdmin(ve_rimmy);
        brixtonMarket.getCommDirectory().addPerson(ve_rimmy, 0);

This does not work either. It also causes a new problem; If I try to talk to Rimmy using the comms menu, it causes a crash; https://pastebin.com/tDijBMwM
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 17, 2023, 09:10:55 AM
@Mitsuru-Ch: check CoreLifecyclePluginImpl.createInitialPeople() and related methods; it assigns a bunch of admins among other things. You've got to be doing something differently, or perhaps some code is running later and removing the admin.

hello again everyone. i have returned with yet another random question:
1) today i learned on the found a market screen, (the one that runs when you run 'OpenCoreTab CARGO OPEN') there is a second check that prevents you from founding a market in a system with no jump points (cut off from hyper space). i was wondering if there is a way to disable, or otherwise interact with this check?
thanks to you all again for awensering questions again. its very kind

Hi! You can remove Tags.SYSTEM_CUT_OFF_FROM_HYPER from the star system's tags.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: khorne8 on August 18, 2023, 10:32:36 AM
I'm playing around with the Dragonfire DEM, because it's too pretty to be as bad as it is. This is my first time getting into weapon_stats.csv. I'd like to modify a couple of the Dragonfire's unique qualities and I'm having trouble finding the right stats to do that.
Thanks. I'm trying to find a modded state where it stays a superheavy, low ammo count weapon. It feels acceptable with the speed and projectile health bumped up a bit, but I'd like to play around with a variant that's less clumsy about actually hitting things when it goes off.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 18, 2023, 11:08:42 AM
A lot of this is configured in data/weapons/proj/dragon.proj
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on August 21, 2023, 12:44:30 PM
How can I get the item that is in the first slot of a player's cargo? Is the cargo ordered? I'm trying to get the item in the first row, far left slot.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 22, 2023, 08:10:39 AM
It's ordered, so just using CargoAPI.getStacksCopy() should work.

Note that a stack may be empty; you can check for this by calling CargoStackAPI.isNull().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: DeCell on August 22, 2023, 02:18:19 PM
So i've been trying to put a sphere like the planets on combat but i couldn't manage it to work. How can i do it? Here is the code that should but doesnt work for me (i run it in the render):

Spoiler

imports:
Code
import cmu.gui.CMUKitUI;
import com.fs.starfarer.api.combat.ViewportAPI;
import com.fs.starfarer.api.graphics.SpriteAPI;
import org.lwjgl.util.glu.Sphere;
import org.lwjgl.util.vector.Vector2f;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.*;

radius is 200, stacks are 70, slices are 70, location is the ships location
Code

        CMUKitUI.closeGLForMisc();//it was open, arcs and stuff doesnt work properly when i dont disable this and do the matrix things (the sources of arcs go to weird places and visual effects happen really outa place)


        glMatrixMode(GL_TEXTURE_MATRIX);
        glPushMatrix();
        texture.bindTexture();

        sphere.setOrientation(GLU_INSIDE);
        sphere.setNormals(GLU_SMOOTH);
        sphere.setDrawStyle(GLU_FILL);
        sphere.setTextureFlag(true);

        glMatrixMode(GL_PROJECTION_MATRIX);
        glPushMatrix();

        glMatrixMode(GL_MODELVIEW_MATRIX);
        glPushMatrix();

        glTranslatef(viewport.convertWorldXtoScreenX(location.x), viewport.convertWorldYtoScreenY(location.y), 0);


        sphere.draw(radius, slices, stacks);

        glPopMatrix();
        glPopMatrix();
        glPopMatrix();


        CMUKitUI.openGLForMisc();
[close]

I was going to look at how the game renders planets but couldn't find the file for it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on August 23, 2023, 03:13:07 AM
I'm trying to do a beam weapon with an extremely short firing interval (basically putting it at the refire rate limit, 0.05s on, 0.05s off, with a magazine so it fires in short bursts of extremely rapid pulses, for both visual reasons and as a trick to increase armor penetration without increasing DPS) and I cannot figure out how to get the firing sound to work- is there other weird stuff going on? I can fit my sound within the 0.1s firing cycle and have it set to firingSoundOne, but it doesn't play the whole thing- and sometimes it doesn't play any sound at all. I can always change it to a loop and use scripting to play that while it's firing, but I have no idea if this is a bug or not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NaughtySanta on August 23, 2023, 12:27:40 PM
Hey all ,

I've been searching around the this immense library on some hints on how to add in custom conditions for planets. Lets say I wanted to create a planet that had an old cloning facility ruin in it that added a bonus to producing marines/workers or make even more dangerous or safer planets with various bonuses. so far I made it to here  https://fractalsoftworks.com/starfarer.api/constant-values.html#com.fs.starfarer.api.impl.campaign.ids.Conditions.ICE   - conditions and the constant fields documentation.  Any mods that do this? or examples I can pull from?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on August 23, 2023, 01:45:33 PM
I'm trying to do a beam weapon with an extremely short firing interval (basically putting it at the refire rate limit, 0.05s on, 0.05s off, with a magazine so it fires in short bursts of extremely rapid pulses, for both visual reasons and as a trick to increase armor penetration without increasing DPS) and I cannot figure out how to get the firing sound to work- is there other weird stuff going on? I can fit my sound within the 0.1s firing cycle and have it set to firingSoundOne, but it doesn't play the whole thing- and sometimes it doesn't play any sound at all. I can always change it to a loop and use scripting to play that while it's firing, but I have no idea if this is a bug or not.
While I don't know what's up with your sound issues, I suspect you're going to have problems with beam damage not matching intended values: at least as of last I checked, beam weapon damage is dealt in .1s increments. So, for example, a beam with a duration of .25s will deal two ticks of damage, resulting in actual damage output being 4/5ths of what's listed in the codex.

How this will interact with a .05s duration beam I don't actually know; if you have data for the actual damage dealt by this beam weapon, I'd be curious to hear it.

I'd also advise against extremely rapid beam cycle times for reasons of avoiding things that could trigger epilepsy.

Hey all ,

I've been searching around the this immense library on some hints on how to add in custom conditions for planets. Lets say I wanted to create a planet that had an old cloning facility ruin in it that added a bonus to producing marines/workers or make even more dangerous or safer planets with various bonuses. so far I made it to here  https://fractalsoftworks.com/starfarer.api/constant-values.html#com.fs.starfarer.api.impl.campaign.ids.Conditions.ICE   - conditions and the constant fields documentation.  Any mods that do this? or examples I can pull from?
I'd suggest taking a look at Unknown Skies (https://fractalsoftworks.com/forum/index.php?topic=12041.0).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: theDragn on August 23, 2023, 07:54:10 PM
How this will interact with a .05s duration beam I don't actually know; if you have data for the actual damage dealt by this beam weapon, I'd be curious to hear it.
It appears to actually do damage normally- I would have to test with something without any armor, since it's frag, but it's doing 1k frag per second at 4000 beam DPS and seems to be functioning normally. (numbers heavily subject to change, of course)

I'd also advise against extremely rapid beam cycle times for reasons of avoiding things that could trigger epilepsy.
... I didn't consider this. I suppose I did intentionally make it a strobe effect. Ah well, back to the drawing board.


edit: after some experiments I think burst beam damage across the game might be applying incorrectly, even with normal longer-duration beams- beam weapons seem to consistently miss somewhere between zero and one frame's worth of damage, even when given extremely high beam speed numbers. They never exceed their listed damage at least, but it is usually under it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on August 24, 2023, 02:06:44 AM
When adding the Mining industry to a planet, how would I go about also adding story point improvements to it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on August 24, 2023, 06:26:52 AM
Does anyone know how much impact, "stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, 1000f);" makes on ship recovery? I might need to make a custom hullmod that reduces the bonus from Reinforced Bulkheads so certain ships are not 100% or extremely close to 100% recoverable, but I don't know what scaled that 100f is is adding onto or even how much out of 100% it is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on August 24, 2023, 07:26:43 AM
When adding the Mining industry to a planet, how would I go about also adding story point improvements to it?

Industry.setImproved()

Use MarketAPI.getIndustry() to get the Industry object.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 25, 2023, 08:14:17 AM
I'd also advise against extremely rapid beam cycle times for reasons of avoiding things that could trigger epilepsy.

(I was going to say, yeah - I experimented with weapons like that and then was like, wait...)


edit: after some experiments I think burst beam damage across the game might be applying incorrectly, even with normal longer-duration beams- beam weapons seem to consistently miss somewhere between zero and one frame's worth of damage, even when given extremely high beam speed numbers. They never exceed their listed damage at least, but it is usually under it.

Beam damage being inexact is just very fundamentally "how things work"!


Does anyone know how much impact, "stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, 1000f);" makes on ship recovery? I might need to make a custom hullmod that reduces the bonus from Reinforced Bulkheads so certain ships are not 100% or extremely close to 100% recoverable, but I don't know what scaled that 100f is is adding onto or even how much out of 100% it is.

A probability of 1 means "guaranteed recovery", and this modifier contributes to that, among other things. You can take a look at Misc.isShipRecoverable() for details.

I think you'd have a tough time making anything precise here, though, that wasn't also very fragile if it e.g. encounters some other modifier to this probability. The modifier of 1000 is vast overkill, and other places could do something similar, or just a different-but-equivalent (in terms of being overkill) number, etc. And also for enemy ships, the recovery chance is modified by how many ships are already recoverable, and by the number of d-mods. See: FleetEncounterContext.getRecoverableShips() and related.

Basically I'd advise against trying to modify this value and hoping for an exact result.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on August 25, 2023, 04:56:36 PM

A probability of 1 means "guaranteed recovery", and this modifier contributes to that, among other things. You can take a look at Misc.isShipRecoverable() for details.

I think you'd have a tough time making anything precise here, though, that wasn't also very fragile if it e.g. encounters some other modifier to this probability. The modifier of 1000 is vast overkill, and other places could do something similar, or just a different-but-equivalent (in terms of being overkill) number, etc. And also for enemy ships, the recovery chance is modified by how many ships are already recoverable, and by the number of d-mods. See: FleetEncounterContext.getRecoverableShips() and related.

Basically I'd advise against trying to modify this value and hoping for an exact result.

Would it be fair to assume if +1000 is a vast overkill for being able to recover, then if that value were unmodified and replaced by a -1000 modifier it would also be vast overkill to making a ship unrecoverable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 26, 2023, 07:43:44 AM
It wouldn't - if you take a look at the code I mentioned, there are many factors that make the ship recoverable entirely regardless of this value.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sombra on August 28, 2023, 05:03:42 AM
Heyo!

I was wondering, is there any mod that has added new colony items? None of the ones I looked at did that, but maybe someone else knows one. I'm just very curious!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on August 28, 2023, 06:13:17 AM
question
is it possible to change the sprite of an individual projectile/missile in combat
the goal is to have 4 missiles from the same spec, but all have different sprite
to avoid making more dummy weapons unnecessarily
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on August 28, 2023, 10:04:51 AM
Heyo!

I was wondering, is there any mod that has added new colony items? None of the ones I looked at did that, but maybe someone else knows one. I'm just very curious!
I've actually had sorta vague plans to implement a very basic colony item demo mod, adding something like, oh, maybe a "explorarium-pattern harvester replicator" that can add +1 production to any of mining, farming, or aquaculture (but also causes small explorarium drone fleets to show up in and around the star system it's installed at).

If this sounds like something people would actually be interested in seeing, I can probably knock it out by sometime this coming weekend.

Edit: There's also the old Shadowyards mod, that adds colony items specific to its own industries.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 28, 2023, 10:15:30 AM
question
is it possible to change the sprite of an individual projectile/missile in combat
the goal is to have 4 missiles from the same spec, but all have different sprite
to avoid making more dummy weapons unnecessarily

Hmm. You could probably attach a script or custom rendering entity (via CombatEngineAPI.addLayeredRenderingPlugin()) to the missile when it's fired (via an onFireEffect in its .proj file) and have it render the desired sprite. But that wouldn't help when the weapon is mounted on the ship rendering the loaded missile sprites; nothing comes to mind for that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on August 28, 2023, 05:40:39 PM
How would I create a custom station for a faction that they would use in the campaign instead of the standard stations? Well, I know how to create a station. I mean how would I tell the game to use the custom one instead of the default one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on August 29, 2023, 03:08:46 PM
I am currently making a hullmod that requires manipulating the hullmod variables on a per-ship basis for it to work properly. Since every copy of a hullmod shares all their variables, the hullmod doesn't work properly when two ships with the same hullmod are in combat at the same time.

The wiki states "There are some different ways to circumvent the issue, such as mapping all ship specific variables based on script+ship ID and storing them in the CombatEngineAPI's CustomData (if it's an in-combat effect)." Is there a coding example of this somewhere where I can take a look?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Hatter on August 29, 2023, 03:21:51 PM
I am currently making a hullmod that requires manipulating the hullmod variables on a per-ship basis for it to work properly. Since every copy of a hullmod shares all their variables, the hullmod doesn't work properly when two ships with the same hullmod are in combat at the same time.

The wiki states "There are some different ways to circumvent the issue, such as mapping all ship specific variables based on script+ship ID and storing them in the CombatEngineAPI's CustomData (if it's an in-combat effect)." Is there a coding example of this somewhere where I can take a look?
com.fs.starfarer.api.impl.hullmods.MissileAutoloader uses CustomData.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: touchofvanilla on August 30, 2023, 10:15:08 AM
I've been screwing around with rules.csv quite a bit lately, and I can't get the "wait" command to work properly. My usage- "$EminenceExpeditionOngoingWait = true 3"

To my understanding, this would make the memkey $EminenceExpeditionOngoing true for 3 days, then false- am I using it incorrectly?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on August 30, 2023, 12:10:11 PM
How would I create a custom station for a faction that they would use in the campaign instead of the standard stations? Well, I know how to create a station. I mean how would I tell the game to use the custom one instead of the default one.

You'd need to create a new industry. See industries.csv for how vanilla handles it; the variant is specified there.

I've been screwing around with rules.csv quite a bit lately, and I can't get the "wait" command to work properly. My usage- "$EminenceExpeditionOngoingWait = true 3"

To my understanding, this would make the memkey $EminenceExpeditionOngoing true for 3 days, then false- am I using it incorrectly?

This seems roughly correct, except the memory key would be unset entirely rather than being set to false. Comparing it to false in that case could still work, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on August 31, 2023, 06:10:14 PM
Is the code for generating a hyperspace typography scan when players max out their exploration score something we can take a look at? I would like to mimic something like that for my mod if I can.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on September 01, 2023, 11:32:38 AM
Is there any documentation on how to add custom dialogue with specific NPCs?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on September 01, 2023, 04:47:33 PM
API request: could you add getters for PersonBountyIntel fields?

I'd like to track how many bounties a player does, and being able to see `result` would be super useful. `bountyType`, too. There are probably ways to work around it (like listening for battles and copy/pasting the logic), but nothing beats reading it directly.

Thanks for the consideration!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 01, 2023, 08:15:34 PM
Is the code for generating a hyperspace typography scan when players max out their exploration score something we can take a look at? I would like to mimic something like that for my mod if I can.

See the HTFactorTracker class!

Is there any documentation on how to add custom dialogue with specific NPCs?

Not that I've written. Sorry :)

API request: could you add getters for PersonBountyIntel fields?

I'd like to track how many bounties a player does, and being able to see `result` would be super useful. `bountyType`, too. There are probably ways to work around it (like listening for battles and copy/pasting the logic), but nothing beats reading it directly.

Thanks for the consideration!

Added a bunch, including these!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 02, 2023, 04:54:41 AM
Any way to increase the maximum level & maximum elite skills on a per officer basis? ive checked the Stats class for the dynamic stats, from what i can tell those are just for the player to increase those fleet wide.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on September 02, 2023, 05:49:15 AM
I like the new gazer missile and thought it would make a nice alternative mine. So, i copied the minelayer hull mod and replaced "minelayer1" with "gazer" but it doesn't work. The missiles spawn and slowly fly towards their target but they don't fire beams. Other missiles work but not this one. Is there a way to do this or is it just too specific a weapon to make it work this way?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2023, 09:13:30 AM
Any way to increase the maximum level & maximum elite skills on a per officer basis? ive checked the Stats class for the dynamic stats, from what i can tell those are just for the player to increase those fleet wide.

Some general-use things:
PersonAPI p = Global.getSector().getPlayerFaction().createRandomPerson();
p.getMemoryWithoutUpdate().set(MemFlags.OFFICER_SKILL_PICKS_PER_LEVEL, 10);
p.getMemoryWithoutUpdate().set(MemFlags.OFFICER_MAX_LEVEL, 7;
p.getMemoryWithoutUpdate().set(MemFlags.OFFICER_MAX_ELITE_SKILLS, 4);

These just completely override whatever the limits would normally be.

I like the new gazer missile and thought it would make a nice alternative mine. So, i copied the minelayer hull mod and replaced "minelayer1" with "gazer" but it doesn't work. The missiles spawn and slowly fly towards their target but they don't fire beams. Other missiles work but not this one. Is there a way to do this or is it just too specific a weapon to make it work this way?

Hmm, I don't actually know offhand; apologies! I'd really need to dig in to answer that one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 02, 2023, 09:31:37 AM
is there a way to have a jump point's tooltip hide what system it's connected to / what planets are in the system?
I'm trying to make a system that's "locked" until the player does a certain thing & obscuring that info would be a nice extra thing.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2023, 09:34:22 AM
Hmm, I don't think so. Edit: you might have the destination go somewhere else until it's unlocked. Edit #2: or, indeed, you might not even add the destination until it's unlocked.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 02, 2023, 10:29:11 AM
Does the FleetType actually matter for fleet generation from FleetFactoryV3 or is it solely there for the fleet name?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 02, 2023, 10:31:45 AM
hmmm, setting a destination to null / leaving the list empty both crash on mouseover, though giving it a dummy destination does work, ty!
I can just use the custom dialog plugin I've made to have it go to the actual destination when travelled through, so it all works out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2023, 10:34:36 AM
Does the FleetType actually matter for fleet generation from FleetFactoryV3 or is it solely there for the fleet name?

Just the name; you can see where it's used in FleetFactoryV3.

hmmm, setting a destination to null / leaving the list empty both crash on mouseover, though giving it a dummy destination does work, ty!
I can just use the custom dialog plugin I've made to have it go to the actual destination when travelled through, so it all works out.

Ah, cool! Just checked btw and it does not crash for me when the destination list is empty, it shows the "this jump-point is anomalous and has no destinations" message in the tooltip.

Adding a null destination *would* make it NPE somewhere, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 02, 2023, 11:13:30 AM
yeah, triple checked (called clearDestinations() after spawning the jump point) and it just throws a IndexOutOfBoundsException, guess that's a nice thing to be looking forwards to for .96.1!
and it's now got me wondering what was added in .96.1 that might need it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2023, 11:16:42 AM
Hmm, weird! Might've been the work with wormholes but I don't remember changing anything that ought to affect this, and the "no destinations" tooltip text exists and I vaguely remember testing that it worked, way back. Ah, well!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on September 02, 2023, 02:46:27 PM
API request: could you add getters for PersonBountyIntel fields?

I'd like to track how many bounties a player does, and being able to see `result` would be super useful. `bountyType`, too. <snip>
Added a bunch, including these!

Thank you!

If Starsector isn't coming to Steam (any time soon), then Steam is coming to Starsector. Sorry not sorry.

Spoiler
(https://i.imgur.com/9UtFDBf.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 02, 2023, 02:48:51 PM
Oh no!

(Seriously though, very cool!)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 03, 2023, 11:29:55 AM
how are bounties (and really, every repeatable mission) generated & given out by the game?

I've got the basic foundation of an interactionDialogPlugin that I want to use to hand out missions, is there a class / method that could work as an example "generate a mission and give it to the player" thing?
I'd also like to know how contacts store their list of missions, though I'm kinda assuming that they just get shoved into the person's memoryAPI or so.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 05, 2023, 10:25:40 AM
how are bounties (and really, every repeatable mission) generated & given out by the game?

I've got the basic foundation of an interactionDialogPlugin that I want to use to hand out missions, is there a class / method that could work as an example "generate a mission and give it to the player" thing?
I'd also like to know how contacts store their list of missions, though I'm kinda assuming that they just get shoved into the person's memoryAPI or so.

Ooooh boy.  I don't know if there's a guide on this somewhere, but you might look at the CheapCommodityMission class for a start. And at ContactIntel for how to set up a person to have a "mission hub" so that they give these kinds of missions. And at data/campaign/person_missions.csv, which is where - in addition to the implementing class - those missions are configured.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 05, 2023, 01:01:49 PM
thank you, contactIntel (and BaseMissionHub) are exactly what I'm looking for!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 05, 2023, 01:06:36 PM
Ah, awesome!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 06, 2023, 01:00:43 PM
I am trying to copy Damper Field with a custom AI, but my AI isn't being called when it is the ship's defense system. It works correctly when it is the ship's normal system. What am I missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 06, 2023, 03:49:43 PM
I am trying to copy Damper Field with a custom AI, but my AI isn't being called when it is the ship's defense system. It works correctly when it is the ship's normal system. What am I missing?

Hmm. Is the shield type in ship_data.csv set to PHASE?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 06, 2023, 04:00:09 PM
Hmm. Is the shield type in ship_data.csv set to PHASE?

Derp. Got the ship set, but forgot the module.

Edit: bug report: ShipSystemAIScript.init for the "phase cloak" gets the ship's system passed in instead of the phase cloak.
Edit2: Can bypass bug by making separate "system" and "phase cloak" versions of the ship system.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 06, 2023, 04:24:37 PM
Ah, that makes sense. You could also get the system via ship.getPhaseCloak(), I think.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 06, 2023, 04:46:09 PM
Yes, the system AI for the defense version assumes it is working with the phase cloak system.

Attached: ship with front armor module using Temporal Shell and Damper Field at the same time on itself and its module.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 07, 2023, 08:26:28 AM
Any way to increase the maximum level & maximum elite skills on a per officer basis? ive checked the Stats class for the dynamic stats, from what i can tell those are just for the player to increase those fleet wide.

Some general-use things:
PersonAPI p = Global.getSector().getPlayerFaction().createRandomPerson();
p.getMemoryWithoutUpdate().set(MemFlags.OFFICER_SKILL_PICKS_PER_LEVEL, 10);
p.getMemoryWithoutUpdate().set(MemFlags.OFFICER_MAX_LEVEL, 7;
p.getMemoryWithoutUpdate().set(MemFlags.OFFICER_MAX_ELITE_SKILLS, 4);


These seem to be 0 by default, is it save to asume that 0 would always be equievelant to 5 if no previous override is set?
Specificly im making an interaction that increases the maximum level of a choosen officer, so id want to guarantee support for officers that are already beyond maximum.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 07, 2023, 09:52:11 AM
Attached: ship with front armor module using Temporal Shell and Damper Field at the same time on itself and its module.

Nice!

These seem to be 0 by default, is it save to asume that 0 would always be equievelant to 5 if no previous override is set?
Specificly im making an interaction that increases the maximum level of a choosen officer, so id want to guarantee support for officers that are already beyond maximum.

These are unset by default, not 0. Though going a getInt() will return 0 for an unset value, but still, it's an important distinction, since if you actually set it to 0, the officer's max level would be 0, probably breaking some things.

I'm not sure I understand the reasoning here, hmm. E.G. the level 7 officers are just level 7, they don't have these values set, iirc. But even if they had it set to 7, setting it to 8 would have the same effect of increasing the max level by 1, regardless of whether it was set to 7 before, or unset and they were just created at level 7.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on September 07, 2023, 12:58:59 PM
hello once more all you kind people. i am hear with questions again
    1) is there a way to edit the 'hazard rating' of a 'market condition' conditionally? or to otherwise change the 'hazard' of a 'market condition' with code?
    2) is there a way to edit the code that runs when you click the 'hazard pay' button on the market screen?
    3) is there a way to edit the code that runs when you click the 'free port' button on the market screen?
    4) is there a way to change the text and descriptions for the 'free port' and 'hazard pay' buttons on the market screen? ether conditionally or overall?
thank you all again for reading and maybe answering my question. hope you all have a good day =)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SirHartley on September 07, 2023, 02:20:58 PM
hello once more all you kind people. i am hear with questions again
    1) is there a way to edit the 'hazard rating' of a 'market condition' conditionally? or to otherwise change the 'hazard' of a 'market condition' with code?
    2) is there a way to edit the code that runs when you click the 'hazard pay' button on the market screen?
    3) is there a way to edit the code that runs when you click the 'free port' button on the market screen?
    4) is there a way to change the text and descriptions for the 'free port' and 'hazard pay' buttons on the market screen? ether conditionally or overall?
thank you all again for reading and maybe answering my question. hope you all have a good day =)
Hi,

1) extremely simple: market.getHazard().modify...;
2) no (trust me, I really, really tried, but it's entirely private static methods)
3) no (freeport code is obfuscated)
4) no (most colony UI code is obfuscated)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 08, 2023, 06:57:47 AM
Is there a way to get the entity that the player is hovering their mouse over in the campaign?
Specificly without it being a course target.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 08, 2023, 07:33:00 AM
Is there a way to get the entity that the player is hovering their mouse over in the campaign?
Specificly without it being a course target.

Doesn't look like it. Just added:
SectorAPI.getMousedOverEntity()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on September 08, 2023, 05:15:14 PM
Is there a way to get the entity that the player is hovering their mouse over in the campaign?
Specificly without it being a course target.

Doesn't look like it. Just added:
SectorAPI.getMousedOverEntity()

Boom! Campaign ability targeting has been added! (I kid, sortof)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on September 09, 2023, 04:28:14 AM
I have a custom faction with custom music. The music does not play ingame. However, if I Alt + Tab or otherwise unfocus the game tab, the music does play. The music only doesn't play if the game window is in focus. Does anyone know what could be causing this?

For context, it used to work fine. I adjusted the music tracks in Audacity and now they do not play ingame, only tabbed out.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 09, 2023, 07:54:29 AM
Actually unrelated to my previous question, how do you get the Mouse Position in Campaign Coordinates?
I want something to happen when the mouse intersects with the radius of a Ring Terrain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 09, 2023, 07:59:57 AM
I have a custom faction with custom music. The music does not play ingame. However, if I Alt + Tab or otherwise unfocus the game tab, the music does play. The music only doesn't play if the game window is in focus. Does anyone know what could be causing this?

For context, it used to work fine. I adjusted the music tracks in Audacity and now they do not play ingame, only tabbed out.

Super weird! Do you have an older version of the track to try with? What you've described makes me wonder if the change to the track isn't just a red herring, and if the issue isn't some change that happened on your system, instead.

Actually unrelated to my previous question, how do you get the Mouse Position in Campaign Coordinates?
I want something to happen when the mouse intersects with the radius of a Ring Terrain.

SectorAPI.getViewport().convertScreenXToWorldX() and convertScreenYToWorldY().

Edit: this may not work when UI scaling is set to anything other than 100% - it takes as input coordinates from mouse input events - InputEventAPI - not the raw mouse coordinate values. So if using raw mouse coordinates, you'd need to adjust them by the screen scale multiplier, which you can get from SettingsAPI.getScreenScaleMult().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on September 10, 2023, 11:36:19 AM
How do I create a beam weapon that does not interact with fighters? In other words, I want it to pass over fighters and only affect ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 11, 2023, 08:50:57 AM
In the .wpn file, set:
"collisionClass":"<class>",
"collisionClassByFighter":"<class>", # when *fired* by a fighter

Where <class> is one of:
HITS_SHIPS_AND_ASTEROIDS
HITS_SHIPS_ONLY_FF
HITS_SHIPS_ONLY_NO_FF

Whichever one of those is desired. "FF" means "friendly fire".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: touchofvanilla on September 12, 2023, 05:46:10 PM
I'm trying to make a planet that receives only very little light from its local star; however, I can't seem to find a way to visually make the planet completely dark on the campaign layer. What would be the best method to go about this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 13, 2023, 04:37:43 AM
Anyway to make an icon appear on the Hyperspace-Starscape map without a system being in that location?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2023, 10:40:49 AM
I'm trying to make a planet that receives only very little light from its local star; however, I can't seem to find a way to visually make the planet completely dark on the campaign layer. What would be the best method to go about this?

Hmm, I'm not sure that you can. Possibly calling SectorEntityToken.setLightSource() on it every frame might do the trick? But it also might not work since the game will be doing this too, using the primary star, so it depends on the order of these calls within the frame. I've added a few ways to override this a couple of weeks ago - MemFlags.LIGHT_SOURCE_OVERRIDE and MemFlags.LIGHT_SOURCE_COLOR_OVERRIDE - but these aren't in the currently-out version.

Anyway to make an icon appear on the Hyperspace-Starscape map without a system being in that location?

I don't think so, the only things that shows are 1) stars, 2) the faked up "nebulas" around the stars, and 3) slipstreams, in dev. Oh, and the constellation/other labels. Hmm. No way to piggyback on any of that comes to mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on September 13, 2023, 11:01:49 AM
Not really a modding question but this kind of a request thread and it's related to modding, so...

Thoughts on adding RAM to the log file in this section?
Code
Starting Starsector 0.96a-RC10 launcher
Running in E:\Starsector\starsector-core
OS: Windows 8.1 6.3
Java version: 1.7.0_79 (64-bit)

The max JVM RAM is a useful thing to know when debugging modded saves. 2GB allocated + 30 mods enabled, hmmmmmm. It is often clear when something is a OOM crash because it says it, but not _always_ (and VRAM crashes don't have any crash message at all).

LazyWizard determines it like so:
https://github.com/LazyWizard/console-commands/blob/master/src/main/kotlin/org/lazywizard/console/ext/SystemInfoExtRAM.kt

GPU doesn't come up as much when troubleshooting (on the Discord anyway) and is more fiddly to get, but if it's a pain point: https://github.com/LazyWizard/console-commands/blob/master/src/main/kotlin/org/lazywizard/console/ext/SystemInfoExtGPU.kt

Also, shameless self-promotion for where I'd use one or both; my logfile viewer: https://chipper.pages.dev/
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on September 13, 2023, 12:45:51 PM
Is the raider behavior of pirates and luddic path hardcoded? How would I go about making a faction do raids on systems like pirates do?

Is the salvager behavior of independents hardcoded? How would I go about making a faction send out exploration fleets like independents do?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on September 13, 2023, 03:45:41 PM
I want to make a beam that does a fraction of its damage as hard flux. Here is the code:
Code
public static class SemiHardFluxDamageDealtMod implements DamageDealtModifier {
protected ShipAPI ship;
public SemiHardFluxDamageDealtMod(ShipAPI ship) {
this.ship = ship;
}

public String modifyDamageDealt(Object param,
    CombatEntityAPI target, DamageAPI damage, Vector2f point, boolean shieldHit) {

if (!(param instanceof DamagingProjectileAPI) && param instanceof BeamAPI) {

double randomNumber = Math.random();
if (randomNumber <= 0.25f) {
damage.setForceHardFlux(true);
}
else {
damage.setForceHardFlux(false);
}

}

return null;
}
}

First question: Do I need the "else"? I think not since the setting to hard flux is only for this batch of damage, right?
Second question: If I want to make the % of hard flux dependent on range as a percent of the Beam's max range is there any way to find out which weapon created this damageAPI object?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 13, 2023, 04:23:14 PM
Not really a modding question but this kind of a request thread and it's related to modding, so...

Thoughts on adding RAM to the log file in this section?
Code
Starting Starsector 0.96a-RC10 launcher
Running in E:\Starsector\starsector-core
OS: Windows 8.1 6.3
Java version: 1.7.0_79 (64-bit)

The max JVM RAM is a useful thing to know when debugging modded saves. 2GB allocated + 30 mods enabled, hmmmmmm. It is often clear when something is a OOM crash because it says it, but not _always_ (and VRAM crashes don't have any crash message at all).

LazyWizard determines it like so:
https://github.com/LazyWizard/console-commands/blob/master/src/main/kotlin/org/lazywizard/console/ext/SystemInfoExtRAM.kt

GPU doesn't come up as much when troubleshooting (on the Discord anyway) and is more fiddly to get, but if it's a pain point: https://github.com/LazyWizard/console-commands/blob/master/src/main/kotlin/org/lazywizard/console/ext/SystemInfoExtGPU.kt

Also, shameless self-promotion for where I'd use one or both; my logfile viewer: https://chipper.pages.dev/

Seems like a good idea, yeah.
Added:
long memMB = (long) (Runtime.getRuntime().maxMemory() / (1024L * 1024L));
log.info("Max memory: " + memMB + "MB");

To that startup section.

Glanced at the code, but only briefly, so let me know if this is problematic; not sure why it'd be checking for "hotspot" etc.


Is the raider behavior of pirates and luddic path hardcoded? How would I go about making a faction do raids on systems like pirates do?

See: pirates.faction, the "custom" section, in particular "makesPirateBases". It *may* work for other factions, or it may not, it hasn't been tested much. If not you could look at PirateBaseIntel and related and implement this behavior directly.

Is the salvager behavior of independents hardcoded? How would I go about making a faction send out exploration fleets like independents do?

See: com.fs.starfarer.api.impl.campaign.procgen.themes.RuinsFleetRouteManager.

It spawns independent salvage fleets targeting the specific system the script is added to, iirc.

First question: Do I need the "else"? I think not since the setting to hard flux is only for this batch of damage, right?
Second question: If I want to make the % of hard flux dependent on range as a percent of the Beam's max range is there any way to find out which weapon created this damageAPI object?

... I'm not sure on either count, actually, sorry! The first one should be pretty easy to test. The second, I know mods have made partial-hard-flux weapons, so you may want to look/ask around.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on September 14, 2023, 05:39:07 PM
question
how can i disable a weapon permanently without triggering any visual effects or floating text?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 14, 2023, 06:26:04 PM
I don't *think* you can.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 14, 2023, 06:46:23 PM
I have a custom faction with custom music. The music does not play ingame. However, if I Alt + Tab or otherwise unfocus the game tab, the music does play. The music only doesn't play if the game window is in focus. Does anyone know what could be causing this?

For context, it used to work fine. I adjusted the music tracks in Audacity and now they do not play ingame, only tabbed out.
Are they not playing at all, or is it just too soft to hear?
I've encountered a bug in the past where music got way louder when the game was out of focus (possibly the game ignoring the volume setting in sounds.json)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tecrys on September 15, 2023, 09:22:29 AM
What do I need to do in a .faction file to prevent a faction from treating the player (or anyone actually) as neutral with transponder off but as soon as I turn it on they're  hostile. I want everyone always being treated as hostile by that faction no matter the state of transponder or any circumstances
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2023, 09:39:06 AM
What do I need to do in a .faction file to prevent a faction from treating the player (or anyone actually) as neutral with transponder off but as soon as I turn it on they're  hostile. I want everyone always being treated as hostile by that faction no matter the state of transponder or any circumstances

Hmm. I don't think you can do this through the .faction file. See:
RemnantSeededFleetManager.initRemnantFleetProperties()

This sets some flags to make Remnant fleets attack the player when the player's transponder is turned off (namely, MemFlags.MEMORY_KEY_SAW_PLAYER_WITH_TRANSPONDER_ON). For other NPC fleets, I'm not sure if this is even necessary, I don't remember offhand.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on September 15, 2023, 10:17:25 AM
Is there a tag or somesuch to get around hidden hullmods not being s-moddable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 15, 2023, 11:20:57 AM

Anyway to make an icon appear on the Hyperspace-Starscape map without a system being in that location?

I don't think so, the only things that shows are 1) stars, 2) the faked up "nebulas" around the stars, and 3) slipstreams, in dev. Oh, and the constellation/other labels. Hmm. No way to piggyback on any of that comes to mind.

Managed to do it by creating a new star type, generating the jumppoint, looking through hyperspace to find the jumppoint, decreasing its radius to 0 and then intercepting its player interactions with the CampaignPlugin...

Lets say it works but having a way to add icons to the starscape map would definitly be appreciated, haha.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 15, 2023, 12:13:55 PM
Is there a tag or somesuch to get around hidden hullmods not being s-moddable?

I don't think so, sorry!

Managed to do it by creating a new star type, generating the jumppoint, looking through hyperspace to find the jumppoint, decreasing its radius to 0 and then intercepting its player interactions with the CampaignPlugin...

Lets say it works but having a way to add icons to the starscape map would definitly be appreciated, haha.

Oh haha, wow. Nice hacking, and I mean that sincerely :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on September 16, 2023, 06:31:24 PM
What do I need to do in a .faction file to prevent a faction from treating the player (or anyone actually) as neutral with transponder off but as soon as I turn it on they're  hostile. I want everyone always being treated as hostile by that faction no matter the state of transponder or any circumstances

Hmm. I don't think you can do this through the .faction file. See:
RemnantSeededFleetManager.initRemnantFleetProperties()

This sets some flags to make Remnant fleets attack the player when the player's transponder is turned off (namely, MemFlags.MEMORY_KEY_SAW_PLAYER_WITH_TRANSPONDER_ON). For other NPC fleets, I'm not sure if this is even necessary, I don't remember offhand.
custom.pirateBehavior in the .faction file would also make the faction fleets attack transponder-off fleets (but with some side effects), I think?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2023, 10:04:34 AM
Yeah - definitely some side effects, though. I think it would only affect how they engage the player re: transponder status, and they'd also be less willing to fight patrols.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 17, 2023, 12:27:33 PM
more mission questions!

1 - how do you set the text in a TooltipMakerAPI to be small?
I'm trying to copy the "accepted mission" dialog popup & I'm almost there, though for some reason it refuses to comply if I call TooltipMakerAPI.setParaSmallInsignia() either before or after the addPara() call


EDIT : so it turns out that setParaSmallInsignia() makes the text large instead of small?

2 - how do you set an intel item to expire itself after some time (like a bounty that's been completed / abandoned etc)
I've tried calling endAfterDelay(1) within the intel item, though it doesn't actually remove the intel after the delay, even if I override notifyEnded() to remove the intel (and endImmediately does end it correctly, but I'd rather not do that)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 17, 2023, 12:34:58 PM
1 - how do you set the text in a TooltipMakerAPI to be small?
I'm trying to copy the "accepted mission" dialog popup & I'm almost there, though for some reason it refuses to comply if I call TooltipMakerAPI.setParaSmallInsignia() either before or after the addPara() call

One of those methods, yeah. "small insignia" is larger than the default font though so maybe that's the issue. It depends on what actual font you want.

2 - how do you set an intel item to expire itself after some time (like a bounty that's been completed / abandoned etc)
I've tried calling endAfterDelay(1) within the intel item, though it doesn't actually remove the intel after the delay, even if I override notifyEnded() to remove the intel (and endImmediately does end it correctly, but I'd rather not do that)

You can use endAfterDelay(), but you need to .addScript(intel) to something - the location, or the SectorAPI - that runs scripts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on September 18, 2023, 01:28:54 PM
hello once again everyone. i have returned with yet more questions for all you kind people.
    1) how do i run ShipVariantAPI.removeMod() and ShipVariantAPI.addMod() without having said ship lose combat readiness
    2) with a 'TooltipMakerAPI' how do i add a set of images in a row, with some text next to each one? the text always seems to end up below the image for some reason.
    2.a)note: what I'm trying to do is mimic 'TooltipMakerAPI.addSkillPanel()' with things that are not officer skills.
thank you all again for answering my questions in the past. its always very nice to have them answering instead of blundering around in the dark for ages.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lycaeon on September 19, 2023, 12:31:16 AM
Is there a setting or mod that allows the adjustment of the damage modifiers for kinetic and high explosive damage against armor/shields? What I want to do is make the damage bonus a flat 33% increase or decrease compared to the current modifiers such as kinetic dealing 200% damage to shields but 50% damage to armor.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 19, 2023, 10:49:36 AM
1) how do i run ShipVariantAPI.removeMod() and ShipVariantAPI.addMod() without having said ship lose combat readiness

CR is not lost touched when you call these methods. The CR loss for "refitting in space" is applied when you call FleetMemberAPI.setVariant(), and that method has a parameter - withRefit - that controls whether or not this happens.

2) with a 'TooltipMakerAPI' how do i add a set of images in a row, with some text next to each one? the text always seems to end up below the image for some reason.
2.a)note: what I'm trying to do is mimic 'TooltipMakerAPI.addSkillPanel()' with things that are not officer skills.
thank you all again for answering my questions in the past. its always very nice to have them answering instead of blundering around in the dark for ages.

See: TooltipMakerAPI.beginImageWithText() and .addImageWithText().

In particular, make sure that you're adding the text to the new TooltipMakerAPI returned by beginImageWithText().


Is there a setting or mod that allows the adjustment of the damage modifiers for kinetic and high explosive damage against armor/shields? What I want to do is make the damage bonus a flat 33% increase or decrease compared to the current modifiers such as kinetic dealing 200% damage to shields but 50% damage to armor.

The DamageType class is in the API and has getters/setters for thes values, so you could do that with code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on September 22, 2023, 01:38:14 PM
Where can I find the text for the size and condition dependent messages about each market on the left of the screen when the player is in the trading window, and how would I add them for a custom faction?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MiniDeth3 on September 23, 2023, 03:22:18 AM
How does one apply a hullmod on a ship as built in (not smod) via a script?

Is it possible to do it in a Campaign every frame?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on September 23, 2023, 12:00:35 PM
How do I get rid of a projectile? I have a weapon that fires a projectile. If it hits, it does damage normally. If it misses by a little bit I call engine.spawnDamagingExplosion for half damage. Everything works fine but currently, after calling the explosion, the projectile continues on its course. I'd like to make it disappear right away.

EDIT
Found it. engine.removeEntity(projetile);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on September 24, 2023, 04:11:32 AM
Is there anyway to show/hide an Aptitude skill and all skills governed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 24, 2023, 11:08:00 AM
Where can I find the text for the size and condition dependent messages about each market on the left of the screen when the player is in the trading window, and how would I add them for a custom faction?

This is in rules.csv; you can take a look at the trigger (TradePanelFlavorText) and conditions there.


How does one apply a hullmod on a ship as built in (not smod) via a script?

ModPlugon.onApplicationLoad(), and then using ShipHullSpecAPI.addBuiltInMod().

You can use Global.getSettings().getAllShipHullSpecs() to get the hull specs.


Is it possible to do it in a Campaign every frame?

I wouldn't, that seems like a recipe for various problems.


EDIT
Found it. engine.removeEntity(projetile);

*thumbs up*



Is there anyway to show/hide an Aptitude skill and all skills governed?

You can add/remove the "npc_only" tag to that aptitude's skill effect, I think that would work. To remove the tag, you'd need to SkillSpecAPI.getTags().remove(); there's no removeTag() method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 27, 2023, 03:29:09 AM
two small (ish) questions -
is there a way to get the emp / burst for a burst beam?
and is there a way to get the number of linked barrels / MIRV subprojectiles for a weapon? (or ideally, is there a way to get the exact string that gets used for a weapon's damage / shot in the refit screen?)

extra question - is there a way to detect if escape menu (is that what it's called? the menu that gets opened by escape) is open in combat?

double extra question - how do you get a ship to be completely removed from the combat engine? I'm calling CombatEngineAPI.removeEntity() on a ship but it still sticks around in the deployed ships screen & keeps taking up DP
triple extra edit - after a small amount of testing (using only console commands to call removeEntity on a ship), it seems like removeEntity is broken w/r/t ships & doesn't fully remove them from combat, could that be fixed?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vitmainlem on September 27, 2023, 08:17:36 AM
Two questions
first - Is it possible to make hullmod that is similar to High Scatter Amplifier but work in the individual java file?
second - is there a way to increase damaging hit box of the beam?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on September 28, 2023, 12:03:46 AM
Is there a way to make a faction not offer anti-pirate base bounties? I am working on a custom faction that is cooperative with pirates (100 reputation), but despite that they just offered a bounty to destroy a pirate base targeting their system. This faction also has "postsNoBounties":true, but that doesn't seem to apply to pirate base bounties.

Also is it possible to make the pirates not raid a faction's convoys even when their reputation isn't at 100?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2023, 09:53:02 AM
is there a way to get the emp / burst for a burst beam?

WeaponAPI.getDamage().getFluxComponent() should do it; before EMP was EMP it applied damage to the target's flux and the method name is from those days. I don't think this was ever in an actual release.


and is there a way to get the number of linked barrels / MIRV subprojectiles for a weapon? (or ideally, is there a way to get the exact string that gets used for a weapon's damage / shot in the refit screen?)

No way to get that exact string other than composing it from the weapon's data.

Number of barrels: the size of getHardpointFireOffsets() in the weapon spec etc.

MIRV projectiles: you'd need to look in ProjectileSpecAPI.getBehaviorJSON(), I believe.

extra question - is there a way to detect if escape menu (is that what it's called? the menu that gets opened by escape) is open in combat?

Not for that dialog specifically, but: CombatEngineAPI.isUIShowingDialog()

double extra question - how do you get a ship to be completely removed from the combat engine? I'm calling CombatEngineAPI.removeEntity() on a ship but it still sticks around in the deployed ships screen & keeps taking up DP

Hmm, there probably is a way to do this since I think people do it, but I'm not 100% on how.


triple extra edit - after a small amount of testing (using only console commands to call removeEntity on a ship), it seems like removeEntity is broken w/r/t ships & doesn't fully remove them from combat, could that be fixed?

It definitely works and is broadly used, so you'd need to be more specific! It's likely either an error using it or a question of expectations.


first - Is it possible to make hullmod that is similar to High Scatter Amplifier but work in the individual java file?

Possibly; I don't remember what the limitations of JANINO are here that would make it not work. You might need to extract other classes defined in that file (anonymous and not) into their own files, or some such.

second - is there a way to increase damaging hit box of the beam?

There isn't; the beam is a line.


Is there a way to make a faction not offer anti-pirate base bounties? I am working on a custom faction that is cooperative with pirates (100 reputation), but despite that they just offered a bounty to destroy a pirate base targeting their system. This faction also has "postsNoBounties":true, but that doesn't seem to apply to pirate base bounties.

Hmm, I don't think so, short of overriding the PirateBaseIntel class; the setBounty() method is where this happens. I've just changed it to respect postsNoBounties.

Also is it possible to make the pirates not raid a faction's convoys even when their reputation isn't at 100?

Hmm - presumably you mean "non-hostile", not "100", but I don't think so. If they're hostile, they'll attack.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 28, 2023, 11:36:12 AM
WeaponAPI.getDamage().getFluxComponent() should do it; before EMP was EMP it applied damage to the target's flux and the method name is from those days. I don't think this was ever in an actual release.
hmmm, I was hoping that it'd be something in the weapon spec I missed, though that still works for what I want to do

No way to get that exact string other than composing it from the weapon's data.
a shame but no big deal, ty!

triple extra edit - after a small amount of testing (using only console commands to call removeEntity on a ship), it seems like removeEntity is broken w/r/t ships & doesn't fully remove them from combat, could that be fixed?

It definitely works and is broadly used, so you'd need to be more specific! It's likely either an error using it or a question of expectations.

here's an example of what I mean - the behaviour I'd expect is that a ship removed with removeEntity() would refund the DP it took up & stop appearing in the "deployed ships" dialog.

https://youtu.be/u1_qlmvf1TE
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2023, 11:39:54 AM
here's an example of what I mean - the behaviour I'd expect is that a ship removed with removeEntity() would refund the DP it took up & stop appearing in the "deployed ships" dialog.

Ah - this is working as intended, yeah. removeEntity() is a low-level method and just removes an entity from the playing field. Anything else that you also want to happen needs to be done directly (and may not have the API exposed, depending on what it is.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on September 28, 2023, 12:13:14 PM
Also is it possible to make the pirates not raid a faction's convoys even when their reputation isn't at 100?
Hmm - presumably you mean "non-hostile", not "100", but I don't think so. If they're hostile, they'll attack.

I'll have to check if this is something caused by Nexerelin and not the base game, but currently the pirates will disrupt the shipping of anyone who isn't at 100 reputation with them, rather than the 0 that's expected. The effect lessens with higher reputation but even when they're at friendly rather than cooperative they'll still disrupt shipping every now and then.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vitmainlem on September 28, 2023, 12:23:46 PM

second - is there a way to increase damaging hit box of the beam?

There isn't; the beam is a line.

Ok, so not even the Width of the beam?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on September 28, 2023, 12:28:06 PM
Ah - this is working as intended, yeah. removeEntity() is a low-level method and just removes an entity from the playing field. Anything else that you also want to happen needs to be done directly (and may not have the API exposed, depending on what it is.)

yeah, it doesn't look like anything related to that is exposed to the API (the closest thing sounds like CombatFleetManagerAPI.removeFromReserves(), but that doesn't do it), would it be possible to have those methods get exposed to the API?
Though it's not a *huge* deal, just multiplying the ship's DP by 0 will "fix" the main issue.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on September 28, 2023, 01:48:10 PM
1. Is adding more personalities through personalities.csv actually supported, i havent seen a mod add custom personalities with it so im wondering if there is some hurdle there.
2. Is the bravery stat used for anything? Since it appears to be the same for all personalities.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 28, 2023, 02:24:15 PM
Ok, so not even the Width of the beam?

Correct, that's purely visual.

yeah, it doesn't look like anything related to that is exposed to the API (the closest thing sounds like CombatFleetManagerAPI.removeFromReserves(), but that doesn't do it), would it be possible to have those methods get exposed to the API?
Though it's not a *huge* deal, just multiplying the ship's DP by 0 will "fix" the main issue.

I'll keep it in mind!

1. Is adding more personalities through personalities.csv actually supported, i havent seen a mod add custom personalities with it so im wondering if there is some hurdle there.
2. Is the bravery stat used for anything? Since it appears to be the same for all personalities.

1. No; there are hardcoded checks in too many places.
2. It has some effect, I believe, but it'd probably mostly be subtle. To do with how it evaluates some aspects of some threats, but far from comprehensive and not officially supported.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on September 28, 2023, 09:40:51 PM
Hi I am trying to imitate UI similar to one below, mainly i want to replicate that transparent background
Spoiler
(https://i.imgur.com/Z8kPPW3.png)
[close]
I am using such code to initalize UI
Spoiler
Code
public class AoTDColonyEventOutcomeDelegate  implements CustomVisualDialogDelegate {
    protected DialogCallbacks callbacks;
    protected AoTDColonyEventOutcomeUI plugin;
    protected InteractionDialogAPI dialog;

    public AoTDColonyEventOutcomeDelegate(AoTDColonyEventOutcomeUI panel , InteractionDialogAPI dialog){
        this.plugin = panel;
        this.dialog = dialog;
    }
    @Override
    public void init(CustomPanelAPI panel, DialogCallbacks callbacks) {
        this.callbacks = callbacks;

        plugin.init(panel, callbacks, dialog);
    }

    @Override
    public CustomUIPanelPlugin getCustomPanelPlugin() {
        return plugin;
    }

    @Override
    public float getNoiseAlpha() {
        return 0;
    }

    @Override
    public void advance(float amount) {

    }

    @Override
    public void reportDismissed(int option) {

    }

Code
public class AoTDColonyEventOutomeDP implements InteractionDialogPlugin {
    public InteractionDialogAPI dialog;
    public AoTDColonyEvent event;

    static enum OptionID {
        INIT,
        LEAVE
    }

    @Override
    public void init(InteractionDialogAPI dialog) {
        this.dialog = dialog;
        this.dialog.getTextPanel();
        dialog.hideTextPanel();
        dialog.setPromptText("");
        dialog.getVisualPanel().finishFadeFast();
        dialog.setOpacity(1.85f);
       
        dialog.setBackgroundDimAmount(0f);
        optionSelected(null, OptionID.INIT);
    }

    public void setEvent(AoTDColonyEvent event) {
        this.event = event;
    }

    @Override
    public void optionSelected(String optionText, Object optionData) {
        if (optionData == OptionID.INIT) {
            //this is where the size of the panel is set, automatically centered
            dialog.showCustomVisualDialog(AoTDColonyEventOutcomeUI.WIDTH + 20, AoTDColonyEventOutcomeUI.HEIGHT + 20, new AoTDColonyEventOutcomeDelegate(new AoTDColonyEventOutcomeUI(),dialog));

        }
    }

    @Override
    public void optionMousedOver(String optionText, Object optionData) {

    }

    @Override
    public void advance(float amount) {

    }

    @Override
    public void backFromEngagement(EngagementResultAPI battleResult) {

    }

    @Override
    public Object getContext() {
        return null;
    }

    @Override
    public Map<String, MemoryAPI> getMemoryMap() {
        return null;
    }
[close]
My problem is I can't get such same effect with transparent background as shown in image and instead got this
Spoiler
(https://i.imgur.com/Cb5SoZT.png)
[close]
I am using such method because when I used class that implemented CustomDialogDelegate It's not possible to jump from one UI to another after confirm button is pressed.
Honestly now i don't know what to do
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RedDragon924 on September 29, 2023, 08:32:18 AM
Hey, does anyone know how to change the base name of a planet with a code via the console command mod or in the code? I used a code posted elsewhere to spawn a couple planets, forgetting to change the name on the copied code. I didn't think it'd be a problem but now, when I colonize both planets, the game seems to think only one exists and puts the other on a permanent pause. I've tried looking through it in the save's xml file with Notepad++, but the best I can do is just replace a few names here and there, and that doesn't seem to be affecting anything. The help would be greatly appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on September 29, 2023, 09:01:23 AM
Hey, does anyone know how to change the base name of a planet with a code via the console command mod or in the code? I used a code posted elsewhere to spawn a couple planets, forgetting to change the name on the copied code. I didn't think it'd be a problem but now, when I colonize both planets, the game seems to think only one exists and puts the other on a permanent pause. I've tried looking through it in the save's xml file with Notepad++, but the best I can do is just replace a few names here and there, and that doesn't seem to be affecting anything. The help would be greatly appreciated.
Code
 for (PlanetAPI planet : Global.getSector().getStarSystem("nameOfSystemWithPlanetsToRename").getPlanets()) {
            if(planet.getId().equals("wantedId")){
                planet.setName("Renamed Planet");
            }
           
        }

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: RedDragon924 on September 29, 2023, 10:14:27 AM
Thank you so much! That seemed to do the trick. Both colonies showed up now and progressed normally.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2023, 10:22:44 AM
Hi I am trying to imitate UI similar to one below, mainly i want to replicate that transparent background
Spoiler
(https://i.imgur.com/Z8kPPW3.png)
[close]
I am using such code to initalize UI

I'm not sure. A dialog using CustomVisualDialogDelegate should have a partially transparent background.

But, this code looks dodgy:
dialog.setOpacity(1.85f);

Opacity should have a value between 0 and 1; I'm actually a bit surprised this doesn't cause a crash.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on September 29, 2023, 10:30:44 AM
How would someone go about removing / increasing the Burn 20 hard cap without resorting to mods like Sundog's Hyperdrive? Is it something that needs to be done via JavaScript, or is there a setting that I missed when searching in 'data\config\settings.json'?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on September 29, 2023, 10:41:47 AM
Hi I am trying to imitate UI similar to one below, mainly i want to replicate that transparent background
Spoiler
(https://i.imgur.com/Z8kPPW3.png)
[close]
I am using such code to initalize UI

I'm not sure. A dialog using CustomVisualDialogDelegate should have a partially transparent background.

But, this code looks dodgy:
dialog.setOpacity(1.85f);

Opacity should have a value between 0 and 1; I'm actually a bit surprised this doesn't cause a crash.
That things with expermenting oppacity was my cry for help.
As problem is such, when I lower oppacity of dialog it does make it transparent, but not only background, UI also becomes transparent to the point when is not readable, and I wondered how could I replicate what was done with example UI I showed
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 29, 2023, 12:12:50 PM
How would someone go about removing / increasing the Burn 20 hard cap without resorting to mods like Sundog's Hyperdrive? Is it something that needs to be done via JavaScript, or is there a setting that I missed when searching in 'data\config\settings.json'?

This is actually hardcoded. Along with the UI bar only showing up to 20, though the numbers go up beyond that.


That things with expermenting oppacity was my cry for help.
As problem is such, when I lower oppacity of dialog it does make it transparent, but not only background, UI also becomes transparent to the point when is not readable, and I wondered how could I replicate what was done with example UI I showed

Hmm. Like I was saying, the default custom dialog should have some background transparency - the default amount - so this is all a bit confusing to me.

IIRC the control for how much to dim the background is not exposed for this, unfortunately.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on September 29, 2023, 08:42:28 PM
How would someone go about removing / increasing the Burn 20 hard cap without resorting to mods like Sundog's Hyperdrive? Is it something that needs to be done via JavaScript, or is there a setting that I missed when searching in 'data\config\settings.json'?

This is actually hardcoded. Along with the UI bar only showing up to 20, though the numbers go up beyond that.


That things with expermenting oppacity was my cry for help.
As problem is such, when I lower oppacity of dialog it does make it transparent, but not only background, UI also becomes transparent to the point when is not readable, and I wondered how could I replicate what was done with example UI I showed

Hmm. Like I was saying, the default custom dialog should have some background transparency - the default amount - so this is all a bit confusing to me.

IIRC the control for how much to dim the background is not exposed for this, unfortunately.
ahh understandable, but gonna say that because of it I needed to rewrite UI and actually this made it better than worse.
Spoiler
(https://i.imgur.com/b1A3dYi.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on September 30, 2023, 11:15:16 AM
That looks nice! Big fan of working illustrations into the UI, for sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 01, 2023, 10:11:03 PM
Is it possible to implement a custom star/system/whatever via mods that's outside the Sector's boundaries? It wouldn't show on the map due to being out-of-bounds, for instance.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on October 03, 2023, 02:38:36 AM
kinda vague question, but that's the deal with BALLISTIC_AS_BEAM projectiles?
this is specifically in relation to why changes to their velocity just don't work, though I would generally like to know more about how they work & when to use them over normal projectiles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on October 03, 2023, 01:31:57 PM
Is it possible to render or hide the sprite of a weapon during combat?

Edit: Never mind I was told to try and set the alpha channel of a sprite to 0, making it entirely transparent.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2023, 08:33:25 AM
Is it possible to implement a custom star/system/whatever via mods that's outside the Sector's boundaries? It wouldn't show on the map due to being out-of-bounds, for instance.

You'd have to remove the gravity well from hyperspace to make it hidden. In the next release, there's a "star_hidden_on_map" tag that could be added to the jump-point instead, for *reasons*.


kinda vague question, but that's the deal with BALLISTIC_AS_BEAM projectiles?
this is specifically in relation to why changes to their velocity just don't work, though I would generally like to know more about how they work & when to use them over normal projectiles.

The main functional difference - aside from getVelocity().set() doing nothing - is that they collide over the entire length of the projectile, including the trail, as opposed to just around the actual projectile. There were other, more meaningful distinctions way back when projectiles could hit each other; not sure if there was ever even a release with that functionality in it. At this point it's more of a holdover from days past.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 04, 2023, 10:16:42 AM
You'd have to remove the gravity well from hyperspace to make it hidden. In the next release, there's a "star_hidden_on_map" tag that could be added to the jump-point instead, for *reasons*.

This makes me both very happy and very hyped!

I'mma add another question while I'm at it: Will the Orion-Perseus abyss start before the actual edge of the map? I remember you mentioned that beyond the map borders will be abyssal hyperspace all around, but I'm wondering if the border at the bottom will be 'brought up' to coincide with the label (at least in alignment if not positioning). This is mostly so it'd allow me to put a hidden star in the abyss for *reasons*.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 04, 2023, 10:49:44 AM
There is some abyssal hyperspace in the corner of the map.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SONZ-INA on October 06, 2023, 06:35:23 AM
Is there a way to remove the UI for arc radius on a weapon?
The weapon will still have range, it'll still work, however the arc display HUD will just not show up for those weapons.
I see that there's a displayArcRadius for weapons, but it doesn't seem to do anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 07, 2023, 01:14:25 AM
Question - there are some older mods that I still like to use so I modify them myself. One of the thing I did was alter the hullmods for the new S-mod thing.

I edited both the java files of hullmods to the add the if (sMod) branch and the hullmods.cvs to add the SModDesc descriptions, but in-game no S-mod description show up, nor even the S-mod ui category. Am I missing something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 07, 2023, 08:09:24 AM
Is there a way to remove the UI for arc radius on a weapon?
The weapon will still have range, it'll still work, however the arc display HUD will just not show up for those weapons.
I see that there's a displayArcRadius for weapons, but it doesn't seem to do anything.

I don't think so. It's up to the player whether they want to show or hide those. (Using the tilde key by default.)

Question - there are some older mods that I still like to use so I modify them myself. One of the thing I did was alter the hullmods for the new S-mod thing.

I edited both the java files of hullmods to the add the if (sMod) branch and the hullmods.cvs to add the SModDesc descriptions, but in-game no S-mod description show up, nor even the S-mod ui category. Am I missing something?

Hmm, nothing else comes to mind. Make sure the hullmod class is extending BaseHullMod - though if it wasn't, I think you'd have noticed due to other problems, so that's probably not it.

... are you testing this in the main menu? S-mod stuff only shows up in the campaign.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on October 08, 2023, 03:55:51 AM
How do i make custom market conditions show up in this screen?
They only show up in the colony management screen for some reason, not on the planet itself.

(https://cdn.discordapp.com/attachments/1073387162646610071/1160530828112175184/image.png?ex=6534ff8f&is=65228a8f&hm=a2e7f1464755181325e7230f1391c85890b29ca1064e4bf64f04bfc6a597e9e9&.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 08, 2023, 04:16:43 AM
IIRC you need to get the MarketConditionAPI and set it surveyed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on October 08, 2023, 04:22:57 AM
IIRC you need to get the MarketConditionAPI and set it surveyed.

The conditions are being spawned at procgen (by myself though, not the condition generation csv) and should be surveyed when the player does it themself.
They show up as surveyed on the planet, just not this menu.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 08, 2023, 04:48:11 AM
IIRC you need to get the MarketConditionAPI and set it surveyed.

The conditions are being spawned at procgen (by myself though, not the condition generation csv) and should be surveyed when the player does it themself.
They show up as surveyed on the planet, just not this menu.

I think player surveys only set "planetary" conditions to surveyed. It has been years since I worked with that stuff but I see custom conditions working for one of my 0.9.1 mods on that screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SONZ-INA on October 08, 2023, 08:58:05 AM
Is there a way to set a slot's, or weapon's arc to a value, and it resets to default when changing to other weapon?
Example: If i install a custom weapon and i set it's Arc to 360 via code, and then uninstall it, the Arc will go back to the Ship's default.
Can't really get it to work with code, so i'm wondering if there's an easier (or existing) solution.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: MiniDeth3 on October 08, 2023, 08:59:01 AM
I'm pretty sure I'm missing something. I've made a modplugin to add a hullmod based on a loaded ships manufacturer but I cant apply my modded hullmod only vanilla ones. Is there a step I'm missing to allow my hullmods id to be recognized?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on October 08, 2023, 01:28:40 PM
is there a way to start a campaign battle from an interactionDialogPlugin?

EDIT: nvm it's InteractionDialogAPI.startBattle();
though now, how do I add an allied fleet to the player side?

EDIT 2 : or more specifically, how would I get the battle to act like one between 2 AI fleets that the player has decided to join in on (with both AI fleets already deployed & damaged, etc)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on October 08, 2023, 02:35:48 PM
How can I get the fluxCapacity that a ship starts the battle with? I used:
ship.getMutableStats().getFluxCapacity().getBaseValue()
but that gets the value without flux capaciters and other hull mods it might have. The reason I ask is that I have a weapon that will temporarily lower a ship's flux capacity but not below one third of the original so I need to know the original.
I can't use
ship.getMutableStats().getFluxCapacity().modified
because I'm going to be modifying it and that value would only be correct for the first time the weapon hits a given ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on October 09, 2023, 11:12:49 AM
IIRC you need to get the MarketConditionAPI and set it surveyed.

The conditions are being spawned at procgen (by myself though, not the condition generation csv) and should be surveyed when the player does it themself.
They show up as surveyed on the planet, just not this menu.

I think player surveys only set "planetary" conditions to surveyed. It has been years since I worked with that stuff but I see custom conditions working for one of my 0.9.1 mods on that screen.

Figured the issue out, even if you dont procgen the conditions, to show in the planet menu they need an entry in the condition procgen csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 10, 2023, 07:42:16 AM
Has there been a change to Hull Mods in .variants?

I saw this stuff in the Automated XIV Legion's file:

Code
    "hullMods": [
        "automated",
        "missleracks",
        "targetingunit",
        "heavyarmor",
        "reinforcedhull",
        "degraded_engines",
        "faulty_grid",
        "comp_structure",
        "hardenedshieldemitter"
    ],
    "permaMods": [
        "automated",
        "degraded_engines",
        "faulty_grid",
        "comp_structure",
        "missleracks",
        "targetingunit",
        "heavyarmor"
    ],
    "sMods": [
        "missleracks",
        "targetingunit",
        "heavyarmor"
    ],

Here in testing, the S-Mods do not show up. There's also the "hardenedshieldemitter" that is the one Hull Mod not present in either of the other lists. IDK whether that was intentional.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 10, 2023, 08:47:04 AM
How (un) feasible would it be to add a sub-tab for items under the Production tab?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on October 10, 2023, 03:47:08 PM
another battle creation question - is there a way to set the max deployment points of a battle independently of the setting in-game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 10, 2023, 04:43:59 PM
How do i make custom market conditions show up in this screen?
They only show up in the colony management screen for some reason, not on the planet itself.

Conditions on that screen only show if .isPlanetary() returns true for them.

Figured the issue out, even if you dont procgen the conditions, to show in the planet menu they need an entry in the condition procgen csv.

(... ah!)


Is there a way to set a slot's, or weapon's arc to a value, and it resets to default when changing to other weapon?
Example: If i install a custom weapon and i set it's Arc to 360 via code, and then uninstall it, the Arc will go back to the Ship's default.
Can't really get it to work with code, so i'm wondering if there's an easier (or existing) solution.

Hmm - you'd want to do this in combat, not in the refit screen, I think.

I'm pretty sure I'm missing something. I've made a modplugin to add a hullmod based on a loaded ships manufacturer but I cant apply my modded hullmod only vanilla ones. Is there a step I'm missing to allow my hullmods id to be recognized?

It's hard to say; it *should* work so the answer is probably yes you're missing something, but what? That's hard to say. I'd try adding a regular hullmod to your mod and making sure it shows up in the refit screen etc just to make sure there isn't some weird hitch like, I don't know, hull_mods.csv being misnamed in your mod or something else that's a total showstopper.



is there a way to start a campaign battle from an interactionDialogPlugin?

EDIT: nvm it's InteractionDialogAPI.startBattle();
though now, how do I add an allied fleet to the player side?

EDIT 2 : or more specifically, how would I get the battle to act like one between 2 AI fleets that the player has decided to join in on (with both AI fleets already deployed & damaged, etc)

It gets a bit complicated, but all this code should be in FleetInteractionDialogPluginImpl.



How can I get the fluxCapacity that a ship starts the battle with? I used:
ship.getMutableStats().getFluxCapacity().getBaseValue()
but that gets the value without flux capaciters and other hull mods it might have. The reason I ask is that I have a weapon that will temporarily lower a ship's flux capacity but not below one third of the original so I need to know the original.
I can't use
ship.getMutableStats().getFluxCapacity().modified
because I'm going to be modifying it and that value would only be correct for the first time the weapon hits a given ship.

ShipAPI.getFluxTracker().getMaxFlux()


Has there been a change to Hull Mods in .variants?

Yes; I forget the specifics but iirc support for specifying s-mods was added.

I saw this stuff in the Automated XIV Legion's file:
...

Here in testing, the S-Mods do not show up. There's also the "hardenedshieldemitter" that is the one Hull Mod not present in either of the other lists. IDK whether that was intentional.

All I can say is it works in the use case the game uses it for, hmm.


How (un) feasible would it be to add a sub-tab for items under the Production tab?

Rather :)


another battle creation question - is there a way to set the max deployment points of a battle independently of the setting in-game?

Hmm, I don't think so - let me add some methods to CombatFleetManagerAPI:
   void setMaxStrength(int maxStrength);
   int getCurrStrength();
   void modifyFlatMax(String source, int value);
   void modifyPercentMax(String source, float percent);
   void unmodifyMax();
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 10, 2023, 06:01:16 PM
How (un) feasible would it be to add a sub-tab for items under the Production tab?
Rather :)
...okay, that one's entirely on me X)

So I'm assuming that it was a "rather" to being unfeasible? And that such a thing is beyond the capabilities of modding?

Oh and while I'm back here (sorry for the large amount of talking), how does the Orbital Solar Array market condition work? For instance, if I make a custom star system and one planet has that condition, will the mirrors and shades be auto-added? Or is it the opposite - adding the mirrors and shades auto-adds the condition to the planet? Is it the same for procgen, are the odds are about the orbiting objects or the condition?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: xenoargh on October 10, 2023, 06:20:49 PM
Quote
All I can say is it works in the use case the game uses it for, hmm.
Yeah, that area of the code is... interesting, lol. Okies, I'll test some things.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 11, 2023, 08:55:29 AM
Oh and while I'm back here (sorry for the large amount of talking), how does the Orbital Solar Array market condition work? For instance, if I make a custom star system and one planet has that condition, will the mirrors and shades be auto-added? Or is it the opposite - adding the mirrors and shades auto-adds the condition to the planet? Is it the same for procgen, are the odds are about the orbiting objects or the condition?

They are added separately. See MiscellaneousThemeGenerator.addSolarShadesAndMirrors()
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on October 11, 2023, 11:35:49 AM
there's a crash in my mod caused by Global.getSoundPlayer.playCustomMusic that only crashes when music volume is set to zero (in game settings). the specific error is "Error initializing music source - AL error 40963", which indicates out of memory error. i'm using a music track defined in sounds.json. i'm wondering if there's a memory leak in there.

edit: i could avoid this crash entirely if i could check music volume setting using the API
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on October 11, 2023, 05:31:45 PM
Quote from: rogerbacon on October 08, 2023, 02:35:48 PM

    How can I get the fluxCapacity that a ship starts the battle with? I used:
    ship.getMutableStats().getFluxCapacity().getBaseValue()
    but that gets the value without flux capaciters and other hull mods it might have. The reason I ask is that I have a weapon that will temporarily lower a ship's flux capacity but not below one third of the original so I need to know the original.
    I can't use
    ship.getMutableStats().getFluxCapacity().modified
    because I'm going to be modifying it and that value would only be correct for the first time the weapon hits a given ship.


>>ShipAPI.getFluxTracker().getMaxFlux()

Well, I'm modifying the max flux with:
ship.getMutableStats().getFluxCapacity().modifyMult(this.key, 0.98f);
and I guess that's modifying the MaxFlux from the FluxTracker method too so that won't work. Do I need to store the unmodified value before I start modifying it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on October 11, 2023, 08:13:35 PM
Do I need to store the unmodified value before I start modifying it?
That's one option.
You can also, since you know what the key is, do an unmodify, check the value, and then re-modify.
Or you could use getMultStatMod (caution, return value may be null if no such modifier has yet been applied), and calculate backwards to what the unmodified maximum has to be.
Or you could just ignore the base maximum and simply cap your modifier at no less than 0.33333...

What exactly will work best is going to depend on exactly how you want your weapon to behave. For example, using modifyMult means this is going to hit 'harder' against ships with larger flux pools, which may or may not be intended behavior. (But is probably still the best way of getting consistent and predictable behavior, since doing flat modifications will run into the issue that anyone else's multipliers will multiply those flat mods.)

And, for that matter, if you're using the same key for all of your modifications - well. For example, if you call ship.getMutableStats().getFluxCapacity.modifyMult("foo",0.5f); then that cuts the ships' flux capacity in half... and if you call that five times in a row, the ship's flux capacity is still only halved because the id was the same for all of them, and that replaces previous "foo"-keyed values.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on October 12, 2023, 05:19:11 AM
Thanks Wyvern. Since I only care about teh max for the purpose of displaying it to the player with engine.maintainStatusForPlayerShip, I'll just forget about it and only display the lowered value. When it recovers to max the message goes away and most of the time the player should know his ship's unmodified max flux.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 12, 2023, 01:18:36 PM
So I'm assuming that it was a "rather" to being unfeasible? And that such a thing is beyond the capabilities of modding?

Yep!

there's a crash in my mod caused by Global.getSoundPlayer.playCustomMusic that only crashes when music volume is set to zero (in game settings). the specific error is "Error initializing music source - AL error 40963", which indicates out of memory error. i'm using a music track defined in sounds.json. i'm wondering if there's a memory leak in there.

edit: i could avoid this crash entirely if i could check music volume setting using the API

... alright! I'd need to see the stack trace, but if you've got a workaround?


@SafariJohn and @Wyvern - thank you for helping out here!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on October 12, 2023, 05:06:37 PM
there's a crash in my mod caused by Global.getSoundPlayer.playCustomMusic that only crashes when music volume is set to zero (in game settings). the specific error is "Error initializing music source - AL error 40963", which indicates out of memory error. i'm using a music track defined in sounds.json. i'm wondering if there's a memory leak in there.

edit: i could avoid this crash entirely if i could check music volume setting using the API

... alright! I'd need to see the stack trace, but if you've got a workaround?
[/quote]

i'll ask nia if they can hand me a stack trace since they reproduced it constantly. but if the volume setting is exposed via API then i can just avoid calling that method at all
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 12, 2023, 06:47:17 PM
if the volume setting is exposed via API then i can just avoid calling that method at all

Have you tried putting the crashing code into a try-catch block? As long as there is not a real problem (like actually running out of memory) then that should handle it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: avallanch on October 13, 2023, 03:37:23 AM
Is there any easy way to override one function from one of the mods?
Namely i want to mess with progress on Engineering Hub from Industrial Evolution
I've already found the function in the java file tried messing with it by adding it as part of separate mod to override it, but i have failed....
Any advices?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: mikkrish on October 13, 2023, 05:54:32 PM
Hi,

I want to rebalance economy in my playthrough but found that I cannot change ship prices in those Bar events in bar_events.csv:
Code
bar event id,tags,freq,prob,min dur,max dur,min timeout,max timeout,min accepted timeout,max accepted timeout,plugin
hmdf,,10,1,30,40,15,20,60,90,com.fs.starfarer.api.impl.campaign.missions.HandMeDownFreighter
sShip,,10,1,30,40,15,20,60,90,com.fs.starfarer.api.impl.campaign.missions.SurplusShipHull
hijack,,10,1,30,40,15,20,60,90,com.fs.starfarer.api.impl.campaign.missions.HijackingMission

Is it possible to adjust those prices?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on October 13, 2023, 08:16:31 PM
How can someone check if a built-in mod is s-modded? Apparently these don't count as Smod
of course i find the method after posting

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 14, 2023, 08:07:52 AM
Question - there are some older mods that I still like to use so I modify them myself. One of the thing I did was alter the hullmods for the new S-mod thing.

I edited both the java files of hullmods to the add the if (sMod) branch and the hullmods.cvs to add the SModDesc descriptions, but in-game no S-mod description show up, nor even the S-mod ui category. Am I missing something?

Hmm, nothing else comes to mind. Make sure the hullmod class is extending BaseHullMod - though if it wasn't, I think you'd have noticed due to other problems, so that's probably not it.

... are you testing this in the main menu? S-mod stuff only shows up in the campaign.

Fixed it.
I named the column SModDesc instead of sModDesc. Now it works! Thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 14, 2023, 01:34:24 PM
Is there any easy way to override one function from one of the mods?
Namely i want to mess with progress on Engineering Hub from Industrial Evolution
I've already found the function in the java file tried messing with it by adding it as part of separate mod to override it, but i have failed....
Any advices?

The source is probably compiled into class files (in a jar) and the .java file is likely provided by the mod just for reference, so changing it wouldn't do anything. Basically: if you're not comfortable setting up a dev environment and compiling stuff, this is going to be tricky.

I want to rebalance economy in my playthrough but found that I cannot change ship prices in those Bar events in bar_events.csv:
Code
bar event id,tags,freq,prob,min dur,max dur,min timeout,max timeout,min accepted timeout,max accepted timeout,plugin
hmdf,,10,1,30,40,15,20,60,90,com.fs.starfarer.api.impl.campaign.missions.HandMeDownFreighter
sShip,,10,1,30,40,15,20,60,90,com.fs.starfarer.api.impl.campaign.missions.SurplusShipHull
hijack,,10,1,30,40,15,20,60,90,com.fs.starfarer.api.impl.campaign.missions.HijackingMission

Is it possible to adjust those prices?


Each of these classes has a BASE_PRICE_MULT static member variable that you could adjust in your ModPlugin's onApplicationLoad() method.

Fixed it.
I named the column SModDesc instead of sModDesc. Now it works! Thanks

Ah, that would do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stokes52 on October 15, 2023, 07:31:12 PM
Hello, I am trying to make a simple mod to faction military markets.

Specifically, I would like to add Diktat Lion Guard variant ships to Diktat Military markets.  Even better, if I can gate certain ships behind reputation. The idea is to make it exactly like buying XIV variants from the Hegemony from their military markets if you have enough reputation.

I have already figured out how to make it so that LG variants appear in general Diktat faction markets, but I want to make it so that the LG variants are ONLY sold in the military market (to the most loyal Diktat servants), not the general market.

How can I go about doing this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 16, 2023, 09:46:44 AM
It's not going to work *exactly* like it does for the Hegemony because the XIV ships are part of the standard Hegemony fleet and the military submarket automatically works off that.

For what you want, you could either implement your own version of the submarket plugin (and create a different submarket for it, and swap it in instead of the standard military one for the colonies you want). Or you could implement a SubmarketUpdateListener and do the work there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 16, 2023, 05:25:23 PM
Where do you set SubmarketUpdateListeners to listen? Was looking at that yesterday and didn't find it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stokes52 on October 17, 2023, 04:39:00 AM
It's not going to work *exactly* like it does for the Hegemony because the XIV ships are part of the standard Hegemony fleet and the military submarket automatically works off that.

For what you want, you could either implement your own version of the submarket plugin (and create a different submarket for it, and swap it in instead of the standard military one for the colonies you want). Or you could implement a SubmarketUpdateListener and do the work there.

Thanks for the response.

So if I just added the Lion Guard ships to the normal Diktat fleets, would it behave the same as the XIV fleets? I notice for the XIV variants, they are typically found in good condition in the military market, locked behind rep, or more rarely you can find heavily d modded versions in the civilian market. Is that how it will work if I just add LG ships to the Diktat fleets?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on October 17, 2023, 05:18:20 AM
Is there any way to influence the distance from its target at which a fleet does the "ORBIT_AGGRESSIVE" or "DEFEND_LOCATION" Fleet Assignment?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ShadowWraith on October 17, 2023, 02:04:00 PM
Is there a way to add factions that are part of a mod during an existing save without having to start a new game. One example being LOST SECTOR, that might not add everything during an existing playthrough but it does add the new faction that's part of the mod if you add the mod to an existing game?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 17, 2023, 04:36:37 PM
Where do you set SubmarketUpdateListeners to listen? Was looking at that yesterday and didn't find it.

Global.getSector().getListenerManager().addListener() or something very similar. *Most* listeners (except for some older ones) go there. One way to check is look at the ListenerUtil class which has the code that invokes all the listeners, so you can see if it's grabbing stuff from ListenerManager (and if not, it's probably not present in ListenerUtil and is therefore an older/more specialized listener).


So if I just added the Lion Guard ships to the normal Diktat fleets, would it behave the same as the XIV fleets? I notice for the XIV variants, they are typically found in good condition in the military market, locked behind rep, or more rarely you can find heavily d modded versions in the civilian market. Is that how it will work if I just add LG ships to the Diktat fleets?

It should work the same way, yes.


Is there any way to influence the distance from its target at which a fleet does the "ORBIT_AGGRESSIVE" or "DEFEND_LOCATION" Fleet Assignment?

Checking - ORBIT_AGGRESSIVE, no. DEFEND_LOCATION: you can set MemFlags.FLEET_PATROL_DISTANCE in the fleet's memory.

Is there a way to add factions that are part of a mod during an existing save without having to start a new game. One example being LOST SECTOR, that might not add everything during an existing playthrough but it does add the new faction that's part of the mod if you add the mod to an existing game?

That's mostly up to the mod to support or not; probably too involved for someone to just do without a pretty good understanding of how that specific mod works.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on October 18, 2023, 06:53:27 AM
Is it possible to get the base module of a module in the refit screen?

The ShipAPI has getParentStation but for ShipVariantAPI it doesn't have that. I have data that needs a uniqueID to save and use to reference stuff but since modules generate a fake fleetmember I couldn't really use that and the next best thing was using the base module fleetmember to have a reference to its modules. any work around or solutions for this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 18, 2023, 09:58:49 AM
How would one go about/where should one look into API docs-wise for  the following task?

I've been fiddling a world script for a custom star system but I wanted to try and trigger the automated Market Conditions generator before adding my own ones and removing the ones I don't want for more variation. So for instance:
Code: java
PlanetAPI planet = system.addPlanet(blah);
//trigger Market Conditions autogenerator here
//if(planet.getMarket.<condition> is present) planet.getMarket().removeCondition(<condition>)
//repeat preceding line for all conditions that I want removed from planet
planet.getMarket().addCondition(<condition>);
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on October 19, 2023, 12:16:48 PM
Is there a way, aside from changing a missile's velocity, to minimize the "sway" of a homing missile? They tend to travel in a snaking s pattern to their target rather than constantly keep their nose pointed. I know some missiles like the Squall will pre-aim then travel in a straight line, but they don't exhibit homing ability aside from that initial sequence.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 19, 2023, 12:56:30 PM
Is it possible to get the base module of a module in the refit screen?

The ShipAPI has getParentStation but for ShipVariantAPI it doesn't have that. I have data that needs a uniqueID to save and use to reference stuff but since modules generate a fake fleetmember I couldn't really use that and the next best thing was using the base module fleetmember to have a reference to its modules. any work around or solutions for this?

Hmm, I don't think so. I'm not even sure what "base module of a module" means, modules don't have a base module - all of the modules belong to a single parent, the ship. Regardless, though, hmm - I think you might want to store that data in Global.getSectorAPI().getPersistentData() or some such - probably with a wrapping class that has all the things you need in it etc.


How would one go about/where should one look into API docs-wise for  the following task?

I've been fiddling a world script for a custom star system but I wanted to try and trigger the automated Market Conditions generator before adding my own ones and removing the ones I don't want for more variation. So for instance:

See the PlanetConditionGenerator class!


Is there a way, aside from changing a missile's velocity, to minimize the "sway" of a homing missile? They tend to travel in a snaking s pattern to their target rather than constantly keep their nose pointed. I know some missiles like the Squall will pre-aim then travel in a straight line, but they don't exhibit homing ability aside from that initial sequence.

You can add the DIRECT_AIM hint to weapon_data.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 20, 2023, 11:53:11 AM
See the PlanetConditionGenerator class!
I have probably done a major goof somewhere; trying to do the market condition finagling (autogenerating, then immediately going in and removing the conditions I don't want + adding the one(s) I want) in the normal custom system script generate method is NOT going well (concurrent modification exception).

Am I missing something the API docs don't tell? Should I be doing a wait()? I've never dealt with concurrent modification exceptions before so I'm pretty much out of my depth here apart from thinking "this is probably multithreading-related".

Tangentially to this; how does one get a system's planets' nascent gravity wells to show up?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on October 21, 2023, 02:41:04 AM
Am I missing something the API docs don't tell? Should I be doing a wait()? I've never dealt with concurrent modification exceptions before so I'm pretty much out of my depth here apart from thinking "this is probably multithreading-related".

are you removing the conditions while iterating over the list?
the game does (basically) no multithreading after launch, so that's the only way to cause a concurrentModificationException

you can get around it by either getting the list's iterator and removing from there, or just making a new list (like so : new arrayList<>(oldList)) and iterating over that one while removing from the original.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 21, 2023, 06:07:03 AM
I'm trying to make a pirate fleet not avoid contact with a superior player fleet on campaign map (while pirates faction is hostile to player). MEMORY_KEY_AVOID_PLAYER_SLOWLY and MEMORY_KEY_MAKE_NON_HOSTILE didn't seem to do the job. Is there something else I should try?

Relatedly, I should ask: In current (and previous) versions of the game, nearby NPC fleets will move away to 'give the player some space', which causes undesired behavior when player unintentionally or intentionally pushes around a fleet that's supposed to hold position somewhere or that's trying to travel someplace. Is this still a thing in dev version?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 21, 2023, 09:44:13 AM
Am I missing something the API docs don't tell? Should I be doing a wait()? I've never dealt with concurrent modification exceptions before so I'm pretty much out of my depth here apart from thinking "this is probably multithreading-related".

are you removing the conditions while iterating over the list?
the game does (basically) no multithreading after launch, so that's the only way to cause a concurrentModificationException

you can get around it by either getting the list's iterator and removing from there, or just making a new list (like so : new arrayList<>(oldList)) and iterating over that one while removing from the original.
Ooooh, yeah, I am doing that. Gonna have a go at what you suggested, ty!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on October 21, 2023, 11:59:04 AM
While looking at how certain text is set in the game, I saw that most (all?) instances of "story points" have the "story" word set by Misc.STORY, leading to the following in Misc.java:

Code
/**
* Name of "story points".
*/
public static String STORY = "story";
This seems to allow their name to be easily changed across the game. I tried my hand at changing them with a small mod and the following:
Spoiler
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global.*;
import com.fs.starfarer.api.impl.campaign.ids.Strings.*;

public class StorypointMod extends BaseModPlugin {

    @Override
public void onApplicationLoad() {   

String STORY = "placeholder";


    }


}
[close]

-but I am not seeing a change (although it's not crashing). My java knowledge is next to zero so I am most certainly messing up - or I'm not understanding when this is being loaded. Thank you if you can help.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AtlanticAccent on October 21, 2023, 03:11:39 PM
While looking at how certain text is set in the game, I saw that most (all?) instances of "story points" have the "story" word set by Misc.STORY, leading to the following in Misc.java:

Code
/**
* Name of "story points".
*/
public static String STORY = "story";
This seems to allow their name to be easily changed across the game. I tried my hand at changing them with a small mod and the following:
Spoiler
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global.*;
import com.fs.starfarer.api.impl.campaign.ids.Strings.*;

public class StorypointMod extends BaseModPlugin {

    @Override
public void onApplicationLoad() {   

String STORY = "placeholder";


    }


}
[close]

-but I am not seeing a change (although it's not crashing). My java knowledge is next to zero so I am most certainly messing up - or I'm not understanding when this is being loaded. Thank you if you can help.

You're just setting a local variable (essentially a holder for data that you can operate on or reference later) here. This doesn't change anything about the values in the game itself. To do so, you must reference the value and alter it, like so:

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.util.Misc;

public class StorypointMod extends BaseModPlugin {
    @Override
    public void onApplicationLoad() {   
Misc.STORY = "placeholder";
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 21, 2023, 03:58:44 PM
I'm trying to make a pirate fleet not avoid contact with a superior player fleet on campaign map (while pirates faction is hostile to player). MEMORY_KEY_AVOID_PLAYER_SLOWLY and MEMORY_KEY_MAKE_NON_HOSTILE didn't seem to do the job. Is there something else I should try?

I think what you want is MemFlags.MEMORY_KEY_MAKE_AGGRESSIVE, that's the "standard" way of accomplishing this.

Relatedly, I should ask: In current (and previous) versions of the game, nearby NPC fleets will move away to 'give the player some space', which causes undesired behavior when player unintentionally or intentionally pushes around a fleet that's supposed to hold position somewhere or that's trying to travel someplace. Is this still a thing in dev version?

... they do? The only thing that comes to mind that may fit the bill is a bunch of fleets orbiting the same entity will try to de-clump by adjusting orbital periods. But that doesn't sound like what you're talking about, hmm.

Especially with regard to traveling fleets or fleets told to hold a position, nothing comes to mind that would match what you're describing. In fact just recently I was working on something that required multiple fleets to hold position next to each other (for an NPC-NPC "inspection") and that worked fine, without being affected by player proximity.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 21, 2023, 06:31:54 PM
Relatedly, I should ask: In current (and previous) versions of the game, nearby NPC fleets will move away to 'give the player some space', which causes undesired behavior when player unintentionally or intentionally pushes around a fleet that's supposed to hold position somewhere or that's trying to travel someplace. Is this still a thing in dev version?

... they do? The only thing that comes to mind that may fit the bill is a bunch of fleets orbiting the same entity will try to de-clump by adjusting orbital periods. But that doesn't sound like what you're talking about, hmm.

You haven't seen that? NPC fleets try to avoid overlapping the player's fleet, interfering with whatever they are currently doing. IDK if there are any exploits from it, but it is always weird to me as a player and a little annoying from the modder side like with Hold Position as Hist mentions.

EDIT: and regarding hold position, it is annoying how bad the AI is at moving to an orbiting point to hold position on it. It misses and circles back repeatedly. For example, if I want the NPC fleet to "mine" at a spot. Orbiting the spot just isn't the same :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on October 21, 2023, 07:20:18 PM
Took a couple of .gifs showing the issue. (https://imgur.com/a/RhVaROw)

Thanks for mentioning the aggressive flag, I'll try that!
EDIT: Huh, now non-hostile works even without aggressive, did I just not set it right the first time?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 21, 2023, 07:45:13 PM
Ahh, ok, I see what you mean - overlapping, right. I think that just doesn't happen super often when I'm playing, hm. Or I'm just conditioned to not notice it. Weird, but, ok, I see the code - it's... super old. But seems fine in the general case, and applies to more than just the player, but other fleets as well. Let me add a MemFlags.DO_NOT_TRY_TO_AVOID_NEARBY_FLEETS you can set to turn off this behavior.

(And, checking what I did recently for the NPC-NPC inspections - it's just overriding the action text and using fleet.setMoveDestinationOverride() to get around all of this entirely.)

EDIT: and regarding hold position, it is annoying how bad the AI is at moving to an orbiting point to hold position on it. It misses and circles back repeatedly. For example, if I want the NPC fleet to "mine" at a spot. Orbiting the spot just isn't the same :(

The thing to do here would be to orbit the same focus as the orbiting point, with the same period, once you get within a certain (very close) distance of it, no?


Took a couple of .gifs showing the issue. (https://imgur.com/a/RhVaROw)

Oof, thank you! Let me also auto-turn-this-off when the fleet is holding/standing down; done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on October 21, 2023, 08:55:46 PM
I'm making a custom AI admiral and I've run into a couple issues.

1. How do I directly tell a ship to fulfill an assignment? None of the arguments for createAssignment(assignment, target, useCommandPoint) allow me to specify which ships are actually going to fulfill this assignment, instead leaving it to the AI to determine that on its own. Sometimes I'd like to assign specific ships to do a specific function. For example to create a wolfpack of specific hulls that form up on a leader, and then the leader goes to a waypoint.

2. I can't figure out how to get the API to give me a list of assignments and what object they're attached to. (ie, defend order attached to an objective, or engage order attached to a ship).
I've made a workaround for this second one, but just in case someone knows, I'd like to use an API solution if possible instead of my own janky one.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Helldiver on October 22, 2023, 12:09:25 AM
You're just setting a local variable (essentially a holder for data that you can operate on or reference later) here. This doesn't change anything about the values in the game itself. To do so, you must reference the value and alter it, like so:

Spoiler
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.util.Misc;

public class StorypointMod extends BaseModPlugin {
    @Override
    public void onApplicationLoad() {   
Misc.STORY = "placeholder";
    }
}
[close]

Thank you so much. I really need to start learning this stuff instead of winging it with reused code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 22, 2023, 06:00:08 AM
EDIT: and regarding hold position, it is annoying how bad the AI is at moving to an orbiting point to hold position on it. It misses and circles back repeatedly. For example, if I want the NPC fleet to "mine" at a spot. Orbiting the spot just isn't the same :(

The thing to do here would be to orbit the same focus as the orbiting point, with the same period, once you get within a certain (very close) distance of it, no?

I have had trouble setting fleets to orbit, but do not remember the specifics atm. Maybe I just wasn't doing it right.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vitmainlem on October 22, 2023, 11:29:20 AM
Is there a way to apply beam effect like tachyon lance with pierceSet like this:
"pierceSet": [
  PROJECTILE_FF,
  PROJECTILE_NO_FF,
  PROJECTILE_FIGHTER,
  MISSILE_FF,
  MISSILE_NO_FF,
  FIGHTER,
  SHIP,
  ASTEROID
  ],
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: betcher on October 22, 2023, 05:33:57 PM
Anyone know where to go to modify how long planets wont let you interact with them if you fought in the area around them? Had some mercs try to kill me and suddenly I couldnt turn in a prisoner. I didnt have my identification on so it shouldnt have mattered by 72 days later when it expired I still couldnt go in. I want to atleast halve the calculation they have for it. I killed 2 fleets without ID that shouldnt make me lose out on a planet for months
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 23, 2023, 04:21:07 PM
I'm making a custom AI admiral and I've run into a couple issues.

1. How do I directly tell a ship to fulfill an assignment? None of the arguments for createAssignment(assignment, target, useCommandPoint) allow me to specify which ships are actually going to fulfill this assignment, instead leaving it to the AI to determine that on its own. Sometimes I'd like to assign specific ships to do a specific function. For example to create a wolfpack of specific hulls that form up on a leader, and then the leader goes to a waypoint.

2. I can't figure out how to get the API to give me a list of assignments and what object they're attached to. (ie, defend order attached to an objective, or engage order attached to a ship).
I've made a workaround for this second one, but just in case someone knows, I'd like to use an API solution if possible instead of my own janky one.

You can use giveAssignment() and getAllAssignments().


I have had trouble setting fleets to orbit, but do not remember the specifics atm. Maybe I just wasn't doing it right.

Ah, hmm - yeah, possibly could be troublesome if some bit of core code keeps overriding it or some such.

Is there a way to apply beam effect like tachyon lance with pierceSet like this:
"pierceSet": [
  PROJECTILE_FF,
  PROJECTILE_NO_FF,
  PROJECTILE_FIGHTER,
  MISSILE_FF,
  MISSILE_NO_FF,
  FIGHTER,
  SHIP,
  ASTEROID
  ],

Yes? I'm not understanding the question - what's the actual problem here?


Anyone know where to go to modify how long planets wont let you interact with them if you fought in the area around them? Had some mercs try to kill me and suddenly I couldnt turn in a prisoner. I didnt have my identification on so it shouldnt have mattered by 72 days later when it expired I still couldnt go in. I want to atleast halve the calculation they have for it. I killed 2 fleets without ID that shouldnt make me lose out on a planet for months

You could modify MarketCMD.HOSTILE_ACTIONS_TIMEOUT_DAYS in a ModPlugin.onApplicationLoad() in your mod.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: betcher on October 23, 2023, 05:27:49 PM
Anyone know where to go to modify how long planets wont let you interact with them if you fought in the area around them? Had some mercs try to kill me and suddenly I couldnt turn in a prisoner. I didnt have my identification on so it shouldnt have mattered by 72 days later when it expired I still couldnt go in. I want to atleast halve the calculation they have for it. I killed 2 fleets without ID that shouldnt make me lose out on a planet for months

You could modify MarketCMD.HOSTILE_ACTIONS_TIMEOUT_DAYS in a ModPlugin.onApplicationLoad() in your mod.
Thanks I had no idea where to even start, all the things I opened had no variables and I ran out of folders. My usual program couldnt search anything at all and opening things in notepad made things act weird unless they were straight numbers. Ended up finding 4 options so its just a matter of playing with them until I get the desired result. It happened again earlier today, 3 months for a minor conflict they started and only 1 fight
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Vitmainlem on October 24, 2023, 07:37:55 AM
Is there a way to apply beam effect like tachyon lance with pierceSet like this:
"pierceSet": [
  PROJECTILE_FF,
  PROJECTILE_NO_FF,
  PROJECTILE_FIGHTER,
  MISSILE_FF,
  MISSILE_NO_FF,
  FIGHTER,
  SHIP,
  ASTEROID
  ],

Yes? I'm not understanding the question - what's the actual problem here?


-----So the I make a beam that pierce everything, which makes beam not hitting anything and that causing problem to apply beam effect like tachyon lance effect. Are there Any solution for this?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on October 24, 2023, 07:14:56 PM
You can use ... getAllAssignments().
Yes, I'm using this. But it only gives me the location of the assignment, not what it's attached to. I have to manually iterate over every battlefield object to find what ship or objective or whatever is at that location. Because AssignmentTargetAPI only has location, velocity and owner. It doesn't have the target object.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on October 24, 2023, 07:29:07 PM
You can use ... getAllAssignments().
Yes, I'm using this. But it only gives me the location of the assignment, not what it's attached to. I have to manually iterate over every battlefield object to find what ship or objective or whatever is at that location. Because AssignmentTargetAPI only has location, velocity and owner. It doesn't actually have the target object.

It is the target, but you need to cast it to the correct type to determine what it is. See what extends AssignmentTargetAPI. For example, ship targets are DeployedFleetMemberAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 26, 2023, 04:33:36 PM
-----So the I make a beam that pierce everything, which makes beam not hitting anything and that causing problem to apply beam effect like tachyon lance effect. Are there Any solution for this?

Ah, I see - yeah, the on-hit effect is not going to get called for anything that's pierced, so you'd have to script that separately somehow.

You can use ... getAllAssignments().
Yes, I'm using this. But it only gives me the location of the assignment, not what it's attached to. I have to manually iterate over every battlefield object to find what ship or objective or whatever is at that location. Because AssignmentTargetAPI only has location, velocity and owner. It doesn't actually have the target object.

It is the target, but you need to cast it to the correct type to determine what it is. See what extends AssignmentTargetAPI. For example, ship targets are DeployedFleetMemberAPI.

And for battle objectives, you can check then cast it to BattleObjectiveAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 28, 2023, 08:19:11 AM
Best way to implement a tractor beam effect?

Negative impact value for a weapon doesn't do anything. Changing targets speed temporarily on weapon impact? Direct application of force? If so, is there an existing method for it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 28, 2023, 03:51:11 PM
Best way to implement a tractor beam effect?

Negative impact value for a weapon doesn't do anything. Changing targets speed temporarily on weapon impact? Direct application of force? If so, is there an existing method for it?

Probably modifying the velocities of the involved entities directly. The physics-math for this is simple (F = ma and so on, which can of course be simplified if one doesn't care about mass etc), though getting it to feel good would likely take a bunch of experimentation.

You could also have a large positive impact value - iirc for a beam this will cause the target to slow down quite a bit. The impact value is ignored for non-beams.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on October 29, 2023, 06:52:17 AM
Wouldn't a high impact value PUSH away the target?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 29, 2023, 11:42:00 AM
I don't remember how it works, but I wouldn't read too much into the name of a spreadsheet column for a feature that never really panned out and isn't exactly "supported" beyond the edge case of the graviton beam. Judging from what the graviton beam does to fighters and missiles, the answer is "no" :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on October 29, 2023, 11:42:27 AM
Hello all. I was hoping someone could help me in hiding the commodities available for my mod Hiver Swarm. It is my most requested fix and I have tried several ways but I cannot seem to figure it out. They always have the best prices so they fill the top of the lists but they are hostile to all so the player cannot trade with them. Essentially what I would like is when someone either looks up the best buy/sell with F1 or open the tab that commodities from the Hiver faction are not shown.

Any help would be appreciated, thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 29, 2023, 11:59:59 AM
You have a few options, at least for the F1 cargo tooltip that shows best places to buy/sell:

1) Remove the Submarkets.SUBMARKET_OPEN submarket from your colonies.

2) market.setEconGroup(<some string>). This will place your markets in a separate sub-economy, so may have undesired effects as e.g. they will not be able to satisfy demand from the core economy.

3) market.setHidden(true). This will hide the colony in some other ways, iirc, such as not having trade fleets from or to it, being targeted for certain missions, etc.

Either one of the three should do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dazs on October 29, 2023, 12:16:15 PM
You have a few options, at least for the F1 cargo tooltip that shows best places to buy/sell:
First off thank you for getting back to me so fast.
1) Remove the Submarkets.SUBMARKET_OPEN submarket from your colonies.
I do not believe I have that string anywhere in my mod. I coded it over a year ago so what file would that be in so I can double check.
2) market.setEconGroup(<some string>). This will place your markets in a separate sub-economy, so may have undesired effects as e.g. they will not be able to satisfy demand from the core economy.
I did try that one before and it had too many negative effects to their economy.
3) market.setHidden(true). This will hide the colony in some other ways, iirc, such as not having trade fleets from or to it, being targeted for certain missions, etc.
Either one of the three should do it.
I believe I tried this one as well and if memory serves it had the unintended consequence of having their internal trade fleets not trade with each other which gutted their ability to form fleets. Of course as above, I did this months ago and maybe I am thinking of something else I tried. What file would I add that line to as I may have put it in an incorrect location.

Sorry for being a pest, I am not very experienced in Java and self-taught so there are gaps for sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on October 29, 2023, 12:55:17 PM
You could also have a large positive impact value - iirc for a beam this will cause the target to slow down quite a bit. The impact value is ignored for non-beams.
How much would this turn fighters into the ultimate spin-your-flesh-off machines? I know graviton beams do a slight number on fighters but I'm wondering how ridiculous it can feasibly get with much larger values.

Related, how would one go about making a beam that has momentum to it? Before that, is it even possible to alter the momentum vector (accurate term to describe what's happening but not necessarily the way things are implemented) with a projectile impact or such?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 29, 2023, 01:47:16 PM
First off thank you for getting back to me so fast.
1) Remove the Submarkets.SUBMARKET_OPEN submarket from your colonies.
I do not believe I have that string anywhere in my mod. I coded it over a year ago so what file would that be in so I can double check.

A market gets that by default if it's loaded from an economy config file, iirc. So you'd just need to manually remove these from your markets, via MarketAPI.removeSubmarket().

2) market.setEconGroup(<some string>). This will place your markets in a separate sub-economy, so may have undesired effects as e.g. they will not be able to satisfy demand from the core economy.
I did try that one before and it had too many negative effects to their economy.

Yeah, if you went that way, you'd need to fudge the economy. For example pirate bases in vanilla (PirateBaseIntel) are hidden, and they basically fill their supply needs with some code.

Sorry for being a pest, I am not very experienced in Java and self-taught so there are gaps for sure.

All good!


Related, how would one go about making a beam that has momentum to it? Before that, is it even possible to alter the momentum vector (accurate term to describe what's happening but not necessarily the way things are implemented) with a projectile impact or such?

You can modify the velocity of things with an on-hit effect.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kosmo on October 30, 2023, 07:07:46 AM
Hi, I'm trying to replicate Red Alert 2's chrono legionnaire weapon effect.
The weapon basically time freezes the enemy while making them invulnerable, after some time has passed (base on hull sizes), they vanished (leaving no hulks behind) and is considered destroyed.

I want to know how can I make a ship cleanly disappear ?

The closest thing I got is setHitpoints(0) from ShipAPI, this does make the ship vanish in thin air (or space) but the ship destroyed this way somehow isn't considered dead and still exist in the Deployment window, preventing deployment of more ships.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on October 31, 2023, 10:00:29 AM
Hmm. Maybe there's a cleaner way, I'd I'd suggest moving the ship somewhere *way* off-map and applying a bunch of damage to it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on October 31, 2023, 12:05:19 PM
Is there a rules.csv condition, similar to $faction.rel == FRIENDLY, that works on persons? I want to add unique greetings to a character based on player's relations with them.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on November 01, 2023, 08:51:16 PM
How can I check whether a ship's system is disabled or not? When ship.setShipSystemDisabled(true) or system isUsable(ShipSystemAPI system, ShipAPI ship) { return false }.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 02, 2023, 10:35:09 AM
Is there a rules.csv condition, similar to $faction.rel == FRIENDLY, that works on persons? I want to add unique greetings to a character based on player's relations with them.

Kind of oddly, $rel in the person context is a number from -1 to 1 rather than a name like FRIENDLY, so you could us that with the right threshold values. Or you could add your own command (see: RepIsAtBest for an example of how that might work). Or you might add a CampaignPlugin that, in its updatePersonFacts() method, sets a variable fo the rel name. I've just added $relName to the vanilla implementation for the future.



How can I check whether a ship's system is disabled or not? When ship.setShipSystemDisabled(true) or system isUsable(ShipSystemAPI system, ShipAPI ship) { return false }.

Let me add isShipSystemDisabled() to ShipAPI, I don't think there's a way to check for this directly right now. Though the only reason this would happen in vanilla is if the ship's CR dropped to zero, so you might check for that instead. In addition to checking whether the system is usable, I mean.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 02, 2023, 01:14:44 PM
What do the DamagingProjectileAPI.addDamagedAlready(CombatEntityAPI c) and removeDamagedAlready methods do? I'm reading the code for PaladinEffect but I'm a bit unclear on their purpose.

Also an extra question, when the player meets a fleet, I can pull the other fleet's CampaignFleetAPI wtih dialog.getInteractionTarget(). But how would I gain the CampaignFleetAPI of the other two fleets in a three way fight where the player can ally with one side? Is it possible to do this on the dialog window or can it only happen once battle starts?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mule_Modder on November 02, 2023, 01:20:41 PM
1. Is there a way to hook into a ShipDestroyed Event? I'd like to run logic when a ship is destroyed.
2. What would I use for persistent Data (first for playthrough and second for one combat session)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on November 02, 2023, 01:21:09 PM
In addition to checking whether the system is usable, I mean.

How would I check whether the system is usable? There doesn't seem to be any form of like "if ship.getsystem.isusable".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: kosmo on November 02, 2023, 07:47:10 PM
1. Is there a way to hook into a ShipDestroyed Event? I'd like to run logic when a ship is destroyed.

I would suggest look into Tesseract's shard spwaner hullmod that triggers when ship is destoryed. If you don't want to make it a hullmod you can use every frame combat plugin.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mule_Modder on November 03, 2023, 12:54:40 AM
Thanks. I did and while the logic there is only for the tesseract itself I now have a new place too look (the CombatEngineAPI).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoki on November 03, 2023, 05:53:33 AM
hello all

first post, so be gentle pls

how would i go about modifying market F1 screen? i see tutorials that add stuff (planets, ships, ...) but none that actually modifies game built in features.

The idea is to add another column to the market F1 info screen that would display the factions standing with me, so that i don't waste time going for a trade and then realize that the faction doesn't like me...

just throw some API calls here, and i'll do the digging myself

thanks

edit: i'll download some larger mods and unpack JARs, and try to figure it out. i just haven't found the time yet. but if someone can point me in the right direction, that'd be great
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on November 07, 2023, 10:42:19 AM
Is there any way to make market non raidable (Someone asked me this question and i also started to wonder if its possible to block raids from happening via inudstry)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 07, 2023, 12:20:52 PM
(Sorry for letting this go for a bit; was sick for a few days there.)

What do the DamagingProjectileAPI.addDamagedAlready(CombatEntityAPI c) and removeDamagedAlready methods do? I'm reading the code for PaladinEffect but I'm a bit unclear on their purpose.

It's for managing things so that the same AoE won't hit the same target multiple times or e.g. the AoE of a torpedo doesn't hit the target the torpedo itself already hit, etc.

Also an extra question, when the player meets a fleet, I can pull the other fleet's CampaignFleetAPI wtih dialog.getInteractionTarget(). But how would I gain the CampaignFleetAPI of the other two fleets in a three way fight where the player can ally with one side? Is it possible to do this on the dialog window or can it only happen once battle starts?

Hmm - depending on where you're doing this from, fleet.getBattle() would let you look at both sides of the engagement.


2. What would I use for persistent Data (first for playthrough and second for one combat session)

Need more specifics, and what you mean by persistent, you could do this in many ways. For combat, you probably want to store an object with your data in CombatEngineAPI.getCustomData().


How would I check whether the system is usable? There doesn't seem to be any form of like "if ship.getsystem.isusable".

See: ShipSystemStatsScriptAdvanced.isUsable()

Though that only covers special cases, not baseline things like "enough charges and flux and not on cooldown and ship is not venting/overloaded" and so on. I don't think there's any centralized method for checking this, actually.


hello all

first post, so be gentle pls

how would i go about modifying market F1 screen? i see tutorials that add stuff (planets, ships, ...) but none that actually modifies game built in features.

The idea is to add another column to the market F1 info screen that would display the factions standing with me, so that i don't waste time going for a trade and then realize that the faction doesn't like me...

just throw some API calls here, and i'll do the digging myself

thanks

edit: i'll download some larger mods and unpack JARs, and try to figure it out. i just haven't found the time yet. but if someone can point me in the right direction, that'd be great

Hi! This would actually be quite complicated to do; the API does not support this sort of thing directly.

Is there any way to make market non raidable (Someone asked me this question and i also started to wonder if its possible to block raids from happening via inudstry)

Hmm. You could boost the ground defenses *a lot*, maybe? Or you might add rules to rules.csv that would override the normal rules that fire in this case; that would require a fairly good understanding of how that's set up but seems doable to me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 07, 2023, 08:34:29 PM
DEM weapons seem to always have the doubled amount of damage of what they do per second in the actual weapon that fires the missile, which then fires the payload. Is there any reason for this, as the damage seems to depend on whats set in the payload anyways?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 08, 2023, 11:47:45 AM
DEM weapons seem to always have the doubled amount of damage of what they do per second in the actual weapon that fires the missile, which then fires the payload. Is there any reason for this, as the damage seems to depend on whats set in the payload anyways?

Just how the math works out in those particular cases, due to beam fade-in and fade-out. Damage scales quadratically with beam brightness, so the overall DPS during fade/in out is one third of the listed beam DPS. E.G. if your beam fades in instantly, fires for 0.25 seconds, and fades out for 0.75 seconds, it's equivalent to 0.5 seconds of firing at full power. So if your desired damage output is 1000, your DPS would need to be 2000. This sort of thing.

(Noting, of course, that beam damage is approximate because of being dealt in discrete ticks about 10x per second.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Crimson Spirit on November 08, 2023, 11:58:22 AM
This isn't really a modding question that is too minor to warrant its own thread

I just wanted to take a bit of time (and space -teehee) to thank you Alex (and the rest of the community) for the making and devotion you have for this masterpiece, it's truly inspiring

GO SPACE NERDS!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 08, 2023, 02:39:16 PM
<3
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 08, 2023, 05:18:00 PM
Are [faction] Strike Fleets and Large Strike Fleets a feature of the core game? And if they are is there a way to make them spawn without d-mods? Never mind they are exerelinInvasionSupportFleets

Is there a way to selectively not show the s-mod text of a hullmod via scripting in the hullmod file?

And how is the second line of tooltip text in structures that affect stability generated? I have a structure that adds a condition that adds stability, so the structure itself adds 0 stability, but I still want the tooltip to display the correct value. I can replicate the first line just fine, but for the second line \n isn't adding enough space between lines, and addPara is adding too much space. I also can't seem to get the padding to line up the text with other examples. Help would be appreciated.

Also I'm hoping you're feeling better now  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on November 09, 2023, 03:27:40 AM
Context: 
I tried to make horizontal scrollbar as i saw ScrollPanelAPI in TooltipMakerAPI have support of setting X offset and scrollbar itself is working but ...
To have a lot of space on x axis i made tooltip the size of 2400 while custom panel where is placed have 500 ( i made tooltip width 2400 not 500 as when i set XOffset to value like -600 , -700 it simply stops rendering content in tooltip)


Spoiler
(https://i.imgur.com/WlIWDy8.png)
[close]
Is there any way of rendering invisible mask that would block rendering tooltip , or i am forced to make fullscreen wide ui to "avoid" that mistake?
As i did not wanted horizontal scrollbar just to make UI width max 1.9 times larger ( not 2 due to having that few units as buffor so it wont stop rendering content)

Nevermind issue solved by moving every element inserted in tooltip manually instead of using xoffset
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mule_Modder on November 09, 2023, 05:36:25 AM
I use the OnFleetSync() method of a HullmodFleetEffect to add certain hullmods to ships.
> The hullmods get added and work like intended.

However: The first time after gameload / new game when I go to the refit screen the are not shown as hullmods. Only when I press the R key again they appear. It's a small problem but maybe there is a method to avoid that?

I suspect that opening the refit screen is the action that fires OnFleetSync in this case. Is there a method to force another update of the Refit Screen? I tried forceSync, but it did not update.


Another question: Is it possible to hook into the ship deployment picker? I'd like to influence deployment option (pre-battle) for the player / implement a custom autodeploy mechanic.
(I gave up on that for now)

Does anybody know a way to keep ships from deploying even in Escape Missions?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 10, 2023, 07:14:00 AM
Is it possible to somehow attach a module to another ship while already in combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 10, 2023, 11:08:34 PM
Also is there a way to hide a module from the fleet view & for the small fleet view in the campaign?. As in dont have it show up in the fleet screen at all. I have a module that essentialy exists to equip something in combat, so once you enter combat it despawns and only in refit its supposed to be visible on the side.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 11, 2023, 06:56:44 PM
Is there a way to selectively not show the s-mod text of a hullmod via scripting in the hullmod file?

Hmm - I'd imagine so? You need to override the addSModEffectSection() and/or addSModSection() methods in the effect class.

And how is the second line of tooltip text in structures that affect stability generated? I have a structure that adds a condition that adds stability, so the structure itself adds 0 stability, but I still want the tooltip to display the correct value. I can replicate the first line just fine, but for the second line \n isn't adding enough space between lines, and addPara is adding too much space. I also can't seem to get the padding to line up the text with other examples. Help would be appreciated.

TooltipMakerAPI.addSpacer() is the method you want, I think - it lets you add an arbitrary height (even negative!) vertical spacer.

Also I'm hoping you're feeling better now  :)

Getting there, thank you :)


Does anybody know a way to keep ships from deploying even in Escape Missions?

(Sorry, I don't.)


Is it possible to somehow attach a module to another ship while already in combat?

I... don't know? :) I'd suspect probably not but it's not something I've tried, so I don't know if the methods exposed by the API are sufficient or not.


Also is there a way to hide a module from the fleet view & for the small fleet view in the campaign?. As in dont have it show up in the fleet screen at all. I have a module that essentialy exists to equip something in combat, so once you enter combat it despawns and only in refit its supposed to be visible on the side.

Doesn't look like it. One hack to make it work might be to set that module's hull spec to a blank sprite while in the campaign, though it'd need to be that when the view is created, so e.g. if a fleet is already on screen, it wouldn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 12, 2023, 03:02:57 AM

Is it possible to somehow attach a module to another ship while already in combat?

I... don't know? :) I'd suspect probably not but it's not something I've tried, so I don't know if the methods exposed by the API are sufficient or not.


Also is there a way to hide a module from the fleet view & for the small fleet view in the campaign?. As in dont have it show up in the fleet screen at all. I have a module that essentialy exists to equip something in combat, so once you enter combat it despawns and only in refit its supposed to be visible on the side.

Doesn't look like it. One hack to make it work might be to set that module's hull spec to a blank sprite while in the campaign, though it'd need to be that when the view is created, so e.g. if a fleet is already on screen, it wouldn't work.

Thanks for the responses. Atleast for my first question i figured out that i can keep the modules attached to the ship and just despawn it from the engine & add it back to the engine when its supposed to appear, atleast i havent seen any major issues with this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on November 13, 2023, 01:15:33 PM
Hey Alex, I've tried using ShipSystemStatsScriptAdvanced.isUsable() to check whether systems are usable, but it seems like this doesn't do what I need. I want to check funny modded ship systems that have goofy activation criteria when writing my own AI, so I can factor in whether a particular ship's system is usable in the situation. (such as the old phase teleporter being only usable while the ship has 0-flux boost) When you add a getter to check whether the ship's system is disabled, can you also do one for this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 13, 2023, 02:43:56 PM
How do I obtain the base shield efficiency flux/dam value in ships.csv and the modified version shown on the fitting screen for a ship? The various get methods in getShieldDamageTakenMult() don't seem to be giving the right results.

Edit: I got it to work with ship.getShield().getFluxPerPointOfDamage() * ship.getMutableStats().getShieldDamageTakenMult().getModifiedValue().

Also how do I access the various parameters in hull_styles.json for a given styleId, for example LOW_TECH shieldInnerColor?

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 14, 2023, 10:10:00 AM
(such as the old phase teleporter being only usable while the ship has 0-flux boost) When you add a getter to check whether the ship's system is disabled, can you also do one for this?

That's actually the only condition that the game checks for in the canBeActivated() method, which I've just added to ShipSystemAPI.


Also how do I access the various parameters in hull_styles.json for a given styleId, for example LOW_TECH shieldInnerColor?

This looks like it's not exposed via the API at all; your only option would be to read the file yourself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 14, 2023, 06:42:01 PM
Is it intended behaviour that a hullmod that is set as "Hidden" and has an smod effect and is built in to a hull, wont be shown in the smod selector?
Anyway around this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 15, 2023, 06:56:02 AM
Is it intended behaviour that a hullmod that is set as "Hidden" and has an smod effect and is built in to a hull, wont be shown in the smod selector?
Anyway around this?

I did not find a way. Would be nice.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 15, 2023, 11:57:04 AM
It's intended behavior, yeah. It's not likely that this would actually change.

What's the issue with making the hullmod not-hidden? The main thing hidden *does* is "do not show this in the hullmod picker" so unless I'm missing something, this behavior sounds like the primary feature of the flag, working. *Am* I missing something?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Jage on November 15, 2023, 12:22:52 PM
Does anybody know why i cant put black outlines for my ship? im just wondering
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 15, 2023, 12:29:05 PM
The officerSkills in .faction determines which skills officers of that faction will pick, but is there a way to explicitly forbid a skill from being chosen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 15, 2023, 12:34:33 PM
The officerSkills in .faction determines which skills officers of that faction will pick, but is there a way to explicitly forbid a skill from being chosen?

Not through the faction file, I don't think. You'd have to adjust the hireable officers in a ColonyInteractionListener or some such.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 15, 2023, 01:20:31 PM
It's intended behavior, yeah. It's not likely that this would actually change.

What's the issue with making the hullmod not-hidden? The main thing hidden *does* is "do not show this in the hullmod picker" so unless I'm missing something, this behavior sounds like the primary feature of the flag, working. *Am* I missing something?

The issue is we only want these sort of hullmods to show up in a ship's built-ins and in the s-mod list. It might be possible to do this in some roundabout way atm, but I don't think so.

Really just need an exception for the S-mod list to show hidden hullmods that have an s-mod effect and are not hiddenEverywhere. Everything else is already good - e.g. s-modded built-ins can't be de-S-modded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 15, 2023, 03:29:25 PM
Hmm. Not necessarily the hardest change, but the code is just tricky enough (with various modes the dialog can be in, and the ability to undo changes) that I'd have to gin up a test case to make sure it worked right. I'll keep it in mind!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 16, 2023, 05:36:50 PM
It's intended behavior, yeah. It's not likely that this would actually change.

What's the issue with making the hullmod not-hidden? The main thing hidden *does* is "do not show this in the hullmod picker" so unless I'm missing something, this behavior sounds like the primary feature of the flag, working. *Am* I missing something?

Setting a hullmod to hidden is just the best way to avoid giving the player access to it outside of its intended purposes. Theres tags for preventing them from dropping or appearing, but ive seen those not always work (probably some mod conflicts). In this case i was talking specificly about a hullmod that would only be available as a built-in for a specific line of ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 16, 2023, 06:06:21 PM
Ah, I see, thank you for clarifying.

... if you (or someone else) can gin up a quick standalone mod for me to test this with I'll give it a go!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: touchofvanilla on November 18, 2023, 07:03:52 AM
I'm making a hullmod that reflects beams off of ships/modules with said hullmod, but I'm running into a few minor issues...

Is there a method to set the offset of a weapon? I'm using FX drones to 'reflect' the beams but the weapon offsets create a bit of a disjoint, and I'm not sure how to adjust them.

(https://cdn.discordapp.com/attachments/310517733458706442/1175438760826114079/image.png?ex=656b3ba7&is=6558c6a7&hm=c9b82b8924b4a0d88d86077d4eb9715cac4474cf8cd4738bb9e8dca379387c8b&)
A HIL, which has a sufficient offset to cause the disjoint.


Secondly, I'm running into an issue where specific 'reflected' beams will hit the armor plate that has the hullmod, but appear to hit the armor plate instead of travelling normally. Here's another screenshot... Is there a way to make friendly beams pass through the armor plate, similar to fighter beams passing through their host ship?

(https://cdn.discordapp.com/attachments/310517733458706442/1175435878307475478/image.png?ex=656b38f7&is=6558c3f7&hm=eacc0b29272dd2d92f3d2ea94de66407da8f960c32193ee0fef12c23ef5c773e&)
A Tachyon lance, which consistently has this issue
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bilbois on November 18, 2023, 07:24:25 AM
https://imgur.com/a/zQdwd5b

why this happen in my game??
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 18, 2023, 11:04:42 AM
Whoa, super cool!

Is there a method to set the offset of a weapon? I'm using FX drones to 'reflect' the beams but the weapon offsets create a bit of a disjoint, and I'm not sure how to adjust them.

WeaponAPI.ensureClonedSpec() to make a copy of the weapon spec, so that your changes don't affet ALL weapons of this type in the game. And then you can do:
WeaponAPI.getSpec(), which returns a WeaponSpecAPI. That has:
List<Vector2f> getHardpointFireOffsets();
List<Float> getHardpointAngleOffsets();
List<Vector2f> getTurretFireOffsets();
List<Float> getTurretAngleOffsets();
List<Vector2f> getHiddenFireOffsets();
List<Float> getHiddenAngleOffsets();

You can edit these lists. The fire offsets are pairs of coordinates, so each "fire offset" list would have twice the size of the related "angle offset" list.


Secondly, I'm running into an issue where specific 'reflected' beams will hit the armor plate that has the hullmod, but appear to hit the armor plate instead of travelling normally. Here's another screenshot... Is there a way to make friendly beams pass through the armor plate, similar to fighter beams passing through their host ship?

You could set the collision class on the beam to CollisionClass.RAY_FIGHTER. Or you could try to finagle the offset so that the beam spawns outside the plate.


https://imgur.com/a/zQdwd5b

why this happen in my game??

Hi - this isn't the thread for this; if you have a suspicion which mod is causing the issue, you can ask/report the issue in that mod's thread. If not, a post in the modded bug reports forum might be the way to go; someone might have seen this before and be able to point you in the right direction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 18, 2023, 07:21:11 PM
How can we adjust how much a hyperspace storm throws a fleet off-course?  I have checked Solar Shielding, but its in-game description "...also has the same effect against storms in deep hyperspace" and code stats.getDynamic().getStat(Stats.CORONA_EFFECT_MULT).modifyMult(id, mult); are not explicitly about being thrown off course.

I ask because I have the idea that the player could somehow reduce this amount, whether through having more and larger ships in the fleet, having multiple Drive Field Stabilizer ships, or s-modding Solar Shielding or Augmented Drive Field.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 19, 2023, 12:43:52 AM
Would there be a way to hide the presence of a faction in a system, as in, dont have their name show up on hover & change the icon?
Would like to have a factions market be hidden, as they are nomadic, but not excluded from the economy, with the logic being essentialy only trading partners knowing their locations at all times.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NeoLemon on November 19, 2023, 05:27:31 AM
there is few question here

1. Is there a way to make custom nebula system? one that without an anchor?

2. Is there a way to implement isolated MarketAPI into specific market? i want to make a hidden market still can import stuff

3. Is there a way to make market inside economy invisible to raid and saturation bombardment?

Thankyo
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: touchofvanilla on November 19, 2023, 12:37:02 PM
You could set the collision class on the beam to CollisionClass.RAY_FIGHTER. Or you could try to finagle the offset so that the beam spawns outside the plate.

Unfortunately, doing the offset doesn't solve the issue. I can't find any methods to dynamically change the Collison Class of a beam. Does one exist?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JlaXion on November 19, 2023, 12:55:00 PM
Hi everyone, I'm pretty new in the modding scene and I'm wondering why my game is crashing every time I launch it with my mod activated.

I am always greeted with a:

Fatal: Mismatched quotes in the string; last quote: [

I have repeatedly checked my various .wpn, .proj, and .ship files and have found no error regarding a missing bracket or parenthesis. Is anyone able to point me in the right direction?

Edit 1: Okay perhaps I missed something but I think I finally fixed it but now something else is popping up and I don't know what it means.

11119 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: JSONObject["name"] not found.
org.json.JSONException: JSONObject["name"] not found.
   at org.json.JSONObject.get(JSONObject.java:406)
   at org.json.JSONObject.getString(JSONObject.java:577)
   at com.fs.starfarer.loading.WeaponSpreadsheetLoader. 00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.public(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)

my game crashed and here is the log, I dont know what happened.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 20, 2023, 12:16:28 PM
How can we adjust how much a hyperspace storm throws a fleet off-course?  I have checked Solar Shielding, but its in-game description "...also has the same effect against storms in deep hyperspace" and code stats.getDynamic().getStat(Stats.CORONA_EFFECT_MULT).modifyMult(id, mult); are not explicitly about being thrown off course.

I ask because I have the idea that the player could somehow reduce this amount, whether through having more and larger ships in the fleet, having multiple Drive Field Stabilizer ships, or s-modding Solar Shielding or Augmented Drive Field.

Hmm, not easily. I think you'd have to detect when the fleet has a HyperStormBoost script, remove it, and replace it with your own version.


Would there be a way to hide the presence of a faction in a system, as in, dont have their name show up on hover & change the icon?
Would like to have a factions market be hidden, as they are nomadic, but not excluded from the economy, with the logic being essentialy only trading partners knowing their locations at all times.

Just setting the market to hidden *should* actually do it - looking at the tooltip code, it should skip over those. Unless we're talking about different things?

IIRC they'd still be in the economy, they just wouldn't get visible trade fleets going to/from. Not 100% sure on this.

A possible option is doing setHidden() only while the core UI is open.

You could set the collision class on the beam to CollisionClass.RAY_FIGHTER. Or you could try to finagle the offset so that the beam spawns outside the plate.

Unfortunately, doing the offset doesn't solve the issue. I can't find any methods to dynamically change the Collison Class of a beam. Does one exist?

I think you should be able to cast a BeamAPI to a CombatEntityAPI and use .setCollisionClass() on that.


there is few question here

1. Is there a way to make custom nebula system? one that without an anchor?

2. Is there a way to implement isolated MarketAPI into specific market? i want to make a hidden market still can import stuff

3. Is there a way to make market inside economy invisible to raid and saturation bombardment?

Thankyo

I'm sorry, could you be more specific with your questions? I don't really understand them; the actual details matter here. And since I don't remember everything about the codebase at all times, having more context is incredibly helpful - things you tried, that didn't work, why/in what way they didn't work.


11119 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - org.json.JSONException: JSONObject["name"] not found.
org.json.JSONException: JSONObject["name"] not found.

my game crashed and here is the log, I dont know what happened.

This means that the game is looking for a field called "name" in a file and not finding it. The name of the file is most likely on the previous line in the log.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 20, 2023, 05:21:16 PM
Hmm, not easily. I think you'd have to detect when the fleet has a HyperStormBoost script, remove it, and replace it with your own version.

Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 20, 2023, 05:37:38 PM
A possible option is doing setHidden() only while the core UI is open.

Wonder how well this dark sorcery works
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zerias on November 20, 2023, 09:06:52 PM
Hello! I decided to dip my toes into modding, and to start off I thought I'd take a peek into the Magnetar Mission mod, as it's one of the few High-Tech supercapitals that don't include a new faction.
I've managed to remove the dependency on the now-defunct Superweapons Mod, but given the entire thing about asset permissions that got Superweapons removed in the first place, I thought I'd ask here before posting a link.
Normally I'd just PM the author for permission, but it looks like IonDragonX hasn't been online since July, so getting a reply isn't likely.
Should I go ahead and post the link with the disclaimer that I'm just making a minor patch, or is there some licensing thing that says I shouldn't at all until and unless I get a response?
Apologies if this is in the wrong section, couldn't see one that stood out as the correct one for this question.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 20, 2023, 10:16:50 PM
Is there a way to obtain a list of the ship hulls currently being shown in the submarket the player is viewing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 21, 2023, 07:14:10 AM
I have noticed in your implementation of HyperStormBoost:
Code
        ...
        if (mult < 0.0F) {
            mult = 0.0F;
        }

        if (mult > 1.0F) {
            mult = 1.0F;
        }
        ...
instead of
Code
    ...
    mult = Math.min(1, Math.max(0, mult);
    ...
Is there a reason for this choice?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 21, 2023, 10:02:58 AM
Hello! I decided to dip my toes into modding, and to start off I thought I'd take a peek into the Magnetar Mission mod, as it's one of the few High-Tech supercapitals that don't include a new faction.
I've managed to remove the dependency on the now-defunct Superweapons Mod, but given the entire thing about asset permissions that got Superweapons removed in the first place, I thought I'd ask here before posting a link.
Normally I'd just PM the author for permission, but it looks like IonDragonX hasn't been online since July, so getting a reply isn't likely.
Should I go ahead and post the link with the disclaimer that I'm just making a minor patch, or is there some licensing thing that says I shouldn't at all until and unless I get a response?
Apologies if this is in the wrong section, couldn't see one that stood out as the correct one for this question.

Thank you for asking! You might try sending a PM anyway - their account might be set up to send a notification email when that happens. You do need permission to repost someone's work on the forum, yes.

I have noticed in your implementation of HyperStormBoost:
...
instead of
...
Is there a reason for this choice?

It's easier to read and understand at a glance, and requires less thinking. Obviously the max(min) thing isn't *hard* but the easier on yourself you make the simple things, the more brain cycles you have for things that actually need it. Or, to put another way, anything that makes one feel even slightly "clever" for doing, is a warning sign :)

(Also, if this was a hot code path, making extra function calls *might* slow it down, but that would require testing and it's absolutely NOT the reason for doing it that way here.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Liral on November 21, 2023, 11:25:29 AM
It's easier to read and understand at a glance, and requires less thinking. Obviously the max(min) thing isn't *hard* but the easier on yourself you make the simple things, the more brain cycles you have for things that actually need it. Or, to put another way, anything that makes one feel even slightly "clever" for doing, is a warning sign :)

(Also, if this was a hot code path, making extra function calls *might* slow it down, but that would require testing and it's absolutely NOT the reason for doing it that way here.)

Oh, that makes sense.  Thanks again!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: 6chad.noirlee9 on November 21, 2023, 11:46:27 AM
i have an odd error i was hoping to get some help with if anyone can.  thanks in advance.

Spoiler
45330 [Thread-3] INFO  com.fs.starfarer.campaign.rules.Rules  - Loading rule: ptes_riftgate
45404 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.UnsupportedClassVersionError: com/fs/starfarer/api/impl/campaign/rulecmd/ptes_riftGateDialog : Unsupported major.minor version 52.0
java.lang.UnsupportedClassVersionError: com/fs/starfarer/api/impl/campaign/rulecmd/ptes_riftGateDialog : Unsupported major.minor version 52.0
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$100(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at com.fs.starfarer.campaign.rules.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.getCommandClass(Unknown Source)
   at com.fs.starfarer.campaign.rules.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.<init>(Unknown Source)
   at com.fs.starfarer.campaign.rules.Rules.o00000(Unknown Source)
   at com.fs.starfarer.loading.SpecStore.public(Unknown Source)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

edit: i added my enabled mod list
Spoiler
{"enabledMods": [
  "starpocalypse",
  "pantera_ANewLevel40R",
  "advanced_gunnery_control_dbeaa06e",
  "adversary",
  "A_S-F",
  "anotherportraitpack",
  "aotd_lost_glory",
  "Cryo_but_better",
  "aod_core",
  "aod_vos",
  "ash",
  "armaa",
  "Planetace_AstralAscensions",
  "automatedcommands",
  "ORK",
  "combatactivators",
  "lw_radar",
  "lw_console",
  "customizablestarsystems",
  "Toaster_deciv",
  "Diktat Enhancement",
  "dex",
  "EmergentThreats_Vice",
  "seven_nexus",
  "pt_exiledSpace",
  "lyr_ehm",
  "a111164_ExtendPack",
  "fleethistory",
  "GrandColonies",
  "hegfleetexpansion",
  "hte",
  "HIVER",
  "hyperdiving",
  "sun_hyperdrive",
  "aerialcombatsuit",
  "IndEvo",
  "interestingportraitspack",
  "Imperium",
  "kyeltziv",
  "lost_sector",
  "LTA",
  "lw_lazylib",
  "leg",
  "luddenhance",
  "lunalib",
  "MagicLib",
  "niko_moreCombatTerrainEffects",
  "MoreMilitaryMissions",
  "advent_seven",
  "ness_saw",
  "nexerelin",
  "sun_nomadic_survival",
  "PirateMiniMegaMod",
  "particleengine",
  "pirate_ransom",
  "portrait",
  "QualityCaptains",
  "assortment_of_things",
  "sun_ruthless_sector",
  "salshiexp",
  "scan_those_gates",
  "ScavengerTrading",
  "secretsofthefrontier",
  "swp",
  "spacetruckin",
  "speedUp",
  "sw",
  "swf",
  "sun_starship_legends",
  "StopGapMeasures3",
  "alcoholism",
  "symbiotic_void_creatures",
  "tahlan",
  "Terraforming & Station Construction",
  "thong",
  "underworld",
  "uaf",
  "unthemedweapons",
  "UGH",
  "WEAPONARCS",
  "which_industry",
  "shaderLib"
]}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 21, 2023, 05:45:26 PM
It's easier to read and understand at a glance, and requires less thinking. Obviously the max(min) thing isn't *hard* but the easier on yourself you make the simple things, the more brain cycles you have for things that actually need it. Or, to put another way, anything that makes one feel even slightly "clever" for doing, is a warning sign :)

I did up something like clamp(min, value, max). Kotlin has coerceAtLeast(min)/coerceAtMost(max), but those are hard to read too IMO.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xaiier on November 22, 2023, 12:10:23 AM
Hi, I think I might have found a vanilla bug but I wanted to check to be sure I'm not doing something dumb...

I have a BeamEffectPlugin that does this:

Code
public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {

if (beam.getWeapon().getChargeLevel() > 0.99f) {
beam.getSource().getMutableStats().getTimeMult().modifyMult("aaa", 10f);
Global.getCombatEngine().getTimeMult().modifyMult("AAA", 0.1f);
}
else {
beam.getSource().getMutableStats().getTimeMult().unmodify("aaa");
Global.getCombatEngine().getTimeMult().unmodify("AAA");
}

if (!beam.didDamageThisFrame()) return;

engine.spawnExplosion(beam.getTo(), new Vector2f(), beam.getFringeColor(),15f, 1f);
}

It results in this:

(https://i.imgur.com/qQKpDU3.png)

The number of "extra" getTo() points seems to vary with the time multiplier.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 22, 2023, 11:17:36 AM
i have an odd error i was hoping to get some help with if anyone can.  thanks in advance.

(Hmm - this isn't the right topic for this; you'd want to make a post in the modded bug reports forum. That said, it looks like a a mod is compiled for the wrong version of java, or something similar.)


I did up something like clamp(min, value, max). Kotlin has coerceAtLeast(min)/coerceAtMost(max), but those are hard to read too IMO.

Yeah, I think I've made a similar clamp() method in places! Definitely agree on the other methods being hard to read.

Hi, I think I might have found a vanilla bug but I wanted to check to be sure I'm not doing something dumb...

I have a BeamEffectPlugin that does this:
...

The number of "extra" getTo() points seems to vary with the time multiplier.

Yeah, that checks out - not something that's likely to be fixed, more of a "how it works" due to IIRC collision checking not running on the faster-time frames.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on November 22, 2023, 12:14:28 PM
It's easier to read and understand at a glance, and requires less thinking. Obviously the max(min) thing isn't *hard* but the easier on yourself you make the simple things, the more brain cycles you have for things that actually need it. Or, to put another way, anything that makes one feel even slightly "clever" for doing, is a warning sign :)

I did up something like clamp(min, value, max). Kotlin has coerceAtLeast(min)/coerceAtMost(max), but those are hard to read too IMO.

Kotlin has Number.coerceIn(min..max) which is very readable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JEENAH on November 22, 2023, 12:31:10 PM
So i just realised that i created a *** post for a stupid little question. Dang. The moderators are gonna hate me -_-

So instead of continuing on my STUPID post ... I add my question here.


QUOTE : "Hello ! I'm actually creating a massive ship that will probably rival some of the biggest modded ships out there.

But since i can't find my info, a critical one ... I'm creating this post.

What is the radius in pixels of the LARGE / MEDIUM and SMALL weapon mounts ?

Actual weapons of the beast (Mounts) : 16 large, 28 medium, 30 small + 6 large missiles and probably more stuff later.

I'm also probably gonna have to request some assistance, because i wanna create it as a flag-ship with some lore behind it (It wont be a blueprint, but will be accessible as a derelict ship randomly in the sector. Intact).

Objective with it is to create a mobile-base like dreadnought that puts itself in the middle of the map and doesn't move at all. (Hull-mod that basically disable engines entirely, you can't move, but every bit of power is redirected to shields and weapons).

"A ship to rule the galaxy, a ship to teach those ants that we will never be defeated nor will we yield"

Anyway ! Wont spoil anything yet, i'm searching those weapon mount sprites but goddamn, its so hard to find.

EDIT : Seems like it's 32 pixels for the LARGE mounts"

Thanks ! Sorry for the pollution :(
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 22, 2023, 03:10:52 PM
I have a mid range (600) large beam weapon with a pretty fast turn rate and short burst attack. The AI seems to like to sway the turret a bit between some of the attack cycles, causing the beam to sweep across an enemy hull rather than aim for the same spot for each burst like most weapons. This might be due to the weapon "losing interest" in an enemy that's just slightly out of range and go to its default resting position rather than aim for the current target even when it's out of range like most beam weapons. Is there a way to fix this behavior with tags or hints, or perhaps some other way?

Also I was wondering if I could get a bit of help with my previous question. Is there a way to obtain a list of the ship hulls currently being shown in the submarket the player is viewing? Thanks :)

Edit: One more question, is there a way to render a missile below its launcher aside from using a deco weapon cover? Or alternately is there a way to render a deco weapon on the fitting screen on top like it would in combat?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on November 23, 2023, 02:48:56 AM
How do I create a nebula systems out of a java script?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on November 25, 2023, 08:28:43 AM
Is there a way to make a ship fire weapons without consideration of friendly fire?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 25, 2023, 11:37:04 AM
What is the radius in pixels of the LARGE / MEDIUM and SMALL weapon mounts ?

Unless I'm missing something, you can just open up any ship sprite that has these and check? You'd find them under graphics/ships/


I have a mid range (600) large beam weapon with a pretty fast turn rate and short burst attack. The AI seems to like to sway the turret a bit between some of the attack cycles, causing the beam to sweep across an enemy hull rather than aim for the same spot for each burst like most weapons. This might be due to the weapon "losing interest" in an enemy that's just slightly out of range and go to its default resting position rather than aim for the current target even when it's out of range like most beam weapons. Is there a way to fix this behavior with tags or hints, or perhaps some other way?

The AI should actually be better about this in the next release. ... or maybe that was already in 0.96a? I'm not actually 100% sure. Either way, there's not going to be much you can do on your end, though as with most AI things, it's very difficult to say anything at all conclusive just based on a verbal description.

Also I was wondering if I could get a bit of help with my previous question. Is there a way to obtain a list of the ship hulls currently being shown in the submarket the player is viewing? Thanks :)

You can use SubmarketAPI.getCargo() or something similar, no? The context of where you're trying to get at this from is going to determine how you'd go about that/whether it's doable.

Edit: One more question, is there a way to render a missile below its launcher aside from using a deco weapon cover? Or alternately is there a way to render a deco weapon on the fitting screen on top like it would in combat?

I don't think so.


How do I create a nebula systems out of a java script?

This question is a bit too broad for this thread. In brief, you can take a look at StarSystemGenerator.java - among other things, it creates nebula-type systems for the campaign. If you try, fail, and have a more specific question, that would be a better fit here.

Is there a way to make a ship fire weapons without consideration of friendly fire?

Hmm. You could try setting the collision class to something that doesn't hit friendlies, and then have a script change it after it's fired. But generally speaking, for a ship firing whatever weapons, nothing comes to mind.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on November 26, 2023, 03:43:24 PM
Also I was wondering if I could get a bit of help with my previous question. Is there a way to obtain a list of the ship hulls currently being shown in the submarket the player is viewing? Thanks :)
You can use SubmarketAPI.getCargo() or something similar, no? The context of where you're trying to get at this from is going to determine how you'd go about that/whether it's doable.
I have a custom faction that uses the same two ships for all aspects of logistics, including cargo, fuel, and troop transport. This is fine except their major industrial market is absolutely flooded with these ships, since I imagine the game is treating it as making "different" ship types for sale to pad out these roles on the market. What I'm trying to do is to write a listener that checks for when players open a ship market window, see if there are >x copies of a certain hull for sale, then delete the excess. Would SubmarketAPI.getCargo() be suitable for that?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 26, 2023, 09:04:13 PM
Ah, ok! Yeah, that should work fine - you'd implement a ColonyInteractionListener, and probably do your filtering out in the reportPlayerOpenedMarketAndCargoUpdated() method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 27, 2023, 11:11:19 AM
Would there be a way to "hide" the player fleet visually, or change the focus of the campaign camera?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 28, 2023, 12:11:48 PM
Would there be a way to "hide" the player fleet visually, or change the focus of the campaign camera?

Hmm - does void forceSensorFaderBrightness() or void forceSensorContactFaderBrightness() not work for the player fleet?

And I'm assuming you've tried using SectorAPI.getViewport().set(...)? That might not work since it might end up being overridden with player-fleet-related coordinates before rendering, but then again it might.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on November 29, 2023, 05:26:55 AM
Would there be a way to "hide" the player fleet visually, or change the focus of the campaign camera?

Hmm - does void forceSensorFaderBrightness() or void forceSensorContactFaderBrightness() not work for the player fleet?

And I'm assuming you've tried using SectorAPI.getViewport().set(...)? That might not work since it might end up being overridden with player-fleet-related coordinates before rendering, but then again it might.

The viewport stuff appears to work so thats nice, forceSensorFaderBrightness() and forceSensorContactFaderBrightness() dont seem to work though, or rather, they only work if the game is paused, so some other script seems to set their values aswell.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on November 29, 2023, 10:06:03 AM
Ah, ok, that makes sense - now that you mention it, I vaguely recall those getting force-set to full brightness for the player fleet, somewhere. Glad the viewport stuff works, though!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Nick9 on November 29, 2023, 10:43:55 AM
I have a question about collision radius (there are 690 pages, not gonna try search it out).

What are some tips on getting it right? Should it extend further from ship if it's, let's say, 'bulky'? Should it be exactly at further polygon bound?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 29, 2023, 11:00:59 AM
Shield radius and collision bounds must be within collision radius to be hit. AIs try to avoid overlapping their collision circles.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: SafariJohn on November 30, 2023, 03:13:44 PM
It's intended behavior, yeah. It's not likely that this would actually change.

What's the issue with making the hullmod not-hidden? The main thing hidden *does* is "do not show this in the hullmod picker" so unless I'm missing something, this behavior sounds like the primary feature of the flag, working. *Am* I missing something?

The issue is we only want these sort of hullmods to show up in a ship's built-ins and in the s-mod list. It might be possible to do this in some roundabout way atm, but I don't think so.

Really just need an exception for the S-mod list to show hidden hullmods that have an s-mod effect and are not hiddenEverywhere. Everything else is already good - e.g. s-modded built-ins can't be de-S-modded.

Worked on this some more. Core issue remains that adding permanent non-S-mod hullmods to a ship is not supported. Specifically, the hullmod pickers (regular and S-mod) don't correctly handle non-S-mod perma mods.

I did get built-in-only hullmods specified in the .ship to be S-moddable. It must be non-Hidden (so it shows in S-mod list), with "no_drop" and "no_drop_salvage" in the tags (so it does not drop as a mod spec anywhere, hopefully), and isApplicableToShip() must return false (so it never shows in the regular hullmod list).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on December 02, 2023, 04:46:49 AM
Does music get unloaded from memory when the track stops playing? Like if I include 500mb of music in my mod, will that eventually all bloat up the ram if every track ends up playing during a session?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 02, 2023, 10:35:30 AM
Does music get unloaded from memory when the track stops playing? Like if I include 500mb of music in my mod, will that eventually all bloat up the ram if every track ends up playing during a session?

It's never loaded into memory in the first place (except for in small chunks), all music is streamed from disk.

Edit: note that this is *not* the case for sfx. It's entirely possible to bloat the memory use by having a bunch of too-long/too-high-sample-rate/etc sfx. E.G. if one has a 10 second loop for a beam weapon, that's probably a bad idea. Won't matter on its own, but multiply that by a hundred different but similar cases, and you get into trouble...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on December 02, 2023, 03:53:08 PM
Is it possible to make it so that when a ship uses its ship system (f-button, not right-click) they become immune to certain usually-unavoidable weaponry (such as Afflictor ship system and Harbinger ship system)?

Another one: how does the Harbinger's system work exactly, does it just set a ship's flux at 100% or does it inject actual flux? Wondering if things with obscenely large buffers would be immune to immediate effects in-universe.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on December 02, 2023, 10:56:44 PM
I have a capital with a lot of small hybrid slots and some larger synergy slots. I want to discount weapons in the hybrid slots to disincentivize leaving slots empty. I also want to discount energies in the synergy slots, since missiles are really strong. Therefore the hullmod effect would be as follows: "Non-missile weapons mounted in mixed weapon slots cost 1/2/4 fewer ordnance points." However, it seems like the API only allows me to discount *all* weapons of a particular type, not by the specific slot. Am I missing something? Basically what I'd want is like "if weapon.slot != energy && weapon.type != missile then weapon.getDynamic.getmod(Stats.COST_MOD).modifyFlat(discount.get(weaponsize))".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on December 03, 2023, 11:17:23 AM
Any way to spawn a ship wing with a source-ship set? im having a shipsystem that spawns a clone of a deployed fighter, using "Global.getCombatEngine().getFleetManager(owner).spawnFleetMember(member, location, facing, 0f)" to spawn the wing in. However this wing has no sourceShip, and some mods have weapons or hullmods that asume their fighter to always have one and will get a Nullpointer. This Nullpointer happens as soon as the line is called, so while the API does not even have a method to set a wings sourceShip, i couldnt set it even if there was. Any way to go around this issue?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 03, 2023, 11:33:56 AM
Is it possible to make it so that when a ship uses its ship system (f-button, not right-click) they become immune to certain usually-unavoidable weaponry (such as Afflictor ship system and Harbinger ship system)?

Another one: how does the Harbinger's system work exactly, does it just set a ship's flux at 100% or does it inject actual flux? Wondering if things with obscenely large buffers would be immune to immediate effects in-universe.

1 - as far as I can tell, no - the targeting logic for the system only seems to care about range (and you can check for yourself at com.fs.starfarer.api.impl.combat.AcausalDisruptorStats)
2 - it simply forces the ship into the overloaded state, entirely ignoring flux

<SD's question>

I've answered this on discord but I'll answer this here as well for posterity - you can achieve this using a WeaponOPCostModifier listener that gets attached to the ship's variant through a hullmod.
thoguh it can't do this specific thing (setting the OP cost of a weapon based on the mount it's being put in), it can do basically anything else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 03, 2023, 03:21:28 PM
I've answered this on discord but I'll answer this here as well for posterity - you can achieve this using a WeaponOPCostModifier listener that gets attached to the ship's variant through a hullmod.
thoguh it can't do this specific thing (setting the OP cost of a weapon based on the mount it's being put in), it can do basically anything else.

Yep. Thank you for the answers!

Just one more note here: the HullModEffect.affectsOPCosts() method should also return true for this kind of hullmod - this is a critical step for OP-affecting hullmods and is very easy to forget.


Any way to spawn a ship wing with a source-ship set? im having a shipsystem that spawns a clone of a deployed fighter, using "Global.getCombatEngine().getFleetManager(owner).spawnFleetMember(member, location, facing, 0f)" to spawn the wing in. However this wing has no sourceShip, and some mods have weapons or hullmods that asume their fighter to always have one and will get a Nullpointer. This Nullpointer happens as soon as the line is called, so while the API does not even have a method to set a wings sourceShip, i couldnt set it even if there was. Any way to go around this issue?

Ah, I see why there's no setter - that's just a convenience method to get the ship for the wing's source fighter bay. Let me add FighterWingAPI.setSourceBay().

As to working around this, hmm. I don't think so. This would require a new method to pass in a source fighter bay, I think. I realize this is not a helpful answer but I'm inclined to say this is just a straight-up bug in the mods that do this, even if it's one that doesn't manifest too often.

Ugh. The code path from the spawnFleetMember call to where the wing is actually spawned is annoyingly long, too, so passing in any sort of parameter would probably be some sort of "pass it into the initial method, set in a static variable, use it, and unset it" hack. Digging into this, it's actually not super clear exactly how to do this; I'd have to really test it out to make sure I didn't break something. The only reason these kinds of weapons/hullmods work is that vanilla happens to "deploy" a fighter wing with no members, set its source bay afterwards, and then start deploying members from the bay one at a time. This is such an implementation detail; it could totally create the fighters before deployign them and then set the wing's source.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on December 04, 2023, 07:30:51 AM
I've answered this on discord but I'll answer this here as well for posterity - you can achieve this using a WeaponOPCostModifier listener that gets attached to the ship's variant through a hullmod.
thoguh it can't do this specific thing (setting the OP cost of a weapon based on the mount it's being put in), it can do basically anything else.

Yep. Thank you for the answers!

Just one more note here: the HullModEffect.affectsOPCosts() method should also return true for this kind of hullmod - this is a critical step for OP-affecting hullmods and is very easy to forget.


Any way to spawn a ship wing with a source-ship set? im having a shipsystem that spawns a clone of a deployed fighter, using "Global.getCombatEngine().getFleetManager(owner).spawnFleetMember(member, location, facing, 0f)" to spawn the wing in. However this wing has no sourceShip, and some mods have weapons or hullmods that asume their fighter to always have one and will get a Nullpointer. This Nullpointer happens as soon as the line is called, so while the API does not even have a method to set a wings sourceShip, i couldnt set it even if there was. Any way to go around this issue?

Ah, I see why there's no setter - that's just a convenience method to get the ship for the wing's source fighter bay. Let me add FighterWingAPI.setSourceBay().

As to working around this, hmm. I don't think so. This would require a new method to pass in a source fighter bay, I think. I realize this is not a helpful answer but I'm inclined to say this is just a straight-up bug in the mods that do this, even if it's one that doesn't manifest too often.

Ugh. The code path from the spawnFleetMember call to where the wing is actually spawned is annoyingly long, too, so passing in any sort of parameter would probably be some sort of "pass it into the initial method, set in a static variable, use it, and unset it" hack. Digging into this, it's actually not super clear exactly how to do this; I'd have to really test it out to make sure I didn't break something. The only reason these kinds of weapons/hullmods work is that vanilla happens to "deploy" a fighter wing with no members, set its source bay afterwards, and then start deploying members from the bay one at a time. This is such an implementation detail; it could totally create the fighters before deployign them and then set the wing's source.

Fair enough, it probably wont be a major issue and i already asked the mod author that it conflicted with to nullcheck the sourceShip since there didnt seem to be another way. Im not sure if this is a reasonable solution, but in this case having a way to stop the execution of hullmods and weapon advances for the first frame of being spawned, + the addition of a setter, would fix situations like this where they happen. But im going to asume that this hullmod and weapon advance code is also deeply nested in the code.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on December 04, 2023, 11:51:41 AM
hello once again everyone. i have returned with a question:
1) is it possible to run code every X ticks? (on the campaign map and/or everywhere)?
2) is it possible to run code every X time? (in game days/hours)
3) is it possible to run code before/when one opens / views there cargo?
4) is it possible to organize the players cargo bay with code?
thanks again all you people for responding to everyone's questions. it is most kind
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 04, 2023, 02:55:44 PM
hello once again everyone. i have returned with a question:
1) is it possible to run code every X ticks? (on the campaign map and/or everywhere)?
2) is it possible to run code every X time? (in game days/hours)
3) is it possible to run code before/when one opens / views there cargo?
4) is it possible to organize the players cargo bay with code?
thanks again all you people for responding to everyone's questions. it is most kind

1 & 2 - you can use an intervalUtil to to this kind of thing, it's effectively just a counter that resets when it hits a limit.
you can track real time passage with them by using the "amount" value that gets passed into most "advance"-type methods; that can also be converted into campaign time using Global.getSector().getClock().ConvertToDays;

3 - from a quick look, the CargoScreenListener interface seems to be what you're looking for, though I've never used it myself so I won't really be able to give any implementation help

I'm unsure on 4, though there doesn't seem to be a method for it in cargoAPI
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 06, 2023, 12:13:17 PM
is there a good (read : not through personalites.csv) way to give a human officer a custom personality name / description?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 06, 2023, 12:39:22 PM
Im not sure if this is a reasonable solution, but in this case having a way to stop the execution of hullmods and weapon advances for the first frame of being spawned, + the addition of a setter, would fix situations like this where they happen. But im going to asume that this hullmod and weapon advance code is also deeply nested in the code.

Yeah, this would I think be an even more difficult/potentially troublesome hack, since it'd have to wait a frame to reset whatever flag it set, and who knows what other things might break then that expected hullmods to be applied.


4) is it possible to organize the players cargo bay with code?

I think you'd need to get a copy of the cargo in whatever way you want, then clear the cargo and add things to it in the order you like.


is there a good (read : not through personalites.csv) way to give a human officer a custom personality name / description?

I don't think so, sorry! A lot of that stuff is fairly deeply hardcoded.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on December 08, 2023, 06:16:39 PM
How do I force a ship to back off in code? I've run into a really weird behavior and I'm trying to correct it, but the ship AI is seemingly ignoring the flags that I set.

https://youtu.be/d9KsfUOQ7YQ (https://youtu.be/d9KsfUOQ7YQ)

In a nutshell, the ship is deciding to engage at extremely close range because I set it to aggressive personality.
Then it's deciding to facehug the enemy despite having the BACKING_OFF flag for 30+ seconds, completely ignoring the flag as seen in the debug info on the righthand side.

In my code I tried to do this:
(https://cdn.discordapp.com/attachments/880035338855260180/1182868068393816144/image.png?ex=658642bc&is=6573cdbc&hm=ad598bf47a84becfe95754527b634803fce2cc044fa33b3dc870407100a4d55a&)
We can see in the video that it does successfully apply the flag, but the ship just keeps driving forwards the moment the BACK_OFF flag expires.
What's the point of BACKING_OFF?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on December 09, 2023, 10:34:17 AM
2 small qs about mines -
is there a purely timed fuse mine behaviour?
and is there a mine that drifts less than the PHASE_MINE type?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 09, 2023, 03:46:52 PM
Hi, I have a couple of questions: firstly, is there a way to set a captain for a ship, but the player can't replace it? The idea is to add a ship to the player's fleet with a fixed captain - the concept being a sort of ally ship that they can command in the battle phase.

Secondly, is it possible to make it so that ships generated during the battle phase (like a frigate that gets spawned from another ship) can be a target for the [F] view camera command? At the moment when I generate allied ships during battle, they seem to refuse the view command, so I can't really see what they're doing unless I have a ship of my own nearby. Also, I can't seem to command them either - that one's a lesser priority for me but would also appreciate to know if there was a way to make them accept player commands too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 10, 2023, 09:05:19 AM
We can see in the video that it does successfully apply the flag, but the ship just keeps driving forwards the moment the BACK_OFF flag expires.
What's the point of BACKING_OFF?

You want to set the BACK_OFF flag. BACKING_OFF is just a way it can signal that it's doing that to anything else that might care, such as a ship system AI. BACK_OFF is the actual instruction to do so.


2 small qs about mines -
is there a purely timed fuse mine behaviour?

I think you'd want to set the collision class to something that doesn't hit things, like NONE. Though that might mess with the AI being able to appreciate the danger, in which case: I don't think so, hmm.

and is there a mine that drifts less than the PHASE_MINE type?

If you set the acceleration/deceleration to something low that might do it. Not 100% sure. Or you could set the mine to "primed".


Hi, I have a couple of questions: firstly, is there a way to set a captain for a ship, but the player can't replace it? The idea is to add a ship to the player's fleet with a fixed captain - the concept being a sort of ally ship that they can command in the battle phase.

Misc.setUnremovable(person, true) may work.


Secondly, is it possible to make it so that ships generated during the battle phase (like a frigate that gets spawned from another ship) can be a target for the [F] view camera command? At the moment when I generate allied ships during battle, they seem to refuse the view command, so I can't really see what they're doing unless I have a ship of my own nearby. Also, I can't seem to command them either - that one's a lesser priority for me but would also appreciate to know if there was a way to make them accept player commands too.

I don't know - I think this may depend on how you're spawning them but the answer might just be "no", though this would be at least slightly surprising to me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: m3rc33 on December 10, 2023, 01:22:12 PM
Hey folks, do you know of a mod that allows you to create "loadouts" of your fleet?

I'm in a situation atm where I have a decent system that is visited by pirates, so I bounce between doing stuff in the core worlds (quests, smuggling, buying new ships etc) and going home to clean up the pirate fleets. So I was wondering if I could make 1 loadout with better smuggling and efficient ships for my core world business and 1 loadout for when I return to wreck the pirates.

Alternatively is there a better solution that does not require me to go back every so often?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 10, 2023, 03:17:53 PM
Misc.setUnremovable(person, true) may work.
Thanks! This partly worked in that I am not able to directly reassign the officer in question, but it seems I am still able to 'cheese' it somewhat by simply picking another officer (or the player character) and assigning them to the supposedly unremovable person's ship, thus initiating an officer swap. Would there be a way to counteract this loophole?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sorrydough on December 11, 2023, 04:44:00 AM
You want to set the BACK_OFF flag. BACKING_OFF is just a way it can signal that it's doing that to anything else that might care, such as a ship system AI. BACK_OFF is the actual instruction to do so.
Your AI is setting the BACKING_OFF flag without actually backing off and this is what triggered me to start trying to mess with the BACK_OFF flag. How do I use the BACKING_OFF flag if it can be set without the ship backing off?
For example I might write a behavior that checks whether the target is backing off by checking the flag, but it isn't actually backing off because it's aggressive, so the code I wrote is going to cause bugged behavior.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 12, 2023, 09:26:40 AM
Hey folks, do you know of a mod that allows you to create "loadouts" of your fleet?

I'm in a situation atm where I have a decent system that is visited by pirates, so I bounce between doing stuff in the core worlds (quests, smuggling, buying new ships etc) and going home to clean up the pirate fleets. So I was wondering if I could make 1 loadout with better smuggling and efficient ships for my core world business and 1 loadout for when I return to wreck the pirates.

Alternatively is there a better solution that does not require me to go back every so often?

Hi - ah, sorry, this isn't the right thread for it. You might have better luck asking in the general forum! This thread is for questions related to creating mods.


Thanks! This partly worked in that I am not able to directly reassign the officer in question, but it seems I am still able to 'cheese' it somewhat by simply picking another officer (or the player character) and assigning them to the supposedly unremovable person's ship, thus initiating an officer swap. Would there be a way to counteract this loophole?

Ah, I don't think so - looks like it only really works for the "integrated AI core" scenario. I'll keep this in mind!

Your AI is setting the BACKING_OFF flag without actually backing off and this is what triggered me to start trying to mess with the BACK_OFF flag. How do I use the BACKING_OFF flag if it can be set without the ship backing off?
For example I might write a behavior that checks whether the target is backing off by checking the flag, but it isn't actually backing off because it's aggressive, so the code I wrote is going to cause bugged behavior.

Looks like you're right - code changed since that flag was added, and since the AI basically doesn't use this flag internally, I never noticed it was being set in the wrong place. *Should* be fixed for the next release!

For now, checking that the DO_NOT_BACK_OFF and SAFE_VENT flags are not set should get you most of the way there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 12, 2023, 07:19:47 PM
Ah, I don't think so - looks like it only really works for the "integrated AI core" scenario. I'll keep this in mind!
Ah, alright. I'll just add a note for this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 13, 2023, 12:51:35 AM
question
is stats.getProjectileSpeedMult() bugged?
it is used exactly once, in the since unused skill ranged_specialization
using it in the hullmod of my own making caused some rather interesting side effects, namely making proximity fuze bombs not explode forever
and i'm not sure where to put the blame, whether it is the stat itself being weird, or my own incompetence
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 15, 2023, 10:44:01 AM
question
is stats.getProjectileSpeedMult() bugged?
it is used exactly once, in the since unused skill ranged_specialization
using it in the hullmod of my own making caused some rather interesting side effects, namely making proximity fuze bombs not explode forever
and i'm not sure where to put the blame, whether it is the stat itself being weird, or my own incompetence

My guess would be that the bombs do some kind of "how long should it take to travel to max range" calculation based on this multiplier, and if it's really low, they may end up with some weird numbers. You could check if that's the case by using less extreme values - but I'm not sure exactly what you're doing, of course.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on December 17, 2023, 05:27:41 AM
Is there any alternative to "removeDeployed" from "CombatFleetManager" in the API? Theres a few cases where manualy spawned ships dont appear to want to be removed, specificly still appearing in the deployment menu, even if dead and removed from the combat engine. This method seems to do the job, but its of course obfuscated, so an alternative or it being unobfuscated would be nice.

Would also be good to know if there is a method to hide spawned ships from the deployment menu.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on December 17, 2023, 12:02:38 PM
And another question, any good way to load new fonts in to the game for paragraphs, etc?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 18, 2023, 10:14:58 AM
Is there any alternative to "removeDeployed" from "CombatFleetManager" in the API? Theres a few cases where manualy spawned ships dont appear to want to be removed, specificly still appearing in the deployment menu, even if dead and removed from the combat engine. This method seems to do the job, but its of course obfuscated, so an alternative or it being unobfuscated would be nice.

I don't think there's any alternative. Looks like I'd already added it to the API, though! Let me add the fighter wing version while I'm looking at it.


Would also be good to know if there is a method to hide spawned ships from the deployment menu.

I actually have no idea. These methods for spawning ships is not something vanilla uses much, so I'be equally unsurprised if you told me these do or don't show up in the deployment menu. I also don't know offhand whether these add into the deployment points total or not.

If you can give me a (Java 7 compatible) code snippet I can paste in somewhere and run, "can this ship be hidden from the deployment menu" would be an easier question for me to answer - and also, it'd be a lot easier to code up a way to do it. I don't really know the standard way these methods are used etc etc.


And another question, any good way to load new fonts in to the game for paragraphs, etc?

Don't think so. Added a SettingsAPI.loadFont(String filename) method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on December 18, 2023, 11:54:32 AM
hello again everyone! i have returned with but a single question
1) is there a way to edit a rules.csv $memory_whatsit with code?
thanks again for answering my question in the past everyone. its been helpful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on December 18, 2023, 04:24:06 PM
My guess would be that the bombs do some kind of "how long should it take to travel to max range" calculation based on this multiplier, and if it's really low, they may end up with some weird numbers. You could check if that's the case by using less extreme values - but I'm not sure exactly what you're doing, of course.

well, the bombs have 0 proj speed, and a non-zero launch speed, so they're supposed to slow down to zero and stay there
and the multiplier is 2f, a +100% speed bonus
which should result in the same 0 proj speed
i tested again and the issue only happens when getProjectileSpeedMult.modifyMult is above zero and proj speed is lesser than launch speed
something suspicious happening tbh, i guess something odd in the prox fuze code?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 19, 2023, 01:12:59 AM
Hi, is there a way to force a fighter to do its "landing" animation at any time other than landing back at its carrier? I'm envisioning a sort of 'boarding' animation where a fighter would 'land' on top of an enemy ship, and disappear from there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alp7292 on December 19, 2023, 11:46:19 AM
hello i copied ballistic rangefinder hullmod from original files to a mod file to edit i changed its location from com.fs.starfarer.api.imp to data.hullmods for both hull_mods.csv and from the script and no addational changes were made when i run the game it crashes saying assignment conversion not possible how can i fix it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 19, 2023, 06:52:11 PM
hello again everyone! i have returned with but a single question
1) is there a way to edit a rules.csv $memory_whatsit with code?
thanks again for answering my question in the past everyone. its been helpful.

Yes. Exactly how depends on which one but it'll be something using the MemoryAPI, obtained via a call like:

Global.getSector().getMemoryWithoutUpdate()
FactionAPI.getMemoryWithoutUpdate()
SectorEntityToken.getMemoryWithoutUpdate()
MarketAPI.getMemoryWithoutUpdate()

And similar.


well, the bombs have 0 proj speed, and a non-zero launch speed, so they're supposed to slow down to zero and stay there
and the multiplier is 2f, a +100% speed bonus
which should result in the same 0 proj speed
i tested again and the issue only happens when getProjectileSpeedMult.modifyMult is above zero and proj speed is lesser than launch speed
something suspicious happening tbh, i guess something odd in the prox fuze code?

... probably! Offhand I'm not surprised something goes weird if proj speed is zero. Launch speed being > proj speed is a fairly common occurrence, though.


Hi, is there a way to force a fighter to do its "landing" animation at any time other than landing back at its carrier? I'm envisioning a sort of 'boarding' animation where a fighter would 'land' on top of an enemy ship, and disappear from there.

ShipAPI.beginLandingAnimation(ShipAPI target)

How well that'll actually work, I don't know; not enough may be exposed to make it work out.


hello i copied ballistic rangefinder hullmod from original files to a mod file to edit i changed its location from com.fs.starfarer.api.imp to data.hullmods for both hull_mods.csv and from the script and no addational changes were made when i run the game it crashes saying assignment conversion not possible how can i fix it

Probably because it's now a script being compiled with Janino (a compiler the game uses to compile loose scripts) and the code from that hullmod uses Java in a way Janino does not support. The way to get around this would be to either tweak the code based on what exactly the error is, or to compile it into a jar yourself instead of having the game compile it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on December 20, 2023, 07:58:18 PM
Would it be possible to mod in such a thing as a reflective shield - not in that it would reflect things back to sender, but rather that the shield's surface would act like a (partially effective) mirror? I'd ideally manually blacklist some weapons from being reflected (anything that isn't explicitly light, for instance) as well. Even better if this can be done for arbitrary shield shapes (ellispoids is what I'm thinking about atm).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dor99alon on December 21, 2023, 11:01:00 AM
The question:
Anyone knows how I can determine if the ShipAPI represents a ship that belongs to the player faction?

The details:
I'm trying to change hullmod "isApplicableToShip(ShipAPI ship)" method to check if the ship is part of the player faction or not.

I was hoping that ship.getFleetMember().GetFleetCommanderForStats().isPlayer() will do the trick but it returns false for the ships in my fleet.

I noticed there is ship.getOriginalOwner() which always returns "-1" and ship.getFleetMember().getOwner() which returns "0" but I have no idea if it returns the same for AI ships as well (no idea how to check that) so I'm hesitant to incorporate it without asking for advice first.

Thank you very much for helping me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on December 22, 2023, 12:09:59 AM
ShipAPI.beginLandingAnimation(ShipAPI target)

How well that'll actually work, I don't know; not enough may be exposed to make it work out.
Hi, I'd like to report that, unfortunately this function indeed doesn't quite work. I doesn't seem to trigger the landing animation when called. But it's okay, I will implement a workaround for now, I look forward to a future update in which this is possible!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on December 22, 2023, 05:41:24 AM
In regards to getHitStrengthBonus(), does a multiplier increase only apply to armor, or also to shields?

One of my 'self-use-only' hullmods uses getHitStrengthBonus() in combination with getDamageToTargetShieldsMult() to modify damage output, and combined with other 'self-use-only' hullmods for role-playing "a C.O. who (foolishly) dials back their weapons output against weaker opponents, or goes all out against actual threats when necessary."

In particular, one scenario has both parameters being used to either severely nerf an ENERGY-type weapon, or to increase the output by an arbitrary multiplier; do the two combine for shields, or do any increases / decreases apply separately to armor/shields?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on December 22, 2023, 08:55:05 AM
In regards to getHitStrengthBonus(), does a multiplier increase only apply to armor, or also to shields?
"Hit Strength" is the term the game uses. It'd be clearer if described as "armor penetration"; that value has no effect on damage dealt to shields. (It does have an effect on damage dealt to hull, however, due to the 5% residual armor.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 22, 2023, 12:15:45 PM
Would it be possible to mod in such a thing as a reflective shield - not in that it would reflect things back to sender, but rather that the shield's surface would act like a (partially effective) mirror? I'd ideally manually blacklist some weapons from being reflected (anything that isn't explicitly light, for instance) as well. Even better if this can be done for arbitrary shield shapes (ellispoids is what I'm thinking about atm).

I'm not the best person to answer this, really; vanilla doesn't do this. From what I've seen/heard about in mods, maybe it's possible, but I'd take that with a grain of salt.


The question:
Anyone knows how I can determine if the ShipAPI represents a ship that belongs to the player faction?

The details:
I'm trying to change hullmod "isApplicableToShip(ShipAPI ship)" method to check if the ship is part of the player faction or not.

I was hoping that ship.getFleetMember().GetFleetCommanderForStats().isPlayer() will do the trick but it returns false for the ships in my fleet.

I noticed there is ship.getOriginalOwner() which always returns "-1" and ship.getFleetMember().getOwner() which returns "0" but I have no idea if it returns the same for AI ships as well (no idea how to check that) so I'm hesitant to incorporate it without asking for advice first.

Thank you very much for helping me.

In that method, the answer is "always" - this method is only called from the refit screen and similar. (Note that this means it also won't do anythin if e.g. you're trying to use this method to prevent the hullmod from being used on NPC ships.)


Hi, I'd like to report that, unfortunately this function indeed doesn't quite work. I doesn't seem to trigger the landing animation when called. But it's okay, I will implement a workaround for now, I look forward to a future update in which this is possible!

Thank you, noted!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dor99alon on December 23, 2023, 01:46:58 AM
In that method, the answer is "always" - this method is only called from the refit screen and similar. (Note that this means it also won't do anythin if e.g. you're trying to use this method to prevent the hullmod from being used on NPC ships.)
Thank you very much for replying to my question.
This is exactly what I'm trying to do so if this method is "not the right place" than how could I block the hullmod from being used on NPC ships based on a condition?

For example like the SO hullmod is only allowed in frigates and destroyers, I want to have my mod only be allowed by AI based on some condition but not lock the player by that condition.
If we continue with the SO example than I would allow my hullmod to be installed on player capital ships but not on NPC capital ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 24, 2023, 11:44:40 AM
Thank you very much for replying to my question.
This is exactly what I'm trying to do so if this method is "not the right place" than how could I block the hullmod from being used on NPC ships based on a condition?

For example like the SO hullmod is only allowed in frigates and destroyers, I want to have my mod only be allowed by AI based on some condition but not lock the player by that condition.
If we continue with the SO example than I would allow my hullmod to be installed on player capital ships but not on NPC capital ships.

The ship loadout generator doesn't know about any of that but also won't try to stick random hullmods onto variants. The only way it's going to end up on a variant is if one of the stock variants for the ship has that hullmod. So for example if you added a variant of a capital ship with SO, then that capital ship would sometimes end up with SO in NPC fleets, despite it not being possible for the player to install in one. But since variants like that don't exist (at least in vanilla), this doesn't happen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: dor99alon on December 24, 2023, 11:46:00 PM
The ship loadout generator doesn't know about any of that but also won't try to stick random hullmods onto variants. The only way it's going to end up on a variant is if one of the stock variants for the ship has that hullmod. So for example if you added a variant of a capital ship with SO, then that capital ship would sometimes end up with SO in NPC fleets, despite it not being possible for the player to install in one. But since variants like that don't exist (at least in vanilla), this doesn't happen.
Thank you again for replying to my question.
Yesterday I captured Erradicator which was using my hullmod which is exactly what I wanted to avoid :)
I don't know how to add "variants" to the game (unless you count the things I design and than "copy\paste" between ships in my own fleet as "variants") so I'm not sure how it happened.

Is there any way to tell the ship loadout manager to avoid using a particular hullmod altogether?
Maybe I can make two versions of my hullmod: one for "player only" and another for "AI"? (I don't know how to limit hullmod to player only).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ymfah on December 25, 2023, 02:10:40 AM
Question

How to make D-mods and Hidden/Hidden Always flagged hullmods be S-moddable?

Detail

My first instinct was to look at BaseHullMod and overwrite it. Turns out this was not the case.

The only instance where I can see if Dmod/Hidden is checked is in com.fs.starfarer.api.util.Misc and ModPickerDialogV3.class, both of which are in vanilla and not easily accessible within a hullmod.

My current workaround is to make hidden hullmods no longer hidden in hull_mods.csv and add a no_drop, no_salvage tag. However, this cannot be applied to d-mods without messing with the games d-mod related codes and and the workaround has other issues of its own like showing up in the main menu missions.

How would I make D-mods and Hidden/Hidden Always flagged hullmods be S-moddable?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on December 25, 2023, 09:07:38 PM
Hmm. There's a bit of a discussion a few pages earlier in this thread, starting here (https://fractalsoftworks.com/forum/index.php?topic=5061.msg416482#msg416482), but that doesn't get into d-mods, just trying to make hidden hullmods s-moddable. Without the d-mod aspect, I think it's mostly doable, with some limited rough edges; the posts from SafariJohn may be useful. It does also involve the "not hidden, no_drop/no_drop_salvage" approach.

With d-mods, I don't think this is going to be doable. I mean, it *might* be but there would likely be all sorts of problems, the game definitely expects s-mods and d-mods to be distinct sets and offhand I couldn't even tell you what all might break when that assumption is broken.

Your best bet might be something like duplicating d-mods as not-d-mods with no_drop etc and using an alternative UI to s-mod those into the hull instead. And have some sort of script remove the d-mod versions of those if the hull winds up with them again? Hm, this sounds very hacky, but it's the only thing that comes to mind that feels even remotely workable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 01, 2024, 09:30:13 PM
question
is there another way to play a sound streamed from disk - i.e. without taking up preload memory - other than playCustomMusic ?
or to play more than one music simultaneously?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2024, 03:15:29 PM
There isn't, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TimeDiver on January 02, 2024, 03:57:22 PM
Meant to post something here, but the forums were (temporarily) down at the time.

Is there a way to make missiles not impact with asteroids and/or disabled/destroyed ship hulks after they are launched?

One of my theories was to add/replace 'HITS_SHIPS_ONLY_NO_FF' to 'collisionClass' in a missile's .proj file, but that didn't work.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 02, 2024, 04:53:25 PM
Hmm, I don't think there's a collision class that does that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on January 03, 2024, 09:41:51 AM
How do I remove a blueprint package of "package_id" from the player's cargo?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: creature on January 03, 2024, 12:25:12 PM
Hi, is it possible to dynamically add new (weapon/station) mounts to a ship during battle? In particular, I am thinking of adding a station module to a ship but only during battle, player doesn't have to see it in the refit screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on January 05, 2024, 10:37:58 AM
Is there a tag or code i could use to slow down a shipsystems activation timer during phase?
Essentialy, keep the activation-timer slowed down by the timemult you have.

I have a active shipsystem that the ship can activate before phasing, and the ship can phase while its active. The issue is that since the timer is modified by the timemult, you technicly get less out of the shipsystem if you decide to phase after activating it, since the effects that the system give are not multiplied by the timemult (and shouldnt be).

In case its not very clear, here is a video of it: https://streamable.com/a2apxi
Phasing in this case slows down the "clones", while the timer that keeps the clones keeps ticking down.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Mitsuru-Ch on January 05, 2024, 06:17:12 PM
(https://fractalsoftworks.com/wp-content/uploads/2023/11/league_inspection-1024x640.jpg)

Is there a way to move the entire dialogue to the left? I want to display a large image on the right of the screen and I need to move the dialogue text to the left to fit an even 1000x1000 to the screen.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Simbach Vazo on January 06, 2024, 01:10:39 AM
Am I able to have an item initiate an event on use? Like learning a blueprint removes it and gives access to designs, could I activate something and have that summon an officer, for example?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 06, 2024, 03:26:33 AM
Quote
37963 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.hullmods.MediumBallisticsIntegration]
java.lang.RuntimeException: Error loading [data.hullmods.MediumBallisticsIntegration]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassFormatError: Inconsistent constant value type in class file data/hullmods/MediumBallisticsIntegration
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at org.codehaus.janino.JavaSourceClassLoader.defineBytecode(JavaSourceClassLoader.java:244)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:194)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more


What exactly is the issue here? I?m not sure. The Hullmod in question:
Code
package data.hullmods;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;

public class MediumBallisticsIntegration extends BaseHullMod {

public static final float COST_REDUCTION  = 3;

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.MEDIUM_BALLISTIC_MOD).modifyFlat(id, -COST_REDUCTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + (int) COST_REDUCTION + "";
return null;
}

@Override
public boolean affectsOPCosts() {
return true;
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AtlanticAccent on January 06, 2024, 06:04:06 AM
Code
public static final float COST_REDUCTION  = 3;
This needs to be 3.0 not 3, as 3 is an int type not float
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: TrashMan on January 06, 2024, 06:55:35 AM
Crikey!
Dunno how I missed that. Thanks.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on January 06, 2024, 07:52:26 AM
Am I able to have an item initiate an event on use? Like learning a blueprint removes it and gives access to designs, could I activate something and have that summon an officer, for example?

Thats what special items are for, they store a piece of data that you can assign them and have a plugin that you can add logic to, like what happens on right-clicking them. Check out data/campaign/special_items.csv and how their done there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 06, 2024, 11:06:02 AM
How do I remove a blueprint package of "package_id" from the player's cargo?

Something like:
cargo.removeItems(CargoItemType.SPECIAL, new SpecialItemData(<id>), 1f)


Hi, is it possible to dynamically add new (weapon/station) mounts to a ship during battle? In particular, I am thinking of adding a station module to a ship but only during battle, player doesn't have to see it in the refit screen.

I don't actually know, though I suspect not.


Is there a tag or code i could use to slow down a shipsystems activation timer during phase?
Essentialy, keep the activation-timer slowed down by the timemult you have.

I have a active shipsystem that the ship can activate before phasing, and the ship can phase while its active. The issue is that since the timer is modified by the timemult, you technicly get less out of the shipsystem if you decide to phase after activating it, since the effects that the system give are not multiplied by the timemult (and shouldnt be).

In case its not very clear, here is a video of it: https://streamable.com/a2apxi
Phasing in this case slows down the "clones", while the timer that keeps the clones keeps ticking down.

Hmm, nothing comes to mind here. An alternative solution might be to apply a timemult to the clones so that they are faster while the parent ship is phased.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 06, 2024, 01:43:31 PM
Kind of weird bug..I keep getting a java.util.ConcurrentModificationException during combat while trying to spawn a ship using the variant of a module.

Code
List<ShipAPI> children = ship.getChildModulesCopy();
if(children != null && !lostmodules)
{
for(ShipAPI m: children)
{
m.ensureClonedStationSlotSpec();

if( m.getStationSlot() != null)
{
if(ship.getSystem().isActive())
{
m.getFluxTracker().showOverloadFloatyIfNeeded("Emergency Purge!", Color.yellow, 4f, true);
                                                //have tried this and just getting variant fron shipapi
variant = m.getFleetMember().getVariant();
break;
}
}
}
}
if(lostmodules)
             cfm.spawnFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP,
               variant),ship.getLocation(),ship.getFacing(),0f);

I keep getting this after getting the module variant and attempting to spawn a ship using
Code
cfm.spawnFleetMember(Global.getFactory().createFleetMember(FleetMemberType.SHIP, variant),ship.getLocation(),ship.getFacing(),0f);
outside of the loop

I did a bit of debugging and found that this always occurs if you try to spawn in a ship with modules I tested using regular stations and a few mod ships and consistently got the crash, but the code executed as expected spawning in a wolf. Oddly enough, if this code runs immediately without any condition at the start of combat(no if statements, or doing something like if(1==1), the ship will spawn, but otherwise you will get a ConcurrentModificationException. Am I doing something wonky here?

EDIT2: seems like just having module slots is enough for the crash to occur. I tried the roundabout way of creating a fleetmember and adding them to reserves, where they can be deployed manually, but using combat fleet managers .spawnFleetMember still causes a crash
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kweker on January 06, 2024, 02:55:09 PM
Hello there, i'm new at modding and wanted to change the Neural Link skill function for make it really useful (or too OP, i don't know) by making all ship who have the hullmods on them have all the piloted skill and switch between targeted ally ship who have the hullmods (much like the description of the skill in fact) but i don't know how to "overwrite" the code in the starfarer.api.jar with the code in the jar of my mod.
I have first think is automatic by looking to "A New Level Of Confidence" (you probably know what i wanted to do with changing the Neural Skill and use this mod) but it's change data outside the jar.
If you know a mod who already change this skill or know where there are explanation for my problem, I would appreciate.
PS : I accept the fact i can be a real dumb if what i search is more or less just in front of me.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Simbach Vazo on January 06, 2024, 05:41:32 PM
Thats what special items are for, they store a piece of data that you can assign them and have a plugin that you can add logic to, like what happens on right-clicking them. Check out data/campaign/special_items.csv and how their done there.
Appreciate the pointer!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kweker on January 06, 2024, 09:39:25 PM
Hello there, i'm new at modding and wanted to change the Neural Link skill function for make it really useful (or too OP, i don't know) by making all ship who have the hullmods on them have all the piloted skill and switch between targeted ally ship who have the hullmods (much like the description of the skill in fact) but i don't know how to "overwrite" the code in the starfarer.api.jar with the code in the jar of my mod.
I have first think is automatic by looking to "A New Level Of Confidence" (you probably know what i wanted to do with changing the Neural Skill and use this mod) but it's change data outside the jar.
If you know a mod who already change this skill or know where there are explanation for my problem, I would appreciate.
PS : I accept the fact i can be a real dumb if what i search is more or less just in front of me.
Sorry for the message, i have find a mod who can do this "Quality Captain" (just now need to only activated the modification for Neural Link).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 07, 2024, 04:37:55 PM
@shoi: generally speaking, a stack trace is helpful when there's a crash!

I think in this case though you need to .clone() the variant? Maybe? It's kind of hard to tell what's going on, though.

Also, it seems like your code might try to spawn a ship with a null variant, since it doesn't seem to be checking for that, but that would likely be a different error.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 07, 2024, 06:54:38 PM
101431 [Thread-3] INFO  sound.oo0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOO  - Cleaning up music with id [miscallenous_corvus_campaign_music.ogg]
101665 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.util.ConcurrentModificationException
java.util.ConcurrentModificationException
   at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
   at java.util.ArrayList$Itr.next(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)


I tried using the .clone()'d variant as well at one point, but that lead to the same result. pretty much any spawn method ends up causing this from what i've found, so long as the ship has module slots.

Code
		List<ShipAPI> children = ship.getChildModulesCopy();
if(children != null && !lostmodules)
{
for(ShipAPI module: children)
{
module.ensureClonedStationSlotSpec();

if( module.getStationSlot() != null)
{

if(ship.getSystem().isActive())
{
module.getFluxTracker().showOverloadFloatyIfNeeded("Emergency Purge!", Color.yellow, 4f, true);
if(module.getFleetMember() != null)
engine.getFleetManager(ship.getOwner()).spawnFleetMember(module.getFleetMember(),ship.getLocation(),ship.getFacing(),0f);
lostmodules = true;
break;
}
}
}
}
I had to repro the crash to get this stack trace so here's a more simple version I used to consistently reproduce it.
It has the same oddity of working if it runs immediately at battle start but crashing otherwise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 07, 2024, 07:16:01 PM
Where is this code running? Seeing the entire method might help here, I'd suspect something like "it's iterating over a list of ships doing this".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 07, 2024, 08:19:07 PM
I have this running off a single deco weapon that's on a single ship on an EveryFrameWeaponEffect, here's the entire advance method:

Code
    @Override
    public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
 
        if(!runOnce)
{
            runOnce=true;
            ship=weapon.getShip();
            for(WeaponAPI w : ship.getAllWeapons())
{
switch (w.getSlot().getId())
{
case "A_GUN":
                    if(armL==null)
{
                        armL = w;
                    }
break;
case "A_GUN2":
if(armR==null)
{
armR= w;
}
break;
case "E_RSHOULDER":
shoulderR = w;
originalShoulderPos = shoulderR.getSprite().getCenterY(); 
break;
case "E_LSHOULDER":
shoulderL = w;
originalShoulderPosL = shoulderL.getSprite().getCenterY(); 
break;
case "WS0003":
                        turretR = w;
                    break;

case "WS0001":
if(turretL == null)
                        turretL = w;
                    break;
case "E_DECO":
if(decoL == null)
                        decoL = w;
                    break;
case "E_DECO_R":
                        decoR = w;
                    break;
//break;
}
            }
        }
       
        if (armL==null) {
            return;
        }

        float sineA=0, sinceB=0;   

float global=ship.getFacing();
        float aim=MathUtils.getShortestRotation(global, weapon.getCurrAngle());
//*End animation math stuff


//Right arm + shoulder
        weapon.setCurrAngle(ship.getFacing() + MathUtils.getShortestRotation(ship.getFacing(),armL.getCurrAngle())*0.7f);
weapon.getSprite().setCenterY(originalShoulderPos+(2*armL.getCooldownRemaining()/armL.getCooldown()));
//turretL.setCurrAngle(ship.getFacing() + MathUtils.getShortestRotation(ship.getFacing(),armL.getCurrAngle())*0.7f);
if(armR != null)
{
shoulderR.setCurrAngle(ship.getFacing() + MathUtils.getShortestRotation(ship.getFacing(),armR.getCurrAngle())*0.7f);
shoulderR.getSprite().setCenterY(originalShoulderPos+(2*armR.getCooldownRemaining()/armR.getCooldown()));
}
ship.syncWeaponDecalsWithArmorDamage();
List<ShipAPI> children = ship.getChildModulesCopy();
if(children != null && !lostmodules)
{
for(ShipAPI module: children)
{
module.ensureClonedStationSlotSpec();

if(module.getStationSlot() != null)
{

if(ship.getSystem().isActive())
{
module.getFluxTracker().showOverloadFloatyIfNeeded("Emergency Purge!", Color.yellow, 4f, true);
ShipAPI s = engine.getFleetManager(ship.getOwner()).spawnFleetMember(module.getFleetMember(),ship.getLocation(),ship.getFacing(),0f);
//m.setStationSlot(null);
lostmodules = true;
//m.setHitpoints(0f);
//engine.removeEntity(m);
break;
}

}
}
}
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 07, 2024, 08:51:32 PM
Thank you! Aaah, ok, that makes sense I think. The deco weapon's advance() method is called while iterating over the list of ships in the engine, and spawnFleetMember() modifies that list, and you get the ConcurrentModificationException.

The easiest thing would probably be to create a custom BaseEveryFrameCombatPlugin implementation that would call the spawn method in its own advance() method (which is *not* called while iterating over the list of ships).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 08, 2024, 12:44:28 AM
it worked  :'( thank you!!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 08, 2024, 12:30:55 PM
Nice, happy you got it sorted out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: presidentmattdamon on January 08, 2024, 02:13:17 PM
i'm trying to insert an option into a FleetInteractionDialogImpl without overriding it completely to maintain maximum mod compatibility
my code follows:

Code
List savedOptionsBeforeClear = options.getSavedOptionList();

options.clearOptions();
options.addOption(text, data);

List newOptions = options.getSavedOptionList();
Object newOption = newOptions.get(0);
savedOptionsBeforeClear.add(Math.max(0, savedOptionsBeforeClear.size() - posFromLast), newOption);

options.restoreSavedOptions(savedOptionsBeforeClear);

for(Map.Entry<Object, Integer> shortcut : shortcutMap.entrySet()) {
    if (options.hasOption(shortcut.getKey())) {
        options.setShortcut(shortcut.getKey(), shortcut.getValue(), false, false, false, true);
    }
}

shortcutMap is a workaround i have for a particular issue, which is that the restoreSavedOptions method doesn't restore hotkeys or confirmation prompts added through either addOptionConfirmation method. is there any other way to insert an option there while preserving all the other options' data?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on January 08, 2024, 11:12:33 PM
Hi is there any way to block what tooltip renders so for example this text does not go outside panel boundries ?
I am asking if it's possible to block it with stencil mask

Spoiler
(https://i.imgur.com/0FJQHlY.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 10, 2024, 10:38:06 AM
shortcutMap is a workaround i have for a particular issue, which is that the restoreSavedOptions method doesn't restore hotkeys or confirmation prompts added through either addOptionConfirmation method. is there any other way to insert an option there while preserving all the other options' data?

Hmm, I don't think so - I mean, you could always *add* an option, but it'd go at the end. Inserting one is not supported.


Hi is there any way to block what tooltip renders so for example this text does not go outside panel boundries ?
I am asking if it's possible to block it with stencil mask

Spoiler
(https://i.imgur.com/0FJQHlY.png)
[close]

I think so - you'd need to add a CustomPanelAPI and you could do your own stencil-masking in its render() method. Though you'd probably want to use glScissor() instead for this sort of thing. I think you would want to account for SettingsAPI.getScreenScaleMult() when using that method, to properly support UI scaling.

This specific example looks a bit odd, though - if the text was getting clipped, it'd still look bad. And if this were inside a scroller, then the clipping should happen automatically. So something feels not right there.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on January 16, 2024, 08:35:20 AM
is it possible to easily replace ship stats and weapon stats without having to just directly override the original files? Like, I can do that with hullmods, all I have to do in their case is replace their original hull_mods.csv file with a hullmod of same ID, but can I do it this way with ships and weapons? I'm trying to rework the whole game, and I'm worried future releases might destroy everything...

Also, I have a question, is there a way to disable campaign missions? I'm trying to rewrite lore into like Starsector freaking morbillion years in the future. Cowboys shooting at pirates whilst Hegemony hides behind a giant toaster. But the missions might ruin the immersion, especially the one in which we get to see [REDACTED] taking over a giant orange

The issue with those is that I have made the stars bigger and because of that it seems like a Tundra world is spawning right next to a giant Blue Star, I've made a lore justification in how Tundras can reflect light or something weird (long story), but it would be far easier if I could just turn off the campaign altogether... At least for now.

Also, I do hope that the Abyss worlds I've heard of are going to be custom planets and not just typical planets spawning with the system gen, because I'm worried that if I change the planets in the custom entities to make them more weird, they are going to again intrude on the story...

And that would be pretty sad.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on January 16, 2024, 10:16:14 AM
is it possible to easily replace ship stats and weapon stats without having to just directly override the original files?

yeah, just provide your own ship_data or weapon_data csv & it'll get overriden in the same way as the hullmods
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 16, 2024, 10:49:07 AM
@Killer of Fate: it sounds like you're in total conversion territory with your mod. There's a "replace" section in the mod_info file which lets you specify that you want to replace a file with the one from your mod rather than have it be merged in. You could use this to turn off the missions, for example, etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on January 16, 2024, 11:35:40 AM
@Killer of Fate: it sounds like you're in total conversion territory with your mod. There's a "replace" section in the mod_info file which lets you specify that you want to replace a file with the one from your mod rather than have it be merged in. You could use this to turn off the missions, for example, etc.
oh, I actually just figured it out, all I had to do was add a mod that uses ID of weapons I want to change, and the game will automatically replace them, it works exactly how I want it to... Thank you for giving this feature tbh, otherwise I would be in HELL.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: blueire on January 16, 2024, 04:29:31 PM
Is there any way to make a larger variety of the vanilla person bounties available from the settings.json or some related file? Right now I'm getting a bunch of identical bounties for 150k with fleets 4-5x my fleet size basically forcing me to be a trader for the next 20 hours or start over with super inflated bounty rewards in the json.

I just want to go back to the bounty size I had 2 missions ago and it feels like the easiest way would be to update the settings to have a wider range of bounty levels spawn or easier bounties spawn, or maybe a slower bounty progression - really open to any suggestions. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 18, 2024, 11:09:53 AM
Is there any way to make a larger variety of the vanilla person bounties available from the settings.json or some related file? Right now I'm getting a bunch of identical bounties for 150k with fleets 4-5x my fleet size basically forcing me to be a trader for the next 20 hours or start over with super inflated bounty rewards in the json.

I just want to go back to the bounty size I had 2 missions ago and it feels like the easiest way would be to update the settings to have a wider range of bounty levels spawn or easier bounties spawn, or maybe a slower bounty progression - really open to any suggestions. Thanks!

Hmm, I don't think there is a way to adjust specifically that aspect of it from settings.json. If you look for "maxPersonBounties", you'll see the block where all of the exposed settings are.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on January 20, 2024, 04:22:23 AM
how do i use this menu to make the penalty for black market trade more significant... I once did that (lost the build), but nowadays I'm unsure if this thing even works at all...
I want the player to have a -50 rep if they sell like 2 million credits worth of illegal chewing gum. Or weapons... Or ships... Contrary to typical -10 or something...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 20, 2024, 09:08:50 PM
Is maxZoomFactor returning the right thing?

Before modifying any values, I'm seeing:
minZoomFactor = 0.5
zoomFactor = 3.0
maxZoomFactor = 0.5

I'd expect maxZoomFactor to be 3, here.

Kotlin code I checked with:
Spoiler
Code
mapOf(
    "minZoomFactor" to Global.getSector().campaignUI.minZoomFactor,
    "zoomFactor" to Global.getSector().campaignUI.zoomFactor,
    "maxZoomFactor" to Global.getSector().campaignUI.maxZoomFactor
)
[close]


edit: Oh, and immediate follow-up: Is `Global.getSettings().getFloat("maxCampaignZoom")` reasonably safe to use to get the vanilla max zoom?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 21, 2024, 01:15:41 PM
how do i use this menu to make the penalty for black market trade more significant... I once did that (lost the build), but nowadays I'm unsure if this thing even works at all...
I want the player to have a -50 rep if they sell like 2 million credits worth of illegal chewing gum. Or weapons... Or ships... Contrary to typical -10 or something...

I think setting "economyPlayerTradeVolumeForRepChangeIncr" to something lower might do it, but I'm not sure; you'd have to dig around in the code. All of this code in the api zip.


Is maxZoomFactor returning the right thing?

Before modifying any values, I'm seeing:
minZoomFactor = 0.5
zoomFactor = 3.0
maxZoomFactor = 0.5

I'd expect maxZoomFactor to be 3, here.

Ooops, that method was also returning the min - fixed!


edit: Oh, and immediate follow-up: Is `Global.getSettings().getFloat("maxCampaignZoom")` reasonably safe to use to get the vanilla max zoom?

It should work unless setMaxZoomFactor() was called (which, double-checked, does set the correct value).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 22, 2024, 11:53:37 AM
<words>

Ooops, that method was also returning the min - fixed!


edit: Oh, and immediate follow-up: Is `Global.getSettings().getFloat("maxCampaignZoom")` reasonably safe to use to get the vanilla max zoom?

It should work unless setMaxZoomFactor() was called (which, double-checked, does set the correct value).

Great, thank you! The zoom bugs I was getting before checking my inputs were wild :D but it's all working nicely now (an ability that lets you temporarily view a larger amount of the system).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 22, 2024, 12:10:56 PM
Hah, I bet :) That sounds like a fun one!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: steve1592 on January 24, 2024, 12:59:12 PM
I want to play with a lot of mods but I've come to the realization that with more mods comes lower performance. So I've started trimming the mods I use, but I've heard that the main thing that causes the campaign map to lag is all the extra markets and fleets that come with faction mods. So my idea is to first generate the sector with the factions whose markets I want, then after sector generation I'll active the faction mods whose markets I don't care about but I still want their ships/weapons/hullmods/blueprints to show up in game. Would this work?

Another alternative idea would be to go around and destroy markets using console commands to have a similar effect. I tried this in the past but didn't notice a big difference. My videocard wasn't as good then though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on January 24, 2024, 01:11:44 PM
So my idea is to first generate the sector with the factions whose markets I want, then after sector generation I'll active the faction mods whose markets I don't care about but I still want their ships/weapons/hullmods/blueprints to show up in game. Would this work?
Generally, yes. Some mods may generate their faction stuff on game load if they weren't present before, however.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on January 24, 2024, 01:23:46 PM
Any way to tell the game to not render this UI for specific ships?
Edit: Appears like setting them to fighters does the trick, though it would be nice to know if theres a way around this without that, though in my specific use case having them set to fighter instead of frigate may be fine.

(https://imgur.com/F6VsDWN.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on January 24, 2024, 06:06:11 PM
is there any other way to move player fleet to another system?
i need the move to happen specifically while in dialogue, while paused
.doHyperspaceTransition works, but that also requires setting up an extra janky script that unpauses game for exactly 5s and then pauses it back again
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 24, 2024, 06:43:49 PM
Any way to tell the game to not render this UI for specific ships?
Edit: Appears like setting them to fighters does the trick, though it would be nice to know if theres a way around this without that, though in my specific use case having them set to fighter instead of frigate may be fine.

Giving the hull a "module_no_status_bar" tag should also prevent it.


is there any other way to move player fleet to another system?
i need the move to happen specifically while in dialogue, while paused
.doHyperspaceTransition works, but that also requires setting up an extra janky script that unpauses game for exactly 5s and then pauses it back again

SectorAPI.setCurrentLocation()

And removing the fleet from its original location and adding it to the new one. I think that should do it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on January 25, 2024, 12:49:25 PM
Any way to tell the game to not render this UI for specific ships?
Edit: Appears like setting them to fighters does the trick, though it would be nice to know if theres a way around this without that, though in my specific use case having them set to fighter instead of frigate may be fine.

Giving the hull a "module_no_status_bar" tag should also prevent it.


is there any other way to move player fleet to another system?
i need the move to happen specifically while in dialogue, while paused
.doHyperspaceTransition works, but that also requires setting up an extra janky script that unpauses game for exactly 5s and then pauses it back again

SectorAPI.setCurrentLocation()

And removing the fleet from its original location and adding it to the new one. I think that should do it.

That does hide the status bar, but if the ship isnt in "view" on the screen, it still adds this UI element, so guess il have to make them fighters.

(https://imgur.com/x4o7AZY.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: prav on January 27, 2024, 08:23:28 AM
Is there an escape value for turnRateStr and accuracyStr in weapon_data.csv? I've got a laser where I'd prefer for the fields to not show in the tooltip.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 27, 2024, 08:33:38 AM
Nothing to modify tooltip behavior, no. Perhaps "---" or "n / a" or some such? The game uses both of those in similar contexts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xaiier on January 28, 2024, 03:01:34 PM
Is there any way to hide the fighter map UI triangles? They show up in some unwanted places (like DEM missiles).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on January 28, 2024, 03:36:13 PM
Is there a way to hide a hullmod on a specific ship but not any others when that hullmod lacks hiddenEverywhere being set to TRUE?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 28, 2024, 04:55:32 PM
Is there any way to hide the fighter map UI triangles? They show up in some unwanted places (like DEM missiles).

Hmm, really? It doesn't seem to happen for vanilla DEM missiles.

Is there a way to hide a hullmod on a specific ship but not any others when that hullmod lacks hiddenEverywhere being set to TRUE?

I don't think so, sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wispborne on January 28, 2024, 11:50:00 PM
Is there a way to modify the player's current zoom directly?
It can be done by modifying the min/max.

`Global.getSector().getCampaignUI().setZoomFactor(float)` doesn't exist (the getter does).

`CampaignEngine.getInstance().getUiData().setCampaignZoom(float)` doesn't appear to do anything.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xaiier on January 29, 2024, 01:20:51 AM
Is there any way to hide the fighter map UI triangles? They show up in some unwanted places (like DEM missiles).

Hmm, really? It doesn't seem to happen for vanilla DEM missiles.

This is what I'm seeing in a [nearly] clean install of 0.96a-RC10:
(https://i.imgur.com/wpp09CF.png)
Any "FIGHTER" size ship has a corresponding map UI element sized to the collision radius, whether it's a DEM, module, etc...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on January 29, 2024, 12:34:51 PM
Is there a way to modify the player's current zoom directly?
It can be done by modifying the min/max.

`Global.getSector().getCampaignUI().setZoomFactor(float)` doesn't exist (the getter does).

`CampaignEngine.getInstance().getUiData().setCampaignZoom(float)` doesn't appear to do anything.

I don't think so; added the former.

The latter is just data that goes into the savefile so the settings there get applied when the game is loaded.

This is what I'm seeing in a [nearly] clean install of 0.96a-RC10:

Any "FIGHTER" size ship has a corresponding map UI element sized to the collision radius, whether it's a DEM, module, etc...

Ah, thank you! I was being dumb and checked the missiles before they started firing (which ofc means there was no drone). There's no way to hide this at the moment, no, but I'll keep it in mind - this is an oversight on my part.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on January 30, 2024, 01:04:15 AM
is it possible to easily replace the surveypluginimpl in mod form? I tried doing this and then this (images linked). Cause this was the way I did it when directly replacing files. But I want the change to be easily reproducible and retractable... Is there a way to have the game interpret this completely functional when outside surveypluginimpl file without it being too complicated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on January 30, 2024, 01:44:33 PM
Is there a way to populate options for an InteractionDialogAPI from rules.csv if it fulfills some arbitrary trigger?
I have a dialog pop up a certain distance from a few planets/entities in the campaign which works, but it seems like I can only manually add options to the dialog's OptionPanelAPI.

for testing purposes I added a rule that has the trigger as "PopulateOptions" with the condition being set just before calling  Global.getSector().getCampaignUI().showInteractionDialog().  im sure the condition is true as the test option appears if I actually interact with the planet after closing the dialog, but the only options in the actual dialog are ones I added in the script  :-\. Hope that makes sense, this area of the API is new to me
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 01, 2024, 11:43:44 AM
is it possible to easily replace the surveypluginimpl in mod form? I tried doing this and then this (images linked). Cause this was the way I did it when directly replacing files. But I want the change to be easily reproducible and retractable... Is there a way to have the game interpret this completely functional when outside surveypluginimpl file without it being too complicated?

What you're doing should work even though you're not directly replacing the file in this case. Make sure your settings.json change is inside a "plugins" section, though.


Is there a way to populate options for an InteractionDialogAPI from rules.csv if it fulfills some arbitrary trigger?
I have a dialog pop up a certain distance from a few planets/entities in the campaign which works, but it seems like I can only manually add options to the dialog's OptionPanelAPI.

for testing purposes I added a rule that has the trigger as "PopulateOptions" with the condition being set just before calling  Global.getSector().getCampaignUI().showInteractionDialog().  im sure the condition is true as the test option appears if I actually interact with the planet after closing the dialog, but the only options in the actual dialog are ones I added in the script  :-\. Hope that makes sense, this area of the API is new to me

You can do one or the other - either run the dialog from rules, or run it "manually" with code.

To do the former, you can use:
Misc.showRuleDialog(showRuleDialog(SectorEntityToken entity, String initialTrigger);

You can look at the code for that method for the details, it's pretty simple - just using a RuleBasedInteractionDialogPluginImpl() to drive the dialog.

It IS possible to switch between the two methods - for example, FleetInteractionDialogPluginImpl does this, swapping to rules for conversations with the fleet commander - but that is considerably more tricky to do.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 01, 2024, 04:32:02 PM
I have a really...really big energy weapon.   I want to simulate a huge power draw when this thing fires by having a chance to turn off one or more of the ship's engines.  I know how to make a percentage chance to happen inside of a OnFireEffect script.   
I have a goal of 10% chance to cause a flameout of one of the ship's engines on firing.
Also a 1% chance of flaming out all of the ship's engines on firing.

My question is:

What is the command to cause one of the ship's engines to flameout?

Is there a related command to to flameout all of the ship's engines?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: shoi on February 01, 2024, 05:33:33 PM
ShipAPI.getEngineController().getShipEngines().disable()

for full flame out ShipApi.getEngineController().forceFlameout()

here's API https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/combat/ShipEngineControllerAPI.html

You can do one or the other - either run the dialog from rules, or run it "manually" with code.

To do the former, you can use:
Misc.showRuleDialog(showRuleDialog(SectorEntityToken entity, String initialTrigger);

You can look at the code for that method for the details, it's pretty simple - just using a RuleBasedInteractionDialogPluginImpl() to drive the dialog.

It IS possible to switch between the two methods - for example, FleetInteractionDialogPluginImpl does this, swapping to rules for conversations with the fleet commander - but that is considerably more tricky to do.

thank you
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on February 02, 2024, 05:05:04 PM
I've put water surface on a gas giant to have it have aqua farming, but for some reason instead of gaining access to aqua farming industry, i gain access to simple farming. I've set all the farming to 0 (previously blank, so still didn't spawn), and had habitable environment, hoping that it could have something to do with that, but in the end this continues...

Is there something specific that I'm doing here or is this a code thing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 02, 2024, 05:16:14 PM
It's a code thing, the Farming class defines what types of planets get aquaculture, it's not based on planetary conditions.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on February 03, 2024, 07:36:20 AM
Since slipstreams can now show up on Starscape, and as far as i know Slipstreams are rendered through the Terrain Plugin on the map, is there now a way for mods to render on Starscape aswell, or is the slipstream terrain rendering on Starscape hardcoded?

Anyways, would be great if that could become functionality if it is not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 04, 2024, 08:02:21 PM
It's hardcoded at the moment, yeah. Sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 05, 2024, 05:42:11 AM
Java code continues to vex me as I know not all of its fancy proper syntax.

Here I am trying to implement a big energy weapon that has a chance when fired to cause a flameout.
Ideally I'd like it to have a 10% chance of going thru and can cause each individual engine to flameout.  I'm currently unsure how to code this.   Does getShipEngines() return an array of the engines on a ship that I could then iterate thru?

Also 'd like  a 1% chance for a full flameout of all engines.
Code attempt:  (causes a crash currently)
Code
public class FusionBlasterOnFireEffect implements OnFireEffectPlugin 
{

    public static final float OVERLOADCHANCE = 10f;
public static final float FLAMEOUTCHANCE = 1f;

private ShipEngineControllerAPI shipengine;

public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
{
// Percentage chance (1 - 100)
int rndChance = (int)Math.round((Math.random() * 99)+ 1);

if (rndChance <= OVERLOADCHANCE)
{
// something here to get each engine, chance to flameout each one individually?

}

if (rndChance <= FLAMEOUTCHANCE)
{
shipengine.(weapon.getShip()).forceFlameout();   // needs fixin'  :-/

}

}
}


Secondly, is this the proper way to implement a custom missile ai script called "SeekerMissileAI"   to missiles of projectile ID "battlefleets_tau_seekermissile"?

Code
public static final String SEEKERMISSILE_MISSILE_ID = "battlefleets_tau_seekermissile"; 

@Override
public PluginPick pickMissileAI(MissileAPI missile, ShipAPI launchingShip)
{
if (SEEKERMISSILE_MISSILE_ID.equals(missile.getProjectileSpecId()))     
{
return new PluginPick(new SeekerMissileAI(missile), CampaignPlugin.PickPriority.MOD_SPECIFIC);     
}

return null;
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on February 05, 2024, 10:44:38 AM
is it possible for a standard missile to deal soft flux damage at the moment? I wanted to change locust damage to kinetic, but don't want it to just eat ships...
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 06, 2024, 09:43:24 AM
is it possible for a standard missile to deal soft flux damage at the moment? I wanted to change locust damage to kinetic, but don't want it to just eat ships...

I believe so, using a custom DamageDealtModifier.

Does getShipEngines() return an array of the engines on a ship that I could then iterate thru?

The Starsector javadoc is here:
https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

It should help you find the answers to those kinds of questions, see what methods are available, etc.

Code attempt:  (causes a crash currently)

The actual error message/stack trace is really helpful to see along this sort of question, btw!

Secondly, is this the proper way to implement a custom missile ai script called "SeekerMissileAI"   to missiles of projectile ID "battlefleets_tau_seekermissile"?

That looks right to me, though I didn't try it etc. But at least the general idea looks correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NeoLemon on February 06, 2024, 10:58:08 AM
is it possible for a standard missile to deal soft flux damage at the moment? I wanted to change locust damage to kinetic, but don't want it to just eat ships...

I believe so, using a custom DamageDealtModifier.

Does getShipEngines() return an array of the engines on a ship that I could then iterate thru?

The Starsector javadoc is here:
https://fractalsoftworks.com/starfarer.api/index.html?overview-summary.html

It should help you find the answers to those kinds of questions, see what methods are available, etc.

Code attempt:  (causes a crash currently)

The actual error message/stack trace is really helpful to see along this sort of question, btw!

Secondly, is this the proper way to implement a custom missile ai script called "SeekerMissileAI"   to missiles of projectile ID "battlefleets_tau_seekermissile"?

That looks right to me, though I didn't try it etc. But at least the general idea looks correct.

Alex sorry to bother you, but it is possible to make ship to be able to shoot while venting? and if it doesnt, do you will add api that will allow it to happen next patch?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 06, 2024, 03:27:55 PM
Whoops!   here's the crash log for my broken fusion blaster:

Code

12551 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.scripts.weapons.FusionBlasterOnFireEffect]
java.lang.RuntimeException: Error loading [data.scripts.weapons.FusionBlasterOnFireEffect]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.weapons.FusionBlasterOnFireEffect'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/weapons/FusionBlasterOnFireEffect.java', Line 44, Column 16: Unexpected selector '(' after "."

So it would appear that my line to cause the flameout:

   shipengine.(weapon.getShip()).forceFlameout();

Is not the proper implementation.


Also I tried tagging in the code for the missileAI and got this:

Code
12127 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error loading [data.scripts.world.BattlefleetsSectorsGen]
java.lang.RuntimeException: Error loading [data.scripts.world.BattlefleetsSectorsGen]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/world/BattlefleetsSectorsGen.java', Line 70, Column 44: Cannot determine simple type name "MissileAPI"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/world/BattlefleetsSectorsGen.java', Line 70, Column 44: Cannot determine simple type name "MissileAPI"

I think I'm missing an import declaration for missileAI?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 07, 2024, 06:23:13 AM
@accuracyThruVolume are you using a proper java IDE? all of these mistakes are minor syntax errors that one would automatically correct for you.
The wiki has a guide for setting up intellij here (https://starsector.fandom.com/wiki/IntelliJ_IDEA_Setup) that should only take a few minutes & will make things so much easier compared to using something like notepad++
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 07, 2024, 02:59:50 PM
Hi people on the forum,

Here is VladimirVV, a player of starsector since 2015. I'm currently making a mod, and I met a silly question that I can't find answer to, any help would be appreciated!

The question is, I want to implement a weapon like death ray, a super laser that literally kills anything in its way but takes super long time to charge. The implementation is OK, and  I find it fun to play with. The only problem is that the ai does NOT fire it under any circumstances.

For my own efforts regarding this issue,  I tried to google for it and I found something like ai would not fire a weapon set if it costs more than 50% of the flux of the ship. And I made this weapon with purpose that it will fill almost 100% of the flux pool for the ship. I want to let the ai bypass this 50% flux threshold, how can I do it? (I don't want to lower the flux this weapon costs, otherwise the data of the weapon will look bizarre and make the ship quite unbalanced)

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 07, 2024, 07:28:37 PM
Hi people on the forum,

Here is VladimirVV, a player of starsector since 2015. I'm currently making a mod, and I met a silly question that I can't find answer to, any help would be appreciated!

The question is, I want to implement a weapon like death ray, a super laser that literally kills anything in its way but takes super long time to charge. The implementation is OK, and  I find it fun to play with. The only problem is that the ai does NOT fire it under any circumstances.

For my own efforts regarding this issue,  I tried to google for it and I found something like ai would not fire a weapon set if it costs more than 50% of the flux of the ship. And I made this weapon with purpose that it will fill almost 100% of the flux pool for the ship. I want to let the ai bypass this 50% flux threshold, how can I do it? (I don't want to lower the flux this weapon costs, otherwise the data of the weapon will look bizarre and make the ship quite unbalanced)

Thank you!

I've found adding the line:

"autocharge":true,

to your .wpn  file will make the AI fire the weapon more reliably.   Note that I've seen them turn the weapon or even the whole ship away from the target (like the AI thinks the weapon has already fired) before the charging weapon actually fires if the the chargeup time is extensive.    If the AI still seems unable to use your weapon well, try balancing the chargeup and chargedown times.

@accuracyThruVolume are you using a proper java IDE? all of these mistakes are minor syntax errors that one would automatically correct for you.
The wiki has a guide for setting up intellij here (https://starsector.fandom.com/wiki/IntelliJ_IDEA_Setup) that should only take a few minutes & will make things so much easier compared to using something like notepad++

Thanks for the pointer on the IDE Ruddygreat!   8)   I was able to get the missileAI working / not complaining / not crashing the game.   I'm still a little lost on the correct implementation of the forceflameout command.   IntelliJ is useful indeed for the "hey this patch of code is no good"   ;D

Currently my fusion blaster onfire code is:

Code
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI;

public class FusionBlasterOnFireEffect implements OnFireEffectPlugin
{

    public static final float OVERLOADCHANCE = 10f;
public static final float FLAMEOUTCHANCE = 1f;

private ShipEngineControllerAPI shipengine;

public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
{
// Percentage chance (1 - 100)
int rndChance = (int)Math.round((Math.random() * 99)+ 1);

if (rndChance <= OVERLOADCHANCE)
{
// something here to get each engine, chance to flameout each one individually?

}

if (rndChance <= FLAMEOUTCHANCE)
{
ShipAPI ship = weapon.getShip();
//ship.ShipEngineControllerAPI.forceFlameout();     <--- this doesn't work
//ShipEngineAPI.forceFlameout();                          <--- this doesn't work either
}

}
}

So my current stumbling block is what is the proper command to tell my ship to flameout.

Also the reference for getShipEngines  just shows:

getShipEngines
java.util.List<ShipEngineControllerAPI.ShipEngineAPI> getShipEngines()

So It's unclear what the return value is.   My first guess is an array of the ship's engines?

EDIT:

Ok so I dug around in  ShipEngineControllerAPI.java   and it looks like it returns a list?

List<ShipEngineAPI> getShipEngines();

Is there an example of how to use this function to capture a list of engines?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ontheheavens on February 10, 2024, 09:16:04 PM
- I made my own loot event (with a showLoot() call). How do I change the image and text at the top left?

You can't, sorry - these are hardcoded. Not for any design reason, just for "had to get it done quickly at some point" reasons.

Any chance this stuff could get exposed in the near future?

Edit: is there any way we can modify maximum cargo of the campaign fleet? CargoData (class that implements CargoAPI) has setMaxCapacity(float), but I reckon it might be called each time fleet composition changes and fleet members contributing cargo capacity reshuffle.

Basically what I have in mind is some kind of buff/debuff that would modify maximum cargo either flatly or multiplicatively, irrespective of fleet member contributions. Would CargoData usage suffice for my purposes, or are there some non-obvious factors here?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 11, 2024, 12:23:56 PM
this isn't necessarily a modding question, but it is about the game in general - why is all of the rendering manually sorted into layers instead of using the depth buffer?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2024, 01:36:06 PM
Alex sorry to bother you, but it is possible to make ship to be able to shoot while venting? and if it doesnt, do you will add api that will allow it to happen next patch?

I don't think so and I don't think so - sorry! There's code pertaining to this in a bunch of places and I wouldn't want to mess with it (and likely break all sorts of things) without a compelling vanilla use case.


- I made my own loot event (with a showLoot() call). How do I change the image and text at the top left?

You can't, sorry - these are hardcoded. Not for any design reason, just for "had to get it done quickly at some point" reasons.

Any chance this stuff could get exposed in the near future?

Edit: is there any way we can modify maximum cargo of the campaign fleet? CargoData (class that implements CargoAPI) has setMaxCapacity(float), but I reckon it might be called each time fleet composition changes and fleet members contributing cargo capacity reshuffle.

Basically what I have in mind is some kind of buff/debuff that would modify maximum cargo either flatly or multiplicatively, irrespective of fleet member contributions. Would CargoData usage suffice for my purposes, or are there some non-obvious factors here?

See the Bulk Transport skill implementation. IIRC the only way to modify the cargo capacity of the fleet is to modify all the individual ships.

(Re: image/text for loot screen - maybe at some point, but being honest it's an extremely low priority item and there's tons of other things to do.)

this isn't necessarily a modding question, but it is about the game in general - why is all of the rendering manually sorted into layers instead of using the depth buffer?

It's a simpler not having to think about what the z-value needs to be all the time - and, importantly, not needing to pass in an extra z-value *at all* and being able to use glVertex2f etc. And also not needing to worry about z-fighting. And being able to keep the depth test off is nice, too, though that's probably not a big deal performance-wise. Basically using the depth test for this would just be an unnecessary pain. If the layering was difficult for some reason, there'd be some reason for it, but it's ... not.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 11, 2024, 02:40:29 PM
It's a simpler not having to think about what the z-value needs to be all the time - and, importantly, not needing to pass in an extra z-value *at all* and being able to use glVertex2f etc. And also not needing to worry about z-fighting. And being able to keep the depth test off is nice, too, though that's probably not a big deal performance-wise. Basically using the depth test for this would just be an unnecessary pain. If the layering was difficult for some reason, there'd be some reason for it, but it's ... not.

Ah yeah, that all makes sense. I was mostly thinking of it in the context of rendering stuff between ships & weapons, though manual sorting is way easier to work with for basically everything else.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 11, 2024, 07:49:53 PM
Gotcha, yeah.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on February 11, 2024, 11:33:23 PM
With some discord help I was able to get my code working for my fusion blaster.

Here it is in case anyone else can make use of it:

Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.ShipEngineControllerAPI.ShipEngineAPI;
import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI;

public class FusionBlasterOnFireEffect implements OnFireEffectPlugin
{

        public static final float OVERLOADCHANCE = 10f;
public static final float FLAMEOUTCHANCE = 1f;

private ShipEngineControllerAPI shipengine;

public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine)
{
ShipAPI ship = weapon.getShip();
// Percentage chance (1 - 100)
int rndChance = (int)Math.round((Math.random() * 99)+ 1);

if (rndChance <= OVERLOADCHANCE)
{
if (!ship.getEngineController().getShipEngines().isEmpty())
{
for(ShipEngineControllerAPI.ShipEngineAPI eachengine : ship.getEngineController().getShipEngines())
{
int rndChance2 = (int)Math.round((Math.random() * 99)+ 1);
if (rndChance2 <= 33)
{
eachengine.disable();
}
}
}
}

if (rndChance <= FLAMEOUTCHANCE)
{
ship.getEngineController().forceFlameout();
}
}
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Homete on February 12, 2024, 01:23:34 AM
Hi i have a question about using updateInteractionDataImpl(). So i was trying to have the data set so when i call the mission, it sets a random planet and gives its distance, star system and calls the map. but it does not call any and acts like nothing happens.

I am at a loss how to resolve this issue. Any help is appreciated.

(https://cdn.discordapp.com/attachments/1193674263010492458/1206499672273850368/image.png?ex=65dc3b61&is=65c9c661&hm=9bf4e40dd51ccd0fb0b22b88dfe2e7412bc302095d8a34ec4f88b7f62b5d191f&)

(https://cdn.discordapp.com/attachments/1193674263010492458/1206530700040347699/image.png?ex=65dc5847&is=65c9e347&hm=b8237c9068afe98f025aaaa1c8785840d68ebba00fa03ca520d3a565e310d339&)

Code
package data.campaign.missions;

import java.awt.Color;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepRewards;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch;
import com.fs.starfarer.api.ui.TooltipMakerAPI;

public class eusan_nation_penroseRecovery1 extends HubMissionWithSearch {

    public static enum Stage {
        LOCATE_PENROSE419,
        RETURN_BLACKBOX,
        COMPLETED
    }
   
    protected PersonAPI officer_yeong;
    protected PlanetAPI vineta;
    protected PlanetAPI target_planet;

    @Override
    protected boolean create(MarketAPI arg0, boolean arg1) {
        if(!setGlobalReference("$eusan_nation_penroseRecovery1_ref")){
            return false;
        }

        officer_yeong = getImportantPerson("eusan_nation_officer_yeong");
        vineta = (PlanetAPI) Global.getSector().getEntityById("eusan_nation_vineta");

        resetSearch();
        requirePlanetUnpopulated();
preferPlanetNotFullySurveyed();
preferPlanetInDirectionOfOtherMissions();
        preferPlanetWithoutRuins();
        preferPlanetNonGasGiant();
        preferSystemUnexplored();
        preferSystemNotPulsar();
        preferSystemNotBlackHole();

        target_planet = pickPlanet();

        if(officer_yeong == null){
            return false;
        }
        if (target_planet == null) {
return false;
}
        if(target_planet.isStar()){
            return false;
        }

        setStartingStage(Stage.LOCATE_PENROSE419);
        addSuccessStages(Stage.COMPLETED);

        setStoryMission();

        setStageOnGlobalFlag(Stage.RETURN_BLACKBOX, "$eusan_nation_penroseRecovery1_returnBlackbox");
        setStageOnGlobalFlag(Stage.COMPLETED, "$eusan_nation_penroseRecovery1_completed");

        makeImportant(target_planet, "$eusan_nation_penroseRecovery1_targetPlanet", Stage.LOCATE_PENROSE419);

        beginStageTrigger(Stage.RETURN_BLACKBOX);
        makeImportant(officer_yeong, "$eusan_nation_penroseRecovery1_returnBlackbox", Stage.RETURN_BLACKBOX);
        endTrigger();

        beginStageTrigger(Stage.COMPLETED);
        triggerSetGlobalMemoryValue("$eusan_nation_penroseRecovery1_completed", true);
        endTrigger();

        setCreditReward(100000);
        setRepRewardPerson(RepRewards.HIGH);
setRepRewardFaction(RepRewards.HIGH);

        //return false;
        return true;
    }

    protected void updateInteractionDataImpl(){
        set("$eusan_nation_penroseRecovery1_planetId", target_planet.getId());
        set("$eusan_nation_penroseRecovery1_planetName", target_planet.getName());
        set("$eusan_nation_penroseRecovery1_systemName", target_planet.getStarSystem().getNameWithNoType());
        set("$eusan_nation_penroseRecovery1_distanceLy", getDistanceLY(target_planet));
    }
   
    @Override
    public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height){
        float opad = 10f;
        if(currentStage == Stage.LOCATE_PENROSE419){
            info.addPara("A transponder signal has been detected by the Deep Space Antenna Array on Rotfront. It has been identified as the PENROSE-419. Recover the blackbox and any remains of the crew.", opad);
        }
        else if(currentStage == Stage.RETURN_BLACKBOX){
            info.addPara("Blackbox retrieved. Return the data to " + officer_yeong.getNameString() + ".", opad);
        }
    }

    @Override
    public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad){
        if(currentStage == Stage.LOCATE_PENROSE419){
            info.addPara("A transponder signal has been detected. Locate and recover the Penrose-419's blackbox and any remains of the crew if possible. The location has been determined to be at " + target_planet.getName() + " at the " + target_planet.getStarSystem().getNameWithNoType() + " system.", tc, pad);
            return true;
        }
        else if(currentStage == Stage.RETURN_BLACKBOX){
            info.addPara("Return to " + officer_yeong.getNameString() + ".", tc, pad);
        }
        return false;
    }

    @Override
    public String getBaseName() {
        return "Recover the mission data recorder from the PENROSE-419";
    }

    @Override
    public String getPostfixForState() {
        if (startingStage != null) {
            return "";
        }
        return super.getPostfixForState();
    }
}
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 12, 2024, 07:57:15 AM
So i was trying to have the data set so when i call the mission, it sets a random planet and gives its distance, star system and calls the map. but it does not call any and acts like nothing happens.
Not sure exactly what you're trying to do, but it sounds like you might want to use the ShowMapMarker command or dialog.getVisualPanel().showMapMarker(). Is there any vanilla mission that does what you're trying to do? If so it might be a good idea to try to copy the relevant parts from that mission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 12, 2024, 08:36:41 AM
Could the exception I reported here (https://fractalsoftworks.com/forum/index.php?topic=28984.msg425379#msg425379) ever be caused by returning a HashSet from IntelInfoPlugin.getIntelTags instead of a LinkedHashSet? Or maybe by failing to return a set with "Important" from an intel that returns true from isImportant()? I'm trying to verify that fixing these things prevents the CTD, but I still haven't managed to reproduce it. The stack trace makes it seem like something that would be caused by returning a set that includes null, but I don't see a way any of the mods I was using could've done that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on February 12, 2024, 11:03:20 AM
Used to be able to Extend from the "HyperspaceTerrainPlugin" to create my own terrain with Hyperspace like features, but since 0.97 doing so does no longer causes storms to be appear in the "nebula", any idea on what would cause this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 12, 2024, 01:43:48 PM
Could the exception I reported here (https://fractalsoftworks.com/forum/index.php?topic=28984.msg425379#msg425379) ever be caused by returning a HashSet from IntelInfoPlugin.getIntelTags instead of a LinkedHashSet? Or maybe by failing to return a set with "Important" from an intel that returns true from isImportant()? I'm trying to verify that fixing these things prevents the CTD, but I still haven't managed to reproduce it. The stack trace makes it seem like something that would be caused by returning a set that includes null, but I don't see a way any of the mods I was using could've done that.

Hmm, that doesn't sound likely - the LinkedHashSet, I mean. Are you able to get a stack trace of this with -RC8?

Used to be able to Extend from the "HyperspaceTerrainPlugin" to create my own terrain with Hyperspace like features, but since 0.97 doing so does no longer causes storms to be appear in the "nebula", any idea on what would cause this?

Storms only happen near the player's location, maybe that's what you're seeing? 0.97 did add some functionality - see: getStormCellTimeMultOutsideBaseArea() and related, used to make storms ramp up faster further away (used for when the player is traveling quickly i.e. via slipsurge to make the storms look natural when they arrive) but that shouldn't just make it not work for a derived class. I don't know, though; it's not a use case I've really thought about and it's a fairly coded-for-a-specific-purpose class (e.g. support for the Abyss is baked into it, now, also).
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 12, 2024, 02:49:58 PM
Could the exception I reported here (https://fractalsoftworks.com/forum/index.php?topic=28984.msg425379#msg425379) ever be caused by returning a HashSet from IntelInfoPlugin.getIntelTags instead of a LinkedHashSet? Or maybe by failing to return a set with "Important" from an intel that returns true from isImportant()? I'm trying to verify that fixing these things prevents the CTD, but I still haven't managed to reproduce it. The stack trace makes it seem like something that would be caused by returning a set that includes null, but I don't see a way any of the mods I was using could've done that.

Hmm, that doesn't sound likely - the LinkedHashSet, I mean. Are you able to get a stack trace of this with -RC8?
Ah, ok. Thanks for checking! I still haven't managed to reproduce it, sadly, but I'll keep trying/brainstorming. I'll let you know if I get a stack trace with RC8, but that might not be likely considering how rare this seems to be.
edit: When you said RC8 I thought you were referring to the latest (RC9). Pretty sure the stack trace I got *was* with RC8, but not 100%
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 12, 2024, 03:45:39 PM
My bad, I meant RC9, the latest. But, let me dig around a bit...

Edit: an RC9 stack trace wouldn't help, and it's unfortunately not real clear what might be causing this. I'm fairly sure that even returning null from getIntelTags() would be fine, though - but that might be worth checking/doing intentionally to see if it produces the same crash.

It's probably *some* intel method returning null that shouldn't be, but it's too open-ended in terms of the code where it crashes to really say much more. Sorry!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Sundog on February 12, 2024, 04:10:01 PM
No worries! Really appreciate you looking into it!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Matheld on February 14, 2024, 01:08:04 AM
Is there a mod or a setting anywhere that would allow me to tweak the spawn-rates of ship and hull blueprints? Industrial Evolution adds like a Engineering bay that can reverse engineer a ship to provide you the blueprint..  but it feels like blueprints spawn so frequently (from exploration and salvage) that by the time you get a colony up and running you kind of already have majority of blueprints. Making it kind of redundant.

And some mods have really expensive blueprints (looking at you UAF) that trading them in at the Prism spaceport (from nex) or even just selling them gives you a -bit- too much points and credits.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 14, 2024, 10:07:06 AM
drop_data.csv, but if there are other mods in play, you might have to edit theirs and they might have their own ways of doing stuff, so it'd be on a case-by-case basis.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on February 14, 2024, 11:35:16 AM
how did you put the administrator alpha core effect on Culann? I wanna replicate that for secret conspiratory Hegemony systems, to add a theme of hypocrisy amongst their ranks.

crossed out part, all of this is solved already, but keeping it in case you read it, and were writing a response as I'm writing this one. Happened before once.
Spoiler
EDIT: second important question... I did something like this [linked image]
I created a second system gen file to insert random systems I craft for the game. Will it all properly interact will all the other scripts in the game, or should I worry about something?
(the system generates properly, just don't want it to accidentally not be functional with some cool feature you add or something)


it actually doesn't work, be right back

Okay, I think I have a problem... How do you add systems easily into the game, so that even if it's updated with new systems, I don't accidentally... Destroy something??? Just pasting something on top... Is it possible to stack scripts? Never mind.
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Xerdies on February 14, 2024, 02:30:11 PM
This probably breaks a lot of mod guidelines, but I was wondering if someone could point me in the direction of how I can overwrite a standard api used in the game with my own.

My java knowledge is a little bit limited, and I don't even know the terms to google. In short - I would for example like to exchange in com.fs.starfarer.api.combat the Interface DamageAPI with my own, so that my version of it is called by everything, and not the standard one.

I think that's not playing nicely with other mods, but that's oki - I don't try to make something particularly "useable" - just goofing around. (I also don't want to overwrite the original files)

Where do I start with this?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on February 16, 2024, 04:17:02 AM
Does anyone know why this might not work? Ideally, this is a modification of the AI Core handover interaction in vanilla, but instead of cores, it's for handing over weapons. However, when I attempt to initiate it, instead the game just gives me an NPE. Is it because CargoPickerListener/showCargoPickerDialog doesn't work with weapons? Or something else? And how can I fix it?
Spoiler
public class DE_WeaponTradeTab extends BaseCommandPlugin {
   
   protected CampaignFleetAPI playerFleet;
   protected SectorEntityToken entity;
   protected FactionAPI playerFaction;
   protected FactionAPI entityFaction;
   protected TextPanelAPI text;
   protected OptionPanelAPI options;
   protected CargoAPI playerCargo;
   protected MemoryAPI memory;
   protected InteractionDialogAPI dialog;
   protected Map<String, MemoryAPI> memoryMap;
   protected PersonAPI person;
   protected FactionAPI faction;
   protected List<String> allowedweaponslist;
   protected float count;
   protected float reqcount;
   protected float overflowcount;
   protected float omegacap;
   protected boolean isomega;
   
   public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {

      this.dialog = dialog;
      this.memoryMap = memoryMap;

      String command = params.get(0).getString(memoryMap);
      if (command == null) return false;

      memory = getEntityMemory(memoryMap);

      entity = dialog.getInteractionTarget();
      text = dialog.getTextPanel();
      options = dialog.getOptionPanel();

      playerFleet = Global.getSector().getPlayerFleet();
      playerCargo = playerFleet.getCargo();

      playerFaction = Global.getSector().getPlayerFaction();
      entityFaction = entity.getFaction();

      person = dialog.getInteractionTarget().getActivePerson();
      faction = person.getFaction();

      if (command.equals("selectHegemonyWeapons")) {
         allowedweaponslist.add("lightneedler");
         allowedweaponslist.add("hveldriver");
         allowedweaponslist.add("heavymauler");
         allowedweaponslist.add("heavyneedler");
         allowedweaponslist.add("gauss");
         allowedweaponslist.add("multineedler");
         reqcount = memory.getInt("$Hegemonyweaponamount");
         selectWeapons();
      } else if (command.equals("selectPLWeapons")) {
         allowedweaponslist.add("gorgon");
         allowedweaponslist.add("gorgonpod");
         allowedweaponslist.add("gazer");
         allowedweaponslist.add("gazerpod");
         allowedweaponslist.add("dragon");
         allowedweaponslist.add("dragonpod");
         allowedweaponslist.add("hydra");
         reqcount = memory.getInt("$PLweaponamount");
         selectWeapons();
      } else if (command.equals("selectTTWeapons")) {
         allowedweaponslist.add("amblaster");
         allowedweaponslist.add("heavyblaster");
         allowedweaponslist.add("heavyburst");
         allowedweaponslist.add("ionpulser");
         allowedweaponslist.add("ionbeam");
         allowedweaponslist.add("plasma");
         allowedweaponslist.add("guardian");
         allowedweaponslist.add("tachyonlance");
         reqcount = memory.getInt("$TTweaponamount");
         selectWeapons();
      } else if (command.equals("selectOmegaWeapons")) {
         allowedweaponslist.add("minipulser");
         allowedweaponslist.add("shockrepeater");
         allowedweaponslist.add("riftlance");
         allowedweaponslist.add("riftbeam");
         allowedweaponslist.add("cryoflux");
         allowedweaponslist.add("cryoblaster");
         allowedweaponslist.add("disintegrator");
         allowedweaponslist.add("riftcascade");
         allowedweaponslist.add("vpdriver");
         allowedweaponslist.add("realitydisruptor");
         allowedweaponslist.add("amsrm");
         allowedweaponslist.add("resonatormrm");
         allowedweaponslist.add("rifttorpedo");
         reqcount = memory.getInt("$omegaweaponamount");
         omegacap = 2.0f;
         isomega = true;
         selectWeapons();
      }
      return true;
   }

   /*protected boolean personCanAcceptCores() {
      if (person == null || !buysAICores) return false;
      
      return Ranks.POST_BASE_COMMANDER.equals(person.getPostId()) ||
            Ranks.POST_STATION_COMMANDER.equals(person.getPostId()) ||
            Ranks.POST_ADMINISTRATOR.equals(person.getPostId()) ||
            Ranks.POST_OUTPOST_COMMANDER.equals(person.getPostId());
   }*/

   protected void selectWeapons() {
      CargoAPI copy = Global.getFactory().createCargo(false);
      //copy.addAll(cargo);
      //copy.setOrigSource(playerCargo);
      for (CargoStackAPI stack : playerCargo.getStacksCopy()) {
         WeaponSpecAPI spec = stack.getWeaponSpecIfWeapon();
         if (spec != null && allowedweaponslist.contains(spec.getWeaponId())) {//compare from a list and add anything inside
            copy.addFromStack(stack);
         }
      }
      copy.sort();

      final float width = 310f;
      dialog.showCargoPickerDialog("Select weapons to turn in", "Confirm", "Cancel", true, width, copy, new CargoPickerListener() {
         public void pickedCargo(CargoAPI cargo) {
            if (cargo.isEmpty()) {
               cancelledCargoSelection();
               return;
            }
            
            cargo.sort();
            for (CargoStackAPI stack : cargo.getStacksCopy()) {
               float canproceed = computeCountValue(cargo);
               if (!isomega) {
                  if (canproceed >= memory.getInt("$Hegemonyweaponamount")) {
                     //playerCargo.removeItems(stack.getType(), stack.getData(), stack.getSize());
                     playerCargo.removeWeapons(stack.getWeaponSpecIfWeapon().getWeaponId(), (int) stack.getSize());
                     if (stack.isWeaponStack()) { // should be always, but just in case
                        int num = (int) stack.getSize();
                        AddRemoveCommodity.addCommodityLossText(stack.getCommodityId(), num, text);
                        allowedweaponslist.clear();
                  /*String key = "$turnedIn_" + stack.getCommodityId();
                  int turnedIn = faction.getMemoryWithoutUpdate().getInt(key);
                  faction.getMemoryWithoutUpdate().set(key, turnedIn + num);

                  // Also, total of all cores! -dgb
                  String key2 = "$turnedIn_allCores";
                  int turnedIn2 = faction.getMemoryWithoutUpdate().getInt(key2);
                  faction.getMemoryWithoutUpdate().set(key2, turnedIn2 + num);*/
                     }
                  }
               } else {
                  if (canproceed >= memory.getInt("$Omegaweaponamount")) {
                     //playerCargo.removeItems(stack.getType(), stack.getData(), stack.getSize());
                     playerCargo.removeWeapons(stack.getWeaponSpecIfWeapon().getWeaponId(), (int) stack.getSize());
                     if (stack.isWeaponStack()) { // should be always, but just in case
                        int num = (int) stack.getSize();
                        AddRemoveCommodity.addCommodityLossText(stack.getCommodityId(), num, text);
                        allowedweaponslist.clear();
                     }
                  }
               }
            }

            float repChange = computeOverflowReputationValue(cargo);
            if (repChange >= 1f) {
               CustomRepImpact impact = new CustomRepImpact();
               impact.delta = repChange * 0.01f;
               Global.getSector().adjustPlayerReputation(
                     new RepActionEnvelope(RepActions.CUSTOM, impact,
                                      null, text, true),
                                      faction.getId());

               impact.delta *= 0.25f;
               if (impact.delta >= 0.01f) {
                  Global.getSector().adjustPlayerReputation(
                        new RepActionEnvelope(RepActions.CUSTOM, impact,
                                         null, text, true),
                                         person);
               }
            }
            FireBest.fire(null, dialog, memoryMap, "WeaponsTurnedIn");
         }
         public void cancelledCargoSelection() {
         }

         public void recreateTextPanel(TooltipMakerAPI panel, CargoAPI cargo, CargoStackAPI pickedUp, boolean pickedUpFromSource, CargoAPI combined) {

            //float bounty = computeCoreCreditValue(combined);
            //float repChange = computeCoreReputationValue(combined);

            float pad = 3f;
            float small = 5f;
            float opad = 10f;

            panel.setParaFontOrbitron();
            panel.addPara(Misc.ucFirst(faction.getDisplayName()), faction.getBaseUIColor(), 1f);
            //panel.addTitle(Misc.ucFirst(faction.getDisplayName()), faction.getBaseUIColor());
            //panel.addPara(faction.getDisplayNameLong(), faction.getBaseUIColor(), opad);
            //panel.addPara(faction.getDisplayName() + " (" + entity.getMarket().getName() + ")", faction.getBaseUIColor(), opad);
            panel.setParaFontDefault();

            panel.addImage(faction.getLogo(), width * 1f, 3f);
            panel.addPara("Giving Lucanus an excess amount of weapons will raise additional reputation with the Sindrian Diktat up to a maximum of 15, or 25 for Omega weapons.", opad);
            panel.beginGridFlipped(width, 1, 40f, 10f);
            //panel.beginGrid(150f, 1);
            panel.addGrid(pad);
         }
      });
   }

   protected float computeCountValue(CargoAPI cargo) {
      float count = 0;
      for (CargoStackAPI stack : cargo.getStacksCopy()) {
         WeaponSpecAPI spec = stack.getWeaponSpecIfWeapon();
         if (allowedweaponslist.contains(spec.getWeaponId())) {
            if (spec != null && spec.getSize().equals(WeaponAPI.WeaponSize.SMALL)) {
            count += 1 * stack.getSize();
            } else if (spec != null && spec.getSize().equals(WeaponAPI.WeaponSize.MEDIUM)) {
               count += 2 * stack.getSize();
            } else if (spec != null && spec.getSize().equals(WeaponAPI.WeaponSize.LARGE)) {
               count += 3 * stack.getSize();
            }
         }
      }
      return count;
   }

   protected float computeOverflowReputationValue(CargoAPI cargo) {
      float rep = 0;
      if (!isomega) {
         if (count > memory.getInt("$Hegemonyweaponamount")) {
            overflowcount = count - memory.getInt("$Hegemonyweaponamount");
            rep += overflowcount * omegacap;
            if (rep >= 15) { // cap the amount of rep so you cant farm lucanus for ez rep
               rep = 15 * omegacap;
            }
         }
      } else {
         if (count > memory.getInt("$Omegaweaponamount")) {
            overflowcount = count - memory.getInt("$Omegaweaponamount");
            rep += overflowcount * omegacap;
            if (rep >= 25) { // cap the amount of rep so you cant farm lucanus for ez rep
               rep = 25 * omegacap;
            }
         }
      }
      /*for (CargoStackAPI stack : cargo.getStacksCopy()) {
         WeaponSpecAPI spec = stack.getWeaponSpecIfWeapon();
         if (allowedweaponslist.contains(spec.getWeaponId())) {
            if (spec != null && spec.getSize().equals(WeaponAPI.WeaponSize.SMALL)) {
               rep += getBaseRepValue(spec.getId()) * stack.getSize();
            }
         }
      }*/
      //if (rep < 1f) rep = 1f;
      return rep;
   }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 16, 2024, 05:20:16 PM
Post the actual line that has the NPE, for starters.
Nex's Omega weapon offer uses a cargo picker dialog, so that much should work fine.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: JAL28 on February 17, 2024, 12:26:54 AM
Post the actual line that has the NPE, for starters.
Nex's Omega weapon offer uses a cargo picker dialog, so that much should work fine.
It’s not really a conventional NPE per se. The game doesn’t crash, it and the rule trigger perfectly fine. Rather, instead of opening the window, it just shows a red NullPointerException on the interaction screen. So I dunno if log will show a relevant error message(I’ll check later anyways jus to be sure though).

(EDIT: When I checked logs, there was in fact a 'crash log'; a warn that says that a null occured on line 89 of the aforemention pasted code. Not sure why that happened though.)
(EDIT2: Upon further inspection and testing, I realised the null was occurring when I attempted to put ids of weapons into "allowedweaponslist". Not really sure why that's happening, I assume it isn't allowed somehow? And how do I fix it, because I want to specifically limit the weapons one can trade to only a few weapon ids.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Uthred on February 18, 2024, 03:23:18 AM
Need help or direction in making a mod.
I want a mod where at the start of the game, when choosing your fleet, you have the option of a phase fleet, which has 1 Doom, 1 Revenant and 1 Phantom.

Any help would be helpful, I dont mind trying to make the mod myself.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: nathan67003 on February 18, 2024, 05:53:44 AM
Look into how vanilla does it? Shouldn't be very complex to then adapt it to suit your needs.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 18, 2024, 07:38:04 AM
(EDIT: When I checked logs, there was in fact a 'crash log'; a warn that says that a null occured on line 89 of the aforemention pasted code. Not sure why that happened though.)
(EDIT2: Upon further inspection and testing, I realised the null was occurring when I attempted to put ids of weapons into "allowedweaponslist". Not really sure why that's happening, I assume it isn't allowed somehow? And how do I fix it, because I want to specifically limit the weapons one can trade to only a few weapon ids.)
Going by the posted code:
allowedweaponslist hasn't been initialized before you try adding stuff to it (or, indeed, anywhere in the class), so that'll break.

Line 89 is memory.getInt("$omegaweaponamount");
If you haven't actually written $omegaweaponamount to the entity memory, that will also result in a null pointer.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 18, 2024, 03:35:47 PM
how did you put the administrator alpha core effect on Culann? I wanna replicate that for secret conspiratory Hegemony systems, to add a theme of hypocrisy amongst their ranks.

Take a look at People.java.


This probably breaks a lot of mod guidelines, but I was wondering if someone could point me in the direction of how I can overwrite a standard api used in the game with my own.

My java knowledge is a little bit limited, and I don't even know the terms to google. In short - I would for example like to exchange in com.fs.starfarer.api.combat the Interface DamageAPI with my own, so that my version of it is called by everything, and not the standard one.

I think that's not playing nicely with other mods, but that's oki - I don't try to make something particularly "useable" - just goofing around. (I also don't want to overwrite the original files)

Where do I start with this?

*This is the sort of thing where it *might* be barely possible for someone that really knows what they're doing, but it'd be pretty complicated and would require some very intimate java knowledge. I wouldn't recommend trying it, it seems like a pretty massive undertaking.)


Need help or direction in making a mod.
I want a mod where at the start of the game, when choosing your fleet, you have the option of a phase fleet, which has 1 Doom, 1 Revenant and 1 Phantom.

Any help would be helpful, I dont mind trying to make the mod myself.

Hmm, load up rules.csv in a spreadsheet editor (preferably google sheets, or possibly the rules-editing tool that's floating around on the forum), and look for "NGCAddShip".
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 18, 2024, 05:45:50 PM
Been looking at the new Colony Crises code and FleetGroupIntel. Wondering:

FGI spawns fleets immediately and never abstracts them like with normal route-managed fleets. Should I be concerned about performance if there are a bunch of large events going on at once (possibly more than a dozen, going by some screenshots I've seen)?

Is there a way to detect when a major crisis event fires or its FGI has been generated?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on February 19, 2024, 11:38:53 AM
hello again everyone. its me. again. with more questions and things.
1) is there a way to get the Strings contained within a given 'TooltipMakerAPI'?
2) is there a way to get the Strings from a given 'BaseIntelPlugin'? (pacifically, the text that would display on the right hand of the screen when you click on it)
thanks everyone who answered my questions in the past. I know sometimes my questions are weird.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Zisko on February 19, 2024, 12:15:13 PM
Hello, how can I stop the launcher from disabling my mods which are not flagged for current version? I know I can change the version in the json file, but dont want to do that with ~35 mods. Would be easier to just stop the game from disabling them everytime I start the game.
Thanks in advance!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on February 20, 2024, 12:34:16 AM
Is there any way to increase salary of individual administrator?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NeoLemon on February 20, 2024, 11:17:35 AM
how did you put the administrator alpha core effect on Culann? I wanna replicate that for secret conspiratory Hegemony systems, to add a theme of hypocrisy amongst their ranks.

Take a look at People.java.


This probably breaks a lot of mod guidelines, but I was wondering if someone could point me in the direction of how I can overwrite a standard api used in the game with my own.

My java knowledge is a little bit limited, and I don't even know the terms to google. In short - I would for example like to exchange in com.fs.starfarer.api.combat the Interface DamageAPI with my own, so that my version of it is called by everything, and not the standard one.

I think that's not playing nicely with other mods, but that's oki - I don't try to make something particularly "useable" - just goofing around. (I also don't want to overwrite the original files)

Where do I start with this?

*This is the sort of thing where it *might* be barely possible for someone that really knows what they're doing, but it'd be pretty complicated and would require some very intimate java knowledge. I wouldn't recommend trying it, it seems like a pretty massive undertaking.)


Need help or direction in making a mod.
I want a mod where at the start of the game, when choosing your fleet, you have the option of a phase fleet, which has 1 Doom, 1 Revenant and 1 Phantom.

Any help would be helpful, I dont mind trying to make the mod myself.

Hmm, load up rules.csv in a spreadsheet editor (preferably google sheets, or possibly the rules-editing tool that's floating around on the forum), and look for "NGCAddShip".

Hi alex, i want to ask few question

Been tinkering around fleetspawner, how do exactly vanilla scavenger fleet spawned on populated or unpopulated area? it is spawned the same way as lions guard fleet?
also how do you spawn specific kind of fleet size or type, indepedently from global faction ship quality/doctrine modifier?

Do it coded to spawn in system with junk/salvage belt on it?

 if its. then is there a tools to make "artificial" junk belt that counted as salvage cloud but cannot salvaged both by player or AI (just for trigger scav fleet spawn)

Or a way to make indepedent scav fleet to dock and using your colony as it return and starting base? i kinda want to have indepedent scav fleet that dock and circling around a colony, Thanks!

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 20, 2024, 08:59:47 PM
Hello everyone,

Here is Vladimir VV, I'm trying to make new star systems by mimicking the vanilla game way (just to get more familiar with how everything works).

So far, what I know is that the campaign/starmap file includes the positions of the systems on the large map, the campaign/econ file includes all the planet conditions and industry conditions we want, and scripts/world/systems folder contains the files including all the system entities we want. Then we can call the system generators in the ModPlugin file to generate the system. But how about the markets? I could generate administrators for each market in the ModPlugin file, but I don't know how the markets are generated.

I implemented a system using the knowledge I have, and it worked as expected, the system was generated at the expected spot with expected entities. But the markets were lost, for some reason the game ignored my campaign/econ file. Is there anyway to fix that? By the way, how about the colony administrators, is there any other simple way to add it besides using the ModPlugin file?

Any help would be appreciated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: LngA7Gw on February 20, 2024, 09:44:43 PM
Been tinkering around fleetspawner, how do exactly vanilla scavenger fleet spawned on populated or unpopulated area? it is spawned the same way as lions guard fleet?

Check out RuinsFleetRouteManager

Or a way to make indepedent scav fleet to dock and using your colony as it return and starting base? i kinda want to have indepedent scav fleet that dock and circling around a colony, Thanks!

Every market, including your own, already generates scavengers?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: NeoLemon on February 21, 2024, 04:36:51 AM
Been tinkering around fleetspawner, how do exactly vanilla scavenger fleet spawned on populated or unpopulated area? it is spawned the same way as lions guard fleet?

Check out RuinsFleetRouteManager

Or a way to make indepedent scav fleet to dock and using your colony as it return and starting base? i kinda want to have indepedent scav fleet that dock and circling around a colony, Thanks!

Every market, including your own, already generates scavengers?

Thanks! every market automatically generates your own scavenger? how to determine the size of scav fleet spawned on it?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 21, 2024, 11:41:56 AM
Hello everyone,

Here is Vladimir VV, I'm trying to make new star systems by mimicking the vanilla game way (just to get more familiar with how everything works).

So far, what I know is that the campaign/starmap file includes the positions of the systems on the large map, the campaign/econ file includes all the planet conditions and industry conditions we want, and scripts/world/systems folder contains the files including all the system entities we want. Then we can call the system generators in the ModPlugin file to generate the system. But how about the markets? I could generate administrators for each market in the ModPlugin file, but I don't know how the markets are generated.

I implemented a system using the knowledge I have, and it worked as expected, the system was generated at the expected spot with expected entities. But the markets were lost, for some reason the game ignored my campaign/econ file. Is there anyway to fix that? By the way, how about the colony administrators, is there any other simple way to add it besides using the ModPlugin file?

Any help would be appreciated.

OK, I found an answer myself. If anyone has similar question, here is a solution:

There is actually an economy.json file, we just need to add the system econ json file into that economy.json to let the game recognize it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 21, 2024, 12:50:44 PM
Been looking at the new Colony Crises code and FleetGroupIntel. Wondering:

FGI spawns fleets immediately and never abstracts them like with normal route-managed fleets. Should I be concerned about performance if there are a bunch of large events going on at once (possibly more than a dozen, going by some screenshots I've seen)?

Is there a way to detect when a major crisis event fires or its FGI has been generated?

It doesn't spawn them immediately - there is a single RouteData that simulates their movement, and it spawns *all* of the fleets when that RouteData is close enough to the player. From that point on, the fleets all stay spawned until the end.

Re: having a bunch of large events - possibly? It depends on if they're all in the same part of the map, how many fleets there are, etc. FGI is not really intended to handle *a lot* of stuff, not on the scale of say faction-faction warfare, especially in a scenario where there are many factions. But the only way to be sure is to test it out and see.

Re: how to detect - not sure, actually. I mean beyond stuff like checking for event progress and the presence of a new FGI etc.

(Sorry about taking a while to respond, btw!)


hello again everyone. its me. again. with more questions and things.
1) is there a way to get the Strings contained within a given 'TooltipMakerAPI'?
2) is there a way to get the Strings from a given 'BaseIntelPlugin'? (pacifically, the text that would display on the right hand of the screen when you click on it)
thanks everyone who answered my questions in the past. I know sometimes my questions are weird.

Not that I can think of. Those strings could be put together with code.

(I mean, one could take a created tooltip/intel item and inspect it with reflection etc, but that's beyond the scope of this thread.)

Hello, how can I stop the launcher from disabling my mods which are not flagged for current version? I know I can change the version in the json file, but dont want to do that with ~35 mods. Would be easier to just stop the game from disabling them everytime I start the game.
Thanks in advance!

There isn't a way, sorry.


Is there any way to increase salary of individual administrator?

See: Misc.getAdminSalary() - you *might* be able to set a different admin tier and provide a different salary value in settings.json. I'm not sure if a different tier value would break something else, though.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on February 21, 2024, 02:12:25 PM
I am using a reportPlayerOpenedMarket listener to check and prune excessive numbers of a certain type of ship from appearing in submarkets visited by the player. Removing ships from submarket.getCargo().getMothballedShips().getMembersListCopy() works, but the ship list won't update until the player leaves the planet and interacts with it again. Is there a way to update the mothballed ship list prior to the player opening the submarket screen?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 22, 2024, 03:42:56 AM
Hello everyone, I met another strange oproblem.

I was trying to add a storyline using rules.csv for one of my characters.

I created the character, set his id with a string in my ModPlugIn file. Let's say I set his Id using the code person.setId("tomas_kol"); (I didn't find any example of using setId and so I kinda went with my imaginations for this code, probably it's gonna be wrong).

Then I set his post Id and his rank Id using codes I copied from the vanilla game file. And I set him on a planet market. Let's say this planet market is A_market.

Everything in my rules.csv works just fine, I can locate the person by his PostId. (However I couldn't locate him using his Id, I don'tknow why) But at the very end of the storyline, when I'm about to modify the relation with this npc by completing the quest, and the game raises a null pointer exception. I called AdjustRepPerson tomas_kol COOPERATIVE 5 in the scripts column of my rules.csv file to raise relation.

I guess it's because somehow the person I created does not have the Id I want. (It should be tomas_kol)

Any ideas on how to deal with this bug? All suggestions will be appreciated!

BTW, I'm particularly interested in a compilation-free way. But just let me know if this problem must be solved with a jar file. Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 22, 2024, 02:01:32 PM
I am using a reportPlayerOpenedMarket listener to check and prune excessive numbers of a certain type of ship from appearing in submarkets visited by the player. Removing ships from submarket.getCargo().getMothballedShips().getMembersListCopy() works, but the ship list won't update until the player leaves the planet and interacts with it again. Is there a way to update the mothballed ship list prior to the player opening the submarket screen?

You might try doing this in reportPlayerOpenedMarket(), along with *maybe* calling updateCargoPrePlayerInteraction() there (if needed; not sure offhand if it would have already been called before then). This should happen before the UI is created, assuming that's the problem (which, honestly, not 100% sure, this is just off the top of my head).

Hello everyone, I met another strange oproblem.

I was trying to add a storyline using rules.csv for one of my characters.

I created the character, set his id with a string in my ModPlugIn file. Let's say I set his Id using the code person.setId("tomas_kol"); (I didn't find any example of using setId and so I kinda went with my imaginations for this code, probably it's gonna be wrong).

Then I set his post Id and his rank Id using codes I copied from the vanilla game file. And I set him on a planet market. Let's say this planet market is A_market.

Everything in my rules.csv works just fine, I can locate the person by his PostId. (However I couldn't locate him using his Id, I don'tknow why) But at the very end of the storyline, when I'm about to modify the relation with this npc by completing the quest, and the game raises a null pointer exception. I called AdjustRepPerson tomas_kol COOPERATIVE 5 in the scripts column of my rules.csv file to raise relation.

I guess it's because somehow the person I created does not have the Id I want. (It should be tomas_kol)

Any ideas on how to deal with this bug? All suggestions will be appreciated!

BTW, I'm particularly interested in a compilation-free way. But just let me know if this problem must be solved with a jar file. Thanks!

Just real quick - you probably need to add this person to Global.getSector().getImportantPeople(), and then the game would be able to find them by ID. See People.java for examples of this being done.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 22, 2024, 07:35:15 PM
I am using a reportPlayerOpenedMarket listener to check and prune excessive numbers of a certain type of ship from appearing in submarkets visited by the player. Removing ships from submarket.getCargo().getMothballedShips().getMembersListCopy() works, but the ship list won't update until the player leaves the planet and interacts with it again. Is there a way to update the mothballed ship list prior to the player opening the submarket screen?

You might try doing this in reportPlayerOpenedMarket(), along with *maybe* calling updateCargoPrePlayerInteraction() there (if needed; not sure offhand if it would have already been called before then). This should happen before the UI is created, assuming that's the problem (which, honestly, not 100% sure, this is just off the top of my head).

Hello everyone, I met another strange oproblem.

I was trying to add a storyline using rules.csv for one of my characters.

I created the character, set his id with a string in my ModPlugIn file. Let's say I set his Id using the code person.setId("tomas_kol"); (I didn't find any example of using setId and so I kinda went with my imaginations for this code, probably it's gonna be wrong).

Then I set his post Id and his rank Id using codes I copied from the vanilla game file. And I set him on a planet market. Let's say this planet market is A_market.

Everything in my rules.csv works just fine, I can locate the person by his PostId. (However I couldn't locate him using his Id, I don'tknow why) But at the very end of the storyline, when I'm about to modify the relation with this npc by completing the quest, and the game raises a null pointer exception. I called AdjustRepPerson tomas_kol COOPERATIVE 5 in the scripts column of my rules.csv file to raise relation.

I guess it's because somehow the person I created does not have the Id I want. (It should be tomas_kol)

Any ideas on how to deal with this bug? All suggestions will be appreciated!

BTW, I'm particularly interested in a compilation-free way. But just let me know if this problem must be solved with a jar file. Thanks!

Just real quick - you probably need to add this person to Global.getSector().getImportantPeople(), and then the game would be able to find them by ID. See People.java for examples of this being done.

Thank you Alex! It helps and solves my problem! Now I got two new problems.

The first is, I need to make a global boolean value to record whether this person is met or not. Like player.metSiyavong in the vanilla game. Do I need to create a new boolean method under the class of the object player? I don't think this idea is practible.

The second is, for some reason, after I add the person to Global.getSector().getImportantPeople(), everything works well, and the person has his sprite and visual as expected when I see him on the stations. But when I tried to call ShowPersonVisual after calling ShowImageVisual tomas_kol, nothing happens. Do I need to undo the ShowImageVisual first, or is it just there is something wrong with the ShowImageVisual? I didn't find any example about doing this.

Would you please let me know whether you have any suggestions? Thank you very much!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 23, 2024, 09:13:40 AM
Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: minno on February 23, 2024, 01:10:57 PM
Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 23, 2024, 07:44:35 PM
The first is, I need to make a global boolean value to record whether this person is met or not. Like player.metSiyavong in the vanilla game. Do I need to create a new boolean method under the class of the object player? I don't think this idea is practible.

Take a look at MemoryAPI in the javadoc.
https://fractalsoftworks.com/forum/index.php?topic=7164.0

You can access the $global memory using Global.getSector().getMemoryWithoutUpdate().

The second is, for some reason, after I add the person to Global.getSector().getImportantPeople(), everything works well, and the person has his sprite and visual as expected when I see him on the stations. But when I tried to call ShowPersonVisual after calling ShowImageVisual tomas_kol, nothing happens. Do I need to undo the ShowImageVisual first, or is it just there is something wrong with the ShowImageVisual? I didn't find any example about doing this.

Ah - you want to use ShowPersonVisual instead.

ShowPersonVisual <true or false> <person id>

The second parameter is whether it'll also show the faction flag/relationship bar, iirc.


Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

I'm not actually sure which sound you mean. IIRC missile engines don't play a sound when they flame out? And they also don't play a sound when they fade out.


Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.

Ah, sorry, this calcualtion is done in core code somewhere. If you look for a flat modifier with id "core_base" you could probably get its value from MarketAPI.getAccessibilityMod().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tranquility on February 23, 2024, 09:11:15 PM
I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

rules.csv Condition for a PopulateOptions trigger (Highlighted is the problem condition)
$isPerson
$personFaction.id == adversary
$player.fcm_faction == adversary
Commission personCanGiveCommission
!$player.defeatedAdversaryAttack
!$global.adversary_mt_ref
[close]
In Devmode, after going through my dialogue, triggering the script, and then dumping the memory, I can see it clearly as $global.adversary_mt_ref = MutualTenacityScript@[object #], but, for whatever reason (and this is my guess), the !$global.adversary_mt_ref condition still thinks that that memory key doesn't exist, making the condition always true when I expect it to be false at that point. All other conditions seem to work fine, and, from what I can find, the other times I used !$global.[memKey] to check for global memory keys had worked as intended. It's only that !$global.adversary_mt_ref condition check that isn't working as I thought it would.

If this is an unsupported feature (or just user error), what would be the intended solution for checking memory keys containing a non-boolean object in rules.csv?

(Oh, and I used the PiracyRespiteScript.java, which contains "$prf_ref" as its key, as a reference for my own script. I didn't see its memory key get used anywhere in the vanilla rules.csv, though, so there wasn't anything else I could fall back on for help with this problem.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 24, 2024, 09:18:25 AM
The first is, I need to make a global boolean value to record whether this person is met or not. Like player.metSiyavong in the vanilla game. Do I need to create a new boolean method under the class of the object player? I don't think this idea is practible.

Take a look at MemoryAPI in the javadoc.
https://fractalsoftworks.com/forum/index.php?topic=7164.0

You can access the $global memory using Global.getSector().getMemoryWithoutUpdate().

The second is, for some reason, after I add the person to Global.getSector().getImportantPeople(), everything works well, and the person has his sprite and visual as expected when I see him on the stations. But when I tried to call ShowPersonVisual after calling ShowImageVisual tomas_kol, nothing happens. Do I need to undo the ShowImageVisual first, or is it just there is something wrong with the ShowImageVisual? I didn't find any example about doing this.

Ah - you want to use ShowPersonVisual instead.

ShowPersonVisual <true or false> <person id>

The second parameter is whether it'll also show the faction flag/relationship bar, iirc.


Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

I'm not actually sure which sound you mean. IIRC missile engines don't play a sound when they flame out? And they also don't play a sound when they fade out.


Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.

Ah, sorry, this calcualtion is done in core code somewhere. If you look for a flat modifier with id "core_base" you could probably get its value from MarketAPI.getAccessibilityMod().

Thank you! Alex, your suggestions worked!

By the way, I think Originem was talking about the situation when the missiles travel longer than their projectile life time, and blow themselves into dusts. It'll make a sound that sounds like a low blow sound of "pang". I guess it's the sound when the projectile getting destroyed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on February 24, 2024, 09:23:09 AM
Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

(and vladimirvv and alex)

that's added by graphicslib, you'll need to add the missile to it's no debris whitelist csv
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: minno on February 24, 2024, 12:31:37 PM
Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.

Ah, sorry, this calcualtion is done in core code somewhere. If you look for a flat modifier with id "core_base" you could probably get its value from MarketAPI.getAccessibilityMod().

That doesn't seem to work. planet.getMarket().getAccessibilityMod().getFlatBonus("core_base") gives me null. planet.getMarket().getAccessibilityMod().computeEffective(0f) gives me just 0, 0.1, or -0.1 depending on if it has high/low gravity, so it doesn't look like that modifier is in there.

I found a workaround, though. The accessibility bonus when only the vanilla core worlds are populated is pretty much determined by distance from Askonia, which is easy enough to look up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 24, 2024, 02:03:57 PM
Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

(and vladimirvv and alex)

that's added by graphicslib, you'll need to add the missile to it's no debris whitelist csv

Thank you!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 24, 2024, 02:10:22 PM
Hi everyone, I'm back with some silly questions,

After succesfully creating my character, and adding all the dialogues, I want to make him a contact to offer some missions.

Everything worked fine as I mimick the vanilla game. But when I was trying to let him offer military bounties, something weird happens and I don't know how to solve.

So I copied the MilitaryCustomBounty file, coded it properly so that things worked out. The person offers military bounties and I can take the mission, the bounties worked jut fine.

But I can't see anything regarding the bounty information in the dialogue. I believe I'm missing some files corresponding to $mcb_ref showBountyDetail and $mcb_ref showBountyAssessment in the rules.csv. But I can't find any class called mcb_ref or any methods in the starfarer.api so far. I may also be missing the triggers. Currently I'm using my own bounty creater names as triggers, but I don't know how to define new triggers, is there any examples about doing that? And in general, my guesses could all be wrong, please let me know what am I missing if that does happen.

I also met another problem I can't solve.

Question 2: I defined a custom bounty following the vanilla CBRemnantPlus.java file, and the starsector.log tells me that the following code is problematic:      

      picker.add("tesseract_Attack");
      picker.add("tesseract_Attack2");
      picker.add("tesseract_Strike");
      picker.add("tesseract_Disruptor");
      fleet.getFleetData().addFleetMember(picker.pick());

It says: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public abstract void com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(com.fs.starfarer.api.fleet.FleetMemberAPI)", "public abstract com.fs.starfarer.api.fleet.FleetMemberAPI com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(java.lang.String)"

Similar reports to the code:

      int i = data.fleet.getFleetData().getMembersListCopy().size() - 1;
      FleetMemberAPI last = data.fleet.getFleetData().getMembersListCopy().get(i);
      data.fleet.getFleetData().removeFleetMember(last);

It seems that somehow the picker.pick() does something wrong, the object class for its return gets lost. And the data.fleet goes wrong. If I avoid using the picker.pick() method at all, and I don't use data.fleet.getFleetData().getMembersListCopy().get() method at all, then the code runs fine. Now I'm even more confused. The following are all my imports:

package data.scripts.campaign.intel.missions;

import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.AICoreOfficerPlugin;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.campaign.FleetDataAPI;
import com.fs.starfarer.api.impl.campaign.missions.cb.BaseCustomBountyCreator;
import com.fs.starfarer.api.impl.campaign.missions.cb.CBStats;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
import com.fs.starfarer.api.impl.campaign.ids.Skills;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithBarEvent;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetQua lity;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetSiz e;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerN um;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerQ uality;
import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
import com.fs.starfarer.api.loading.VariantSource;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;

This is strange, is it because I forgot some imports? I didn't use a compiler and I don't have any .jar files, because I want to get more familiar with how the vanilla game works.

Please let me know, any help will be greatly appreciated!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tranquility on February 24, 2024, 07:45:05 PM
I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

...

While I'm still waiting for a response to this, I actually do have another, more general question to ask. What's the recommended way to seamlessly add a modded Colony Crisis into the game. So far, I just have this to spawn in the crisis for my faction during a game load:

Code: java
    @Override
    public void onGameLoad(boolean newGame) {
        # stuff
        addAdversaryColonyCrisis();
        # stuff
    }

    private void addAdversaryColonyCrisis() {
        HostileActivityEventIntel intel = HostileActivityEventIntel.get();
        if (intel != null && intel.getActivityOfClass(AdversaryHostileActivityFactor.class) == null) {
            AdversaryHostileActivityFactor adversaryFactor = new AdversaryHostileActivityFactor(intel);
            intel.addActivity(adversaryFactor, new AdversaryActivityCause(intel));
            intel.addActivity(adversaryFactor, new AdversaryActivityCause2(intel));
        }
    }
But that means if the Colony Crisis intel gets added mid-game, the custom Crisis will not get put in too (and, thus, not contribute towards the event) unless the game was saved and then reloaded. Also, if the CC intel gets removed (due to losing all colonies at once) and then gets added back in, the custom Crisis will temporarily disappear until yet another save reload. Not exactly the biggest deal for what I've planned with my faction, but, if possible, I'd appreciate a way to avoid those edge cases and cleanly implement a custom Colony Crisis.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 25, 2024, 01:59:25 PM
I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

rules.csv Condition for a PopulateOptions trigger (Highlighted is the problem condition)
$isPerson
$personFaction.id == adversary
$player.fcm_faction == adversary
Commission personCanGiveCommission
!$player.defeatedAdversaryAttack
!$global.adversary_mt_ref
[close]
In Devmode, after going through my dialogue, triggering the script, and then dumping the memory, I can see it clearly as $global.adversary_mt_ref = MutualTenacityScript@[object #], but, for whatever reason (and this is my guess), the !$global.adversary_mt_ref condition still thinks that that memory key doesn't exist, making the condition always true when I expect it to be false at that point. All other conditions seem to work fine, and, from what I can find, the other times I used !$global.[memKey] to check for global memory keys had worked as intended. It's only that !$global.adversary_mt_ref condition check that isn't working as I thought it would.

If this is an unsupported feature (or just user error), what would be the intended solution for checking memory keys containing a non-boolean object in rules.csv?

(Oh, and I used the PiracyRespiteScript.java, which contains "$prf_ref" as its key, as a reference for my own script. I didn't see its memory key get used anywhere in the vanilla rules.csv, though, so there wasn't anything else I could fall back on for help with this problem.)

Hi Tranquility, I think I can solve this. It seems to me that you are not using the right codes. For a variable, say $x (for simplicity), the condition !$x written in the rules means "Assuming that $x is a boolean variable, and if its value is false, then this condition is true". I would not suggest using the method !$x in rules.csv if $x is not boolean, because according to my experiences, it seems that the !$x treats non-boolean variables $x or null variables $x as if they were false boolean values by default. I would suggest defining a function that takes value of $global.adversary_mt_ref, examines whether it's null, and returns another global boolean value $result. Then you may use !$result in rules.csv.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 25, 2024, 02:16:44 PM
I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

...

While I'm still waiting for a response to this, I actually do have another, more general question to ask. What's the recommended way to seamlessly add a modded Colony Crisis into the game. So far, I just have this to spawn in the crisis for my faction during a game load:

Code: java
    @Override
    public void onGameLoad(boolean newGame) {
        # stuff
        addAdversaryColonyCrisis();
        # stuff
    }

    private void addAdversaryColonyCrisis() {
        HostileActivityEventIntel intel = HostileActivityEventIntel.get();
        if (intel != null && intel.getActivityOfClass(AdversaryHostileActivityFactor.class) == null) {
            AdversaryHostileActivityFactor adversaryFactor = new AdversaryHostileActivityFactor(intel);
            intel.addActivity(adversaryFactor, new AdversaryActivityCause(intel));
            intel.addActivity(adversaryFactor, new AdversaryActivityCause2(intel));
        }
    }
But that means if the Colony Crisis intel gets added mid-game, the custom Crisis will not get put in too (and, thus, not contribute towards the event) unless the game was saved and then reloaded. Also, if the CC intel gets removed (due to losing all colonies at once) and then gets added back in, the custom Crisis will temporarily disappear until yet another save reload. Not exactly the biggest deal for what I've planned with my faction, but, if possible, I'd appreciate a way to avoid those edge cases and cleanly implement a custom Colony Crisis.

Hi Tranquility,I believe you may add the custom colony crisis in new game, or together with sector creation, make it sleep. Then create a global boolean variable (or maybe a set of global boolean values) to keep track of the hostility intel, set it to false in the beginning, and use this global boolean value to determine whether your colony crisis should sleep or not. I think it's just easier to split this task of adding a colony crisis in two parts, instead of trying to do everything at once.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Tranquility on February 25, 2024, 03:46:50 PM
...

Hi Tranquility, I think I can solve this. It seems to me that you are not using the right codes. For a variable, say $x (for simplicity), the condition !$x written in the rules means "Assuming that $x is a boolean variable, and if its value is false, then this condition is true". I would not suggest using the method !$x in rules.csv if $x is not boolean, because according to my experiences, it seems that the !$x treats non-boolean variables $x or null variables $x as if they were false boolean values by default. I would suggest defining a function that takes value of $global.adversary_mt_ref, examines whether it's null, and returns another global boolean value $result. Then you may use !$result in rules.csv.

Hi, I ended up just making a custom BaseCommandPlugin class - that I can call in rules.csv - to address both my original issue and other issues that I came about since then. Kinda unfortunate that, as you said, !$x still treats non-boolean variables as false, but I did manage to work around that limitation anyways. Appreciate the help, though!

...

Hi Tranquility,I believe you may add the custom colony crisis in new game, or together with sector creation, make it sleep. Then create a global boolean variable (or maybe a set of global boolean values) to keep track of the hostility intel, set it to false in the beginning, and use this global boolean value to determine whether your colony crisis should sleep or not. I think it's just easier to split this task of adding a colony crisis in two parts, instead of trying to do everything at once.

I'm not too sure on what you meant here, but, to clarify further, I basically wanted a way to effectively "attach" the custom Colony Crisis script to the main Colony Crisis intel object whenever the main CC intel gets created, as to avoid needing to do continuous and/or redundant checks (like making a custom EveryFrameScript, using the ModPlugin load() methods, having an unrelated listener run the script occasionally, etc.) if said CC intel doesn't exist or gets removed mid-game. If there isn't an "official" way to do this (i.e. nothing in the API that would allow for running scripts when the CC intel starts existing), I would either have to make a custom listener that runs whenever the CC intel gets created, or just have the custom script also run continuously on one of my existing listeners and call it a day - which, ok, not perfect, but an improvement over running it only a single time with onGameLoad().
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 25, 2024, 05:23:05 PM
(and vladimirvv and alex)

that's added by graphicslib, you'll need to add the missile to it's no debris whitelist csv
Oh thanks! I even didn't notice that!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 26, 2024, 03:33:14 AM
Is there any way to get missile's id from WeaponAPI?
There is no getId in MissileSpecAPI....
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 26, 2024, 08:01:36 AM
Is there any way to get missile's id from WeaponAPI?
There is no getId in MissileSpecAPI....

If you want to get the Id of the weapon that launches your missile, maybe you want to try method getProjectileSpecId() from DamagingProjectileAPI.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 26, 2024, 06:37:29 PM
Hi everyone, I'm back with some silly questions,

After succesfully creating my character, and adding all the dialogues, I want to make him a contact to offer some missions.

Everything worked fine as I mimick the vanilla game. But when I was trying to let him offer military bounties, something weird happens and I don't know how to solve.

So I copied the MilitaryCustomBounty file, coded it properly so that things worked out. The person offers military bounties and I can take the mission, the bounties worked jut fine.

But I can't see anything regarding the bounty information in the dialogue. I believe I'm missing some files corresponding to $mcb_ref showBountyDetail and $mcb_ref showBountyAssessment in the rules.csv. But I can't find any class called mcb_ref or any methods in the starfarer.api so far. I may also be missing the triggers. Currently I'm using my own bounty creater names as triggers, but I don't know how to define new triggers, is there any examples about doing that? And in general, my guesses could all be wrong, please let me know what am I missing if that does happen.

I also met another problem I can't solve.

Question 2: I defined a custom bounty following the vanilla CBRemnantPlus.java file, and the starsector.log tells me that the following code is problematic:      

      picker.add("tesseract_Attack");
      picker.add("tesseract_Attack2");
      picker.add("tesseract_Strike");
      picker.add("tesseract_Disruptor");
      fleet.getFleetData().addFleetMember(picker.pick());

It says: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public abstract void com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(com.fs.starfarer.api.fleet.FleetMemberAPI)", "public abstract com.fs.starfarer.api.fleet.FleetMemberAPI com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(java.lang.String)"

Similar reports to the code:

      int i = data.fleet.getFleetData().getMembersListCopy().size() - 1;
      FleetMemberAPI last = data.fleet.getFleetData().getMembersListCopy().get(i);
      data.fleet.getFleetData().removeFleetMember(last);

It seems that somehow the picker.pick() does something wrong, the object class for its return gets lost. And the data.fleet goes wrong. If I avoid using the picker.pick() method at all, and I don't use data.fleet.getFleetData().getMembersListCopy().get() method at all, then the code runs fine. Now I'm even more confused. The following are all my imports:

package data.scripts.campaign.intel.missions;

import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.AICoreOfficerPlugin;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.campaign.FleetDataAPI;
import com.fs.starfarer.api.impl.campaign.missions.cb.BaseCustomBountyCreator;
import com.fs.starfarer.api.impl.campaign.missions.cb.CBStats;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
import com.fs.starfarer.api.impl.campaign.ids.Skills;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithBarEvent;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetQua lity;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetSiz e;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerN um;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerQ uality;
import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
import com.fs.starfarer.api.loading.VariantSource;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;

This is strange, is it because I forgot some imports? I didn't use a compiler and I don't have any .jar files, because I want to get more familiar with how the vanilla game works.

Please let me know, any help will be greatly appreciated!

I'm still stuck at these problems, and mean while i did some experiments to find some clues. After I see the results, I'm even more confused than I was. So the following are what I did:

1-I changed the mission name to mcb in the person_mission csv file instead of my faction's special mcb name, call it tomas_mcb
2-I changes everything in my rules csv accordingly, directly copying from vanilla rules.csv for the mcb rule lines, and added some conditions, changed the rules id, as if I have made a new voice for the vanilla mcb mission.

Then it magically worked, a lot of mcb variables that were not there when I was using my alternative version of the custom bounty file were created. And I don't know why by adding a condition to the person_mission csv file in my mod that says id: mcb, conditions: id == tomas_kol would not block other npc's from offering mcb bounties. I thought it would. I don't know why this would work, I don't know why my version didn't work, and I'm just more confused.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 27, 2024, 11:58:22 AM
(Augh, sorry for not responding for a while here! Got sidetracked, and also, after the thread has been stickied, I keep not seeing it - just not used to where to look, still.)

I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

rules.csv Condition for a PopulateOptions trigger (Highlighted is the problem condition)
$isPerson
$personFaction.id == adversary
$player.fcm_faction == adversary
Commission personCanGiveCommission
!$player.defeatedAdversaryAttack
!$global.adversary_mt_ref
[close]
In Devmode, after going through my dialogue, triggering the script, and then dumping the memory, I can see it clearly as $global.adversary_mt_ref = MutualTenacityScript@[object #], but, for whatever reason (and this is my guess), the !$global.adversary_mt_ref condition still thinks that that memory key doesn't exist, making the condition always true when I expect it to be false at that point. All other conditions seem to work fine, and, from what I can find, the other times I used !$global.[memKey] to check for global memory keys had worked as intended. It's only that !$global.adversary_mt_ref condition check that isn't working as I thought it would.

If this is an unsupported feature (or just user error), what would be the intended solution for checking memory keys containing a non-boolean object in rules.csv?

(Oh, and I used the PiracyRespiteScript.java, which contains "$prf_ref" as its key, as a reference for my own script. I didn't see its memory key get used anywhere in the vanilla rules.csv, though, so there wasn't anything else I could fall back on for help with this problem.)

Yeah, the ! (not) operator is not going to work to check for the existence of a key like this. Generally when vanilla goes this sort of thing, the reference is a mission or some other type of CallableEvent, so using Call $<ref> <action id> would return false if the reference is not set.

You could also create your own custom rule command - ah, I see you already did that. Nice!

For the next release, I've made it so that the == null check works. != null already works, by the way.



But I can't see anything regarding the bounty information in the dialogue. I believe I'm missing some files corresponding to $mcb_ref showBountyDetail and $mcb_ref showBountyAssessment in the rules.csv. But I can't find any class called mcb_ref or any methods in the starfarer.api so far. I may also be missing the triggers. Currently I'm using my own bounty creater names as triggers, but I don't know how to define new triggers, is there any examples about doing that? And in general, my guesses could all be wrong, please let me know what am I missing if that does happen.

$mcb_ref is a reference to the MilitaryCustomBounty mission. That class extends BaseCustomBounty, and that has a callAction() method that handles these calls.



Question 2: I defined a custom bounty following the vanilla CBRemnantPlus.java file, and the starsector.log tells me that the following code is problematic:      

      picker.add("tesseract_Attack");
      picker.add("tesseract_Attack2");
      picker.add("tesseract_Strike");
      picker.add("tesseract_Disruptor");
      fleet.getFleetData().addFleetMember(picker.pick());

It says: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public abstract void com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(com.fs.starfarer.api.fleet.FleetMemberAPI)", "public abstract com.fs.starfarer.api.fleet.FleetMemberAPI com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(java.lang.String)"

Have you set up an IDE? There are some instructions for how to do this floating around on the forum and on the wiki. At this point, it sounds like you would save some time by doing this, as - when set up properly - a dev environment would catch these sorts of things for you immediately, and point you to what you need to do.


But that means if the Colony Crisis intel gets added mid-game, the custom Crisis will not get put in too (and, thus, not contribute towards the event) unless the game was saved and then reloaded. Also, if the CC intel gets removed (due to losing all colonies at once) and then gets added back in, the custom Crisis will temporarily disappear until yet another save reload. Not exactly the biggest deal for what I've planned with my faction, but, if possible, I'd appreciate a way to avoid those edge cases and cleanly implement a custom Colony Crisis.

Hmm, you're right, actually. For the moment you'd probably want to set up a script that uses an IntervalUtil to run these checks every few seconds.

Made a note to add a completely clean way of doing this.

Is there any way to get missile's id from WeaponAPI?
There is no getId in MissileSpecAPI....

MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:


1-I changed the mission name to mcb in the person_mission csv file instead of my faction's special mcb name, call it tomas_mcb
2-I changes everything in my rules csv accordingly, directly copying from vanilla rules.csv for the mcb rule lines, and added some conditions, changed the rules id, as if I have made a new voice for the vanilla mcb mission.

Then it magically worked, a lot of mcb variables that were not there when I was using my alternative version of the custom bounty file were created. And I don't know why by adding a condition to the person_mission csv file in my mod that says id: mcb, conditions: id == tomas_kol would not block other npc's from offering mcb bounties. I thought it would. I don't know why this would work, I don't know why my version didn't work, and I'm just more confused.

This sounds like changing the mission id to "mcb" is making use of some vanilla rules that you maybe didn't have duplicated for your specific mission? I'd be concerned that this may only seem to be working and something else might've broken. For example, if the mission id is mcb now, you've *replaced* the vanilla mcb mission with yours!

In particular also if variables were missing make sure about calling Call $mcb_ref updateData in your "conditions" column.

But, honestly, it's hard to say exactly what's going on here; I don't really have a full overview and it's hard to take in that much info at a glance. If I might suggest more bite-size increments, making things work one step at a time?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 27, 2024, 01:55:53 PM
(Augh, sorry for not responding for a while here! Got sidetracked, and also, after the thread has been stickied, I keep not seeing it - just not used to where to look, still.)

I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

rules.csv Condition for a PopulateOptions trigger (Highlighted is the problem condition)
$isPerson
$personFaction.id == adversary
$player.fcm_faction == adversary
Commission personCanGiveCommission
!$player.defeatedAdversaryAttack
!$global.adversary_mt_ref
[close]
In Devmode, after going through my dialogue, triggering the script, and then dumping the memory, I can see it clearly as $global.adversary_mt_ref = MutualTenacityScript@[object #], but, for whatever reason (and this is my guess), the !$global.adversary_mt_ref condition still thinks that that memory key doesn't exist, making the condition always true when I expect it to be false at that point. All other conditions seem to work fine, and, from what I can find, the other times I used !$global.[memKey] to check for global memory keys had worked as intended. It's only that !$global.adversary_mt_ref condition check that isn't working as I thought it would.

If this is an unsupported feature (or just user error), what would be the intended solution for checking memory keys containing a non-boolean object in rules.csv?

(Oh, and I used the PiracyRespiteScript.java, which contains "$prf_ref" as its key, as a reference for my own script. I didn't see its memory key get used anywhere in the vanilla rules.csv, though, so there wasn't anything else I could fall back on for help with this problem.)

Yeah, the ! (not) operator is not going to work to check for the existence of a key like this. Generally when vanilla goes this sort of thing, the reference is a mission or some other type of CallableEvent, so using Call $<ref> <action id> would return false if the reference is not set.

You could also create your own custom rule command - ah, I see you already did that. Nice!

For the next release, I've made it so that the == null check works. != null already works, by the way.



But I can't see anything regarding the bounty information in the dialogue. I believe I'm missing some files corresponding to $mcb_ref showBountyDetail and $mcb_ref showBountyAssessment in the rules.csv. But I can't find any class called mcb_ref or any methods in the starfarer.api so far. I may also be missing the triggers. Currently I'm using my own bounty creater names as triggers, but I don't know how to define new triggers, is there any examples about doing that? And in general, my guesses could all be wrong, please let me know what am I missing if that does happen.

$mcb_ref is a reference to the MilitaryCustomBounty mission. That class extends BaseCustomBounty, and that has a callAction() method that handles these calls.



Question 2: I defined a custom bounty following the vanilla CBRemnantPlus.java file, and the starsector.log tells me that the following code is problematic:      

      picker.add("tesseract_Attack");
      picker.add("tesseract_Attack2");
      picker.add("tesseract_Strike");
      picker.add("tesseract_Disruptor");
      fleet.getFleetData().addFleetMember(picker.pick());

It says: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public abstract void com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(com.fs.starfarer.api.fleet.FleetMemberAPI)", "public abstract com.fs.starfarer.api.fleet.FleetMemberAPI com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(java.lang.String)"

Have you set up an IDE? There are some instructions for how to do this floating around on the forum and on the wiki. At this point, it sounds like you would save some time by doing this, as - when set up properly - a dev environment would catch these sorts of things for you immediately, and point you to what you need to do.


But that means if the Colony Crisis intel gets added mid-game, the custom Crisis will not get put in too (and, thus, not contribute towards the event) unless the game was saved and then reloaded. Also, if the CC intel gets removed (due to losing all colonies at once) and then gets added back in, the custom Crisis will temporarily disappear until yet another save reload. Not exactly the biggest deal for what I've planned with my faction, but, if possible, I'd appreciate a way to avoid those edge cases and cleanly implement a custom Colony Crisis.

Hmm, you're right, actually. For the moment you'd probably want to set up a script that uses an IntervalUtil to run these checks every few seconds.

Made a note to add a completely clean way of doing this.

Is there any way to get missile's id from WeaponAPI?
There is no getId in MissileSpecAPI....

MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:


1-I changed the mission name to mcb in the person_mission csv file instead of my faction's special mcb name, call it tomas_mcb
2-I changes everything in my rules csv accordingly, directly copying from vanilla rules.csv for the mcb rule lines, and added some conditions, changed the rules id, as if I have made a new voice for the vanilla mcb mission.

Then it magically worked, a lot of mcb variables that were not there when I was using my alternative version of the custom bounty file were created. And I don't know why by adding a condition to the person_mission csv file in my mod that says id: mcb, conditions: id == tomas_kol would not block other npc's from offering mcb bounties. I thought it would. I don't know why this would work, I don't know why my version didn't work, and I'm just more confused.

This sounds like changing the mission id to "mcb" is making use of some vanilla rules that you maybe didn't have duplicated for your specific mission? I'd be concerned that this may only seem to be working and something else might've broken. For example, if the mission id is mcb now, you've *replaced* the vanilla mcb mission with yours!

In particular also if variables were missing make sure about calling Call $mcb_ref updateData in your "conditions" column.

But, honestly, it's hard to say exactly what's going on here; I don't really have a full overview and it's hard to take in that much info at a glance. If I might suggest more bite-size increments, making things work one step at a time?

Thank you Alex. I was just trying to see how far can I go without making a jar. It seems that I get stuck at making quests. Then I will install and configure an IDE. And it seems that we do need jar files to create new quests. I tried to simply pull some java files of vanilla quests out of the jar, and immediately I got an error saying that the game doesn't understand the enum Stage definition and expects a ";" instead of "{". Too bad, I thought I could make a mod without using jar at all :(

By the way, for the mcb mission, strange, right? I thought it would replace the vanilla mcb as well, but it didn't. I was able to get vanilla mcb missions as usual, and I used devmode to verify, they were actually military bounty instead of underworld bounties. These military bounties does not follow my mcb rules (I removed several mcb bounties from generating, but these vanilla military bounties ignore those restrictions). And the even more strange thing is, I set $missionId to be my version of mcb (tomas_mcb), and I set mission Id in the person_mission file to be mcb. So there is actually no mission called tomas_mcb at all, I thought this would break the game, but it just magically worked. I hope someone could give an explanation to why this would happen. I'm happy to share more details.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 27, 2024, 08:25:07 PM
Hello, everyone, I'm back with some more silly questions.

So I tried to set up an IDE, and started building .jar files. I used eclipse (for some reason that's the only IDE working for me.), and the building was successful.

I configured the JRE's and compiler settings to JRE 7, and the attached are my setting pics.

But then I still encounter a major.minor version 52 error when trying to launch my mission file in my jar.

I believe I'm missing something as I tried to set the compile target to JRE 7. I thought it would be OK if I configure the compiler version and jre preference, but I don't know exactly how to do that with eclipse.

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 28, 2024, 04:26:16 PM
Hi everyone, I'm back with some silly questions,

After succesfully creating my character, and adding all the dialogues, I want to make him a contact to offer some missions.

Everything worked fine as I mimick the vanilla game. But when I was trying to let him offer military bounties, something weird happens and I don't know how to solve.

So I copied the MilitaryCustomBounty file, coded it properly so that things worked out. The person offers military bounties and I can take the mission, the bounties worked jut fine.

But I can't see anything regarding the bounty information in the dialogue. I believe I'm missing some files corresponding to $mcb_ref showBountyDetail and $mcb_ref showBountyAssessment in the rules.csv. But I can't find any class called mcb_ref or any methods in the starfarer.api so far. I may also be missing the triggers. Currently I'm using my own bounty creater names as triggers, but I don't know how to define new triggers, is there any examples about doing that? And in general, my guesses could all be wrong, please let me know what am I missing if that does happen.

I also met another problem I can't solve.

Question 2: I defined a custom bounty following the vanilla CBRemnantPlus.java file, and the starsector.log tells me that the following code is problematic:      

      picker.add("tesseract_Attack");
      picker.add("tesseract_Attack2");
      picker.add("tesseract_Strike");
      picker.add("tesseract_Disruptor");
      fleet.getFleetData().addFleetMember(picker.pick());

It says: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public abstract void com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(com.fs.starfarer.api.fleet.FleetMemberAPI)", "public abstract com.fs.starfarer.api.fleet.FleetMemberAPI com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(java.lang.String)"

Similar reports to the code:

      int i = data.fleet.getFleetData().getMembersListCopy().size() - 1;
      FleetMemberAPI last = data.fleet.getFleetData().getMembersListCopy().get(i);
      data.fleet.getFleetData().removeFleetMember(last);

It seems that somehow the picker.pick() does something wrong, the object class for its return gets lost. And the data.fleet goes wrong. If I avoid using the picker.pick() method at all, and I don't use data.fleet.getFleetData().getMembersListCopy().get() method at all, then the code runs fine. Now I'm even more confused. The following are all my imports:

package data.scripts.campaign.intel.missions;

import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.AICoreOfficerPlugin;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.campaign.FleetDataAPI;
import com.fs.starfarer.api.impl.campaign.missions.cb.BaseCustomBountyCreator;
import com.fs.starfarer.api.impl.campaign.missions.cb.CBStats;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
import com.fs.starfarer.api.impl.campaign.ids.Skills;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithBarEvent;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetQua lity;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetSiz e;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerN um;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerQ uality;
import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
import com.fs.starfarer.api.loading.VariantSource;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;

This is strange, is it because I forgot some imports? I didn't use a compiler and I don't have any .jar files, because I want to get more familiar with how the vanilla game works.

Please let me know, any help will be greatly appreciated!

OK, though I'm still stuck on the java version, I found a solution to my old silly questions, and I'll post them here just in case it could help someone.

To my first silly question, my answer is: I was actually not missing anything. The onlything wrong was that I should've changed all the variable names, i.e. $mcb_ref to $tomas_mcb_ref. Because after examining the BaseCustomBounty file, I found that these variables are actually generated using the mission Id, which is tomas_mcb, plus _ref. So by doing mcb_ref, both showBountyDetail method and showBountyAssessment method would not work. After making these small changes and using my version of mcb quest java file, everything works out, the tomas_mcb mission is now functional.

To my second silly question, my answer is: Well, after examining it using the eclipse IDE, unfortunately this is an issue caused by compilation. The result returned by the picker.pick method would not be recognized properly if it were not compiled into a .jar file. Similar behavior is observed in enum objects, they just can't live in the game if they exist in a java file that's not compiled into a jar.

And, I discovered that all the vanilla contact missions can be implemented without a .jar file. Then I continue my experiments to see can I somehow generalize this idea to a way of creating bounties with any fleet without using a .jar. I did it, it worked. The only thing I need to do is copy a vanilla CBCreater file (let's say CBRemnantPlus), modify it and rename it properly (let's say tomas_CBRemnantPlus), add this to the CREATOR List in tomas_MilitaryCustomBounty.java file, and we are done with the codes. Then to the rules.csv, add corresponding rules for tomas to say proper words describing the bounty. And change the trigger from MCBShowBounty to tomasMCBShowBounty. Everything worked fine.

It turns out what caused the strange problem was that I didn't change the trigger in the rules.csv file, I used the trigger MCBShowBounty, but the Military Custom Bounty file contains a bounty creater NOT in the CREATOR List of the vanilla MCBShowBounty file, and things get broken. Everything worked properly after I changed the trigger. I also want to make a remark (to whoever that may read my silly questions) that, you do NOT need to define the trigger using separate scripts, you can let your custom trigger be an arbitrary string and call it after FireBest or FireAll. I thought all triggers should be defined using some codes, and that's why I didn't change the trigger name.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on February 28, 2024, 06:09:16 PM
API request: RemoveOption rulecmd currently causes all remaining options to forget whether they were disabled. It should not do this.

e.g. this modded bug (https://fractalsoftworks.com/forum/index.php?topic=29310.0) involves a mod dialog option being disabled but then having that setting removed by a separate vanilla dialog option, so I have to catch the invalid state after the mod option is selected as well as before
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on February 28, 2024, 09:10:08 PM
Ah, that's... unfortunate. The implementation of RemoveOption has some limitations, it definitely does not handle everything. I'll make a note of this specific thing, but improving the implementation to handle these kinds of cases is fairly complicated.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Originem on February 29, 2024, 01:56:32 AM
MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:
Wait what? hull spec  hull id??
And is there something missing?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on February 29, 2024, 09:01:29 PM
Hello, everyone, I'm back with some more silly questions.

So I tried to set up an IDE, and started building .jar files. I used eclipse (for some reason that's the only IDE working for me.), and the building was successful.

I configured the JRE's and compiler settings to JRE 7, and the attached are my setting pics.

But then I still encounter a major.minor version 52 error when trying to launch my mission file in my jar.

I believe I'm missing something as I tried to set the compile target to JRE 7. I thought it would be OK if I configure the compiler version and jre preference, but I don't know exactly how to do that with eclipse.

OK, I'm back with an answer to my silly question. It seems that I need to check a box in the export options. As shown in the attached. After checking that box saying JRE 7, the version issue was solved.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 01, 2024, 09:27:47 AM
MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:
Wait what? hull spec  hull id??
And is there something missing?

Missiles are have a fake hull spec to hold their engine data; I don't remember off the top of my head what fields are set for it and the id *might* be set to the missile projectile ID. But it might also not be. That's all I meant.


@VladimirVV: glad you got it figured out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dagg_r on March 02, 2024, 10:22:06 AM
Hello, I'm new on this forum but a long time player.

I'm trying to keep destroyed ship hulks from disappearing, I'm almost sure it's impossible but still asking here to be certain.

Hulk pieces disappear after 90 seconds, while whole ship hulks don't disappear until there are too many hulks on the map. I looked in the json configurations but didn't find anything relevant, then I dug through the API to see if there is something that controls this, specifically in CombatEngineAPI, but didn't find anything.

Then what I did is hijack a mod that had a plugin that extends BaseEveryFrameCombatPlugin which iterates over hulks, and then I tried various things in the advance method :

Am I missing anything ?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 03, 2024, 08:33:32 AM
Hello, everyone, I'm back with some more silly questions.

So now I'm adding some story missions to my mod. Let's say I have tomas_kol, and I have macario. Now I finish the usurpers, and I want to get Macario a dialogue option I can choose to ask about tomas. According to the vanilla rules.csv, there is already a default macario greeting after finishing the usurpers, and it does not fire any PopulateOptions.

So far what I did was that I added a macario greeting rule, saying that if the player is on the tomas mission, then when the trigger PickGreeting happens, under condition !$global.PlayerAskedMacarioAboutTomas && $global.TomasMissionStarted, it will do the script FireBest Populate Options, and it seems to work just fine.

I have two concerns, my first concern is, if I use FireBest, then what if the player is concurrently on another mission that also involves macario, and macario will only offer one option from both options as he should offer.

And my second concern is, if I change FireBest to FireAll, then Macario will Not offer any options when he picks greetings, I believe this is due to the vanilla rule, and I need to cut commlink and greet him again to let him offer options.

I think FireAll PopulateOptions should be the proper way to do this, I might be wrong. But what is the proper way for me to let macario fire all PopulateOptions without needing to cut comm link first?

Update: I have solved my silly question. After some tests, I found that if I add another condition to the tomas mission macario greeting that !$global.TomasMissionCompleted, the FireAll actually worked. And so FireAll PopulateOptions should be the proper way to do this, it's just I need to set up the greeting conditions correctly so that it would not get overrided by the vanilla macario greeting rule.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 03, 2024, 08:34:09 AM
how does PlanetAPI.setSecondLight() work?
I'm setting it in an EveryFrameScript with runWhilePaused returning true but it only ever actually works while the game is paused, if I unpause the planet goes back to being unlit.

later edit : I've also checked with a debugger, the planet's secondLightColor & secondLightLocation fields do get properly filled out wether the game is paused or not

I've also tried setting it once when the planet is generated, but that didn't seem to work either

the script that gets added to the system the planet is in
(I also use this to block transverse jumping out of the system)
Code
public class SSCHomeSystemTJBlocker implements EveryFrameScript {

    public final StarSystemAPI system;

    public SSCHomeSystemTJBlocker(StarSystemAPI system) {
        this.system = system;
    }

    @Override
    public boolean isDone() {
        return false;
    }

    @Override
    public boolean runWhilePaused() {
        return true;
    }

    @Override
    public void advance(float amount) {

        CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();

        if (playerFleet.getContainingLocation() != system) return;

        PlanetAPI planet = (PlanetAPI) Global.getSector().getEntityById(IDs.gardenPlanetID);
        SectorEntityToken SSCStation = Global.getSector().getEntityById(IDs.cronusStationID);
        planet.setSecondLight(
                new Vector3f(SSCStation.getLocation().x, SSCStation.getLocation().y, SSCStation.getCircularOrbitRadius() * 0.75f),
                new Color(255, 225, 125, 255)
        );

        if (!playerFleet.hasAbility(Abilities.TRANSVERSE_JUMP)) return;
        if (playerFleet.getAbility(Abilities.TRANSVERSE_JUMP) == null) return;

        playerFleet.getAbility(Abilities.TRANSVERSE_JUMP).setCooldownLeft(Global.getSettings().getAbilitySpec(Abilities.TRANSVERSE_JUMP).getDeactivationDays());

    }
}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 04, 2024, 09:34:19 AM
Hello, I'm new on this forum but a long time player.

I'm trying to keep destroyed ship hulks from disappearing, I'm almost sure it's impossible but still asking here to be certain.

Hulk pieces disappear after 90 seconds, while whole ship hulks don't disappear until there are too many hulks on the map. I looked in the json configurations but didn't find anything relevant, then I dug through the API to see if there is something that controls this, specifically in CombatEngineAPI, but didn't find anything.

Then what I did is hijack a mod that had a plugin that extends BaseEveryFrameCombatPlugin which iterates over hulks, and then I tried various things in the advance method :
  • ship.setHitpoints(10000) : I thought maybe hulks have decaying hull ? But no, this doesn't work.
  • ship.setHulk(false) : Immediately makes the hulk disappear.
  • ship.setTimeDeployed(0) : Doesn't work.

Am I missing anything ?

Hi - ahh, sorry, this looks like it won't work. There's a "sinceVisible" variable that tracks how long it was since the hulk was near the visible area of the battlefield, and the despawning is based on that. And there are no getters/setters for this variable.

Update: I have solved my silly question. After some tests, I found that if I add another condition to the tomas mission macario greeting that !$global.TomasMissionCompleted, the FireAll actually worked. And so FireAll PopulateOptions should be the proper way to do this, it's just I need to set up the greeting conditions correctly so that it would not get overrided by the vanilla macario greeting rule.

Just a quick note, if you're not aware already: if you need one rule to have higher priority, you can append " score:1000" (or some other number) to one of its conditions. Normally a rule's "score" is the number of conditions it has, and the rule with the highest score gets picked. Though, this only applies for FireBest - FireAll fires all the matching rules, regardless of their scores.



how does PlanetAPI.setSecondLight() work?
I'm setting it in an EveryFrameScript with runWhilePaused returning true but it only ever actually works while the game is paused, if I unpause the planet goes back to being unlit.

Hmm - FusionLampEntityPlugin (which is in the api source) uses this and it works. I'm not seeing anything wrong with your code offhand, though, so I'm not sure what the difference is.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 04, 2024, 10:27:07 AM
Hmm - FusionLampEntityPlugin (which is in the api source) uses this and it works. I'm not seeing anything wrong with your code offhand, though, so I'm not sure what the difference is.

yeah, I looked there to see how it was done in the first place.
my only guess is that the system having no primary star does something funky to it, but I've given the SectorEntityToken that I got from initNonStarCenter() the AMBIENT_LS tag & that lighting works fine. (and the whole "only works while paused" thing makes no sense if that's the issue)

EDIT : moved the relevant code into a custom campaign entity plugin & it works fine now, huh.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 04, 2024, 10:28:53 AM
A quick question,

What does DelayedBlueprintLearnScript do in vanilla game? I was trying to implement other factions learning new blueprint as parts of the storyline outcomes, and I happen to come across this code in vanilla game.

It seems to me that if all factions get this code active, then after cycles in the vanilla game, all factions will learn all ships, weapons, and wings existing in the game, and it would make the differentiating factions by their fighting styles kind of useless, and I'm concerned. Does this code have some other conditions to trigger besides that delayed days?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dagg_r on March 04, 2024, 11:27:46 AM
Hi - ahh, sorry, this looks like it won't work. There's a "sinceVisible" variable that tracks how long it was since the hulk was near the visible area of the battlefield, and the despawning is based on that. And there are no getters/setters for this variable.

"Visible area" meaning the area within the map's bounds right ? Or the viewport ? Hulks can despawn within the player's screen so I'm assuming it's the former.

Fair enough, I was just trying to add some extra chaos to the game by making wrecks stay longer, and also avoid seeing them vanish which I find slightly jarring. Anyway, thank you for the explanation, I assume that field is not only used for hulk despawning so I understand if making it accessible is not preferable.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Histidine on March 05, 2024, 12:50:46 AM
A quick question,

What does DelayedBlueprintLearnScript do in vanilla game? I was trying to implement other factions learning new blueprint as parts of the storyline outcomes, and I happen to come across this code in vanilla game.

It seems to me that if all factions get this code active, then after cycles in the vanilla game, all factions will learn all ships, weapons, and wings existing in the game, and it would make the differentiating factions by their fighting styles kind of useless, and I'm concerned. Does this code have some other conditions to trigger besides that delayed days?
A DelayedBlueprintLearnScript is generated when player sells one or more blueprints on the black market, for the specific ship(s)/wing(s)/fighter(s) in the BPs. (Also for a specific Kanta tribute)

The script is added by BlackMarketPlugin.reportPlayerMarketTransaction. Your mod code could also generate its own delayed learn scripts for any faction.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 05, 2024, 01:42:38 PM
A quick question,

What does DelayedBlueprintLearnScript do in vanilla game? I was trying to implement other factions learning new blueprint as parts of the storyline outcomes, and I happen to come across this code in vanilla game.

It seems to me that if all factions get this code active, then after cycles in the vanilla game, all factions will learn all ships, weapons, and wings existing in the game, and it would make the differentiating factions by their fighting styles kind of useless, and I'm concerned. Does this code have some other conditions to trigger besides that delayed days?
A DelayedBlueprintLearnScript is generated when player sells one or more blueprints on the black market, for the specific ship(s)/wing(s)/fighter(s) in the BPs. (Also for a specific Kanta tribute)

The script is added by BlackMarketPlugin.reportPlayerMarketTransaction. Your mod code could also generate its own delayed learn scripts for any faction.

Good, thanks! This solves my concern.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: OptimisticSociopath on March 05, 2024, 01:57:56 PM
Hello there! :^)

I am having a problem with my mod. I want to make Solar Shielding hullmod incompatible with my modded hulmod.
I know I can make my hullmod incompatible with any Vanilla hullmod by using:

"public boolean isApplicableToShip(ShipAPI ship)"
and later
"public String getUnapplicableReason(ShipAPI ship)"

but I don't see how I can to do it in the other way... Maybe adding something to .ship file or hullmod.csv file? Strings? :/

Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.impl.campaign.ids.HullMods;


@SuppressWarnings("unchecked")
public class nowacfluxcore extends BaseHullMod {

public static final int HARD_FLUX_DISSIPATION_PERCENT = 60;

public static float FLUX_RESISTANCE = 55f;
public static float VENT_RATE_BONUS = 40f;

public static float CORONA_EFFECT_MULT = 0f;
public static float ENERGY_DAMAGE_MULT = 0.8f;


public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getHardFluxDissipationFraction().modifyFlat(id, (float)HARD_FLUX_DISSIPATION_PERCENT * 0.01f);

stats.getEmpDamageTakenMult().modifyMult(id, 1f - FLUX_RESISTANCE * 0.01f);
stats.getVentRateMult().modifyPercent(id, VENT_RATE_BONUS);

stats.getEnergyDamageTakenMult().modifyMult(id, ENERGY_DAMAGE_MULT);
stats.getEnergyShieldDamageTakenMult().modifyMult(id, ENERGY_DAMAGE_MULT);
float mult = CORONA_EFFECT_MULT;
stats.getDynamic().getStat(Stats.CORONA_EFFECT_MULT).modifyMult(id, mult);


}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + HARD_FLUX_DISSIPATION_PERCENT + "%";
if (index == 1) return "" + (int) FLUX_RESISTANCE + "%";
if (index == 2) return "" + (int) VENT_RATE_BONUS + "%";
if (index == 3) return "" + (int) Math.round((1f - CORONA_EFFECT_MULT) * 100f) + "%";
if (index == 4) return "" + (int) Math.round((1f - ENERGY_DAMAGE_MULT) * 100f) + "%";

return null;
}

@Override
public boolean isApplicableToShip(ShipAPI ship) {
return !ship.getVariant().getHullMods().contains("SolarShielding") &&
!ship.getVariant().getHullMods().contains("FluxShunt") &&
!ship.getVariant().getHullMods().contains("fluxbreakers");
}


public String getUnapplicableReason(ShipAPI ship) {
if (ship.getVariant().getHullMods().contains("SolarShielding")) {
return "Incompatible with Solar Shielding";
}
if (ship.getVariant().getHullMods().contains("FluxShunt")) {
return "Incompatible with Flux Shunt";
}
if (ship.getVariant().getHullMods().contains("fluxbreakers")) {
return "Incompatible with Flux Breakers";
}
return null;
}


}

That's the code for my hullmod. Yes, it is not very balanced becouse it's build-in and you can't get this hullmod for any other ship. This Hullmod is attached to one of my ships by using
""builtInMods":"
in .ship file.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 06, 2024, 10:29:45 AM
Hello there! :^)

I am having a problem with my mod. I want to make Solar Shielding hullmod incompatible with my modded hulmod.
I know I can make my hullmod incompatible with any Vanilla hullmod by using:

"public boolean isApplicableToShip(ShipAPI ship)"
and later
"public String getUnapplicableReason(ShipAPI ship)"

but I don't see how I can to do it in the other way... Maybe adding something to .ship file or hullmod.csv file? Strings? :/

Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.impl.campaign.ids.HullMods;


@SuppressWarnings("unchecked")
public class nowacfluxcore extends BaseHullMod {

public static final int HARD_FLUX_DISSIPATION_PERCENT = 60;

public static float FLUX_RESISTANCE = 55f;
public static float VENT_RATE_BONUS = 40f;

public static float CORONA_EFFECT_MULT = 0f;
public static float ENERGY_DAMAGE_MULT = 0.8f;


public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getHardFluxDissipationFraction().modifyFlat(id, (float)HARD_FLUX_DISSIPATION_PERCENT * 0.01f);

stats.getEmpDamageTakenMult().modifyMult(id, 1f - FLUX_RESISTANCE * 0.01f);
stats.getVentRateMult().modifyPercent(id, VENT_RATE_BONUS);

stats.getEnergyDamageTakenMult().modifyMult(id, ENERGY_DAMAGE_MULT);
stats.getEnergyShieldDamageTakenMult().modifyMult(id, ENERGY_DAMAGE_MULT);
float mult = CORONA_EFFECT_MULT;
stats.getDynamic().getStat(Stats.CORONA_EFFECT_MULT).modifyMult(id, mult);


}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + HARD_FLUX_DISSIPATION_PERCENT + "%";
if (index == 1) return "" + (int) FLUX_RESISTANCE + "%";
if (index == 2) return "" + (int) VENT_RATE_BONUS + "%";
if (index == 3) return "" + (int) Math.round((1f - CORONA_EFFECT_MULT) * 100f) + "%";
if (index == 4) return "" + (int) Math.round((1f - ENERGY_DAMAGE_MULT) * 100f) + "%";

return null;
}

@Override
public boolean isApplicableToShip(ShipAPI ship) {
return !ship.getVariant().getHullMods().contains("SolarShielding") &&
!ship.getVariant().getHullMods().contains("FluxShunt") &&
!ship.getVariant().getHullMods().contains("fluxbreakers");
}


public String getUnapplicableReason(ShipAPI ship) {
if (ship.getVariant().getHullMods().contains("SolarShielding")) {
return "Incompatible with Solar Shielding";
}
if (ship.getVariant().getHullMods().contains("FluxShunt")) {
return "Incompatible with Flux Shunt";
}
if (ship.getVariant().getHullMods().contains("fluxbreakers")) {
return "Incompatible with Flux Breakers";
}
return null;
}


}

That's the code for my hullmod. Yes, it is not very balanced becouse it's build-in and you can't get this hullmod for any other ship. This Hullmod is attached to one of my ships by using
""builtInMods":"
in .ship file.

I woner how to do this as well. To my best knowledge, you can't make the vanilla hullmods to be incompatible with yours unless you modify those vanilla hull mods.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: OptimisticSociopath on March 06, 2024, 11:00:34 AM

I woner how to do this as well. To my best knowledge, you can't make the vanilla hullmods to be incompatible with yours unless you modify those vanilla hull mods.

Ow damn...  :-\
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 06, 2024, 11:46:23 AM
you can have your hullmods look for and remove any other hullmods you want to be incompatible with

magicLib has a method built into it (MagicIncompatibleHullmods) that makes it a little fancier by telling the player what hullmod removed what other hullmod, but if you don't want the dependency then you can just do something like this

Code

    @Override
    public void applyEffectsBeforeShipCreation(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats, String id) {

        ShipVariantAPI var = stats.getVariant();

        ArrayList<String> blockedHmodIDs = new ArrayList<>();
        /*
        * this should really be a static class-level variable that gets filled out elsewhere but
        * imagine that it's filled for the sake of this example
        */

        for (String modid : var.getHullMods()) {
            if (blockedHmodIDs.contains(modid)) {
                var.removeMod(modid);
            }
        }
    }
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on March 06, 2024, 03:49:23 PM
Is there any way of increasing size of star system's grid?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: OptimisticSociopath on March 07, 2024, 03:43:28 AM
you can have your hullmods look for and remove any other hullmods you want to be incompatible with

magicLib has a method built into it (MagicIncompatibleHullmods) that makes it a little fancier by telling the player what hullmod removed what other hullmod, but if you don't want the dependency then you can just do something like this

Code

    @Override
    public void applyEffectsBeforeShipCreation(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats, String id) {

        ShipVariantAPI var = stats.getVariant();

        ArrayList<String> blockedHmodIDs = new ArrayList<>();
        /*
        * this should really be a static class-level variable that gets filled out elsewhere but
        * imagine that it's filled for the sake of this example
        */

        for (String modid : var.getHullMods()) {
            if (blockedHmodIDs.contains(modid)) {
                var.removeMod(modid);
            }
        }
    }

Thank you Mr. Seal, Sir  ;D
I will take a MagicLib approach...
About non-MagicLib version:

Quote
       
 ArrayList<String> blockedHmodIDs = new ArrayList<>();
        /*
        * this should really be a static class-level variable that gets filled out elsewhere but
        * imagine that it's filled for the sake of this example
        */

        for (String modid : var.getHullMods()) {
            if (blockedHmodIDs.contains(modid)) {
                var.removeMod(modid);
            }
        }

I have no idea what to do about it. I am just a beginner in modding :-\ Usually I look at the other stuff (code), and try to put few thing together and see if that is going to work and creating something new in the process :^)
 
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 07, 2024, 09:17:06 AM
you can have your hullmods look for and remove any other hullmods you want to be incompatible with

magicLib has a method built into it (MagicIncompatibleHullmods) that makes it a little fancier by telling the player what hullmod removed what other hullmod, but if you don't want the dependency then you can just do something like this

Code

    @Override
    public void applyEffectsBeforeShipCreation(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats, String id) {

        ShipVariantAPI var = stats.getVariant();

        ArrayList<String> blockedHmodIDs = new ArrayList<>();
        /*
        * this should really be a static class-level variable that gets filled out elsewhere but
        * imagine that it's filled for the sake of this example
        */

        for (String modid : var.getHullMods()) {
            if (blockedHmodIDs.contains(modid)) {
                var.removeMod(modid);
            }
        }
    }

Thank you Mr. Seal, Sir  ;D
I will take a MagicLib approach...
About non-MagicLib version:

Quote
       
 ArrayList<String> blockedHmodIDs = new ArrayList<>();
        /*
        * this should really be a static class-level variable that gets filled out elsewhere but
        * imagine that it's filled for the sake of this example
        */

        for (String modid : var.getHullMods()) {
            if (blockedHmodIDs.contains(modid)) {
                var.removeMod(modid);
            }
        }

I have no idea what to do about it. I am just a beginner in modding :-\ Usually I look at the other stuff (code), and try to put few thing together and see if that is going to work and creating something new in the process :^)

I think you should consider the MagicLab approach. But also notice, that both methods are NOT like the vanilla 'incompatible hull mods". i.e, if your hullmod is incompatible with vanilla hullmod "heavy armor", then you may still install "heavy armor" even if you had your hullmod already, it's just that the effects of "heavyarmor" would be removed. I think this is quite counter-intuitive to players (especially players like me), there shoule be someway to stop players from installing incompatible hullmods at once. But there is currently no way of doing this other than modifying the hullmod file directly, and so I just try to avoid doing this.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 07, 2024, 12:22:15 PM
EDIT : moved the relevant code into a custom campaign entity plugin & it works fine now, huh.

Ah! Probably an order-of-operations issue, then.

Is there any way of increasing size of star system's grid?

Hmm, I don't think so, actually. You mean making the grid cover a larger area, right? I thought I might have done that at one point, but looking at the code, doesn't seem like it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 07, 2024, 12:56:57 PM
"Visible area" meaning the area within the map's bounds right ? Or the viewport ? Hulks can despawn within the player's screen so I'm assuming it's the former.

It's the viewport, hulks are not supposed to despawn while the player can see them, or has seen them recently. Are you able to reproduce this reliably?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on March 07, 2024, 01:20:24 PM
"Visible area" meaning the area within the map's bounds right ? Or the viewport ? Hulks can despawn within the player's screen so I'm assuming it's the former.

It's the viewport, hulks are not supposed to despawn while the player can see them, or has seen them recently. Are you able to reproduce this reliably?
I'm not sure how reliable it is, but I've definitely seen spaceship bits despawn while visible. Hadn't realized that was a bug, honestly, figured the game was just done keeping track of them. (It's possible that this only happens to hulk bits that had been offscreen at one point, and then are onscreen again? Unsure; haven't been keeping track of when this happens.)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 07, 2024, 04:04:09 PM
Ugh. I've been over that code with a fine-toothed comb (at some point, a while back). Is this with the latest? It was definitely doing that at some point, but then I'd thought I'd fixed it; not exactly sure whether it was 2 or 3 releases back.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Wyvern on March 07, 2024, 04:09:04 PM
Unsure. I remember seeing this, but couldn't say with certainty that I've seen it in 0.97. Will put up a bug report thread if I come across it again.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Dagg_r on March 07, 2024, 09:09:30 PM

It's the viewport, hulks are not supposed to despawn while the player can see them, or has seen them recently. Are you able to reproduce this reliably?
I can reproduce it in 0.97, and I disabled all mods to be absolutely sure. I select mission, run a simulation in the refit screen, and blow up an Atlas to pieces.

The delay is more inconsistent than I thought, sometimes it takes 60 seconds, and once I didn't see the pieces despawn after waiting for 5 minutes. On average it seems to take around 2 minutes.


Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 08, 2024, 08:11:27 PM
Hello,guys, I'm back with more silly questions.

I want to ask, what does devmode do to the mission scripts?

So what happened was, I have 3 quest missions that are supposed to generate some fleets. I turned on devmode to test my missions. I accepted one mission, and that mission works just fine. But the fleets from other 2 missions also get spawned even if I didn't start those missions at all. The interaction dialogue and the infos on map worked properly, and so I'm confused about the reason for this.

Due to convenience, I used the same stage name for some stages sharing the same locations in all these different missions, but I don't see how this could trigger such weird behavior. Is this behavior caused by devmode? Or is it caused by my stage name problems.

After some tests, I found that it's probably the problem of the devmode. It seems that if I have my missions offered by a contact, say tomas_kol. Then somehow if I accept any mission, incuding the usual contact missions like military bounty, all the fleets spawning codes in all missions offered by tomas_kol would run. But the important marks and the info boards work just fine. I don't know why is this. Anyone has got any ideas?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 09, 2024, 11:18:15 AM
Unsure. I remember seeing this, but couldn't say with certainty that I've seen it in 0.97. Will put up a bug report thread if I come across it again.

adding to this that there is definitely some wierdness with some viewport checks - I was helping someone on the discord who was wondering why their DEM wasn't spawning any particle effects, it turned out to be because they had set their max zoom out higher than vanilla & that just broke it
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2024, 12:43:25 PM
Unsure. I remember seeing this, but couldn't say with certainty that I've seen it in 0.97. Will put up a bug report thread if I come across it again.

It's the viewport, hulks are not supposed to despawn while the player can see them, or has seen them recently. Are you able to reproduce this reliably?
I can reproduce it in 0.97, and I disabled all mods to be absolutely sure. I select mission, run a simulation in the refit screen, and blow up an Atlas to pieces.

The delay is more inconsistent than I thought, sometimes it takes 60 seconds, and once I didn't see the pieces despawn after waiting for 5 minutes. On average it seems to take around 2 minutes.

Thank you! Made a note to check this out.

adding to this that there is definitely some wierdness with some viewport checks - I was helping someone on the discord who was wondering why their DEM wasn't spawning any particle effects, it turned out to be because they had set their max zoom out higher than vanilla & that just broke it

Hm, interesting - that's pretty odd, I'll keep that in mind. The viewport numbers literally determine what you see, so it's hard to see how checks for whether something is in or near it would fail, but I'll have a look.


Hello,guys, I'm back with more silly questions.

I want to ask, what does devmode do to the mission scripts?

So what happened was, I have 3 quest missions that are supposed to generate some fleets. I turned on devmode to test my missions. I accepted one mission, and that mission works just fine. But the fleets from other 2 missions also get spawned even if I didn't start those missions at all. The interaction dialogue and the infos on map worked properly, and so I'm confused about the reason for this.

Due to convenience, I used the same stage name for some stages sharing the same locations in all these different missions, but I don't see how this could trigger such weird behavior. Is this behavior caused by devmode? Or is it caused by my stage name problems.

After some tests, I found that it's probably the problem of the devmode. It seems that if I have my missions offered by a contact, say tomas_kol. Then somehow if I accept any mission, incuding the usual contact missions like military bounty, all the fleets spawning codes in all missions offered by tomas_kol would run. But the important marks and the info boards work just fine. I don't know why is this. Anyone has got any ideas?

One of the things devMode does is let you press Escape to get out of a dialog, avoiding the normal flow. This can sometimes mean that a mission is created (spawning fleets etc) but then not properly aborted (removing the fleets etc), as it would be if the normal dialog flow was followed. This sounds like maybe what happened here?

The enum names being shared should not be an issue, no. Vanilla does that all the time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 09, 2024, 06:23:29 PM
Thank you, Alex! So I think it would be more helpful if I give more details. So I have 3 different missions, I started the dev mode, started one mission, and I didn’t even clack the options of starting the other two missions. So with your reply, I now suspect that what happened was that my fleet spawning code somehow runs when the missions are created, instead of when the missions are accepted.

I believe this could be caused by the fact that I didn’t make mission reference flags for those fleets, I just set them to be mission important. I thought it wouldn’t matter.

And so now I want to ask, what does mission reference memory flag do to the mission fleets? Does it tell the game to spawn this fleet and let it exist only in the mission is active?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 09, 2024, 06:25:05 PM
The reference flag is just there so that you can Call (using that rule command) the mission when you're interacting with the fleet. For example:

Call $mission_ref <command>

Would call the callAction() method in the mission.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 10, 2024, 10:31:40 AM
The reference flag is just there so that you can Call (using that rule command) the mission when you're interacting with the fleet. For example:

Call $mission_ref <command>

Would call the callAction() method in the mission.

Thank you, Alex. I think I know what’s going wrong. I just need to add a condition to tell the game when to spawn the fleet, and when to let the fleet despawn. I didn’t know where to find such codes in vanilla, but I’m using the most naive if currentStage==x way to do this in the create function. It does not seem to work though, after adding this condition in the create function, the fleet just never gets created. Please let me know where may I find an example to correctly tell the game to only create fleets at certain stages. Thanks!

Update: I found a method called stageTrigger (or something with similar name) by browsing the starsector.api. And that seems to be the proper way of doing what I was trying to do. Things work fine for now, but all suggestions are appreciated and welcomed!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 14, 2024, 02:13:29 PM
hello again. I have emerged with questions.
1) when putting a single charged beam weapon on a fighter with the 'bomber' 'role', how do i make said fighter point straight at the target until the beam is done firing? as is, they try to turn before its done and that's no fun.
2) with a weapon, is there a way to have it look different when it has charges / has no charges? and if so, can you please show me a example so i can attempt to mimic it?
thanks once more to all the people who answered my questions in the past. It has been really really helpful that people are so helpful.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 14, 2024, 09:32:38 PM
hello again. I have emerged with questions.
1) when putting a single charged beam weapon on a fighter with the 'bomber' 'role', how do i make said fighter point straight at the target until the beam is done firing? as is, they try to turn before its done and that's no fun.

Hmm. I'd suggest adding a script to that weapon that detects when it starts firing and have it call:
ship.blockCommandForOneFrame(ShipCommand.TURN_LEFT);
ship.blockCommandForOneFrame(ShipCommand.TURN_RIGHT);

Or just store and set the facing via ship.setFacing().

Or could modify the weapon slot arc once it starts firing, so the weapon can track the target once it fires but not before.


2) with a weapon, is there a way to have it look different when it has charges / has no charges? and if so, can you please show me a example so i can attempt to mimic it?
thanks once more to all the people who answered my questions in the past. It has been really really helpful that people are so helpful.

For weapons with barrels, the barrels will be retrated when out of ammo. Otherwise - some kind of custom rendering, perhaps via CombatLayeredRenderingPlugin? There may be other ways of doing it but I'm not honestly sure.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on March 15, 2024, 06:45:25 AM
are ship variant tags permanent when you add them?

planning on using tags to hold simple data like an id or a number and just grabbing it when needed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Audax on March 15, 2024, 06:51:29 AM
[Replied to my own post by accident]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on March 15, 2024, 08:51:01 AM
How i can replicate this stuff but in star system?
I mean it shows stars like those icons, instead of jump points
Spoiler
(https://i.imgur.com/M609Jm2.png?1)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2024, 12:14:27 PM
How i can replicate this stuff but in star system?
I mean it shows stars like those icons, instead of jump points
Spoiler
(https://i.imgur.com/M609Jm2.png?1)
[close]


Ah - this is hardcoded to only work in hyperspace with starscape mode turned on, apologies!


are ship variant tags permanent when you add them?

planning on using tags to hold simple data like an id or a number and just grabbing it when needed.

Unless they're removed or cleared out, they should stick around. Make sure it's not a stock variant, though - otherwise the tags would be shared across *all ships that use that stock variant*.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on March 15, 2024, 12:22:37 PM
How i can replicate this stuff but in star system?
I mean it shows stars like those icons, instead of jump points
Spoiler
(https://i.imgur.com/M609Jm2.png?1)
[close]


Ah - this is hardcoded to only work in hyperspace with starscape mode turned on, apologies!

Is there any way to replicate then this stuff I mean even spawning icons themself like creating custom entity?
For example someone showed me that for example you can insert names into star systems landscape so i thought icons wont be issue
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 15, 2024, 12:24:55 PM
hello once again everyone here. I have returned with less strange questions
what do the following variables do from the commodities.csv:
    1) price variability (I know the basics of what it does, but not the exact equation)
    2) utility
    3) origin
    4) stack size (does not seem to be the size of a stack)
    5) economyTier
    6) econUnitOrigUnused
    7) econUnit
I have seen a lot of tags in the commodities.csv, but the only ones i that i know the function of are the 'no_drop' and 'no_loss_from_combat'. what do the rest do?

thanks again to everyone that answer all my questions last time and the thousand time before. its been really really helpful overall.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 15, 2024, 12:42:59 PM
Is there any way to replicate then this stuff I mean even spawning icons themself like creating custom entity?
For example someone showed me that for example you can insert names into star systems landscape so i thought icons wont be issue

Probably - custom rendering on the map; I think the only way to do this is with a CampaignTerrainPlugin, that has methods for on-map rendering.


    1) price variability (I know the basics of what it does, but not the exact equation)

It contributes to an exponent somewhere, I don't know the exact formula offhand and the details are too involved to easily describe.
   
   
    2) utility

How much demand one unit of the commodity satisfies, but I think it's safer to always have this be set to 1.
   
   
    3) origin

I don't remember if this works at all but at some point there was an idea for having exotic commodities that cost more further away from their "origin". Probably does not work.
   
   
    4) stack size (does not seem to be the size of a stack)

Used to be stack size, but that's no longer used.
   
   
    5) economyTier

The order in which the economy simulation runs. Stuff lower on the production ladder (e.g. ore) needs to have a lower tier than the stuff that's made from it (i.e. metals) to have the simulation stabilize more quickly.
   
   
    6) econUnitOrigUnused

Unused :)
   
   
    7) econUnit
   

Affects how many units there are for sale at markets.
   
   
I have seen a lot of tags in the commodities.csv, but the only ones i that i know the function of are the 'no_drop' and 'no_loss_from_combat'. what do the rest do?

Ah, could you be more specific? It'd be a bit to write up.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 16, 2024, 10:51:25 AM
   
I have seen a lot of tags in the commodities.csv, but the only ones i that i know the function of are the 'no_drop' and 'no_loss_from_combat'. what do the rest do?
Ah, could you be more specific? It'd be a bit to write up.
thanks for the info about the commoditys.csv. i really needed that for reasons of understanding.
a list of tags that i have no clue what do are as follows:
1) military
2) expensive
3) crew
4) personnel
5) marines
6) food
7) medical
8 ) luxury
9) exotic
10) meta
11) nonecon
12) ai_core (I think this is just what can be put in the AI slot at a colony, but am unsure)

thanks again for answering so many of my questions over the years. It has really helped me with the things i try to do when modding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: P. Kerman on March 17, 2024, 04:30:01 AM
Could someone please explain to me what I am doing wrong with my Script?

I get this error in the log file:
Spoiler
java.lang.RuntimeException: Error loading [data.shipsystems.scripts.SensorJammerStats]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.shipsystems.scripts.SensorJammerStats'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.shipsystems.scripts.SensorJammerStats' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more
[close]

I am pretty sure that with "public class SensorJammerStats extends BaseShipSystemScript {" I do declare a class of the same name so I really do not understand the error.

Script:
Spoiler
package com.fs.starfarer.api.impl.combat;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI.SystemState;
import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.util.Misc;

public class SensorJammerStats extends BaseShipSystemScript {
   public static Object KEY_SHIP = new Object();
   public static Object KEY_TARGET = new Object();
   
   public static float RANGE_MULT = 0.8f;
   public static float SENSOR_MULT = 0.6f;   
   protected static float RANGE = 1500f;
   
   public static Color TEXT_COLOR = new Color(255,55,55,255);
   
   public static Color JITTER_COLOR = new Color(255,50,50,75);
   public static Color JITTER_UNDER_COLOR = new Color(255,100,100,155);

   
   public static class TargetData {
      public ShipAPI ship;
      public ShipAPI target;
      public EveryFrameCombatPlugin targetEffectPlugin;
      public float currRange_Mult;
      public float currSensor_Mult;      
      public float elaspedAfterInState;
      public TargetData(ShipAPI ship, ShipAPI target) {
         this.ship = ship;
         this.target = target;
      }
   }
   
   
   public void apply(MutableShipStatsAPI stats, final String id, State state, float effectLevel) {
      ShipAPI ship = null;
      if (stats.getEntity() instanceof ShipAPI) {
         ship = (ShipAPI) stats.getEntity();
      } else {
         return;
      }
      
      final String targetDataKey = ship.getId() + "_Jammer_target_data";
      
      Object targetDataObj = Global.getCombatEngine().getCustomData().get(targetDataKey);
      if (state == State.IN && targetDataObj == null) {
         ShipAPI target = findTarget(ship);
         Global.getCombatEngine().getCustomData().put(targetDataKey, new TargetData(ship, target));
         if (target != null) {
            if (target.getFluxTracker().showFloaty() ||
                  ship == Global.getCombatEngine().getPlayerShip() ||
                  target == Global.getCombatEngine().getPlayerShip()) {
               target.getFluxTracker().showOverloadFloatyIfNeeded("Sensors Jammed!", TEXT_COLOR, 4f, true);
            }
         }
      } else if (state == State.IDLE && targetDataObj != null) {
         Global.getCombatEngine().getCustomData().remove(targetDataKey);
         ((TargetData)targetDataObj).currRange_Mult = 1f;
         ((TargetData)targetDataObj).currSensor_Mult = 1f;         
         targetDataObj = null;
      }
      if (targetDataObj == null || ((TargetData) targetDataObj).target == null) return;
      
      final TargetData targetData = (TargetData) targetDataObj;
      targetData.currRange_Mult = RANGE_MULT * (1f - effectLevel);
      targetData.currSensor_Mult = SENSOR_MULT * (1f - effectLevel);      
      if (targetData.targetEffectPlugin == null) {
         targetData.targetEffectPlugin = new BaseEveryFrameCombatPlugin() {
            @Override
            public void advance(float amount, List<InputEventAPI> events) {
               if (Global.getCombatEngine().isPaused()) return;
               if (targetData.target == Global.getCombatEngine().getPlayerShip()) {
                  Global.getCombatEngine().maintainStatusForPlayerShip(KEY_TARGET,
                        targetData.ship.getSystem().getSpecAPI().getIconSpriteName(),
                        targetData.ship.getSystem().getDisplayName(),
                        "" + (int)((targetData.currRange_Mult - 1f) * 100f) + "% Weapon Range and " + (int)((targetData.currSensor_Mult - 1f) * 100f) + "% Sensor Range", true);
               }
               
               if (targetData.currRange_Mult <= 1f || !targetData.ship.isAlive()) {
                  targetData.target.getMutableStats().getBallisticWeaponRangeBonus().unmodify(id);
                  targetData.target.getMutableStats().getEnergyWeaponRangeBonus().unmodify(id);
                  targetData.target.getMutableStats().getSightRadiusMod().unmodify(id);
                  Global.getCombatEngine().removePlugin(targetData.targetEffectPlugin);
               } else {
                  targetData.target.getMutableStats().getBallisticWeaponRangeBonus().modifyMult(id, currRange_Mult);
                  targetData.target.getMutableStats().getEnergyWeaponRangeBonus().modifyMult(id, currRange_Mult);
                  targetData.target.getMutableStats().getSightRadiusMod().modifyMult(id, currSensor_Mult);
               }
            }
         };
         Global.getCombatEngine().addPlugin(targetData.targetEffectPlugin);
      }
      
      
      if (effectLevel > 0) {
         if (state != State.IN) {
            targetData.elaspedAfterInState += Global.getCombatEngine().getElapsedInLastFrame();
         }
         float shipJitterLevel = 0;
         if (state == State.IN) {
            shipJitterLevel = effectLevel;
         } else {
            float durOut = 0.5f;
            shipJitterLevel = Math.max(0, durOut - targetData.elaspedAfterInState) / durOut;
         }
         float targetJitterLevel = effectLevel;
         
         float maxRangeBonus = 50f;
         float jitterRangeBonus = shipJitterLevel * maxRangeBonus;
         
         Color color = JITTER_COLOR;
         if (shipJitterLevel > 0) {
            //ship.setJitterUnder(KEY_SHIP, JITTER_UNDER_COLOR, shipJitterLevel, 21, 0f, 3f + jitterRangeBonus);
            ship.setJitter(KEY_SHIP, color, shipJitterLevel, 4, 0f, 0 + jitterRangeBonus * 1f);
         }
         
         if (targetJitterLevel > 0) {
            //target.setJitterUnder(KEY_TARGET, JITTER_UNDER_COLOR, targetJitterLevel, 5, 0f, 15f);
            targetData.target.setJitter(KEY_TARGET, color, targetJitterLevel, 3, 0f, 5f);
         }
      }
   }
   
   
   public void unapply(MutableShipStatsAPI stats, String id) {
      
   }
   
   protected ShipAPI findTarget(ShipAPI ship) {
      float range = getMaxRange(ship);
      boolean player = ship == Global.getCombatEngine().getPlayerShip();
      ShipAPI target = ship.getShipTarget();
      
      if (ship.getShipAI() != null && ship.getAIFlags().hasFlag(AIFlags.TARGET_FOR_SHIP_SYSTEM)){
         target = (ShipAPI) ship.getAIFlags().getCustom(AIFlags.TARGET_FOR_SHIP_SYSTEM);
      }
      
      if (target != null) {
         float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
         float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
         if (dist > range + radSum) target = null;
      } else {
         if (target == null || target.getOwner() == ship.getOwner()) {
            if (player) {
               target = Misc.findClosestShipEnemyOf(ship, ship.getMouseTarget(), HullSize.FIGHTER, range, true);
            } else {
               Object test = ship.getAIFlags().getCustom(AIFlags.MANEUVER_TARGET);
               if (test instanceof ShipAPI) {
                  target = (ShipAPI) test;
                  float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
                  float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
                  if (dist > range + radSum) target = null;
               }
            }
         }
         if (target == null) {
            target = Misc.findClosestShipEnemyOf(ship, ship.getLocation(), HullSize.FIGHTER, range, true);
         }
      }
      
      return target;
   }
   
   
   public static float getMaxRange(ShipAPI ship) {
      return ship.getMutableStats().getSystemRangeBonus().computeEffective(RANGE);
   }

   
   public StatusData getStatusData(int index, State state, float effectLevel) {
      if (effectLevel > 0) {
         if (index == 0) {
            float damMult = 1f + (DAM_MULT - 1f) * effectLevel;
            return new StatusData("" + (int)((targetData.currRange_Mult - 1f) * 100f) + "% Weapon Range and " + (int)((targetData.currSensor_Mult - 1f) * 100f) + "% Sensor Range", false);
         }
      }
      return null;
   }


   @Override
   public String getInfoText(ShipSystemAPI system, ShipAPI ship) {
      if (system.isOutOfAmmo()) return null;
      if (system.getState() != SystemState.IDLE) return null;
      
      ShipAPI target = findTarget(ship);
      if (target != null && target != ship) {
         return "READY";
      }
      if ((target == null) && ship.getShipTarget() != null) {
         return "OUT OF RANGE";
      }
      return "NO TARGET";
   }

   
   @Override
   public boolean isUsable(ShipSystemAPI system, ShipAPI ship) {
      //if (true) return true;
      ShipAPI target = findTarget(ship);
      return target != null && target != ship;
   }

}
[close]

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AtlanticAccent on March 17, 2024, 05:04:24 AM
Could someone please explain to me what I am doing wrong with my Script?

I get this error in the log file:
Spoiler
java.lang.RuntimeException: Error loading [data.shipsystems.scripts.SensorJammerStats]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.shipsystems.scripts.SensorJammerStats'
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
   at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.shipsystems.scripts.SensorJammerStats' does not declare a class with the same name
   at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
   ... 7 more
[close]

I am pretty sure that with "public class SensorJammerStats extends BaseShipSystemScript {" I do declare a class of the same name so I really do not understand the error.

Script:
Spoiler
package com.fs.starfarer.api.impl.combat;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI.SystemState;
import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.util.Misc;

public class SensorJammerStats extends BaseShipSystemScript {
   public static Object KEY_SHIP = new Object();
   public static Object KEY_TARGET = new Object();
   
   public static float RANGE_MULT = 0.8f;
   public static float SENSOR_MULT = 0.6f;   
   protected static float RANGE = 1500f;
   
   public static Color TEXT_COLOR = new Color(255,55,55,255);
   
   public static Color JITTER_COLOR = new Color(255,50,50,75);
   public static Color JITTER_UNDER_COLOR = new Color(255,100,100,155);

   
   public static class TargetData {
      public ShipAPI ship;
      public ShipAPI target;
      public EveryFrameCombatPlugin targetEffectPlugin;
      public float currRange_Mult;
      public float currSensor_Mult;      
      public float elaspedAfterInState;
      public TargetData(ShipAPI ship, ShipAPI target) {
         this.ship = ship;
         this.target = target;
      }
   }
   
   
   public void apply(MutableShipStatsAPI stats, final String id, State state, float effectLevel) {
      ShipAPI ship = null;
      if (stats.getEntity() instanceof ShipAPI) {
         ship = (ShipAPI) stats.getEntity();
      } else {
         return;
      }
      
      final String targetDataKey = ship.getId() + "_Jammer_target_data";
      
      Object targetDataObj = Global.getCombatEngine().getCustomData().get(targetDataKey);
      if (state == State.IN && targetDataObj == null) {
         ShipAPI target = findTarget(ship);
         Global.getCombatEngine().getCustomData().put(targetDataKey, new TargetData(ship, target));
         if (target != null) {
            if (target.getFluxTracker().showFloaty() ||
                  ship == Global.getCombatEngine().getPlayerShip() ||
                  target == Global.getCombatEngine().getPlayerShip()) {
               target.getFluxTracker().showOverloadFloatyIfNeeded("Sensors Jammed!", TEXT_COLOR, 4f, true);
            }
         }
      } else if (state == State.IDLE && targetDataObj != null) {
         Global.getCombatEngine().getCustomData().remove(targetDataKey);
         ((TargetData)targetDataObj).currRange_Mult = 1f;
         ((TargetData)targetDataObj).currSensor_Mult = 1f;         
         targetDataObj = null;
      }
      if (targetDataObj == null || ((TargetData) targetDataObj).target == null) return;
      
      final TargetData targetData = (TargetData) targetDataObj;
      targetData.currRange_Mult = RANGE_MULT * (1f - effectLevel);
      targetData.currSensor_Mult = SENSOR_MULT * (1f - effectLevel);      
      if (targetData.targetEffectPlugin == null) {
         targetData.targetEffectPlugin = new BaseEveryFrameCombatPlugin() {
            @Override
            public void advance(float amount, List<InputEventAPI> events) {
               if (Global.getCombatEngine().isPaused()) return;
               if (targetData.target == Global.getCombatEngine().getPlayerShip()) {
                  Global.getCombatEngine().maintainStatusForPlayerShip(KEY_TARGET,
                        targetData.ship.getSystem().getSpecAPI().getIconSpriteName(),
                        targetData.ship.getSystem().getDisplayName(),
                        "" + (int)((targetData.currRange_Mult - 1f) * 100f) + "% Weapon Range and " + (int)((targetData.currSensor_Mult - 1f) * 100f) + "% Sensor Range", true);
               }
               
               if (targetData.currRange_Mult <= 1f || !targetData.ship.isAlive()) {
                  targetData.target.getMutableStats().getBallisticWeaponRangeBonus().unmodify(id);
                  targetData.target.getMutableStats().getEnergyWeaponRangeBonus().unmodify(id);
                  targetData.target.getMutableStats().getSightRadiusMod().unmodify(id);
                  Global.getCombatEngine().removePlugin(targetData.targetEffectPlugin);
               } else {
                  targetData.target.getMutableStats().getBallisticWeaponRangeBonus().modifyMult(id, currRange_Mult);
                  targetData.target.getMutableStats().getEnergyWeaponRangeBonus().modifyMult(id, currRange_Mult);
                  targetData.target.getMutableStats().getSightRadiusMod().modifyMult(id, currSensor_Mult);
               }
            }
         };
         Global.getCombatEngine().addPlugin(targetData.targetEffectPlugin);
      }
      
      
      if (effectLevel > 0) {
         if (state != State.IN) {
            targetData.elaspedAfterInState += Global.getCombatEngine().getElapsedInLastFrame();
         }
         float shipJitterLevel = 0;
         if (state == State.IN) {
            shipJitterLevel = effectLevel;
         } else {
            float durOut = 0.5f;
            shipJitterLevel = Math.max(0, durOut - targetData.elaspedAfterInState) / durOut;
         }
         float targetJitterLevel = effectLevel;
         
         float maxRangeBonus = 50f;
         float jitterRangeBonus = shipJitterLevel * maxRangeBonus;
         
         Color color = JITTER_COLOR;
         if (shipJitterLevel > 0) {
            //ship.setJitterUnder(KEY_SHIP, JITTER_UNDER_COLOR, shipJitterLevel, 21, 0f, 3f + jitterRangeBonus);
            ship.setJitter(KEY_SHIP, color, shipJitterLevel, 4, 0f, 0 + jitterRangeBonus * 1f);
         }
         
         if (targetJitterLevel > 0) {
            //target.setJitterUnder(KEY_TARGET, JITTER_UNDER_COLOR, targetJitterLevel, 5, 0f, 15f);
            targetData.target.setJitter(KEY_TARGET, color, targetJitterLevel, 3, 0f, 5f);
         }
      }
   }
   
   
   public void unapply(MutableShipStatsAPI stats, String id) {
      
   }
   
   protected ShipAPI findTarget(ShipAPI ship) {
      float range = getMaxRange(ship);
      boolean player = ship == Global.getCombatEngine().getPlayerShip();
      ShipAPI target = ship.getShipTarget();
      
      if (ship.getShipAI() != null && ship.getAIFlags().hasFlag(AIFlags.TARGET_FOR_SHIP_SYSTEM)){
         target = (ShipAPI) ship.getAIFlags().getCustom(AIFlags.TARGET_FOR_SHIP_SYSTEM);
      }
      
      if (target != null) {
         float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
         float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
         if (dist > range + radSum) target = null;
      } else {
         if (target == null || target.getOwner() == ship.getOwner()) {
            if (player) {
               target = Misc.findClosestShipEnemyOf(ship, ship.getMouseTarget(), HullSize.FIGHTER, range, true);
            } else {
               Object test = ship.getAIFlags().getCustom(AIFlags.MANEUVER_TARGET);
               if (test instanceof ShipAPI) {
                  target = (ShipAPI) test;
                  float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
                  float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
                  if (dist > range + radSum) target = null;
               }
            }
         }
         if (target == null) {
            target = Misc.findClosestShipEnemyOf(ship, ship.getLocation(), HullSize.FIGHTER, range, true);
         }
      }
      
      return target;
   }
   
   
   public static float getMaxRange(ShipAPI ship) {
      return ship.getMutableStats().getSystemRangeBonus().computeEffective(RANGE);
   }

   
   public StatusData getStatusData(int index, State state, float effectLevel) {
      if (effectLevel > 0) {
         if (index == 0) {
            float damMult = 1f + (DAM_MULT - 1f) * effectLevel;
            return new StatusData("" + (int)((targetData.currRange_Mult - 1f) * 100f) + "% Weapon Range and " + (int)((targetData.currSensor_Mult - 1f) * 100f) + "% Sensor Range", false);
         }
      }
      return null;
   }


   @Override
   public String getInfoText(ShipSystemAPI system, ShipAPI ship) {
      if (system.isOutOfAmmo()) return null;
      if (system.getState() != SystemState.IDLE) return null;
      
      ShipAPI target = findTarget(ship);
      if (target != null && target != ship) {
         return "READY";
      }
      if ((target == null) && ship.getShipTarget() != null) {
         return "OUT OF RANGE";
      }
      return "NO TARGET";
   }

   
   @Override
   public boolean isUsable(ShipSystemAPI system, ShipAPI ship) {
      //if (true) return true;
      ShipAPI target = findTarget(ship);
      return target != null && target != ship;
   }

}
[close]

In your apply method, where you create a new BaseEveryFrameCombatPlugin, you reference the type "List<InputEventAPI>". Unfortunately Janino, the runtime compiler bundled with the game does not understand this type as it uses generics, and Janino does not support generics.
In order for the above to work, you will need to compile your code prior to it being loaded by the game and include the compilation output in a .jar file. Whilst this sounds complicated, there is a tutorial on how to do so here: https://starsector.fandom.com/wiki/IntelliJ_IDEA_Setup
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: P. Kerman on March 17, 2024, 06:20:48 AM
In your apply method, where you create a new BaseEveryFrameCombatPlugin, you reference the type "List<InputEventAPI>". Unfortunately Janino, the runtime compiler bundled with the game does not understand this type as it uses generics, and Janino does not support generics.
In order for the above to work, you will need to compile your code prior to it being loaded by the game and include the compilation output in a .jar file. Whilst this sounds complicated, there is a tutorial on how to do so here: https://starsector.fandom.com/wiki/IntelliJ_IDEA_Setup

Ok followed the instructions and setup IntelliJ but now I am running into new errors. I have to admit my programming skill are limited at best and as far as Starsector scripting in particular is concerned they are pretty much non existent. I am basically just trying to modifying the Entropy Amplifier script to do what I want.
I get the following 7 errors:
Spoiler
  • SensorJammerStats.java:96:107
    java: cannot find symbol
      symbol: variable currRange_Mult
  • SensorJammerStats.java:97:104
    java: cannot find symbol
      symbol: variable currRange_Mult
  • SensorJammerStats.java:98:96
    java: cannot find symbol
      symbol: variable currSensor_Mult
  • SensorJammerStats.java:184:17
    java: cannot find symbol
      symbol:   variable targetData
      location: class com.fs.starfarer.api.impl.combat.SensorJammerStats
  • SensorJammerStats.java:185:17
    java: cannot find symbol
      symbol:   variable targetData
      location: class com.fs.starfarer.api.impl.combat.SensorJammerStats
  • SensorJammerStats.java:186:51
    java: cannot find symbol
      symbol:   variable targetData
      location: class com.fs.starfarer.api.impl.combat.SensorJammerStats
  • \SensorJammerStats.java:186:124
    java: cannot find symbol
      symbol:   variable targetData
      location: class com.fs.starfarer.api.impl.combat.SensorJammerStats
[close]

Script with Error lines marked bold:
Spoiler
package com.fs.starfarer.api.impl.combat;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipSystemAPI.SystemState;
import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.util.Misc;

public class SensorJammerStats extends BaseShipSystemScript {
   public static Object KEY_SHIP = new Object();
   public static Object KEY_TARGET = new Object();
   
   public static float RANGE_MULT = 0.8f;
   public static float SENSOR_MULT = 0.6f;   
   protected static float RANGE = 1500f;
   
   public static Color TEXT_COLOR = new Color(255,55,55,255);
   
   public static Color JITTER_COLOR = new Color(255,50,50,75);
   public static Color JITTER_UNDER_COLOR = new Color(255,100,100,155);

   
   public static class TargetData {
      public ShipAPI ship;
      public ShipAPI target;
      public EveryFrameCombatPlugin targetEffectPlugin;
      public float currRange_Mult;
      public float currSensor_Mult;      
      public float elaspedAfterInState;
      public TargetData(ShipAPI ship, ShipAPI target) {
         this.ship = ship;
         this.target = target;
      }
   }
   
   
   public void apply(MutableShipStatsAPI stats, final String id, State state, float effectLevel) {
      ShipAPI ship = null;
      if (stats.getEntity() instanceof ShipAPI) {
         ship = (ShipAPI) stats.getEntity();
      } else {
         return;
      }
      
      final String targetDataKey = ship.getId() + "_Jammer_target_data";
      
      Object targetDataObj = Global.getCombatEngine().getCustomData().get(targetDataKey);
      if (state == State.IN && targetDataObj == null) {
         ShipAPI target = findTarget(ship);
         Global.getCombatEngine().getCustomData().put(targetDataKey, new TargetData(ship, target));
         if (target != null) {
            if (target.getFluxTracker().showFloaty() ||
                  ship == Global.getCombatEngine().getPlayerShip() ||
                  target == Global.getCombatEngine().getPlayerShip()) {
               target.getFluxTracker().showOverloadFloatyIfNeeded("Sensors Jammed!", TEXT_COLOR, 4f, true);
            }
         }
      } else if (state == State.IDLE && targetDataObj != null) {
         Global.getCombatEngine().getCustomData().remove(targetDataKey);
         ((TargetData)targetDataObj).currRange_Mult = 1f;
         ((TargetData)targetDataObj).currSensor_Mult = 1f;         
         targetDataObj = null;
      }
      if (targetDataObj == null || ((TargetData) targetDataObj).target == null) return;
      
      final TargetData targetData = (TargetData) targetDataObj;
      targetData.currRange_Mult = RANGE_MULT * (1f - effectLevel);
      targetData.currSensor_Mult = SENSOR_MULT * (1f - effectLevel);      
      if (targetData.targetEffectPlugin == null) {
         targetData.targetEffectPlugin = new BaseEveryFrameCombatPlugin() {
            @Override
            public void advance(float amount, List<InputEventAPI> events) {
               if (Global.getCombatEngine().isPaused()) return;
               if (targetData.target == Global.getCombatEngine().getPlayerShip()) {
                  Global.getCombatEngine().maintainStatusForPlayerShip(KEY_TARGET,
                        targetData.ship.getSystem().getSpecAPI().getIconSpriteName(),
                        targetData.ship.getSystem().getDisplayName(),
                        "" + (int)((targetData.currRange_Mult - 1f) * 100f) + "% Weapon Range and " + (int)((targetData.currSensor_Mult - 1f) * 100f) + "% Sensor Range", true);
               }
               
               if (targetData.currRange_Mult <= 1f || !targetData.ship.isAlive()) {
                  targetData.target.getMutableStats().getBallisticWeaponRangeBonus().unmodify(id);
                  targetData.target.getMutableStats().getEnergyWeaponRangeBonus().unmodify(id);
                  targetData.target.getMutableStats().getSightRadiusMod().unmodify(id);
                  Global.getCombatEngine().removePlugin(targetData.targetEffectPlugin);
               } else {
96                  targetData.target.getMutableStats().getBallisticWeaponRangeBonus().modifyMult(id, currRange_Mult);
97                  targetData.target.getMutableStats().getEnergyWeaponRangeBonus().modifyMult(id, currRange_Mult);
98                  targetData.target.getMutableStats().getSightRadiusMod().modifyMult(id, currSensor_Mult);

               }
            }
         };
         Global.getCombatEngine().addPlugin(targetData.targetEffectPlugin);
      }
      
      
      if (effectLevel > 0) {
         if (state != State.IN) {
            targetData.elaspedAfterInState += Global.getCombatEngine().getElapsedInLastFrame();
         }
         float shipJitterLevel = 0;
         if (state == State.IN) {
            shipJitterLevel = effectLevel;
         } else {
            float durOut = 0.5f;
            shipJitterLevel = Math.max(0, durOut - targetData.elaspedAfterInState) / durOut;
         }
         float targetJitterLevel = effectLevel;
         
         float maxRangeBonus = 50f;
         float jitterRangeBonus = shipJitterLevel * maxRangeBonus;
         
         Color color = JITTER_COLOR;
         if (shipJitterLevel > 0) {
            //ship.setJitterUnder(KEY_SHIP, JITTER_UNDER_COLOR, shipJitterLevel, 21, 0f, 3f + jitterRangeBonus);
            ship.setJitter(KEY_SHIP, color, shipJitterLevel, 4, 0f, 0 + jitterRangeBonus * 1f);
         }
         
         if (targetJitterLevel > 0) {
            //target.setJitterUnder(KEY_TARGET, JITTER_UNDER_COLOR, targetJitterLevel, 5, 0f, 15f);
            targetData.target.setJitter(KEY_TARGET, color, targetJitterLevel, 3, 0f, 5f);
         }
      }
   }
   
   
   public void unapply(MutableShipStatsAPI stats, String id) {
      
   }
   
   protected ShipAPI findTarget(ShipAPI ship) {
      float range = getMaxRange(ship);
      boolean player = ship == Global.getCombatEngine().getPlayerShip();
      ShipAPI target = ship.getShipTarget();
      
      if (ship.getShipAI() != null && ship.getAIFlags().hasFlag(AIFlags.TARGET_FOR_SHIP_SYSTEM)){
         target = (ShipAPI) ship.getAIFlags().getCustom(AIFlags.TARGET_FOR_SHIP_SYSTEM);
      }
      
      if (target != null) {
         float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
         float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
         if (dist > range + radSum) target = null;
      } else {
         if (target == null || target.getOwner() == ship.getOwner()) {
            if (player) {
               target = Misc.findClosestShipEnemyOf(ship, ship.getMouseTarget(), HullSize.FIGHTER, range, true);
            } else {
               Object test = ship.getAIFlags().getCustom(AIFlags.MANEUVER_TARGET);
               if (test instanceof ShipAPI) {
                  target = (ShipAPI) test;
                  float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
                  float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
                  if (dist > range + radSum) target = null;
               }
            }
         }
         if (target == null) {
            target = Misc.findClosestShipEnemyOf(ship, ship.getLocation(), HullSize.FIGHTER, range, true);
         }
      }
      
      return target;
   }
   
   
   public static float getMaxRange(ShipAPI ship) {
      return ship.getMutableStats().getSystemRangeBonus().computeEffective(RANGE);
   }

   
   public StatusData getStatusData(int index, State state, float effectLevel) {
      if (effectLevel > 0) {
         if (index == 0) {
184            targetData.currRange_Mult = RANGE_MULT * (1f - effectLevel);
185            targetData.currSensor_Mult = SENSOR_MULT * (1f - effectLevel);
186            return new StatusData("" + (int)((targetData.currRange_Mult - 1f) * 100f) + "% Weapon Range and " + (int)((targetData.currSensor_Mult - 1f) * 100f) + "% Sensor Range", false);

         }
      }
      return null;
   }


   @Override
   public String getInfoText(ShipSystemAPI system, ShipAPI ship) {
      if (system.isOutOfAmmo()) return null;
      if (system.getState() != SystemState.IDLE) return null;
      
      ShipAPI target = findTarget(ship);
      if (target != null && target != ship) {
         return "READY";
      }
      if ((target == null) && ship.getShipTarget() != null) {
         return "OUT OF RANGE";
      }
      return "NO TARGET";
   }

   
   @Override
   public boolean isUsable(ShipSystemAPI system, ShipAPI ship) {
      //if (true) return true;
      ShipAPI target = findTarget(ship);
      return target != null && target != ship;
   }

}
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 17, 2024, 09:49:54 AM
thanks for the info about the commoditys.csv. i really needed that for reasons of understanding.
a list of tags that i have no clue what do are as follows:

No problem! So for most of the tags, you can actually open up Commodities.java, look for the various TAG_<name> static data members, and search for references to see where they're used, provided you're using an IDE of some kind. Most of these are only used from the code in the api zip; a few have uses outside it as well:

A few other things:
3) crew

Governs CommoditySpecAPI.isCrew()

4) personnel

Whether it uses personnel cargo space, iirc.


9) exotic

Governs CommoditySpecAPI.isExotic() (which I think isn't used)

10) meta
11) nonecon

Whether the commodity participates in the economy or is something special like an AI core. I don't remember the difference here.

12) ai_core (I think this is just what can be put in the AI slot at a colony, but am unsure)

Yep, that's correct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 17, 2024, 09:52:34 AM
Hello everyone, I'm back with another silly question.

So I tried to generate some fleets in my campaign missions, and I would like to add some variants of my special mission ships to the fleet. I used fleet.addmember(String variantId) method. But then I encountered a strange bug, the variants generated in the fleet are getting their hullmods correct, and their built-in weapons are correct. But for all other weapon slots, the weapons from my mod are just not showing up. Does anyone know how to fix it?

Update: OK,I found the answer to my silly question. I set the tiers of those weapons too high. A notice to anyone who may read this:

DO NOT SET YOUR WEAPON TIER ABOVE 3, OR THE WEAPON WOULD NOT GET RECOGNIZED BY THE GAME! IT WILL NOT APPEAR IN MARKETS, NOR APPEAR IN VARIANTS.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 17, 2024, 04:24:04 PM
OK, I met another question.

So I'm trying to add specific variants to my fleet, and I'm using fleet.addvariant method. However, some times I may get some weapon slots end up having different weapons than in the variant file. How could I fix this issue?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: hondaEbro on March 17, 2024, 06:22:11 PM
Hello! New guy to the forum, I appear to be running into an issue with a replicable fatal CTD. Starsector is reporting a null pointer of some sort, and I have a few mods enabled, so I was wondering if anyone has experienced the same. All mods are, to my knowledge/SMOL, up to date. I will attach the relevant section of the error log for reference.

325244 [Thread-6] INFO  sound.O  - Cleaning up music with id [Ambush.ogg]
325485 [Thread-2] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException: Cannot invoke "com.fs.starfarer.api.campaign.SpecialItemData.getId()" because "this.data" is null
java.lang.NullPointerException: Cannot invoke "com.fs.starfarer.api.campaign.SpecialItemData.getId()" because "this.data" is null
   at com.fs.starfarer.campaign.ui.trade.CargoItemStack.getSpecialItemSpecIfSpecial(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.campaign.ui.trade.CargoItemStack.readResolve(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.campaign.ui.trade.CargoItemStack.<init>(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.campaign.fleet.CargoData.addItems(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.campaign.fleet.CargoData.addSpecial(Unknown Source) ~[port_obf.jar:?]
   at boggled.scripts.BoggledTerraformingProjectEffect$IndustryRemove.applyProjectEffectImpl(BoggledTerraformingProjectEffect.java:2321) ~[?:?]
   at boggled.scripts.BoggledTerraformingProjectEffect$TerraformingProjectEffect.applyProjectEffect(BoggledTerraformingProjectEffect.java:93) ~[?:?]
   at boggled.campaign.econ.industries.BoggledCommonIndustry.buildingFinished(BoggledCommonIndustry.java:308) ~[?:?]
   at boggled.campaign.econ.industries.BoggledBaseIndustry.buildingFinished(BoggledBaseIndustry.java:47) ~[?:?]
   at com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry.finishBuildingOrUpgra ding(BaseIndustry.java:560) ~[starfarer.api.jar:?]
   at boggled.campaign.econ.industries.BoggledBaseIndustry.finishBuildingOrUpgrading(BoggledBaseIndustry.java:58) ~[?:?]
   at com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry.advance(BaseIndustry.java:457) ~[starfarer.api.jar:?]
   at boggled.campaign.econ.industries.BoggledBaseIndustry.advance(BoggledBaseIndustry.java:101) ~[?:?]
   at com.fs.starfarer.campaign.econ.Market.advance(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.campaign.econ.Economy.advance(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source) ~[port_obf.jar:?]
   at com.fs.state.AppDriver.begin(Unknown Source) ~[port.common_obf.jar:?]
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source) ~[port_obf.jar:?]
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source) ~[port_obf.jar:?]
   at java.base/java.lang.Thread.run(Thread.java:1575) [?:?]
325555 [Thread-8] INFO  sound.O  - Creating streaming player for music with id [Stellar_Rust.ogg]
325557 [Thread-8] INFO  sound.OooO  - Playing music with id [Stellar_Rust.ogg]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2024, 07:35:49 AM
OK, I met another question.

So I'm trying to add specific variants to my fleet, and I'm using fleet.addvariant method. However, some times I may get some weapon slots end up having different weapons than in the variant file. How could I fix this issue?

You can add the "no_autofit" tag to either the variant or the hull to avoid this, I think.

@hondaEbro: hi! This isn't the right thread for this, but: this looks like a bug with whatever mod the "BoggledTerraformingProjectEffect" class is from. For future reference, you'd want to post these kinds of issues in the Bug Reports & Support (modded) (https://fractalsoftworks.com/forum/index.php?board=14.0) board.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: hondaEbro on March 18, 2024, 03:46:08 PM
Ah, my sincere apologies. Bright side, I spent 4 hours messing around with the mod in order to bugfix it and make it functional. Gotta go hunt down the mod page and post the info and my workaround for the author. Cheers, broseph.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 18, 2024, 08:25:44 PM
No worries, cheers :) Congrats on figuring it out!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 19, 2024, 01:04:52 AM
OK, I met another question.

So I'm trying to add specific variants to my fleet, and I'm using fleet.addvariant method. However, some times I may get some weapon slots end up having different weapons than in the variant file. How could I fix this issue?

You can add the "no_autofit" tag to either the variant or the hull to avoid this, I think.

@hondaEbro: hi! This isn't the right thread for this, but: this looks like a bug with whatever mod the "BoggledTerraformingProjectEffect" class is from. For future reference, you'd want to post these kinds of issues in the Bug Reports & Support (modded) (https://fractalsoftworks.com/forum/index.php?board=14.0) board.

Thank you, Alex! This is helpful. Though I avoided the issue this time by creating mission-specific copies of the ships and variants so that all weapons are built-in, I think this way is much better and saves tons of time.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 19, 2024, 08:28:19 AM
Oh wow - using a chainsaw instead of a scalpel, but hey, if it works! Points for creativity, for sure :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on March 19, 2024, 01:27:18 PM
hello! thanks for the info on how to find out things like this. i would like to make a report though, as i have found something that does not quite seem right when looking through the code, and double checking with my own experiments
4) personnel
Whether it uses personnel cargo space, iirc.
the personnel tag does determine if a commodity uses personnel space, but only for NPC trade fleets? It does nothing for at all for commodity's in the players cargo hold. and I think that might be a bug, because why would it be like that for only NPC trade fleets?? (as a side note, if this is a bug like i suspect, and you make the personnel tag make commodity use personnel space instead, please let us have values that are not '1' for how mush personnel space a commodity takes up. I ask this because i see no system in place to handle that right now)

secondly i have a question:
1) how do i make it so one can loot a commodity (be it from ruins or stations, or salvaging or what have you) is there like a loot table system or..?

and that's all!
thanks for the help with the subject. I'm trying to organize data on how commodity's work, and this has been really really helpful so far. so thanks
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: vicegrip on March 21, 2024, 02:31:39 AM
Is there a way to rename the station of a colony in code to something besides planetname Station?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Ruddygreat on March 21, 2024, 03:32:28 PM
Is there a way to rename the station of a colony in code to something besides planetname Station?

can't you just use the setName() method of sectorEntityToken on the station?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 21, 2024, 04:14:05 PM
the personnel tag does determine if a commodity uses personnel space, but only for NPC trade fleets? It does nothing for at all for commodity's in the players cargo hold. and I think that might be a bug, because why would it be like that for only NPC trade fleets?? (as a side note, if this is a bug like i suspect, and you make the personnel tag make commodity use personnel space instead, please let us have values that are not '1' for how mush personnel space a commodity takes up. I ask this because i see no system in place to handle that right now)

Ah, looks like you're right; I think the core code is hardcoded to count crew + marines. Honestly, I haven't dug around in that area of the code for a while.

secondly i have a question:
1) how do i make it so one can loot a commodity (be it from ruins or stations, or salvaging or what have you) is there like a loot table system or..?

Yeah - see data/campaign/procgen/drop_groups.csv

And for example salvage_entity_gen_data.csv refers to drop groups defined in that file.

There's actually fairly up-to-date documentation on this :)

https://fractalsoftworks.com/forum/index.php?topic=15244.0
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Killer of Fate on March 22, 2024, 10:42:53 AM
short question... I swear there was a tag for wpn that allowed for "fireSoundOne" to overlap, I used it for something, but also didn't. And now... I kinda forgot what that tag was, and I can't find it anywhere. I'm not even sure if it ever existed anymore.

Uhhhhhh, do you remember it perhaps? Or could you at least point me to where I could find it?

ps. I also need to ask what is the tag you would use in weapondata to make a weapon set to firing in alternating in spite of not being a typical like strike weapon. And vice versa. I think there is one. But I can't find it at the moment. Could you... Help a fella out? 'd be cool. Thanks in advance. If somehow there isn't and it's just me misremembering, don't worry about it. It's not important.

pps. uhhhh, do the c/s or whatever... These weird numbers. Can they be deleted or are they important to the game somehow?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 24, 2024, 10:08:40 AM
short question... I swear there was a tag for wpn that allowed for "fireSoundOne" to overlap, I used it for something, but also didn't. And now... I kinda forgot what that tag was, and I can't find it anywhere. I'm not even sure if it ever existed anymore.

Uhhhhhh, do you remember it perhaps? Or could you at least point me to where I could find it?

As far as I can see there's no such functionality in the playback code, fireSoundOne is stopped when the weapon stops firing.

ps. I also need to ask what is the tag you would use in weapondata to make a weapon set to firing in alternating in spite of not being a typical like strike weapon. And vice versa. I think there is one. But I can't find it at the moment. Could you... Help a fella out? 'd be cool. Thanks in advance. If somehow there isn't and it's just me misremembering, don't worry about it. It's not important.

Hmm, I don't understand what you mean - alternating fire and strike weapons are not concepts that are tied together?

pps. uhhhh, do the c/s or whatever... These weird numbers. Can they be deleted or are they important to the game somehow?

Those are not needed, just set by a formula in the original sheet I use. I forget the details right now.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: spinloki on March 25, 2024, 08:08:53 PM
I've got an idea for a mod that leverages capital 'E' Events. Are there any working examples out there yet whose source code I could look at?

EDIT: Never mind, found some! Cheers anyway
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Axisoflint on March 27, 2024, 08:31:08 PM
After getting the urge to mod the list of ship names for my faction, I found a mod that does that, altered it for my purposes (purely for my personal use, I'm not intending to distribute it and claim credit for someone else's work), but in the process I was looking at the vanilla ship names list and there's a #'d out section for names for specific ship classes. Is there a way to specify which names go to which class?

Also, on a slightly different but related note, is it possible to have some sort of toggle so that names aren't re-used unless there are no names left on the list?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 28, 2024, 06:02:28 PM
What is the effective "whitelist" for weapons being sold and weapons being sold through an arms dealer?

I'm aware that no_sell or tier 5 act as a "blacklist" of sorts for normal sales and no_dealer is the "blacklist" for arms deals.

My Assumption for market sales is not only does the weapon in question not have the "no_sell" tag  or tier 5, but also must:
1. Be known by a target faction (faction tagged in weapon file, weapon in known weapons in the faction file, or weapon is in a bp_package the faction knows or any other tag like standard)
2. Faction has a market the player can interact with.

Assuming the above is true does the Arms Dealer have similar requirements?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 28, 2024, 08:07:24 PM
After getting the urge to mod the list of ship names for my faction, I found a mod that does that, altered it for my purposes (purely for my personal use, I'm not intending to distribute it and claim credit for someone else's work), but in the process I was looking at the vanilla ship names list and there's a #'d out section for names for specific ship classes. Is there a way to specify which names go to which class?

Ah, that's very old and I don't think it ever actually was implemented.

Also, on a slightly different but related note, is it possible to have some sort of toggle so that names aren't re-used unless there are no names left on the list?

There isn't sorry!

What is the effective "whitelist" for weapons being sold and weapons being sold through an arms dealer?

I'm aware that no_sell or tier 5 act as a "blacklist" of sorts for normal sales and no_dealer is the "blacklist" for arms deals.

My Assumption for market sales is not only does the weapon in question not have the "no_sell" tag  or tier 5, but also must:
1. Be known by a target faction (faction tagged in weapon file, weapon in known weapons in the faction file, or weapon is in a bp_package the faction knows or any other tag like standard)
2. Faction has a market the player can interact with.

Assuming the above is true does the Arms Dealer have similar requirements?

See: CustomProductionContract.addArmsDealerBlueprints()

In brief, the dealer excludes weapons with no_sell, no_dealer, and restricted, and weapons with AIHints.SYSTEM, but may sell anything that passes those checks, regardless of it being available to the faction etc.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 28, 2024, 10:13:23 PM
See: CustomProductionContract.addArmsDealerBlueprints()

In brief, the dealer excludes weapons with no_sell, no_dealer, and restricted, and weapons with AIHints.SYSTEM, but may sell anything that passes those checks, regardless of it being available to the faction etc.

So in theory if I were to make a modded weapon that I want a faction to use, but not sell, while still allowing for Arms dealer production I would have to:

1. Set Weapon Tier at 5 for no sale.
2. Do not add the SYSTEM AIHint.
3. Do not add the no_sell tag.
4. Do not add the no_dealer tag.
5. Do not add the restricted tag.

For other control on how the weapon could be gotten (or not) I could also make use of:

1. no_drop. This is post combat loot and salvage if I'm not mistaken?
2. no_drop_salvage. This is location based salvage (Like a Research Station) If I'm correct.

I also assume that the SYSTEM hint also prevents drops of the weapon in question too?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 29, 2024, 09:23:44 AM
This all sounds mostly correct. The one possible issue is that I'm not sure the weapon will actually be used by faction fleets if it's tier is set to 5, if the variants are randomized-  that is, if the hull or the variant do not have the no_autofit tag.

But! One thing I forgot to mention (which you can see from the code) - there's also a "dealer" tag, which does exactly what you want, i.e. allowing the weapon to be sold by the dealer while it has the no_sell tag.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: pgamesfood on March 29, 2024, 09:30:01 AM
hi, do you know if something like this idea is already existing, or if it would be possible to do in the game?

Battle Star DreadNautica (a battlestar gallactica mod idea for StarSector) - by pgamesfood :o)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

idea is for us to start out with a super massive ship hull, (either as humans or the redacted ai)
and the ship has 50 weapon mounts of multiple hardpoints, but we only start with 10 mining lasers.
and the ship has space for 10 fighter units, but we only start with 2 mining pod drones
(the ship would have the appropriate power and capacity for them etc, but the rest of the weapons and fighters are all missing)

and the Objective: (and fun) would be the need to Find and Mount, a weapon or fighter into every other empty slot :) (BUT via salvage mostly, or later replacement)

Rationale:
basically i had the idea because whenever i salvaged a battle site, or won a battle, i was finding more weapons then i could mount, and i always wanted to just be able to equip even the smallest of spare weapons, to add to the ships capabilities to see how it would look in future battles, not only in vanilla, but also because when you play with a bunch of mods, you get lots new unique weapons and missiles and fighter types, it would be cool to mix and match a bit of everything, however small :o)


im not sure if its easy to set up limits in the game, but as a self-enforced player rule, it would be something like this:
- you can add any other ships to the fleet, BUT can only deploy your main huge starter ship in combats where possible.
- you can only mount weapon modules and fighters that you FIND or win in battle to your ship.
- BUT you can buy any weapon and fighters etc from trading, BUT only to replace something you already have found.
(you can replace the mining lasers in this way but ONLY after filling all 50 weapon mounts first)
(you can replace the mining pod fighters in this way but ONLY after filling all 10 fighter slots with fighters first)
(you can always buy things when you want, to save them for swapping out later, and can buy/sell items for trading, even weapons and fighters, just follow the rules above) :o)


extra ideas: you can buy another super massive starter ship from traders at a huge cost, but only after you have maxxed out your 1st one.
challenge will be to end up with a fleet of super massive ships in this way, completing all mounts and fighter slots in this way, 1 big ship at a time :O)

can something like this be done in game? a lot of self-enforced rules will make it easier, but am not sure if making such a big sturdy ship is possible, with alll the weapon mounts for energy/missiles/balistics and figher slots are possible, and with high enough stats to be able to move/shoot/shield/armour etc? :)

Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 29, 2024, 12:30:54 PM
A quick question. Does anyone know how to make combat screenshots? I want to make some to post on my Mod page, but I don't know how to do this. Everytime when I try to make a screenshot, the game would not stop, and I end up missing those best instances during a combat. Or is it necessary that I have to let the AI fight the battle and be a pure screenshot taker.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on March 29, 2024, 12:37:40 PM
See: CustomProductionContract.addArmsDealerBlueprints()

In brief, the dealer excludes weapons with no_sell, no_dealer, and restricted, and weapons with AIHints.SYSTEM, but may sell anything that passes those checks, regardless of it being available to the faction etc.

So in theory if I were to make a modded weapon that I want a faction to use, but not sell, while still allowing for Arms dealer production I would have to:

1. Set Weapon Tier at 5 for no sale.
2. Do not add the SYSTEM AIHint.
3. Do not add the no_sell tag.
4. Do not add the no_dealer tag.
5. Do not add the restricted tag.

For other control on how the weapon could be gotten (or not) I could also make use of:

1. no_drop. This is post combat loot and salvage if I'm not mistaken?
2. no_drop_salvage. This is location based salvage (Like a Research Station) If I'm correct.

I also assume that the SYSTEM hint also prevents drops of the weapon in question too?

Updates on Alex's comments: No you do not want to do this. I did experiments with my own mod of setting weapon tiers to 5, and what happened was that the weapon would almost NEVER appear in the game naturally. Even if you put it in the variant file, and you generate your variant with autofit, the weapon would get lost. My suggestion is that REFRAIN from writing the tier of a weapon above 3, unless you want it to be a weapon that is almost purely used by player. For the military productions, it's more or less not affected as long as the faction knows the weapon. I believe you could set a 'restricted' or 'no_sell' tag with the weapon if you don't want to see it on markets.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 30, 2024, 02:27:19 AM
See: CustomProductionContract.addArmsDealerBlueprints()

In brief, the dealer excludes weapons with no_sell, no_dealer, and restricted, and weapons with AIHints.SYSTEM, but may sell anything that passes those checks, regardless of it being available to the faction etc.

So in theory if I were to make a modded weapon that I want a faction to use, but not sell, while still allowing for Arms dealer production I would have to:

1. Set Weapon Tier at 5 for no sale.
2. Do not add the SYSTEM AIHint.
3. Do not add the no_sell tag.
4. Do not add the no_dealer tag.
5. Do not add the restricted tag.

For other control on how the weapon could be gotten (or not) I could also make use of:

1. no_drop. This is post combat loot and salvage if I'm not mistaken?
2. no_drop_salvage. This is location based salvage (Like a Research Station) If I'm correct.

I also assume that the SYSTEM hint also prevents drops of the weapon in question too?

Updates on Alex's comments: No you do not want to do this. I did experiments with my own mod of setting weapon tiers to 5, and what happened was that the weapon would almost NEVER appear in the game naturally. Even if you put it in the variant file, and you generate your variant with autofit, the weapon would get lost. My suggestion is that REFRAIN from writing the tier of a weapon above 3, unless you want it to be a weapon that is almost purely used by player. For the military productions, it's more or less not affected as long as the faction knows the weapon. I believe you could set a 'restricted' or 'no_sell' tag with the weapon if you don't want to see it on markets.

Sounds like no_sell + dealer might be the best option then. I'm not doing weapons atm, but in the past (personal mod) I felt that it was too easy to flood the market and dilute the pool of weapon variety.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Anexgohan on March 30, 2024, 05:18:26 AM
Any know of a spreadsheet / google doc that I can use to calculate weapon damage for balancing.
I remember there was such a google doc i used 2 years ago, where i could enter the damage, burst, reload, etc and it would show how much dps it did and per shot.
Anyone member?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on March 30, 2024, 09:46:59 AM
hi, do you know if something like this idea is already existing, or if it would be possible to do in the game?

...

im not sure if its easy to set up limits in the game, but as a self-enforced player rule, it would be something like this:
- you can add any other ships to the fleet, BUT can only deploy your main huge starter ship in combats where possible.
- you can only mount weapon modules and fighters that you FIND or win in battle to your ship.
- BUT you can buy any weapon and fighters etc from trading, BUT only to replace something you already have found.
(you can replace the mining lasers in this way but ONLY after filling all 50 weapon mounts first)
(you can replace the mining pod fighters in this way but ONLY after filling all 10 fighter slots with fighters first)
(you can always buy things when you want, to save them for swapping out later, and can buy/sell items for trading, even weapons and fighters, just follow the rules above) :o)


extra ideas: you can buy another super massive starter ship from traders at a huge cost, but only after you have maxxed out your 1st one.
challenge will be to end up with a fleet of super massive ships in this way, completing all mounts and fighter slots in this way, 1 big ship at a time :O)

can something like this be done in game? a lot of self-enforced rules will make it easier, but am not sure if making such a big sturdy ship is possible, with alll the weapon mounts for energy/missiles/balistics and figher slots are possible, and with high enough stats to be able to move/shoot/shield/armour etc? :)

The game makes no distinction between where you got a weapon - a stack of 10 pulse lasers is a stack of 10 pulse lasers, regardless of how many you found vs how many you bought. So this would be complicated to try to manage, these are not the sort of rules that map nicely onto what the game does/keeps track of.


A quick question. Does anyone know how to make combat screenshots? I want to make some to post on my Mod page, but I don't know how to do this. Everytime when I try to make a screenshot, the game would not stop, and I end up missing those best instances during a combat. Or is it necessary that I have to let the AI fight the battle and be a pure screenshot taker.

Is pressing PrintScreen not working?

Any know of a spreadsheet / google doc that I can use to calculate weapon damage for balancing.
I remember there was such a google doc i used 2 years ago, where i could enter the damage, burst, reload, etc and it would show how much dps it did and per shot.
Anyone member?

Sorry, not aware of a spreadsheet. But the game computes and prints some of this info to the log when starting up - search for "Derived weapon info".)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: ctuncks on March 30, 2024, 09:28:28 PM
Any know of a spreadsheet / google doc that I can use to calculate weapon damage for balancing.
I remember there was such a google doc i used 2 years ago, where i could enter the damage, burst, reload, etc and it would show how much dps it did and per shot.
Anyone member?

I think some of Vayra's mods had them, but I personally found them not as useful as I would have liked, so I made my own in excel, granted it was somewhat flawed in the end too.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on April 01, 2024, 06:11:18 AM
Hello.

I am working on a beam weapon that does additional damage based on the flux level of the ship that fires the beam.

Here is my code:

Code
package data.scripts.weapons;

import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.BeamAPI;
import com.fs.starfarer.api.combat.BeamEffectPlugin;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;



public class DemiurgCuttingBeam implements BeamEffectPlugin
{

    private final IntervalUtil fireInterval = new IntervalUtil(0.1f, 0.1f); //interval between applying flux
    private float FluxLevel = 0f;
    private float MaxFluxLevel = 0f;
    private float FluxPercentage = 0f;

    private float BaseBeamDamageMulti = 0f;

    public static String DAMAGE_MOD_ID = "demiurgmining_dam_mod";

    @Override
    public void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
{

        if (engine.isPaused())
{
            return;
        }

        fireInterval.advance(amount);

        CombatEntityAPI target = beam.getDamageTarget();
        //If we have a target, target is a Ship
        if (target != null && target instanceof ShipAPI)
{
            if (fireInterval.intervalElapsed())
{
                if (beam.getBrightness() >= 1f)
{
                    ShipAPI targetship = (ShipAPI) target; //cast as ship
                    ShipAPI firingship = beam.getSource();

                    FluxLevel = firingship.getCurrFlux();
                    MaxFluxLevel = firingship.getMaxFlux();
                    FluxPercentage = ((FluxLevel/MaxFluxLevel) * 100);

                    if (FluxPercentage < 20 )
                    {
                        BaseBeamDamageMulti = 1;
                    }
                    else if ((FluxPercentage >= 20 ) &&  (FluxPercentage < 30 ))
                    {
                        BaseBeamDamageMulti = 2;
                    }
                    else if ((FluxPercentage >= 30 ) &&  (FluxPercentage < 40 ))
                    {
                        BaseBeamDamageMulti = 3;
                    }
                    else if ((FluxPercentage >= 40 ) &&  (FluxPercentage < 50 ))
                    {
                        BaseBeamDamageMulti = 4;
                    }
                    else if ((FluxPercentage >= 50 ) &&  (FluxPercentage < 60 ))
                    {
                        BaseBeamDamageMulti = 5;
                    }
                    else if ((FluxPercentage >= 60 ) &&  (FluxPercentage < 70 ))
                    {
                        BaseBeamDamageMulti = 6;
                    }
                    else if ((FluxPercentage >= 70 ) &&  (FluxPercentage < 80 ))
                    {
                        BaseBeamDamageMulti = 7;
                    }
                    else if (FluxPercentage >= 80 )
                    {
                        BaseBeamDamageMulti = 8;
                    }

                    if (target.getShield() != null && target.getShield().isWithinArc(beam.getTo()))  // target has a shield, beam hits shield
                    {
                        targetship.getFluxTracker().increaseFlux(BaseBeamDamageMulti * beam.getWeapon().getDerivedStats().getDps(), false); //apply flux
                    }
                    else if (target.getShield() == null || (!(target.getShield().isWithinArc(beam.getTo()))))  // No Shield or not hitting target's shield
                    {
                        if (BaseBeamDamageMulti > 1)
                        {
                            targetship.getMutableStats().getBeamDamageTakenMult().modifyMult(DAMAGE_MOD_ID, 1f + BaseBeamDamageMulti * 0.01f);
                        }
                        else
                        {
                            targetship.getMutableStats().getBeamDamageTakenMult().unmodify(DAMAGE_MOD_ID);
                        }
                    }
                }

            }

        }
    }
}


It does seem to compile and do the additional damage as flux raises.
My question is, can this code as above cause the additional damage multiplier to stay on the target ship and not be removed?  If so is there a more reliable way to remove the damage multiplier?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Aku1a on April 01, 2024, 09:34:30 AM
So im having problems adding my weapons to blueprints in the game. Ive added them to their own weapons_data.cvs and it shows in the codex but it isnt listed in the blueprints that should have them. I tried copy pasting a vanilla weapon in but it disappeared from the blueprint it was in after i did that. Im not sure whats wrong because the files are where they should be because it reads all the stats i give the weapons.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Axisoflint on April 01, 2024, 11:57:35 AM
After getting the urge to mod the list of ship names for my faction, I found a mod that does that, altered it for my purposes (purely for my personal use, I'm not intending to distribute it and claim credit for someone else's work), but in the process I was looking at the vanilla ship names list and there's a #'d out section for names for specific ship classes. Is there a way to specify which names go to which class?

Ah, that's very old and I don't think it ever actually was implemented.

Also, on a slightly different but related note, is it possible to have some sort of toggle so that names aren't re-used unless there are no names left on the list?

There isn't sorry!

No problem in either case, just curious :) Thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: AccuracyThruVolume on April 01, 2024, 04:46:44 PM
After getting the urge to mod the list of ship names for my faction, I found a mod that does that, altered it for my purposes (purely for my personal use, I'm not intending to distribute it and claim credit for someone else's work), but in the process I was looking at the vanilla ship names list and there's a #'d out section for names for specific ship classes. Is there a way to specify which names go to which class?




Ah, that's very old and I don't think it ever actually was implemented.

Also, on a slightly different but related note, is it possible to have some sort of toggle so that names aren't re-used unless there are no names left on the list?

There isn't sorry!

No problem in either case, just curious :) Thanks!

My solution to the ship names was to just make a list of over one thousand names for every faction in my mod.  Should make repeats kinda rare  :-)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 01, 2024, 04:59:13 PM
My question is, can this code as above cause the additional damage multiplier to stay on the target ship and not be removed?  If so is there a more reliable way to remove the damage multiplier?

It looks like it could stick around permanently, yes. I'd suggesting using the script to add an implementation of DamageDealtModifier to the ship with the weapon instead.


So im having problems adding my weapons to blueprints in the game. Ive added them to their own weapons_data.cvs and it shows in the codex but it isnt listed in the blueprints that should have them. I tried copy pasting a vanilla weapon in but it disappeared from the blueprint it was in after i did that. Im not sure whats wrong because the files are where they should be because it reads all the stats i give the weapons.

What goes into blueprint packages is determined by the tags the weapon has, so I'd look at those.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: pgamesfood on April 03, 2024, 04:06:50 AM
hi, do you know if something like this idea is already existing, or if it would be possible to do in the game?

...

im not sure if its easy to set up limits in the game, but as a self-enforced player rule, it would be something like this:
- you can add any other ships to the fleet, BUT can only deploy your main huge starter ship in combats where possible.
- you can only mount weapon modules and fighters that you FIND or win in battle to your ship.
- BUT you can buy any weapon and fighters etc from trading, BUT only to replace something you already have found.
(you can replace the mining lasers in this way but ONLY after filling all 50 weapon mounts first)
(you can replace the mining pod fighters in this way but ONLY after filling all 10 fighter slots with fighters first)
(you can always buy things when you want, to save them for swapping out later, and can buy/sell items for trading, even weapons and fighters, just follow the rules above) :o)


extra ideas: you can buy another super massive starter ship from traders at a huge cost, but only after you have maxxed out your 1st one.
challenge will be to end up with a fleet of super massive ships in this way, completing all mounts and fighter slots in this way, 1 big ship at a time :O)

can something like this be done in game? a lot of self-enforced rules will make it easier, but am not sure if making such a big sturdy ship is possible, with alll the weapon mounts for energy/missiles/balistics and figher slots are possible, and with high enough stats to be able to move/shoot/shield/armour etc? :)

The game makes no distinction between where you got a weapon - a stack of 10 pulse lasers is a stack of 10 pulse lasers, regardless of how many you found vs how many you bought. So this would be complicated to try to manage, these are not the sort of rules that map nicely onto what the game does/keeps track of.



ah ok thanks for the reply - its ok, i can use "self enforced" rules for those parts :)
 i just wasnt sure if there was a way for the game to allow for a huge ship with lots of weapon slots, (and flux or stat levels to cater for their firing etc)
as i have seen some capital ships, but not any with 50 weapon slots in a mixed harpoint type before.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 04, 2024, 11:43:26 AM
Ah - that part (the huge ship) is definitely doable!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: pgamesfood on April 05, 2024, 03:00:01 AM
Ah - that part (the huge ship) is definitely doable!

cool, thanks - i'll try and see if i can learn how to use the ship editor mod to make a big ship for the concept  :)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on April 05, 2024, 03:23:20 AM
Is there any way to hide jump point icons on map in star systems?
Correction is there any way to replicate form JumpPoint class behaviour of planetRenderer?
This is obfuscated class so could you give hint Alex how to make one properly?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on April 05, 2024, 07:16:37 PM
hi, do you know if something like this idea is already existing, or if it would be possible to do in the game?

...

im not sure if its easy to set up limits in the game, but as a self-enforced player rule, it would be something like this:
- you can add any other ships to the fleet, BUT can only deploy your main huge starter ship in combats where possible.
- you can only mount weapon modules and fighters that you FIND or win in battle to your ship.
- BUT you can buy any weapon and fighters etc from trading, BUT only to replace something you already have found.
(you can replace the mining lasers in this way but ONLY after filling all 50 weapon mounts first)
(you can replace the mining pod fighters in this way but ONLY after filling all 10 fighter slots with fighters first)
(you can always buy things when you want, to save them for swapping out later, and can buy/sell items for trading, even weapons and fighters, just follow the rules above) :o)


extra ideas: you can buy another super massive starter ship from traders at a huge cost, but only after you have maxxed out your 1st one.
challenge will be to end up with a fleet of super massive ships in this way, completing all mounts and fighter slots in this way, 1 big ship at a time :O)

can something like this be done in game? a lot of self-enforced rules will make it easier, but am not sure if making such a big sturdy ship is possible, with alll the weapon mounts for energy/missiles/balistics and figher slots are possible, and with high enough stats to be able to move/shoot/shield/armour etc? :)

The game makes no distinction between where you got a weapon - a stack of 10 pulse lasers is a stack of 10 pulse lasers, regardless of how many you found vs how many you bought. So this would be complicated to try to manage, these are not the sort of rules that map nicely onto what the game does/keeps track of.


A quick question. Does anyone know how to make combat screenshots? I want to make some to post on my Mod page, but I don't know how to do this. Everytime when I try to make a screenshot, the game would not stop, and I end up missing those best instances during a combat. Or is it necessary that I have to let the AI fight the battle and be a pure screenshot taker.

Is pressing PrintScreen not working?

Any know of a spreadsheet / google doc that I can use to calculate weapon damage for balancing.
I remember there was such a google doc i used 2 years ago, where i could enter the damage, burst, reload, etc and it would show how much dps it did and per shot.
Anyone member?

Sorry, not aware of a spreadsheet. But the game computes and prints some of this info to the log when starting up - search for "Derived weapon info".)

It works, thanks!
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on April 05, 2024, 07:19:27 PM
Another quick question.

Are there some ways we can use to make a ship always get deployed during battles like a station? I made an AI only ship, and I put it in an allied fleet. It is very annoying and lore breaking that sometimes the allied fleet AI decides to hold that ship in reserve if the player has got a good fleet to join the fight.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 07, 2024, 08:25:11 AM
Correction is there any way to replicate form JumpPoint class behaviour of planetRenderer?
This is obfuscated class so could you give hint Alex how to make one properly?

Hmm - you might be able to just put a very small planet in the middle of it and add a non_clickable tag to it, or something like that?


Are there some ways we can use to make a ship always get deployed during battles like a station? I made an AI only ship, and I put it in an allied fleet. It is very annoying and lore breaking that sometimes the allied fleet AI decides to hold that ship in reserve if the player has got a good fleet to join the fight.

You could use CombatFleetManagerAPI to deploy it with code, I believe, but I don't think there's any specific way to just force the AI admiral to deploy that ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Kaysaar on April 08, 2024, 01:29:21 AM
How i can increase frequency of storms to basicaally be always there ( In hyperspace terrian plugin)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: VladimirVV on April 08, 2024, 05:50:37 AM
Correction is there any way to replicate form JumpPoint class behaviour of planetRenderer?
This is obfuscated class so could you give hint Alex how to make one properly?

Hmm - you might be able to just put a very small planet in the middle of it and add a non_clickable tag to it, or something like that?


Are there some ways we can use to make a ship always get deployed during battles like a station? I made an AI only ship, and I put it in an allied fleet. It is very annoying and lore breaking that sometimes the allied fleet AI decides to hold that ship in reserve if the player has got a good fleet to join the fight.

You could use CombatFleetManagerAPI to deploy it with code, I believe, but I don't think there's any specific way to just force the AI admiral to deploy that ship.

Thanks, Alex. That’s helpful to know. I just end up changing the fleet composition to make the AI deployment choice less relevant to prevent it from breaking the lore.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 09, 2024, 05:44:10 AM
How do I find a missile's target? I want to get a list of all missiles targeting a specific ship.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 09, 2024, 10:03:30 AM
Any way to close a Core Campaign Screen? Trying to close the Intel screen as im trying to open a dialog after the player presses an button in intel.
I know you can open dialogs through intel, though it crashes with the kind of dialog im trying to open (A fleet interaction), so i am trying to quit the intel menu and then open a normal dialog.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 09, 2024, 11:55:22 AM
How do I find a missile's target? I want to get a list of all missiles targeting a specific ship.

Something like: if (missile.getAI() instanceof GuidedMissileAI) then get and cast the AI to GuidedMissileAI and call GuidedMissileAI.getTarget()

Any way to close a Core Campaign Screen? Trying to close the Intel screen as im trying to open a dialog after the player presses an button in intel.
I know you can open dialogs through intel, though it crashes with the kind of dialog im trying to open (A fleet interaction), so i am trying to quit the intel menu and then open a normal dialog.

Hmm, I don't think this is possible, actually, there's no method to close the core UI. It seems potentially problematic to add, too - what if stuff is mid-transaction in some way (buy/sell, changing production orders/doctrine, mid some other dialog, etc). Though I suppose that could just be the responsibility of whoever calls the method.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Lukas04 on April 09, 2024, 03:02:42 PM
How do I find a missile's target? I want to get a list of all missiles targeting a specific ship.

Something like: if (missile.getAI() instanceof GuidedMissileAI) then get and cast the AI to GuidedMissileAI and call GuidedMissileAI.getTarget()

Any way to close a Core Campaign Screen? Trying to close the Intel screen as im trying to open a dialog after the player presses an button in intel.
I know you can open dialogs through intel, though it crashes with the kind of dialog im trying to open (A fleet interaction), so i am trying to quit the intel menu and then open a normal dialog.

Hmm, I don't think this is possible, actually, there's no method to close the core UI. It seems potentially problematic to add, too - what if stuff is mid-transaction in some way (buy/sell, changing production orders/doctrine, mid some other dialog, etc). Though I suppose that could just be the responsibility of whoever calls the method.

Sad, guess il just need to think of another way to do what i wanted to do, can probably find some way. Mostly wanted to add a way to re-fight a boss encounter (ziggurat-esque), but i can probably just place some entity somewhere.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 09, 2024, 04:16:55 PM
Ah, sorry :( UI hooks like this are probably some of the hairier things to do, modding wise.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 10, 2024, 12:02:43 PM
Ah, looks like you're right; I think the core code is hardcoded to count crew + marines. Honestly, I haven't dug around in that area of the code for a while.
hey, so i was wondering, if there are any plans to make the 'crew' and 'personnel' tags work (in the commodity CSV).
I'm asking this, because I recently realized that there is a way I could simulate that working (by reducing the min / max crew of all ships in the players fleet), but it would be really hard to do, and would not be posable for the interface to respect such changes, causing lots of player confusing. but then i realized, that if the tags ever were made to work, my efforts would be wasted.
so i suppose that before i waste my time building a janky system that barely works, i should probably ask: are there any plans to fix this, or should i go and do my crazy plan?
(also, if you are wondering if people want this, I actually have gotten quite a few messages asking if crew replacer has the capacity to make non crew commodity's crew ships and and fill crew space on ships, so at least a few people want such a thing)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Shogouki on April 10, 2024, 04:05:40 PM
Ah, looks like you're right; I think the core code is hardcoded to count crew + marines. Honestly, I haven't dug around in that area of the code for a while.
hey, so i was wondering, if there are any plans to make the 'crew' and 'personnel' tags work (in the commodity CSV).
I'm asking this, because I recently realized that there is a way I could simulate that working (by reducing the min / max crew of all ships in the players fleet), but it would be really hard to do, and would not be posable for the interface to respect such changes, causing lots of player confusing. but then i realized, that if the tags ever were made to work, my efforts would be wasted.
so i suppose that before i waste my time building a janky system that barely works, i should probably ask: are there any plans to fix this, or should i go and do my crazy plan?
(also, if you are wondering if people want this, I actually have gotten quite a few messages asking if crew replacer has the capacity to make non crew commodity's crew ships and and fill crew space on ships, so at least a few people want such a thing)

I know I would definitely love this but I'm not sure just how much work it might take to make those changes.  If it wouldn't be very difficult and Alex feels like working towards that I would definitely support it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: rogerbacon on April 10, 2024, 04:07:23 PM
Is there a way to set a ship as untargetable? I see there is ship.isTargetable() but I didn't see a setter. Right now I have a workaround of setting it to the neutral team but that has some unintended consequences so I was hoping there was something obvious I'd missed.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on April 10, 2024, 04:20:58 PM
is there some modifier or cooldown or something somewhere for enemy raids? every time an empire is hostile they launch raids without pause. quite often organizing the next on while the current raid is still running about my system. i just want to put a cooldown between these, i like the mechanic and all, but they are simply coming to often, i literally dont have time to do a mission between raids if i am defending my colonies.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 11, 2024, 10:21:28 AM
hey, so i was wondering, if there are any plans to make the 'crew' and 'personnel' tags work (in the commodity CSV).

Ah, sorry, definitely not. It's annoyingly complicated; the move away from multiple crew XP levels was to simplify things, and I'm definitely not going back or adding this functionality.

(Consider what using other types of crew does to any interactions that involve crew - losing crew during salvage, rescuing crew, picking up stranded crew from a planet, crew leaving due to being unpaid, and so on. It's a mess.)


Is there a way to set a ship as untargetable? I see there is ship.isTargetable() but I didn't see a setter. Right now I have a workaround of setting it to the neutral team but that has some unintended consequences so I was hoping there was something obvious I'd missed.

That method will return true if ship.getStats().getHullDamageTakenMult().getModifiedValue() returns zero.

(It also returns true for hulks etc.)


is there some modifier or cooldown or something somewhere for enemy raids? every time an empire is hostile they launch raids without pause. quite often organizing the next on while the current raid is still running about my system. i just want to put a cooldown between these, i like the mechanic and all, but they are simply coming to often, i literally dont have time to do a mission between raids if i am defending my colonies.

Hmm - are you talking about Nexerelin, or the Colony Crises system? For Crises, they don't happen again if they're defeated; you could change the HostileActivityEventIntel code but that requires fairly in-depth modding.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 11, 2024, 10:59:26 AM
Ah, sorry, definitely not. It's annoyingly complicated; the move away from multiple crew XP levels was to simplify things, and I'm definitely not going back or adding this functionality.

(Consider what using other types of crew does to any interactions that involve crew - losing crew during salvage, rescuing crew, picking up stranded crew from a planet, crew leaving due to being unpaid, and so on. It's a mess.)
hey, thanks for the fast response.
I really hope I'm not being rude here, but i feel the need to clarify my words a little.
I think i might have failed to ask for what i wanted. i suck at words, and trying to ask questions is really stressful sometimes. so I'm going to attempt to explain what i was trying to ask now and probably fail again.
I'm well aware of how mush of a mess it is, as i have a library built around handling such interactions called crew replacer (https://fractalsoftworks.com/forum/index.php?topic=24249.0) that i have been slowly upgrading to handle all commodity interactions the player has in all events in the game, as well as a few mods.
what i was trying to do was ask in a very roundabout way was for a way to change the number of 'crew that are currently crewing star ships' and 'crew using crew space' numbers, but somehow i failed to ask that.
so a more direct version of my question would be: is it possible to make the 'crew that are crewing star ships' and 'crew space used' values be something like, a mutable stat? this way mods like crew replacer could interface with said values and create changes
let things like losses / crew leaving / whatever be handled by the modding community. i know I'm ready to cry trying such a challenge.
again, i hope I'm not being rude, and I'm really sorry if i am, but i needed to say this at some point. also, no pressure if changing such values in such something your not up for, I can still handle this in a somewhat janky way.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 11, 2024, 11:09:11 AM
No worries, you're not being rude at all, and I appreciate the clarification!

Just had a quick look and unfortunately this isn't trivial on my end. There's getCrew() and getMarines() methods, and iirc the sum of those is what gets used, and lots of places assume that getCrew() returns the actual crew-commodity-count. And then there's the crew/marine counts shown in the lower left in the campaign, etc. It's just - things like this, that vanilla does not use, are pretty hard to add without bugs and/or breaking them later (and not noticing, due to not having a vanilla use case). It'd need to be absolutely trivial, and this isn't.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 12, 2024, 12:07:32 PM
No worries, you're not being rude at all, and I appreciate the clarification!

Just had a quick look and unfortunately this isn't trivial on my end. There's getCrew() and getMarines() methods, and iirc the sum of those is what gets used, and lots of places assume that getCrew() returns the actual crew-commodity-count. And then there's the crew/marine counts shown in the lower left in the campaign, etc. It's just - things like this, that vanilla does not use, are pretty hard to add without bugs and/or breaking them later (and not noticing, due to not having a vanilla use case). It'd need to be absolutely trivial, and this isn't.
mush sadness. but thanks for taking a look. ill simply have to do my implementation instead, as janky as it will be, it will still work.
thanks for answering my questions. I hope you have yourself a good day. Im going to take a nap
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on April 12, 2024, 01:06:54 PM
is there a simple way to disable ships in particular mods? got one mod here i really enjoy, but it has so many very slightly different versions of the same ships it kinda floods my list. looking for an easy way to disable it from being used by factions, as well as learning it from a blueprint.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2024, 01:16:59 PM
Im going to take a nap

(Honestly? Solid idea, tempting.)

is there a simple way to disable ships in particular mods? got one mod here i really enjoy, but it has so many very slightly different versions of the same ships it kinda floods my list. looking for an easy way to disable it from being used by factions, as well as learning it from a blueprint.

You can edit that mod's default_ship_roles.json file and remove the variants. It won't remove the ships from the game entirely but they should mostly stop showing up in fleets and for sale at markets. Disabling learning it from a blueprint, you'd need to edit the tags for each ship in ship_data.csv, so that'd be a pain.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on April 12, 2024, 01:52:06 PM
aight, thanks. im kinda working on a 'megamod' project, bashing dozens of mods together, and polishing up the result. i've never been any good at art, and lack the patience for building things from the ground up myself, but i've always been pretty good at tweaking things so they work better. and after my last install of the game i spent DAYS collecting mods to play with that didnt destroy immersion. figured having what i wanted available to others might see use.

not sure about the politics of releasing such a megapack, but there is a massive barrier to entry for new players to the game when it comes to mods. if nothing else, it should serve as a pseudo x-pack for players who simply cant be bothered to spend the time and effort collecting mods to work together.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 12, 2024, 02:27:21 PM
This would definitely be against the forum rules to release, unless you had explicit permission from every author of every mod involved. I mean, I get that you're coming from a positive place here, but modifying and re-releasing the work of others without permission is just a non-starter here.

(Also, consider what happens when there's a bugfix release for one of the mods, or an update...)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on April 12, 2024, 03:04:07 PM
meh, there are a few 'unofficial' mods floating about i've learned exist. so not having an 'official' release isnt gonna upset me terribly. as to updates and what-not, my plan had been to make a complete 'as-is' package. truth, the reason for this is a friend wanting exactly this when i told him what i had done to my game via mods, and i figured if it was already packaged why not share it? and because this is basically just MY version of the game, at some point down the road, as i update individual mods and tweak piecemeal as i go, i will have made enough changes to justify repacking it for my friend again.  (and actually, despite my modding noobishness, i've been fixing a fair few bugs as i go XD)

still have a lot of work to do before it is ready to share with my friend, never mind anyone else. but perhaps a compromise could be reached on a release here? there are a LOT of mods i have bashed together now. which means seeking permission from a LOT of people. would a certain threshold of explicit permission be acceptable? say 60%, with conditions that i actively try to expand the list of those who have given consent (i expect getting a hold of most of the authors to be the real hurdle), and that anything an author asks be removed is done immediately.

edit - tbh, most of what i have done so far, aside from fixing aforementioned bugs, was making sure each empire's color was distinct enough i could remove secondary segments entirely, normalizing naming conventions, and allowing them to interact with the other mods content (such as making sure most places outlaw hazard mining's red water).
Spoiler
(https://i.imgur.com/7CtaJvR.png)
[close]
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on April 12, 2024, 06:57:13 PM
No worries, you're not being rude at all, and I appreciate the clarification!

Just had a quick look and unfortunately this isn't trivial on my end. There's getCrew() and getMarines() methods, and iirc the sum of those is what gets used, and lots of places assume that getCrew() returns the actual crew-commodity-count. And then there's the crew/marine counts shown in the lower left in the campaign, etc. It's just - things like this, that vanilla does not use, are pretty hard to add without bugs and/or breaking them later (and not noticing, due to not having a vanilla use case). It'd need to be absolutely trivial, and this isn't.
a question/request about that actually
is it likely, or even possible, sometime in the future, that scripted interactions check for demand class amount, instead of a specific commodity by name?
there is already such a column in the commodities.csv, but from my (frankly limited) investigation, it is not used for anything _but_ market economy
changing - or even allowing to - check for demand class in, say, salvage dialog, would allow to supply both vanilla crew, and also anything that has "crew" as demand class
i mean purely concerning vanilla game usage
that "crew replacement" mod exists, but the way it is implemented makes me apprehensive to touch it, and frankly, this should've been a thing along time ago in vanilla anyway
sorry for being presumptious, but since the issue is already being raised, might as well throw in my own frustration with it
just
missed opportunity, it feels like
one that would take way too much work to rectify, on account of it's cause being buried deep in the obfuscated code
(https://i.imgur.com/FSYVnXu.png)
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 12, 2024, 09:11:53 PM
that "crew replacement" mod exists, but the way it is implemented makes me apprehensive to touch it, and frankly, this should've been a thing along time ago in vanilla anyway
hello! it is me, the crew replacer developer.
I know this question is not for me, but i feel the need to ask a question. for my own peace of mind if nothing else.
you mention being uncomfortable with the way crew replacer is implemented, would you be willing to give me some examples of things that worry you about my mod? I do try to make sure its as accessible and stable as possible (with some failures in that regard every now and then, i admit) and as such would like your opinion on whats worrying you about it.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: bananana on April 13, 2024, 05:15:47 AM
you mention being uncomfortable with the way crew replacer is implemented...
mainly the fact that it requires to jump through extra hoops to add a commodity reskin, it works only for crew, and it doesn't address the fundamental cause for it's existence, rather it does a roundabout shenanigans to "catch" the crew consumption event and process it with alternative commodity
(if i understand what it does properly)
way too complicated solution for a simple issue that i would deem unsolvable otherwise.
i mean from a modmaker perspective.
i wouldn't give a second thought adding it to playthrough if someone else's mod required it
but i am apprehensive to tie my own mod to it, despite it fulfilling a crucial feature that i need, simply because i don't want to deal with issues i cannot understand.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: alaricdragon on April 13, 2024, 09:09:22 AM
ok, so there are a few misconceptions about my mods function and integration here. so im going to try and address them one by one. please feel free to correct me if i didn't understand what you were saying when i try to address things, as i am very tired and dont function the best well tired.

the fact that it requires to jump through extra hoops to add a commodity reskin
I suppose it does require one to jump a few hops, to add the library, and read the documentation and what not. but i fail to see how i could make it simpler. but i would be willing to hear any suggestions to have on ways i could make it more accessible.

it works only for crew
crew replacer works for any commodity I can get my grabby little hands on, in any event i can find a way to edit. not just for crew. the name 'crew replacer' is kind of a relic from when i was first developing the mod, as back then my primary objective was to have it effect crew. i didn't know at the time how simple it would be to replace every commodity with crew replacers functionality.

it doesn't address the fundamental cause for it's existence, rather it does a roundabout shenanigans to "catch" the crew consumption event and process it with alternative commodity
this is not correct, but i understand your confusion, given the name
crew replacer does not simply swap one commodity for another. rather, it replaces the commodity for a something i call a 'job' (please note: each events commodity has its own 'job', so one can customize things more) (a 'job' is basically just a list of commodity's (although they can be other things. but that's something i would need to create a tutorial for), and how good they are at replacing the replaced commodity at this task). it uses the combined 'power' of everything in said 'job' when deterring how mush of the replaced commodity you have, and running through a complicated equation to determine what is lost, and in what numbers.
how losses are calculated (copied from a post on AI-Retrofits from like a year ago or something. some info here is out of date (I think i describe priority backwards, for example) but it explains how losses work well))
Quote
Order of losses for drones vs humans
order of losses is kind of complicated, and the current version might have the priority set wrong. so here how it should work though:
first crew replacer gets the crew a job wants, so if it wants 45 crew to salvage something, and you have 300 'crew' and 40 'salvage robots',
it will look at the priority for both ('crew' = 10 and 'salvage robots' = 9) and try to get the 'required crew' in order of best priority to worst.
(so 40 'salvage robots' and 5 'crew')
if you had more 'salvage robots' then 'required crew', it would only call 'salvage robots'.
if 'crew' had a lower priority then 'savage robots', it would call 'crew' first, and because there is more 'crew' then 'required crew', it would call only 'crew'.
if 'crew' and 'salvage robots' had the same priority, it would try to get random 'crew' and 'salvage robots' using some math that acts like all the available crews were picking straws.

now how this relates to crew losses:
when calculating crew losses, the code looks at the crew used in a job example: (40 'salvage robots' and 5 'crew') then randomly try's to get crew losses using the 'drawing straws' math thing, using crew used in the job as who draws the straws. so in this case, it would be 8X more likely to loss a 'salvage robot' then a 'crew' (there is 8x more 'salvage robots' then 'crew'), but it would still be random, if that makes sense. so there is a change that you would lose all 5 'crew' anyways. or would lose only 'salvage robots', even if you were set to lose 40 crew.

both the loses and crew for job functions are also effected by something called power. think of it as a multiplier for how mush each unit is work in calculations. but 'salvage drones' and 'crew' have the same power, so it dose not matter here.
[close]

way too complicated solution for a simple issue that i would deem unsolvable otherwise.
again, i try to keep things as simple as possible one can for example, add a 'crew' to a 'job' (or to all 'jobs' that replace a certain commodity) with a single line of code.
example i gave someone else
in the 'onApplicationLoad()' function
'crewReplacer_Main.getJob("job name goes here").addNewCrew("the commodity id of you crew",power,defence,priority);'
what all the stats do
   "job name goes here" is the jobID that you want this crew to do. i have a list of them somewere ask me about it.
   "the commodity id of you crew" is the commodityID of your crew. this should be a thing after step 1.
   power is how strong your crew is. 1 is the default.
   defence is how many losses your crew tends to take. the default is 1.
   priority is what order your crew is used in. higher numbers go first. the default is 10
[close]
[close]

i am apprehensive to tie my own mod to it, despite it fulfilling a crucial feature that i need, simply because i don't want to deal with issues i cannot understand
I can understand this, as its always a risk. crew replacer is inherently difficult to test and make function at all (on my end. i make sure users of crew replacer can do things as easily as possible (although who knows if i succeed.)) do to the fact that i as a modder cant access all the base games code. making it extremely difficult to replace some events code.

if you ever decide that you want to utilize crew replacer, but don't want to make it a 'dependency' you can do the following:
1) create a class and make all your crew replacer code run there.
2) were ever you would put your 'crew replacer' code, run if(Global.getSettings().getModManager().isModEnabled("aaacrew_replacer")){ class.function()}
this should make it so you can have whatever crew replacer jobs you want if crew replacer is enabled, and should prevent crashes from missing a imported class (provided crew replacer is only called in this class)
(if you try this and doing so causes a crash when crew replacer is not installed, I might have misremembered. send me a message and i will amend my words)


ok, i think i addressed everything i saw here. I hope im not missing the point though. I also hope my words were understandable. i can struggle to exsplain myself sometimes.
have yourself a good day
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 13, 2024, 12:03:47 PM
a question/request about that actually
is it likely, or even possible, sometime in the future, that scripted interactions check for demand class amount, instead of a specific commodity by name?

Extremely unlikely! I'd say just flat out never except never say never. It's just a needless complication for vanilla; I appreciate that it limits somewhat what mods can *easily* do but there's no way I can justify dumping all these extra checks in vanilla. It probably wouldn't work anyway, due to a lack of vanilla use cases.

but perhaps a compromise could be reached on a release here? there are a LOT of mods i have bashed together now. which means seeking permission from a LOT of people. would a certain threshold of explicit permission be acceptable? say 60%, with conditions that i actively try to expand the list of those who have given consent (i expect getting a hold of most of the authors to be the real hurdle), and that anything an author asks be removed is done immediately.

Ah, getting permission from other people to use and redistribute their stuff just does not work like that.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on April 13, 2024, 02:50:21 PM
where are contact types located? the stelnet mod wont display contacts without a 'type', and the legio contact in tahlan doesnt have one making the interactions with stelnet odd. i assume it is just a tag somewhere, but i wasnt able to locate it.

edit - another question; if i add the line "tags":"no_dealer" to a skin file, why doesnt it prevent arms dealers from letting you build them?
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Great Wound on April 17, 2024, 09:53:18 AM
Is there a way to unlock hullmods when starting a new game in rules.csv? Been taking a prod and a probe but I can't seem to find a way.

I've got a workaround; I can create a dummy "npc_only" skill that unlocks the hullmod and unlock that skill using "NGCSetSkill", but I was hoping for something a little more clean and direct.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 17, 2024, 11:01:35 AM
where are contact types located? the stelnet mod wont display contacts without a 'type', and the legio contact in tahlan doesnt have one making the interactions with stelnet odd. i assume it is just a tag somewhere, but i wasnt able to locate it.

Tags.CONTACT_MILITARY etc.

edit - another question; if i add the line "tags":"no_dealer" to a skin file, why doesnt it prevent arms dealers from letting you build them?

"tags" needs to be a json array. E.G. ["no_dealer"]


Is there a way to unlock hullmods when starting a new game in rules.csv? Been taking a prod and a probe but I can't seem to find a way.

I've got a workaround; I can create a dummy "npc_only" skill that unlocks the hullmod and unlock that skill using "NGCSetSkill", but I was hoping for something a little more clean and direct.

See the NGCAddStandardStartingScript command for an example that adds a custom script that can do pretty much anything after the game starts.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Stormy Fairweather on April 17, 2024, 06:28:08 PM
thanks alex. appreciate ya taking the time to answer my inane questions
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on April 17, 2024, 07:41:10 PM
Hiya, hope you're having a good one

I am implementing a custom travel drive that can move ships offscreen and warp them in very fast. Checks for the presence of ship getCustomData() in the beginning of the apply() function of the drive's stats script, moving it back a significant distance if it does not find the data and adds it after moving the ship.

In the ship_systems.CSV, this Travel Drive uses a 20 second duration, 1 second out/cooldown, and it is NOT a "Toggle" ship system because the ships deactivate the drive very easily (if, say, they are too far out of bounds, or if they pass near a ship, ect).

In short, the script currently works good when the cases where ships are first deployed. Early in combat, with no ships on the board.

However, if the player moves in to assist a friendly ally to fleet, all predeployed allies start with their Travel Drive in the active state (according to debug statements). Various code-based attempts to deactivate it hasn't worked, but I am still trying various ways, and it seems they don't deactivate after a 20 second period either.

My question is, despite all this over-explanation of nonsense, is it possible to get a brief explanation what ships go through of the "steps" feature in CombatEngineAPI().getContext(). And also, how does the travel drive behave during this period - specifically why they do not appear to activate the Out state - that's where I perform the de-phasing of the traveling ships.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: Alex on April 17, 2024, 07:58:05 PM
ShipSystemAPI.deactivate() *should* work, I believe, so that may be worth revisiting. If your ship system code just assumes the 20 second duration and does stuff, that wouldn't be interrupted, though, so depending on how it's implemented... well, it's just hard to say.
Title: Re: Misc modding questions that are too minor to warrant their own thread
Post by: FasterThanSleepyfish on April 18, 2024, 12:17:15 AM
ShipSystemAPI.deactivate() *should* work, I believe, so that may be worth revisiting. If your ship system code just assumes the 20 second duration and does stuff, that wouldn't be interrupted, though, so depending on how it's implemented... well, it's just hard to say.

Thank you!! The ship.getTravelDrive().deactivate() methodology worked, BUT yes it must only be called after the GFX/final exit from warp is executed. Appreciate the help!  :-X

crimescene
Code: java
public class fed_TravelDriveStats extends BaseShipSystemScript {

    public static Logger log = Global.getLogger(fed_TravelDriveStats.class);

    @Override
    public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {

        //ShipAPI ship = null;
        CombatEngineAPI engine = Global.getCombatEngine();

        if (engine == null) {
            return;
        }
        if (engine.isPaused()) {
            //return;
        }

        Boolean validPlayerShip = false;
        // We can get ship APIs from a MutableShipStatAPI using getEntity()
        if (stats.getEntity() instanceof ShipAPI) { // Needed? maybe not, but I didn't touch bc im lazy
            ShipAPI ship = (ShipAPI) stats.getEntity();
           
            // Magic-ish number, will use later to make escaping fleets spawn inside the map (if they are far OoB, they autoescape)
            float retreatNerfMult = 0.05f;

            // We want ships to warp in from offscreen when deployed
           
            // We only want do this for newly deployed ships once.
            // So we will use some custom data (or lack thereof) to make sure the move-back is a one-off
           
            // Reminder: ship_systems.csv matters a lot to this travel drive. It runs on strict 20sec intervals
            // so that unfortunately means there are a few magic numbers here that mostly make it work as intended.
            // literally ill-advised modifications hullmod, but in IRL

            // Look for custom data tag to prevent double move-backs.
            // We will insert it once we move the ship back, but simply run stat changes/gfx if we see it.
            if (!ship.getCustomData().containsKey(id)) {

                // DEBUG
                /*log.info(
                        "Moving back - Ship ID: " + ship.getId()
                        + " | Ship FMID: " + ship.getFleetMemberId()
                        + " | Ship TimeDeployed: " + ship.getFullTimeDeployed()
                        + " | Ship Name: " + ship.getName());
               
                    for ( Object value : ship.getCustomData().values()) {
                    log.info(value.toString());
                    }

                log.info("Esc Dburn Dur " + engine.getContext().getEscapeDeploymentBurnDuration());
                    log.info("Flank Dburn Dist " + engine.getContext().getFlankDeploymentDistance());
                    log.info("Init Dburn Dur " + engine.getContext().getInitialDeploymentBurnDuration());
                    log.info("Init Esc Range " + engine.getContext().getInitialEscapeRange());
                    log.info("Init Num Step " + engine.getContext().getInitialNumSteps());
                    log.info("Init Step Size " + engine.getContext().getInitialStepSize());
                    log.info("Stdoff range " + engine.getContext().getStandoffRange());
                    log.info("Norm Dburn Dur " + engine.getContext().getNormalDeploymentBurnDuration());
                    log.info("Other goal " + engine.getContext().getOtherGoal());
                    log.info("player goal " + engine.getContext().getPlayerGoal());*/
               
               
                // Look for burn duration for new ships depending on battle context.
                // It appears ships don't ALWAYS burn in from offscreen, ex) they are being pursued and start in the lower area
                // or are pushed up to reinforce a station. Still WIP determination through playtesting.
               
                // First magic number. Gotta test via debugging printing log messages in all the various combat situations.
                // I think it's usually 1.5f? NormalDeploymentBurn is 6, and EscapeDeploymentBurn is 1.5 as well.
                // Don't quote me on that though
                float initalBurnSeconds = engine.getContext().getInitialDeploymentBurnDuration();
               
                // Second magic number, correlating with ship_system.csv's ACTIVE time for this travel drive.
                // Don't ask me why or how it works. Because it kinda doesn't if put under real scrutiny.
                float penalty = 10000f - engine.getMapHeight() * 0.03f;

                // So we need to deal with ships that sometimes CANNOT be moved offscreen, lest they auto-retreat
                // Thus we start with the player escaping.
                if (engine.getContext().getPlayerGoal() != null && engine.getContext().getPlayerGoal().equals(FleetGoal.ESCAPE)) {

                   // Magic number *** for NPC ships, don't make pursing starfed AI hostiles start too close yknow?
                    penalty = penalty - (1000f + engine.getMapHeight() * 0.03f);

                    // But here we make player warp-ins start much closer, but move much slower.
                    // This means they don't run off the map but still work with the 20 second ACTIVE time defined in the csv.
                    if (ship.getOwner() == engine.getPlayerShip().getOwner() || ship.isAlly()) {
                        retreatNerfMult = 0.3333333333f;
                        initalBurnSeconds = engine.getContext().getEscapeDeploymentBurnDuration() * 0.15f;
                        stats.getMaxSpeed().modifyMult(id, retreatNerfMult);
                        //Probably the most unreliable of magic numbers. Doesn't always place it on-point in retreating formations.
                        penalty = penalty * 0.4f - (1200f - engine.getMapHeight() * 0.05f);
                    }

                }
               
                // CASE: Enemy fleet is escaping. We can't move them too far back off the map or they autoretreat.
                if (engine.getContext().getOtherGoal() != null && engine.getContext().getOtherGoal().equals(FleetGoal.ESCAPE)) {
                   
                    // Wohoo magic numbers
                    initalBurnSeconds = engine.getContext().getEscapeDeploymentBurnDuration() * 0.15f;

                    if (ship.getOwner() == engine.getPlayerShip().getOwner() || ship.isAlly()) {
                        // What I determined to be the distance that friendly ships will burn to
                        // Even if starfed warping ships rushing past might make them stop halfway. Oops.
                        penalty = penalty - (2000f + engine.getMapHeight() * 0.05f);
                       
                    } else {
                        // this makes them really slow so they can start kinda on the map and not auto retreat.
                        retreatNerfMult = 0.16666666666f;
                        initalBurnSeconds = engine.getContext().getEscapeDeploymentBurnDuration() * 0.15f;
                        stats.getMaxSpeed().modifyMult(id, retreatNerfMult);
                        // A magic number I determined would make them start relatively fairly, like normal retreating ships.
                        penalty = penalty * 0.2f - (1200f - engine.getMapHeight() * 0.03f);
                    }
                }
               
                // We need to know how theoretically far back these ships are moving.
                // So we calcualte the burn time * the mostly-hard speed limit of combat entities, not accounting for time mults.
                float burnDistanceProbablyCovered = ((initalBurnSeconds * 610f));
               
                // Double that for our new burn time, as we will be moving back an additional distance.
                // Honestly these numbers are messed up or don't work at all...
                // They all rely on the 20 second ACTIVE time in the ship_systems.csv, you can't really
                // So you can't make ship travel drives turn on a set amount of time I think.
                float newTimeToBurn = ((initalBurnSeconds));
               
                // log.info("burnDistanceProbablyCovered " + burnDistanceProbablyCovered);
                // log.info("penalty " + penalty);

                // Now we determine what direciton we need to shift the ship "backwards", depending on heading.
                // Pretty sure the center of the map is 0,0 in terms of X, Y, with -X being the left and -Y being the south.
               
                // You can probably do this moveback purely by manipulating vectors... but I am not smart.
                   
                if (ship.getFacing() == 0f) {
                    // Facing 0 means facing to the left, so we add more X value to make it slide right.
                    ship.getLocation().setX(ship.getLocation().getX() - burnDistanceProbablyCovered - (penalty * 1.05f));
                    ship.turnOnTravelDrive(newTimeToBurn);
                   
                } else if (ship.getFacing() == 90f) {
                    // Facing 90 means facing upwards, so we reduce Y value to make the ship go lower
                    ship.getLocation().setY(ship.getLocation().getY() - burnDistanceProbablyCovered - penalty * 0.98f);
                    ship.turnOnTravelDrive();
                   
                } else if (ship.getFacing() == 180f) {
                    // Facing 180 means facing to the right, so we reduce the X value to make it slide left.
                    ship.getLocation().setX(ship.getLocation().getX() + burnDistanceProbablyCovered + (penalty * 1.05f));
                    ship.turnOnTravelDrive(newTimeToBurn);
                   
                } else if (ship.getFacing() == 270f) {
                    // Facing 270 means facing downards, so we add more Y value to make the ship go higher.
                    ship.getLocation().setY(ship.getLocation().getY() + burnDistanceProbablyCovered + penalty * 0.98f );
                    ship.turnOnTravelDrive(newTimeToBurn);
                   
                } else {
                    // If a ship is NOT in a designated facing, make it leave warp via the OUT state.
                    ship.getTravelDrive().forceState(ShipSystemAPI.SystemState.OUT, 0f);
                }
                //}

                // Moving and warping is done, so now we add the data value to ensure it doesn't get moved back again.
               
                // The TRUE value is used to signify the ship has been moved back out of the map.
                // A FALSE value in this custom data entry will prevent a second moveback given the customData exists at all, BUT...
                //   we will assume that FALSE means it has left warp, and FALSE can only be gained from the OUT function.
                // This entire complexity is because those allied ships you can reinforce in battle will have ACTIVE traveldrives
                //   that make them invisible and non-collidable. Unfortunately these ghost ships will remain ghosts because
                //   they refuse to enter the OUT stage unless the ACTIVE code has an exit somehow... hence the initial TRUE
                //   value indicating that the ship has not "left" warping and should probably leave via being forced into the OUT
                //   stage, thereby becoming tangible again and gaining a FALSE data value.
                ship.setCustomData(id, true);
            }

            // Do not keep doing graphics/stat mod stuff when the screen is paused
            if (engine.isPaused()) {
                return;
            }

            if (null != state) {
                switch (state) {
                   
                    case IN: // UNUSED, probably, ship has no "in" time definied in shipsystems.csv
                       
                        ship.setCustomData(id, true);
                        ship.setAlphaMult(1 - 1 * effectLevel);
                        ship.setCollisionClass(CollisionClass.FIGHTER);
                        // If a ship has modules, we need it to fade out/disable fleetshields too.
                        if (ship.isShipWithModules()) {
                            List<ShipAPI> modules = ship.getChildModulesCopy();
                            for (ShipAPI childModule : modules) {
                                childModule.setCollisionClass(CollisionClass.FIGHTER);
                                // Fookin null checks
                                if (childModule.getShield() != null) {
                                    if (childModule.getShield().getType() == (ShieldAPI.ShieldType.FRONT) || (childModule.getShield().getType() == ShieldAPI.ShieldType.OMNI)) {
                                        // Overkill never fails
                                        childModule.getShield().setArc(0f);
                                        childModule.getShield().setRadius(0f);
                                    }
                                }
                                childModule.setAlphaMult(1 - 0.8f * effectLevel);
                            }
                        }
                        // Gee, how come mom lets you have three explosions instead of one!
                        //    ... because I am a master of gfx, that's why.
                        fed_spawnTravelDriveExplosion(stats, ship, effectLevel);
                        fed_spawnTravelDriveExplosion(stats, ship, effectLevel);
                        fed_spawnTravelDriveExplosion(stats, ship, effectLevel);
                        break;

                    case ACTIVE:
                        // Hard to get allies already deployed ( IE you are reinforcing an existing battle ) out of this state.
                        // The if statement immediately below tries to solve that, it disqualifies most ships from using TD.
                        // But you can use the warp drive if retreating.
                        if (ship.getCustomData().get(id).equals(true) && !ship.isRetreating() && ship.getFullTimeDeployed() > 20f) {
                            ship.setCustomData(id, false);
                            effectLevel = 0;
                            ship.getTravelDrive().forceState(ShipSystemAPI.SystemState.OUT, 0f);
                        }

                        // Just make sure we know the ship has warped, cannot tell if it goes through logic above or not.
                        ship.setCustomData(id, true);
                       
                        // Make ship not bonk things when warping.
                        ship.setAlphaMult(1 - 0.9f * effectLevel);
                        ship.setPhased(true);
                        ship.setCollisionClass(CollisionClass.FIGHTER);

                        // Zoom
                        stats.getMaxSpeed().modifyFlat(id, 600f);
                        stats.getAcceleration().modifyFlat(id, 600f);
                       
                        // Only way to make it seem literally FTL, like tesseracts engaging temporal shell
                        stats.getTimeMult().modifyPercent(id, 600 * effectLevel);

                        // Some prerandomized variables to argument size in cosmetic particle calls
                       
                        // RENDER PARTICLES FOR WARPING SHIPS
                        /*ship.addAfterimage(
                            new Color(125, 125, 1, 255), //color
                            MathUtils.getRandomNumberInRange(-5f, 5f), //X Location rel to ship center
                            MathUtils.getRandomNumberInRange(-5f, 5f), //Y Location rel to ship center
                            (stats.getEntity().getVelocity().getX()) * -1f, //X Velocity
                            (stats.getEntity().getVelocity().getY()) * -1f, //Y Velocity
                            5f, //Max Jitter, units of distance
                            0f, //Fade-in time
                            0f, //Regular duration
                            0.5f, //Fade-out time
                            true, //Is Additive (whiteness adds up)
                            true, //Combine with sprite color
                            true); //Above ship
                         */
                        // GD modules need afterimages/no hitbox too waaaah
                        if (ship.isShipWithModules()) {
                            List<ShipAPI> modules = ship.getChildModulesCopy();
                            for (ShipAPI childModule : modules) {
                                childModule.addAfterimage(
                                        new Color(125, 100, 25, 55), //color
                                        MathUtils.getRandomNumberInRange(-5f, 5f), //X Location rel to ship center
                                        MathUtils.getRandomNumberInRange(-5f, 5f), //Y Location rel to ship center
                                        (stats.getEntity().getVelocity().getX()) * -1f, //X Velocity
                                        (stats.getEntity().getVelocity().getY()) * -1f, //Y Velocity
                                        5f, //Max Jitter, units of distance
                                        0f, //Fade-in time
                                        0f, //Regular duration
                                        0.2f, //Fade-out time
                                        true, //Is Additive (whiteness adds up)
                                        true, //Combine with sprite color
                                        true);
                                childModule.setCollisionClass(CollisionClass.FIGHTER);
                                // Morrrre null checks
                                if (childModule.getShield() != null) {
                                    if (childModule.getShield().getType() == (ShieldAPI.ShieldType.FRONT) || (childModule.getShield().getType() == ShieldAPI.ShieldType.OMNI)) {
                                        // Overkill
                                        childModule.getShield().setArc(0f);
                                        childModule.getShield().setRadius(0f);
                                    }
                                }
                                childModule.setAlphaMult(1 - 0.8f * effectLevel);
                            }
                        }
                       
                        // We don't always want to render the warp trail, keeps it lighter
                        fed_spawnTravelDriveWake(stats, ship, effectLevel);
                        break;

                    case OUT:
                        // Hard to trigger this unless forced when with exisiting battles with allies you are reinforcing.
                        // See first lines of code in ACTIVE state contents above.
                       
                        ship.setCustomData(id, false);
                        ship.setPhased(false);
                       
                        stats.getMaxSpeed().unmodify(id);
                        float shipExitSpeed = (stats.getDeceleration().modified) * 10 + ship.getMutableStats().getZeroFluxSpeedBoost().modified;
                        //engine.addFloatingText(ship.getLocation(), "Y: " + ship.getLocation().y, 15f, Color.RED, ship, 1f, 0.5f);
                        if (shipExitSpeed > 500f) {
                            shipExitSpeed = 500f;
                        }

                        if (ship.getHullSize().equals(ShipAPI.HullSize.CAPITAL_SHIP)) {
                            shipExitSpeed = (220f);
                        }

                        ship.getVelocity().scale(shipExitSpeed / (ship.getVelocity().length()));

                        stats.getTimeMult().unmodify(id);
                        ship.setAlphaMult(1 - 0.8f * effectLevel);

                        // Give modules back shields as we come out of warp.
                        //if (ship.getVelocity().length() <= ship.getMaxSpeed()) { //&& ship.getFullTimeDeployed() > 1) {
                        if (ship.isShipWithModules()) {
                            List<ShipAPI> modules = ship.getChildModulesCopy();
                            for (ShipAPI childModule : modules) {
                                if (!childModule.getVariant().hasHullMod("fed_fleetshieldeffect")) {
                                    childModule.setCollisionClass(CollisionClass.SHIP);
                                }
                                childModule.ensureClonedStationSlotSpec();
                                if (childModule.getShield() != null) {
                                    if (childModule.getShield().getType() == (ShieldAPI.ShieldType.FRONT) || (childModule.getShield().getType() == ShieldAPI.ShieldType.OMNI)) {
                                        childModule.getShield().setType(childModule.getHullSpec().getShieldType());
                                        childModule.getShield().setArc(childModule.getHullSpec().getShieldSpec().getArc());
                                        // This doesn't nuke shields because FederationDesign.java sets shield radiuses constantly.
                                        childModule.getShield().setRadius(0f);
                                    }
                                }
                                childModule.setAlphaMult(1f);
                            }
                        }
                       
                        stats.getEntity().setCollisionClass(CollisionClass.SHIP);
                       
                        ship.getTravelDrive().deactivate();
                        fed_spawnTravelDriveExplosion(stats, ship, effectLevel);
                        fed_spawnTravelDriveExplosion(stats, ship, effectLevel);
                        fed_spawnTravelDriveExplosion(stats, ship, effectLevel);
                       
                        // Immediate sound based on nearby arrivals
                        Global.getSoundPlayer().playSound(ship.getTravelDrive().getSpecAPI().getOutOfUsesSound(), 1, 1, ship.getLocation(), new Vector2f(0f, 0f));
                        // Faint UI sound for distant arrivals
                        Global.getSoundPlayer().playUISound(ship.getTravelDrive().getSpecAPI().getOutOfUsesSound(), 1, 0.1f);
                        //      }

                        break;

                    default: //Unused

                        break;
                }
            }
           
            /* DEBUGGING           
            log.info(
            " | Ship Name: " + ship.getName()
            + " | Ship TD State: " + ship.getTravelDrive().getState()
            + " | Ship Effect Level: " + ship.getTravelDrive().getEffectLevel()
            + " | Ship TimeDeployed: " + ship.getFullTimeDeployed()
            + " | Combat Time Elapsed: " + engine.getTotalElapsedTime(false)
            + " HAS DATA: " + ship.getCustomData().containsKey(id)
            );*/
        }
    }
@Override
    public void unapply(MutableShipStatsAPI stats, String id
    ) {

        stats.getTimeMult().unmodify(id);
        stats.getMaxSpeed().unmodify(id);
        stats.getAcceleration().unmodify(id);
        stats.getDeceleration().unmodify(id);
        stats.getMaxTurnRate().unmodify(id);
        stats.getMaxTurnRate().unmodify(id);
        stats.getTurnAcceleration().unmodify(id);
        stats.getTurnAcceleration().unmodify(id);
        Global.getCombatEngine().getTimeMult().unmodify(id);
    }
}
[close]